42 #include "boost/bind.hpp" 44 #include <vtkRenderer.h> 45 #include <vtkActor2D.h> 47 #include <vtkCamera.h> 65 mRTGraphics->setShowInToolSpace(
false);
66 mRTGraphics->setClipToSector(
false);
68 mInfoText.reset(
new TextDisplay(
"", QColor::fromRgbF(1.0, 0.8, 0.0), 16));
69 mInfoText->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
70 mInfoText->setCentered();
71 mInfoText->setPosition(0.5, 0.05);
73 mStatusText.reset(
new TextDisplay(
"", QColor::fromRgbF(1.0, 0.8, 0.0), 20));
74 mStatusText->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
75 mStatusText->setCentered();
76 mStatusText->setPosition(0.5, 0.5);
77 mStatusText->updateText(
"Not Connected");
79 mOrientationVText.reset(
new TextDisplay(
"V", QColor::fromRgbF(1.0, 0.9, 0.0), 30));
80 mOrientationVText->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
81 mOrientationVText->setCentered();
82 mOrientationVText->setPosition(0.05, 0.95);
85 mProbeOrigin->setColor(
Vector3D(1, 165.0/255.0, 0));
87 mProbeSector->setColor(
Vector3D(1, 165.0/255.0, 0));
89 mProbeClipRect->setColor(
Vector3D(1, 0.9, 0));
92 mViewportListener->setCallback(boost::bind(&VideoFixedPlaneRep::setCamera,
this));
102 this->updateSector();
110 void VideoFixedPlaneRep::updateSector()
114 mProbeOrigin->getActor()->SetVisibility(show);
115 mProbeSector->getActor()->SetVisibility(show);
116 mProbeClipRect->getActor()->SetVisibility(show);
120 mProbeDefinition.
setData(mTool->getProbe()->getProbeDefinition());
129 mRTGraphics->setTool(tool);
136 mRTGraphics->setRealtimeStream(data);
139 void VideoFixedPlaneRep::newDataSlot()
144 mInfoText->updateText(mData->getInfoString());
145 mStatusText->updateText(mData->getStatusString());
146 mStatusText->getActor()->SetVisibility(!mData->validData());
147 mOrientationVText->getActor()->SetVisibility(mData->validData());
149 this->updateSector();
156 void VideoFixedPlaneRep::setCamera()
160 mViewportListener->stopListen();
161 vtkCamera* camera = mRenderer->GetActiveCamera();
162 camera->ParallelProjectionOn();
163 mRenderer->ResetCamera();
166 if (
similar(bounds.range()[0], 0.0) ||
similar(bounds.range()[1], 0.0))
169 double* vpRange = mRenderer->GetAspect();
171 double vw = vpRange[0];
172 double vh = vpRange[1];
174 double w = bounds.range()[0];
175 double h = bounds.range()[1];
178 double w_vp = vh * (w/h);
184 camera->GetPosition(position);
185 position[0] = bounds.center()[0];
186 position[1] = bounds.center()[1];
187 camera->SetPosition(position);
189 camera->GetFocalPoint(position);
190 position[0] = bounds.center()[0];
191 position[1] = bounds.center()[1];
192 camera->SetFocalPoint(position);
194 camera->SetParallelScale(h/2*scale*1.01);
195 mViewportListener->startListen(mRenderer);
201 mRenderer = view->getRenderer();
202 mViewportListener->startListen(mRenderer);
204 view->getRenderer()->AddActor(mRTGraphics->getActor());
205 view->getRenderer()->AddActor(mInfoText->getActor());
206 view->getRenderer()->AddActor(mStatusText->getActor());
207 view->getRenderer()->AddActor(mOrientationVText->getActor());
209 mProbeClipRect->setRenderer(view->getRenderer());
210 mProbeOrigin->setRenderer(view->getRenderer());
211 mProbeSector->setRenderer(view->getRenderer());
217 view->getRenderer()->RemoveActor(mRTGraphics->getActor());
218 view->getRenderer()->RemoveActor(mInfoText->getActor());
219 view->getRenderer()->RemoveActor(mStatusText->getActor());
220 view->getRenderer()->RemoveActor(mOrientationVText->getActor());
221 mProbeOrigin->setRenderer(NULL);
222 mProbeSector->setRenderer(NULL);
223 mProbeClipRect->setRenderer(NULL);
225 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