Public Member Functions | Static Public Attributes | Protected Slots | Protected Attributes | Friends

QmitkPointBasedRegistrationView Class Reference
[FunctionalitiesClasses related to point based registration]

The PointBasedRegistration functionality is used to perform point based registration. More...

#include <QmitkPointBasedRegistrationView.h>

Inheritance diagram for QmitkPointBasedRegistrationView:
Inheritance graph
[legend]
Collaboration diagram for QmitkPointBasedRegistrationView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 QmitkPointBasedRegistrationView (QObject *parent=0, const char *name=0)
 Default constructor.
virtual ~QmitkPointBasedRegistrationView ()
 Default destructor.
virtual void CreateQtPartControl (QWidget *parent)
 method for creating the applications main widget
virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget)
 Sets the StdMultiWidget and connects it to the functionality.
virtual void StdMultiWidgetNotAvailable ()
 Removes the StdMultiWidget and disconnects it from the functionality.
virtual void CreateConnections ()
 Method for creating the connections of main and control widget.
virtual void Activated ()
virtual void Deactivated ()
virtual void Visible ()
virtual void Hidden ()
void DataNodeHasBeenRemoved (const mitk::DataNode *node)
 Helper method for testing.

Static Public Attributes

static const std::string VIEW_ID = "org.mitk.views.pointbasedregistration"

Protected Slots

void FixedSelected (mitk::DataNode::Pointer fixedImage)
 Sets the fixed Image according to TreeNodeSelector widget.
void MovingSelected (mitk::DataNode::Pointer movingImage)
 Sets the moving Image according to TreeNodeSelector widget.
void calculateLandmarkbased ()
 Calculates registration with vtkLandmarkTransform.
void calculateLandmarkWarping ()
 Calculates registration with itkLandmarkWarping.
void calculateLandmarkbasedWithICP ()
 Calculates registration with ICP and vtkLandmarkTransform.
void HideMovingImage (bool hide)
 lets the fixed image become invisible and the moving image visible
void HideFixedImage (bool hide)
 lets the moving image become invisible and the fixed image visible
bool CheckCalculate ()
 Checks if registration is possible.
void UndoTransformation ()
 Performs an undo for the last transform.
void RedoTransformation ()
 Performs a redo for the last undo transform.
void showRedGreen (bool show)
 Stores whether the image will be shown in grayvalues or in red for fixed image and green for moving image.
void OpacityUpdate (float opacity)
 Sets the selected opacity for moving image.
void OpacityUpdate (int opacity)
 Sets the selected opacity for moving image.
void updateMovingLandmarksList ()
 Updates the moving landmarks.
void updateFixedLandmarksList ()
 Updates the fixed landmarks.
void setImageColor (bool redGreen)
 Sets the images to gray values or fixed image to red and moving image to green.
void clearTransformationLists ()
 Clears the undo and redo transformation lists.
void checkLandmarkError ()
 Calculates the landmark error for the selected transformation.
void transformationChanged (int transform)
 Changes the transformation type and calls checkLandmarkError().
bool checkCalculateEnabled ()
 Checks whether the registration can be performed.
void calculate ()
 Performs the registration.
void SetImagesVisible (berry::ISelection::ConstPointer)
void SwitchImages ()

Protected Attributes

berry::ISelectionListener::Pointer m_SelListener
berry::IStructuredSelection::ConstPointer m_CurrentSelection
QmitkStdMultiWidgetm_MultiWidget
Ui::QmitkPointBasedRegistrationControls m_Controls
mitk::PointSet::Pointer m_FixedLandmarks
mitk::PointSet::Pointer m_MovingLandmarks
mitk::DataNode::Pointer m_MovingPointSetNode
mitk::DataNode::Pointer m_FixedPointSetNode
mitk::DataNode::Pointer m_MovingNode
mitk::DataNode::Pointer m_FixedNode
std::list
< mitk::Geometry3D::Pointer
m_UndoGeometryList
std::list
< mitk::Geometry3D::Pointer
m_UndoPointsGeometryList
std::list
< mitk::Geometry3D::Pointer
m_RedoGeometryList
std::list
< mitk::Geometry3D::Pointer
m_RedoPointsGeometryList
bool m_ShowRedGreen
float m_Opacity
float m_OriginalOpacity
mitk::Color m_FixedColor
mitk::Color m_MovingColor
int m_Transformation
bool m_HideFixedImage
bool m_HideMovingImage
std::string m_OldFixedLabel
std::string m_OldMovingLabel
bool m_Deactivated
int m_CurrentFixedLandmarksObserverID
int m_CurrentMovingLandmarksObserverID
itk::SimpleMemberCommand
< QmitkPointBasedRegistrationView >
::Pointer 
m_FixedLandmarksChangedCommand
itk::SimpleMemberCommand
< QmitkPointBasedRegistrationView >
::Pointer 
m_MovingLandmarksChangedCommand

Friends

struct SelListenerPointBasedRegistration

Detailed Description

The PointBasedRegistration functionality is used to perform point based registration.

This functionality allows you to register 2D as well as 3D images in a rigid and deformable manner via corresponding PointSets. Register means to align two images, so that they become as similar as possible. Therefore you have to set corresponding points in both images, which will be matched. The movement, which has to be performed on the points to align them will be performed on the moving image as well. The result is shown in the multi-widget.

For more informations see: QmitkPointBasedRegistrationUserManual

See also:
QmitkFunctionality

Definition at line 54 of file QmitkPointBasedRegistrationView.h.


Constructor & Destructor Documentation

QmitkPointBasedRegistrationView::QmitkPointBasedRegistrationView ( QObject *  parent = 0,
const char *  name = 0 
)
QmitkPointBasedRegistrationView::~QmitkPointBasedRegistrationView (  ) [virtual]

Member Function Documentation

void QmitkPointBasedRegistrationView::Activated (  ) [virtual]
void QmitkPointBasedRegistrationView::calculate (  ) [protected, slot]
void QmitkPointBasedRegistrationView::calculateLandmarkbased (  ) [protected, slot]

Calculates registration with vtkLandmarkTransform.

Definition at line 1095 of file QmitkPointBasedRegistrationView.cpp.

References CheckCalculate(), checkLandmarkError(), mitk::RenderingManager::GetInstance(), berry::SmartPointer< TObjectType >::GetPointer(), m_Controls, m_FixedLandmarks, m_MovingLandmarks, m_MovingNode, m_RedoGeometryList, m_RedoPointsGeometryList, Ui_QmitkPointBasedRegistrationControls::m_RedoTransformation, m_Transformation, m_UndoGeometryList, m_UndoPointsGeometryList, Ui_QmitkPointBasedRegistrationControls::m_UndoTransformation, and matrix().

Referenced by calculate().

{
  if(CheckCalculate())
  {
    mitk::Geometry3D::Pointer pointsGeometry = m_MovingLandmarks->GetGeometry(0);
    mitk::AffineGeometryFrame3D::Pointer movingLandmarksGeometry = m_MovingLandmarks->GetGeometry(0)->Clone();
    m_UndoPointsGeometryList.push_back(static_cast<mitk::Geometry3D *>(movingLandmarksGeometry.GetPointer()));

    mitk::BaseData::Pointer originalData = m_MovingNode->GetData();
    mitk::AffineGeometryFrame3D::Pointer originalDataGeometry = originalData->GetGeometry(0)->Clone();
    m_UndoGeometryList.push_back(static_cast<mitk::Geometry3D *>(originalDataGeometry.GetPointer()));

    vtkIdType pointId;
    vtkPoints* vPointsSource=vtkPoints::New();
    for(pointId = 0; pointId < m_MovingLandmarks->GetSize(); ++pointId)
    {
      mitk::Point3D sourcePoint = m_MovingLandmarks->GetPoint(pointId);
      vPointsSource->InsertNextPoint(sourcePoint[0],sourcePoint[1],sourcePoint[2]);
    }
    vtkPoints* vPointsTarget=vtkPoints::New();
    for(pointId=0; pointId<m_FixedLandmarks->GetSize();++pointId)
    {
      mitk::Point3D targetPoint=m_FixedLandmarks->GetPoint(pointId);
      vPointsTarget->InsertNextPoint(targetPoint[0],targetPoint[1],targetPoint[2]);
    }

    vtkLandmarkTransform * transform= vtkLandmarkTransform::New();
    transform->SetSourceLandmarks(vPointsSource);
    transform->SetTargetLandmarks(vPointsTarget);
    if(m_Transformation==0)
    {
      transform->SetModeToRigidBody();
    }
    if(m_Transformation==1)
    {
      transform->SetModeToSimilarity();
    }
    if(m_Transformation==2)
    {
      transform->SetModeToAffine();
    }
    vtkMatrix4x4 * matrix=transform->GetMatrix();
    double determinant = fabs(matrix->Determinant());
    if((determinant < mitk::eps) || (determinant > 100) || (determinant < 0.01)
      || (determinant==itk::NumericTraits<double>::infinity())
      || (determinant==itk::NumericTraits<double>::quiet_NaN())
      || (determinant==itk::NumericTraits<double>::signaling_NaN())
      || (determinant==-itk::NumericTraits<double>::infinity())
      || (determinant==-itk::NumericTraits<double>::quiet_NaN())
      || (determinant==-itk::NumericTraits<double>::signaling_NaN())
      || (!(determinant <= 0) && !(determinant > 0)))
    {
      QMessageBox msgBox;
      msgBox.setText("Suspicious determinant of matrix calculated.\n"
        "Please select more points or other points!" );
      msgBox.exec();
      return;
    }
    pointsGeometry->Compose(matrix);
    m_MovingLandmarks->GetTimeSlicedGeometry()->UpdateInformation();

    mitk::BaseData::Pointer movingData = m_MovingNode->GetData();
    mitk::Geometry3D::Pointer movingGeometry = movingData->GetGeometry(0);
    movingGeometry->Compose(matrix);
    movingData->GetTimeSlicedGeometry()->UpdateInformation();
    m_Controls.m_UndoTransformation->setEnabled(true);
    m_Controls.m_RedoTransformation->setEnabled(false);
    m_RedoGeometryList.clear();
    m_RedoPointsGeometryList.clear();
    mitk::RenderingManager::GetInstance()->RequestUpdateAll();
    this->checkLandmarkError();
  }
}
void QmitkPointBasedRegistrationView::calculateLandmarkbasedWithICP (  ) [protected, slot]

