Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
Medical Imaging Interaction Toolkit
mitkScaleLegendAnnotation.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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 #include <vtkAxisActor2D.h>
15 #include <vtkLegendScaleActor.h>
16 #include <vtkTextProperty.h>
17 
19 {
24  SetLegendVisibility(true);
30  SetFontFactor(1.0);
31 }
32 
34 {
35  for (BaseRenderer *renderer : m_LSH.GetRegisteredBaseRenderer())
36  {
37  if (renderer)
38  {
39  this->RemoveFromBaseRenderer(renderer);
40  }
41  }
42 }
43 
45 {
46 }
47 
49 {
50  m_legendScaleActor = vtkSmartPointer<vtkLegendScaleActor>::New();
51 }
52 
54 {
55  LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);
56 
57  if (ls->IsGenerateDataRequired(renderer, this))
58  {
59  ls->m_legendScaleActor->SetRightAxisVisibility(this->GetRightAxisVisibility());
60  ls->m_legendScaleActor->SetTopAxisVisibility(this->GetTopAxisVisibility());
61  ls->m_legendScaleActor->SetLeftAxisVisibility(this->GetLeftAxisVisibility());
62  ls->m_legendScaleActor->SetBottomAxisVisibility(this->GetBottomAxisVisibility());
63  ls->m_legendScaleActor->SetLegendVisibility(this->GetLegendVisibility());
64  ls->m_legendScaleActor->SetRightBorderOffset(this->GetRightBorderOffset());
65  ls->m_legendScaleActor->SetLeftBorderOffset(this->GetLeftBorderOffset());
66  ls->m_legendScaleActor->SetTopBorderOffset(this->GetTopBorderOffset());
67  ls->m_legendScaleActor->SetBottomBorderOffset(this->GetBottomBorderOffset());
68  ls->m_legendScaleActor->SetCornerOffsetFactor(this->GetCornerOffsetFactor());
69  ls->m_legendScaleActor->GetLeftAxis()->SetFontFactor(this->GetFontFactor());
70  ls->m_legendScaleActor->GetRightAxis()->SetFontFactor(this->GetFontFactor());
71  ls->m_legendScaleActor->GetTopAxis()->SetFontFactor(this->GetFontFactor());
72  ls->m_legendScaleActor->GetBottomAxis()->SetFontFactor(this->GetFontFactor());
73  }
74 }
75 
77 {
78  LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);
79  return ls->m_legendScaleActor;
80 }
81 
83 {
84  SetBoolProperty("ScaleLegendAnnotation.RightAxisVisibility", visibility);
85 }
86 
88 {
89  bool visibility;
90  GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.RightAxisVisibility", visibility);
91  return visibility;
92 }
93 
95 {
96  SetBoolProperty("ScaleLegendAnnotation.LeftAxisVisibility", visibility);
97 }
98 
100 {
101  bool visibility;
102  GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.LeftAxisVisibility", visibility);
103  return visibility;
104 }
105 
107 {
108  SetBoolProperty("ScaleLegendAnnotation.TopAxisVisibility", visibility);
109 }
110 
112 {
113  bool visibility;
114  GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.TopAxisVisibility", visibility);
115  return visibility;
116 }
117 
119 {
120  SetBoolProperty("ScaleLegendAnnotation.BottomAxisVisibility", visibility);
121 }
122 
124 {
125  bool visibility;
126  GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.BottomAxisVisibility", visibility);
127  return visibility;
128 }
129 
131 {
132  SetBoolProperty("ScaleLegendAnnotation.SetLegendVisibility", visibility);
133 }
134 
136 {
137  bool visibility;
138  GetPropertyList()->GetBoolProperty("ScaleLegendAnnotation.SetLegendVisibility", visibility);
139  return visibility;
140 }
141 
143 {
144  SetIntProperty("ScaleLegendAnnotation.RightBorderOffset", offset);
145 }
146 
148 {
149  int offset;
150  GetPropertyList()->GetIntProperty("ScaleLegendAnnotation.RightBorderOffset", offset);
151  return offset;
152 }
153 
155 {
156  SetIntProperty("ScaleLegendAnnotation.LeftBorderOffset", offset);
157 }
158 
160 {
161  int offset;
162  GetPropertyList()->GetIntProperty("ScaleLegendAnnotation.LeftBorderOffset", offset);
163  return offset;
164 }
165 
167 {
168  SetIntProperty("ScaleLegendAnnotation.TopBorderOffset", offset);
169 }
170 
172 {
173  int offset;
174  GetPropertyList()->GetIntProperty("ScaleLegendAnnotation.TopBorderOffset", offset);
175  return offset;
176 }
177 
179 {
180  SetIntProperty("ScaleLegendAnnotation.BottomBorderOffset", offset);
181 }
182 
184 {
185  int offset;
186  GetPropertyList()->GetIntProperty("ScaleLegendAnnotation.BottomBorderOffset", offset);
187  return offset;
188 }
189 
191 {
192  SetDoubleProperty("ScaleLegendAnnotation.CornerOffsetFactor", offsetFactor);
193 }
194 
196 {
197  double offsetFactor;
198  GetPropertyList()->GetDoubleProperty("ScaleLegendAnnotation.CornerOffsetFactor", offsetFactor);
199  return offsetFactor;
200 }
201 
203 {
204  SetDoubleProperty("ScaleLegendAnnotation.FontFactor", fontFactor);
205 }
206 
208 {
209  double offsetFactor;
210  GetPropertyList()->GetDoubleProperty("ScaleLegendAnnotation.FontFactor", offsetFactor);
211  return offsetFactor;
212 }
#define ls
Definition: MitkMCxyz.cpp:57
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
void UpdateVtkAnnotation(BaseRenderer *renderer) override
vtkProp * GetVtkProp(BaseRenderer *renderer) const override
This method is implemented by the specific VTKAnnotation in order to create the element as a vtkProp...
std::vector< mitk::BaseRenderer * > GetRegisteredBaseRenderer()
bool GetIntProperty(const char *propertyKey, int &intValue) const
Convenience method to access the value of an IntProperty.
~ScaleLegendAnnotation() override
virtual destructor in order to derive from this class
Organizes the rendering process.
bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Annotation *Annotation)
vtkSmartPointer< vtkLegendScaleActor > m_legendScaleActor
Actor of a 2D render window.
LocalStorage()
Default constructor of the local storage.
void SetBottomAxisVisibility(bool visibility)
void SetDoubleProperty(const std::string &propertyKey, double doubleValue)
Convenience method for setting int properties (instances of IntProperty)
static Vector3D offset
void SetRightAxisVisibility(bool visibility)
void RemoveFromBaseRenderer(BaseRenderer *renderer) override
Removes the Annotation from the specified renderer. It is not visible anymore then.
void SetBoolProperty(const std::string &propertyKey, bool boolValue)
Convenience method for setting int properties (instances of IntProperty)
~LocalStorage()
Default deconstructor of the local storage.
ScaleLegendAnnotation()
explicit constructor which disallows implicit conversions
void SetCornerOffsetFactor(double offsetFactor)
PropertyList * GetPropertyList() const
bool GetBoolProperty(const char *propertyKey, bool &boolValue) const
Convenience method to access the value of a BoolProperty.
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all LocalStorages for the render windows.
void SetIntProperty(const std::string &propertyKey, int intValue)
Convenience method for setting int properties (instances of IntProperty)
bool GetDoubleProperty(const char *propertyKey, double &doubleValue) const
Convenience method to access the value of a DoubleProperty.
void SetLeftAxisVisibility(bool visibility)