35 #include <vtkCamera.h>
36 #include <vtkRenderer.h>
37 #include <vtkRenderWindow.h>
52 #include "vtkRenderWindowInteractor.h"
66 mView->getRenderWindow()->GetInteractor()->Disable();
67 mView->getRenderer()->GetActiveCamera()->SetParallelProjection(
true);
68 double clipDepth = 1.0;
69 mView->getRenderer()->GetActiveCamera()->SetClippingRange(-clipDepth / 2.0, clipDepth / 2.0);
72 connect(
mServices->video().get(), SIGNAL(activeVideoSourceChanged()),
this, SLOT(connectStream()));
73 connect(
mServices->tracking().get(), SIGNAL(activeToolChanged(QString)),
this, SLOT(connectStream()));
77 this->connectStream();
94 this->connectStream();
97 void ViewWrapperVideo::appendToContextMenu(QMenu& contextMenu)
99 QAction* showSectorAction =
new QAction(
"Show Sector", &contextMenu);
100 showSectorAction->setCheckable(
true);
102 showSectorAction->setChecked(mStreamRep->getShowSector());
103 connect(showSectorAction, SIGNAL(triggered(
bool)),
this, SLOT(showSectorActionSlot(
bool)));
105 contextMenu.addSeparator();
108 QMenu* sourceMenu =
new QMenu(
"Video Source", &contextMenu);
109 std::vector<VideoSourcePtr> sources =
mServices->video()->getVideoSources();
110 this->addStreamAction(
"active", sourceMenu);
111 for (
unsigned i=0; i<sources.size(); ++i)
112 this->addStreamAction(sources[i]->getUid(), sourceMenu);
113 contextMenu.addMenu(sourceMenu);
116 contextMenu.addAction(showSectorAction);
119 void ViewWrapperVideo::showSectorActionSlot(
bool checked)
121 mStreamRep->setShowSector(checked);
125 void ViewWrapperVideo::addStreamAction(QString uid, QMenu* contextMenu)
127 QAction* action =
new QAction(uid, contextMenu);
132 action->setData(QVariant(uid));
133 action->setCheckable(
true);
135 action->setChecked(
mGroupData->getVideoSource()==
"active");
137 action->setChecked(selected && (selected==current));
139 connect(action, SIGNAL(triggered()),
this, SLOT(streamActionSlot()));
140 contextMenu->addAction(action);
143 void ViewWrapperVideo::streamActionSlot()
145 QAction* theAction =
static_cast<QAction*
>(sender());
148 if (!theAction->isChecked())
151 QString uid = theAction->data().toString();
157 this->connectStream();
160 void ViewWrapperVideo::connectStream()
174 uid = source->getUid();
178 if (tool && tool->getProbe())
180 if (tool->getProbe()->getAvailableVideoSources().count(uid))
183 source = tool->getProbe()->getRTSource(uid);
192 this->setupRep(source, newTool);
195 VideoSourcePtr ViewWrapperVideo::getSourceFromService(QString uid)
198 return mServices->video()->getActiveVideoSource();
200 std::vector<VideoSourcePtr> source =
mServices->video()->getVideoSources();
202 for (
unsigned i=0; i< source.size(); ++i)
204 if (source[i]->getUid()==uid)
215 if (( mSource == source )&&( tool==mTool ))
232 mStreamRep.reset(
new VideoFixedPlaneRep(
"rtrep",
"rtrep"));
233 mView->addRep(mStreamRep);
236 mStreamRep->setRealtimeStream(mSource);
237 mStreamRep->setTool(tool);
239 mDataNameText->setText(0, mSource->getName());
240 mStreamRep->setShowSector(
settings()->value(
"showSectorInRTView").toBool());
248 void ViewWrapperVideo::updateSlot()
252 mDataNameText->setText(0, mSource->getName());
255 void ViewWrapperVideo::addReps()
259 mPlaneTypeText->addText(QColor(Qt::green),
"RT",
Vector3D(0.98, 0.02, 0.0));
260 mView->addRep(mPlaneTypeText);
264 mDataNameText->addText(QColor(Qt::green),
"not initialized",
Vector3D(0.02, 0.02, 0.0));
265 mView->addRep(mDataNameText);
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
boost::shared_ptr< class VisServices > VisServicesPtr
virtual ~ViewWrapperVideo()
Superclass for ViewWrappers.
virtual ViewPtr getView()
virtual void videoSourceChangedSlot(QString uid)
boost::shared_ptr< class View > ViewPtr
void setValue(const QString &key, const QVariant &value)
virtual void setViewGroup(ViewGroupDataPtr group)
virtual void setViewGroup(ViewGroupDataPtr group)
ViewGroupDataPtr mGroupData
boost::shared_ptr< class VideoSource > VideoSourcePtr
Settings * settings()
Shortcut for accessing the settings instance.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
static DisplayTextRepPtr New(const QString &uid="")
ViewWrapperVideo(ViewPtr view, VisServicesPtr services)
void connectContextMenu(ViewPtr view)
void newFrame()
emitted when a new frame has arrived (getVtkImageData() returns something new). info/status/name/vali...
boost::shared_ptr< class Tool > ToolPtr