Calculates registration with ICP and vtkLandmarkTransform.

Definition at line 1000 of file QmitkPointBasedRegistrationView.cpp.

References CheckCalculate(), checkLandmarkError(), mitk::RenderingManager::GetInstance(), berry::SmartPointer< TObjectType >::GetPointer(), m_Controls, m_FixedLandmarks, m_MovingLandmarks, m_MovingNode, m_RedoGeometryList, m_RedoPointsGeometryList, Ui_QmitkPointBasedRegistrationControls::m_RedoTransformation, m_Transformation, m_UndoGeometryList, m_UndoPointsGeometryList, Ui_QmitkPointBasedRegistrationControls::m_UndoTransformation, and matrix().

Referenced by calculate().

{
  if(CheckCalculate())
  {
    mitk::Geometry3D::Pointer pointsGeometry = m_MovingLandmarks->GetGeometry(0);
    mitk::AffineGeometryFrame3D::Pointer movingLandmarksGeometry = m_MovingLandmarks->GetGeometry(0)->Clone();
    m_UndoPointsGeometryList.push_back(static_cast<mitk::Geometry3D *>(movingLandmarksGeometry.GetPointer()));

    mitk::BaseData::Pointer originalData = m_MovingNode->GetData();
    mitk::AffineGeometryFrame3D::Pointer originalDataGeometry = originalData->GetGeometry(0)->Clone();
    m_UndoGeometryList.push_back(static_cast<mitk::Geometry3D *>(originalDataGeometry.GetPointer()));

    vtkIdType pointId;
    vtkPoints* vPointsSource=vtkPoints::New();
    vtkCellArray* vCellsSource=vtkCellArray::New();
    for(pointId=0; pointId<m_MovingLandmarks->GetSize();++pointId)
    {
      mitk::Point3D pointSource=m_MovingLandmarks->GetPoint(pointId);
      vPointsSource->InsertNextPoint(pointSource[0],pointSource[1],pointSource[2]);
      vCellsSource->InsertNextCell(1, &pointId);
    }

    vtkPoints* vPointsTarget=vtkPoints::New();
    vtkCellArray* vCellsTarget = vtkCellArray::New();
    for(pointId=0; pointId<m_FixedLandmarks->GetSize();++pointId)
    {
      mitk::Point3D pointTarget=m_FixedLandmarks->GetPoint(pointId);
      vPointsTarget->InsertNextPoint(pointTarget[0],pointTarget[1],pointTarget[2]);
      vCellsTarget->InsertNextCell(1, &pointId);
    }

    vtkPolyData* vPointSetSource=vtkPolyData::New();
    vtkPolyData* vPointSetTarget=vtkPolyData::New();

    vPointSetTarget->SetPoints(vPointsTarget);
    vPointSetTarget->SetVerts(vCellsTarget);
    vPointSetSource->SetPoints(vPointsSource);
    vPointSetSource->SetVerts(vCellsSource);

    vtkIterativeClosestPointTransform * icp=vtkIterativeClosestPointTransform::New();
    icp->SetCheckMeanDistance(1);
    icp->SetSource(vPointSetSource);
    icp->SetTarget(vPointSetTarget);
    icp->SetMaximumNumberOfIterations(50);
    icp->StartByMatchingCentroidsOn();
    vtkLandmarkTransform * transform=icp->GetLandmarkTransform();
    if(m_Transformation==0)
    {
      transform->SetModeToRigidBody();
    }
    if(m_Transformation==1)
    {
      transform->SetModeToSimilarity();
    }
    if(m_Transformation==2)
    {
      transform->SetModeToAffine();
    }

    vtkMatrix4x4 * matrix=icp->GetMatrix();

    double determinant = fabs(matrix->Determinant());
    if((determinant < mitk::eps) || (determinant > 100) || (determinant < 0.01)
      || (determinant==itk::NumericTraits<double>::infinity())
      || (determinant==itk::NumericTraits<double>::quiet_NaN())
      || (determinant==itk::NumericTraits<double>::signaling_NaN())
      || (determinant==-itk::NumericTraits<double>::infinity())
      || (determinant==-itk::NumericTraits<double>::quiet_NaN())
      || (determinant==-itk::NumericTraits<double>::signaling_NaN())
      || (!(determinant <= 0) && !(determinant > 0)))
    {
      QMessageBox msgBox;
      msgBox.setText("Suspicious determinant of matrix calculated by ICP.\n"
        "Please select more points or other points!" );
      msgBox.exec();
      return;
    }

    pointsGeometry->Compose(matrix);
    m_MovingLandmarks->GetTimeSlicedGeometry()->UpdateInformation();

    mitk::BaseData::Pointer movingData = m_MovingNode->GetData();
    mitk::Geometry3D::Pointer movingGeometry = movingData->GetGeometry(0);
    movingGeometry->Compose(matrix);
    movingData->GetTimeSlicedGeometry()->UpdateInformation();
    m_Controls.m_UndoTransformation->setEnabled(true);
    m_Controls.m_RedoTransformation->setEnabled(false);
    m_RedoGeometryList.clear();
    m_RedoPointsGeometryList.clear();
    mitk::RenderingManager::GetInstance()->RequestUpdateAll();
    this->checkLandmarkError();
  }
}
void QmitkPointBasedRegistrationView::calculateLandmarkWarping (  ) [protected, slot]

Calculates registration with itkLandmarkWarping.

Definition at line 1169 of file QmitkPointBasedRegistrationView.cpp.

References mitk::CastToItkImage(), mitk::CastToMitkImage(), checkLandmarkError(), clearTransformationLists(), mitk::UndoStackItem::ExecuteIncrement(), mitk::UndoController::GetCurrentUndoModel(), mitk::RenderingManager::GetInstance(), mitk::LandmarkWarping::GetTransformedTargetLandmarks(), mitk::UndoStackItem::IncCurrObjectEventId(), int(), m_FixedLandmarks, m_FixedNode, m_MovingLandmarks, m_MovingNode, mitk::LevelWindowProperty::New(), mitk::Image::New(), mitk::OpMOVE, mitk::LandmarkWarping::Register(), mitk::LevelWindow::SetAuto(), mitk::LandmarkWarping::SetFixedImage(), mitk::LandmarkWarping::SetLandmarks(), and mitk::LandmarkWarping::SetMovingImage().

Referenced by calculate().

