Medical Imaging Interaction Toolkit  2026.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 {
29  template <class T>
30  class CallbackEventOneParameter : public itk::AnyEvent
31  {
32  public:
34  typedef itk::AnyEvent Superclass;
35 
37  CallbackEventOneParameter(const T t) : m_Data(t) {}
39  const char *GetEventName() const override { return "CallbackEventOneParameter"; }
40  bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
41  ::itk::EventObject *MakeObject() const override { return new Self(m_Data); }
42 
46  const T GetData() const { return m_Data; }
47  CallbackEventOneParameter(const Self &s) : itk::AnyEvent(s), m_Data(s.m_Data){};
48 
49  protected:
50  const T m_Data;
51 
52  private:
53  void operator=(const Self &);
54  };
55 
66  {
67  public:
74  virtual void CallThisFromGUIThread(itk::Command *, itk::EventObject *) = 0;
75 
77 
78  protected:
79  private:
80  };
81 
173  {
174  public:
180 
191 
201  void CallThisFromGUIThread(itk::Command *, itk::EventObject *e = nullptr);
202 
203  protected:
206 
207  private:
208  static CallbackFromGUIThreadImplementation *m_Implementation;
209  static CallbackFromGUIThread *m_Instance;
210  };
211 
212 } // namespace
213 
214 #endif
#define MITKCORE_EXPORT
ITK event that carries a single typed parameter for CallbackFromGUIThread.
bool CheckEvent(const ::itk::EventObject *e) const override
const char * GetEventName() const override
CallbackEventOneParameter(const T t)
Construct with the given data payload.
const T GetData() const
Retrieve the stored data payload.
::itk::EventObject * MakeObject() const override
Toolkit-specific implementation of mitk::CallbackFromGUIThread.
virtual void CallThisFromGUIThread(itk::Command *, itk::EventObject *)=0
Execute the given command from the GUI thread.
Allows threads to call some method from within the GUI thread.
void CallThisFromGUIThread(itk::Command *, itk::EventObject *e=nullptr)
Schedule the given command for execution on the GUI thread.
CallbackFromGUIThread()
Hidden constructor (singleton pattern).
static void RegisterImplementation(CallbackFromGUIThreadImplementation *implementation)
Register a toolkit-specific implementation.
static CallbackFromGUIThread * GetInstance()
Return the singleton instance.
Find image slices visible on a given plane.