diff --git a/Core/Code/Interactions/mitkDataInteractor.cpp b/Core/Code/Interactions/mitkDataInteractor.cpp index 57ea5f84f7..c99f9e01d8 100644 --- a/Core/Code/Interactions/mitkDataInteractor.cpp +++ b/Core/Code/Interactions/mitkDataInteractor.cpp @@ -1,93 +1,93 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDataInteractor.h" #include "mitkInteractor.h" #include "mitkPointSet.h" #include "mitkDataNode.h" #include "mitkStateMachineState.h" mitk::DataInteractor::DataInteractor() { } -const mitk::DataNode::Pointer mitk::DataInteractor::GetDataNode() +mitk::DataInteractor::NodeType mitk::DataInteractor::GetDataNode() const { return m_DataNode; } void mitk::DataInteractor::SetDataNode(DataNode::Pointer dataNode) { if (dataNode == m_DataNode) return; if (m_DataNode.IsNotNull()) { // if DataInteractors' DataNode is set to null, the "old" DataNode has to be notified (else the Dispatcher won't be notified either) m_DataNode->SetDataInteractor(NULL); } m_DataNode = dataNode; if (m_DataNode.IsNotNull()) { m_DataNode->SetDataInteractor(this); } // notify implementations ... DataNodeChanged(); } -int mitk::DataInteractor::GetLayer() +int mitk::DataInteractor::GetLayer() const { int layer = -1; if (m_DataNode.IsNotNull()) { m_DataNode->GetIntProperty("layer", layer); } return layer; } mitk::DataInteractor::~DataInteractor() { if (m_DataNode.IsNotNull()) { m_DataNode->SetInteractor(NULL); } } void mitk::DataInteractor::ConnectActionsAndFunctions() { MITK_WARN<< "ConnectActionsAndFunctions in DataInteractor not implemented.\n DataInteractor will not be able to process any events."; } mitk::ProcessEventMode mitk::DataInteractor::GetMode() { if (GetCurrentState()->GetMode() == "PREFER_INPUT") { return PREFERINPUT; } if (GetCurrentState()->GetMode() == "GRAB_INPUT") { return GRABINPUT; } return REGULAR; } void mitk::DataInteractor::DataNodeChanged() { } diff --git a/Core/Code/Interactions/mitkDataInteractor.h b/Core/Code/Interactions/mitkDataInteractor.h index 1d25c29ec4..94cd3b5d58 100644 --- a/Core/Code/Interactions/mitkDataInteractor.h +++ b/Core/Code/Interactions/mitkDataInteractor.h @@ -1,100 +1,100 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKEVENTINTERACTOR_H_ #define MITKEVENTINTERACTOR_H_ #include "itkSmartPointer.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include #include "mitkEventStateMachine.h" #include namespace mitk { /** * \class DataInteractor * * \brief Base class from with interactors that handle DataNodes are to be derived. * * Base class from with interactors that handle DataNodes are to be derived. * Provides an interface that is relevant for the interactor to work together with the dispatcher. * To implement a new interactor overwrite the ConnectActionsAndFunctions to connect the actions. */ // Public 'cause it's also used by the mitk::Dispatcher enum ProcessEventMode { REGULAR = 0, GRABINPUT = 1, PREFERINPUT = 2, CONNECTEDMOUSEACTION = 3 // only used by mitk::Dispatcher }; class DataNode; class MITK_CORE_EXPORT DataInteractor: public EventStateMachine { public: typedef itk::SmartPointer NodeType; mitkClassMacro(DataInteractor, EventStateMachine) itkNewMacro(Self) /** * Set/Change the DataNode of the DataInteractor */ void SetDataNode(NodeType); /** * @brief Returns the mode the DataInteractor currently is in. See in mitkDispatcher the description of m_ProcessingMode for further details. */ ProcessEventMode GetMode(); - const NodeType GetDataNode(); - int GetLayer(); + NodeType GetDataNode() const; + int GetLayer() const; protected: DataInteractor(); virtual ~DataInteractor(); /** * @brief Overwrite this function to connect actions from StateMachine description with functions. * * Following example shows how to connect the 'addpoint' action from the StateMachine XML description using the CONNECT_FUNCTION macro * with the AddPoint() function in the TestInteractor. * @code * void mitk::TestInteractor::ConnectActionsAndFunctions() { CONNECT_FUNCTION("addpoint", AddPoint); } * @endcode */ virtual void ConnectActionsAndFunctions(); /** \brief Is called when a DataNode is initially set or changed * To be implemented by sub-classes for initialization code which require a DataNode. * \note New DataInteractors usually are expected to have the focus, but this only works if they have the highest Layer, * since empty DataNodes have a layer of -1, the DataNode must be filled here in order to get a layer assigned. * \note Is also called when the DataNode is set to NULL. */ virtual void DataNodeChanged(); private: NodeType m_DataNode; }; } /* namespace mitk */ #endif /* MITKEVENTINTERACTOR_H_ */ diff --git a/Core/Code/Interactions/mitkDisplayPositionEvent.cpp b/Core/Code/Interactions/mitkDisplayPositionEvent.cpp index 1884421ad6..8ee766820b 100644 --- a/Core/Code/Interactions/mitkDisplayPositionEvent.cpp +++ b/Core/Code/Interactions/mitkDisplayPositionEvent.cpp @@ -1,76 +1,76 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDisplayPositionEvent.h" #include "mitkBaseRenderer.h" mitk::DisplayPositionEvent::DisplayPositionEvent( mitk::BaseRenderer *sender, int type, int button, int buttonState, int key, const mitk::Point2D& displPosition ) : Event( sender, type, button, buttonState, key ), m_DisplayPosition( displPosition ), m_WorldPositionIsSet( false ), m_PickedObjectIsSet( false ) { } -const mitk::Point3D& mitk::DisplayPositionEvent::GetWorldPosition() const +mitk::Point3D &mitk::DisplayPositionEvent::GetWorldPosition() const { // Method performs position picking and sets world position if ( m_WorldPositionIsSet ) return m_WorldPosition; assert( m_Sender != NULL ); m_Sender->PickWorldPoint( m_DisplayPosition, m_WorldPosition ); m_WorldPositionIsSet = true; return m_WorldPosition; } mitk::DataNode *mitk::DisplayPositionEvent::GetPickedObjectNode() const { // Method performs object picking and sets both object and world position if ( m_PickedObjectIsSet ) { return m_PickedObjectNode; } assert( m_Sender != NULL ); m_PickedObjectNode = m_Sender->PickObject( m_DisplayPosition, m_WorldPosition ); m_PickedObjectIsSet = true; m_WorldPositionIsSet = true; return m_PickedObjectNode; } mitk::BaseData *mitk::DisplayPositionEvent::GetPickedObject() const { mitk::DataNode *node = this->GetPickedObjectNode(); if ( node != NULL ) { return node->GetData(); } else { return NULL; } } diff --git a/Core/Code/Interactions/mitkDisplayPositionEvent.h b/Core/Code/Interactions/mitkDisplayPositionEvent.h index 78ed86abb9..f3ed4377a3 100644 --- a/Core/Code/Interactions/mitkDisplayPositionEvent.h +++ b/Core/Code/Interactions/mitkDisplayPositionEvent.h @@ -1,82 +1,82 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef DISPLAYPOSITIONEVENT_H_HEADER_INCLUDED_C184F366 #define DISPLAYPOSITIONEVENT_H_HEADER_INCLUDED_C184F366 #include #include "mitkEvent.h" #include "mitkVector.h" #include "mitkDataNode.h" namespace mitk { /** * \brief Event that stores coordinates * * Stores display position of the mouse. * * If requested, the correspondent 3D world position in mm is calculated via * picking (delegated to the BaseRenderer). Additionally, the mitk::BaseData or * mitk::DataNode corresponding to the picked object in the (3D) scene can * be retrieved. * \ingroup Interaction * \deprecatedSince{2013_03} mitk::DisplayPositionEvent is deprecated. Use mitk::InteractionPositionEvent instead. * Refer to \see DataInteractionPage for general information about the concept of the new implementation. */ class MITK_CORE_EXPORT DisplayPositionEvent : public Event { public: /** \brief Constructor with all necessary arguments. * * \param sender is the renderer that caused that event * \param type, button, buttonState, key: information from the Event * \param displPosition is the 2D Position of the mouse */ DisplayPositionEvent(BaseRenderer* sender, int type, int button, int buttonState, int key, const Point2D& displPosition); const Point2D& GetDisplayPosition() const { return m_DisplayPosition; } void SetDisplayPosition(const Point2D& displPosition) { m_DisplayPosition = displPosition; } - const Point3D& GetWorldPosition() const; + Point3D& GetWorldPosition() const; /** Returns node with object at the current position (NULL if not applicable) */ mitk::DataNode *GetPickedObjectNode() const; /** Returns object at the current position (NULL if not applicable) */ mitk::BaseData *GetPickedObject() const; protected: Point2D m_DisplayPosition; mutable Point3D m_WorldPosition; mutable bool m_WorldPositionIsSet; mutable mitk::DataNode::Pointer m_PickedObjectNode; mutable bool m_PickedObjectIsSet; }; typedef DisplayPositionEvent MouseEvent; } // namespace mitk #endif /* DISPLAYPOSITIONozsiEVENT_H_HEADER_INCLUDED_C184F366 */ diff --git a/Core/Code/Interactions/mitkEventConfig.cpp b/Core/Code/Interactions/mitkEventConfig.cpp index a72580040a..19c869a8c5 100755 --- a/Core/Code/Interactions/mitkEventConfig.cpp +++ b/Core/Code/Interactions/mitkEventConfig.cpp @@ -1,196 +1,196 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkEventConfig.h" #include #include #include #include #include #include "mitkEventFactory.h" #include "mitkInteractionEvent.h" #include "mitkInternalEvent.h" #include "mitkInteractionKeyEvent.h" #include "mitkInteractionEventConst.h" // us #include "mitkModule.h" #include "mitkModuleResource.h" #include "mitkModuleResourceStream.h" #include "mitkModuleRegistry.h" namespace mitk { vtkStandardNewMacro(EventConfig); } mitk::EventConfig::EventConfig() : m_Errors(false) { if (m_PropertyList.IsNull()) { m_PropertyList = PropertyList::New(); } } mitk::EventConfig::~EventConfig() { } void mitk::EventConfig::InsertMapping(EventMapping mapping) { for (EventListType::iterator it = m_EventList.begin(); it != m_EventList.end(); ++it) { if ((*it).interactionEvent->MatchesTemplate(mapping.interactionEvent)) { //MITK_INFO<< "Configuration overwritten:" << (*it).variantName; m_EventList.erase(it); break; } } m_EventList.push_back(mapping); } /** * @brief Loads the xml file filename and generates the necessary instances. **/ bool mitk::EventConfig::LoadConfig(std::string fileName, std::string moduleName) { mitk::Module* module = mitk::ModuleRegistry::GetModule(moduleName); mitk::ModuleResource resource = module->GetResource("Interactions/" + fileName); if (!resource.IsValid()) { mitkThrow()<< ("Resource not valid. State machine pattern not found:" + fileName); } mitk::ModuleResourceStream stream(resource); this->SetStream(&stream); return this->Parse() && !m_Errors; } void mitk::EventConfig::StartElement(const char* elementName, const char **atts) { std::string name(elementName); if (name == xmlTagConfigRoot) { // } else if (name == xmlTagParam) { std::string name = ReadXMLStringAttribut(xmlParameterName, atts); std::string value = ReadXMLStringAttribut(xmlParameterValue, atts); m_PropertyList->SetStringProperty(name.c_str(), value.c_str()); } else if (name == xmlTagEventVariant) { std::string eventClass = ReadXMLStringAttribut(xmlParameterEventClass, atts); std::string eventVariant = ReadXMLStringAttribut(xmlParameterName, atts); // New list in which all parameters are stored that are given within the tag m_EventPropertyList = PropertyList::New(); m_EventPropertyList->SetStringProperty(xmlParameterEventClass.c_str(), eventClass.c_str()); m_EventPropertyList->SetStringProperty(xmlParameterEventVariant.c_str(), eventVariant.c_str()); m_CurrEventMapping.variantName = eventVariant; } else if (name == xmlTagAttribute) { // Attributes that describe an Input Event, such as which MouseButton triggered the event,or which modifier keys are pressed std::string name = ReadXMLStringAttribut(xmlParameterName, atts); std::string value = ReadXMLStringAttribut(xmlParameterValue, atts); m_EventPropertyList->SetStringProperty(name.c_str(), value.c_str()); } } void mitk::EventConfig::EndElement(const char* elementName) { std::string name(elementName); // At end of input section, all necessary infos are collected to created an interaction event. if (name == xmlTagEventVariant) { InteractionEvent::Pointer event = EventFactory::CreateEvent(m_EventPropertyList); if (event.IsNotNull()) { m_CurrEventMapping.interactionEvent = event; InsertMapping(m_CurrEventMapping); } else { MITK_WARN<< "EventConfig: Unknown Event-Type in config. Entry skipped: " << name; } } } std::string mitk::EventConfig::ReadXMLStringAttribut(std::string name, const char** atts) { if (atts) { const char** attsIter = atts; while (*attsIter) { if (name == *attsIter) { attsIter++; return *attsIter; } attsIter += 2; } } return std::string(); } -const mitk::PropertyList::Pointer mitk::EventConfig::GetAttributes() +mitk::PropertyList::Pointer mitk::EventConfig::GetAttributes() const { return m_PropertyList; } std::string mitk::EventConfig::GetMappedEvent(InteractionEvent::Pointer interactionEvent) { // internal events are excluded from mapping if (interactionEvent->GetEventClass() == "InternalEvent") { InternalEvent* internalEvent = dynamic_cast(interactionEvent.GetPointer()); return internalEvent->GetSignalName(); } for (EventListType::iterator it = m_EventList.begin(); it != m_EventList.end(); ++it) { if ((*it).interactionEvent->MatchesTemplate(interactionEvent)) { return (*it).variantName; } } // if this part is reached, no mapping has been found, // so here we handle key events and map a key event to the string "Std" + letter/code // so "A" will be returned as "StdA" if (interactionEvent->GetEventClass() == "KeyEvent") { InteractionKeyEvent* keyEvent = dynamic_cast(interactionEvent.GetPointer()); return ("Std" + keyEvent->GetKey()); } return ""; } void mitk::EventConfig::ClearConfig() { m_EventList.clear(); } bool mitk::EventConfig::ReadXMLBooleanAttribut(std::string name, const char** atts) { std::string s = ReadXMLStringAttribut(name, atts); std::transform(s.begin(), s.end(), s.begin(), ::toupper); return s == "TRUE"; } diff --git a/Core/Code/Interactions/mitkEventConfig.h b/Core/Code/Interactions/mitkEventConfig.h index 3b9ba71bd4..2f41a6640d 100755 --- a/Core/Code/Interactions/mitkEventConfig.h +++ b/Core/Code/Interactions/mitkEventConfig.h @@ -1,144 +1,144 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkStateMachineConfig_h #define mitkStateMachineConfig_h #include #include #include "mitkCommon.h" #include #include #include namespace mitk { class InteractionEvent; class EventConfigReader: public vtkXMLParser { public: private: }; /** * \class EventConfig * \brief Configuration Object for Statemachines. * * Reads given config file, which translates specific user inputs (InteractionEvents) into EventVariants that can be processed * by the StateMachine. * Refer to \ref ConfigFileDescriptionSection . * * @ingroup Interaction **/ class EventConfig: public vtkXMLParser { public: static EventConfig *New(); vtkTypeMacro(EventConfig,vtkXMLParser) typedef itk::SmartPointer EventType; /** * @brief Loads XML resource * * Loads a XML resource file in the given module context. * The files have to be placed in the Resources/Interaction folder of their respective module. **/ bool LoadConfig(std::string fileName, std::string moduleName = "Mitk"); void ClearConfig(); /** * Returns a PropertyList that contains the properties set in the configuration file. * All properties are stored as strings. */ - const PropertyList::Pointer GetAttributes(); + PropertyList::Pointer GetAttributes() const; /** - * Checks if the config object has a definition for the given event. If it has the corresponding variant name is return, else + * Checks if the config object has a definition for the given event. If it has, the corresponding variant name is returned, else * an empty string is returned. * \note mitk::InternalEvents are handled differently. Their signal name is returned as event variant. So there is no need * to configure them in a config file. * \note mitk::InteractionKeys may have a defined event variant, if this is the case, this function returns it. If no * such definition is found key events are mapped to Std + Key , so an 'A' will be return as 'StdA' . */ std::string GetMappedEvent(EventType interactionEvent); protected: EventConfig(); virtual ~EventConfig(); /** * @brief Derived from XMLReader **/ void StartElement(const char* elementName, const char **atts); /** * @brief Derived from XMLReader **/ void EndElement(const char* elementName); private: /** * @brief Derived from XMLReader **/ std::string ReadXMLStringAttribut(std::string name, const char** atts); /** * @brief Derived from XMLReader **/ bool ReadXMLBooleanAttribut(std::string name, const char** atts); /** * @brief List of all global properties of the config object. */ PropertyList::Pointer m_PropertyList; /** * @brief Temporal list of all properties of a Event. Used to parse an Input-Event and collect all parameters between the two * and tags. */ PropertyList::Pointer m_EventPropertyList; struct EventMapping { std::string variantName; EventType interactionEvent; }; /** * Checks if mapping with the same parameters already exists, if so, it is replaced, * else the new mapping added */ void InsertMapping(EventMapping mapping); typedef std::list EventListType; EventMapping m_CurrEventMapping; /** * Stores InteractionEvents and their corresponding VariantName */ EventListType m_EventList; bool m_Errors; // use member, because of inheritance from vtkXMLParser we can't return a success value for parsing the file. }; } // namespace mitk #endif /* mitkStateMachineConfig_h */ diff --git a/Core/Code/Interactions/mitkInteractionEvent.cpp b/Core/Code/Interactions/mitkInteractionEvent.cpp index a2fba0afa5..195e0f0c76 100644 --- a/Core/Code/Interactions/mitkInteractionEvent.cpp +++ b/Core/Code/Interactions/mitkInteractionEvent.cpp @@ -1,48 +1,53 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkException.h" #include "mitkInteractionEvent.h" mitk::InteractionEvent::InteractionEvent(BaseRenderer* baseRenderer, std::string eventClass) : m_Sender(baseRenderer) , m_EventClass(eventClass) { } void mitk::InteractionEvent::SetSender(mitk::BaseRenderer* sender) { m_Sender = sender; } mitk::BaseRenderer* mitk::InteractionEvent::GetSender() { return m_Sender; } bool mitk::InteractionEvent::MatchesTemplate(InteractionEvent::Pointer) { return false; } mitk::InteractionEvent::~InteractionEvent() { } +bool mitk::InteractionEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + return (dynamic_cast(baseClass.GetPointer()) != NULL) ; +} + std::string mitk::InteractionEvent::GetEventClass() const { return m_EventClass; } diff --git a/Core/Code/Interactions/mitkInteractionEvent.h b/Core/Code/Interactions/mitkInteractionEvent.h index 61cc90c278..64ac405415 100644 --- a/Core/Code/Interactions/mitkInteractionEvent.h +++ b/Core/Code/Interactions/mitkInteractionEvent.h @@ -1,78 +1,75 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKINTERACTIONEVENT_H_ #define MITKINTERACTIONEVENT_H_ #include "itkLightObject.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include "mitkBaseRenderer.h" #include #include namespace mitk { class MITK_CORE_EXPORT InteractionEvent: public itk::LightObject { public: mitkClassMacro(InteractionEvent,itk::LightObject) mitkNewMacro2Param(Self,BaseRenderer*, std::string) void SetSender(BaseRenderer* sender); BaseRenderer* GetSender(); /** * Implementation of equality for each event class. * Equality does \b not mean an exact copy or pointer equality. * * A match is determined by agreement in all attributes that are necessary to describe * the event for a state machine transition. * E.g. for a mouse event press event, it is important which modifiers are used, * which mouse button was used to triggered the event, but the mouse position is irrelevant. */ virtual bool MatchesTemplate(InteractionEvent::Pointer); /** * Return unique string identifier that gives the event class of this object, as it can be used in a state machine pattern. * --- itk */ std::string GetEventClass() const; + /** * This class implements an up cast to check if the provided baseClass object is derived from this class. * This function is used to support polymorphism on state machine pattern (XML) level. */ - template - bool IsSubClassOf(T *baseClass) - { - return dynamic_cast(baseClass) != NULL; - } + virtual bool IsSuperClassOf(InteractionEvent::Pointer baseClass); protected: InteractionEvent(BaseRenderer*, std::string); virtual ~InteractionEvent(); private: BaseRenderer* m_Sender; std::string m_EventClass; }; } /* namespace mitk */ #endif /* MITKINTERACTIONEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkInteractionKeyEvent.cpp b/Core/Code/Interactions/mitkInteractionKeyEvent.cpp index 029221248f..feb979df3f 100644 --- a/Core/Code/Interactions/mitkInteractionKeyEvent.cpp +++ b/Core/Code/Interactions/mitkInteractionKeyEvent.cpp @@ -1,47 +1,52 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkInteractionKeyEvent.h" mitk::InteractionKeyEvent::InteractionKeyEvent(mitk::BaseRenderer* baseRenderer, const std::string key, mitk::ModifierKeys modifiers = ControlKey) : InteractionEvent(baseRenderer, "KeyEvent"), m_Key(key), m_Modifiers(modifiers) { } mitk::ModifierKeys mitk::InteractionKeyEvent::GetModifiers() const { return m_Modifiers; } std::string mitk::InteractionKeyEvent::GetKey() const { return m_Key; } mitk::InteractionKeyEvent::~InteractionKeyEvent() { } bool mitk::InteractionKeyEvent::MatchesTemplate(mitk::InteractionEvent::Pointer interactionEvent) { mitk::InteractionKeyEvent* keyEvent = dynamic_cast(interactionEvent.GetPointer()); if (keyEvent == NULL) { return false; } return (this->GetModifiers() == keyEvent->GetModifiers() && this->GetKey() == keyEvent->GetKey()); } + +bool mitk::InteractionKeyEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + return (dynamic_cast(baseClass.GetPointer()) != NULL) ; +} diff --git a/Core/Code/Interactions/mitkInteractionKeyEvent.h b/Core/Code/Interactions/mitkInteractionKeyEvent.h index 92db999d19..7dea3c994c 100644 --- a/Core/Code/Interactions/mitkInteractionKeyEvent.h +++ b/Core/Code/Interactions/mitkInteractionKeyEvent.h @@ -1,64 +1,65 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKINTERACTIONKEYEVENT_H_ #define MITKINTERACTIONKEYEVENT_H_ #include "itkObject.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include "mitkInteractionEventConst.h" #include "mitkInteractionPositionEvent.h" #include "mitkBaseRenderer.h" #include "mitkInteractionEvent.h" #include #include /* * Note: A Click with the MiddleButton is to be handled with MousePressEvents */ namespace mitk { /** * \class InteractionKeyEvent * \brief Handles key events. * \input std::string for pressed key or special key description , mitk::ModifierKeys for modifiers * \ingroup Interaction. */ class MITK_CORE_EXPORT InteractionKeyEvent : public InteractionEvent { public: mitkClassMacro(InteractionKeyEvent,InteractionEvent) mitkNewMacro3Param(Self, BaseRenderer*, const std::string , ModifierKeys) virtual bool MatchesTemplate(InteractionEvent::Pointer); + bool IsSuperClassOf(InteractionEvent::Pointer baseClass); ModifierKeys GetModifiers() const; std::string GetKey() const; protected: InteractionKeyEvent(BaseRenderer*, const std::string key, ModifierKeys modifiers); virtual ~InteractionKeyEvent(); private: std::string m_Key; ModifierKeys m_Modifiers; }; } /* namespace mitk */ #endif /* MITKINTERACTIONKEYEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkInteractionPositionEvent.cpp b/Core/Code/Interactions/mitkInteractionPositionEvent.cpp index f3fd1391a5..155f6c80a0 100644 --- a/Core/Code/Interactions/mitkInteractionPositionEvent.cpp +++ b/Core/Code/Interactions/mitkInteractionPositionEvent.cpp @@ -1,53 +1,58 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkInteractionPositionEvent.h" #include mitk::InteractionPositionEvent::InteractionPositionEvent(mitk::BaseRenderer* baseRenderer, const mitk::Point2D mousePosition, const std::string eventClass) : InteractionEvent(baseRenderer, eventClass) , m_PointerPosition(mousePosition) { if (GetSender() != NULL) { m_WorldPosition = GetSender()->Map2DRendererPositionTo3DWorldPosition(&m_PointerPosition); } else { m_WorldPosition.Fill(0); } } const mitk::Point2D mitk::InteractionPositionEvent::GetPointerPositionOnScreen() { return m_PointerPosition; } const mitk::Point3D mitk::InteractionPositionEvent::GetPositionInWorld() { return m_WorldPosition; } bool mitk::InteractionPositionEvent::MatchesTemplate(InteractionEvent::Pointer) { return true; } mitk::InteractionPositionEvent::~InteractionPositionEvent() { } + +bool mitk::InteractionPositionEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + return (dynamic_cast(baseClass.GetPointer()) != NULL) ; +} diff --git a/Core/Code/Interactions/mitkInteractionPositionEvent.h b/Core/Code/Interactions/mitkInteractionPositionEvent.h index 3711f36719..5f7960cd9a 100644 --- a/Core/Code/Interactions/mitkInteractionPositionEvent.h +++ b/Core/Code/Interactions/mitkInteractionPositionEvent.h @@ -1,63 +1,65 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKINTERACTIONPOSITIONEVENT_H_ #define MITKINTERACTIONPOSITIONEVENT_H_ #include "itkObject.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include "mitkInteractionEvent.h" #include "mitkInteractionEventConst.h" #include #include namespace mitk { /** * \class InteractionPositionEvent * * \brief Super class for all position events. * * This class is instantiated with a BaseRenderer and the 2D pointer position relative to the renderer, * the object then queries the Renderer for 3D world coordinates and supplies them to deriving classes. * */ class MITK_CORE_EXPORT InteractionPositionEvent : public InteractionEvent { public: mitkClassMacro(InteractionPositionEvent,InteractionEvent); mitkNewMacro3Param(Self, BaseRenderer*, const Point2D , const std::string); const Point2D GetPointerPositionOnScreen(); const Point3D GetPositionInWorld(); + virtual bool MatchesTemplate(InteractionEvent::Pointer); + virtual bool IsSuperClassOf(InteractionEvent::Pointer baseClass); + protected: InteractionPositionEvent(BaseRenderer* baseRenderer, const Point2D mousePosition, const std::string eventClass); - virtual bool MatchesTemplate(InteractionEvent::Pointer); virtual ~InteractionPositionEvent(); private: Point2D m_PointerPosition; Point3D m_WorldPosition; }; } /* namespace mitk */ #endif /* MITKINTERACTIONPOSITIONEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkInternalEvent.cpp b/Core/Code/Interactions/mitkInternalEvent.cpp index 1c3b814d1f..15622e6bc1 100644 --- a/Core/Code/Interactions/mitkInternalEvent.cpp +++ b/Core/Code/Interactions/mitkInternalEvent.cpp @@ -1,50 +1,55 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkInternalEvent.h" #include "mitkDataInteractor.h" mitk::InternalEvent::InternalEvent(mitk::BaseRenderer* baseRenderer, DataInteractor* sourceInteractor, const std::string signalName) : InteractionEvent(baseRenderer, "InternalEvent") , m_DataInteractor(sourceInteractor) , m_SignalName(signalName) { } bool mitk::InternalEvent::MatchesTemplate(mitk::InteractionEvent::Pointer interactionEvent) { mitk::InternalEvent* internalEvent = dynamic_cast(interactionEvent.GetPointer()); if (internalEvent == NULL) { return false; } return (m_SignalName == internalEvent->GetSignalName()); } mitk::InternalEvent::~InternalEvent() { } const std::string mitk::InternalEvent::GetSignalName() { return m_SignalName; } mitk::DataInteractor* mitk::InternalEvent::GetTargetInteractor() { return m_DataInteractor.GetPointer(); } + +bool mitk::InternalEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + return (NULL != dynamic_cast(baseClass.GetPointer()) ); +} diff --git a/Core/Code/Interactions/mitkInternalEvent.h b/Core/Code/Interactions/mitkInternalEvent.h index 3d7fee09df..4d511084e2 100644 --- a/Core/Code/Interactions/mitkInternalEvent.h +++ b/Core/Code/Interactions/mitkInternalEvent.h @@ -1,62 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkInternalEvent_h #define mitkInternalEvent_h #include "itkObject.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include "mitkInteractionEventConst.h" #include "mitkInteractionEvent.h" #include "mitkBaseRenderer.h" #include #include namespace mitk { /** *\brief Class to create events from within the application to signal about internal events. * * These events can target a specific DataInteractor, if this DataInteractor is specified in the constructor; * else this parameter is set to NULL and the event is treated as a regular event. */ class DataInteracor; class MITK_CORE_EXPORT InternalEvent: public InteractionEvent { public: mitkClassMacro(InternalEvent,InteractionEvent); mitkNewMacro3Param(Self, BaseRenderer*, DataInteractor*, const std::string); const std::string GetSignalName(); DataInteractor* GetTargetInteractor(); virtual bool MatchesTemplate(InteractionEvent::Pointer); + virtual bool IsSuperClassOf(InteractionEvent::Pointer baseClass); protected: InternalEvent(BaseRenderer*, DataInteractor* destInteractor, const std::string signalName); virtual ~InternalEvent(); private: DataInteractor::Pointer m_DataInteractor; std::string m_SignalName; }; } #endif /* mitkInternalEvent_h */ diff --git a/Core/Code/Interactions/mitkMouseMoveEvent.cpp b/Core/Code/Interactions/mitkMouseMoveEvent.cpp index 8a31142ef0..31492997e0 100644 --- a/Core/Code/Interactions/mitkMouseMoveEvent.cpp +++ b/Core/Code/Interactions/mitkMouseMoveEvent.cpp @@ -1,59 +1,64 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkException.h" #include "mitkMouseMoveEvent.h" mitk::MouseMoveEvent::MouseMoveEvent(mitk::BaseRenderer* baseRenderer, mitk::Point2D mousePosition , mitk::MouseButtons buttonStates, mitk::ModifierKeys modifiers) : InteractionPositionEvent(baseRenderer, mousePosition, "MouseMoveEvent") , m_ButtonStates(buttonStates) , m_Modifiers(modifiers) { } mitk::ModifierKeys mitk::MouseMoveEvent::GetModifiers() const { return m_Modifiers; } mitk::MouseButtons mitk::MouseMoveEvent::GetButtonStates() const { return m_ButtonStates; } void mitk::MouseMoveEvent::SetModifiers(ModifierKeys modifiers) { m_Modifiers = modifiers; } void mitk::MouseMoveEvent::SetButtonStates(MouseButtons buttons) { m_ButtonStates = buttons; } mitk::MouseMoveEvent::~MouseMoveEvent() { } bool mitk::MouseMoveEvent::MatchesTemplate(mitk::InteractionEvent::Pointer interactionEvent) { mitk::MouseMoveEvent* mpe = dynamic_cast(interactionEvent.GetPointer()); if (mpe == NULL) { return false; } return (this->GetModifiers() == mpe->GetModifiers() && this->GetButtonStates() == mpe->GetButtonStates()); } + +bool mitk::MouseMoveEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + return (dynamic_cast(baseClass.GetPointer()) != NULL) ; +} diff --git a/Core/Code/Interactions/mitkMouseMoveEvent.h b/Core/Code/Interactions/mitkMouseMoveEvent.h index 03c732339f..dc7dd8a5cf 100644 --- a/Core/Code/Interactions/mitkMouseMoveEvent.h +++ b/Core/Code/Interactions/mitkMouseMoveEvent.h @@ -1,56 +1,57 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKMOUSEMOVEEVENT_H_ #define MITKMOUSEMOVEEVENT_H_ #include "itkObject.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include "mitkInteractionEventConst.h" #include "mitkInteractionPositionEvent.h" #include "mitkBaseRenderer.h" #include "mitkInteractionEvent.h" #include namespace mitk { class MITK_CORE_EXPORT MouseMoveEvent : public InteractionPositionEvent { public: mitkClassMacro(MouseMoveEvent,InteractionPositionEvent); mitkNewMacro4Param(Self, BaseRenderer*, Point2D , MouseButtons , ModifierKeys); ModifierKeys GetModifiers() const; MouseButtons GetButtonStates() const; void SetModifiers(ModifierKeys modifiers); void SetButtonStates(MouseButtons buttons); virtual bool MatchesTemplate(InteractionEvent::Pointer); + virtual bool IsSuperClassOf(InteractionEvent::Pointer baseClass); protected: MouseMoveEvent(BaseRenderer*, Point2D = Point2D(), MouseButtons buttonStates = NoButton, mitk::ModifierKeys modifiers = NoKey); virtual ~MouseMoveEvent(); private: MouseButtons m_ButtonStates; ModifierKeys m_Modifiers; }; } /* namespace mitk */ #endif /* MITKMOUSEMOVEEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkMousePressEvent.cpp b/Core/Code/Interactions/mitkMousePressEvent.cpp index 917cade44e..6026811db7 100644 --- a/Core/Code/Interactions/mitkMousePressEvent.cpp +++ b/Core/Code/Interactions/mitkMousePressEvent.cpp @@ -1,75 +1,80 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkException.h" #include "mitkMousePressEvent.h" mitk::MousePressEvent::MousePressEvent(mitk::BaseRenderer* baseRenderer, const mitk::Point2D mousePosition, mitk::MouseButtons buttonStates, mitk::ModifierKeys modifiers, mitk::MouseButtons eventButton) : InteractionPositionEvent(baseRenderer, mousePosition, "MousePressEvent") , m_EventButton(eventButton) , m_ButtonStates(buttonStates) , m_Modifiers( modifiers) { } mitk::MouseButtons mitk::MousePressEvent::GetEventButton() const { return m_EventButton; } void mitk::MousePressEvent::SetEventButton(MouseButtons buttons) { m_EventButton = buttons; } mitk::ModifierKeys mitk::MousePressEvent::GetModifiers() const { return m_Modifiers; } mitk::MouseButtons mitk::MousePressEvent::GetButtonStates() const { return m_ButtonStates; } void mitk::MousePressEvent::SetModifiers(ModifierKeys modifiers) { m_Modifiers = modifiers; } void mitk::MousePressEvent::SetButtonStates(MouseButtons buttons) { m_ButtonStates = buttons; } mitk::MousePressEvent::~MousePressEvent() { } bool mitk::MousePressEvent::MatchesTemplate(mitk::InteractionEvent::Pointer interactionEvent) { mitk::MousePressEvent* mpe = dynamic_cast(interactionEvent.GetPointer()); if (mpe == NULL) { return false; } return (this->GetEventButton() == mpe->GetEventButton() && this->GetModifiers() == mpe->GetModifiers() && this->GetButtonStates() == mpe->GetButtonStates()); } + +bool mitk::MousePressEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + return (dynamic_cast(baseClass.GetPointer()) != NULL) ; +} diff --git a/Core/Code/Interactions/mitkMousePressEvent.h b/Core/Code/Interactions/mitkMousePressEvent.h index d9afb34fc0..f15f3f15b4 100644 --- a/Core/Code/Interactions/mitkMousePressEvent.h +++ b/Core/Code/Interactions/mitkMousePressEvent.h @@ -1,60 +1,62 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKMOUSEPRESSEVENT_H_ #define MITKMOUSEPRESSEVENT_H_ #include "itkObject.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include "mitkInteractionEventConst.h" #include "mitkInteractionPositionEvent.h" #include "mitkBaseRenderer.h" #include "mitkInteractionEvent.h" #include namespace mitk { class MITK_CORE_EXPORT MousePressEvent: public InteractionPositionEvent { public: mitkClassMacro(MousePressEvent,InteractionPositionEvent) mitkNewMacro5Param(Self, BaseRenderer*, const Point2D , MouseButtons , ModifierKeys, MouseButtons) ModifierKeys GetModifiers() const; MouseButtons GetButtonStates() const; void SetModifiers(ModifierKeys modifiers); void SetButtonStates(MouseButtons buttons); MouseButtons GetEventButton() const; void SetEventButton(MouseButtons buttons); + virtual bool MatchesTemplate(InteractionEvent::Pointer); + virtual bool IsSuperClassOf(InteractionEvent::Pointer baseClass); protected: MousePressEvent(BaseRenderer*, const Point2D = Point2D(), mitk::MouseButtons buttonStates = NoButton, mitk::ModifierKeys modifiers = NoKey, mitk::MouseButtons eventButton = NoButton); virtual ~MousePressEvent(); private: MouseButtons m_EventButton; MouseButtons m_ButtonStates; ModifierKeys m_Modifiers; }; } /* namespace mitk */ #endif /* MITKMOUSEPRESSEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkMouseReleaseEvent.cpp b/Core/Code/Interactions/mitkMouseReleaseEvent.cpp index 3703868d19..4433732ed4 100644 --- a/Core/Code/Interactions/mitkMouseReleaseEvent.cpp +++ b/Core/Code/Interactions/mitkMouseReleaseEvent.cpp @@ -1,78 +1,83 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkException.h" #include "mitkMouseReleaseEvent.h" mitk::MouseReleaseEvent::MouseReleaseEvent(mitk::BaseRenderer* baseRenderer = NULL, mitk::Point2D mousePosition, mitk::MouseButtons buttonStates, mitk::ModifierKeys modifiers, mitk::MouseButtons eventButton) : InteractionPositionEvent(baseRenderer, mousePosition, "MouseReleaseEvent") , m_EventButton(eventButton) ,m_ButtonStates(buttonStates) , m_Modifiers(modifiers) { } mitk::MouseButtons mitk::MouseReleaseEvent::GetEventButton() const { return m_EventButton; } void mitk::MouseReleaseEvent::SetEventButton(MouseButtons buttons) { m_EventButton = buttons; } mitk::ModifierKeys mitk::MouseReleaseEvent::GetModifiers() const { return m_Modifiers; } mitk::MouseButtons mitk::MouseReleaseEvent::GetButtonStates() const { return m_ButtonStates; } void mitk::MouseReleaseEvent::SetModifiers(ModifierKeys modifiers) { m_Modifiers = modifiers; } void mitk::MouseReleaseEvent::SetButtonStates(MouseButtons buttons) { m_ButtonStates = buttons; } mitk::MouseReleaseEvent::~MouseReleaseEvent() { } bool mitk::MouseReleaseEvent::MatchesTemplate(mitk::InteractionEvent::Pointer interactionEvent) { mitk::MouseReleaseEvent* mre = dynamic_cast(interactionEvent.GetPointer()); if (mre == NULL) { return false; } return (this->GetEventButton() == mre->GetEventButton() && this->GetModifiers() == mre->GetModifiers() && this->GetButtonStates() == mre->GetButtonStates() ); } + +bool mitk::MouseReleaseEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + return (dynamic_cast(baseClass.GetPointer()) != NULL) ; +} diff --git a/Core/Code/Interactions/mitkMouseReleaseEvent.h b/Core/Code/Interactions/mitkMouseReleaseEvent.h index eec482e1b4..966c4d70da 100644 --- a/Core/Code/Interactions/mitkMouseReleaseEvent.h +++ b/Core/Code/Interactions/mitkMouseReleaseEvent.h @@ -1,63 +1,65 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKMOUSERELEASEEVENT_H_ #define MITKMOUSERELEASEEVENT_H_ #include "itkObject.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include "mitkInteractionPositionEvent.h" #include "mitkInteractionEventConst.h" #include "mitkBaseRenderer.h" #include "mitkInteractionEvent.h" #include namespace mitk { class MITK_CORE_EXPORT MouseReleaseEvent: public InteractionPositionEvent { public: mitkClassMacro(MouseReleaseEvent,InteractionPositionEvent) mitkNewMacro5Param(Self, BaseRenderer*, const Point2D ,MouseButtons , ModifierKeys, MouseButtons) ModifierKeys GetModifiers() const; MouseButtons GetButtonStates() const; void SetModifiers(ModifierKeys modifiers); void SetButtonStates(MouseButtons buttons); MouseButtons GetEventButton() const; void SetEventButton(MouseButtons buttons); + virtual bool MatchesTemplate(InteractionEvent::Pointer); + virtual bool IsSuperClassOf(InteractionEvent::Pointer baseClass); protected: MouseReleaseEvent(BaseRenderer*, mitk::Point2D mousePosition = Point2D(), mitk::MouseButtons buttonStates = NoButton, mitk::ModifierKeys modifiers = NoKey, mitk::MouseButtons eventButton = NoButton); virtual ~MouseReleaseEvent(); private: MouseButtons m_EventButton; MouseButtons m_ButtonStates; ModifierKeys m_Modifiers; }; } /* namespace mitk */ #endif /* MITKMOUSERELEASEEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkMouseWheelEvent.cpp b/Core/Code/Interactions/mitkMouseWheelEvent.cpp index b97968007a..d81b1800e3 100644 --- a/Core/Code/Interactions/mitkMouseWheelEvent.cpp +++ b/Core/Code/Interactions/mitkMouseWheelEvent.cpp @@ -1,74 +1,79 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkMouseWheelEvent.h" mitk::MouseWheelEvent::MouseWheelEvent(BaseRenderer* baseRenderer, Point2D mousePosition, MouseButtons buttonStates, ModifierKeys modifiers, int wheelDelta) : InteractionPositionEvent(baseRenderer, mousePosition, "MouseWheelEvent") , m_WheelDelta(wheelDelta) , m_ButtonStates(buttonStates) , m_Modifiers(modifiers) { } int mitk::MouseWheelEvent::GetWheelDelta() const { return m_WheelDelta; } void mitk::MouseWheelEvent::SetWheelDelta(int delta) { m_WheelDelta = delta; } mitk::ModifierKeys mitk::MouseWheelEvent::GetModifiers() const { return m_Modifiers; } mitk::MouseButtons mitk::MouseWheelEvent::GetButtonStates() const { return m_ButtonStates; } void mitk::MouseWheelEvent::SetModifiers(ModifierKeys modifiers) { m_Modifiers = modifiers; } void mitk::MouseWheelEvent::SetButtonStates(MouseButtons buttons) { m_ButtonStates = buttons; } mitk::MouseWheelEvent::~MouseWheelEvent() { } bool mitk::MouseWheelEvent::MatchesTemplate(mitk::InteractionEvent::Pointer interactionEvent) { const mitk::MouseWheelEvent* mwe = dynamic_cast(interactionEvent.GetPointer()); if (mwe == NULL) { return false; } return ((this->GetWheelDelta() * mwe->GetWheelDelta() > 0) // Consider WheelEvents to be equal if the scrolling is done in the same direction. && this->GetModifiers() == mwe->GetModifiers() && this->GetButtonStates() == mwe->GetButtonStates()); } + +bool mitk::MouseWheelEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + return (dynamic_cast(baseClass.GetPointer()) != NULL) ; +} diff --git a/Core/Code/Interactions/mitkMouseWheelEvent.h b/Core/Code/Interactions/mitkMouseWheelEvent.h index b95a480818..deac97bb56 100644 --- a/Core/Code/Interactions/mitkMouseWheelEvent.h +++ b/Core/Code/Interactions/mitkMouseWheelEvent.h @@ -1,67 +1,68 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKMOUSEWHEELEVENT_H_ #define MITKMOUSEWHEELEVENT_H_ #include "itkObject.h" #include "itkObjectFactory.h" #include "mitkCommon.h" #include "mitkInteractionEventConst.h" #include "mitkInteractionPositionEvent.h" #include "mitkBaseRenderer.h" #include "mitkInteractionEvent.h" #include /** * Note: A Click with the MiddleButton is to be handled with MousePressEvents */ namespace mitk { class MITK_CORE_EXPORT MouseWheelEvent: public InteractionPositionEvent { public: mitkClassMacro(MouseWheelEvent,InteractionPositionEvent) mitkNewMacro5Param(Self, BaseRenderer*, const Point2D , MouseButtons , ModifierKeys, int) ModifierKeys GetModifiers() const; MouseButtons GetButtonStates() const; void SetModifiers(ModifierKeys modifiers); void SetButtonStates(MouseButtons buttons); int GetWheelDelta() const; void SetWheelDelta(int delta); virtual bool MatchesTemplate(InteractionEvent::Pointer); + virtual bool IsSuperClassOf(InteractionEvent::Pointer baseClass); protected: MouseWheelEvent(BaseRenderer* = NULL, const Point2D mousePosition = Point2D(), MouseButtons buttonStates = NoButton, ModifierKeys modifiers = NoKey, int wheelDelta = 0); virtual ~MouseWheelEvent(); private: int m_WheelDelta; MouseButtons m_ButtonStates; ModifierKeys m_Modifiers; }; } /* namespace mitk */ #endif /* MITKMOUSEPRESSEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkStateMachineState.cpp b/Core/Code/Interactions/mitkStateMachineState.cpp index f501131398..155b41cb57 100755 --- a/Core/Code/Interactions/mitkStateMachineState.cpp +++ b/Core/Code/Interactions/mitkStateMachineState.cpp @@ -1,86 +1,86 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkStateMachineState.h" mitk::StateMachineState::StateMachineState(std::string stateName, std::string stateMode) : m_Name(stateName), m_StateMode(stateMode) { } -std::string mitk::StateMachineState::GetMode() +std::string mitk::StateMachineState::GetMode() const { return m_StateMode; } mitk::StateMachineState::~StateMachineState() { m_Transitions.clear(); } bool mitk::StateMachineState::AddTransition(StateMachineTransition::Pointer transition) { for (TransitionVector::iterator it = m_Transitions.begin(); it != m_Transitions.end(); ++it) { if (transition.GetPointer() == (*it).GetPointer()) return false; } m_Transitions.push_back(transition); return true; } -mitk::StateMachineTransition::Pointer mitk::StateMachineState::GetTransition(std::string eventClass, std::string eventVariant) +mitk::StateMachineTransition::Pointer mitk::StateMachineState::GetTransition(const std::string eventClass, const std::string eventVariant) { mitk::StateMachineTransition::Pointer t = mitk::StateMachineTransition::New("", eventClass, eventVariant); for (TransitionVector::iterator it = m_Transitions.begin(); it != m_Transitions.end(); ++it) { if (**it == *t) // do not switch it and t, order matters, see mitk::StateMachineTransition == operator return *it; } return NULL; } -std::string mitk::StateMachineState::GetName() +std::string mitk::StateMachineState::GetName() const { return m_Name; } //##Documentation //## Post-processing step, when builing StateMachine from XML. //## Parse all transitions and find the State that matches the String-Name. bool mitk::StateMachineState::ConnectTransitions(StateMap *allStates) { for (TransitionVector::iterator transIt = m_Transitions.begin(); transIt != m_Transitions.end(); ++transIt) { bool found = false; for (StateMap::iterator stateIt = allStates->begin(); stateIt != allStates->end(); ++stateIt) { if ((*stateIt)->GetName() == (*transIt)->GetNextStateName()) { (*transIt)->SetNextState(*stateIt); found = true; break; } } if (!found) { MITK_WARN<< "Target State not found in StateMachine."; return false; // only reached if no state matching the string is found } } return true; } diff --git a/Core/Code/Interactions/mitkStateMachineState.h b/Core/Code/Interactions/mitkStateMachineState.h index 5d32ffdc95..b83c100ec1 100755 --- a/Core/Code/Interactions/mitkStateMachineState.h +++ b/Core/Code/Interactions/mitkStateMachineState.h @@ -1,90 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef SMSTATE_H_HEADER_INCLUDED_C19A8A5D #define SMSTATE_H_HEADER_INCLUDED_C19A8A5D #include #include #include #include #include #include "mitkStateMachineTransition.h" namespace mitk { /** * \class StateMachineState * Represents a state of a state machine pattern. * It holds transitions to other states (mitk::StateMachineTransition) and the mode of the current state, see * m_StateMode . */ class MITK_CORE_EXPORT StateMachineState : public itk::Object { public: mitkClassMacro(StateMachineState, itk::Object); mitkNewMacro2Param(Self, std::string, std::string); typedef std::vector StateMap; typedef std::vector TransitionVector; bool AddTransition( StateMachineTransition::Pointer transition ); /** * @brief Return Transition which matches given event description. **/ - StateMachineTransition::Pointer GetTransition(std::string eventClass, std::string eventVariant); + StateMachineTransition::Pointer GetTransition(const std::string eventClass,const std::string eventVariant); /** * @brief Returns the name. **/ - std::string GetName(); + std::string GetName() const; - std::string GetMode(); + std::string GetMode() const; /** * @brief Searches dedicated States of all Transitions and sets *nextState of these Transitions. * Required for this is a List of all build States of that StateMachine (allStates). This way the StateMachine can be build up. **/ bool ConnectTransitions(StateMap* allStates); protected: StateMachineState(std::string name, std::string stateMode); ~StateMachineState(); private: /** * @brief Name of this State. **/ std::string m_Name; /** * State Modus, which determines the behavior of the dispatcher. A State can be in three different modes: * REGULAR - standard dispatcher behavior * GRAB_INPUT - all events are given to the statemachine in this modus, if they are not processed by this statemachine the events are dropped. * PREFER_INPUT - events are first given to this statemachine, and if not processed, offered to the other statemachines. */ std::string m_StateMode; /** * @brief map of transitions that lead from this state to the next state **/ TransitionVector m_Transitions; }; } // namespace mitk #endif /* SMSTATE_H_HEADER_INCLUDED_C19A8A5D */ diff --git a/Core/Code/Interactions/mitkStateMachineTransition.cpp b/Core/Code/Interactions/mitkStateMachineTransition.cpp index e8e73cf893..fcce659d99 100755 --- a/Core/Code/Interactions/mitkStateMachineTransition.cpp +++ b/Core/Code/Interactions/mitkStateMachineTransition.cpp @@ -1,96 +1,96 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkStateMachineTransition.h" #include "mitkStateMachineAction.h" #include "mitkStateMachineState.h" #include "mitkEventFactory.h" #include "mitkInteractionEventConst.h" mitk::StateMachineTransition::StateMachineTransition(std::string nextStateName, std::string eventClass, std::string eventVariant) : m_EventClass(eventClass), m_EventVariant(eventVariant), m_NextStateName(nextStateName) { PropertyList::Pointer propertyList = PropertyList::New(); propertyList->SetStringProperty(xmlParameterEventClass.c_str(), eventClass.c_str()); m_TransitionEvent = EventFactory::CreateEvent(propertyList); } -bool mitk::StateMachineTransition::operator ==(const StateMachineTransition& transition) +bool mitk::StateMachineTransition::operator ==(const StateMachineTransition& transition) const { // Create event based on incoming event type, // then try to cast it to the type of event that this transition holds, // if this is possible, the variant is checked // check for NULL since a corrupted state machine might cause an empty event if (m_TransitionEvent.IsNull()) { return false; } PropertyList::Pointer propertyList = PropertyList::New(); propertyList->SetStringProperty(xmlParameterEventClass.c_str(), transition.m_EventClass.c_str()); InteractionEvent::Pointer tmpEvent = EventFactory::CreateEvent(propertyList); if (tmpEvent.IsNull()) { return false; } - if (tmpEvent->IsSubClassOf(m_TransitionEvent.GetPointer())) + if (m_TransitionEvent->IsSuperClassOf(tmpEvent.GetPointer())) { return (this->m_EventVariant == transition.m_EventVariant); } else { // if event variants match, but super class condition is violated // this means that the configuration file, implements a class that does not // support the type in the state machine. if (this->m_EventVariant == transition.m_EventVariant) { MITK_WARN<< "Event type in Statemachine " << m_EventClass << " is not compatible to configuration class " << transition.m_EventClass; } return false; } } mitk::StateMachineTransition::~StateMachineTransition() { //needed for correct reference counting of mitkState//, for real??? m_NextState = NULL; m_Actions.clear(); } void mitk::StateMachineTransition::AddAction(StateMachineAction::Pointer action) { m_Actions.push_back(action); } -mitk::StateMachineState::Pointer mitk::StateMachineTransition::GetNextState() +mitk::StateMachineState::Pointer mitk::StateMachineTransition::GetNextState() const { return m_NextState; } std::string mitk::StateMachineTransition::GetNextStateName() const { return m_NextStateName; } std::vector mitk::StateMachineTransition::GetActions() const { return m_Actions; } void mitk::StateMachineTransition::SetNextState(SpStateMachineState nextState) { m_NextState = nextState; } diff --git a/Core/Code/Interactions/mitkStateMachineTransition.h b/Core/Code/Interactions/mitkStateMachineTransition.h index a533ef0532..fdc94e2802 100755 --- a/Core/Code/Interactions/mitkStateMachineTransition.h +++ b/Core/Code/Interactions/mitkStateMachineTransition.h @@ -1,94 +1,94 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef SMTRANSITION_H_HEADER_INCLUDED #define SMTRANSITION_H_HEADER_INCLUDED #include #include "mitkCommon.h" #include #include #include #include "mitkStateMachineAction.h" #include "mitkInteractionEvent.h" namespace mitk { class StateMachineState; typedef std::vector ActionVectorType; typedef itk::SmartPointer SpStateMachineState; /** * \class StateMachineTransition * @brief Connects two states, and holds references to actions that are executed on transition. * * @ingroup Interaction **/ class MITK_CORE_EXPORT StateMachineTransition: public itk::Object { public: mitkClassMacro(StateMachineTransition, itk::Object); mitkNewMacro3Param(Self, std::string,std::string,std::string); void AddAction(StateMachineAction::Pointer action); - SpStateMachineState GetNextState(); + SpStateMachineState GetNextState() const; std::string GetNextStateName() const; /** * Check for equality. Equality is given if event variant is the same and * classes are the same or the first argument is a superclass of the second. * \warn Here the order of arguments matters. ! */ - bool operator==(const StateMachineTransition& transition); + bool operator==(const StateMachineTransition& transition) const; /** * @brief Get an iterator on the first action in list. **/ ActionVectorType GetActions() const; /** * @brief Set the next state of this object. **/ void SetNextState(SpStateMachineState nextState); protected: StateMachineTransition(std::string nextStateName, std::string eventClass, std::string eventVariant); virtual ~StateMachineTransition(); // Triggering Event std::string m_EventClass; std::string m_EventVariant; private: SpStateMachineState m_NextState; std::string m_NextStateName; InteractionEvent::Pointer m_TransitionEvent; /** * @brief The list of actions, that are executed if this transition is done. **/ std::vector m_Actions; }; } // namespace mitk #endif /* SMTRANSITION_H_HEADER_INCLUDED */ diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index c0bef6908f..b2539a95ed 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,128 +1,128 @@ # tests with no extra command line parameter set(MODULE_TESTS mitkAccessByItkTest.cpp mitkCoreObjectFactoryTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkDispatcherTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp - #mitkEventConfigTest.cpp ## needs to be re-written, test indirect since EventConfig is no longer exported as interface + #mitkEventConfigTest.cpp ## needs to be re-written, test indirect since EventConfig is no longer exported as interface Bug 14529 mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry3DTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageDataItemTest.cpp #mitkImageMapper2DTest.cpp mitkImageGeneratorTest.cpp mitkBaseDataTest.cpp #mitkImageToItkTest.cpp mitkInstantiateAccessFunctionTest.cpp mitkInteractorTest.cpp mitkInteractionEventTest.cpp mitkITKThreadingTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp #mitkPipelineSmartPointerCorrectnessTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp mitkPointSetFileIOTest.cpp mitkPointSetTest.cpp mitkPointSetWriterTest.cpp mitkPointSetReaderTest.cpp mitkPointSetInteractorTest.cpp mitkPropertyTest.cpp mitkPropertyListTest.cpp #mitkRegistrationBaseTest.cpp #mitkSegmentationInterpolationTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp - mitkStateMachineContainerTest.cpp + ##mitkStateMachineContainerTest.cpp ## rewrite test, indirect since no longer exported Bug 14529 mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeSlicedGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp #mitkAbstractTransformGeometryTest.cpp mitkStepperTest.cpp itkTotalVariationDenoisingImageFilterTest.cpp mitkRenderingManagerTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp mitkVectorTest.cpp mitkClippedSurfaceBoundsCalculatorTest.cpp #QmitkRenderingTestHelper.cpp mitkExceptionTest.cpp mitkExtractSliceFilterTest.cpp mitkLogTest.cpp mitkImageDimensionConverterTest.cpp mitkLoggingAdapterTest.cpp mitkUIDGeneratorTest.cpp ) # test with image filename as an extra command line parameter set(MODULE_IMAGE_TESTS mitkPlanePositionManagerTest.cpp mitkSurfaceVtkWriterTest.cpp #mitkImageSliceSelectorTest.cpp mitkImageTimeSelectorTest.cpp # mitkVtkPropRendererTest.cpp mitkDataNodeFactoryTest.cpp #mitkSTLFileReaderTest.cpp mitkImageAccessorTest.cpp ) # list of images for which the tests are run set(MODULE_TESTIMAGES # Pic-Factory no more available in Core, test images now in .nrrd format US4DCyl.nrrd Pic3D.nrrd Pic2DplusT.nrrd BallBinary30x30x30.nrrd binary.stl ball.stl ) set(MODULE_CUSTOM_TESTS #mitkLabeledImageToSurfaceFilterTest.cpp #mitkExternalToolsTest.cpp mitkDataStorageTest.cpp mitkDataNodeTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkEventMapperTest.cpp mitkNodeDependentPointSetInteractorTest.cpp mitkStateMachineFactoryTest.cpp mitkPointSetLocaleTest.cpp mitkImageTest.cpp mitkImageWriterTest.cpp mitkImageVtkMapper2DTest.cpp mitkImageVtkMapper2DLevelWindowTest.cpp mitkImageVtkMapper2DOpacityTest.cpp mitkImageVtkMapper2DColorTest.cpp mitkImageVtkMapper2DSwivelTest.cpp mitkIOUtilTest.cpp mitkSurfaceVtkMapper3DTest mitkSurfaceVtkMapper3DTexturedSphereTest.cpp mitkVolumeCalculatorTest.cpp mitkLevelWindowManagerTest.cpp ) # Create an artificial module initializing class for # the usServiceListenerTest.cpp usFunctionGenerateModuleInit(testdriver_init_file NAME ${MODULE_NAME}TestDriver DEPENDS "Mitk" VERSION "0.1.0" EXECUTABLE ) set(TEST_CPP_FILES ${testdriver_init_file} mitkRenderingTestHelper.cpp) diff --git a/Core/Documentation/Doxygen/Concepts/NewEvents.dox b/Core/Documentation/Doxygen/Concepts/NewEvents.dox index 2f7992c126..cb42cb550a 100644 --- a/Core/Documentation/Doxygen/Concepts/NewEvents.dox +++ b/Core/Documentation/Doxygen/Concepts/NewEvents.dox @@ -1,56 +1,72 @@ /** \page ImplementNewEventsPage What needs to be done to implement a new event? \tableofcontents \section WhenUseEvents When to use this guide In general there are no restriction about how events are created and processed. The intention of this page is to provide how to contruct Events in order to use them with the MITK Interaction Concept. \section OriginEvents Origin and processing of Events \ref DataInteractionPage gives a brief description of how events are generated and proccessed. After events are created they need to be send via mitk::RenderWindowBase::HandleEvent() so that they are relayed to a Dispatcher which handles the event distribution to the DataInteractors. \section EventImplementation Event Implementation The only prerequisite for a new event to be accepted is that it is derived from the mitk::InteractionEvent class. Further it is neccessary to provide a unique string identifier for this event class -(this string will identify this class/super-class in a state machine pattern by the event_class tag), and it needs to implement at least one function, +(this string will identify this class/super-class in a state machine pattern by the event_class tag), and it needs to implement at least two functions, as shown at the example of the MousePressEvent. Implementation of equality for each event class by implementing isEqual. Equality does \b not mean an exact copy or pointer equality. Equality is determined by agreement in all attributes that are necessary to describe the event for a state machine transition. Here, for example, for the a mouse event press event, it is important which modifiers are used, which mouse button was used to triggered the event, but the mouse position is irrelevant. \code bool mitk::MousePressEvent::MatchesTemplate(mitk::InteractionEvent::Pointer interactionEvent) { // cast to your event class here mitk::MousePressEvent* mpe = dynamic_cast(interactionEvent.GetPointer()); if (mpe == NULL) { return false; } // Checking relevant attributes, such as EventButton and Modifiers, but omitting the mouse coordinates // Replace this to check for your event class' attributes return (this->GetEventButton() == mpe->GetEventButton() && this->GetModifiers() == mpe->GetModifiers() && this->GetButtonStates() == mpe->GetButtonStates()); } \endcode +The function IsSuperClassOf() implements an up cast to check if the provided baseClass object is derived from this class. +This function is used to support polymorphism on state machine pattern (XML) level. + +\code +bool mitk::MousePressEvent::IsSuperClassOf(InteractionEvent::Pointer baseClass) +{ + // Replace with your class, or implement some rules which classes are accepted. + MousePressEvent* event = dynamic_cast(baseClass.GetPointer()); + if (event != NULL) + { + return true; + } + return false; +} +\endcode + \section EventConstruction Configuration File & Event Factory Regarding the state machine and the state machine pattern parser there are no changes necessary. To be able to parse the new event, changes have to be made in the mitk::EventConfig and mitk::EventFactory classes. The mitk::EventConfig class has to be adapted in a way such that the parameters that describe the event are parsed. The parsing can be easily extended, and should provide a mitk::PropertyList for each event parsed. Lastly the mitk::EventFactory has to be extended to use this mitk::PropertyList and construct an event based on it. */