Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkColorBarOverlay.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 
17 #include "mitkColorBarOverlay.h"
18 #include "mitkLookupTable.h"
20 #include <vtkScalarBarActor.h>
21 
23 {
24  SetDrawAnnotations(true);
25 
26  SetDrawTickLabels(true);
27 
29 
32 
34 
35  SetLookupTable(NULL);
36 }
37 
39 {
40 }
41 
43 {
44 }
45 
47 {
48  m_ScalarBarActor = vtkSmartPointer<vtkScalarBarActor>::New();
49 }
50 
52 {
53  LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);
54 
55  if (ls->IsGenerateDataRequired(renderer, this))
56  {
57  ls->m_ScalarBarActor->SetDrawAnnotations(this->GetDrawAnnotations());
58  ls->m_ScalarBarActor->SetLookupTable(this->GetLookupTable());
59  ls->m_ScalarBarActor->SetOrientation(this->GetOrientation());
60  ls->m_ScalarBarActor->SetDrawTickLabels(this->GetDrawTickLabels());
61  ls->m_ScalarBarActor->SetMaximumNumberOfColors(this->GetMaxNumberOfColors());
62  ls->m_ScalarBarActor->SetNumberOfLabels(this->GetNumberOfLabels());
63  ls->m_ScalarBarActor->SetAnnotationTextScaling(this->GetAnnotationTextScaling());
64  // manually set position so there is no overlap with mitk logo in 3d renderwindow
65  if (this->GetOrientation() == 1)
66  {
67  ls->m_ScalarBarActor->SetPosition(0.80, 0.15);
68  ls->m_ScalarBarActor->SetWidth(0.15);
69  ls->m_ScalarBarActor->SetHeight(0.85);
70  }
71  else
72  {
73  ls->m_ScalarBarActor->SetPosition(0.03, 0.03);
74  ls->m_ScalarBarActor->SetWidth(0.8);
75  ls->m_ScalarBarActor->SetHeight(0.15);
76  }
77  }
78 }
79 
81 {
82  LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);
83  return ls->m_ScalarBarActor;
84 }
85 
87 {
88  SetBoolProperty("ColorBarOverlay.DrawAnnotations", annotations);
89 }
90 
92 {
93  bool annotations;
94  GetPropertyList()->GetBoolProperty("ColorBarOverlay.DrawAnnotations", annotations);
95  return annotations;
96 }
97 
98 void mitk::ColorBarOverlay::SetLookupTable(vtkSmartPointer<vtkLookupTable> table)
99 {
102  lut->SetVtkLookupTable(table);
103  prop->SetLookupTable(lut);
104  SetProperty("ColorBarOverlay.LookupTable", prop.GetPointer());
105 }
106 
107 vtkSmartPointer<vtkLookupTable> mitk::ColorBarOverlay::GetLookupTable() const
108 {
110  lut = dynamic_cast<mitk::LookupTableProperty *>(GetPropertyList()->GetProperty("ColorBarOverlay.LookupTable"))
111  ->GetLookupTable();
112  return lut->GetVtkLookupTable();
113 }
114 
116 {
117  SetIntProperty("ColorBarOverlay.Orientation", orientation);
118 }
119 
121 {
122  int orientation;
123  GetPropertyList()->GetIntProperty("ColorBarOverlay.Orientation", orientation);
124  return orientation;
125 }
126 
128 {
129  SetBoolProperty("ColorBarOverlay.DrawTicks", ticks);
130 }
131 
133 {
134  bool ticks;
135  GetPropertyList()->GetBoolProperty("ColorBarOverlay.DrawTicks", ticks);
136  return ticks;
137 }
138 
140 {
141  SetOrientation(0);
142 }
143 
145 {
146  SetOrientation(1);
147 }
148 
150 {
151  SetIntProperty("ColorBarOverlay.MaximumNumberOfColors", numberOfColors);
152 }
153 
155 {
156  int numberOfColors;
157  GetPropertyList()->GetIntProperty("ColorBarOverlay.MaximumNumberOfColors", numberOfColors);
158  return numberOfColors;
159 }
160 
162 {
163  SetIntProperty("ColorBarOverlay.NumberOfLabels", numberOfLabels);
164 }
165 
167 {
168  int numberOfLabels;
169  GetPropertyList()->GetIntProperty("ColorBarOverlay.NumberOfLabels", numberOfLabels);
170  return numberOfLabels;
171 }
172 
174 {
175  SetBoolProperty("ColorBarOverlay.ScaleAnnotationText", scale);
176 }
177 
179 {
180  bool scale;
181  GetPropertyList()->GetBoolProperty("ColorBarOverlay.ScaleAnnotationText", scale);
182  return scale;
183 }
LocalStorage()
Default constructor of the local storage.
void SetDrawAnnotations(bool annotations)
ColorBarOverlay()
explicit constructor which disallows implicit conversions
Organizes the rendering process.
void SetOrientation(int orientation)
void SetAnnotationTextScaling(bool scale)
void SetMaxNumberOfColors(int numberOfColors)
~LocalStorage()
Default deconstructor of the local storage.
void SetDrawTickLabels(bool ticks)
virtual vtkProp * GetVtkProp(BaseRenderer *renderer) const override
This method is implemented by the specific VTKOverlays in order to create the element as a vtkProp...
The LookupTableProperty class Property to associate mitk::LookupTable to an mitk::DataNode.
static Pointer New()
vtkSmartPointer< vtkScalarBarActor > m_ScalarBarActor
Actor of a 2D render window.
void SetLookupTable(vtkSmartPointer< vtkLookupTable > table)
void SetNumberOfLabels(int numberOfLabels)
vtkSmartPointer< vtkLookupTable > GetLookupTable() const
bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Overlay *overlay)
virtual ~ColorBarOverlay()
virtual destructor in order to derive from this class
static Pointer New()
virtual void UpdateVtkOverlay(BaseRenderer *renderer) override
bool GetAnnotationTextScaling() const
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.