15 #include <boost/bind.hpp>
16 #include <vtkRenderer.h>
17 #include <vtkMatrix4x4.h>
18 #include <vtkActor2D.h>
19 #include <vtkTextProperty.h>
20 #include <vtkTextActor3D.h>
32 mConnectedTo3D =
false;
36 QColor color1 = QColor::fromRgbF(0, 1, 1);
37 QColor color2 = QColor::fromRgbF(0, 0.6, 1);
38 QColor color3 = QColor::fromRgbF(0.5, 0.5, 1);
39 QColor color4 = QColor::fromRgbF(0.75, 0.75, 1);
93 return mVisible && mConnectedTo3D;
112 if (!mData.count(type))
125 mData[type].vp_s = vp_s;
133 slice->initializeFromPlane(type,
false,
true, 1, 0.25);
154 SlicePlanes3DRep::SlicePlanes3DRep() :
162 mProxy->connectTo3D(
false);
174 mViewportListener->setCallback(boost::bind(&SlicePlanes3DRep::rescale,
this));
178 mViewportListener.reset();
185 if (mViewportListener)
186 mViewportListener->startListen(view->getRenderer());
191 if (mViewportListener)
192 mViewportListener->stopListen();
196 void SlicePlanes3DRep::clearActors()
201 for (DataMap::iterator i = mData.begin(); i != mData.end(); ++i)
204 i->second.mPoint.reset();
205 i->second.mRect.reset();
206 i->second.mAxes.reset();
211 void SlicePlanes3DRep::rescale()
216 void SlicePlanes3DRep::changedSlot()
221 if (!mProxy->getVisible())
229 for (SlicePlanesProxy::DataMap::iterator i = baseData.begin(); i != baseData.end(); ++i)
231 SlicePlanesProxy::DataType& base = i->second;
232 DataType& data = mData[i->first];
236 data.mText = vtkTextActor3DPtr::New();
239 data.mText->GetTextProperty()->SetFontSize(mProxy->getProperties().m3DFontSize);
240 data.mText->GetTextProperty()->BoldOn();
241 data.mText->GetTextProperty()->SetVerticalJustificationToBottom();
242 data.mText->GetTextProperty()->SetJustificationToLeft();
243 data.mText->GetTextProperty()->ShadowOff();
248 data.mRect.reset(
new Rect3D(this->
getRenderer(), base.mColor));
251 Transform3D rMs = base.mSliceProxy->get_sMr().inv();
253 Vector3D pos_s = vpMnvp.coord(base.mPointPos_normvp);
259 if (mViewportListener)
262 double size = mViewportListener->getVpnZoom(focus);
263 double planeSize = (i->second.vp_s.range()[0] + i->second.vp_s.range()[1]) / 2.0;
264 double sphereSize = std::min(0.1 / size, planeSize/5);
265 sphereSize = sphereSize/50;
266 data.mText->GetTextProperty()->SetFontSize(mProxy->getProperties().m3DFontSize);
277 data.mText->SetUserMatrix((rMs * T * S * T2).
getVtkMatrix());
282 data.mPoint->setColor(base.mColor);
283 data.mPoint->setValue(rMs.coord(pos_s));
287 data.mRect->updatePosition(base.vp_s, rMs);
288 data.mRect->setLine(mProxy->getProperties().mLineWidth != 0, mProxy->getProperties().mLineWidth);
289 data.mRect->setSurface(mProxy->getDrawPlanes());
293 data.mAxes->setPosition(rMs);
301 mProxy->connectTo3D(
true);
302 connect(mProxy.get(), SIGNAL(changed()),
this, SLOT(changedSlot()));
315 SlicePlanes3DMarkerIn2DRep::SlicePlanes3DMarkerIn2DRep() :
329 mText->textProperty()->BoldOn();
330 mText->textProperty()->SetVerticalJustificationToTop();
331 mText->textProperty()->SetJustificationToLeft();
333 mText->getActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
334 view->getRenderer()->AddActor2D(mText->getActor());
340 view->getRenderer()->RemoveActor(mText->getActor());
344 void SlicePlanes3DMarkerIn2DRep::changedSlot()
348 mText->getActor()->SetVisibility(mProxy->getVisible() && mProxy->getData().count(mType));
359 connect(mProxy.get(), SIGNAL(changed()),
this, SLOT(changedSlot()));