{
  mitk::LandmarkWarping* registration = new mitk::LandmarkWarping();

  mitk::LandmarkWarping::FixedImageType::Pointer fixedImage = mitk::LandmarkWarping::FixedImageType::New();
  mitk::Image::Pointer fimage = dynamic_cast<mitk::Image*>(m_FixedNode->GetData());
  mitk::LandmarkWarping::MovingImageType::Pointer movingImage = mitk::LandmarkWarping::MovingImageType::New();
  mitk::Image::Pointer mimage = dynamic_cast<mitk::Image*>(m_MovingNode->GetData());
  if (fimage.IsNotNull() && /*fimage->GetDimension() == 2 || */ fimage->GetDimension() == 3 && mimage.IsNotNull() && mimage->GetDimension() == 3)
  {
    mitk::CastToItkImage(fimage, fixedImage);   
    mitk::CastToItkImage(mimage, movingImage);
    
    registration->SetFixedImage(fixedImage);
    registration->SetMovingImage(movingImage);
    unsigned int pointId;
    mitk::Point3D sourcePoint, targetPoint;
    mitk::LandmarkWarping::LandmarkContainerType::Pointer fixedLandmarks = mitk::LandmarkWarping::LandmarkContainerType::New();
    mitk::LandmarkWarping::LandmarkPointType point;
    for(pointId = 0; pointId < (unsigned int)m_FixedLandmarks->GetSize(); ++pointId)
    {
      fimage->GetGeometry(0)->WorldToItkPhysicalPoint(m_FixedLandmarks->GetPoint(pointId), point);
      fixedLandmarks->InsertElement( pointId, point);
    }
    mitk::LandmarkWarping::LandmarkContainerType::Pointer movingLandmarks = mitk::LandmarkWarping::LandmarkContainerType::New();
    for(pointId = 0; pointId < (unsigned int)m_MovingLandmarks->GetSize(); ++pointId)
    {
      mitk::BaseData::Pointer fixedData = m_FixedNode->GetData();
      mitk::Geometry3D::Pointer fixedGeometry = fixedData->GetGeometry(0);
      fixedGeometry->WorldToItkPhysicalPoint(m_MovingLandmarks->GetPoint(pointId), point);
      movingLandmarks->InsertElement( pointId, point);
    }
    registration->SetLandmarks(fixedLandmarks.GetPointer(), movingLandmarks.GetPointer());
    mitk::LandmarkWarping::MovingImageType::Pointer output = registration->Register();
    if (output.IsNotNull())
    {
      mitk::Image::Pointer image = mitk::Image::New();
      mitk::CastToMitkImage(output, image);
      m_MovingNode->SetData(image);
      mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New();
      mitk::LevelWindow levelWindow;
      levelWindow.SetAuto( image );
      levWinProp->SetLevelWindow(levelWindow);
      m_MovingNode->GetPropertyList()->SetProperty("levelwindow",levWinProp);
      movingLandmarks = registration->GetTransformedTargetLandmarks();
      mitk::PointSet::PointDataIterator it;
      it = m_MovingLandmarks->GetPointSet()->GetPointData()->Begin();
      //increase the eventId to encapsulate the coming operations
      mitk::OperationEvent::IncCurrObjectEventId();
      mitk::OperationEvent::ExecuteIncrement();
      for(pointId=0; pointId<movingLandmarks->Size();++pointId, ++it)
      {
        int position = it->Index();
        mitk::PointSet::PointType pt = m_MovingLandmarks->GetPoint(position);
        mitk::Point3D undoPoint = ( pt );
        point = movingLandmarks->GetElement(pointId);
        fimage->GetGeometry(0)->ItkPhysicalPointToWorld(point, pt);
        mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVE, pt, position);
        //undo operation
        mitk::PointOperation* undoOp = new mitk::PointOperation(mitk::OpMOVE, undoPoint, position);
        mitk::OperationEvent* operationEvent = new mitk::OperationEvent(m_MovingLandmarks, doOp, undoOp, "Move point");
        mitk::UndoController::GetCurrentUndoModel()->SetOperationEvent(operationEvent);

        //execute the Operation
        m_MovingLandmarks->ExecuteOperation(doOp);
      }
      mitk::RenderingManager::GetInstance()->RequestUpdateAll();
      this->clearTransformationLists();
      this->checkLandmarkError();
    }
  }
}
bool QmitkPointBasedRegistrationView::CheckCalculate (  ) [protected, slot]
bool QmitkPointBasedRegistrationView::checkCalculateEnabled (  ) [protected, slot]

Checks whether the registration can be performed.

Definition at line 1242 of file QmitkPointBasedRegistrationView.cpp.

References Ui_QmitkPointBasedRegistrationControls::m_Calculate, m_Controls, m_FixedLandmarks, m_MovingLandmarks, m_Transformation, and Ui_QmitkPointBasedRegistrationControls::m_UseICP.

Referenced by CheckCalculate(), CreateConnections(), and transformationChanged().

{
  if (m_FixedLandmarks.IsNotNull() && m_MovingLandmarks.IsNotNull())
  {
    int fixedPoints = m_FixedLandmarks->GetSize();
    int movingPoints = m_MovingLandmarks->GetSize();
    if (m_Transformation == 0 || m_Transformation == 1 || m_Transformation == 2)
    {
      if (m_Controls.m_UseICP->isChecked())
      {
        if((movingPoints > 0 && fixedPoints > 0))
        {
          m_Controls.m_Calculate->setEnabled(true);
          return true;
        }
        else
        {
          m_Controls.m_Calculate->setEnabled(false);
          return false;
        }
      }
      else
      {
        if ((movingPoints == fixedPoints) && movingPoints > 0)
        {
          m_Controls.m_Calculate->setEnabled(true);
          return true;
        }
        else
        {
          m_Controls.m_Calculate->setEnabled(false);
          return false;
        }
      }
    }
    else
    {
      m_Controls.m_Calculate->setEnabled(true);
      return true;
    }
  }
  else
  {
    return false;
  }
}
void QmitkPointBasedRegistrationView::checkLandmarkError (  ) [protected, slot]

Calculates the landmark error for the selected transformation.

Definition at line 904 of file QmitkPointBasedRegistrationView.cpp.

References QuadProgPP::dist(), m_Controls, m_FixedLandmarks, Ui_QmitkPointBasedRegistrationControls::m_MeanError, Ui_QmitkPointBasedRegistrationControls::m_MeanErrorLCD, m_MovingLandmarks, m_Transformation, Ui_QmitkPointBasedRegistrationControls::m_UseICP, and QuadProgPP::sqrt().

Referenced by calculateLandmarkbased(), calculateLandmarkbasedWithICP(), calculateLandmarkWarping(), CreateConnections(), RedoTransformation(), transformationChanged(), UndoTransformation(), updateFixedLandmarksList(), and updateMovingLandmarksList().

{
  double totalDist = 0, dist = 0, dist2 = 0;
  mitk::Point3D point1, point2, point3;
  double p1[3], p2[3];
  if(m_Transformation < 3)
  {
    if (m_Controls.m_UseICP->isChecked())
    {
      if (m_MovingLandmarks.IsNotNull() && m_FixedLandmarks.IsNotNull()&& m_MovingLandmarks->GetSize() != 0 && m_FixedLandmarks->GetSize() != 0)
      {
        for(int pointId = 0; pointId < m_MovingLandmarks->GetSize(); ++pointId)
        {
          point1 = m_MovingLandmarks->GetPoint(pointId);
          point2 = m_FixedLandmarks->GetPoint(0);
          p1[0] = point1[0]; p1[1] = point1[1]; p1[2] = point1[2];
          p2[0] = point2[0]; p2[1] = point2[1]; p2[2] = point2[2];
          dist = vtkMath::Distance2BetweenPoints(p1, p2);
          for(int pointId2 = 1; pointId2 < m_FixedLandmarks->GetSize(); ++pointId2)
          {
            point2 = m_FixedLandmarks->GetPoint(pointId2);
            p1[0] = point1[0]; p1[1] = point1[1]; p1[2] = p1[2];
            p2[0] = point2[0]; p2[1] = point2[1]; p2[2] = p2[2];
            dist2 = vtkMath::Distance2BetweenPoints(p1, p2);
            if (dist2 < dist)
            {
              dist = dist2;
            }
          }
          totalDist += dist;
        }
        m_Controls.m_MeanErrorLCD->display(sqrt(totalDist/m_FixedLandmarks->GetSize()));
        m_Controls.m_MeanErrorLCD->show();
        m_Controls.m_MeanError->show();
      }
      else
      {
        m_Controls.m_MeanErrorLCD->hide();
        m_Controls.m_MeanError->hide();
      }
    }
    else
    {
      if (m_MovingLandmarks.IsNotNull() && m_FixedLandmarks.IsNotNull() && m_MovingLandmarks->GetSize() != 0 && m_FixedLandmarks->GetSize() != 0 && m_MovingLandmarks->GetSize() == m_FixedLandmarks->GetSize())
      {
        for(int pointId = 0; pointId < m_MovingLandmarks->GetSize(); ++pointId)
        {
          point1 = m_MovingLandmarks->GetPoint(pointId);
          point2 = m_FixedLandmarks->GetPoint(pointId);
          p1[0] = point1[0]; p1[1] = point1[1]; p1[2] = point1[2];
          p2[0] = point2[0]; p2[1] = point2[1]; p2[2] = point2[2];
          totalDist += vtkMath::Distance2BetweenPoints(p1, p2);
        }
        m_Controls.m_MeanErrorLCD->display(sqrt(totalDist/m_FixedLandmarks->GetSize()));
        m_Controls.m_MeanErrorLCD->show();
        m_Controls.m_MeanError->show();
      }
      else
      {
        m_Controls.m_MeanErrorLCD->hide();
        m_Controls.m_MeanError->hide();
      }
    }
  }
  else
  {
    if (m_MovingLandmarks.IsNotNull() && m_FixedLandmarks.IsNotNull() && m_MovingLandmarks->GetSize() != 0 && m_FixedLandmarks->GetSize() != 0 && m_MovingLandmarks->GetSize() == m_FixedLandmarks->GetSize())
    {
      for(int pointId = 0; pointId < m_MovingLandmarks->GetSize(); ++pointId)
      {
        point1 = m_MovingLandmarks->GetPoint(pointId);
        point2 = m_FixedLandmarks->GetPoint(pointId);
        p1[0] = point1[0]; p1[1] = point1[1]; p1[2] = point1[2];
        p2[0] = point2[0]; p2[1] = point2[1]; p2[2] = point2[2];
        totalDist += vtkMath::Distance2BetweenPoints(p1, p2);
      }
      m_Controls.m_MeanErrorLCD->display(sqrt(totalDist/m_FixedLandmarks->GetSize()));
      m_Controls.m_MeanErrorLCD->show();
      m_Controls.m_MeanError->show();
    }
    else
    {
      m_Controls.m_MeanErrorLCD->hide();
      m_Controls.m_MeanError->hide();
    }
  }
}
void QmitkPointBasedRegistrationView::clearTransformationLists (  ) [protected, slot]
void QmitkPointBasedRegistrationView::CreateConnections (  ) [virtual]

