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"),
49 mUpdateConnectionInService(true)
51 this->setToolTip(
"Connect to a video source");
54 QString defaultConnection =
mServices->video()->getConnectionMethod();
79 this->addExistingStreamerServices();
94 void VideoConnectionWidget::addExistingStreamerServices()
96 QList<StreamerServicePtr> services =
mServices->video()->getStreamerServices();
105 QWidget* widget = this->createStreamerWidget(service);
108 mStreamerServiceWidgets[service->
getType()] = serviceWidget;
110 this->addServiceToSelector(service);
113 QWidget* VideoConnectionWidget::createStreamerWidget(
StreamerService* service)
117 std::vector<PropertyPtr> adapters = service->
getSettings(element);
121 widget->setObjectName(service->
getType());
122 widget->setFocusPolicy(Qt::StrongFocus);
131 this->removeServiceFromSelector(service);
132 this->removeServiceWidget(service->
getType());
135 void VideoConnectionWidget::addServiceToSelector(
StreamerService *service)
140 range.append(service->
getType());
141 range.removeDuplicates();
148 void VideoConnectionWidget::removeServiceFromSelector(StreamerService *service)
152 int index = range.indexOf(service->getType());
155 range.removeAt(index);
159 void VideoConnectionWidget::removeServiceWidget(QString name)
161 QWidget* serviceWidget = mStreamerServiceWidgets[name];
163 delete serviceWidget;
164 mStreamerServiceWidgets.erase(name);
174 QFrame* frame =
new QFrame(
this);
175 frame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
176 frame->setSizePolicy(frame->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
177 QVBoxLayout* frameLayout =
new QVBoxLayout(frame);
179 frame->setFocusPolicy(Qt::StrongFocus);
186 QWidget* retval =
new QWidget(
this);
187 QVBoxLayout* layout =
new QVBoxLayout(retval);
188 layout->addWidget(input);
189 retval->setObjectName(input->objectName());
190 layout->addStretch();
191 layout->setMargin(0);
192 layout->setSpacing(0);
201 if(mUpdateConnectionInService)
202 mServices->video()->setConnectionMethod(name);
203 mUpdateConnectionInService =
true;
205 QWidget* serviceWidget = mStreamerServiceWidgets[name];
215 QString changedConnectionMethod =
mServices->video()->getConnectionMethod();
217 this->mUpdateConnectionInService =
false;
231 QPushButton* connectButton =
new QPushButton(
"Connect",
this);
232 connectButton->setToolTip(
"Connect/disconnect to the video server using the seleted method");
234 return connectButton;
239 QPushButton* importstreamimagebutton =
new QPushButton(
"Import image from stream",
this);
240 importstreamimagebutton->setToolTip(
"Import a single image/volume from the real time stream");
241 importstreamimagebutton->setDisabled(
true);
244 return importstreamimagebutton;
270 videoSource = probe->getProbe()->getRTSource();
274 videoSource =
mServices->video()->getActiveVideoSource();
281 if (!videoSource->validData())
288 input = videoSource->getVtkImageData();
305 Transform3D tMu = probe->getProbe()->getSector()->get_tMu();
306 Transform3D uMv = probe->getProbe()->getSector()->get_uMv();
307 rMd = rMpr * prMt * tMu * uMv;
314 int* extent = input->GetExtent();
317 if (extent[5] - extent[4] > 0)
318 filename =
"3DRTSnapshot_";
320 filename =
"2DRTSnapshot_";
322 filename += videoSource->getName() + QDateTime::currentDateTime().toString(format);
329 copiedImage->DeepCopy(input);
333 output->get_rMd_History()->setRegistration(rMd);
334 mServices->patient()->insertData(output);
337 report(QString(
"Saved snapshot %1 from active video source").arg(output->getName()));