Medical Imaging Interaction Toolkit  2025.12.02
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;
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);
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);
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;
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);
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
#define MITKMULTILABEL_EXPORT
~AnyGroupEvent() override
itk::ModifiedEvent Superclass
bool CheckEvent(const itk::EventObject *e) const override
const char * GetEventName() const override
AnyGroupEvent(GroupIndexType groupID)
itk::EventObject * MakeObject() const override
AnyGroupEvent(const Self &s)
AnyGroupEvent()=default
void SetGroupID(GroupIndexType groupID)
GroupIndexType GetGroupID() const
Label::PixelType GetLabelValue() const
itk::EventObject * MakeObject() const override
~AnyLabelEvent() override
bool CheckEvent(const itk::EventObject *e) const override
AnyLabelEvent(const Self &s)
void SetLabelValue(Label::PixelType labelValue)
AnyLabelEvent(Label::PixelType labelValue)
const char * GetEventName() const override
itk::ModifiedEvent Superclass
AnyLabelEvent()=default
unsigned short PixelType
Definition: mitkLabel.h:94
const char * GetEventName() const override
std::vector< Label::PixelType > GetLabelValues() const
~LabelsChangedEvent() override
LabelsChangedEvent(std::vector< Label::PixelType > labelValues)
LabelsChangedEvent(const Self &s)
itk::EventObject * MakeObject() const override
bool CheckEvent(const itk::EventObject *e) const override
void SetLabelValues(std::vector< Label::PixelType > labelValues)
#define mitkMultiLabelEventMacroDeclaration(classname, super, IDType)
Find image slices visible on a given plane.