Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
mitkMultiLabelEvents.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 mitkMultiLabelEvents_h
14 #define mitkMultiLabelEvents_h
15 
16 #include <itkEventObject.h>
17 #include <mitkLabel.h>
18 
19 #include <MitkMultilabelExports.h>
20 
21 namespace mitk
22 {
23 #define mitkMultiLabelEventMacroDeclaration(classname, super, IDType) \
24  class MITKMULTILABEL_EXPORT classname : public super \
25  { \
26  public: \
27  using Self = classname; \
28  using Superclass = super; \
29  classname() = default; \
30  classname(IDType value); \
31  classname(const Self & s); \
32  virtual ~classname() override; \
33  virtual const char * \
34  GetEventName() const override; \
35  virtual bool \
36  CheckEvent(const itk::EventObject * e) const override; \
37  virtual itk::EventObject * \
38  MakeObject() const override; \
39  \
40  private: \
41  void \
42  operator=(const Self &); \
43  }; \
44  static_assert(true, "Compile time eliminated. Used to require a semi-colon at end of macro.")
45 
46 #define mitkMultiLabelEventMacroDefinition(classname, super, IDType) \
47  classname::classname(const classname & s) \
48  : super(s){}; \
49  classname::classname(IDType value): super(value) {} \
50  classname::~classname() {} \
51  const char * classname::GetEventName() const { return #classname; } \
52  bool classname::CheckEvent(const itk::EventObject * e) const \
53  { \
54  if (!super::CheckEvent(e)) return false; \
55  return (dynamic_cast<const classname *>(e) != nullptr); \
56  } \
57  itk::EventObject * classname::MakeObject() const { return new classname; } \
58  static_assert(true, "Compile time eliminated. Used to require a semi-colon at end of macro.")
59 
66  class MITKMULTILABEL_EXPORT AnyLabelEvent : public itk::ModifiedEvent
67  {
68  public:
70  using Superclass = itk::ModifiedEvent;
71  const static mitk::Label::PixelType ANY_LABEL = std::numeric_limits<mitk::Label::PixelType>::max();
72 
73  AnyLabelEvent() = default;
74  AnyLabelEvent(Label::PixelType labelValue);
75  AnyLabelEvent(const Self & s);
76  ~AnyLabelEvent() override;
77  const char * GetEventName() const override;
78  bool CheckEvent(const itk::EventObject * e) const override;
79  itk::EventObject * MakeObject() const override;
80 
81  void SetLabelValue(Label::PixelType labelValue);
82  Label::PixelType GetLabelValue() const;
83  private:
84  void operator=(const Self &);
85  Label::PixelType m_LabelValue = std::numeric_limits<mitk::Label::PixelType>::max();
86  };
87 
95 
103 
111 
120  class MITKMULTILABEL_EXPORT LabelsChangedEvent : public itk::ModifiedEvent
121  {
122  public:
124  using Superclass = itk::ModifiedEvent;
125 
126  LabelsChangedEvent() = default;
127  LabelsChangedEvent(std::vector<Label::PixelType> labelValues);
128  LabelsChangedEvent(const Self& s);
129  ~LabelsChangedEvent() override;
130  const char* GetEventName() const override;
131  bool CheckEvent(const itk::EventObject* e) const override;
132  itk::EventObject* MakeObject() const override;
133 
134  void SetLabelValues(std::vector<Label::PixelType> labelValues);
135  std::vector<Label::PixelType> GetLabelValues() const;
136  private:
137  void operator=(const Self&);
138  std::vector<Label::PixelType> m_LabelValues;
139  };
140 
147  class MITKMULTILABEL_EXPORT AnyGroupEvent : public itk::ModifiedEvent
148  {
149  public:
150  using GroupIndexType = std::size_t;
152  using Superclass = itk::ModifiedEvent;
153  const static GroupIndexType ANY_GROUP = std::numeric_limits<GroupIndexType>::max();
154 
155  AnyGroupEvent() = default;
156  AnyGroupEvent(GroupIndexType groupID);
157  AnyGroupEvent(const Self& s);
158  ~AnyGroupEvent() override;
159  const char* GetEventName() const override;
160  bool CheckEvent(const itk::EventObject* e) const override;
161  itk::EventObject* MakeObject() const override;
162 
163  void SetGroupID(GroupIndexType groupID);
164  GroupIndexType GetGroupID() const;
165  private:
166  void operator=(const Self&);
167  GroupIndexType m_GroupID = std::numeric_limits<GroupIndexType>::max();
168  };
169 
177 
185 
193 
194 }
195 
196 #endif
MITKMULTILABEL_EXPORT
#define MITKMULTILABEL_EXPORT
Definition: MitkMultilabelExports.h:15
mitkLabel.h
mitkMultiLabelEventMacroDeclaration
#define mitkMultiLabelEventMacroDeclaration(classname, super, IDType)
Definition: mitkMultiLabelEvents.h:23
mitk::AnyGroupEvent::Superclass
itk::ModifiedEvent Superclass
Definition: mitkMultiLabelEvents.h:152
mitk::GroupModifiedEvent
Definition: mitkMultiLabelEvents.h:184
mitk::GroupRemovedEvent
Definition: mitkMultiLabelEvents.h:192
mitk::LabelAddedEvent
Definition: mitkMultiLabelEvents.h:94
mitk::Label::PixelType
unsigned short PixelType
Definition: mitkLabel.h:34
mitk::LabelRemovedEvent
Definition: mitkMultiLabelEvents.h:110
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::AnyGroupEvent
Definition: mitkMultiLabelEvents.h:147
mitk::LabelsChangedEvent::Superclass
itk::ModifiedEvent Superclass
Definition: mitkMultiLabelEvents.h:124
mitk::AnyGroupEvent::GroupIndexType
std::size_t GroupIndexType
Definition: mitkMultiLabelEvents.h:150
mitk::GroupAddedEvent
Definition: mitkMultiLabelEvents.h:176
mitk::AnyLabelEvent::Superclass
itk::ModifiedEvent Superclass
Definition: mitkMultiLabelEvents.h:70
mitk::AnyLabelEvent
Definition: mitkMultiLabelEvents.h:66
mitk::LabelsChangedEvent
Definition: mitkMultiLabelEvents.h:120
mitk::LabelModifiedEvent
Definition: mitkMultiLabelEvents.h:102
MitkMultilabelExports.h