Method for creating the connections of main and control widget.

Definition at line 292 of file QmitkPointBasedRegistrationView.cpp.

References calculate(), checkCalculateEnabled(), checkLandmarkError(), HideFixedImage(), HideMovingImage(), Ui_QmitkPointBasedRegistrationControls::m_Calculate, m_Controls, Ui_QmitkPointBasedRegistrationControls::m_FixedPointListWidget, Ui_QmitkPointBasedRegistrationControls::m_MovingPointListWidget, Ui_QmitkPointBasedRegistrationControls::m_OpacitySlider, Ui_QmitkPointBasedRegistrationControls::m_RedoTransformation, Ui_QmitkPointBasedRegistrationControls::m_SelectedTransformationClass, Ui_QmitkPointBasedRegistrationControls::m_ShowRedGreenValues, Ui_QmitkPointBasedRegistrationControls::m_SwitchImages, Ui_QmitkPointBasedRegistrationControls::m_UndoTransformation, Ui_QmitkPointBasedRegistrationControls::m_UseICP, OpacityUpdate(), RedoTransformation(), showRedGreen(), SwitchImages(), transformationChanged(), UndoTransformation(), updateFixedLandmarksList(), and updateMovingLandmarksList().

Referenced by CreateQtPartControl().

{
  connect( (QObject*)(m_Controls.m_FixedPointListWidget), SIGNAL(EditPointSets(bool)), (QObject*)(m_Controls.m_MovingPointListWidget), SLOT(DeactivateInteractor(bool)));
  connect( (QObject*)(m_Controls.m_MovingPointListWidget), SIGNAL(EditPointSets(bool)), (QObject*)(m_Controls.m_FixedPointListWidget), SLOT(DeactivateInteractor(bool)));
  connect( (QObject*)(m_Controls.m_FixedPointListWidget), SIGNAL(EditPointSets(bool)), this, SLOT(HideMovingImage(bool)));
  connect( (QObject*)(m_Controls.m_MovingPointListWidget), SIGNAL(EditPointSets(bool)), this, SLOT(HideFixedImage(bool)));
  connect( (QObject*)(m_Controls.m_FixedPointListWidget), SIGNAL(PointListChanged()), this, SLOT(updateFixedLandmarksList()));
  connect( (QObject*)(m_Controls.m_MovingPointListWidget), SIGNAL(PointListChanged()), this, SLOT(updateMovingLandmarksList()));
  connect((QObject*)(m_Controls.m_Calculate),SIGNAL(clicked()),this,SLOT(calculate()));
  connect((QObject*)(m_Controls.m_SwitchImages),SIGNAL(clicked()),this,SLOT(SwitchImages()));
  connect((QObject*)(m_Controls.m_UndoTransformation),SIGNAL(clicked()),this,SLOT(UndoTransformation()));
  connect((QObject*)(m_Controls.m_RedoTransformation),SIGNAL(clicked()),this,SLOT(RedoTransformation()));
  connect((QObject*)(m_Controls.m_ShowRedGreenValues),SIGNAL(toggled(bool)),this,SLOT(showRedGreen(bool)));
  connect((QObject*)(m_Controls.m_OpacitySlider),SIGNAL(valueChanged(int)),this,SLOT(OpacityUpdate(int)));
  connect((QObject*)(m_Controls.m_SelectedTransformationClass),SIGNAL(activated(int)), this,SLOT(transformationChanged(int)));
  connect((QObject*)(m_Controls.m_UseICP),SIGNAL(toggled(bool)), this,SLOT(checkCalculateEnabled()));
  connect((QObject*)(m_Controls.m_UseICP),SIGNAL(toggled(bool)), this,SLOT(checkLandmarkError()));
}
void QmitkPointBasedRegistrationView::CreateQtPartControl ( QWidget *  parent ) [virtual]

method for creating the applications main widget

Implements berry::QtViewPart.

Definition at line 247 of file QmitkPointBasedRegistrationView.cpp.

References CreateConnections(), Ui_QmitkPointBasedRegistrationControls::label, Ui_QmitkPointBasedRegistrationControls::label_2, Ui_QmitkPointBasedRegistrationControls::line1, Ui_QmitkPointBasedRegistrationControls::line2, m_Controls, Ui_QmitkPointBasedRegistrationControls::m_FixedLabel, Ui_QmitkPointBasedRegistrationControls::m_FixedPointListWidget, Ui_QmitkPointBasedRegistrationControls::m_MeanError, Ui_QmitkPointBasedRegistrationControls::m_MeanErrorLCD, Ui_QmitkPointBasedRegistrationControls::m_MovingLabel, Ui_QmitkPointBasedRegistrationControls::m_MovingPointListWidget, m_MultiWidget, Ui_QmitkPointBasedRegistrationControls::m_OpacityLabel, Ui_QmitkPointBasedRegistrationControls::m_OpacitySlider, QmitkFunctionality::m_Parent, Ui_QmitkPointBasedRegistrationControls::m_ShowRedGreenValues, Ui_QmitkPointBasedRegistrationControls::m_SwitchImages, QmitkPointListWidget::SetMultiWidget(), Ui_QmitkPointBasedRegistrationControls::setupUi(), Ui_QmitkPointBasedRegistrationControls::TextLabelFixed, and Ui_QmitkPointBasedRegistrationControls::TextLabelMoving.

void QmitkPointBasedRegistrationView::DataNodeHasBeenRemoved ( const mitk::DataNode node )

Helper method for testing.

Helper method for testing

Definition at line 457 of file QmitkPointBasedRegistrationView.cpp.

References Ui_QmitkPointBasedRegistrationControls::label, Ui_QmitkPointBasedRegistrationControls::label_2, Ui_QmitkPointBasedRegistrationControls::line1, Ui_QmitkPointBasedRegistrationControls::line2, m_Controls, Ui_QmitkPointBasedRegistrationControls::m_FixedLabel, m_FixedNode, Ui_QmitkPointBasedRegistrationControls::m_FixedPointListWidget, Ui_QmitkPointBasedRegistrationControls::m_MovingLabel, m_MovingNode, Ui_QmitkPointBasedRegistrationControls::m_MovingPointListWidget, Ui_QmitkPointBasedRegistrationControls::m_OpacityLabel, Ui_QmitkPointBasedRegistrationControls::m_OpacitySlider, Ui_QmitkPointBasedRegistrationControls::m_ShowRedGreenValues, Ui_QmitkPointBasedRegistrationControls::m_StatusLabel, Ui_QmitkPointBasedRegistrationControls::m_SwitchImages, Ui_QmitkPointBasedRegistrationControls::TextLabelFixed, and Ui_QmitkPointBasedRegistrationControls::TextLabelMoving.

Referenced by QmitkPointBasedRegistrationView().

void QmitkPointBasedRegistrationView::Deactivated (  ) [virtual]

Only called when IsExclusiveFunctionality() returns true.

See also:
IsExclusiveFunctionality()

Reimplemented from QmitkFunctionality.

Definition at line 339 of file QmitkPointBasedRegistrationView.cpp.

References clearTransformationLists(), QmitkPointListWidget::DeactivateInteractor(), QmitkFunctionality::GetDataStorage(), mitk::RenderingManager::GetInstance(), berry::WorkbenchPart::GetSite(), Ui_QmitkPointBasedRegistrationControls::label, Ui_QmitkPointBasedRegistrationControls::label_2, Ui_QmitkPointBasedRegistrationControls::line1, Ui_QmitkPointBasedRegistrationControls::line2, m_Controls, m_CurrentFixedLandmarksObserverID, m_CurrentMovingLandmarksObserverID, m_Deactivated, Ui_QmitkPointBasedRegistrationControls::m_FixedLabel, m_FixedLandmarks, m_FixedNode, Ui_QmitkPointBasedRegistrationControls::m_FixedPointListWidget, m_FixedPointSetNode, Ui_QmitkPointBasedRegistrationControls::m_MovingLabel, m_MovingLandmarks, m_MovingNode, Ui_QmitkPointBasedRegistrationControls::m_MovingPointListWidget, m_MovingPointSetNode, m_OldFixedLabel, m_OldMovingLabel, Ui_QmitkPointBasedRegistrationControls::m_OpacityLabel, Ui_QmitkPointBasedRegistrationControls::m_OpacitySlider, m_OriginalOpacity, m_SelListener, Ui_QmitkPointBasedRegistrationControls::m_SwitchImages, mitk::StringProperty::New(), berry::ISelectionService::RemovePostSelectionListener(), setImageColor(), QmitkPointListWidget::SetPointSetNode(), Ui_QmitkPointBasedRegistrationControls::TextLabelFixed, and Ui_QmitkPointBasedRegistrationControls::TextLabelMoving.

