Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkOverlay.h
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 #ifndef OVERLAY_H
18 #define OVERLAY_H
19 
20 #include <MitkCoreExports.h>
21 #include <mitkBaseRenderer.h>
22 #include <mitkCommon.h>
23 
24 namespace mitk
25 {
26  class AbstractOverlayLayouter;
27 
34  class MITKCORE_EXPORT Overlay : public itk::Object
35  {
37 
38  public:
40  struct Bounds
41  {
42  itk::Point<double, 2> Position;
43  itk::Point<double, 2> Size;
44  };
45 
46  typedef std::map<const BaseRenderer *, PropertyList::Pointer> MapOfPropertyLists;
47 
51  {
52  public:
53  bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Overlay *overlay);
54 
55  inline void UpdateGenerateDataTime() { m_LastGenerateDataTime.Modified(); }
56  inline itk::TimeStamp &GetLastGenerateDataTime() { return m_LastGenerateDataTime; }
57  protected:
59  itk::TimeStamp m_LastGenerateDataTime;
60  };
61 
73  void SetProperty(const std::string &propertyKey,
74  const BaseProperty::Pointer &property,
75  const mitk::BaseRenderer *renderer = nullptr);
76 
87  void ReplaceProperty(const std::string &propertyKey,
88  const BaseProperty::Pointer &property,
89  const mitk::BaseRenderer *renderer = nullptr);
90 
107  void AddProperty(const std::string &propertyKey,
108  const BaseProperty::Pointer &property,
109  const mitk::BaseRenderer *renderer = nullptr,
110  bool overwrite = false);
111 
120  mitk::PropertyList *GetPropertyList(const mitk::BaseRenderer *renderer = nullptr) const;
121 
138  void ConcatenatePropertyList(PropertyList *pList, bool replace = false);
139 
151  mitk::BaseProperty *GetProperty(const std::string &propertyKey, const mitk::BaseRenderer *renderer = nullptr) const;
152 
164  template <typename T>
166  const std::string &propertyKey,
167  const mitk::BaseRenderer *renderer = nullptr) const
168  {
169  property = dynamic_cast<T *>(GetProperty(propertyKey, renderer));
170  return property.IsNotNull();
171  }
172 
184  template <typename T>
185  bool GetProperty(T *&property, const std::string &propertyKey, const mitk::BaseRenderer *renderer = nullptr) const
186  {
187  property = dynamic_cast<T *>(GetProperty(propertyKey, renderer));
188  return property != nullptr;
189  }
190 
196  template <typename T>
197  bool GetPropertyValue(const std::string &propertyKey, T &value, mitk::BaseRenderer *renderer = nullptr) const
198  {
199  GenericProperty<T> *gp = dynamic_cast<GenericProperty<T> *>(GetProperty(propertyKey, renderer));
200  if (gp != nullptr)
201  {
202  value = gp->GetValue();
203  return true;
204  }
205  return false;
206  }
207 
213  bool GetBoolProperty(const std::string &propertyKey, bool &boolValue, mitk::BaseRenderer *renderer = nullptr) const;
214 
220  bool GetIntProperty(const std::string &propertyKey, int &intValue, mitk::BaseRenderer *renderer = nullptr) const;
221 
227  bool GetFloatProperty(const std::string &propertyKey,
228  float &floatValue,
229  mitk::BaseRenderer *renderer = nullptr) const;
230 
236  bool GetStringProperty(const std::string &propertyKey,
237  std::string &string,
238  mitk::BaseRenderer *renderer = nullptr) const;
239 
244  void SetIntProperty(const std::string &propertyKey, int intValue, mitk::BaseRenderer *renderer = nullptr);
245 
250  void SetBoolProperty(const std::string &propertyKey, bool boolValue, mitk::BaseRenderer *renderer = nullptr);
251 
256  void SetFloatProperty(const std::string &propertyKey, float floatValue, mitk::BaseRenderer *renderer = nullptr);
257 
262  void SetStringProperty(const std::string &propertyKey,
263  const std::string &string,
264  mitk::BaseRenderer *renderer = nullptr);
265 
275  bool IsOn(const std::string &propertyKey, mitk::BaseRenderer *renderer, bool defaultIsOn = true) const
276  {
277  GetBoolProperty(propertyKey, defaultIsOn, renderer);
278  return defaultIsOn;
279  }
280 
286  bool GetName(std::string &nodeName,
287  mitk::BaseRenderer *renderer = nullptr,
288  const std::string &propertyKey = "name") const;
289 
299  virtual std::string GetName() const;
300 
306  virtual void SetName(const std::string &name);
307 
313  bool GetColor(float rgb[], mitk::BaseRenderer *renderer = nullptr, const std::string &propertyKey = "color") const;
318  void SetColor(const mitk::Color &color,
319  mitk::BaseRenderer *renderer = nullptr,
320  const std::string &propertyKey = "color");
325  void SetColor(float red,
326  float green,
327  float blue,
328  mitk::BaseRenderer *renderer = nullptr,
329  const std::string &propertyKey = "color");
334  void SetColor(const float rgb[], mitk::BaseRenderer *renderer = nullptr, const std::string &propertyKey = "color");
340  bool GetOpacity(float &opacity, mitk::BaseRenderer *renderer, const std::string &propertyKey = "opacity") const;
345  void SetOpacity(float opacity, mitk::BaseRenderer *renderer = nullptr, const std::string &propertyKey = "opacity");
346 
347  void SetText(std::string text, mitk::BaseRenderer *renderer = nullptr);
348 
349  std::string GetText(mitk::BaseRenderer *renderer = nullptr) const;
350 
351  void SetFontSize(int fontSize, mitk::BaseRenderer *renderer = nullptr);
352 
353  int GetFontSize(mitk::BaseRenderer *renderer = nullptr) const;
354 
361  bool GetVisibility(bool &visible, mitk::BaseRenderer *renderer, const std::string &propertyKey = "visible") const;
362 
374  bool IsVisible(mitk::BaseRenderer *renderer,
375  const std::string &propertyKey = "visible",
376  bool defaultIsOn = true) const;
377 
385  void SetVisibility(bool visible,
386  mitk::BaseRenderer *renderer = nullptr,
387  const std::string &propertyKey = "visible");
388 
391  virtual void AddToBaseRenderer(BaseRenderer *renderer) = 0;
392 
395  virtual void AddToRenderer(BaseRenderer *renderer, vtkRenderer *vtkrenderer) = 0;
396 
398  virtual void RemoveFromBaseRenderer(BaseRenderer *renderer) = 0;
399 
401  virtual void RemoveFromRenderer(BaseRenderer *renderer, vtkRenderer *vtkrenderer) = 0;
402 
404  virtual void Update(BaseRenderer *renderer) = 0;
405 
407  virtual Bounds GetBoundsOnDisplay(BaseRenderer *renderer) const;
408 
410  virtual void SetBoundsOnDisplay(BaseRenderer *renderer, const Bounds &);
411 
412  void SetForceInForeground(bool forceForeground);
413 
414  bool IsForceInForeground() const;
415 
417 
418  protected:
420  Overlay();
421 
423  virtual ~Overlay();
424 
432 
436  mutable MapOfPropertyLists m_MapOfPropertyLists;
437 
442 
443  private:
445  bool m_ForceInForeground;
446 
448  Overlay(const Overlay &);
449 
451  Overlay &operator=(const Overlay &);
452 
454  AbstractOverlayLayouter *m_LayoutedBy;
455  };
456 
457 } // namespace mitk
458 #endif // OVERLAY_H
bool IsOn(const std::string &propertyKey, mitk::BaseRenderer *renderer, bool defaultIsOn=true) const
Convenience access method for boolean properties (instances of BoolProperty). Return value is the val...
Definition: mitkOverlay.h:275
#define MITKCORE_EXPORT
signed integer value
Definition: jsoncpp.h:348
bool GetProperty(T *&property, const std::string &propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property of type T with key propertyKey from the PropertyList of the renderer, if available there, otherwise use the BaseRenderer-independent PropertyList.
Definition: mitkOverlay.h:185
itk::Point< double, 2 > Size
Definition: mitkOverlay.h:43
Organizes the rendering process.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
DataCollection - Class to facilitate loading/accessing structured data.
itk::Point< double, 2 > Position
Definition: mitkOverlay.h:42
Key-value list holding instances of BaseProperty.
PropertyList::Pointer m_PropertyList
BaseRenderer-independent PropertyList.
Definition: mitkOverlay.h:431
itk::TimeStamp & GetLastGenerateDataTime()
Definition: mitkOverlay.h:56
std::map< const BaseRenderer *, PropertyList::Pointer > MapOfPropertyLists
Definition: mitkOverlay.h:46
MapOfPropertyLists m_MapOfPropertyLists
Map associating each BaseRenderer with its own PropertyList.
Definition: mitkOverlay.h:436
Abstract base class for properties.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
Baseclass of Overlay layouters.
Base class for mapper specific rendering ressources.
Definition: mitkOverlay.h:50
itk::TimeStamp m_LastGenerateDataTime
timestamp of last update of stored data
Definition: mitkOverlay.h:59
bool GetPropertyValue(const std::string &propertyKey, T &value, mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for GenericProperty properties (T being the type of the second parameter...
Definition: mitkOverlay.h:197
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
itk::TimeStamp m_DataReferenceChangedTime
Timestamp of the last change of m_Data.
Definition: mitkOverlay.h:441
Base class for all overlays.
Definition: mitkOverlay.h:34
static const char * replace[]
This is a dictionary to replace long names of classes, modules, etc. to shorter versions in the conso...
static std::string GetName(std::string fileName, std::string suffix)
bool GetProperty(itk::SmartPointer< T > &property, const std::string &propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property of type T with key propertyKey from the PropertyList of the renderer, if available there, otherwise use the BaseRenderer-independent PropertyList.
Definition: mitkOverlay.h:165
Container for position and size on the display.
Definition: mitkOverlay.h:40
virtual T GetValue() const