Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions

mitk::PlanarFigureMapper2D Class Reference
[Mapper Classes]

OpenGL-based mapper to render display sub-class instances of mitk::PlanarFigure. More...

#include <mitkPlanarFigureMapper2D.h>

Inheritance diagram for mitk::PlanarFigureMapper2D:
Inheritance graph
[legend]
Collaboration diagram for mitk::PlanarFigureMapper2D:
Collaboration graph
[legend]

List of all members.

Public Types

typedef PlanarFigureMapper2D Self
typedef Mapper2D Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual void Paint (BaseRenderer *renderer)

Static Public Member Functions

static Pointer New ()
static void SetDefaultProperties (mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
 Set default values of properties used by this mapper to node.

Protected Types

enum  PlanarFigureDisplayMode { PF_DEFAULT = 0, PF_HOVER, PF_SELECTED }
typedef
PlanarFigure::VertexContainerType 
VertexContainerType

Protected Member Functions

 PlanarFigureMapper2D ()
virtual ~PlanarFigureMapper2D ()
void TransformObjectToDisplay (const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::Geometry2D *objectGeometry, const mitk::Geometry2D *rendererGeometry, const mitk::DisplayGeometry *displayGeometry)
void DrawMarker (const mitk::Point2D &point, float *lineColor, float lineOpacity, float *markerColor, float markerOpacity, float lineWidth, PlanarFigureControlPointStyleProperty::Shape shape, const mitk::Geometry2D *objectGeometry, const mitk::Geometry2D *rendererGeometry, const mitk::DisplayGeometry *displayGeometry)
void PaintPolyLine (const VertexContainerType *vertices, bool closed, float *color, float opacity, float lineWidth, Point2D &firstPoint, const Geometry2D *planarFigureGeometry2D, const Geometry2D *rendererGeometry2D, const DisplayGeometry *displayGeometry)
void DrawMainLines (mitk::PlanarFigure *figure, float *color, float opacity, float lineWidth, Point2D &firstPoint, const Geometry2D *planarFigureGeometry2D, const Geometry2D *rendererGeometry2D, const DisplayGeometry *displayGeometry)
void DrawHelperLines (mitk::PlanarFigure *figure, float *color, float opacity, float lineWidth, Point2D &firstPoint, const Geometry2D *planarFigureGeometry2D, const Geometry2D *rendererGeometry2D, const DisplayGeometry *displayGeometry)
void InitializeDefaultPlanarFigureProperties ()
void InitializePlanarFigurePropertiesFromDataNode (const mitk::DataNode *node)
void SetColorProperty (float property[3][3], PlanarFigureDisplayMode mode, float red, float green, float blue)
void SetFloatProperty (float *property, PlanarFigureDisplayMode mode, float value)

Detailed Description

OpenGL-based mapper to render display sub-class instances of mitk::PlanarFigure.

The appearance of planar figures can be configured through properties. If no properties are specified, default values will be used. There are four elements a planar figure consists of:

  1. "line": the main line segments of the planar figure (note: text is drawn in the same style)
  2. "helperline": additional line segments of planar figures, such as arrow tips, arches of angles, etc.
  3. "outline": background which is drawn behind the lines and helperlines of the planar figure (optional)
  4. "marker": the markers (control points) of a planar figure
  5. "markerline": the lines by which markers (control points) are surrounded

In the following, all appearance-related planar figure properties are listed:

  1. General properties for the planar figure
    • "planarfigure.drawoutline": if true, the "outline" lines is drawn
    • "planarfigure.drawquantities": if true, the quantities (text) associated with the planar figure is drawn
    • "planarfigure.controlpointshape": style of the control points (enum)
  2. Line widths of planar figure elements
    • "planarfigure.line.width": width of "line" segments (float value, in mm)
    • "planarfigure.outline.width": width of "outline" segments (float value, in mm)
    • "planarfigure.helperline.width": width of "helperline" segments (float value, in mm)
  3. Color/opacity of planar figure elements in normal mode (unselected)
    • "planarfigure.default.line.color"
    • "planarfigure.default.line.opacity"
    • "planarfigure.default.outline.color"
    • "planarfigure.default.outline.opacity"
    • "planarfigure.default.helperline.color"
    • "planarfigure.default.helperline.opacity"
    • "planarfigure.default.markerline.color"
    • "planarfigure.default.markerline.opacity"
    • "planarfigure.default.marker.color"
    • "planarfigure.default.marker.opacity"
  4. Color/opacity of planar figure elements in hover mode (mouse-over)
    • "planarfigure.hover.line.color"
    • "planarfigure.hover.line.opacity"
    • "planarfigure.hover.outline.color"
    • "planarfigure.hover.outline.opacity"
    • "planarfigure.hover.helperline.color"
    • "planarfigure.hover.helperline.opacity"
    • "planarfigure.hover.markerline.color"
    • "planarfigure.hover.markerline.opacity"
    • "planarfigure.hover.marker.color"
    • "planarfigure.hover.marker.opacity"
  5. Color/opacity of planar figure elements in selected mode
    • "planarfigure.selected.line.color"
    • "planarfigure.selected.line.opacity"
    • "planarfigure.selected.outline.color"
    • "planarfigure.selected.outline.opacity"
    • "planarfigure.selected.helperline.color"
    • "planarfigure.selected.helperline.opacity"
    • "planarfigure.selected.markerline.color;"
    • "planarfigure.selected.markerline.opacity"
    • "planarfigure.selected.marker.color"
    • "planarfigure.selected.marker.opacity"

Definition at line 107 of file mitkPlanarFigureMapper2D.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::PlanarFigureMapper2D::ConstPointer

Reimplemented from mitk::Mapper2D.

Definition at line 111 of file mitkPlanarFigureMapper2D.h.

typedef itk::SmartPointer<Self> mitk::PlanarFigureMapper2D::Pointer

Reimplemented from mitk::Mapper2D.

Definition at line 111 of file mitkPlanarFigureMapper2D.h.

Reimplemented from mitk::Mapper2D.

Definition at line 111 of file mitkPlanarFigureMapper2D.h.

Reimplemented from mitk::Mapper2D.

Definition at line 111 of file mitkPlanarFigureMapper2D.h.

Definition at line 125 of file mitkPlanarFigureMapper2D.h.


Member Enumeration Documentation

Enumerator:
PF_DEFAULT 
PF_HOVER 
PF_SELECTED 

Definition at line 127 of file mitkPlanarFigureMapper2D.h.


Constructor & Destructor Documentation

mitk::PlanarFigureMapper2D::PlanarFigureMapper2D (  ) [protected]
mitk::PlanarFigureMapper2D::~PlanarFigureMapper2D (  ) [protected, virtual]

Definition at line 34 of file mitkPlanarFigureMapper2D.cpp.

{
}

Member Function Documentation

void mitk::PlanarFigureMapper2D::DrawHelperLines ( mitk::PlanarFigure figure,
float *  color,
float  opacity,
float  lineWidth,
Point2D &  firstPoint,
const Geometry2D planarFigureGeometry2D,
const Geometry2D rendererGeometry2D,
const DisplayGeometry displayGeometry 
) [protected]

Definition at line 322 of file mitkPlanarFigureMapper2D.cpp.

References mitk::DisplayGeometry::GetDisplayHeight(), mitk::PlanarFigure::GetHelperPolyLine(), mitk::PlanarFigure::GetHelperPolyLinesSize(), mitk::DisplayGeometry::GetScaleFactorMMPerDisplayUnit(), and mitk::PlanarFigure::IsHelperToBePainted().

{
  // Draw helper objects
  for ( unsigned int loop = 0; loop < figure->GetHelperPolyLinesSize(); ++loop )
  {    
    // Get (and possibly generate) helper polyline (this needs to be done before
    // checking if the helper polyline has to be painted!)
    const VertexContainerType *polyLine = figure->GetHelperPolyLine( loop,
      displayGeometry->GetScaleFactorMMPerDisplayUnit(),
      displayGeometry->GetDisplayHeight() );

    // Check if the current helper objects is to be painted
    if ( !figure->IsHelperToBePainted( loop ) )
    {
      continue;
    }

    this->PaintPolyLine( polyLine, false,
      color, opacity, lineWidth, firstPoint,
      planarFigureGeometry2D, rendererGeometry2D, displayGeometry );
  }
}
void mitk::PlanarFigureMapper2D::DrawMainLines ( mitk::PlanarFigure figure,
float *  color,
float  opacity,
float  lineWidth,
Point2D &  firstPoint,
const Geometry2D planarFigureGeometry2D,
const Geometry2D rendererGeometry2D,
const DisplayGeometry displayGeometry 
) [protected]

Definition at line 302 of file mitkPlanarFigureMapper2D.cpp.

References mitk::PlanarFigure::GetPolyLine(), mitk::PlanarFigure::GetPolyLinesSize(), and mitk::PlanarFigure::IsClosed().

{
  for ( unsigned short loop = 0; loop < figure->GetPolyLinesSize(); ++loop )
  {
    const VertexContainerType* polyLine = figure->GetPolyLine(loop);
    this->PaintPolyLine( polyLine,
      figure->IsClosed(),    
      color, opacity, lineWidth, firstPoint,
      planarFigureGeometry2D, rendererGeometry2D, displayGeometry );
  }
}
void mitk::PlanarFigureMapper2D::DrawMarker ( const mitk::Point2D &  point,
float *  lineColor,
float  lineOpacity,
float *  markerColor,
float  markerOpacity,
float  lineWidth,
PlanarFigureControlPointStyleProperty::Shape  shape,
const mitk::Geometry2D objectGeometry,
const mitk::Geometry2D rendererGeometry,
const mitk::DisplayGeometry displayGeometry 
) [protected]

Definition at line 373 of file mitkPlanarFigureMapper2D.cpp.

References mitk::PlanarFigureControlPointStyleProperty::Circle, GL_LINE_LOOP, GL_LINE_SMOOTH, GL_POLYGON, glBegin(), glColor4f(), glDisable(), glEnd(), glLineWidth(), glRectf(), glVertex2f(), and mitk::PlanarFigureControlPointStyleProperty::Square.

{
  mitk::Point2D displayPoint;

  this->TransformObjectToDisplay(
    point, displayPoint,
    objectGeometry, rendererGeometry, displayGeometry );

  glColor4f( markerColor[0], markerColor[1], markerColor[2], markerOpacity );
  glLineWidth( lineWidth );

  switch ( shape )
  {
    case PlanarFigureControlPointStyleProperty::Square:
    default:
      // Paint filled square

      // Disable line antialiasing (does not look nice for squares)
      glDisable( GL_LINE_SMOOTH );

      glRectf(
        displayPoint[0] - 4, displayPoint[1] - 4, 
        displayPoint[0] + 4, displayPoint[1] + 4 );

      // Paint outline
      glColor4f( lineColor[0], lineColor[1], lineColor[2], lineOpacity );
      glBegin( GL_LINE_LOOP );
      glVertex2f( displayPoint[0] - 4, displayPoint[1] - 4 );
      glVertex2f( displayPoint[0] - 4, displayPoint[1] + 4 );
      glVertex2f( displayPoint[0] + 4, displayPoint[1] + 4 );
      glVertex2f( displayPoint[0] + 4, displayPoint[1] - 4 );
      glEnd();
      break;

    case PlanarFigureControlPointStyleProperty::Circle:
      // Paint filled circle
      glBegin( GL_POLYGON );
      float radius = 4.0;
      for ( int angle = 0; angle < 8; ++angle )
      {
        float angleRad = angle * (float) 3.14159 / 4.0;
        float x = displayPoint[0] + radius * (float)cos( angleRad );
        float y = displayPoint[1] + radius * (float)sin( angleRad );
        glVertex2f(x,y);
      }
      glEnd();

      // Paint outline
      glColor4f( lineColor[0], lineColor[1], lineColor[2], lineOpacity );
      glBegin( GL_LINE_LOOP );
      for ( int angle = 0; angle < 8; ++angle )
      {
        float angleRad = angle * (float) 3.14159 / 4.0;
        float x = displayPoint[0] + radius * (float)cos( angleRad );
        float y = displayPoint[1] + radius * (float)sin( angleRad );
        glVertex2f(x,y);
      }
      glEnd();
      break;

    } // end switch
}
virtual const char* mitk::PlanarFigureMapper2D::GetClassName (  ) const [virtual]

Reimplemented from mitk::Mapper2D.

void mitk::PlanarFigureMapper2D::InitializeDefaultPlanarFigureProperties (  ) [protected]

Definition at line 447 of file mitkPlanarFigureMapper2D.cpp.

References mitk::PlanarFigureControlPointStyleProperty::Square.

Referenced by PlanarFigureMapper2D().

{
  m_IsSelected = false;
  m_IsHovering = false;
  m_DrawOutline = false;
  m_DrawQuantities = false;

  m_LineWidth = 1.0;
  m_OutlineWidth = 4.0;
  m_HelperlineWidth = 2.0;

  m_ControlPointShape = PlanarFigureControlPointStyleProperty::Square;

  this->SetColorProperty( m_LineColor, PF_DEFAULT, 1.0, 1.0, 1.0 );
  this->SetFloatProperty( m_LineOpacity, PF_DEFAULT, 1.0 );
  this->SetColorProperty( m_OutlineColor, PF_DEFAULT, 0.0, 0.0, 1.0 );
  this->SetFloatProperty( m_OutlineOpacity, PF_DEFAULT, 1.0 );
  this->SetColorProperty( m_HelperlineColor, PF_DEFAULT, 0.4, 0.8, 0.2 );
  this->SetFloatProperty( m_HelperlineOpacity, PF_DEFAULT, 0.4 );
  this->SetColorProperty( m_MarkerlineColor, PF_DEFAULT, 1.0, 1.0, 1.0 );
  this->SetFloatProperty( m_MarkerlineOpacity, PF_DEFAULT, 1.0 );
  this->SetColorProperty( m_MarkerColor, PF_DEFAULT, 1.0, 1.0, 1.0 );
  this->SetFloatProperty( m_MarkerOpacity, PF_DEFAULT, 0.0 );

  this->SetColorProperty( m_LineColor, PF_HOVER, 1.0, 0.7, 0.0 );
  this->SetFloatProperty( m_LineOpacity, PF_HOVER, 1.0 );
  this->SetColorProperty( m_OutlineColor, PF_HOVER, 0.0, 0.0, 1.0 );
  this->SetFloatProperty( m_OutlineOpacity, PF_HOVER, 1.0 );
  this->SetColorProperty( m_HelperlineColor, PF_HOVER, 0.4, 0.8, 0.2 );
  this->SetFloatProperty( m_HelperlineOpacity, PF_HOVER, 0.4 );
  this->SetColorProperty( m_MarkerlineColor, PF_HOVER, 1.0, 1.0, 1.0 );
  this->SetFloatProperty( m_MarkerlineOpacity, PF_HOVER, 1.0 );
  this->SetColorProperty( m_MarkerColor, PF_HOVER, 1.0, 0.6, 0.0 );
  this->SetFloatProperty( m_MarkerOpacity, PF_HOVER, 0.2 );

  this->SetColorProperty( m_LineColor, PF_SELECTED, 1.0, 0.0, 0.0 );
  this->SetFloatProperty( m_LineOpacity, PF_SELECTED, 1.0 );
  this->SetColorProperty( m_OutlineColor, PF_SELECTED, 0.0, 0.0, 1.0 );
  this->SetFloatProperty( m_OutlineOpacity, PF_SELECTED, 1.0 );
  this->SetColorProperty( m_HelperlineColor, PF_SELECTED, 0.4, 0.8, 0.2 );
  this->SetFloatProperty( m_HelperlineOpacity, PF_SELECTED, 0.4 );
  this->SetColorProperty( m_MarkerlineColor, PF_SELECTED, 1.0, 1.0, 1.0 );
  this->SetFloatProperty( m_MarkerlineOpacity, PF_SELECTED, 1.0 );
  this->SetColorProperty( m_MarkerColor, PF_SELECTED, 1.0, 0.6, 0.0 );
  this->SetFloatProperty( m_MarkerOpacity, PF_SELECTED, 1.0 );
}
void mitk::PlanarFigureMapper2D::InitializePlanarFigurePropertiesFromDataNode ( const mitk::DataNode node ) [protected]

Definition at line 495 of file mitkPlanarFigureMapper2D.cpp.

References mitk::DataNode::GetBoolProperty(), mitk::DataNode::GetColor(), mitk::DataNode::GetFloatProperty(), mitk::DataNode::GetProperty(), and mitk::PlanarFigureControlPointStyleProperty::GetShape().

{
  if ( node == NULL )
  {
    return;
  }

  node->GetBoolProperty( "selected", m_IsSelected );
  node->GetBoolProperty( "planarfigure.ishovering", m_IsHovering );
  node->GetBoolProperty( "planarfigure.drawoutline", m_DrawOutline );
  node->GetBoolProperty( "planarfigure.drawquantities", m_DrawQuantities );

  node->GetFloatProperty( "planarfigure.line.width", m_LineWidth );
  node->GetFloatProperty( "planarfigure.outline.width", m_OutlineWidth );
  node->GetFloatProperty( "planarfigure.helperline.width", m_HelperlineWidth );

  PlanarFigureControlPointStyleProperty::Pointer styleProperty = 
    dynamic_cast< PlanarFigureControlPointStyleProperty* >( node->GetProperty( "planarfigure.controlpointshape" ) );
  if ( styleProperty.IsNotNull() )
  {
    m_ControlPointShape = styleProperty->GetShape();
  }

  node->GetColor( m_LineColor[PF_DEFAULT], NULL, "planarfigure.default.line.color" );
  node->GetFloatProperty( "planarfigure.default.line.opacity", m_LineOpacity[PF_DEFAULT] );
  node->GetColor( m_OutlineColor[PF_DEFAULT], NULL, "planarfigure.default.outline.color" );
  node->GetFloatProperty( "planarfigure.default.outline.opacity", m_OutlineOpacity[PF_DEFAULT] );
  node->GetColor( m_HelperlineColor[PF_DEFAULT], NULL, "planarfigure.default.helperline.color" );
  node->GetFloatProperty( "planarfigure.default.helperline.opacity", m_HelperlineOpacity[PF_DEFAULT] );
  node->GetColor( m_MarkerlineColor[PF_DEFAULT], NULL, "planarfigure.default.markerline.color" );
  node->GetFloatProperty( "planarfigure.default.markerline.opacity", m_MarkerlineOpacity[PF_DEFAULT] );
  node->GetColor( m_MarkerColor[PF_DEFAULT], NULL, "planarfigure.default.marker.color" );
  node->GetFloatProperty( "planarfigure.default.marker.opacity", m_MarkerOpacity[PF_DEFAULT] );

  node->GetColor( m_LineColor[PF_HOVER], NULL, "planarfigure.hover.line.color" );
  node->GetFloatProperty( "planarfigure.hover.line.opacity", m_LineOpacity[PF_HOVER] );
  node->GetColor( m_OutlineColor[PF_HOVER], NULL, "planarfigure.hover.outline.color" );
  node->GetFloatProperty( "planarfigure.hover.outline.opacity", m_OutlineOpacity[PF_HOVER] );
  node->GetColor( m_HelperlineColor[PF_HOVER], NULL, "planarfigure.hover.helperline.color" );
  node->GetFloatProperty( "planarfigure.hover.helperline.opacity", m_HelperlineOpacity[PF_HOVER] );
  node->GetColor( m_MarkerlineColor[PF_HOVER], NULL, "planarfigure.hover.markerline.color" );
  node->GetFloatProperty( "planarfigure.hover.markerline.opacity", m_MarkerlineOpacity[PF_HOVER] );
  node->GetColor( m_MarkerColor[PF_HOVER], NULL, "planarfigure.hover.marker.color" );
  node->GetFloatProperty( "planarfigure.hover.marker.opacity", m_MarkerOpacity[PF_HOVER] );

  node->GetColor( m_LineColor[PF_SELECTED], NULL, "planarfigure.selected.line.color" );
  node->GetFloatProperty( "planarfigure.selected.line.opacity", m_LineOpacity[PF_SELECTED] );
  node->GetColor( m_OutlineColor[PF_SELECTED], NULL, "planarfigure.selected.outline.color" );
  node->GetFloatProperty( "planarfigure.selected.outline.opacity", m_OutlineOpacity[PF_SELECTED] );
  node->GetColor( m_HelperlineColor[PF_SELECTED], NULL, "planarfigure.selected.helperline.color" );
  node->GetFloatProperty( "planarfigure.selected.helperline.opacity", m_HelperlineOpacity[PF_SELECTED] );
  node->GetColor( m_MarkerlineColor[PF_SELECTED], NULL, "planarfigure.selected.markerline.color" );
  node->GetFloatProperty( "planarfigure.selected.markerline.opacity", m_MarkerlineOpacity[PF_SELECTED] );
  node->GetColor( m_MarkerColor[PF_SELECTED], NULL, "planarfigure.selected.marker.color" );
  node->GetFloatProperty( "planarfigure.selected.marker.opacity", m_MarkerOpacity[PF_SELECTED] );

}
static Pointer mitk::PlanarFigureMapper2D::New (  ) [static]
void mitk::PlanarFigureMapper2D::Paint ( mitk::BaseRenderer renderer ) [virtual]

reimplemented from Baseclass

Implements mitk::GLMapper2D.

Definition at line 39 of file mitkPlanarFigureMapper2D.cpp.

References mitk::PlaneGeometry::DistanceFromPlane(), mitk::PlanarFigure::GetControlPoint(), mitk::BaseRenderer::GetCurrentWorldGeometry2D(), mitk::BaseRenderer::GetDisplayGeometry(), mitk::Geometry3D::GetExtentInMM(), mitk::PlanarFigure::GetFeatureUnit(), mitk::BaseData::GetGeometry(), mitk::DataNode::GetName(), mitk::PlanarFigure::GetNumberOfControlPoints(), mitk::PlanarFigure::GetNumberOfFeatures(), mitk::PlanarFigure::GetQuantity(), mitk::PlanarFigure::GetSelectedControlPoint(), GL_LINE_SMOOTH, GL_LINE_SMOOTH_HINT, GL_NICEST, glEnable(), glHint(), glLineWidth(), mitk::PlanarFigure::IsFeatureActive(), mitk::PlaneGeometry::IsParallel(), mitk::PlanarFigure::IsPlaced(), MITK_ERROR, and mitk::VtkPropRenderer::WriteSimpleText().

{
  if ( !this->IsVisible( renderer ) ) 
  {
    return;
  }

  // Get PlanarFigure from input
  mitk::PlanarFigure *planarFigure = const_cast< mitk::PlanarFigure * >(
    static_cast< const mitk::PlanarFigure * >( this->GetData() ) );

  // Check if PlanarFigure has already been placed; otherwise, do nothing
  if ( !planarFigure->IsPlaced() )
  {
    return;
  }

  // Get 2D geometry frame of PlanarFigure
  mitk::Geometry2D *planarFigureGeometry2D = 
    dynamic_cast< Geometry2D * >( planarFigure->GetGeometry( 0 ) );
  if ( planarFigureGeometry2D == NULL )
  {
    MITK_ERROR << "PlanarFigure does not have valid Geometry2D!";
    return;
  }

  // Get current world 2D geometry from renderer
  const mitk::Geometry2D *rendererGeometry2D = renderer->GetCurrentWorldGeometry2D();

  // If the PlanarFigure geometry is a plane geometry, check if current
  // world plane is parallel to and within the planar figure geometry bounds
  // (otherwise, display nothing)
  mitk::PlaneGeometry *planarFigurePlaneGeometry = 
    dynamic_cast< PlaneGeometry * >( planarFigureGeometry2D );
  const mitk::PlaneGeometry *rendererPlaneGeometry = 
    dynamic_cast< const PlaneGeometry * >( rendererGeometry2D );

  if ( (planarFigurePlaneGeometry != NULL) && (rendererPlaneGeometry != NULL) )
  {
    double planeThickness = planarFigurePlaneGeometry->GetExtentInMM( 2 );
    if ( !planarFigurePlaneGeometry->IsParallel( rendererPlaneGeometry )
      || !(planarFigurePlaneGeometry->DistanceFromPlane( 
           rendererPlaneGeometry ) < planeThickness / 2.0) )
    {
      // Planes are not parallel or renderer plane is not within PlanarFigure
      // geometry bounds --> exit
      return;
    }
  }
  else
  {
    // Plane is not valid (curved reformations are not possible yet)
    return;
  }


  // Get display geometry
  mitk::DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry();
  assert( displayGeometry != NULL );


  // Apply visual appearance properties from the PropertyList
  this->ApplyProperties( renderer );

  // Enable line antialiasing
  glEnable( GL_LINE_SMOOTH );
  glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
  
  // Get properties from node (if present)
  const mitk::DataNode* node=this->GetDataNode();
  this->InitializePlanarFigurePropertiesFromDataNode( node );

  PlanarFigureDisplayMode lineDisplayMode = PF_DEFAULT;

  if ( m_IsSelected )
  {
    lineDisplayMode = PF_SELECTED;
  }
  else if ( m_IsHovering )
  {
    lineDisplayMode = PF_HOVER;
  }
 
  mitk::Point2D firstPoint; firstPoint[0] = 0; firstPoint[1] = 1;

  if ( m_DrawOutline )
  {
    // Draw the outline for all polylines if requested
    this->DrawMainLines( planarFigure,
      m_OutlineColor[lineDisplayMode],
      m_OutlineOpacity[lineDisplayMode],
      m_OutlineWidth,
      firstPoint,
      planarFigureGeometry2D, rendererGeometry2D, displayGeometry );

    // Draw the outline for all helper objects if requested
    this->DrawHelperLines( planarFigure,
      m_OutlineColor[lineDisplayMode],
      m_OutlineOpacity[lineDisplayMode],
      m_OutlineWidth,
      firstPoint,
      planarFigureGeometry2D, rendererGeometry2D, displayGeometry );
  }


  // Draw the main line for all polylines
  this->DrawMainLines( planarFigure,
    m_LineColor[lineDisplayMode],
    m_LineOpacity[lineDisplayMode],
    m_LineWidth,
    firstPoint,
    planarFigureGeometry2D, rendererGeometry2D, displayGeometry );

  double annotationOffset = 0.0;

  // draw name near the first point (if present)
  std::string name = node->GetName();
  if ( !name.empty() )
  {
    mitk::VtkPropRenderer* openGLrenderer = dynamic_cast<mitk::VtkPropRenderer*>( renderer );
    if ( openGLrenderer )
    {
      if ( m_IsSelected || m_IsHovering )
      {
        openGLrenderer->WriteSimpleText( name,
          firstPoint[0] + 5.0, firstPoint[1] + 5.0,
          m_LineColor[lineDisplayMode][0],
          m_LineColor[lineDisplayMode][1],
          m_LineColor[lineDisplayMode][2] );
      }
      
      // If drawing is successful, add approximate height to annotation offset
      annotationOffset -= 15.0;
    }
  }

  // draw feature quantities (if requested) new the first point
  if ( m_DrawQuantities )
  {
    std::stringstream quantityString;
    quantityString.setf( ios::fixed, ios::floatfield );
    quantityString.precision( 1 );

    bool firstActiveFeature = true;
    for ( unsigned int i = 0; i < planarFigure->GetNumberOfFeatures(); ++i )
    {     
      if( planarFigure->IsFeatureActive(i) )
      {
        if ( ! firstActiveFeature ) 
        {
          quantityString << " / ";
        }
        quantityString << planarFigure->GetQuantity( i ) << " ";
        quantityString << planarFigure->GetFeatureUnit( i );
        firstActiveFeature = false;
      }
    }

    mitk::VtkPropRenderer* openGLrenderer = dynamic_cast<mitk::VtkPropRenderer*>( renderer );
    if ( openGLrenderer )
    {
      openGLrenderer->WriteSimpleText( quantityString.str().c_str(),
        firstPoint[0] + 5.0, firstPoint[1] + 5.0 + annotationOffset,
        m_LineColor[lineDisplayMode][0],
        m_LineColor[lineDisplayMode][1],
        m_LineColor[lineDisplayMode][2] );

      // If drawing is successful, add approximate height to annotation offset
      annotationOffset -= 15.0;
    }
  }


  // Draw helper objects
  this->DrawHelperLines( planarFigure,
    m_HelperlineColor[lineDisplayMode],
    m_HelperlineOpacity[lineDisplayMode],
    m_LineWidth,
    firstPoint,
    planarFigureGeometry2D, rendererGeometry2D, displayGeometry );



  // Draw markers at control points (selected control point will be colored)
  for ( unsigned int i = 0; i < planarFigure->GetNumberOfControlPoints(); ++i )
  {
    
    bool isEditable = true;
    m_DataNode->GetBoolProperty( "planarfigure.iseditable", isEditable );
    
    PlanarFigureDisplayMode pointDisplayMode = PF_DEFAULT;

    // Only if planar figure is marked as editable: display markers (control points) in a
    // different style if mouse is over them or they are selected
    if ( isEditable )
    {
      if ( i == (unsigned int) planarFigure->GetSelectedControlPoint() )
      {
        pointDisplayMode = PF_SELECTED;
      }
      else if ( m_IsHovering )
      {
        pointDisplayMode = PF_HOVER;
      }
    }

    this->DrawMarker( planarFigure->GetControlPoint( i ),
      m_MarkerlineColor[pointDisplayMode],
      m_MarkerlineOpacity[pointDisplayMode],
      m_MarkerColor[pointDisplayMode],
      m_MarkerOpacity[pointDisplayMode],
      m_LineWidth,
      m_ControlPointShape,
      planarFigureGeometry2D, 
      rendererGeometry2D, 
      displayGeometry );
  }

  glLineWidth( 1.0f );
}
void mitk::PlanarFigureMapper2D::PaintPolyLine ( const VertexContainerType vertices,
bool  closed,
float *  color,
float  opacity,
float  lineWidth,
Point2D &  firstPoint,
const Geometry2D planarFigureGeometry2D,
const Geometry2D rendererGeometry2D,
const DisplayGeometry displayGeometry 
) [protected]

Definition at line 261 of file mitkPlanarFigureMapper2D.cpp.

References GL_LINE_LOOP, GL_LINE_STRIP, glBegin(), glColor4f(), glEnd(), glLineWidth(), and glVertex2f().

{
  glColor4f( color[0], color[1], color[2], opacity );
  glLineWidth(lineWidth);

  if ( closed )
  {
    glBegin( GL_LINE_LOOP );
  }
  else 
  {
    glBegin( GL_LINE_STRIP );
  }

  for ( VertexContainerType::ConstIterator it = vertices->Begin(); it != vertices->End(); ++it )
  {
    // Draw this 2D point as OpenGL vertex
    mitk::Point2D displayPoint;
    this->TransformObjectToDisplay( it->Value(), displayPoint,
      planarFigureGeometry2D, rendererGeometry2D, displayGeometry );

    if(it == vertices->Begin())
      firstPoint = displayPoint;

    glVertex2f( displayPoint[0], displayPoint[1] );

  }

  glEnd();
}
void mitk::PlanarFigureMapper2D::SetColorProperty ( float  property[3][3],
PlanarFigureDisplayMode  mode,
float  red,
float  green,
float  blue 
) [inline, protected]

Definition at line 190 of file mitkPlanarFigureMapper2D.h.

  {
    property[mode][0] = red;
    property[mode][1] = green;
    property[mode][2] = blue;
  }
void mitk::PlanarFigureMapper2D::SetDefaultProperties ( mitk::DataNode node,
mitk::BaseRenderer renderer = NULL,
bool  overwrite = false 
) [static]

Set default values of properties used by this mapper to node.

Parameters:
nodeThe node for which the properties are set
overwriteoverwrite existing properties (default: false)
rendererdefines which property list of node is used (default: NULL, i.e. default property list)

Reimplemented from mitk::Mapper.

Definition at line 554 of file mitkPlanarFigureMapper2D.cpp.

References mitk::DataNode::AddProperty(), and mitk::BoolProperty::New().

Referenced by mitk::PlanarFigureObjectFactory::SetDefaultProperties().

{
  node->AddProperty( "visible", mitk::BoolProperty::New(true), renderer, overwrite );
}
void mitk::PlanarFigureMapper2D::SetFloatProperty ( float *  property,
PlanarFigureDisplayMode  mode,
float  value 
) [inline, protected]

Definition at line 197 of file mitkPlanarFigureMapper2D.h.

  {
    property[mode] = value;
  }
void mitk::PlanarFigureMapper2D::TransformObjectToDisplay ( const mitk::Point2D &  point2D,
mitk::Point2D &  displayPoint,
const mitk::Geometry2D objectGeometry,
const mitk::Geometry2D rendererGeometry,
const mitk::DisplayGeometry displayGeometry 
) [protected]

Definition at line 355 of file mitkPlanarFigureMapper2D.cpp.

References mitk::Geometry2D::Map(), and mitk::DisplayGeometry::WorldToDisplay().

{
  mitk::Point3D point3D;

  // Map circle point from local 2D geometry into 3D world space
  objectGeometry->Map( point2D, point3D );

  // Project 3D world point onto display geometry
  rendererGeometry->Map( point3D, displayPoint );
  displayGeometry->WorldToDisplay( displayPoint, displayPoint );
}

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