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();
144 DoubleBoundingBox3D bounds(mRTGraphics->getActor()->GetBounds());
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();