Medical Imaging Interaction Toolkit  2026.06.00
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 
69  class MITKMULTILABEL_EXPORT AnyLabelEvent : public itk::ModifiedEvent
70  {
71  public:
73  using Superclass = itk::ModifiedEvent;
74 
76  const static mitk::Label::PixelType ANY_LABEL = std::numeric_limits<mitk::Label::PixelType>::max();
77 
78  AnyLabelEvent() = default;
79 
85 
87  AnyLabelEvent(const Self & s);
88 
89  ~AnyLabelEvent() override;
90 
92  const char * GetEventName() const override;
93 
99  bool CheckEvent(const itk::EventObject * e) const override;
100 
102  itk::EventObject * MakeObject() const override;
103 
108  void SetLabelValue(Label::PixelType labelValue);
109 
115  private:
116  void operator=(const Self &);
117  Label::PixelType m_LabelValue = std::numeric_limits<mitk::Label::PixelType>::max();
118  };
119 
127 
135 
143 
154  class MITKMULTILABEL_EXPORT LabelsChangedEvent : public itk::ModifiedEvent
155  {
156  public:
158  using Superclass = itk::ModifiedEvent;
159 
160  LabelsChangedEvent() = default;
161 
166  LabelsChangedEvent(std::vector<Label::PixelType> labelValues);
167 
170 
172 
174  const char* GetEventName() const override;
175 
181  bool CheckEvent(const itk::EventObject* e) const override;
182 
184  itk::EventObject* MakeObject() const override;
185 
190  void SetLabelValues(std::vector<Label::PixelType> labelValues);
191 
196  std::vector<Label::PixelType> GetLabelValues() const;
197  private:
198  void operator=(const Self&);
199  std::vector<Label::PixelType> m_LabelValues;
200  };
201 
211  class MITKMULTILABEL_EXPORT AnyGroupEvent : public itk::ModifiedEvent
212  {
213  public:
215  using GroupIndexType = std::size_t;
217  using Superclass = itk::ModifiedEvent;
218 
220  const static GroupIndexType ANY_GROUP = std::numeric_limits<GroupIndexType>::max();
221 
222  AnyGroupEvent() = default;
223 
229 
231  AnyGroupEvent(const Self& s);
232 
233  ~AnyGroupEvent() override;
234 
236  const char* GetEventName() const override;
237 
243  bool CheckEvent(const itk::EventObject* e) const override;
244 
246  itk::EventObject* MakeObject() const override;
247 
252  void SetGroupID(GroupIndexType groupID);
253 
259  private:
260  void operator=(const Self&);
261  GroupIndexType m_GroupID = std::numeric_limits<GroupIndexType>::max();
262  };
263 
271 
279 
287 
288 }
289 
290 #endif
#define MITKMULTILABEL_EXPORT
Base event class for all group-related events in a MultiLabelSegmentation.
~AnyGroupEvent() override
itk::ModifiedEvent Superclass
bool CheckEvent(const itk::EventObject *e) const override
Checks if a given event matches this event type and group index.
const char * GetEventName() const override
Returns the name of this event class.
AnyGroupEvent(GroupIndexType groupID)
Constructor with a specific group index.
itk::EventObject * MakeObject() const override
Creates a copy of this event.
AnyGroupEvent(const Self &s)
Copy constructor.
AnyGroupEvent()=default
void SetGroupID(GroupIndexType groupID)
Sets the group index this event refers to.
GroupIndexType GetGroupID() const
Returns the group index this event refers to.
std::size_t GroupIndexType
Type for group indices.
Base event class for all label-related events in a MultiLabelSegmentation.
Label::PixelType GetLabelValue() const
Returns the label value this event refers to.
itk::EventObject * MakeObject() const override
Creates a copy of this event.
~AnyLabelEvent() override
bool CheckEvent(const itk::EventObject *e) const override
Checks if a given event matches this event type and label value.
AnyLabelEvent(const Self &s)
Copy constructor.
void SetLabelValue(Label::PixelType labelValue)
Sets the label value this event refers to.
AnyLabelEvent(Label::PixelType labelValue)
Constructor with a specific label value.
const char * GetEventName() const override
Returns the name of this event class.
itk::ModifiedEvent Superclass
AnyLabelEvent()=default
unsigned short PixelType
Pixel type used for label values (unsigned short).
Definition: mitkLabel.h:106
Event emitted once after a batch of label changes in a MultiLabelSegmentation.
const char * GetEventName() const override
Returns the name of this event class.
std::vector< Label::PixelType > GetLabelValues() const
Returns the label values this event refers to.
~LabelsChangedEvent() override
LabelsChangedEvent(std::vector< Label::PixelType > labelValues)
Constructor with a vector of affected label values.
LabelsChangedEvent(const Self &s)
Copy constructor.
itk::EventObject * MakeObject() const override
Creates a copy of this event.
bool CheckEvent(const itk::EventObject *e) const override
Checks if a given event matches this event type.
void SetLabelValues(std::vector< Label::PixelType > labelValues)
Sets the label values this event refers to.
#define mitkMultiLabelEventMacroDeclaration(classname, super, IDType)
Find image slices visible on a given plane.