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<StreamerServicePtr> services =
mServices->videoService->getStreamerServices();
121 QWidget* widget = this->createStreamerWidget(service);
124 mStreamerServiceWidgets[service->
getType()] = serviceWidget;
126 this->addServiceToSelector(service);
129 QWidget* VideoConnectionWidget::createStreamerWidget(
StreamerService* service)
133 std::vector<PropertyPtr> adapters = service->
getSettings(element);
137 widget->setObjectName(service->
getType());
138 widget->setFocusPolicy(Qt::StrongFocus);
147 this->removeServiceFromSelector(service);
148 this->removeServiceWidget(service->
getType());
151 void VideoConnectionWidget::addServiceToSelector(
StreamerService *service)
156 range.append(service->
getType());
157 range.removeDuplicates();
164 void VideoConnectionWidget::removeServiceFromSelector(StreamerService *service)
168 int index = range.indexOf(service->getType());
171 range.removeAt(index);
175 void VideoConnectionWidget::removeServiceWidget(QString name)
177 QWidget* serviceWidget = mStreamerServiceWidgets[name];
179 delete serviceWidget;
180 mStreamerServiceWidgets.erase(name);
190 QFrame* frame =
new QFrame(
this);
191 frame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
192 frame->setSizePolicy(frame->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
193 QVBoxLayout* frameLayout =
new QVBoxLayout(frame);
195 frame->setFocusPolicy(Qt::StrongFocus);
202 QWidget* retval =
new QWidget(
this);
203 QVBoxLayout* layout =
new QVBoxLayout(retval);
204 layout->addWidget(input);
205 retval->setObjectName(input->objectName());
206 layout->addStretch();
207 layout->setMargin(0);
208 layout->setSpacing(0);
217 mServices->videoService->setConnectionMethod(name);
219 QWidget* serviceWidget = mStreamerServiceWidgets[name];
229 if (
mServices->videoService->isConnected())
230 mServices->videoService->closeConnection();
232 mServices->videoService->openConnection();
237 QPushButton* connectButton =
new QPushButton(
"Connect",
this);
238 connectButton->setToolTip(
"Connect/disconnect to the video server using the seleted method");
240 return connectButton;
245 QPushButton* importstreamimagebutton =
new QPushButton(
"Import image from stream",
this);
246 importstreamimagebutton->setToolTip(
"Import a single image/volume from the real time stream");
247 importstreamimagebutton->setDisabled(
true);
250 return importstreamimagebutton;
256 if (
mServices->videoService->isConnected())
266 if (!
mServices->videoService->isConnected())
276 videoSource = probe->getProbe()->getRTSource();
280 videoSource =
mServices->videoService->getActiveVideoSource();
287 if (!videoSource->validData())
294 input = videoSource->getVtkImageData();
311 Transform3D tMu = probe->getProbe()->getSector()->get_tMu();
312 Transform3D uMv = probe->getProbe()->getSector()->get_uMv();
313 rMd = rMpr * prMt * tMu * uMv;
320 int* extent = input->GetExtent();
323 if (extent[5] - extent[4] > 0)
324 filename =
"3DRTSnapshot_";
326 filename =
"2DRTSnapshot_";
328 filename += videoSource->getName() + QDateTime::currentDateTime().toString(format);
335 copiedImage->DeepCopy(input);
339 output->get_rMd_History()->setRegistration(rMd);
340 mServices->patientModelService->insertData(output);
342 mServices->visualizationService->autoShowData(output);
343 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())
boost::shared_ptr< class StreamerService > StreamerServicePtr
Abstract class. Interface to Streamers.
boost::shared_ptr< class Tool > ToolPtr