コード例 #1
0
void QmitkImageNavigatorView::SetBorderColors()
{
  if (m_IRenderWindowPart)
  {
    QString decoColor;

    QmitkRenderWindow* renderWindow = m_IRenderWindowPart->GetQmitkRenderWindow("axial");
    if (renderWindow)
    {
      decoColor = GetDecorationColorOfGeometry(renderWindow);
      mitk::PlaneGeometry::ConstPointer geometry = renderWindow->GetSliceNavigationController()->GetCurrentPlaneGeometry();
      if (geometry.IsNotNull())
      {
        mitk::Vector3D normal = geometry->GetNormal();
        int axis = this->GetClosestAxisIndex(normal);
        this->SetBorderColor(axis, decoColor);
      }
    }

    renderWindow = m_IRenderWindowPart->GetQmitkRenderWindow("sagittal");
    if (renderWindow)
    {
      decoColor = GetDecorationColorOfGeometry(renderWindow);
      mitk::PlaneGeometry::ConstPointer geometry = renderWindow->GetSliceNavigationController()->GetCurrentPlaneGeometry();
      if (geometry.IsNotNull())
      {
        mitk::Vector3D normal = geometry->GetNormal();
        int axis = this->GetClosestAxisIndex(normal);
        this->SetBorderColor(axis, decoColor);
      }
    }

    renderWindow = m_IRenderWindowPart->GetQmitkRenderWindow("coronal");
    if (renderWindow)
    {
      decoColor = GetDecorationColorOfGeometry(renderWindow);
      mitk::PlaneGeometry::ConstPointer geometry = renderWindow->GetSliceNavigationController()->GetCurrentPlaneGeometry();
      if (geometry.IsNotNull())
      {
        mitk::Vector3D normal = geometry->GetNormal();
        int axis = this->GetClosestAxisIndex(normal);
        this->SetBorderColor(axis, decoColor);
      }
    }
  }
}
コード例 #2
0
ファイル: CLGlobalImageFeatures.cpp プロジェクト: Cdebus/MITK
static
void SaveSliceOrImageAsPNG(mitk::Image::Pointer image, mitk::Image::Pointer mask, std::string path, int index)
{
  // Create a Standalone Datastorage for the single purpose of saving screenshots..
  mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New();
  QmitkRenderWindow renderWindow;
  renderWindow.GetRenderer()->SetDataStorage(ds);

  auto nodeI = mitk::DataNode::New();
  nodeI->SetData(image);
  auto nodeM = mitk::DataNode::New();
  nodeM->SetData(mask);
  ds->Add(nodeI);
  ds->Add(nodeM);

  auto geo = ds->ComputeBoundingGeometry3D(ds->GetAll());
  mitk::RenderingManager::GetInstance()->InitializeViews(geo);

  mitk::SliceNavigationController::Pointer sliceNaviController = renderWindow.GetSliceNavigationController();
  unsigned int numberOfSteps = 1;
  if (sliceNaviController)
  {
    numberOfSteps = sliceNaviController->GetSlice()->GetSteps();
    sliceNaviController->GetSlice()->SetPos(0);
  }

  renderWindow.show();
  renderWindow.resize(256, 256);

  for (unsigned int currentStep = 0; currentStep < numberOfSteps; ++currentStep)
  {
    if (sliceNaviController)
    {
      sliceNaviController->GetSlice()->SetPos(currentStep);
    }

    renderWindow.GetRenderer()->PrepareRender();

    vtkRenderWindow* renderWindow2 = renderWindow.GetVtkRenderWindow();
    mitk::BaseRenderer* baserenderer = mitk::BaseRenderer::GetInstance(renderWindow2);
    auto vtkRender = baserenderer->GetVtkRenderer();
    vtkRender->GetRenderWindow()->WaitForCompletion();

    vtkRenderLargeImage* magnifier = vtkRenderLargeImage::New();
    magnifier->SetInput(vtkRender);
    magnifier->SetMagnification(3.0);

    std::stringstream ss;
    ss << path << "_Idx-" << index << "_Step-"<<currentStep<<".png";
    std::string tmpImageName;
    ss >> tmpImageName;
    auto fileWriter = vtkPNGWriter::New();
    fileWriter->SetInputConnection(magnifier->GetOutputPort());
    fileWriter->SetFileName(tmpImageName.c_str());
    fileWriter->Write();
    fileWriter->Delete();
  }
}
コード例 #3
0
void QmitkSegmentationView::OnContourMarkerSelected(const mitk::DataNode *node)
{
   QmitkRenderWindow* selectedRenderWindow = 0;
   QmitkRenderWindow* axialRenderWindow =
      this->GetRenderWindowPart(OPEN)->GetQmitkRenderWindow("axial");
   QmitkRenderWindow* sagittalRenderWindow =
      this->GetRenderWindowPart(OPEN)->GetQmitkRenderWindow("sagittal");
   QmitkRenderWindow* coronalRenderWindow =
      this->GetRenderWindowPart(OPEN)->GetQmitkRenderWindow("coronal");
   QmitkRenderWindow* _3DRenderWindow =
      this->GetRenderWindowPart(OPEN)->GetQmitkRenderWindow("3d");
   bool PlanarFigureInitializedWindow = false;

   // find initialized renderwindow
   if (node->GetBoolProperty("PlanarFigureInitializedWindow",
      PlanarFigureInitializedWindow, axialRenderWindow->GetRenderer()))
   {
      selectedRenderWindow = axialRenderWindow;
   }
   if (!selectedRenderWindow && node->GetBoolProperty(
      "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
      sagittalRenderWindow->GetRenderer()))
   {
      selectedRenderWindow = sagittalRenderWindow;
   }
   if (!selectedRenderWindow && node->GetBoolProperty(
      "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
      coronalRenderWindow->GetRenderer()))
   {
      selectedRenderWindow = coronalRenderWindow;
   }
   if (!selectedRenderWindow && node->GetBoolProperty(
      "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
      _3DRenderWindow->GetRenderer()))
   {
      selectedRenderWindow = _3DRenderWindow;
   }

   // make node visible
   if (selectedRenderWindow)
   {
      std::string nodeName = node->GetName();
      unsigned int t = nodeName.find_last_of(" ");
      unsigned int id = atof(nodeName.substr(t+1).c_str())-1;

      {
         ctkPluginContext* context = mitk::PluginActivator::getContext();
         ctkServiceReference ppmRef = context->getServiceReference<mitk::PlanePositionManagerService>();
         mitk::PlanePositionManagerService* service = context->getService<mitk::PlanePositionManagerService>(ppmRef);
         selectedRenderWindow->GetSliceNavigationController()->ExecuteOperation(service->GetPlanePosition(id));
         context->ungetService(ppmRef);
      }

      selectedRenderWindow->GetRenderer()->GetCameraController()->Fit();
      mitk::RenderingManager::GetInstance()->RequestUpdateAll();
   }
}
コード例 #4
0
void QmitkImageNavigatorView::RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart)
{
  if (this->m_IRenderWindowPart != renderWindowPart)
  {
    this->m_IRenderWindowPart = renderWindowPart;
    this->m_Parent->setEnabled(true);

    QmitkRenderWindow* renderWindow = renderWindowPart->GetRenderWindow("axial");
    if (renderWindow)
    {
      if (m_AxialStepper) m_AxialStepper->deleteLater();
      m_AxialStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorAxial,
                                                     renderWindow->GetSliceNavigationController()->GetSlice(),
                                                     "sliceNavigatorAxialFromSimpleExample");
      m_Controls.m_SliceNavigatorAxial->setEnabled(true);
      m_Controls.m_AxialLabel->setEnabled(true);
      m_Controls.m_ZWorldCoordinateSpinBox->setEnabled(true);
      connect(m_AxialStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch()));
    }
    else
    {
      m_Controls.m_SliceNavigatorAxial->setEnabled(false);
      m_Controls.m_AxialLabel->setEnabled(false);
      m_Controls.m_ZWorldCoordinateSpinBox->setEnabled(false);
    }

    renderWindow = renderWindowPart->GetRenderWindow("sagittal");
    if (renderWindow)
    {
      if (m_SagittalStepper) m_SagittalStepper->deleteLater();
      m_SagittalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorSagittal,
                                                  renderWindow->GetSliceNavigationController()->GetSlice(),
                                                  "sliceNavigatorSagittalFromSimpleExample");
      m_Controls.m_SliceNavigatorSagittal->setEnabled(true);
      m_Controls.m_SagittalLabel->setEnabled(true);
      m_Controls.m_YWorldCoordinateSpinBox->setEnabled(true);
      connect(m_SagittalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch()));
    }
    else
    {
      m_Controls.m_SliceNavigatorSagittal->setEnabled(false);
      m_Controls.m_SagittalLabel->setEnabled(false);
      m_Controls.m_YWorldCoordinateSpinBox->setEnabled(false);
    }

    renderWindow = renderWindowPart->GetRenderWindow("coronal");
    if (renderWindow)
    {
      if (m_FrontalStepper) m_FrontalStepper->deleteLater();
      m_FrontalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorFrontal,
                                                 renderWindow->GetSliceNavigationController()->GetSlice(),
                                                 "sliceNavigatorFrontalFromSimpleExample");
      m_Controls.m_SliceNavigatorFrontal->setEnabled(true);
      m_Controls.m_CoronalLabel->setEnabled(true);
      m_Controls.m_XWorldCoordinateSpinBox->setEnabled(true);
      connect(m_FrontalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch()));
    }
    else
    {
      m_Controls.m_SliceNavigatorFrontal->setEnabled(false);
      m_Controls.m_CoronalLabel->setEnabled(false);
      m_Controls.m_XWorldCoordinateSpinBox->setEnabled(false);
    }

    mitk::SliceNavigationController* timeController = renderWindowPart->GetTimeNavigationController();
    if (timeController)
    {
      if (m_TimeStepper) m_TimeStepper->deleteLater();
      m_TimeStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorTime,
                                              timeController->GetTime(),
                                              "sliceNavigatorTimeFromSimpleExample");
      m_Controls.m_SliceNavigatorTime->setEnabled(true);
      m_Controls.m_TimeLabel->setEnabled(true);
    }
    else
    {
      m_Controls.m_SliceNavigatorTime->setEnabled(false);
      m_Controls.m_TimeLabel->setEnabled(false);
    }
  }
}
コード例 #5
0
void QmitkNavigationButtonsView::PlanarFigureFocus()
{
  if(m_SelectedNode)
  {
    mitk::PlanarFigure* _PlanarFigure = 0;
    _PlanarFigure = dynamic_cast<mitk::PlanarFigure*> (m_SelectedNode->GetData());

    if (_PlanarFigure)
    {

      QmitkRenderWindow* selectedRenderWindow = 0;
      bool PlanarFigureInitializedWindow = false;

      QmitkRenderWindow* RenderWindow1 =
          this->GetActiveStdMultiWidget()->GetRenderWindow1();

      if (m_SelectedNode->GetBoolProperty("PlanarFigureInitializedWindow",
        PlanarFigureInitializedWindow, RenderWindow1->GetRenderer()))
      {
        selectedRenderWindow = RenderWindow1;
      }

      QmitkRenderWindow* RenderWindow2 =
          this->GetActiveStdMultiWidget()->GetRenderWindow2();

      if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty(
          "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
          RenderWindow2->GetRenderer()))
      {
        selectedRenderWindow = RenderWindow2;
      }

      QmitkRenderWindow* RenderWindow3 =
          this->GetActiveStdMultiWidget()->GetRenderWindow3();

      if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty(
          "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
          RenderWindow3->GetRenderer()))
      {
        selectedRenderWindow = RenderWindow3;
      }

      QmitkRenderWindow* RenderWindow4 =
          this->GetActiveStdMultiWidget()->GetRenderWindow4();

      if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty(
          "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
          RenderWindow4->GetRenderer()))
      {
        selectedRenderWindow = RenderWindow4;
      }

      const mitk::PlaneGeometry
          * _PlaneGeometry =
          dynamic_cast<const mitk::PlaneGeometry*> (_PlanarFigure->GetGeometry2D());
      mitk::VnlVector normal = _PlaneGeometry->GetNormalVnl();

      mitk::Geometry2D::ConstPointer worldGeometry1 =
        RenderWindow1->GetRenderer()->GetCurrentWorldGeometry2D();
      mitk::PlaneGeometry::ConstPointer _Plane1 =
        dynamic_cast<const mitk::PlaneGeometry*>( worldGeometry1.GetPointer() );
      mitk::VnlVector normal1 = _Plane1->GetNormalVnl();

      mitk::Geometry2D::ConstPointer worldGeometry2 =
        RenderWindow2->GetRenderer()->GetCurrentWorldGeometry2D();
      mitk::PlaneGeometry::ConstPointer _Plane2 =
        dynamic_cast<const mitk::PlaneGeometry*>( worldGeometry2.GetPointer() );
      mitk::VnlVector normal2 = _Plane2->GetNormalVnl();

      mitk::Geometry2D::ConstPointer worldGeometry3 =
        RenderWindow3->GetRenderer()->GetCurrentWorldGeometry2D();
      mitk::PlaneGeometry::ConstPointer _Plane3 =
        dynamic_cast<const mitk::PlaneGeometry*>( worldGeometry3.GetPointer() );
      mitk::VnlVector normal3 = _Plane3->GetNormalVnl();

      normal[0]  = fabs(normal[0]);  normal[1]  = fabs(normal[1]);  normal[2]  = fabs(normal[2]);
      normal1[0] = fabs(normal1[0]); normal1[1] = fabs(normal1[1]); normal1[2] = fabs(normal1[2]);
      normal2[0] = fabs(normal2[0]); normal2[1] = fabs(normal2[1]); normal2[2] = fabs(normal2[2]);
      normal3[0] = fabs(normal3[0]); normal3[1] = fabs(normal3[1]); normal3[2] = fabs(normal3[2]);

      double ang1 = angle(normal, normal1);
      double ang2 = angle(normal, normal2);
      double ang3 = angle(normal, normal3);

      if(ang1 < ang2 && ang1 < ang3)
      {
        selectedRenderWindow = RenderWindow1;
      }
      else
      {
        if(ang2 < ang3)
        {
          selectedRenderWindow = RenderWindow2;
        }
        else
        {
          selectedRenderWindow = RenderWindow3;
        }
      }

      // make node visible
      if (selectedRenderWindow)
      {
        mitk::Point3D centerP = _PlaneGeometry->GetOrigin();
        selectedRenderWindow->GetSliceNavigationController()->ReorientSlices(
            centerP, _PlaneGeometry->GetNormal());
        selectedRenderWindow->GetSliceNavigationController()->SelectSliceByPoint(
            centerP);
      }
    }

    // set interactor for new node (if not already set)
    mitk::PlanarFigureInteractor::Pointer figureInteractor
        = dynamic_cast<mitk::PlanarFigureInteractor*>(m_SelectedNode->GetDataInteractor().GetPointer());

    if(figureInteractor.IsNull())
    {
      figureInteractor = mitk::PlanarFigureInteractor::New();
      mitk::Module* planarFigureModule = mitk::ModuleRegistry::GetModule( "MitkPlanarFigure" );
      figureInteractor->LoadStateMachine("PlanarFigureInteraction.xml", planarFigureModule );
      figureInteractor->SetEventConfig( "PlanarFigureConfig.xml", planarFigureModule );
      figureInteractor->SetDataNode( m_SelectedNode );
    }

    m_SelectedNode->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true));

  }
}
コード例 #6
0
ファイル: Step1.cpp プロジェクト: GHfangxin/MITK
//##Documentation
//## @brief Load image (nrrd format) and display it in a 2D view
int main(int argc, char* argv[])
{
  QApplication qtapplication( argc, argv );

  if (argc < 2)
  {
    fprintf( stderr, "Usage:   %s [filename] \n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str() );
    return 1;
  }

  // Register Qmitk-dependent global instances
  QmitkRegisterClasses();

  //*************************************************************************
  // Part I: Basic initialization
  //*************************************************************************

  // Create a DataStorage
  // The DataStorage manages all data objects. It is used by the
  // rendering mechanism to render all data objects
  // We use the standard implementation mitk::StandaloneDataStorage.
  mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New();


  //*************************************************************************
  // Part II: Create some data by reading a file
  //*************************************************************************

  // Create a DataNodeFactory to read a data format supported
  // by the DataNodeFactory (many image formats, surface formats, etc.)
  mitk::DataNodeFactory::Pointer reader=mitk::DataNodeFactory::New();
  const char * filename = argv[1];
  try
  {
    reader->SetFileName(filename);
    reader->Update();
    //*************************************************************************
    // Part III: Put the data into the datastorage
    //*************************************************************************

    // Add the node to the DataStorage
    ds->Add(reader->GetOutput());
  }
  catch(...)
  {
    fprintf( stderr, "Could not open file %s \n\n", filename );
    exit(2);
  }

  //*************************************************************************
  // Part IV: Create window and pass the datastorage to it
  //*************************************************************************

  // Create a RenderWindow
  QmitkRenderWindow renderWindow;

  // Tell the RenderWindow which (part of) the datastorage to render
  renderWindow.GetRenderer()->SetDataStorage(ds);

  // Initialize the RenderWindow
  mitk::TimeGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll());
  mitk::RenderingManager::GetInstance()->InitializeViews( geo );
  //mitk::RenderingManager::GetInstance()->InitializeViews();

  // Select a slice
  mitk::SliceNavigationController::Pointer sliceNaviController = renderWindow.GetSliceNavigationController();
  if (sliceNaviController)
    sliceNaviController->GetSlice()->SetPos( 0 );

  //*************************************************************************
  // Part V: Qt-specific initialization
  //*************************************************************************
  renderWindow.show();
  renderWindow.resize( 256, 256 );

  // for testing
  #include "QtTesting.h"
  if (strcmp(argv[argc-1], "-testing") != 0)
    return qtapplication.exec();
  else
    return QtTesting();

  // cleanup: Remove References to DataStorage. This will delete the object
  ds = NULL;
}
コード例 #7
0
ファイル: Step2.cpp プロジェクト: GHfangxin/MITK
//##Documentation
//## @brief Load one or more data sets (many image, surface
//## and other formats) and display it in a 2D view
int main(int argc, char* argv[])
{
    QApplication qtapplication( argc, argv );

    if(argc<2)
    {
        fprintf( stderr, "Usage:   %s [filename1] [filename2] ...\n\n",
                 itksys::SystemTools::GetFilenameName(argv[0]).c_str() );
        return 1;
    }

    // Register Qmitk-dependent global instances
    QmitkRegisterClasses();

    //*************************************************************************
    // Part I: Basic initialization
    //*************************************************************************

    // Create a data storage object. We will use it as a singleton
    mitk::StandaloneDataStorage::Pointer storage = mitk::StandaloneDataStorage::New();

    //*************************************************************************
    // Part II: Create some data by reading files
    //*************************************************************************
    int i;
    for(i=1; i<argc; ++i)
    {
        // For testing
        if(strcmp(argv[i], "-testing")==0) continue;

        // Create a DataNodeFactory to read a data format supported
        // by the DataNodeFactory (many image formats, surface formats, etc.)
        mitk::DataNodeFactory::Pointer nodeReader=mitk::DataNodeFactory::New();
        const char * filename = argv[i];
        try
        {
            nodeReader->SetFileName(filename);
            nodeReader->Update();
            //*********************************************************************
            // Part III: Put the data into the datastorage
            //*********************************************************************

            // Since the DataNodeFactory directly creates a node,
            // use the datastorage to add the read node
            storage->Add(nodeReader->GetOutput());
        }
        catch(...)
        {
            fprintf( stderr, "Could not open file %s \n\n", filename );
            exit(2);
        }
    }

    //*************************************************************************
    // Part IV: Create window and pass the datastorage to it
    //*************************************************************************

    // Create a RenderWindow
    QmitkRenderWindow renderWindow;

    // Tell the RenderWindow which (part of) the datastorage to render
    renderWindow.GetRenderer()->SetDataStorage(storage);

    // Initialize the RenderWindow
    mitk::TimeGeometry::Pointer geo = storage->ComputeBoundingGeometry3D(storage->GetAll());
    mitk::RenderingManager::GetInstance()->InitializeViews( geo );

    // Select a slice
    mitk::SliceNavigationController::Pointer sliceNaviController = renderWindow.GetSliceNavigationController();
    if (sliceNaviController)
        sliceNaviController->GetSlice()->SetPos( 2 );


    //*************************************************************************
    // Part V: Qt-specific initialization
    //*************************************************************************
    renderWindow.show();
    renderWindow.resize( 256, 256 );

    // for testing
#include "QtTesting.h"
    if(strcmp(argv[argc-1], "-testing")!=0)
        return qtapplication.exec();
    else
        return QtTesting();
}
コード例 #8
0
ファイル: OverlayExample.cpp プロジェクト: AGrafmint/MITK
//##Documentation
//## @brief Load image (nrrd format) and display it in a 2D view
int main(int argc, char* argv[])
{
  QApplication qtapplication( argc, argv );

  if (argc < 2)
  {
    fprintf( stderr, "Usage:   %s [filename] \n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str() );
    return 1;
  }

  // Register Qmitk-dependent global instances
  QmitkRegisterClasses();

  //*************************************************************************
  // Part I: Basic initialization
  //*************************************************************************

  // Create a DataStorage
  // The DataStorage manages all data objects. It is used by the
  // rendering mechanism to render all data objects
  // We use the standard implementation mitk::StandaloneDataStorage.
  mitk::StandaloneDataStorage::Pointer dataStorage = mitk::StandaloneDataStorage::New();


  //*************************************************************************
  // Part II: Create some data by reading a file
  //*************************************************************************

  // Create a DataNodeFactory to read a data format supported
  // by the DataNodeFactory (many image formats, surface formats, etc.)
  mitk::DataNodeFactory::Pointer reader=mitk::DataNodeFactory::New();
  const char * filename = argv[1];
  try
  {
    reader->SetFileName(filename);
    reader->Update();
    //*************************************************************************
    // Part III: Put the data into the datastorage
    //*************************************************************************

    // Add the node to the DataStorage
    dataStorage->Add(reader->GetOutput());
  }
  catch(...)
  {
    fprintf( stderr, "Could not open file %s \n\n", filename );
    exit(2);
  }

  //*************************************************************************
  // Part IV: Create window and pass the datastorage to it
  //*************************************************************************

  // Create a RenderWindow
  QmitkRenderWindow renderWindow;

  // Tell the RenderWindow which (part of) the datastorage to render
  renderWindow.GetRenderer()->SetDataStorage(dataStorage);

  // Initialize the RenderWindow
  mitk::TimeSlicedGeometry::Pointer geo = dataStorage->ComputeBoundingGeometry3D(dataStorage->GetAll());
  mitk::RenderingManager::GetInstance()->InitializeViews( geo );
  //mitk::RenderingManager::GetInstance()->InitializeViews();

  // Select a slice
  mitk::SliceNavigationController::Pointer sliceNaviController = renderWindow.GetSliceNavigationController();
  if (sliceNaviController)
    sliceNaviController->GetSlice()->SetPos( 0 );

  //*************************************************************************
  // Part V: Qt-specific initialization
  //*************************************************************************

  //! [CreateOverlayManager]
  mitk::OverlayManager::Pointer OverlayManagerInstance = mitk::OverlayManager::New();
  mitk::BaseRenderer* renderer = mitk::BaseRenderer::GetInstance(renderWindow.GetVtkRenderWindow());
  renderer->SetOverlayManager(OverlayManagerInstance);
  //! [CreateOverlayManager]


  //! [GetOverlayManagerInstance]
  //The id that is passed identifies the correct mitk::OverlayManager and is '0' by default.
  mitk::BaseRenderer* renderer2D = mitk::BaseRenderer::GetInstance(renderWindow.GetVtkRenderWindow());
  mitk::OverlayManager::Pointer overlayManager = renderer2D->GetOverlayManager();
  //! [GetOverlayManagerInstance]


  //! [AddLayouter]
  //This creates a 2DLayouter that is only active for the recently fetched axialRenderer and positione
  mitk::Overlay2DLayouter::Pointer topleftLayouter = mitk::Overlay2DLayouter::CreateLayouter(mitk::Overlay2DLayouter::STANDARD_2D_TOPLEFT(), renderer2D);

  //Now, the created Layouter is added to the OverlayManager and can be referred to by its identification string.
  overlayManager->AddLayouter(topleftLayouter.GetPointer());

  //Several other Layouters can be added to the overlayManager
  mitk::Overlay2DLayouter::Pointer bottomLayouter = mitk::Overlay2DLayouter::CreateLayouter(mitk::Overlay2DLayouter::STANDARD_2D_BOTTOM(), renderer2D);
  overlayManager->AddLayouter(bottomLayouter.GetPointer());
  //! [AddLayouter]


  //! [TextOverlay2D]
  //Create a textOverlay2D
  mitk::TextOverlay2D::Pointer textOverlay = mitk::TextOverlay2D::New();

  textOverlay->SetText("Test!"); //set UTF-8 encoded text to render
  textOverlay->SetFontSize(40);
  textOverlay->SetColor(1,0,0); //Set text color to red
  textOverlay->SetOpacity(1);

  //The position of the Overlay can be set to a fixed coordinate on the display.
  mitk::Point2D pos;
  pos[0] = 10,pos[1] = 20;
  textOverlay->SetPosition2D(pos);

  //Add the overlay to the overlayManager. It is added to all registered renderers automaticly
  overlayManager->AddOverlay(textOverlay.GetPointer());

  //Alternatively, a layouter can be used to manage the position of the overlay. If a layouter is set, the absolute position of the overlay is not used anymore
  //The Standard TopLeft Layouter has to be registered to the OverlayManager first
  overlayManager->AddLayouter(mitk::Overlay2DLayouter::CreateLayouter(mitk::Overlay2DLayouter::STANDARD_2D_TOPLEFT(), renderer2D).GetPointer());
  //! [TextOverlay2D]

  //! [SetLayouterToOverlay]
  //Because a Layouter is specified by the identification string AND the Renderer, both have to be passed to the call.
  overlayManager->SetLayouter(textOverlay.GetPointer(),mitk::Overlay2DLayouter::STANDARD_2D_TOPLEFT(),renderer2D);
  //! [SetLayouterToOverlay]


  //! [TextOverlay3D]
  mitk::PointSet::Pointer pointset = mitk::PointSet::New();

  // This vector is used to define an offset for the annotations, in order to show them with a margin to the actual coordinate.
  mitk::Point3D offset;
  offset[0] = .5;
  offset[1] = .5;
  offset[2] = .5;

  //Just a loop to create some points
  for(int i=0 ; i < 10 ; i++){
    //To each point, a TextOverlay3D is created
    mitk::TextOverlay3D::Pointer textOverlay3D = mitk::TextOverlay3D::New();
    mitk::Point3D point;
    point[0] = i*20;
    point[1] = i*30;
    point[2] = -i*50;
    pointset->InsertPoint(i, point);
    textOverlay3D->SetText("A Point");

    // The Position is set to the point coordinate to create an annotation to the point in the PointSet.
    textOverlay3D->SetPosition3D(point);

    // move the annotation away from the actual point
    textOverlay3D->SetOffsetVector(offset);

    overlayManager->AddOverlay(textOverlay3D.GetPointer());
  }

  // also show the created pointset
  mitk::DataNode::Pointer datanode = mitk::DataNode::New();
  datanode->SetData(pointset);
  datanode->SetName("pointSet");
  dataStorage->Add(datanode);
  //! [TextOverlay3D]
  renderWindow.show();
  renderWindow.resize( 256, 256 );

  return qtapplication.exec();

  // cleanup: Remove References to DataStorage. This will delete the object
  dataStorage = NULL;
}