{

  m_Deactivated = true;
  if (m_FixedPointSetNode.IsNotNull())
    m_FixedPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldFixedLabel));
  m_Controls.m_FixedPointListWidget->SetPointSetNode(NULL);
  m_Controls.m_FixedPointListWidget->DeactivateInteractor(true);
  if (m_MovingPointSetNode.IsNotNull())
    m_MovingPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldMovingLabel));
  m_Controls.m_MovingPointListWidget->SetPointSetNode(NULL);
  m_Controls.m_MovingPointListWidget->DeactivateInteractor(true);
  this->setImageColor(false);
  if (m_FixedNode.IsNotNull())
    m_FixedNode->SetOpacity(1.0);
  if (m_MovingNode.IsNotNull())
  {
    m_MovingNode->SetOpacity(m_OriginalOpacity);
  }
  this->clearTransformationLists();
  if (m_FixedPointSetNode.IsNotNull() && m_FixedLandmarks.IsNotNull() && m_FixedLandmarks->GetSize() == 0)
  {
    this->GetDataStorage()->Remove(m_FixedPointSetNode);
  }
  if (m_MovingPointSetNode.IsNotNull() && m_MovingLandmarks.IsNotNull() && m_MovingLandmarks->GetSize() == 0)
  {
    this->GetDataStorage()->Remove(m_MovingPointSetNode);
  }
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
  m_FixedNode = NULL;
  m_MovingNode = NULL;
  if(m_FixedLandmarks.IsNotNull())
    m_FixedLandmarks->RemoveObserver(m_CurrentFixedLandmarksObserverID);
  m_FixedLandmarks = NULL;
  if(m_MovingLandmarks.IsNotNull())
    m_MovingLandmarks->RemoveObserver(m_CurrentMovingLandmarksObserverID);
  m_MovingLandmarks = NULL;
  m_FixedPointSetNode = NULL;
  m_MovingPointSetNode = NULL;
  m_Controls.m_FixedLabel->hide();
  m_Controls.TextLabelFixed->hide();
  m_Controls.line2->hide();
  m_Controls.m_FixedPointListWidget->hide();
  m_Controls.m_MovingLabel->hide();
  m_Controls.TextLabelMoving->hide();
  m_Controls.line1->hide();
  m_Controls.m_MovingPointListWidget->hide();
  m_Controls.m_OpacityLabel->hide();
  m_Controls.m_OpacitySlider->hide();
  m_Controls.label->hide();
  m_Controls.label_2->hide();
  m_Controls.m_SwitchImages->hide();
  berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService();
  if(s)
    s->RemovePostSelectionListener(m_SelListener);
  m_SelListener = NULL;

}
void QmitkPointBasedRegistrationView::FixedSelected ( mitk::DataNode::Pointer  fixedImage ) [protected, slot]

Sets the fixed Image according to TreeNodeSelector widget.

Definition at line 480 of file QmitkPointBasedRegistrationView.cpp.

References QmitkFunctionality::GetDataStorage(), mitk::RenderingManager::GetInstance(), Ui_QmitkPointBasedRegistrationControls::line2, m_Controls, m_CurrentFixedLandmarksObserverID, m_FixedColor, Ui_QmitkPointBasedRegistrationControls::m_FixedLabel, m_FixedLandmarks, m_FixedLandmarksChangedCommand, m_FixedNode, Ui_QmitkPointBasedRegistrationControls::m_FixedPointListWidget, m_FixedPointSetNode, m_OldFixedLabel, m_ShowRedGreen, Ui_QmitkPointBasedRegistrationControls::m_SwitchImages, mitk::ColorProperty::New(), mitk::DataNode::New(), mitk::PointSet::New(), mitk::StringProperty::New(), setImageColor(), QmitkPointListWidget::SetPointSetNode(), and Ui_QmitkPointBasedRegistrationControls::TextLabelFixed.

Referenced by SwitchImages().

{
  if(m_FixedLandmarks.IsNotNull())
    m_FixedLandmarks->RemoveObserver(m_CurrentFixedLandmarksObserverID);
  if (fixedImage.IsNotNull())
  {
    if (m_FixedNode != fixedImage)
    {
      // remove changes on previous selected node
      if (m_FixedNode.IsNotNull())
      {
        this->setImageColor(false);
        m_FixedNode->SetOpacity(1.0);
        if (m_FixedPointSetNode.IsNotNull())
        {
          m_FixedPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldFixedLabel));
        }
      }
      // get selected node
      m_FixedNode = fixedImage;
      m_FixedNode->SetOpacity(0.5);
      m_FixedNode->SetVisibility(true);
      m_Controls.m_FixedLabel->setText(QString::fromStdString(m_FixedNode->GetName()));
      m_Controls.m_FixedLabel->show();
      m_Controls.m_SwitchImages->show();
      m_Controls.TextLabelFixed->show();
      m_Controls.line2->show();
      m_Controls.m_FixedPointListWidget->show();
      mitk::ColorProperty::Pointer colorProperty;
      colorProperty = dynamic_cast<mitk::ColorProperty*>(m_FixedNode->GetProperty("color"));
      if ( colorProperty.IsNotNull() )
      {
        m_FixedColor = colorProperty->GetColor();
      }
      this->setImageColor(m_ShowRedGreen);

      bool hasPointSetNode = false;
      mitk::DataStorage::SetOfObjects::ConstPointer children = this->GetDataStorage()->GetDerivations(m_FixedNode);
      unsigned long size;
      size = children->Size();
      for (unsigned long i = 0; i < size; ++i)
      {
        mitk::StringProperty::Pointer nameProp = dynamic_cast<mitk::StringProperty*>(children->GetElement(i)->GetProperty("name"));
        if(nameProp.IsNotNull() && nameProp->GetValueAsString()=="PointBasedRegistrationNode")
        {
          m_FixedPointSetNode=children->GetElement(i);
          m_FixedLandmarks = dynamic_cast<mitk::PointSet*> (m_FixedPointSetNode->GetData());
          this->GetDataStorage()->Remove(m_FixedPointSetNode);
          hasPointSetNode = true;
          break;
        }
      }
      if (!hasPointSetNode)
      {
        m_FixedLandmarks = mitk::PointSet::New();
        m_FixedPointSetNode = mitk::DataNode::New();
        m_FixedPointSetNode->SetData(m_FixedLandmarks);
        m_FixedPointSetNode->SetProperty("name", mitk::StringProperty::New("PointBasedRegistrationNode"));
      }
      m_FixedPointSetNode->GetStringProperty("label", m_OldFixedLabel);
      m_FixedPointSetNode->SetProperty("label", mitk::StringProperty::New("F "));
      m_FixedPointSetNode->SetProperty("color", mitk::ColorProperty::New(0.0f, 1.0f, 1.0f));
      m_FixedPointSetNode->SetVisibility(true);
      m_Controls.m_FixedPointListWidget->SetPointSetNode(m_FixedPointSetNode);
      this->GetDataStorage()->Add(m_FixedPointSetNode, m_FixedNode);
      
      mitk::RenderingManager::GetInstance()->RequestUpdateAll();
    }
    if (m_FixedPointSetNode.IsNull())
    {
      m_FixedLandmarks = mitk::PointSet::New();
      m_FixedPointSetNode = mitk::DataNode::New();
      m_FixedPointSetNode->SetData(m_FixedLandmarks);
      m_FixedPointSetNode->SetProperty("name", mitk::StringProperty::New("PointBasedRegistrationNode"));

      m_FixedPointSetNode->GetStringProperty("label", m_OldFixedLabel);
      m_FixedPointSetNode->SetProperty("label", mitk::StringProperty::New("F "));
      m_FixedPointSetNode->SetProperty("color", mitk::ColorProperty::New(0.0f, 1.0f, 1.0f));
      m_FixedPointSetNode->SetVisibility(true);
      m_Controls.m_FixedPointListWidget->SetPointSetNode(m_FixedPointSetNode);
      this->GetDataStorage()->Add(m_FixedPointSetNode, m_FixedNode);
      
      mitk::RenderingManager::GetInstance()->RequestUpdateAll();
    }
  }
  else
  {
    m_FixedNode = NULL;
    if (m_FixedPointSetNode.IsNotNull())
      m_FixedPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldFixedLabel));
    m_FixedPointSetNode = NULL;
    m_FixedLandmarks = NULL;
    m_Controls.m_FixedPointListWidget->SetPointSetNode(m_FixedPointSetNode);
    m_Controls.m_FixedLabel->hide();
    m_Controls.TextLabelFixed->hide();
    m_Controls.line2->hide();
    m_Controls.m_FixedPointListWidget->hide();
    m_Controls.m_SwitchImages->hide();
  }
  if(m_FixedLandmarks.IsNotNull())
    m_CurrentFixedLandmarksObserverID = m_FixedLandmarks->AddObserver(itk::ModifiedEvent(), m_FixedLandmarksChangedCommand);
}
void QmitkPointBasedRegistrationView::Hidden (  ) [virtual]

