14 #include <boost/bind.hpp> 17 #include <QStackedWidget> 18 #include <QPushButton> 19 #include <QFileDialog> 21 #include "vtkImageData.h" 47 BaseWidget(parent,
"igt_link_widget",
"Video Connection"),
50 this->setToolTip(
"Connect to a video source");
53 QString defaultConnection =
mServices->video()->getConnectionMethod();
77 this->addExistingStreamerServices();
91 void VideoConnectionWidget::addExistingStreamerServices()
93 QList<StreamerServicePtr> services =
mServices->video()->getStreamerServices();
102 QWidget* widget = this->createStreamerWidget(service);
105 mStreamerServiceWidgets[service->
getType()] = serviceWidget;
107 this->addServiceToSelector(service);
110 QWidget* VideoConnectionWidget::createStreamerWidget(
StreamerService* service)
114 std::vector<PropertyPtr> adapters = service->
getSettings(element);
118 widget->setObjectName(service->
getType());
119 widget->setFocusPolicy(Qt::StrongFocus);
128 this->removeServiceFromSelector(service);
129 this->removeServiceWidget(service->
getType());
132 void VideoConnectionWidget::addServiceToSelector(
StreamerService *service)
137 range.append(service->
getType());
138 range.removeDuplicates();
145 void VideoConnectionWidget::removeServiceFromSelector(
StreamerService *service)
149 int index = range.indexOf(service->
getType());
152 range.removeAt(index);
156 void VideoConnectionWidget::removeServiceWidget(QString name)
158 QWidget* serviceWidget = mStreamerServiceWidgets[name];
160 delete serviceWidget;
161 mStreamerServiceWidgets.erase(name);
171 QFrame* frame =
new QFrame(
this);
172 frame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
173 frame->setSizePolicy(frame->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
174 QVBoxLayout* frameLayout =
new QVBoxLayout(frame);
176 frame->setFocusPolicy(Qt::StrongFocus);
183 QWidget* retval =
new QWidget(
this);
184 QVBoxLayout* layout =
new QVBoxLayout(retval);
185 layout->addWidget(input);
186 retval->setObjectName(input->objectName());
187 layout->addStretch();
188 layout->setMargin(0);
189 layout->setSpacing(0);
198 mServices->video()->setConnectionMethod(name);
200 QWidget* serviceWidget = mStreamerServiceWidgets[name];
218 QPushButton* connectButton =
new QPushButton(
"Connect",
this);
219 connectButton->setToolTip(
"Connect/disconnect to the video server using the seleted method");
221 return connectButton;
226 QPushButton* importstreamimagebutton =
new QPushButton(
"Import image from stream",
this);
227 importstreamimagebutton->setToolTip(
"Import a single image/volume from the real time stream");
228 importstreamimagebutton->setDisabled(
true);
231 return importstreamimagebutton;
257 videoSource = probe->getProbe()->getRTSource();
261 videoSource =
mServices->video()->getActiveVideoSource();
268 if (!videoSource->validData())
275 input = videoSource->getVtkImageData();
292 Transform3D tMu = probe->getProbe()->getSector()->get_tMu();
293 Transform3D uMv = probe->getProbe()->getSector()->get_uMv();
294 rMd = rMpr * prMt * tMu * uMv;
301 int* extent = input->GetExtent();
304 if (extent[5] - extent[4] > 0)
305 filename =
"3DRTSnapshot_";
307 filename =
"2DRTSnapshot_";
309 filename += videoSource->getName() + QDateTime::currentDateTime().toString(format);
316 copiedImage->DeepCopy(input);
320 output->get_rMd_History()->setRegistration(rMd);
321 mServices->patient()->insertData(output);
324 report(QString(
"Saved snapshot %1 from active video source").arg(output->getName()));
cxResource_EXPORT ProfilePtr profile()
boost::shared_ptr< class StringPropertyActiveVideoSource > StringPropertyActiveVideoSourcePtr
boost::shared_ptr< class VisServices > VisServicesPtr
virtual void setVtkImageData(const vtkImageDataPtr &data, bool resetTransferFunctions=true)
virtual std::vector< PropertyPtr > getSettings(QDomElement root)=0
virtual QString getType() const =0
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class Image > ImagePtr
QString timestampSecondsFormat()
QDomElement getElement()
return the current element
static StringPropertyActiveVideoSourcePtr create(VideoServicePtr service)
void reportWarning(QString msg)
boost::shared_ptr< class VideoSource > VideoSourcePtr
virtual QString getName()=0
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
boost::shared_ptr< class StreamerService > StreamerServicePtr
Abstract class. Interface to Streamers.
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr