00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #ifndef QMITKSTEPPERADAPTER_H_HEADER_INCLUDED_C1E77191 00020 #define QMITKSTEPPERADAPTER_H_HEADER_INCLUDED_C1E77191 00021 00022 #include "qobject.h" 00023 #include "QmitkExtExports.h" 00024 #include "mitkStepper.h" 00025 #include "itkObject.h" 00026 #include "itkCommand.h" 00027 00028 //##Documentation 00029 //## @brief Helper class to connect Qt-based navigators to instances of Stepper 00030 //## 00031 //## The constructor has to be provided with the \a Navigator 00032 //## that wants to use the \a Stepper. The \a Navigator has to define the 00033 //## slots \a Refetch() and \a SetStepper(mitk::Stepper *). \a SetStepper will be 00034 //## called only once to pass the \a Stepper to the \a Navigator. When the values of 00035 //## the \a Stepper changes, \a Refetch() will be called. The \a Navigator can than 00036 //## ask the \a Stepper for its new values. 00037 //## \warning The \a Navigator has to be aware that it might have caused the changes 00038 //## of the \a Stepper itself. So take care that no infinite recursion is created! 00039 //## @ingroup NavigationControl 00040 class QmitkExt_EXPORT QmitkStepperAdapter : public QObject 00041 { 00042 Q_OBJECT 00043 public: 00044 QmitkStepperAdapter( QObject * navigator, mitk::Stepper * stepper, const char * name ); 00045 virtual ~QmitkStepperAdapter(); 00046 00047 void SetStepper( mitk::Stepper* stepper ) 00048 { 00049 this->SendStepper( stepper ); 00050 this->Refetch(); 00051 } 00052 00053 class QmitkExt_EXPORT ItkEventListener : public itk::Command 00054 { 00055 public: 00056 mitkClassMacro(ItkEventListener, itk::Command); 00057 ItkEventListener(QmitkStepperAdapter* receiver) : 00058 m_Receiver(receiver) 00059 { 00060 00061 }; 00062 virtual void Execute (itk::Object * /* caller */, const itk::EventObject & /* event */) 00063 { 00064 emit m_Receiver->Refetch(); 00065 }; 00066 virtual void Execute (const itk::Object * /* caller */, const itk::EventObject & /* event */) 00067 { 00068 emit m_Receiver->Refetch(); 00069 }; 00070 protected: 00071 QmitkStepperAdapter* m_Receiver; 00072 }; 00073 00074 signals: 00075 void signal_dummy(); 00076 void Refetch(); 00077 void SendStepper(mitk::Stepper *); 00078 00079 protected: 00080 mitk::Stepper::Pointer m_Stepper; 00081 long m_ObserverTag; 00082 friend class QmitkStepperAdapter::ItkEventListener; 00083 00084 ItkEventListener::Pointer m_ItkEventListener; 00085 }; 00086 00087 #endif /* QMITKSTEPPERADAPTER_H_HEADER_INCLUDED_C1E77191 */