Called when this functionality is hidden ( no matter what IsExclusiveFunctionality() returns )

Reimplemented from QmitkFunctionality.

Definition at line 398 of file QmitkPointBasedRegistrationView.cpp.

{
  /*
  m_Deactivated = true;
  if (m_FixedPointSetNode.IsNotNull())
    m_FixedPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldFixedLabel));
  m_Controls.m_FixedPointListWidget->SetPointSetNode(NULL);
  m_Controls.m_FixedPointListWidget->DeactivateInteractor(true);
  if (m_MovingPointSetNode.IsNotNull())
    m_MovingPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldMovingLabel));
  m_Controls.m_MovingPointListWidget->SetPointSetNode(NULL);
  m_Controls.m_MovingPointListWidget->DeactivateInteractor(true);
  this->setImageColor(false);
  if (m_MovingNode.IsNotNull())
  {
    m_MovingNode->SetOpacity(m_OriginalOpacity);
  }
  this->clearTransformationLists();
  if (m_FixedPointSetNode.IsNotNull() && m_FixedLandmarks.IsNotNull() && m_FixedLandmarks->GetSize() == 0)
  {
    this->GetDataStorage()->Remove(m_FixedPointSetNode);
  }
  if (m_MovingPointSetNode.IsNotNull() && m_MovingLandmarks.IsNotNull() && m_MovingLandmarks->GetSize() == 0)
  {
    this->GetDataStorage()->Remove(m_MovingPointSetNode);
  }
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
  m_FixedNode = NULL;
  m_MovingNode = NULL;
  if(m_FixedLandmarks.IsNotNull())
    m_FixedLandmarks->RemoveObserver(m_CurrentFixedLandmarksObserverID);
  m_FixedLandmarks = NULL;
  if(m_MovingLandmarks.IsNotNull())
    m_MovingLandmarks->RemoveObserver(m_CurrentMovingLandmarksObserverID);
  m_MovingLandmarks = NULL;
  m_FixedPointSetNode = NULL;
  m_MovingPointSetNode = NULL;
  m_Controls.m_FixedLabel->hide();
  m_Controls.TextLabelFixed->hide();
  m_Controls.line2->hide();
  m_Controls.m_FixedPointListWidget->hide();
  m_Controls.m_MovingLabel->hide();
  m_Controls.TextLabelMoving->hide();
  m_Controls.line1->hide();
  m_Controls.m_MovingPointListWidget->hide();
  m_Controls.m_OpacityLabel->hide();
  m_Controls.m_OpacitySlider->hide();
  m_Controls.label->hide();
  m_Controls.label_2->hide();
  m_Controls.m_SwitchImages->hide();
  berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService();
  if(s)
    s->RemovePostSelectionListener(m_SelListener);
  m_SelListener = NULL;
  //mitk::RenderingManager::GetInstance()->RequestUpdateAll();
  //QmitkFunctionality::Deactivated();*/
}
void QmitkPointBasedRegistrationView::HideFixedImage ( bool  hide ) [protected, slot]

lets the moving image become invisible and the fixed image visible

Definition at line 724 of file QmitkPointBasedRegistrationView.cpp.

References mitk::RenderingManager::GetInstance(), m_FixedNode, m_HideFixedImage, and m_HideMovingImage.

Referenced by CreateConnections().

{
  m_HideFixedImage = hide;
  if(m_FixedNode.IsNotNull())
  {
    m_FixedNode->SetVisibility(!hide);
  }
  if (hide)
  {
    //this->reinitMovingClicked();
  }
  if (!m_HideMovingImage && !m_HideFixedImage)
  {
    //this->globalReinitClicked();
  }
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
void QmitkPointBasedRegistrationView::HideMovingImage ( bool  hide ) [protected, slot]

lets the fixed image become invisible and the moving image visible

Definition at line 742 of file QmitkPointBasedRegistrationView.cpp.

References mitk::RenderingManager::GetInstance(), m_HideFixedImage, m_HideMovingImage, and m_MovingNode.

Referenced by CreateConnections().

{
  m_HideMovingImage = hide;
  if(m_MovingNode.IsNotNull())
  {
    m_MovingNode->SetVisibility(!hide);
  }
  if (hide)
  {
    //this->reinitFixedClicked();
  }
  if (!m_HideMovingImage && !m_HideFixedImage)
  {
    //this->globalReinitClicked();
  }
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
void QmitkPointBasedRegistrationView::MovingSelected ( mitk::DataNode::Pointer  movingImage ) [protected, slot]

Sets the moving Image according to TreeNodeSelector widget.

Definition at line 583 of file QmitkPointBasedRegistrationView.cpp.

References clearTransformationLists(), QmitkFunctionality::GetDataStorage(), mitk::RenderingManager::GetInstance(), Ui_QmitkPointBasedRegistrationControls::label, Ui_QmitkPointBasedRegistrationControls::label_2, Ui_QmitkPointBasedRegistrationControls::line1, m_Controls, m_CurrentMovingLandmarksObserverID, m_FixedNode, m_MovingColor, Ui_QmitkPointBasedRegistrationControls::m_MovingLabel, m_MovingLandmarks, m_MovingLandmarksChangedCommand, m_MovingNode, Ui_QmitkPointBasedRegistrationControls::m_MovingPointListWidget, m_MovingPointSetNode, m_OldFixedLabel, m_OldMovingLabel, m_Opacity, Ui_QmitkPointBasedRegistrationControls::m_OpacityLabel, Ui_QmitkPointBasedRegistrationControls::m_OpacitySlider, m_OriginalOpacity, m_ShowRedGreen, mitk::ColorProperty::New(), mitk::DataNode::New(), mitk::PointSet::New(), mitk::StringProperty::New(), OpacityUpdate(), setImageColor(), QmitkPointListWidget::SetPointSetNode(), and Ui_QmitkPointBasedRegistrationControls::TextLabelMoving.

Referenced by SwitchImages().

{
  if(m_MovingLandmarks.IsNotNull())
    m_MovingLandmarks->RemoveObserver(m_CurrentMovingLandmarksObserverID);
  if (movingImage.IsNotNull())
  {
    if (m_MovingNode != movingImage)
    {
      if (m_MovingNode.IsNotNull())
      {
        m_MovingNode->SetOpacity(m_OriginalOpacity);
        if (m_FixedNode == m_MovingNode)
          m_FixedNode->SetOpacity(0.5);
        this->setImageColor(false);
        if (m_MovingNode != m_FixedNode)
        {
          m_MovingPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldMovingLabel));
        }
        else
        {
          m_OldFixedLabel = m_OldMovingLabel;
        }
      }
      if (m_MovingPointSetNode.IsNotNull())
        m_MovingPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldMovingLabel));
      m_MovingNode = movingImage;
      m_MovingNode->SetVisibility(true);
      m_Controls.m_MovingLabel->setText(QString::fromStdString(m_MovingNode->GetName()));
      m_Controls.m_MovingLabel->show();
      m_Controls.TextLabelMoving->show();
      m_Controls.line1->show();
      m_Controls.m_MovingPointListWidget->show();
      m_Controls.m_OpacityLabel->show();
      m_Controls.m_OpacitySlider->show();
      m_Controls.label->show();
      m_Controls.label_2->show();
      mitk::ColorProperty::Pointer colorProperty;
      colorProperty = dynamic_cast<mitk::ColorProperty*>(m_MovingNode->GetProperty("color"));
      if ( colorProperty.IsNotNull() )
      {
        m_MovingColor = colorProperty->GetColor();
      }
      this->setImageColor(m_ShowRedGreen);
      m_MovingNode->GetFloatProperty("opacity", m_OriginalOpacity);
      this->OpacityUpdate(m_Opacity);
      bool hasPointSetNode = false;
      mitk::DataStorage::SetOfObjects::ConstPointer children = this->GetDataStorage()->GetDerivations(m_MovingNode);
      unsigned long size;
      size = children->Size();
      for (unsigned long i = 0; i < size; ++i)
      {
        mitk::StringProperty::Pointer nameProp = dynamic_cast<mitk::StringProperty*>(children->GetElement(i)->GetProperty("name"));
        if(nameProp.IsNotNull() && nameProp->GetValueAsString()=="PointBasedRegistrationNode")
        {
          m_MovingPointSetNode=children->GetElement(i);
          m_MovingLandmarks = dynamic_cast<mitk::PointSet*> (m_MovingPointSetNode->GetData());
          this->GetDataStorage()->Remove(m_MovingPointSetNode);
          hasPointSetNode = true;
          break;
        }
      }
      if (!hasPointSetNode)
      {
        m_MovingLandmarks = mitk::PointSet::New();
        m_MovingPointSetNode = mitk::DataNode::New();
        m_MovingPointSetNode->SetData(m_MovingLandmarks);
        m_MovingPointSetNode->SetProperty("name", mitk::StringProperty::New("PointBasedRegistrationNode"));
      }
      this->GetDataStorage()->Add(m_MovingPointSetNode, m_MovingNode);
      m_MovingPointSetNode->GetStringProperty("label", m_OldMovingLabel);
      m_MovingPointSetNode->SetProperty("label", mitk::StringProperty::New("M "));
      m_MovingPointSetNode->SetProperty("color", mitk::ColorProperty::New(1.0f, 1.0f, 0.0f));
      m_MovingPointSetNode->SetVisibility(true);
      m_Controls.m_MovingPointListWidget->SetPointSetNode(m_MovingPointSetNode);
      mitk::RenderingManager::GetInstance()->RequestUpdateAll();
      this->clearTransformationLists();
      this->OpacityUpdate(m_Opacity);
    }
    if (m_MovingPointSetNode.IsNull())
    {
      m_MovingLandmarks = mitk::PointSet::New();
      m_MovingPointSetNode = mitk::DataNode::New();
      m_MovingPointSetNode->SetData(m_MovingLandmarks);
      m_MovingPointSetNode->SetProperty("name", mitk::StringProperty::New("PointBasedRegistrationNode"));

      m_MovingPointSetNode->GetStringProperty("label", m_OldMovingLabel);
      m_MovingPointSetNode->SetProperty("label", mitk::StringProperty::New("M "));
      m_MovingPointSetNode->SetProperty("color", mitk::ColorProperty::New(1.0f, 1.0f, 0.0f));
      m_MovingPointSetNode->SetVisibility(true);
      m_Controls.m_MovingPointListWidget->SetPointSetNode(m_MovingPointSetNode);
      this->GetDataStorage()->Add(m_MovingPointSetNode, m_MovingNode);

      mitk::RenderingManager::GetInstance()->RequestUpdateAll();      
     
    }
    


   
  }
  else
  {
    m_MovingNode = NULL;
    if (m_MovingPointSetNode.IsNotNull())
      m_MovingPointSetNode->SetProperty("label", mitk::StringProperty::New(m_OldMovingLabel));
    m_MovingPointSetNode = NULL;
    m_MovingLandmarks = NULL;
    m_Controls.m_MovingPointListWidget->SetPointSetNode(m_MovingPointSetNode);
    m_Controls.m_MovingLabel->hide();
    m_Controls.TextLabelMoving->hide();
    m_Controls.line1->hide();
    m_Controls.m_MovingPointListWidget->hide();
    m_Controls.m_OpacityLabel->hide();
    m_Controls.m_OpacitySlider->hide();
    m_Controls.label->hide();
    m_Controls.label_2->hide();
  }
  if(m_MovingLandmarks.IsNotNull())
    m_CurrentMovingLandmarksObserverID = m_MovingLandmarks->AddObserver(itk::ModifiedEvent(), m_MovingLandmarksChangedCommand);
}
void QmitkPointBasedRegistrationView::OpacityUpdate ( float  opacity ) [protected, slot]

