35 #include <boost/bind.hpp>
38 #include <QStackedWidget>
39 #include <QPushButton>
40 #include <QFileDialog>
42 #include "vtkImageData.h"
66 BaseWidget(parent,
"IGTLinkWidget",
"Video Connection"),
69 this->setToolTip(
"Connect to a video source");
72 QString defaultConnection =
mServices->videoService->getConnectionMethod();
96 this->addExistingStreamerServices();
110 void VideoConnectionWidget::addExistingStreamerServices()
112 QList<StreamerService *> services =
mServices->videoService->getStreamerServices();
121 QWidget* widget = this->createStreamerWidget(service);
124 mStreamerServiceWidgets[service->
getName()] = serviceWidget;
126 this->addServiceToSelector(service->
getName());
129 QWidget* VideoConnectionWidget::createStreamerWidget(
StreamerService* service)
131 QString serviceName = service->
getName();
133 std::vector<PropertyPtr> adapters = service->
getSettings(element);
136 widget->
setOptions(serviceName, adapters,
false);
137 widget->setObjectName(service->
getType());
138 widget->setFocusPolicy(Qt::StrongFocus);
147 this->removeServiceFromSelector(service->
getName());
148 this->removeServiceWidget(service->
getName());
151 void VideoConnectionWidget::addServiceToSelector(QString name)
155 range.removeDuplicates();
159 void VideoConnectionWidget::removeServiceFromSelector(QString name)
162 int index = range.indexOf(name);
165 range.removeAt(index);
169 void VideoConnectionWidget::removeServiceWidget(QString name)
171 QWidget* serviceWidget = mStreamerServiceWidgets[name];
173 delete serviceWidget;
174 mStreamerServiceWidgets.erase(name);
184 QFrame* frame =
new QFrame(
this);
185 frame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
186 frame->setSizePolicy(frame->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
187 QVBoxLayout* frameLayout =
new QVBoxLayout(frame);
189 frame->setFocusPolicy(Qt::StrongFocus);
196 QWidget* retval =
new QWidget(
this);
197 QVBoxLayout* layout =
new QVBoxLayout(retval);
198 layout->addWidget(input);
199 retval->setObjectName(input->objectName());
200 layout->addStretch();
201 layout->setMargin(0);
202 layout->setSpacing(0);
212 QWidget* serviceWidget = mStreamerServiceWidgets[name];
222 if (
mServices->videoService->isConnected())
223 mServices->videoService->closeConnection();
225 mServices->videoService->openConnection();
230 QPushButton* connectButton =
new QPushButton(
"Connect",
this);
231 connectButton->setToolTip(
"Connect/disconnect to the video server using the seleted method");
233 return connectButton;
238 QPushButton* importstreamimagebutton =
new QPushButton(
"Import image from stream",
this);
239 importstreamimagebutton->setToolTip(
"Import a single image/volume from the real time stream");
240 importstreamimagebutton->setDisabled(
true);
243 return importstreamimagebutton;
249 if (
mServices->videoService->isConnected())
259 if (!
mServices->videoService->isConnected())
269 videoSource = probe->getProbe()->getRTSource();
273 videoSource =
mServices->videoService->getActiveVideoSource();
280 if (!videoSource->validData())
287 input = videoSource->getVtkImageData();
304 Transform3D tMu = probe->getProbe()->getSector()->get_tMu();
305 Transform3D uMv = probe->getProbe()->getSector()->get_uMv();
306 rMd = rMpr * prMt * tMu * uMv;
313 int* extent = input->GetExtent();
316 if (extent[5] - extent[4] > 0)
317 filename =
"3DRTSnapshot_";
319 filename =
"2DRTSnapshot_";
321 filename += videoSource->getName() + QDateTime::currentDateTime().toString(format);
328 copiedImage->DeepCopy(input);
332 output->get_rMd_History()->setRegistration(rMd);
333 mServices->patientModelService->insertData(output);
335 mServices->visualizationService->autoShowData(output);
336 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
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