54 mDataManager(dataManager)
64 disconnect(mSliceProxy.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this, SLOT(ensureCenterWithinView()));
67 mSliceProxy = sliceProxy;
71 connect(mSliceProxy.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this, SLOT(ensureCenterWithinView()));
78 this->ensureCenterWithinView();
81 void ViewFollower::ensureCenterWithinView()
85 if (!mSliceProxy->getTool())
88 bool followTooltip =
settings()->
value(
"Navigation/followTooltip").value<
bool>();
93 if (mSliceProxy->getComputer().getOrientationType()!=
otORTHOGONAL)
96 Vector3D shift_s = this->findCenterShift_s();
97 this->applyShiftToCenter(shift_s);
100 Vector3D ViewFollower::findCenterShift_s()
104 Vector3D pt_s = this->findVirtualTooltip_s();
105 DoubleBoundingBox3D BB_s = this->findStaticBox();
106 shift = this->findShiftFromBoxToTool_s(BB_s, pt_s);
122 Vector3D ViewFollower::findVirtualTooltip_s()
124 ToolPtr tool = mSliceProxy->getTool();
128 Vector3D pt_s = sMr * rMpr * prMt.coord(
Vector3D(0,0,tool->getTooltipOffset()));
133 DoubleBoundingBox3D ViewFollower::findStaticBox()
135 double followTooltipBoundary =
settings()->
value(
"Navigation/followTooltipBoundary").toDouble();
136 followTooltipBoundary =
constrainValue(followTooltipBoundary, 0.0, 0.5);
139 DoubleBoundingBox3D BB_s =
transform(T*S*T.inv(), mBB_s);
143 Vector3D ViewFollower::findShiftFromBoxToTool_s(DoubleBoundingBox3D BB_s,
Vector3D pt_s)
147 for (
unsigned i=0; i<2; ++i)
149 if (pt_s[i] < BB_s[2*i])
150 shift[i] += pt_s[i] - BB_s[2*i];
151 if (pt_s[i] > BB_s[2*i+1])
152 shift[i] += pt_s[i] - BB_s[2*i+1];
158 void ViewFollower::applyShiftToCenter(
Vector3D shift_s)
161 Vector3D c_s = sMr.coord(mDataManager->getCenter());
162 Vector3D newcenter_s = c_s + shift_s;
163 Vector3D newcenter_r = sMr.inv().coord(newcenter_s);
164 mDataManager->setCenter(newcenter_r);
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
boost::shared_ptr< class ViewFollower > ViewFollowerPtr
void setView(DoubleBoundingBox3D bb_s)
Transform3D createTransformScale(const Vector3D &scale_)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setSliceProxy(SliceProxyPtr sliceProxy)
double constrainValue(double val, double min, double max)
otORTHOGONAL
orient planes relative to the image/reference space.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Transform3D createTransformTranslate(const Vector3D &translation)
Settings * settings()
Shortcut for accessing the settings instance.
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.
static ViewFollowerPtr create(PatientModelServicePtr dataManager)
boost::shared_ptr< class Tool > ToolPtr