void mitk::RegistrationTool::CrossTranslateCoronal(int x, int y) { //std::cout << "hi from " << __FUNCSIG__ << std::endl; if(x == 0 && y == 0) { return; } // Undo / Redo controller mitk::Point3D forwardPoint; mitk::Point3D reversePoint; forwardPoint[0] = (double)x / 10.0; forwardPoint[1] = 0.0; forwardPoint[2] = -(double)y / 10.0; reversePoint[0] = -forwardPoint[0]; reversePoint[1] = -forwardPoint[1]; reversePoint[2] = -forwardPoint[2]; mitk::PointOperation* doOp = new mitk::PointOperation(OpMOVE, forwardPoint); if ( m_UndoEnabled ) { mitk::PointOperation* undoOp = new mitk::PointOperation(OpMOVE, reversePoint); OperationEvent *operationEvent = new OperationEvent( m_Ext->GetSurface()->GetGeometry(), doOp, undoOp, "Move surface coronal"); m_UndoController->SetOperationEvent(operationEvent); if(m_LastTool != 6) { std::cout << "Change last tool from: " << m_LastTool << ", to: 6.\n"; operationEvent->IncCurrObjectEventId(); operationEvent->IncCurrGroupEventId(); m_LastTool = 6; } } //execute the Operation m_Ext->GetSurface()->GetGeometry()->ExecuteOperation(doOp); m_Ext->GetSurface()->Update(); m_Ext->GetSurfaceNode()->Modified(); mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); if(m_AutoReinit) { m_Ext->Reinit(); } //std::cout << "ciao from " << __FUNCSIG__ << std::endl; }
void mitk::RegistrationTool::CrossRotateZ(int x) { //std::cout << "hi from " << __FUNCSIG__ << std::endl; if(x == 0) { return; } mitk::Point3D newCenter; newCenter = m_Ext->GetSurface()->GetGeometry()->GetCenter(); mitk::Vector3D rotationAxis; rotationAxis[0] = 0.0; rotationAxis[1] = 20.0; rotationAxis[2] = 0.0; //(sagittal, coronal, transversal) mitk::RotationOperation *doOp = new mitk::RotationOperation(mitk::OpROTATE, newCenter, rotationAxis, x); if(m_UndoEnabled) { mitk::RotationOperation* undoOp = new mitk::RotationOperation(mitk::OpROTATE, newCenter, rotationAxis, -x); OperationEvent *operationEvent = new OperationEvent(m_Ext->GetSurface()->GetGeometry(), doOp, undoOp, "Rotate Coronal (Z)"); m_UndoController->SetOperationEvent(operationEvent); if(m_LastTool != 3) { std::cout << "Change last tool from: " << m_LastTool << ", to: 3.\n"; operationEvent->IncCurrObjectEventId(); operationEvent->IncCurrGroupEventId(); m_LastTool = 3; } } m_Ext->GetSurface()->GetGeometry()->ExecuteOperation(doOp); m_Ext->GetSurface()->Update(); m_Ext->GetSurfaceNode()->Modified(); mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); if(m_AutoReinit) { m_Ext->Reinit(); } //std::cout << "ciao from " << __FUNCSIG__ << std::endl; }
void mitk::RegistrationTool::ScaleChangedByCross(int scale) { //std::cout << "hi from " << __FUNCSIG__ << std::endl; if(scale == 0) { return; } else if(scale > 0) { m_Factor = 1.01; } else { m_Factor = 0.99; } //std::cout << "Scale factor: " << m_Factor << "\n"; mitk::Geometry3D::Pointer geometry = m_Ext->GetSurface()->GetGeometry(); // from mitk::Geometry3D: /* calculate new scale: newscale = oldscale * (oldscale + scaletoadd)/oldscale */ mitk::Point3D newScale; newScale.Fill(m_Factor); mitk::Point3D newScale2; newScale2[0] = (newScale[0] - 1) * (m_Ext->GetSurface()->GetGeometry()->GetMatrixColumn(0).magnitude()); newScale2[1] = (newScale[1] - 1) * (m_Ext->GetSurface()->GetGeometry()->GetMatrixColumn(1).magnitude()); newScale2[2] = (newScale[2] - 1) * (m_Ext->GetSurface()->GetGeometry()->GetMatrixColumn(2).magnitude()); mitk::Point3D reverseScale; reverseScale[0] = -newScale2[0]; reverseScale[1] = -newScale2[1]; reverseScale[2] = -newScale2[2]; m_CenterBeforeScale = m_Ext->GetSurface()->GetGeometry()->GetCenter(); /* generate Operation and send it to the receiving geometry */ PointOperation* doOp = new mitk::PointOperation(OpSCALE, newScale2, 0); // Index is not used here if (m_UndoEnabled) //write to UndoMechanism { mitk::Point3D oldScaleData; oldScaleData[0] = -newScale[0]; oldScaleData[1] = -newScale[1]; oldScaleData[2] = -newScale[2]; PointOperation* undoOp = new mitk::PointOperation(OpSCALE, reverseScale/*oldScaleData*/, 0); OperationEvent *operationEvent = new OperationEvent(geometry, doOp, undoOp, "Scale surface"); m_UndoController->SetOperationEvent(operationEvent); if(m_LastTool != 0) { std::cout << "Change last tool from: " << m_LastTool << ", to: 0.\n"; operationEvent->IncCurrObjectEventId(); operationEvent->IncCurrGroupEventId(); m_LastTool = 0; } } /* execute the Operation */ geometry->ExecuteOperation(doOp); m_Ext->GetSurface()->Update(); m_Ext->GetSurfaceNode()->Modified(); //update rendering mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // translate to keep object at place mitk::Point3D forwardPoint; mitk::Point3D reversePoint; m_CenterAfterScale = m_Ext->GetSurface()->GetGeometry()->GetCenter(); forwardPoint[0] = m_CenterBeforeScale[0] - m_CenterAfterScale[0]; forwardPoint[1] = m_CenterBeforeScale[1] - m_CenterAfterScale[1]; forwardPoint[2] = m_CenterBeforeScale[2] - m_CenterAfterScale[2]; reversePoint[0] = -forwardPoint[0]; reversePoint[1] = -forwardPoint[1]; reversePoint[2] = -forwardPoint[2]; if(0) // print { std::cout << "Scale: " << newScale[0] << ", " << newScale[1] << ", " << newScale[2] << "\n"; std::cout << "Translation: " << forwardPoint[0] << ", " << forwardPoint[1] << ", " << forwardPoint[2] << "\n"; std::cout << "Center of Surface: " << m_Ext->GetSurface()->GetGeometry()->GetCenter() << "\n"; } mitk::PointOperation* doOp2 = new mitk::PointOperation(OpMOVE, forwardPoint); if ( m_UndoEnabled ) { mitk::PointOperation* undoOp2 = new mitk::PointOperation(OpMOVE, reversePoint); OperationEvent *operationEvent2 = new OperationEvent(m_Ext->GetSurface()->GetGeometry(), doOp2, undoOp2, "Back transformation (translate after scale)"); m_UndoController->SetOperationEvent(operationEvent2); } //execute the Operation m_Ext->GetSurface()->GetGeometry()->ExecuteOperation(doOp2); m_Ext->GetSurface()->Update(); m_Ext->GetSurfaceNode()->Modified(); //update rendering mitk::RenderingManager::GetInstance()->RequestUpdateAll(); if(m_AutoReinit) { m_Ext->Reinit(); } //std::cout << "ciao from " << __FUNCSIG__ << std::endl; }