Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
mitkCallbackFromGUIThread.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 mitkCallbackFromGUIThread_h
14 #define mitkCallbackFromGUIThread_h
15 
16 #include <MitkCoreExports.h>
17 #include <itkCommand.h>
18 #include <itkEventObject.h>
19 
20 namespace mitk
21 {
25  template <class T>
26  class CallbackEventOneParameter : public itk::AnyEvent
27  {
28  public:
30  typedef itk::AnyEvent Superclass;
31 
32  CallbackEventOneParameter(const T t) : m_Data(t) {}
34  const char *GetEventName() const override { return "CallbackEventOneParameter"; }
35  bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
36  ::itk::EventObject *MakeObject() const override { return new Self(m_Data); }
37  const T GetData() const { return m_Data; }
38  CallbackEventOneParameter(const Self &s) : itk::AnyEvent(s), m_Data(s.m_Data){};
39 
40  protected:
41  const T m_Data;
42 
43  private:
44  void operator=(const Self &);
45  };
46 
55  {
56  public:
58  virtual void CallThisFromGUIThread(itk::Command *, itk::EventObject *) = 0;
59 
61 
62  protected:
63  private:
64  };
65 
154  {
155  public:
157  static CallbackFromGUIThread *GetInstance();
158 
160  static void RegisterImplementation(CallbackFromGUIThreadImplementation *implementation);
161 
163  void CallThisFromGUIThread(itk::Command *, itk::EventObject *e = nullptr);
164 
165  protected:
168 
169  private:
170  static CallbackFromGUIThreadImplementation *m_Implementation;
171  static CallbackFromGUIThread *m_Instance;
172  };
173 
174 } // namespace
175 
176 #endif
mitk::CallbackEventOneParameter::m_Data
const T m_Data
Definition: mitkCallbackFromGUIThread.h:38
mitk::CallbackEventOneParameter::CallbackEventOneParameter
CallbackEventOneParameter(const T t)
Definition: mitkCallbackFromGUIThread.h:32
mitk::CallbackEventOneParameter
Used by CallbackFromGUIThread to pass parameters.
Definition: mitkCallbackFromGUIThread.h:26
mitk::CallbackEventOneParameter::MakeObject
::itk::EventObject * MakeObject() const override
Definition: mitkCallbackFromGUIThread.h:36
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::CallbackFromGUIThreadImplementation::~CallbackFromGUIThreadImplementation
virtual ~CallbackFromGUIThreadImplementation()
Definition: mitkCallbackFromGUIThread.h:60
mitk::CallbackFromGUIThread
Allows threads to call some method from within the GUI thread.
Definition: mitkCallbackFromGUIThread.h:153
mitk::CallbackEventOneParameter::~CallbackEventOneParameter
~CallbackEventOneParameter() override
Definition: mitkCallbackFromGUIThread.h:33
mitk::CallbackEventOneParameter::GetData
const T GetData() const
Definition: mitkCallbackFromGUIThread.h:37
MitkCoreExports.h
mitk::CallbackFromGUIThreadImplementation
Toolkit specific implementation of mitk::CallbackFromGUIThread.
Definition: mitkCallbackFromGUIThread.h:54
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30
mitk::CallbackEventOneParameter::Superclass
itk::AnyEvent Superclass
Definition: mitkCallbackFromGUIThread.h:30
mitk::CallbackEventOneParameter::GetEventName
const char * GetEventName() const override
Definition: mitkCallbackFromGUIThread.h:34
mitk::CallbackEventOneParameter::Self
CallbackEventOneParameter Self
Definition: mitkCallbackFromGUIThread.h:29
mitk::CallbackEventOneParameter::CheckEvent
bool CheckEvent(const ::itk::EventObject *e) const override
Definition: mitkCallbackFromGUIThread.h:35
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15