Sets the selected opacity for moving image.

Parameters:
opacitythe selected opacity

Definition at line 872 of file QmitkPointBasedRegistrationView.cpp.

References mitk::RenderingManager::GetInstance(), m_MovingNode, and m_Opacity.

Referenced by Activated(), CreateConnections(), MovingSelected(), and OpacityUpdate().

{
  if (opacity > 1)
  {
    opacity = opacity/100.0f;
  }
  m_Opacity = opacity;
  if (m_MovingNode.IsNotNull())
  {
    m_MovingNode->SetOpacity(m_Opacity);
  }
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
void QmitkPointBasedRegistrationView::OpacityUpdate ( int  opacity ) [protected, slot]

Sets the selected opacity for moving image.

Parameters:
opacitythe selected opacity

Definition at line 886 of file QmitkPointBasedRegistrationView.cpp.

References OpacityUpdate().

{
  float fValue = ((float)opacity)/100.0f;
  this->OpacityUpdate(fValue);
}
void QmitkPointBasedRegistrationView::RedoTransformation (  ) [protected, slot]

Performs a redo for the last undo transform.

Definition at line 807 of file QmitkPointBasedRegistrationView.cpp.

References checkLandmarkError(), mitk::RenderingManager::GetInstance(), berry::SmartPointer< TObjectType >::GetPointer(), m_Controls, m_MovingLandmarks, m_MovingNode, m_MovingPointSetNode, m_MultiWidget, m_RedoGeometryList, m_RedoPointsGeometryList, Ui_QmitkPointBasedRegistrationControls::m_RedoTransformation, m_UndoGeometryList, m_UndoPointsGeometryList, Ui_QmitkPointBasedRegistrationControls::m_UndoTransformation, and QmitkStdMultiWidget::mitkWidget4.

Referenced by CreateConnections().

{
  if(!m_RedoPointsGeometryList.empty())
  {
    mitk::AffineGeometryFrame3D::Pointer movingLandmarksGeometry = m_MovingLandmarks->GetGeometry(0)->Clone();
    m_UndoPointsGeometryList.push_back(static_cast<mitk::Geometry3D *>(movingLandmarksGeometry.GetPointer()));
    m_MovingLandmarks->SetGeometry(m_RedoPointsGeometryList.back());
    m_RedoPointsGeometryList.pop_back();
    //\FIXME when geometry is substituted the matrix referenced by the actor created by the mapper
    //is still pointing to the old one. Workaround: delete mapper
    m_MovingPointSetNode->SetMapper(1, NULL);

    mitk::BaseData::Pointer movingData = m_MovingNode->GetData();
    mitk::AffineGeometryFrame3D::Pointer movingGeometry = movingData->GetGeometry(0)->Clone();
    m_UndoGeometryList.push_back(static_cast<mitk::Geometry3D *>(movingGeometry.GetPointer()));
    movingData->SetGeometry(m_RedoGeometryList.back());
    m_RedoGeometryList.pop_back();
    //\FIXME when geometry is substituted the matrix referenced by the actor created by the mapper
    //is still pointing to the old one. Workaround: delete mapper
    m_MovingNode->SetMapper(1, NULL);
    mitk::RenderingManager::GetInstance()->RequestUpdate(m_MultiWidget->mitkWidget4->GetRenderWindow());

    movingData->GetTimeSlicedGeometry()->UpdateInformation();
    m_MovingLandmarks->GetTimeSlicedGeometry()->UpdateInformation();
    m_Controls.m_UndoTransformation->setEnabled(true);
    mitk::RenderingManager::GetInstance()->RequestUpdateAll();
    this->checkLandmarkError();
  }
  if(!m_RedoPointsGeometryList.empty())
  {
    m_Controls.m_RedoTransformation->setEnabled(true);
  }
  else
  {
    m_Controls.m_RedoTransformation->setEnabled(false);
  }
}
void QmitkPointBasedRegistrationView::setImageColor ( bool  redGreen ) [protected, slot]

Sets the images to gray values or fixed image to red and moving image to green.

Parameters:
redGreenif true, then images will be shown in red and green

Definition at line 851 of file QmitkPointBasedRegistrationView.cpp.

References mitk::RenderingManager::GetInstance(), m_FixedColor, m_FixedNode, m_MovingColor, and m_MovingNode.

Referenced by Deactivated(), FixedSelected(), MovingSelected(), and showRedGreen().

{
  if (!redGreen && m_FixedNode.IsNotNull())
  {
    m_FixedNode->SetColor(m_FixedColor);
  }
  if (!redGreen && m_MovingNode.IsNotNull())
  {
    m_MovingNode->SetColor(m_MovingColor);
  }
  if (redGreen && m_FixedNode.IsNotNull())
  {
    m_FixedNode->SetColor(1.0f, 0.0f, 0.0f);
  }
  if (redGreen && m_MovingNode.IsNotNull())
  {
    m_MovingNode->SetColor(0.0f, 1.0f, 0.0f);
  }
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
void QmitkPointBasedRegistrationView::SetImagesVisible ( berry::ISelection::ConstPointer   ) [protected, slot]

Definition at line 1315 of file QmitkPointBasedRegistrationView.cpp.

References QmitkFunctionality::GetDataStorage(), and m_CurrentSelection.

{
  if (this->m_CurrentSelection->Size() == 0)
  {
    // show all images
    mitk::DataStorage::SetOfObjects::ConstPointer setOfObjects = this->GetDataStorage()->GetAll();
    for (mitk::DataStorage::SetOfObjects::ConstIterator nodeIt = setOfObjects->Begin()
      ; nodeIt != setOfObjects->End(); ++nodeIt)  // for each node
    {
      if ( (nodeIt->Value().IsNotNull()) && (nodeIt->Value()->GetProperty("visible")) && dynamic_cast<mitk::Geometry2DData*>(nodeIt->Value()->GetData())==NULL)
      {
        nodeIt->Value()->SetVisibility(true);
      }
    }
  }
  else
  {
    // hide all images
    mitk::DataStorage::SetOfObjects::ConstPointer setOfObjects = this->GetDataStorage()->GetAll();
    for (mitk::DataStorage::SetOfObjects::ConstIterator nodeIt = setOfObjects->Begin()
      ; nodeIt != setOfObjects->End(); ++nodeIt)  // for each node
    {
      if ( (nodeIt->Value().IsNotNull()) && (nodeIt->Value()->GetProperty("visible")) && dynamic_cast<mitk::Geometry2DData*>(nodeIt->Value()->GetData())==NULL)
      {
        nodeIt->Value()->SetVisibility(false);
      }
    }
  }
}
void QmitkPointBasedRegistrationView::showRedGreen ( bool  show ) [protected, slot]

Stores whether the image will be shown in grayvalues or in red for fixed image and green for moving image.

Parameters:
showif true, then images will be shown in red and green

Definition at line 845 of file QmitkPointBasedRegistrationView.cpp.

References m_ShowRedGreen, and setImageColor().

Referenced by Activated(), and CreateConnections().

void QmitkPointBasedRegistrationView::StdMultiWidgetAvailable ( QmitkStdMultiWidget stdMultiWidget ) [virtual]
void QmitkPointBasedRegistrationView::StdMultiWidgetNotAvailable (  ) [virtual]
void QmitkPointBasedRegistrationView::SwitchImages (  ) [protected, slot]

Definition at line 1345 of file QmitkPointBasedRegistrationView.cpp.

References FixedSelected(), m_FixedNode, m_MovingNode, and MovingSelected().

Referenced by CreateConnections().

{
  mitk::DataNode::Pointer newMoving = m_FixedNode;
  mitk::DataNode::Pointer newFixed = m_MovingNode;
  this->FixedSelected(newFixed);
  this->MovingSelected(newMoving);
}
void QmitkPointBasedRegistrationView::transformationChanged ( int  transform ) [protected, slot]

Changes the transformation type and calls checkLandmarkError().

Definition at line 992 of file QmitkPointBasedRegistrationView.cpp.

References checkCalculateEnabled(), checkLandmarkError(), and m_Transformation.

Referenced by CreateConnections().

{
  m_Transformation = transform;
  this->checkCalculateEnabled();
  this->checkLandmarkError();
}
void QmitkPointBasedRegistrationView::UndoTransformation (  ) [protected, slot]

Performs an undo for the last transform.

Definition at line 769 of file QmitkPointBasedRegistrationView.cpp.

References checkLandmarkError(), mitk::RenderingManager::GetInstance(), berry::SmartPointer< TObjectType >::GetPointer(), m_Controls, m_MovingLandmarks, m_MovingNode, m_MovingPointSetNode, m_MultiWidget, m_RedoGeometryList, m_RedoPointsGeometryList, Ui_QmitkPointBasedRegistrationControls::m_RedoTransformation, m_UndoGeometryList, m_UndoPointsGeometryList, Ui_QmitkPointBasedRegistrationControls::m_UndoTransformation, and QmitkStdMultiWidget::mitkWidget4.

Referenced by CreateConnections().

{
  if(!m_UndoPointsGeometryList.empty())
  {
    mitk::AffineGeometryFrame3D::Pointer movingLandmarksGeometry = m_MovingLandmarks->GetGeometry(0)->Clone();
    m_RedoPointsGeometryList.push_back(static_cast<mitk::Geometry3D *>(movingLandmarksGeometry.GetPointer()));
    m_MovingLandmarks->SetGeometry(m_UndoPointsGeometryList.back());
    m_UndoPointsGeometryList.pop_back();
    //\FIXME when geometry is substituted the matrix referenced by the actor created by the mapper
    //is still pointing to the old one. Workaround: delete mapper
    m_MovingPointSetNode->SetMapper(1, NULL);

    mitk::BaseData::Pointer movingData = m_MovingNode->GetData();
    mitk::AffineGeometryFrame3D::Pointer movingGeometry = movingData->GetGeometry(0)->Clone();
    m_RedoGeometryList.push_back(static_cast<mitk::Geometry3D *>(movingGeometry.GetPointer()));
    movingData->SetGeometry(m_UndoGeometryList.back());
    m_UndoGeometryList.pop_back();
    //\FIXME when geometry is substituted the matrix referenced by the actor created by the mapper
    //is still pointing to the old one. Workaround: delete mapper
    m_MovingNode->SetMapper(1, NULL);
    mitk::RenderingManager::GetInstance()->RequestUpdate(m_MultiWidget->mitkWidget4->GetRenderWindow());

    movingData->GetTimeSlicedGeometry()->UpdateInformation();
    m_MovingLandmarks->GetTimeSlicedGeometry()->UpdateInformation();
    m_Controls.m_RedoTransformation->setEnabled(true);
    mitk::RenderingManager::GetInstance()->RequestUpdateAll();
    this->checkLandmarkError();
  }
  if(!m_UndoPointsGeometryList.empty())
  {
    m_Controls.m_UndoTransformation->setEnabled(true);
  }
  else
  {
    m_Controls.m_UndoTransformation->setEnabled(false);
  }
}
void QmitkPointBasedRegistrationView::updateFixedLandmarksList (  ) [protected, slot]

Updates the fixed landmarks.

Definition at line 717 of file QmitkPointBasedRegistrationView.cpp.

References CheckCalculate(), checkLandmarkError(), m_FixedLandmarks, and m_FixedPointSetNode.

Referenced by CreateConnections(), and QmitkPointBasedRegistrationView().

{
  m_FixedLandmarks = dynamic_cast<mitk::PointSet*>(m_FixedPointSetNode->GetData());
  this->checkLandmarkError();
  this->CheckCalculate();
}
void QmitkPointBasedRegistrationView::updateMovingLandmarksList (  ) [protected, slot]

Updates the moving landmarks.

Definition at line 704 of file QmitkPointBasedRegistrationView.cpp.

References CheckCalculate(), checkLandmarkError(), m_MovingLandmarks, and m_MovingPointSetNode.

Referenced by CreateConnections(), and QmitkPointBasedRegistrationView().

{
//  mitk::PointSet* ps = mitk::PointSet::New();
//  ps = dynamic_cast<mitk::PointSet*>(m_MovingPointSetNode->GetData());
//  mitk::DataNode::Pointer tmpPtr = m_MovingPointSetNode;
//  m_MovingLandmarks = 0;
//  m_MovingLandmarks = (ps);
  m_MovingLandmarks = dynamic_cast<mitk::PointSet*>(m_MovingPointSetNode->GetData());
//  m_Controls.m_MovingPointListWidget->SetPointSetNode(m_MovingPointSetNode);    //Workaround: m_MovingPointListWidget->m_PointListView->m_PointListModel loses the pointer on the pointsetnode
  this->checkLandmarkError();
  this->CheckCalculate();
}
void QmitkPointBasedRegistrationView::Visible (  ) [virtual]

Called when this functionality becomes visible ( no matter what IsExclusiveFunctionality() returns )

Reimplemented from QmitkFunctionality.

Definition at line 334 of file QmitkPointBasedRegistrationView.cpp.

{

}

Friends And Related Function Documentation

friend struct SelListenerPointBasedRegistration [friend]

Definition at line 57 of file QmitkPointBasedRegistrationView.h.

Referenced by Activated().


Member Data Documentation

Definition at line 293 of file QmitkPointBasedRegistrationView.h.

Referenced by Deactivated(), and FixedSelected().

Definition at line 294 of file QmitkPointBasedRegistrationView.h.

Referenced by Deactivated(), and MovingSelected().

Definition at line 292 of file QmitkPointBasedRegistrationView.h.

Referenced by Activated(), and Deactivated().

Definition at line 285 of file QmitkPointBasedRegistrationView.h.

Referenced by FixedSelected(), and setImageColor().

Definition at line 288 of file QmitkPointBasedRegistrationView.h.

Referenced by HideFixedImage(), and HideMovingImage().

Definition at line 289 of file QmitkPointBasedRegistrationView.h.

Referenced by HideFixedImage(), and HideMovingImage().

Definition at line 286 of file QmitkPointBasedRegistrationView.h.

Referenced by MovingSelected(), and setImageColor().

default main widget containing 4 windows showing 3 orthogonal slices of the volume and a 3d render window

Definition at line 266 of file QmitkPointBasedRegistrationView.h.

Referenced by CreateQtPartControl(), RedoTransformation(), StdMultiWidgetAvailable(), StdMultiWidgetNotAvailable(), and UndoTransformation().

Definition at line 283 of file QmitkPointBasedRegistrationView.h.

Referenced by MovingSelected(), and OpacityUpdate().

Definition at line 284 of file QmitkPointBasedRegistrationView.h.

Referenced by Deactivated(), and MovingSelected().

Definition at line 282 of file QmitkPointBasedRegistrationView.h.

Referenced by FixedSelected(), MovingSelected(), and showRedGreen().

const std::string QmitkPointBasedRegistrationView::VIEW_ID = "org.mitk.views.pointbasedregistration" [static]

Definition at line 63 of file QmitkPointBasedRegistrationView.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines