Medical Imaging Interaction Toolkit  2025.12.02
Medical Imaging Interaction Toolkit
mitkMapper.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 (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 
13 #ifndef mitkMapper_h
14 #define mitkMapper_h
15 
16 #include "mitkBaseRenderer.h"
17 #include "mitkCommon.h"
18 #include "mitkLevelWindow.h"
20 #include "mitkVtkPropRenderer.h"
21 #include <MitkCoreExports.h>
22 
23 #include <itkObject.h>
24 #include <itkWeakPointer.h>
25 
26 class vtkWindow;
27 class vtkProp;
28 
29 namespace mitk
30 {
31  class BaseRenderer;
32  class BaseData;
33  class DataNode;
34 
46  class MITKCORE_EXPORT Mapper : public itk::Object
47  {
48  public:
50 
52  itkSetObjectMacro(DataNode, DataNode);
53 
57  virtual DataNode *GetDataNode() const;
58 
66 
72  DEPRECATED(virtual bool GetColor(float rgb[3], BaseRenderer *renderer, const char *name = "color") const);
73 
80  DEPRECATED(virtual bool GetVisibility(bool &visible, BaseRenderer *renderer, const char *name = "visible") const);
81 
87  DEPRECATED(virtual bool GetOpacity(float &opacity, BaseRenderer *renderer, const char *name = "opacity") const);
88 
94  DEPRECATED(virtual bool GetLevelWindow(LevelWindow &levelWindow,
95  BaseRenderer *renderer,
96  const char *name = "levelwindow") const);
97 
108  DEPRECATED(virtual bool IsVisible(BaseRenderer *renderer, const char *name = "visible") const);
109 
113  virtual bool IsVtkBased() const { return true; }
114 
118  virtual void Update(BaseRenderer *renderer);
119 
124 
131  virtual void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor = nullptr) = 0;
132 
141  static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer = nullptr, bool overwrite = false);
142 
144  TimeStepType GetTimestep() const { return m_TimeStep; }
148  virtual bool IsLODEnabled(BaseRenderer * /*renderer*/) const { return false; }
149  protected:
151  explicit Mapper();
152 
154  ~Mapper() override;
155 
159  DEPRECATED(virtual void GenerateData()) {}
161  virtual void GenerateDataForRenderer(BaseRenderer * /* renderer */) {}
163  virtual void CalculateTimeStep(BaseRenderer *renderer);
164 
171  virtual void ResetMapper(BaseRenderer * /*renderer*/) {}
173 
174  private:
179  TimeStepType m_TimeStep;
180 
182  Mapper(const Mapper &);
183 
185  Mapper &operator=(const Mapper &);
186 
187  public:
191  {
192  public:
193  BaseLocalStorage() = default;
194  virtual ~BaseLocalStorage() = default;
195 
198 
199  bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Mapper *mapper, mitk::DataNode *dataNode) const;
200 
201  inline void UpdateGenerateDataTime() { m_LastGenerateDataTime.Modified(); }
202  inline itk::TimeStamp &GetLastGenerateDataTime() { return m_LastGenerateDataTime; }
203  protected:
205  itk::TimeStamp m_LastGenerateDataTime;
206  };
207  };
208 
209 } // namespace mitk
210 
211 #endif
#define MITKCORE_EXPORT
Base of all data objects.
Definition: mitkBaseData.h:44
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
The LevelWindow class Class to store level/window values.
Base class for mapper specific rendering resources.
Definition: mitkMapper.h:191
itk::TimeStamp & GetLastGenerateDataTime()
Definition: mitkMapper.h:202
BaseLocalStorage(const BaseLocalStorage &)=delete
itk::TimeStamp m_LastGenerateDataTime
timestamp of last update of stored data
Definition: mitkMapper.h:205
bool IsGenerateDataRequired(mitk::BaseRenderer *renderer, mitk::Mapper *mapper, mitk::DataNode *dataNode) const
virtual ~BaseLocalStorage()=default
BaseLocalStorage & operator=(const BaseLocalStorage &)=delete
Base class of all mappers, Vtk as well as OpenGL mappers.
Definition: mitkMapper.h:47
virtual void GenerateDataForRenderer(BaseRenderer *)
Generate the data needed for rendering into renderer.
Definition: mitkMapper.h:161
virtual void ResetMapper(BaseRenderer *)
Reset the mapper (i.e., make sure that nothing is displayed) if no valid data is present....
Definition: mitkMapper.h:171
virtual void GenerateData()
Generate the data needed for rendering (independent of a specific renderer)
Definition: mitkMapper.h:159
virtual bool IsVisible(BaseRenderer *renderer, const char *name="visible") const
Convenience access method for visibility properties (instances of BoolProperty). Return value is the ...
virtual bool GetVisibility(bool &visible, BaseRenderer *renderer, const char *name="visible") const
Convenience access method for visibility properties (instances of BoolProperty)
virtual void MitkRender(mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type)=0
Responsible for calling the appropriate render functions. To be implemented in sub-classes.
virtual void Update(BaseRenderer *renderer)
Calls the time step of the input data for the specified renderer and checks whether the time step is ...
virtual bool IsVtkBased() const
Returns whether this is an vtk-based mapper.
Definition: mitkMapper.h:113
virtual bool IsLODEnabled(BaseRenderer *) const
Definition: mitkMapper.h:148
virtual bool GetOpacity(float &opacity, BaseRenderer *renderer, const char *name="opacity") const
Convenience access method for opacity properties (instances of FloatProperty)
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=nullptr, bool overwrite=false)
Set default values of properties used by this mapper to node.
mitk::DataNode * m_DataNode
Definition: mitkMapper.h:172
virtual bool GetColor(float rgb[3], BaseRenderer *renderer, const char *name="color") const
Convenience access method for color properties (instances of ColorProperty)
BaseData * GetData() const
Get the data to map.
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
Mapper()
explicit constructor which disallows implicit conversions
virtual void CalculateTimeStep(BaseRenderer *renderer)
Updates the time step, which is sometimes needed in subclasses.
virtual void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor=nullptr)=0
Apply specific color and opacity properties read from the PropertyList. Reimplemented in GLmapper (do...
~Mapper() override
virtual destructor in order to derive from this class
TimeStepType GetTimestep() const
Returns the current time step as calculated from the renderer.
Definition: mitkMapper.h:144
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
#define DEPRECATED(func)
Definition: mitkCommon.h:175
Find image slices visible on a given plane.
std::size_t TimeStepType