35 #include <boost/bind.hpp> 38 #include <QStackedWidget> 39 #include <QPushButton> 40 #include <QFileDialog> 42 #include "vtkImageData.h" 68 BaseWidget(parent,
"igt_link_widget",
"Video Connection"),
71 this->setToolTip(
"Connect to a video source");
74 QString defaultConnection =
mServices->video()->getConnectionMethod();
98 this->addExistingStreamerServices();
112 void VideoConnectionWidget::addExistingStreamerServices()
114 QList<StreamerServicePtr> services =
mServices->video()->getStreamerServices();
123 QWidget* widget = this->createStreamerWidget(service);
126 mStreamerServiceWidgets[service->
getType()] = serviceWidget;
128 this->addServiceToSelector(service);
131 QWidget* VideoConnectionWidget::createStreamerWidget(
StreamerService* service)
135 std::vector<PropertyPtr> adapters = service->
getSettings(element);
139 widget->setObjectName(service->
getType());
140 widget->setFocusPolicy(Qt::StrongFocus);
149 this->removeServiceFromSelector(service);
150 this->removeServiceWidget(service->
getType());
153 void VideoConnectionWidget::addServiceToSelector(
StreamerService *service)
158 range.append(service->
getType());
159 range.removeDuplicates();
166 void VideoConnectionWidget::removeServiceFromSelector(
StreamerService *service)
170 int index = range.indexOf(service->
getType());
173 range.removeAt(index);
177 void VideoConnectionWidget::removeServiceWidget(QString name)
179 QWidget* serviceWidget = mStreamerServiceWidgets[name];
181 delete serviceWidget;
182 mStreamerServiceWidgets.erase(name);
192 QFrame* frame =
new QFrame(
this);
193 frame->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
194 frame->setSizePolicy(frame->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
195 QVBoxLayout* frameLayout =
new QVBoxLayout(frame);
197 frame->setFocusPolicy(Qt::StrongFocus);
204 QWidget* retval =
new QWidget(
this);
205 QVBoxLayout* layout =
new QVBoxLayout(retval);
206 layout->addWidget(input);
207 retval->setObjectName(input->objectName());
208 layout->addStretch();
209 layout->setMargin(0);
210 layout->setSpacing(0);
219 mServices->video()->setConnectionMethod(name);
221 QWidget* serviceWidget = mStreamerServiceWidgets[name];
239 QPushButton* connectButton =
new QPushButton(
"Connect",
this);
240 connectButton->setToolTip(
"Connect/disconnect to the video server using the seleted method");
242 return connectButton;
247 QPushButton* importstreamimagebutton =
new QPushButton(
"Import image from stream",
this);
248 importstreamimagebutton->setToolTip(
"Import a single image/volume from the real time stream");
249 importstreamimagebutton->setDisabled(
true);
252 return importstreamimagebutton;
278 videoSource = probe->getProbe()->getRTSource();
282 videoSource =
mServices->video()->getActiveVideoSource();
289 if (!videoSource->validData())
296 input = videoSource->getVtkImageData();
313 Transform3D tMu = probe->getProbe()->getSector()->get_tMu();
314 Transform3D uMv = probe->getProbe()->getSector()->get_uMv();
315 rMd = rMpr * prMt * tMu * uMv;
322 int* extent = input->GetExtent();
325 if (extent[5] - extent[4] > 0)
326 filename =
"3DRTSnapshot_";
328 filename =
"2DRTSnapshot_";
330 filename += videoSource->getName() + QDateTime::currentDateTime().toString(format);
337 copiedImage->DeepCopy(input);
341 output->get_rMd_History()->setRegistration(rMd);
342 mServices->patient()->insertData(output);
345 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