36 #include <boost/bind.hpp>
37 #include <vtkRenderer.h>
38 #include <vtkMatrix4x4.h>
39 #include <vtkActor2D.h>
40 #include <vtkTextProperty.h>
41 #include <vtkTextActor3D.h>
53 mConnectedTo3D =
false;
57 QColor color1 = QColor::fromRgbF(0, 1, 1);
58 QColor color2 = QColor::fromRgbF(0, 0.6, 1);
59 QColor color3 = QColor::fromRgbF(0.5, 0.5, 1);
60 QColor color4 = QColor::fromRgbF(0.75, 0.75, 1);
110 return mVisible && mConnectedTo3D;
129 if (!mData.count(type))
142 mData[type].vp_s = vp_s;
150 slice->initializeFromPlane(type,
false,
true, 1, 0.25);
171 SlicePlanes3DRep::SlicePlanes3DRep() :
179 mProxy->connectTo3D(
false);
191 mViewportListener->setCallback(boost::bind(&SlicePlanes3DRep::rescale,
this));
195 mViewportListener.reset();
202 if (mViewportListener)
203 mViewportListener->startListen(view->getRenderer());
208 if (mViewportListener)
209 mViewportListener->stopListen();
213 void SlicePlanes3DRep::clearActors()
218 for (DataMap::iterator i = mData.begin(); i != mData.end(); ++i)
221 i->second.mPoint.reset();
222 i->second.mRect.reset();
223 i->second.mAxes.reset();
228 void SlicePlanes3DRep::rescale()
233 void SlicePlanes3DRep::changedSlot()
238 if (!mProxy->getVisible())
246 for (SlicePlanesProxy::DataMap::iterator i = baseData.begin(); i != baseData.end(); ++i)
248 SlicePlanesProxy::DataType& base = i->second;
249 DataType& data = mData[i->first];
253 data.mText = vtkTextActor3DPtr::New();
256 data.mText->GetTextProperty()->SetFontSize(mProxy->getProperties().m3DFontSize);
257 data.mText->GetTextProperty()->BoldOn();
258 data.mText->GetTextProperty()->SetVerticalJustificationToBottom();
259 data.mText->GetTextProperty()->SetJustificationToLeft();
260 data.mText->GetTextProperty()->ShadowOff();
265 data.mRect.reset(
new Rect3D(this->
getRenderer(), base.mColor));
268 Transform3D rMs = base.mSliceProxy->get_sMr().inv();
270 Vector3D pos_s = vpMnvp.coord(base.mPointPos_normvp);
276 if (mViewportListener)
278 double size = mViewportListener->getVpnZoom();
279 double planeSize = (i->second.vp_s.range()[0] + i->second.vp_s.range()[1]) / 2.0;
280 double sphereSize = std::min(0.1 / size, planeSize/5);
281 sphereSize = sphereSize/50;
282 data.mText->GetTextProperty()->SetFontSize(mProxy->getProperties().m3DFontSize);
293 data.mText->SetUserMatrix((rMs * T * S * T2).
getVtkMatrix());
298 data.mPoint->setColor(base.mColor);
299 data.mPoint->setValue(rMs.coord(pos_s));
303 data.mRect->updatePosition(base.vp_s, rMs);
304 data.mRect->setLine(mProxy->getProperties().mLineWidth != 0, mProxy->getProperties().mLineWidth);
305 data.mRect->setSurface(mProxy->getDrawPlanes());
309 data.mAxes->setPosition(rMs);
317 mProxy->connectTo3D(
true);
318 connect(mProxy.get(), SIGNAL(changed()),
this, SLOT(changedSlot()));
331 SlicePlanes3DMarkerIn2DRep::SlicePlanes3DMarkerIn2DRep() :
345 mText->textProperty()->BoldOn();
346 mText->textProperty()->SetVerticalJustificationToTop();
347 mText->textProperty()->SetJustificationToLeft();
349 mText->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
350 view->getRenderer()->AddActor2D(mText->getActor());
356 view->getRenderer()->RemoveActor(mText->getActor());
360 void SlicePlanes3DMarkerIn2DRep::changedSlot()
364 mText->getActor()->SetVisibility(mProxy->getVisible() && mProxy->getData().count(mType));
375 connect(mProxy.get(), SIGNAL(changed()),
this, SLOT(changedSlot()));
virtual ~SlicePlanes3DRep()
virtual ~SlicePlanes3DMarkerIn2DRep()
void setViewportData(PLANE_TYPE type, SliceProxyPtr slice, const DoubleBoundingBox3D &vp_s)
vtkRendererPtr getRenderer()
ptCORONAL
a slice seen from the front of the patient
static SliceProxyPtr create(PatientModelServicePtr dataManager)
Vector3D getColorAsVector3D(QColor color)
boost::shared_ptr< class SlicePlanesProxy > SlicePlanesProxyPtr
PLANE_TYPE mClipPlane
what plane to use for 3D clipping
Transform3D createTransformScale(const Vector3D &scale_)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
std::map< PLANE_TYPE, DataType > DataMap
void setDrawPlanes(bool on)
static SlicePlanes3DRepPtr New(const QString &uid="")
Vector3D mPointPos_normvp
position of symbol in normalized space <0..1, 0..1>
int mLineWidth
draw wireframe lines. 0 means no line
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
cstring_cast_Placeholder cstring_cast(const T &val)
Display a set of planes in 3D.
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
void setVisible(bool visible)
void connectTo3D(bool on)
ptAXIAL
a slice seen from the top of the patient
boost::shared_ptr< class View > ViewPtr
static SlicePlanes3DMarkerIn2DRepPtr New(const QString &uid="")
Transform3D createTransformNormalize(const DoubleBoundingBox3D &in, const DoubleBoundingBox3D &out)
Listens to changes in viewport and camera matrix.
ptSAGITTAL
a slice seen from the side of the patient
void setProxy(SlicePlanesProxyPtr proxy)
bool getDrawPlanes() const
Display annotations for the SlicePlanesProxy planes in 2D.
void addSimpleSlicePlane(PLANE_TYPE type, PatientModelServicePtr dataManager)
std::map< PLANE_TYPE, QString > mSymbol
normalized RGB
std::map< PLANE_TYPE, QColor > mColor
ptTOOLSIDEPLANE
z-rotated 90* relative to anyplane like side plane, but always kept oriented like the plane defined b...
Helper for drawing text in 2D.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Transform3D createTransformTranslate(const Vector3D &translation)
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.
Vector3D mPointPos_normvp
void setProxy(PLANE_TYPE type, SlicePlanesProxyPtr proxy)
boost::shared_ptr< class SlicePlanes3DRep > SlicePlanes3DRepPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
ptRADIALPLANE
y-rotated 90* relative to anyplane (bird's view)
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
virtual void addRepActorsToViewRenderer(ViewPtr view)
void setDynamicLabelSize(bool on)
ptANYPLANE
a plane aligned with the tool base plane
boost::shared_ptr< class SlicePlanes3DMarkerIn2DRep > SlicePlanes3DMarkerIn2DRepPtr
virtual void addRepActorsToViewRenderer(ViewPtr view)
SliceProxyPtr mSliceProxy
ptSIDEPLANE
z-rotated 90* relative to anyplane (dual anyplane)