Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkContourModelGLMapper2D.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 #include "mitkBaseRenderer.h"
19 #include "mitkColorProperty.h"
20 #include "mitkContourModel.h"
22 #include "mitkPlaneGeometry.h"
23 #include "mitkProperties.h"
24 #include <vtkLinearTransform.h>
25 
26 #include "mitkGL.h"
27 
29  : m_SubdivisionContour(mitk::ContourModel::New()), m_InitSubdivisionCurve(true)
30 {
31 }
32 
34 {
35 }
36 
38 {
39  BaseLocalStorage *ls = m_LSH.GetLocalStorage(renderer);
40 
41  mitk::DataNode *dataNode = this->GetDataNode();
42 
43  bool visible = true;
44  dataNode->GetVisibility(visible, renderer, "visible");
45 
46  if (!visible)
47  return;
48 
49  mitk::ContourModel *input = this->GetInput();
50 
51  mitk::ContourModel::Pointer renderingContour = input;
52 
53  bool subdivision = false;
54 
55  dataNode->GetBoolProperty("subdivision curve", subdivision, renderer);
56  if (subdivision)
57  {
58  if (this->m_SubdivisionContour->GetMTime() < renderingContour->GetMTime() || m_InitSubdivisionCurve)
59  {
60  // mitk::ContourModel::Pointer subdivContour = mitk::ContourModel::New();
61 
63 
64  subdivFilter->SetInput(input);
65  subdivFilter->Update();
66 
67  this->m_SubdivisionContour = subdivFilter->GetOutput();
68 
69  m_InitSubdivisionCurve = false;
70  }
71  renderingContour = this->m_SubdivisionContour;
72  }
73 
74  this->DrawContour(renderingContour, renderer);
75 
76  ls->UpdateGenerateDataTime();
77 }
78 
79 mitk::ContourModel *mitk::ContourModelGLMapper2D::GetInput(void)
80 {
81  return const_cast<mitk::ContourModel *>(static_cast<const mitk::ContourModel *>(GetDataNode()->GetData()));
82 }
83 
85  mitk::BaseRenderer *renderer,
86  bool overwrite)
87 {
88  node->AddProperty("contour.color", ColorProperty::New(0.9, 1.0, 0.1), renderer, overwrite);
89  node->AddProperty("contour.points.color", ColorProperty::New(1.0, 0.0, 0.1), renderer, overwrite);
90  node->AddProperty("contour.points.show", mitk::BoolProperty::New(false), renderer, overwrite);
91  node->AddProperty("contour.segments.show", mitk::BoolProperty::New(true), renderer, overwrite);
92  node->AddProperty("contour.controlpoints.show", mitk::BoolProperty::New(false), renderer, overwrite);
93  node->AddProperty("contour.width", mitk::FloatProperty::New(1.0), renderer, overwrite);
94  node->AddProperty("contour.hovering.width", mitk::FloatProperty::New(3.0), renderer, overwrite);
95  node->AddProperty("contour.hovering", mitk::BoolProperty::New(false), renderer, overwrite);
96  node->AddProperty("contour.points.text", mitk::BoolProperty::New(false), renderer, overwrite);
97  node->AddProperty("contour.controlpoints.text", mitk::BoolProperty::New(false), renderer, overwrite);
98 
99  node->AddProperty("subdivision curve", mitk::BoolProperty::New(false), renderer, overwrite);
100  node->AddProperty("contour.project-onto-plane", mitk::BoolProperty::New(false), renderer, overwrite);
101 
102  node->AddProperty("opacity", mitk::FloatProperty::New(1.0f), renderer, overwrite);
103 
104  Superclass::SetDefaultProperties(node, renderer, overwrite);
105 }
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
static Pointer New()
Organizes the rendering process.
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
DataCollection - Class to facilitate loading/accessing structured data.
virtual void Paint(BaseRenderer *renderer) override
static Pointer New()
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
static Pointer New()
bool GetVisibility(bool &visible, const mitk::BaseRenderer *renderer, const char *propertyKey="visible") const
Convenience access method for visibility properties (instances of BoolProperty with property-key "vis...
Definition: mitkDataNode.h:413
itk::SmartPointer< Self > Pointer
Definition: mitkBaseData.h:42
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.