35 #include <boost/bind.hpp>
38 #include <QStackedWidget>
39 #include <QPushButton>
40 #include <QFileDialog>
42 #include "vtkImageData.h"
66 BaseWidget(parent,
"IGTLinkWidget",
"Video Connection"),
71 QString defaultConnection =
mServices->videoService->getConnectionMethod();
95 this->addExistingStreamerServices();
109 void VideoConnectionWidget::addExistingStreamerServices()
111 QList<StreamerService *> services =
mServices->videoService->getStreamerServices();
120 QWidget* widget = this->createStreamerWidget(service);
123 mStreamerServiceWidgets[service->
getName()] = serviceWidget;
125 this->addServiceToSelector(service->
getName());
128 QWidget* VideoConnectionWidget::createStreamerWidget(
StreamerService* service)
130 QString serviceName = service->
getName();
132 std::vector<PropertyPtr> adapters = service->
getSettings(element);
135 widget->
setOptions(serviceName, adapters,
false);
144 this->removeServiceFromSelector(service->
getName());
145 this->removeServiceWidget(service->
getName());
148 void VideoConnectionWidget::addServiceToSelector(QString name)
152 range.removeDuplicates();
156 void VideoConnectionWidget::removeServiceFromSelector(QString name)
159 int index = range.indexOf(name);
162 range.removeAt(index);
166 void VideoConnectionWidget::removeServiceWidget(QString name)
168 QWidget* serviceWidget = mStreamerServiceWidgets[name];
170 delete serviceWidget;
171 mStreamerServiceWidgets.erase(name);
181 QFrame* frame =
new QFrame(
this);
182 frame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
183 frame->setSizePolicy(frame->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
184 QVBoxLayout* frameLayout =
new QVBoxLayout(frame);
192 QWidget* retval =
new QWidget(
this);
193 QVBoxLayout* layout =
new QVBoxLayout(retval);
194 layout->addWidget(input);
195 layout->addStretch();
196 layout->setMargin(0);
197 layout->setSpacing(0);
204 "<h3><Setup IGTLink connection.</h3>"
205 "<p>Lets you set up a connection to a streaming server using IGTLink.</p>"
216 QWidget* serviceWidget = mStreamerServiceWidgets[name];
223 if (
mServices->videoService->isConnected())
224 mServices->videoService->closeConnection();
226 mServices->videoService->openConnection();
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;
250 if (
mServices->videoService->isConnected())
260 if (!
mServices->videoService->isConnected())
270 videoSource = probe->getProbe()->getRTSource();
274 videoSource =
mServices->videoService->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->patientModelService->insertData(output);
336 mServices->visualizationService->autoShowData(output);
337 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
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class Image > ImagePtr
static StringPropertyActiveVideoSourcePtr New()
QString timestampSecondsFormat()
QDomElement getElement()
return the current element
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())
Abstract class. Interface to Streamers.
boost::shared_ptr< class Tool > ToolPtr