/**Move the tool pos / axis pos to a new position given * by the input click position in vp space. */ void ViewWrapper2D::setAxisPos(Vector3D click_vp) { ToolPtr tool = mServices->getToolManager()->getManualTool(); Transform3D sMr = mSliceProxy->get_sMr(); Transform3D rMpr = mServices->getPatientService()->get_rMpr(); Transform3D prMt = tool->get_prMt(); // find tool position in s Vector3D tool_t(0, 0, tool->getTooltipOffset()); Vector3D tool_s = (sMr * rMpr * prMt).coord(tool_t); // find click position in s. Transform3D vpMs = mView->get_vpMs(); Vector3D click_s = vpMs.inv().coord(click_vp); // compute the new tool position in slice space as a synthesis of the plane part of click and the z part of original. Vector3D cross_s(click_s[0], click_s[1], tool_s[2]); // compute the position change and transform to patient. Vector3D delta_s = cross_s - tool_s; Vector3D delta_pr = (rMpr.inv() * sMr.inv()).vector(delta_s); // MD is the actual tool movement in patient space, matrix form Transform3D MD = createTransformTranslate(delta_pr); // set new tool position to old modified by MD: tool->set_prMt(MD * prMt); }
void LandmarkRegistrationWidget::setManualToolPosition(Vector3D p_r) { Transform3D rMpr = mServices->patient()->get_rMpr(); Vector3D p_pr = rMpr.inv().coord(p_r); // set the picked point as offset tip ToolPtr tool = mServices->tracking()->getManualTool(); Vector3D offset = tool->get_prMt().vector(Vector3D(0, 0, tool->getTooltipOffset())); p_pr -= offset; p_r = rMpr.coord(p_pr); // TODO set center here will not do: must handle mServices->patient()->setCenter(p_r); Vector3D p0_pr = tool->get_prMt().coord(Vector3D(0, 0, 0)); tool->set_prMt(createTransformTranslate(p_pr - p0_pr) * tool->get_prMt()); }
/**Move the tool pos / axis pos to a new position given * by delta movement in vp space. */ void ViewWrapper2D::shiftAxisPos(Vector3D delta_vp) { delta_vp = -delta_vp; ToolPtr tool = mServices->getToolManager()->getManualTool(); Transform3D sMr = mSliceProxy->get_sMr(); Transform3D rMpr = mServices->getPatientService()->get_rMpr(); Transform3D prMt = tool->get_prMt(); Transform3D vpMs = mView->get_vpMs(); Vector3D delta_s = vpMs.inv().vector(delta_vp); Vector3D delta_pr = (rMpr.inv() * sMr.inv()).vector(delta_s); // MD is the actual tool movement in patient space, matrix form Transform3D MD = createTransformTranslate(delta_pr); // set new tool position to old modified by MD: tool->set_prMt(MD * prMt); }