21 #include "boost/bind.hpp" 23 #include <vtkRenderer.h> 24 #include <vtkActor2D.h> 26 #include <vtkCamera.h> 44 mRTGraphics->setShowInToolSpace(
false);
45 mRTGraphics->setClipToSector(
false);
47 mInfoText.reset(
new TextDisplay(
"", QColor::fromRgbF(1.0, 0.8, 0.0), 16));
48 mInfoText->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
49 mInfoText->setCentered();
50 mInfoText->setPosition(0.5, 0.05);
52 mStatusText.reset(
new TextDisplay(
"", QColor::fromRgbF(1.0, 0.8, 0.0), 20));
53 mStatusText->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
54 mStatusText->setCentered();
55 mStatusText->setPosition(0.5, 0.5);
56 mStatusText->updateText(
"Not Connected");
58 mOrientationVText.reset(
new TextDisplay(
"V", QColor::fromRgbF(1.0, 0.9, 0.0), 30));
59 mOrientationVText->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
60 mOrientationVText->setCentered();
61 mOrientationVText->setPosition(0.05, 0.95);
64 mProbeOrigin->setColor(
Vector3D(1, 165.0/255.0, 0));
66 mProbeSector->setColor(
Vector3D(1, 165.0/255.0, 0));
68 mProbeClipRect->setColor(
Vector3D(1, 0.9, 0));
71 mViewportListener->setCallback(boost::bind(&VideoFixedPlaneRep::setCamera,
this));
89 void VideoFixedPlaneRep::updateSector()
93 mProbeOrigin->getActor()->SetVisibility(show);
94 mProbeSector->getActor()->SetVisibility(show);
95 mProbeClipRect->getActor()->SetVisibility(show);
99 mProbeDefinition.
setData(mTool->getProbe()->getProbeDefinition());
108 mRTGraphics->setTool(tool);
115 mRTGraphics->setRealtimeStream(data);
118 void VideoFixedPlaneRep::newDataSlot()
123 mInfoText->updateText(mData->getInfoString());
124 mStatusText->updateText(mData->getStatusString());
125 mStatusText->getActor()->SetVisibility(!mData->validData());
126 mOrientationVText->getActor()->SetVisibility(mData->validData());
128 this->updateSector();
135 void VideoFixedPlaneRep::setCamera()
139 mViewportListener->stopListen();
140 vtkCamera* camera = mRenderer->GetActiveCamera();
141 camera->ParallelProjectionOn();
142 mRenderer->ResetCamera();
145 if (
similar(bounds.range()[0], 0.0) ||
similar(bounds.range()[1], 0.0))
148 double* vpRange = mRenderer->GetAspect();
150 double vw = vpRange[0];
151 double vh = vpRange[1];
153 double w = bounds.range()[0];
154 double h = bounds.range()[1];
157 double w_vp = vh * (w/h);
163 camera->GetPosition(position);
164 position[0] = bounds.center()[0];
165 position[1] = bounds.center()[1];
166 camera->SetPosition(position);
168 camera->GetFocalPoint(position);
169 position[0] = bounds.center()[0];
170 position[1] = bounds.center()[1];
171 camera->SetFocalPoint(position);
173 camera->SetParallelScale(h/2*scale*1.01);
174 mViewportListener->startListen(mRenderer);
180 mRenderer = view->getRenderer();
181 mViewportListener->startListen(mRenderer);
183 view->getRenderer()->AddActor(mRTGraphics->getActor());
184 view->getRenderer()->AddActor(mInfoText->getActor());
185 view->getRenderer()->AddActor(mStatusText->getActor());
186 view->getRenderer()->AddActor(mOrientationVText->getActor());
188 mProbeClipRect->setRenderer(view->getRenderer());
189 mProbeOrigin->setRenderer(view->getRenderer());
190 mProbeSector->setRenderer(view->getRenderer());
196 view->getRenderer()->RemoveActor(mRTGraphics->getActor());
197 view->getRenderer()->RemoveActor(mInfoText->getActor());
198 view->getRenderer()->RemoveActor(mStatusText->getActor());
199 view->getRenderer()->RemoveActor(mOrientationVText->getActor());
200 mProbeOrigin->setRenderer(NULL);
201 mProbeSector->setRenderer(NULL);
202 mProbeClipRect->setRenderer(NULL);
204 mViewportListener->stopListen();
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
bool getShowSector() const
VideoFixedPlaneRep(const QString &uid, const QString &name="")
void setTool(ToolPtr tool)
void setRealtimeStream(VideoSourcePtr data)
virtual void addRepActorsToViewRenderer(ViewPtr view)
boost::shared_ptr< class View > ViewPtr
Listens to changes in viewport and camera matrix.
Helper class for displaying a VideoSource.
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
Helper for rendering a a polydata in 3D.
vtkPolyDataPtr getSectorSectorOnlyLinesOnly()
get a polydata representation of the us sector
virtual ~VideoFixedPlaneRep()
Helper for drawing text in 2D.
boost::shared_ptr< class VideoSource > VideoSourcePtr
vtkPolyDataPtr getClipRectLinesOnly()
get a polydata representation of the us clip rect
Default implementation of Rep.
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
void setShowSector(bool on)
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
vtkPolyDataPtr getOriginPolyData()
get a polydata representation of the origin
void setData(ProbeDefinition data)
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr