diff --git a/Core/Code/Interactions/mitkEventFactory.cpp b/Core/Code/Interactions/mitkEventFactory.cpp index 762bf34974..794bf6fb0f 100755 --- a/Core/Code/Interactions/mitkEventFactory.cpp +++ b/Core/Code/Interactions/mitkEventFactory.cpp @@ -1,230 +1,544 @@ /*=================================================================== 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 "mitkEventFactory.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace { - std::vector &split(const std::string &s, char delim, std::vector &elems) +std::vector &split(const std::string &s, char delim, std::vector &elems) +{ + std::stringstream ss(s); + std::string item; + while (std::getline(ss, item, delim)) { - std::stringstream ss(s); - std::string item; - while (std::getline(ss, item, delim)) - { - elems.push_back(item); - } - return elems; + elems.push_back(item); } + return elems; +} - std::vector split(const std::string &s, char delim) - { - std::vector < std::string > elems; - return split(s, delim, elems); - } +std::vector split(const std::string &s, char delim) +{ + std::vector < std::string > elems; + return split(s, delim, elems); +} } mitk::InteractionEvent::Pointer mitk::EventFactory::CreateEvent(PropertyList::Pointer list) { -// + // std::string eventClass, eventVariant; list->GetStringProperty(InteractionEventConst::xmlParameterEventClass().c_str(), eventClass); list->GetStringProperty(InteractionEventConst::xmlParameterEventVariant().c_str(), eventVariant); -// Query all possible attributes, if they are not present, set their default values. -// Position Events & Key Events + // Query all possible attributes, if they are not present, set their default values. + // Position Events & Key Events std::string strModifiers; InteractionEvent::ModifierKeys modifiers = InteractionEvent::NoKey; std::string strEventButton; InteractionEvent::MouseButtons eventButton = InteractionEvent::NoButton; std::string strButtonState; InteractionEvent::MouseButtons buttonState = InteractionEvent::NoButton; std::string strKey; std::string key; std::string strWheelDelta; int wheelDelta; std::string strSignalName = ""; Point2D pos; pos.Fill(0); + std::string strPos; + + // Position on screen + if( list->GetStringProperty(InteractionEventConst::xmlEventPropertyPositionOnScreen().c_str(), strPos)) + { + //split comma separated string + int commaPos; + commaPos = strPos.find_first_of(','); + + pos[0] = static_cast(std::atof(strPos.substr(0, commaPos).c_str())); + pos[1] = static_cast(std::atof(strPos.substr(commaPos+1, strPos.length()).c_str())); + } -// Parse modifier information + std::string strWorld; + Point3D worldPos; + worldPos.Fill(0); + //Position in world coordinates + if(list->GetStringProperty(InteractionEventConst::xmlEventPropertyPositionInWorld().c_str(), strWorld)) + { + std::vector coords = split(strWorld, ','); + int i = 0; + for ( std::vector::iterator it = coords.begin(); it != coords.end(); ++it, ++i) + { + worldPos[i] = atof((*it).c_str()); + } + } + + // Parse modifier information if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyModifier().c_str(), strModifiers)) { std::vector mods = split(strModifiers, ','); for (std::vector::iterator it = mods.begin(); it != mods.end(); ++it) { std::transform((*it).begin(), (*it).end(), (*it).begin(), ::toupper); if (*it == "CTRL") { modifiers = modifiers | InteractionEvent::ControlKey; } else if (*it == "ALT") { modifiers = modifiers | InteractionEvent::AltKey; } else if (*it == "SHIFT") { modifiers = modifiers | InteractionEvent::ShiftKey; } else { MITK_WARN<< "mitkEventFactory: Invalid event modifier in config file :" << (*it); } } } -// Set EventButton + // Set EventButton if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyEventButton().c_str(), strEventButton)) { std::transform(strEventButton.begin(), strEventButton.end(), strEventButton.begin(), ::toupper); if (strEventButton == "MIDDLEMOUSEBUTTON") { eventButton = InteractionEvent::MiddleMouseButton; } else if (strEventButton == "LEFTMOUSEBUTTON") { eventButton = InteractionEvent::LeftMouseButton; } else if (strEventButton == "RIGHTMOUSEBUTTON") { eventButton = InteractionEvent::RightMouseButton; } else { MITK_WARN<< "mitkEventFactory: Invalid event button in config file: " << strEventButton; } } -// Parse ButtonStates + // Parse ButtonStates if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyButtonState().c_str(), strButtonState)) { std::vector mods = split(strButtonState, ','); for (std::vector::iterator it = mods.begin(); it != mods.end(); ++it) { std::transform((*it).begin(), (*it).end(), (*it).begin(), ::toupper); if (*it == "MIDDLEMOUSEBUTTON") { buttonState = buttonState | InteractionEvent::MiddleMouseButton; } else if (*it == "LEFTMOUSEBUTTON") { buttonState = buttonState | InteractionEvent::LeftMouseButton; } else if (*it == "RIGHTMOUSEBUTTON") { buttonState = buttonState | InteractionEvent::RightMouseButton; } else { MITK_WARN<< "mitkEventFactory: Invalid event buttonstate in config file:" << (*it); } } } -// Key + // Key if (!list->GetStringProperty(InteractionEventConst::xmlEventPropertyKey().c_str(), strKey)) { key = ""; } else { key = strKey; } -// WheelDelta + // WheelDelta if (!list->GetStringProperty(InteractionEventConst::xmlEventPropertyScrollDirection().c_str(), strWheelDelta)) { wheelDelta = 0; } else { std::transform(strWheelDelta.begin(), strWheelDelta.end(), strWheelDelta.begin(), ::toupper); if (strWheelDelta == "DOWN") { wheelDelta = -1; } else { wheelDelta = 1; } } -// Internal Signals Name + // Internal Signals Name list->GetStringProperty(InteractionEventConst::xmlEventPropertySignalName().c_str(), strSignalName); + // Get BaseRenderer by name + mitk::BaseRenderer* renderer = NULL; + std::string strRenderer; + + // only search for a renderer if there is at least one renderer registered + if(mitk::BaseRenderer::baseRendererMap.size() > 0) + { + + if(list->GetStringProperty(mitk::InteractionEventConst::xmlEventPropertyRendererName().c_str(), strRenderer)) + { + //look up for renderer registered with the name in xml file + renderer = mitk::BaseRenderer::GetByName(strRenderer); + } + + //if not found always use first registered renderer + if(renderer == NULL) + renderer = (*(mitk::BaseRenderer::baseRendererMap.begin())).second; +} + /* * Here the objects are created */ mitk::InteractionEvent::Pointer event; std::transform(eventClass.begin(), eventClass.end(), eventClass.begin(), ::toupper); if (eventClass == "MOUSEPRESSEVENT") { // buttonstates incorporate the event button (as in Qt) buttonState = buttonState | eventButton; - event = MousePressEvent::New(NULL, pos, buttonState, modifiers, eventButton); + event = MousePressEvent::New(renderer, pos,worldPos, buttonState, modifiers, eventButton); } else if (eventClass == "MOUSEDOUBLECLICKEVENT") { buttonState = buttonState | eventButton; - event = MouseDoubleClickEvent::New(NULL, pos, buttonState, modifiers, eventButton); + event = MouseDoubleClickEvent::New(renderer, pos,worldPos, buttonState, modifiers, eventButton); } else if (eventClass == "MOUSEMOVEEVENT") { - event = MouseMoveEvent::New(NULL, pos, buttonState, modifiers); + event = MouseMoveEvent::New(renderer, pos,worldPos, buttonState, modifiers); } else if (eventClass == "MOUSERELEASEEVENT") { - event = MouseReleaseEvent::New(NULL, pos, buttonState, modifiers, eventButton); + event = MouseReleaseEvent::New(renderer, pos,worldPos, buttonState, modifiers, eventButton); } else if (eventClass == "INTERACTIONKEYEVENT") { - event = InteractionKeyEvent::New(NULL, key, modifiers); + event = InteractionKeyEvent::New(renderer, key, modifiers); } else if (eventClass == "MOUSEWHEELEVENT") { - event = MouseWheelEvent::New(NULL, pos, buttonState, modifiers, wheelDelta); + event = MouseWheelEvent::New(renderer, pos,worldPos, buttonState, modifiers, wheelDelta); } else if (eventClass == "INTERACTIONPOSITIONEVENT") { - event = InteractionPositionEvent::New(NULL, pos); + event = InteractionPositionEvent::New(renderer, pos,worldPos); } else if (eventClass == "INTERNALEVENT") { - event = InternalEvent::New(NULL, NULL, strSignalName); + event = InternalEvent::New(renderer, NULL, strSignalName); } else if (eventClass == "INTERACTIONEVENT") { - event = InteractionEvent::New(NULL); + event = InteractionEvent::New(renderer); } if (event.IsNull()) { MITK_WARN<< "Event couldn't be constructed. Please check your StateMachine patterns and config files\n for the following event class, which is not valid: " << eventClass; return NULL; } return event; } + +std::string mitk::EventFactory::EventToXML(mitk::InteractionEvent *event) +{ + + InternalEvent* ie = dynamic_cast (event); + if (ie != NULL) + return ""; + + std::string eventClass = event->GetNameOfClass(); + std::string eventXML = "<" + InteractionEventConst::xmlTagEventVariant() + " " + InteractionEventConst::xmlParameterEventClass() + "=\""; + + std::transform(eventClass.begin(), eventClass.end(), eventClass.begin(), ::toupper); + + eventXML += eventClass + "\" >\n"; + // here follow event specific attributes + if (eventClass == "MOUSEPRESSEVENT" || eventClass == "MOUSERELEASEEVENT" || eventClass == "MOUSEDOUBLECLICKEVENT" || eventClass == "MOUSEMOVEEVENT" || eventClass == "MOUSEWHEELEVENT") + { + if (!(eventClass == "MOUSEMOVEEVENT") && !(eventClass == "MOUSEWHEELEVENT")) + { + // EventButton + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyEventButton() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += GetEventButton(event); + eventXML += "\"/>\n"; + } + // ButtonState + if (GetButtonState(event) != "") + { + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyButtonState() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += GetButtonState(event); + eventXML += "\"/>\n"; + } + + // Modifiers + if (GetModifierState(event) != "") + { + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyModifier() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += GetModifierState(event); + eventXML += "\"/>\n"; + } + + // Position on Screen + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyPositionOnScreen() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += GetPositionOnScreen(event); + eventXML += "\"/>\n"; + + // Position in World + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyPositionInWorld() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += GetPositionInWorld(event); + eventXML += "\"/>\n"; + } + else if (eventClass == "INTERACTIONKEYEVENT") + { + mitk::InteractionKeyEvent* ke = dynamic_cast(event); + + // key + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyKey() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += ke->GetKey(); + eventXML += "\"/>\n"; + } + else + { + MITK_WARN << "Event not recognized, discarding event of type " << event->GetNameOfClass(); + } + if (eventClass == "MOUSEWHEELEVENT") + { + MouseWheelEvent* we = dynamic_cast (event); + int delta = we->GetWheelDelta(); + + std::stringstream ss; + ss << delta; + + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyWheelDelta() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += ss.str(); + eventXML += "\"/>\n"; + + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyScrollDirection() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += delta < 0 ? "DOWN" : "UP"; + eventXML += "\"/>\n"; + } + + // Renderer name + eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyRendererName() + "\" "; + eventXML += InteractionEventConst::xmlParameterValue() + "=\""; + eventXML += event->GetSender()->GetName(); + eventXML += "\"/>\n"; + + // closing tag: + eventXML += ""; + return eventXML; +} + +std::string mitk::EventFactory::GetButtonState(mitk::InteractionEvent *event) +{ + InteractionEvent::MouseButtons buttonState = InteractionEvent::NoButton; + std::string eventClass = event->GetNameOfClass(); + std::transform(eventClass.begin(), eventClass.end(), eventClass.begin(), ::toupper); + + std::string strButtonState = ""; + if (eventClass == "MOUSEPRESSEVENT") + { + MousePressEvent* mme = dynamic_cast (event); + buttonState = mme->GetButtonStates(); + } + if (eventClass == "MOUSERELEASEEVENT") + { + MouseReleaseEvent* mme = dynamic_cast (event); + buttonState = mme->GetButtonStates(); + } + if (eventClass == "MOUSEDOUBLECLICKEVENT") + { + MouseDoubleClickEvent* mme = dynamic_cast (event); + buttonState = mme->GetButtonStates(); + } + if (eventClass == "MOUSEMOVEEVENT") + { + MouseMoveEvent* mme = dynamic_cast (event); + buttonState = mme->GetButtonStates(); + } + if (eventClass == "MOUSEWHEELEVENT") + { + MouseWheelEvent* mme = dynamic_cast (event); + buttonState = mme->GetButtonStates(); + } + + if (buttonState & InteractionEvent::LeftMouseButton ) + { + strButtonState = "LeftMouseButton"; + } + if (buttonState & InteractionEvent::RightMouseButton ) + { + if (strButtonState != "") + strButtonState += ","; + + strButtonState += "RightMouseButton"; + } + if (buttonState & InteractionEvent::MiddleMouseButton ) + { + if (strButtonState != "") + strButtonState += ","; + + strButtonState += "MiddleMouseButton"; + } + return strButtonState; +} + +std::string mitk::EventFactory::GetModifierState(mitk::InteractionEvent *event) +{ + InteractionEvent::ModifierKeys modifierKeys = InteractionEvent::NoKey; + std::string eventClass = event->GetNameOfClass(); + std::transform(eventClass.begin(), eventClass.end(), eventClass.begin(), ::toupper); + std::string strModKeys = ""; + // TODO Add InteractionKey + if (eventClass == "MOUSEPRESSEVENT") + { + MousePressEvent* mme = dynamic_cast (event); + modifierKeys = mme->GetModifiers(); + } + if (eventClass == "MOUSERELEASEEVENT") + { + MouseReleaseEvent* mme = dynamic_cast (event); + modifierKeys = mme->GetModifiers(); + } + if (eventClass == "MOUSEDOUBLECLICKEVENT") + { + MouseDoubleClickEvent* mme = dynamic_cast (event); + modifierKeys = mme->GetModifiers(); + } + if (eventClass == "MOUSEMOVEEVENT") + { + MouseMoveEvent* mme = dynamic_cast (event); + modifierKeys = mme->GetModifiers(); + } + if (eventClass == "MOUSEWHEELEVENT") + { + MouseWheelEvent* mme = dynamic_cast (event); + modifierKeys = mme->GetModifiers(); + } + + if (modifierKeys & InteractionEvent::ShiftKey ) + { + strModKeys = "SHIFT"; + } + if (modifierKeys & InteractionEvent::ControlKey ) + { + if (strModKeys != "") + strModKeys += ","; + + strModKeys += "CTRL"; + } + if (modifierKeys & InteractionEvent::AltKey ) + { + if (strModKeys != "") + strModKeys += ","; + + strModKeys += "ALT"; + } + return strModKeys; +} + +std::string mitk::EventFactory::GetEventButton(mitk::InteractionEvent *event) +{ + InteractionEvent::MouseButtons button = InteractionEvent::NoButton; + std::string eventClass = event->GetNameOfClass(); + std::transform(eventClass.begin(), eventClass.end(), eventClass.begin(), ::toupper); + std::string stdButton = ""; + // TODO Add InteractionKey + if (eventClass == "MOUSEPRESSEVENT") + { + MousePressEvent* mme = dynamic_cast (event); + button = mme->GetEventButton(); + } + if (eventClass == "MOUSERELEASEEVENT") + { + MouseReleaseEvent* mme = dynamic_cast (event); + button = mme->GetEventButton(); + } + if (eventClass == "MOUSEDOUBLECLICKEVENT") + { + MouseDoubleClickEvent* mme = dynamic_cast (event); + button = mme->GetEventButton(); + } + + if (button & InteractionEvent::LeftMouseButton ) + { + stdButton = "LeftMouseButton"; + } + if (button & InteractionEvent::RightMouseButton ) + { + stdButton = "RightMouseButton"; + } + if (button & InteractionEvent::MiddleMouseButton ) + { + stdButton = "MiddleMouseButton"; + } + return stdButton; + +} + +std::string mitk::EventFactory::GetPositionInWorld(mitk::InteractionEvent *event) +{ + std::stringstream ss; + InteractionPositionEvent* pe = dynamic_cast (event); + if (pe != NULL) + { + Point3D p = pe->GetPositionInWorld(); + ss << p[0] << "," << p[1] << "," << p[2]; + } + return ss.str(); +} + +std::string mitk::EventFactory::GetPositionOnScreen(mitk::InteractionEvent *event) +{ + std::stringstream ss; + InteractionPositionEvent* pe = dynamic_cast (event); + if (pe != NULL) + { + Point2D p = pe->GetPointerPositionOnScreen(); + ss << p[0] << "," << p[1]; + } + return ss.str(); +} diff --git a/Core/Code/Interactions/mitkEventFactory.h b/Core/Code/Interactions/mitkEventFactory.h index 3b4efe2504..59635df9f2 100755 --- a/Core/Code/Interactions/mitkEventFactory.h +++ b/Core/Code/Interactions/mitkEventFactory.h @@ -1,47 +1,97 @@ /*=================================================================== 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 mitkEventFactory_h #define mitkEventFactory_h #include "mitkCommon.h" #include "mitkInteractionEvent.h" #include "mitkPropertyList.h" #include namespace mitk { /** * \class EventFactory - * \brief Generates InteractionEvent-Objects which are described by a PropertyList. + * \brief Generates InteractionEvent-Objects/XML. + * + * 1) InteractionEvents can be constructed by a PropertyList describing the event (see mitk::EventConfig for examples) + * 2) An XML description of InteractionEvents can be retrieved. + * * This class is used by the EventConfig object to parse configuration files and create Events based on the xml description. * * \ingroup Interaction */ class MITK_CORE_EXPORT EventFactory { public: + + /** * Parses PropertyList and queries all possible Information. * If an attribute is not present the default value is used. * Finally the Event-Type is chosen by the ClassName property and the object is created using the collected information. */ static InteractionEvent::Pointer CreateEvent(PropertyList::Pointer eventDescription); + + /** + * @brief EventToXML Transforms an event into a XML tag describing it. + * @param event + * @return Event block specifying event class and attributes of that event. + */ + static std::string EventToXML(InteractionEvent* event); + + private: + /** + * @brief GetEventButton Return EventButton as String + * @param event + * @return + */ + static std::string GetButtonState(InteractionEvent* event); + + /** + * @brief GetModifierState Return ModifierState as String + * @param event + * @return + */ + static std::string GetModifierState(InteractionEvent* event); + + /** + * @brief GetEventButton Return EventButton as String + * @param event + * @return + */ + static std::string GetEventButton(InteractionEvent* event); + + /** + * @brief GetPosition Return World Position as String + * @param event + * @return + */ + static std::string GetPositionInWorld(InteractionEvent* event); + + /** + * @brief GetPositionOnScreen Return PositionOnScreen as String + * @param event + * @return + */ + static std::string GetPositionOnScreen(InteractionEvent* event); + }; } #endif /* mitkEventFactory_h */ diff --git a/Core/Code/Interactions/mitkEventRecorder.cpp b/Core/Code/Interactions/mitkEventRecorder.cpp new file mode 100644 index 0000000000..229eb3a007 --- /dev/null +++ b/Core/Code/Interactions/mitkEventRecorder.cpp @@ -0,0 +1,162 @@ +/*=================================================================== + + 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 "mitkEventRecorder.h" +#include "mitkEventFactory.h" +#include "mitkInteractionEvent.h" +#include "mitkInteractionEventConst.h" + +#include "mitkBaseRenderer.h" + + +static void WriteEventXMLHeader(std::ofstream& stream) +{ + stream << mitk::InteractionEventConst::xmlHead() << "\n"; +} + + +static void WriteEventXMLConfig(std::ofstream& stream) +{ + // + stream << " <" << mitk::InteractionEventConst::xmlTagConfigRoot() << ">\n"; + + //write renderer config + //for all registered 2D renderers write name and viewdirection. + mitk::BaseRenderer::BaseRendererMapType::iterator rendererIterator = mitk::BaseRenderer::baseRendererMap.begin(); + mitk::BaseRenderer::BaseRendererMapType::iterator end = mitk::BaseRenderer::baseRendererMap.end(); + + for(; rendererIterator != end; rendererIterator++) + { + if((*rendererIterator).second->GetMapperID() == mitk::BaseRenderer::Standard2D) + { + std::string rendererName = (*rendererIterator).second->GetName(); + mitk::SliceNavigationController::ViewDirection viewDirection = (*rendererIterator).second->GetSliceNavigationController()->GetDefaultViewDirection(); + + // + stream << " <" << mitk::InteractionEventConst::xmlTagRenderer() << " " << mitk::InteractionEventConst::xmlEventPropertyRendererName() << "=\"" << rendererName << "\" " << mitk::InteractionEventConst::xmlEventPropertyViewDirection() << "=\"" << viewDirection << "\"/>\n"; + } + } + + // + stream << " \n"; +} + +static void WriteEventXMLEventsOpen(std::ofstream& stream) +{ + stream << " <" << mitk::InteractionEventConst::xmlTagEvents() << ">\n"; +} + + +static void WriteEventXMLEventsClose(std::ofstream& stream) +{ + stream << " \n"; +} + + +static void WriteEventXMLInteractionsOpen(std::ofstream& stream) +{ + stream << "<" << mitk::InteractionEventConst::xmlTagInteractions() << ">\n"; +} + + +static void WriteEventXMLInteractionsClose(std::ofstream& stream) +{ + stream << ""; +} + + +static void WriteEventXMLClose(std::ofstream& stream) +{ + WriteEventXMLEventsClose(stream); + WriteEventXMLInteractionsClose(stream); +} + + +mitk::EventRecorder::EventRecorder() + : m_Active(false) +{ +} + +mitk::EventRecorder::~EventRecorder() +{ + if (m_FileStream.is_open()) + { + m_FileStream.flush(); + m_FileStream.close(); + } +} + +void mitk::EventRecorder::Notify(mitk::InteractionEvent *interactionEvent, bool /*isHandled*/) +{ + std::cout << EventFactory::EventToXML(interactionEvent) << "\n"; + if (m_FileStream.is_open()) + m_FileStream << EventFactory::EventToXML(interactionEvent) << "\n"; +} + +void mitk::EventRecorder::SetEventIgnoreList(std::vector list) +{ + m_IgnoreList = list; +} + +void mitk::EventRecorder::StartRecording() +{ + if (m_FileName == "") + { + MITK_ERROR << "EventRecorder::StartRecording - Filename needs to be set first."; + return; + } + if (m_FileStream.is_open()) + { + MITK_ERROR << "EventRecorder::StartRecording - Still recording. Stop recording before starting it again."; + return; + } + + m_FileStream.open(m_FileName.c_str(), std::ofstream::out ); + if ( !m_FileStream.good() ) + { + MITK_ERROR << "File " << m_FileName << " could not be opened!"; + m_FileStream.close(); + return; + } + + //write head and config + // + // + // + // + // + // ... + // + // + WriteEventXMLHeader(m_FileStream); + WriteEventXMLInteractionsOpen(m_FileStream); + WriteEventXMLConfig(m_FileStream); + WriteEventXMLEventsOpen(m_FileStream); +} + +void mitk::EventRecorder::StopRecording() +{ + if (m_FileStream.is_open()) + { + //write end tag + // + // + WriteEventXMLClose(m_FileStream); + + m_FileStream.flush(); + m_FileStream.close(); + } +} diff --git a/Core/Code/Interactions/mitkEventRecorder.h b/Core/Code/Interactions/mitkEventRecorder.h new file mode 100644 index 0000000000..68fe37a843 --- /dev/null +++ b/Core/Code/Interactions/mitkEventRecorder.h @@ -0,0 +1,92 @@ +/*=================================================================== + + 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 mitkEventRecorder_h +#define mitkEventRecorder_h + +#include +#include "mitkInteractionEventObserver.h" +#include "iostream" + +namespace mitk +{ +/** + *\class EventRecorder + *@brief Observer that enables recoding of all user interaction with the render windows and storing it in an XML file. + * + * @ingroup Interaction + * + * XML file will look like + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + **/ +class MITK_CORE_EXPORT EventRecorder: public InteractionEventObserver +{ +public: + EventRecorder(); + ~EventRecorder(); + + /** + * By this function the Observer gets notified about new events. + */ + virtual void Notify(InteractionEvent* interactionEvent, bool); + + /** + * @brief SetEventIgnoreList Optional. Provide a list of strings that describe which events are to be ignored + */ + void SetEventIgnoreList(std::vector list); + + void StartRecording(); + void StopRecording(); + + void SetOutputFile(std::string filename) + { + m_FileName = filename; + } + +private: + + /** + * @brief m_IgnoreList lists the names of events that are dropped + */ + std::vector m_IgnoreList; + + /** + * @brief m_Active determindes if events are caught and written to file + */ + bool m_Active; + std::string m_FileName; + + std::ofstream m_FileStream; + + +}; +} +#endif diff --git a/Core/Code/Interactions/mitkInteractionEventConst.cpp b/Core/Code/Interactions/mitkInteractionEventConst.cpp index 810d1377af..49dc5cc910 100644 --- a/Core/Code/Interactions/mitkInteractionEventConst.cpp +++ b/Core/Code/Interactions/mitkInteractionEventConst.cpp @@ -1,107 +1,159 @@ /*=================================================================== 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 "mitkInteractionEventConst.h" namespace mitk { +const std::string InteractionEventConst::xmlHead() +{ + static const std::string xmlHead = ""; + return xmlHead; +} + const std::string InteractionEventConst::xmlTagConfigRoot() { static const std::string xmlTagConfigRoot = "config"; return xmlTagConfigRoot; } +const std::string InteractionEventConst::xmlTagEvents() +{ + static const std::string xmlTagEvents = "events"; + return xmlTagEvents; +} + +const std::string InteractionEventConst::xmlTagInteractions() +{ + static const std::string xmlTagInteractions = "interactions"; + return xmlTagInteractions; +} + +const std::string InteractionEventConst::xmlTagRenderer() +{ + static const std::string xmlTagRenderer = "renderer"; + return xmlTagRenderer; +} + const std::string InteractionEventConst::xmlTagParam() { static const std::string xmlTagParam = "param"; return xmlTagParam; - } const std::string InteractionEventConst::xmlTagEventVariant() { static const std::string xmlTagEventVariant = "event_variant"; return xmlTagEventVariant; } const std::string InteractionEventConst::xmlTagAttribute() { static const std::string xmlTagAttribute = "attribute"; return xmlTagAttribute; } const std::string InteractionEventConst::xmlParameterName() { static const std::string xmlParameterName = "name"; return xmlParameterName; } const std::string InteractionEventConst::xmlParameterValue() { static const std::string xmlParameterValue = "value"; return xmlParameterValue; } const std::string InteractionEventConst::xmlParameterEventVariant() { static const std::string xmlParameterEventVariant = "event_variant"; return xmlParameterEventVariant; } const std::string InteractionEventConst::xmlParameterEventClass() { static const std::string xmlParameterEventClass = "class"; return xmlParameterEventClass; } const std::string InteractionEventConst::xmlEventPropertyModifier() { static const std::string xmlEventPropertyModifier = "Modifiers"; return xmlEventPropertyModifier; } const std::string InteractionEventConst::xmlEventPropertyEventButton() { static const std::string xmlEventPropertyEventButton = "EventButton"; return xmlEventPropertyEventButton; } const std::string InteractionEventConst::xmlEventPropertyButtonState() { static const std::string xmlEventPropertyButtonState = "ButtonState"; return xmlEventPropertyButtonState; } +const std::string InteractionEventConst::xmlEventPropertyPositionInWorld() +{ + static const std::string xmlEventPropertyPosition = "PositionInWorld"; + return xmlEventPropertyPosition; +} + +const std::string InteractionEventConst::xmlEventPropertyPositionOnScreen() +{ + static const std::string xmlEventPropertyPosition = "PositionOnScreen"; + return xmlEventPropertyPosition; +} + const std::string InteractionEventConst::xmlEventPropertyKey() { static const std::string xmlEventPropertyKey = "Key"; return xmlEventPropertyKey; } const std::string InteractionEventConst::xmlEventPropertyScrollDirection() { static const std::string xmlEventPropertyScrollDirection = "ScrollDirection"; return xmlEventPropertyScrollDirection; } +const std::string InteractionEventConst::xmlEventPropertyWheelDelta() +{ + static const std::string xmlEventPropertyWheelDelta = "WheelDelta"; + return xmlEventPropertyWheelDelta; +} + const std::string InteractionEventConst::xmlEventPropertySignalName() { static const std::string xmlEventPropertySignalName = "SignalName"; return xmlEventPropertySignalName; } +const std::string InteractionEventConst::xmlEventPropertyRendererName() +{ + static const std::string xmlEventPropertyRendererName = "RendererName"; + return xmlEventPropertyRendererName; +} + +const std::string InteractionEventConst::xmlEventPropertyViewDirection() +{ + static const std::string xmlEventPropertyViewDirection = "ViewDirection"; + return xmlEventPropertyViewDirection; +} } diff --git a/Core/Code/Interactions/mitkInteractionEventConst.h b/Core/Code/Interactions/mitkInteractionEventConst.h index fea72b994c..5fb599d6b6 100644 --- a/Core/Code/Interactions/mitkInteractionEventConst.h +++ b/Core/Code/Interactions/mitkInteractionEventConst.h @@ -1,53 +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 MITKINTERACTEVENTCONST_H #define MITKINTERACTEVENTCONST_H #include #include namespace mitk { /** * @brief Constants to describe Mouse Events and special Key Events. */ struct MITK_CORE_EXPORT InteractionEventConst { + static const std::string xmlHead(); // = ""; + // XML Tags static const std::string xmlTagConfigRoot(); // = "config"; + static const std::string xmlTagEvents(); // = "events"; + static const std::string xmlTagInteractions(); // = "interactions"; static const std::string xmlTagParam(); // = "param"; static const std::string xmlTagEventVariant(); // = "event_variant"; static const std::string xmlTagAttribute(); // = "attribute"; + static const std::string xmlTagRenderer(); // = "renderer"; // XML Param static const std::string xmlParameterName(); // = "name"; static const std::string xmlParameterValue(); // = "value"; static const std::string xmlParameterEventVariant(); // = "event_variant"; static const std::string xmlParameterEventClass(); // = "class"; // Event Description static const std::string xmlEventPropertyModifier(); // = "Modifiers"; static const std::string xmlEventPropertyEventButton(); // = "EventButton"; static const std::string xmlEventPropertyButtonState(); // = "ButtonState"; + static const std::string xmlEventPropertyPositionInWorld(); // = "PositionInWorld"; + static const std::string xmlEventPropertyPositionOnScreen(); // = "PositionOnScreen"; static const std::string xmlEventPropertyKey(); // = "Key"; static const std::string xmlEventPropertyScrollDirection(); // = "ScrollDirection"; + static const std::string xmlEventPropertyWheelDelta(); // = "WheelDelta"; static const std::string xmlEventPropertySignalName(); // = "SignalName"; + static const std::string xmlEventPropertyRendererName(); // = "RendererName"; + static const std::string xmlEventPropertyViewDirection(); // = "ViewDirection"; }; } //namespace mitk #endif //ifndef MITKINTERACTEVENTCONST_H diff --git a/Core/Code/Interactions/mitkInteractionPositionEvent.cpp b/Core/Code/Interactions/mitkInteractionPositionEvent.cpp index 74f963600e..1cb147ffb2 100644 --- a/Core/Code/Interactions/mitkInteractionPositionEvent.cpp +++ b/Core/Code/Interactions/mitkInteractionPositionEvent.cpp @@ -1,57 +1,50 @@ /*=================================================================== 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 mitk::Point2D& mousePosition, const mitk::Point3D& worldPosition ) : InteractionEvent(baseRenderer) , m_PointerPosition(mousePosition) +, m_WorldPosition(worldPosition) { - if (GetSender() != NULL) - { - m_WorldPosition = GetSender()->Map2DRendererPositionTo3DWorldPosition(&m_PointerPosition); - } - else - { - m_WorldPosition.Fill(0); - } } -const mitk::Point2D mitk::InteractionPositionEvent::GetPointerPositionOnScreen() const +mitk::Point2D mitk::InteractionPositionEvent::GetPointerPositionOnScreen() const { return m_PointerPosition; } -const mitk::Point3D mitk::InteractionPositionEvent::GetPositionInWorld() const +mitk::Point3D mitk::InteractionPositionEvent::GetPositionInWorld() const { return m_WorldPosition; } bool mitk::InteractionPositionEvent::IsEqual(const InteractionEvent& other) const { return Superclass::IsEqual(other); } mitk::InteractionPositionEvent::~InteractionPositionEvent() { } bool mitk::InteractionPositionEvent::IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const { return (dynamic_cast(baseClass.GetPointer()) != NULL) ; } diff --git a/Core/Code/Interactions/mitkInteractionPositionEvent.h b/Core/Code/Interactions/mitkInteractionPositionEvent.h index 428b03d05c..005d2bb4be 100644 --- a/Core/Code/Interactions/mitkInteractionPositionEvent.h +++ b/Core/Code/Interactions/mitkInteractionPositionEvent.h @@ -1,66 +1,66 @@ /*=================================================================== 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); - mitkNewMacro2Param(Self, BaseRenderer*, const Point2D&); + mitkNewMacro3Param(Self, BaseRenderer*, const Point2D&, const Point3D&); - const Point2D GetPointerPositionOnScreen() const; - const Point3D GetPositionInWorld() const; + Point2D GetPointerPositionOnScreen() const; + Point3D GetPositionInWorld() const; virtual bool IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const; protected: - InteractionPositionEvent(BaseRenderer* baseRenderer, const Point2D& mousePosition); + InteractionPositionEvent(BaseRenderer* baseRenderer, const Point2D& mousePosition, const Point3D &worldPosition); virtual ~InteractionPositionEvent(); virtual bool IsEqual(const InteractionEvent&) const; private: - Point2D m_PointerPosition; - Point3D m_WorldPosition; + const Point2D m_PointerPosition; + const Point3D m_WorldPosition; }; } /* namespace mitk */ #endif /* MITKINTERACTIONPOSITIONEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkMouseDoubleClickEvent.cpp b/Core/Code/Interactions/mitkMouseDoubleClickEvent.cpp index 70103198f7..cb20862aee 100644 --- a/Core/Code/Interactions/mitkMouseDoubleClickEvent.cpp +++ b/Core/Code/Interactions/mitkMouseDoubleClickEvent.cpp @@ -1,77 +1,77 @@ /*=================================================================== 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 "mitkMouseDoubleClickEvent.h" mitk::MouseDoubleClickEvent::MouseDoubleClickEvent(mitk::BaseRenderer* baseRenderer, - const mitk::Point2D& mousePosition, + const mitk::Point2D& mousePosition, const Point3D& worldPosition, MouseButtons buttonStates, ModifierKeys modifiers, MouseButtons eventButton) -: InteractionPositionEvent(baseRenderer, mousePosition) +: InteractionPositionEvent(baseRenderer, mousePosition, worldPosition) , m_EventButton(eventButton) , m_ButtonStates(buttonStates) , m_Modifiers( modifiers) { } mitk::InteractionEvent::MouseButtons mitk::MouseDoubleClickEvent::GetEventButton() const { return m_EventButton; } void mitk::MouseDoubleClickEvent::SetEventButton(MouseButtons buttons) { m_EventButton = buttons; } mitk::InteractionEvent::ModifierKeys mitk::MouseDoubleClickEvent::GetModifiers() const { return m_Modifiers; } mitk::InteractionEvent::MouseButtons mitk::MouseDoubleClickEvent::GetButtonStates() const { return m_ButtonStates; } void mitk::MouseDoubleClickEvent::SetModifiers(ModifierKeys modifiers) { m_Modifiers = modifiers; } void mitk::MouseDoubleClickEvent::SetButtonStates(MouseButtons buttons) { m_ButtonStates = buttons; } mitk::MouseDoubleClickEvent::~MouseDoubleClickEvent() { } bool mitk::MouseDoubleClickEvent::IsEqual(const mitk::InteractionEvent& interactionEvent) const { const mitk::MouseDoubleClickEvent& mpe = static_cast(interactionEvent); return (this->GetEventButton() == mpe.GetEventButton() && this->GetModifiers() == mpe.GetModifiers() && this->GetButtonStates() == mpe.GetButtonStates() && Superclass::IsEqual(interactionEvent)); } bool mitk::MouseDoubleClickEvent::IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const { return (dynamic_cast(baseClass.GetPointer()) != NULL) ; } diff --git a/Core/Code/Interactions/mitkMouseDoubleClickEvent.h b/Core/Code/Interactions/mitkMouseDoubleClickEvent.h index 408fb5878b..e1fb210122 100644 --- a/Core/Code/Interactions/mitkMouseDoubleClickEvent.h +++ b/Core/Code/Interactions/mitkMouseDoubleClickEvent.h @@ -1,63 +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 MITKMouseDoubleClickEvent_H_ #define MITKMouseDoubleClickEvent_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 MouseDoubleClickEvent: public InteractionPositionEvent { public: mitkClassMacro(MouseDoubleClickEvent,InteractionPositionEvent) - mitkNewMacro5Param(Self, BaseRenderer*, const Point2D& , MouseButtons , ModifierKeys, MouseButtons) + mitkNewMacro6Param(Self, BaseRenderer*, const Point2D& ,const Point3D& , 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 IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const; protected: - MouseDoubleClickEvent(BaseRenderer*, const Point2D& = Point2D(), MouseButtons buttonStates = NoButton, + MouseDoubleClickEvent(BaseRenderer*, const Point2D& = Point2D(),const Point3D& = Point3D(), MouseButtons buttonStates = NoButton, ModifierKeys modifiers = NoKey, MouseButtons eventButton = NoButton); virtual ~MouseDoubleClickEvent(); virtual bool IsEqual(const InteractionEvent&) const; private: MouseButtons m_EventButton; MouseButtons m_ButtonStates; ModifierKeys m_Modifiers; }; } /* namespace mitk */ #endif /* MITKMouseDoubleClickEvent_H_ */ diff --git a/Core/Code/Interactions/mitkMouseModeSwitcher.cpp b/Core/Code/Interactions/mitkMouseModeSwitcher.cpp index 19fe9ddd6d..1048a6359b 100644 --- a/Core/Code/Interactions/mitkMouseModeSwitcher.cpp +++ b/Core/Code/Interactions/mitkMouseModeSwitcher.cpp @@ -1,113 +1,112 @@ /*=================================================================== 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 "mitkMouseModeSwitcher.h" // us #include "usGetModuleContext.h" #include "usModuleContext.h" #include "mitkInteractionEventObserver.h" mitk::MouseModeSwitcher::MouseModeSwitcher() : m_ActiveInteractionScheme(MITK), m_ActiveMouseMode(MousePointer), m_CurrentObserver(NULL) { this->InitializeListeners(); this->SetInteractionScheme(m_ActiveInteractionScheme); } mitk::MouseModeSwitcher::~MouseModeSwitcher() { m_ServiceRegistration.Unregister(); } void mitk::MouseModeSwitcher::InitializeListeners() { if (m_CurrentObserver.IsNull()) { m_CurrentObserver = mitk::DisplayInteractor::New(); m_CurrentObserver->LoadStateMachine("DisplayInteraction.xml"); m_CurrentObserver->SetEventConfig("DisplayConfigMITK.xml"); // Register as listener via micro services us::ServiceProperties props; props["name"] = std::string("DisplayInteractor"); m_ServiceRegistration = us::GetModuleContext()->RegisterService( m_CurrentObserver.GetPointer(),props); - } } void mitk::MouseModeSwitcher::SetInteractionScheme(InteractionScheme scheme) { switch (scheme) { case MITK: { m_CurrentObserver->SetEventConfig("DisplayConfigMITK.xml"); } break; case PACS: { m_CurrentObserver->SetEventConfig("DisplayConfigPACS.xml"); } break; } m_ActiveInteractionScheme = scheme; this->InvokeEvent(MouseModeChangedEvent()); } void mitk::MouseModeSwitcher::SelectMouseMode(MouseMode mode) { if (m_ActiveInteractionScheme != PACS) return; switch (mode) { case MousePointer: { m_CurrentObserver->SetEventConfig("DisplayConfigPACS.xml"); break; } // case 0 case Scroll: { m_CurrentObserver->AddEventConfig("DisplayConfigPACSScroll.xml"); break; } case LevelWindow: { m_CurrentObserver->AddEventConfig("DisplayConfigPACSLevelWindow.xml"); break; } case Zoom: { m_CurrentObserver->AddEventConfig("DisplayConfigPACSZoom.xml"); break; } case Pan: { m_CurrentObserver->AddEventConfig("DisplayConfigPACSPan.xml"); break; } } // end switch (mode) m_ActiveMouseMode = mode; this->InvokeEvent(MouseModeChangedEvent()); } mitk::MouseModeSwitcher::MouseMode mitk::MouseModeSwitcher::GetCurrentMouseMode() const { return m_ActiveMouseMode; } diff --git a/Core/Code/Interactions/mitkMouseModeSwitcher.h b/Core/Code/Interactions/mitkMouseModeSwitcher.h index d52a127439..4fc102844f 100644 --- a/Core/Code/Interactions/mitkMouseModeSwitcher.h +++ b/Core/Code/Interactions/mitkMouseModeSwitcher.h @@ -1,129 +1,132 @@ /*=================================================================== 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 MITKMouseModeSwitcher_H_HEADER_INCLUDED_C10DC4EB #define MITKMouseModeSwitcher_H_HEADER_INCLUDED_C10DC4EB #include "MitkExports.h" #include #include "mitkDisplayInteractor.h" +#include "mitkEventRecorder.h" + namespace mitk { /*********************************************************************** * * \brief Class that offers a convenient way to switch between different * interaction schemes * * This class offers the possibility to switch between the two different * interaction schemes that are available: * - MITK : The original interaction scheme * - left mouse button : setting the cross position in the MPR view * - middle mouse button : panning * - right mouse button : zooming * * * - PACS : an alternative interaction scheme that behaves more like a * PACS workstation * - left mouse button : behavior depends on current MouseMode * - middle mouse button : fast scrolling * - right mouse button : level-window * - ctrl + right button : zooming * - shift+ right button : panning * * There are 5 different MouseModes that are available in the PACS scheme. * Each MouseMode defines the interaction that is performed on a left * mouse button click: * - Pointer : sets the cross position for the MPR * - Scroll * - Level-Window * - Zoom * - Pan * * When the interaction scheme or the MouseMode is changed, this class * manages the adding and removing of the relevant listeners offering * a convenient way to modify the interaction behavior. * ***********************************************************************/ class MITK_CORE_EXPORT MouseModeSwitcher : public itk::Object { public: #pragma GCC visibility push(default) /** \brief Can be observed by GUI class to update button states when mode is changed programatically. */ itkEventMacro( MouseModeChangedEvent, itk::AnyEvent ); #pragma GCC visibility pop mitkClassMacro( MouseModeSwitcher, itk::Object ); itkNewMacro(Self); // enum of the different interaction schemes that are available enum InteractionScheme { PACS = 0, MITK = 1 }; // enum of available mouse modes for PACS interaction scheme enum MouseMode { MousePointer = 0, Scroll, LevelWindow, Zoom, Pan }; /** * \brief Setter for interaction scheme */ void SetInteractionScheme( InteractionScheme ); /** * \brief Setter for mouse mode */ void SelectMouseMode( MouseMode mode ); /** * \brief Returns the current mouse mode */ MouseMode GetCurrentMouseMode() const; protected: MouseModeSwitcher(); virtual ~MouseModeSwitcher(); private: /** * \brief Initializes the listener with the MITK default behavior. */ void InitializeListeners(); InteractionScheme m_ActiveInteractionScheme; MouseMode m_ActiveMouseMode; DisplayInteractor::Pointer m_CurrentObserver; + /** * Reference to the service registration of the observer, * it is needed to unregister the observer on unload. */ us::ServiceRegistration m_ServiceRegistration; }; } // namespace mitk #endif /* MITKMouseModeSwitcher_H_HEADER_INCLUDED_C10DC4EB */ diff --git a/Core/Code/Interactions/mitkMouseMoveEvent.cpp b/Core/Code/Interactions/mitkMouseMoveEvent.cpp index d58ce5c563..37896ed905 100644 --- a/Core/Code/Interactions/mitkMouseMoveEvent.cpp +++ b/Core/Code/Interactions/mitkMouseMoveEvent.cpp @@ -1,61 +1,61 @@ /*=================================================================== 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, const mitk::Point2D& mousePosition , MouseButtons buttonStates, ModifierKeys modifiers) -: InteractionPositionEvent(baseRenderer, mousePosition) +mitk::MouseMoveEvent::MouseMoveEvent(mitk::BaseRenderer* baseRenderer, const mitk::Point2D& mousePosition ,const mitk::Point3D& worldPosition , MouseButtons buttonStates, ModifierKeys modifiers) +: InteractionPositionEvent(baseRenderer, mousePosition,worldPosition) , m_ButtonStates(buttonStates) , m_Modifiers(modifiers) { } mitk::InteractionEvent::ModifierKeys mitk::MouseMoveEvent::GetModifiers() const { return m_Modifiers; } mitk::InteractionEvent::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::IsEqual(const mitk::InteractionEvent& interactionEvent) const { const mitk::MouseMoveEvent& mpe = static_cast(interactionEvent); return (this->GetModifiers() == mpe.GetModifiers() && this->GetButtonStates() == mpe.GetButtonStates() && Superclass::IsEqual(interactionEvent)); } bool mitk::MouseMoveEvent::IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const { return (dynamic_cast(baseClass.GetPointer()) != NULL) ; } diff --git a/Core/Code/Interactions/mitkMouseMoveEvent.h b/Core/Code/Interactions/mitkMouseMoveEvent.h index 074e508ac3..6bac529832 100644 --- a/Core/Code/Interactions/mitkMouseMoveEvent.h +++ b/Core/Code/Interactions/mitkMouseMoveEvent.h @@ -1,59 +1,59 @@ /*=================================================================== 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*, const Point2D& , MouseButtons , ModifierKeys); + mitkNewMacro5Param(Self, BaseRenderer*, const Point2D& ,const Point3D& , MouseButtons , ModifierKeys); ModifierKeys GetModifiers() const; MouseButtons GetButtonStates() const; void SetModifiers(ModifierKeys modifiers); void SetButtonStates(MouseButtons buttons); virtual bool IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const; protected: - MouseMoveEvent(BaseRenderer*, const Point2D& = Point2D(), MouseButtons buttonStates = NoButton, + MouseMoveEvent(BaseRenderer*, const Point2D& = Point2D(), const Point3D& = Point3D(), MouseButtons buttonStates = NoButton, ModifierKeys modifiers = NoKey); virtual ~MouseMoveEvent(); virtual bool IsEqual(const InteractionEvent&) const; 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 12af1bfe82..7ae23b4686 100644 --- a/Core/Code/Interactions/mitkMousePressEvent.cpp +++ b/Core/Code/Interactions/mitkMousePressEvent.cpp @@ -1,77 +1,77 @@ /*=================================================================== 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, + const mitk::Point2D& mousePosition, const Point3D& worldPosition, MouseButtons buttonStates, ModifierKeys modifiers, MouseButtons eventButton) -: InteractionPositionEvent(baseRenderer, mousePosition) +: InteractionPositionEvent(baseRenderer, mousePosition, worldPosition) , m_EventButton(eventButton) , m_ButtonStates(buttonStates) , m_Modifiers( modifiers) { } mitk::InteractionEvent::MouseButtons mitk::MousePressEvent::GetEventButton() const { return m_EventButton; } void mitk::MousePressEvent::SetEventButton(MouseButtons buttons) { m_EventButton = buttons; } mitk::InteractionEvent::ModifierKeys mitk::MousePressEvent::GetModifiers() const { return m_Modifiers; } mitk::InteractionEvent::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::IsEqual(const mitk::InteractionEvent& interactionEvent) const { const mitk::MousePressEvent& mpe = static_cast(interactionEvent); return (this->GetEventButton() == mpe.GetEventButton() && this->GetModifiers() == mpe.GetModifiers() && this->GetButtonStates() == mpe.GetButtonStates() && Superclass::IsEqual(interactionEvent)); } bool mitk::MousePressEvent::IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const { return (dynamic_cast(baseClass.GetPointer()) != NULL) ; } diff --git a/Core/Code/Interactions/mitkMousePressEvent.h b/Core/Code/Interactions/mitkMousePressEvent.h index 6b931236a2..60266654f7 100644 --- a/Core/Code/Interactions/mitkMousePressEvent.h +++ b/Core/Code/Interactions/mitkMousePressEvent.h @@ -1,63 +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 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) + mitkNewMacro6Param(Self, BaseRenderer*, const Point2D& , const Point3D& , 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 IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const; protected: - MousePressEvent(BaseRenderer*, const Point2D& = Point2D(), MouseButtons buttonStates = NoButton, + MousePressEvent(BaseRenderer*, const Point2D& = Point2D(), const Point3D& = Point3D(), MouseButtons buttonStates = NoButton, ModifierKeys modifiers = NoKey, MouseButtons eventButton = NoButton); virtual ~MousePressEvent(); virtual bool IsEqual(const InteractionEvent&) const; 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 00162b9f49..23f0f47500 100644 --- a/Core/Code/Interactions/mitkMouseReleaseEvent.cpp +++ b/Core/Code/Interactions/mitkMouseReleaseEvent.cpp @@ -1,78 +1,78 @@ /*=================================================================== 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, - const mitk::Point2D& mousePosition, + const mitk::Point2D& mousePosition, const Point3D &worldPosition, MouseButtons buttonStates, ModifierKeys modifiers, MouseButtons eventButton) -: InteractionPositionEvent(baseRenderer, mousePosition) +: InteractionPositionEvent(baseRenderer, mousePosition, worldPosition) , m_EventButton(eventButton) , m_ButtonStates(buttonStates) , m_Modifiers(modifiers) { } mitk::InteractionEvent::MouseButtons mitk::MouseReleaseEvent::GetEventButton() const { return m_EventButton; } void mitk::MouseReleaseEvent::SetEventButton(MouseButtons buttons) { m_EventButton = buttons; } mitk::InteractionEvent::ModifierKeys mitk::MouseReleaseEvent::GetModifiers() const { return m_Modifiers; } mitk::InteractionEvent::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::IsEqual(const mitk::InteractionEvent& interactionEvent) const { const mitk::MouseReleaseEvent& mre = static_cast(interactionEvent); return (this->GetEventButton() == mre.GetEventButton() && this->GetModifiers() == mre.GetModifiers() && this->GetButtonStates() == mre.GetButtonStates() && Superclass::IsEqual(interactionEvent)); } bool mitk::MouseReleaseEvent::IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const { return (dynamic_cast(baseClass.GetPointer()) != NULL) ; } diff --git a/Core/Code/Interactions/mitkMouseReleaseEvent.h b/Core/Code/Interactions/mitkMouseReleaseEvent.h index b2699544a5..0c7743d5c5 100644 --- a/Core/Code/Interactions/mitkMouseReleaseEvent.h +++ b/Core/Code/Interactions/mitkMouseReleaseEvent.h @@ -1,66 +1,67 @@ /*=================================================================== 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) + mitkNewMacro6Param(Self, BaseRenderer*, const Point2D& ,const Point3D& , 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 IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const; protected: MouseReleaseEvent(BaseRenderer*, const mitk::Point2D& mousePosition = Point2D(), + const mitk::Point3D& worldPosition = Point3D(), MouseButtons buttonStates = NoButton, ModifierKeys modifiers = NoKey, MouseButtons eventButton = NoButton); virtual ~MouseReleaseEvent(); virtual bool IsEqual(const InteractionEvent&) const; 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 f35a5c84d0..57b48d56c4 100644 --- a/Core/Code/Interactions/mitkMouseWheelEvent.cpp +++ b/Core/Code/Interactions/mitkMouseWheelEvent.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 "mitkMouseWheelEvent.h" mitk::MouseWheelEvent::MouseWheelEvent(BaseRenderer* baseRenderer, - const Point2D& mousePosition, + const Point2D& mousePosition, const Point3D& worldPosition, MouseButtons buttonStates, ModifierKeys modifiers, int wheelDelta) -: InteractionPositionEvent(baseRenderer, mousePosition) +: InteractionPositionEvent(baseRenderer, mousePosition, worldPosition) , 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::InteractionEvent::ModifierKeys mitk::MouseWheelEvent::GetModifiers() const { return m_Modifiers; } mitk::InteractionEvent::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::IsEqual(const mitk::InteractionEvent& interactionEvent) const { const mitk::MouseWheelEvent& mwe = static_cast(interactionEvent); 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() && Superclass::IsEqual(interactionEvent)); } bool mitk::MouseWheelEvent::IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const { return (dynamic_cast(baseClass.GetPointer()) != NULL) ; } diff --git a/Core/Code/Interactions/mitkMouseWheelEvent.h b/Core/Code/Interactions/mitkMouseWheelEvent.h index 25caf1c7c0..0694f869b5 100644 --- a/Core/Code/Interactions/mitkMouseWheelEvent.h +++ b/Core/Code/Interactions/mitkMouseWheelEvent.h @@ -1,69 +1,70 @@ /*=================================================================== 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) + mitkNewMacro6Param(Self, BaseRenderer*, const Point2D&,const Point3D&, 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 IsSuperClassOf(const InteractionEvent::Pointer& baseClass) const; protected: MouseWheelEvent(BaseRenderer* = NULL, const Point2D& mousePosition = Point2D(), + const Point3D& worldPosition = Point3D(), MouseButtons buttonStates = NoButton, ModifierKeys modifiers = NoKey, int wheelDelta = 0); virtual ~MouseWheelEvent(); virtual bool IsEqual(const InteractionEvent&) const; private: int m_WheelDelta; MouseButtons m_ButtonStates; ModifierKeys m_Modifiers; }; } /* namespace mitk */ #endif /* MITKMOUSEPRESSEVENT_H_ */ diff --git a/Core/Code/Interactions/mitkVtkEventAdapter.cpp b/Core/Code/Interactions/mitkVtkEventAdapter.cpp index 2b5b907da3..c875cc1771 100644 --- a/Core/Code/Interactions/mitkVtkEventAdapter.cpp +++ b/Core/Code/Interactions/mitkVtkEventAdapter.cpp @@ -1,463 +1,464 @@ /*=================================================================== 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 "mitkVtkEventAdapter.h" #include // INTERACTION LEGACY #include // INTERACTION LEGACY #include "mitkInteractionEventConst.h" #include #include "vtkCommand.h" namespace mitk { std::map VtkEventAdapter::buttonStateMap; } mitk::MouseEvent mitk::VtkEventAdapter::AdaptMouseEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId, vtkRenderWindowInteractor* rwi) { mitk::Point2D p; p[0] = rwi->GetEventPosition()[0]; p[1] = rwi->GetEventPosition()[1]; - p[1] = rwi->GetSize()[1] - p[1]; // flip y axis // http://doc.trolltech.com/4.6/qt.html#MouseButton-enum int button = 0; int type = 0; int state = 0; // vtkRenderWindowInteractor does not provide information about mouse buttons during // mouse move events... // some button action might be going on during mouse move events // that needs to be temp. saved in our buttonStateMap int tmpstate = 0; if (buttonStateMap.find(sender) != buttonStateMap.end()) tmpstate = buttonStateMap.find(sender)->second; if (tmpstate != 0 && vtkCommandEventId != vtkCommand::MouseMoveEvent) buttonStateMap.erase(buttonStateMap.find(sender)); //press or release event with active map caching switch (vtkCommandEventId) { case vtkCommand::MouseMoveEvent: type = 5; button = mitk::BS_NoButton; if (tmpstate != 0) { state = tmpstate; /* // debug output static char tmp; sprintf(&tmp,"%d",tmpstate); std::cout << tmp << std::endl; */ } break; case vtkCommand::LeftButtonReleaseEvent: type = 3; button = mitk::BS_LeftButton; state = tmpstate; buttonStateMap[sender] = (tmpstate - button); break; case vtkCommand::MiddleButtonReleaseEvent: type = 3; button = mitk::BS_MidButton; state = tmpstate; buttonStateMap[sender] = (tmpstate - button); break; case vtkCommand::RightButtonReleaseEvent: type = 3; button = mitk::BS_RightButton; state = tmpstate; buttonStateMap[sender] = (tmpstate - button); break; case vtkCommand::LeftButtonPressEvent: type = 2; button = mitk::BS_LeftButton; tmpstate |= button; buttonStateMap[sender] = tmpstate; break; case vtkCommand::MiddleButtonPressEvent: type = 2; button = mitk::BS_MidButton; tmpstate |= button; buttonStateMap[sender] = tmpstate; break; case vtkCommand::RightButtonPressEvent: type = 2; button = mitk::BS_RightButton; tmpstate |= button; buttonStateMap[sender] = tmpstate; break; } if (rwi->GetShiftKey()) { state |= mitk::BS_ShiftButton; } if (rwi->GetControlKey()) { state |= mitk::BS_ControlButton; } if (rwi->GetAltKey()) { state |= mitk::BS_AltButton; } mitk::MouseEvent mitkEvent(sender, type, button, state, mitk::Key_none, p); return mitkEvent; } mitk::WheelEvent //mitk::VtkEventAdapter::AdaptWheelEvent(mitk::BaseRenderer* sender, QWheelEvent* wheelEvent) mitk::VtkEventAdapter::AdaptWheelEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId, vtkRenderWindowInteractor* rwi) { mitk::Point2D p; p[0] = rwi->GetEventPosition()[0]; p[1] = rwi->GetEventPosition()[1]; // http://doc.trolltech.com/4.6/qt.html#MouseButton-enum int button = 0; int type = 0; int state = 0; int delta = 0; switch (vtkCommandEventId) { case vtkCommand::MouseWheelForwardEvent: type = 31; // wheel event, // see qcoreevent enum "type" button = 0x00000000; delta = +120; //http://doc.trolltech.com/3.3/qwheelevent.html#delta break; case vtkCommand::MouseWheelBackwardEvent: type = 31; // wheel event, // see qcoreevent enum "type" button = 0x00000000; delta = -120; //http://doc.trolltech.com/3.3/qwheelevent.html#delta break; } if (rwi->GetShiftKey()) state |= mitk::BS_ShiftButton; if (rwi->GetControlKey()) state |= mitk::BS_ControlButton; if (rwi->GetAltKey()) state |= mitk::BS_AltButton; mitk::WheelEvent mitkEvent(sender, type, button, state, mitk::Key_none, p, delta); return mitkEvent; } mitk::KeyEvent //mitk::VtkEventAdapter::AdaptKeyEvent(mitk::BaseRenderer* sender, QKeyEvent* keyEvent, const QPoint& cp) mitk::VtkEventAdapter::AdaptKeyEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId, vtkRenderWindowInteractor* rwi) { // TODO: is this viable? int key = (int) rwi->GetKeyCode(); // Those keycodes changed in Qt 4 if (key >= 0x01000000 && key <= 0x01000060) key -= (0x01000000 - 0x1000); else if (key >= 0x01001120 && key <= 0x01001262) key -= 0x01000000; mitk::Point2D p; p[0] = rwi->GetEventPosition()[0]; p[1] = rwi->GetEventPosition()[1]; int type = 0; if (vtkCommandEventId == vtkCommand::KeyPressEvent) type = 6; // http://doc.trolltech.com/4.6/qevent.html#Type-enum int state = 0; if (rwi->GetShiftKey()) state |= mitk::BS_ShiftButton; if (rwi->GetControlKey()) state |= mitk::BS_ControlButton; if (rwi->GetAltKey()) state |= mitk::BS_AltButton; mitk::KeyEvent mke(sender, type, mitk::BS_NoButton, state, key, std::string(rwi->GetKeySym()), p); return mke; } mitk::MousePressEvent::Pointer mitk::VtkEventAdapter::AdaptMousePressEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId, vtkRenderWindowInteractor* rwi) { mitk::Point2D point; point[0] = rwi->GetEventPosition()[0]; point[1] = rwi->GetEventPosition()[1]; - point[1] = rwi->GetSize()[1] - point[1]; // flip y axis + int button = 0; int modifiers = 0; int buttonState = 0; // vtkRenderWindowInteractor does not provide information about mouse buttons during // mouse move events therefore the Press/Release functions update the button state in the buttonStateMap // this button state is then provided for mouse move events if (buttonStateMap.find(sender) != buttonStateMap.end()) buttonState = buttonStateMap.find(sender)->second; if (buttonState != 0 && vtkCommandEventId != vtkCommand::MouseMoveEvent) buttonStateMap.erase(buttonStateMap.find(sender)); //press or release event with active map caching switch (vtkCommandEventId) { case vtkCommand::LeftButtonPressEvent: button = InteractionEvent::LeftMouseButton; buttonState |= button; buttonStateMap[sender] = buttonState; break; case vtkCommand::MiddleButtonPressEvent: button = InteractionEvent::MiddleMouseButton; buttonState |= button; buttonStateMap[sender] = buttonState; break; case vtkCommand::RightButtonPressEvent: button = InteractionEvent::RightMouseButton; buttonState |= button; buttonStateMap[sender] = buttonState; break; } if (rwi->GetShiftKey()) { modifiers |= InteractionEvent::ShiftKey; } if (rwi->GetControlKey()) { modifiers |= InteractionEvent::ControlKey; } if (rwi->GetAltKey()) { modifiers |= InteractionEvent::AltKey; } - MousePressEvent::Pointer mpe = MousePressEvent::New(sender, point, + Point3D worldPos = sender->Map2DRendererPositionTo3DWorldPosition(point); + MousePressEvent::Pointer mpe = MousePressEvent::New(sender, point,worldPos, static_cast(buttonState), static_cast(modifiers), static_cast(button)); return mpe; } mitk::MouseMoveEvent::Pointer mitk::VtkEventAdapter::AdaptMouseMoveEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId, vtkRenderWindowInteractor* rwi) { mitk::Point2D point; point[0] = rwi->GetEventPosition()[0]; point[1] = rwi->GetEventPosition()[1]; - point[1] = rwi->GetSize()[1] - point[1]; // flip y axis int modifiers = 0; // vtkRenderWindowInteractor does not provide information about mouse buttons during // mouse move events therefore the Press/Release functions update the button state in the buttonStateMap // this button state is then provided for mouse move events int buttonState = 0; if (buttonStateMap.find(sender) != buttonStateMap.end()) { // set stored button state buttonState = buttonStateMap.find(sender)->second; } if (vtkCommandEventId == vtkCommand::MouseMoveEvent) { if (buttonState != 0) { modifiers = buttonState; } } else { MITK_WARN<< "Wrong usage of function AdaptMouseMoveEvent. Wrong input type."; } if (rwi->GetShiftKey()) { modifiers |= InteractionEvent::ShiftKey; } if (rwi->GetControlKey()) { modifiers |= InteractionEvent::ControlKey; } if (rwi->GetAltKey()) { modifiers |= InteractionEvent::AltKey; } - MouseMoveEvent::Pointer mme = MouseMoveEvent::New(sender, point, + Point3D worldPos = sender->Map2DRendererPositionTo3DWorldPosition(point); + MouseMoveEvent::Pointer mme = MouseMoveEvent::New(sender, point,worldPos, static_cast(buttonState), static_cast(modifiers)); return mme; } mitk::MouseReleaseEvent::Pointer mitk::VtkEventAdapter::AdaptMouseReleaseEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId, vtkRenderWindowInteractor* rwi) { mitk::Point2D point; point[0] = rwi->GetEventPosition()[0]; point[1] = rwi->GetEventPosition()[1]; - point[1] = rwi->GetSize()[1] - point[1]; // flip y axis int button = 0; int modifiers = 0; int buttonState = 0; // vtkRenderWindowInteractor does not provide information about mouse buttons during // mouse move events therefore the Press/Release functions update the button state in the buttonStateMap // this button state is then provided for mouse move events if (buttonStateMap.find(sender) != buttonStateMap.end()) buttonState = buttonStateMap.find(sender)->second; if (buttonState != 0 && vtkCommandEventId != vtkCommand::MouseMoveEvent) buttonStateMap.erase(buttonStateMap.find(sender)); //press or release event with active map caching switch (vtkCommandEventId) { case vtkCommand::LeftButtonReleaseEvent: button = InteractionEvent::LeftMouseButton; // remove left mouse button from button state buttonStateMap[sender] = (buttonState - button); break; case vtkCommand::MiddleButtonReleaseEvent: button = InteractionEvent::MiddleMouseButton; // remove middle button from button state buttonStateMap[sender] = (buttonState - button); break; case vtkCommand::RightButtonReleaseEvent: button = InteractionEvent::RightMouseButton; // remove right mouse button from button state buttonStateMap[sender] = (buttonState - button); break; } if (rwi->GetShiftKey()) { modifiers |= InteractionEvent::ShiftKey; } if (rwi->GetControlKey()) { modifiers |= InteractionEvent::ControlKey; } if (rwi->GetAltKey()) { modifiers |= InteractionEvent::AltKey; } // after releasing button is no longer pressed, to update it if (buttonStateMap.find(sender) != buttonStateMap.end()) { buttonState = buttonStateMap.find(sender)->second; } - MouseReleaseEvent::Pointer mre = MouseReleaseEvent::New(sender, point, + Point3D worldPos = sender->Map2DRendererPositionTo3DWorldPosition(point); + + MouseReleaseEvent::Pointer mre = MouseReleaseEvent::New(sender, point,worldPos, static_cast(buttonState), static_cast(modifiers), static_cast(button)); return mre; } mitk::MouseWheelEvent::Pointer mitk::VtkEventAdapter::AdaptMouseWheelEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId, vtkRenderWindowInteractor* rwi) { mitk::Point2D p; p[0] = rwi->GetEventPosition()[0]; p[1] = rwi->GetEventPosition()[1]; int delta = 0; switch (vtkCommandEventId) { case vtkCommand::MouseWheelForwardEvent: delta = +120; //http://doc.trolltech.com/3.3/qwheelevent.html#delta break; case vtkCommand::MouseWheelBackwardEvent: delta = -120; //http://doc.trolltech.com/3.3/qwheelevent.html#delta break; } int modifiers = 0; if (rwi->GetShiftKey()) { modifiers |= mitk::BS_ShiftButton; } if (rwi->GetControlKey()) { modifiers |= mitk::BS_ControlButton; } if (rwi->GetAltKey()) { modifiers |= mitk::BS_AltButton; } mitk::Point2D point; point[0] = rwi->GetEventPosition()[0]; point[1] = rwi->GetEventPosition()[1]; - point[1] = rwi->GetSize()[1] - point[1]; // flip y axis // vtkWheelEvent does not have a buttonState or event button int buttonState = 0; - MouseWheelEvent::Pointer mpe = MouseWheelEvent::New(sender, point, + Point3D worldPos = sender->Map2DRendererPositionTo3DWorldPosition(point); + MouseWheelEvent::Pointer mpe = MouseWheelEvent::New(sender, point,worldPos, static_cast(buttonState), static_cast(modifiers), delta); return mpe; } mitk::InteractionKeyEvent::Pointer mitk::VtkEventAdapter::AdaptInteractionKeyEvent(mitk::BaseRenderer* sender, unsigned long vtkCommandEventId, vtkRenderWindowInteractor* rwi) { if (vtkCommandEventId != vtkCommand::KeyPressEvent) { MITK_WARN<< "mitk::VtkEventAdapter::AdaptInteractionKeyEvent() called with wrong argument"; return NULL; } int modifiers = 0; if (rwi->GetShiftKey()) { modifiers |= mitk::BS_ShiftButton;} if (rwi->GetControlKey()) { modifiers |= mitk::BS_ControlButton;} if (rwi->GetAltKey()) { modifiers |= mitk::BS_AltButton; } InteractionKeyEvent::Pointer ike = InteractionKeyEvent::New(sender, std::string(rwi->GetKeySym()), static_cast(modifiers)); return ike; } diff --git a/Core/Code/Interactions/mitkXML2EventParser.cpp b/Core/Code/Interactions/mitkXML2EventParser.cpp new file mode 100755 index 0000000000..00e4ebae7a --- /dev/null +++ b/Core/Code/Interactions/mitkXML2EventParser.cpp @@ -0,0 +1,137 @@ +/*=================================================================== + + 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 "mitkXML2EventParser.h" + +#include "mitkEventFactory.h" +#include "mitkInteractionEvent.h" +#include "mitkInternalEvent.h" +#include "mitkInteractionKeyEvent.h" +#include "mitkInteractionEventConst.h" + +// VTK +#include + +// us +#include "usGetModuleContext.h" +#include "usModule.h" +#include "usModuleResource.h" +#include "usModuleResourceStream.h" + +namespace mitk { + + +void mitk::XML2EventParser::StartElement(const char* elementName, const char **atts) +{ + std::string name(elementName); + + if (name == InteractionEventConst::xmlTagConfigRoot()) + { + // + } + else if (name == InteractionEventConst::xmlTagEventVariant()) + { + std::string eventClass = ReadXMLStringAttribute(InteractionEventConst::xmlParameterEventClass(), atts); + // New list in which all parameters are stored that are given within the tag + m_EventPropertyList = PropertyList::New(); + m_EventPropertyList->SetStringProperty(InteractionEventConst::xmlParameterEventClass().c_str(), eventClass.c_str()); + //MITK_INFO << "event class " << eventClass; + } + else if (name == InteractionEventConst::xmlTagAttribute()) + { + // Attributes that describe an Input Event, such as which MouseButton triggered the event,or which modifier keys are pressed + std::string name = ReadXMLStringAttribute(InteractionEventConst::xmlParameterName(), atts); + std::string value = ReadXMLStringAttribute(InteractionEventConst::xmlParameterValue(), atts); + //MITK_INFO << "tag attr " << value; + m_EventPropertyList->SetStringProperty(name.c_str(), value.c_str()); + } +} + +void mitk::XML2EventParser::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 == InteractionEventConst::xmlTagEventVariant()) + { + InteractionEvent::Pointer event = EventFactory::CreateEvent(m_EventPropertyList); + if (event.IsNotNull()) + { + m_InteractionList.push_back(event); + } + else + { + MITK_WARN<< "EventConfig: Unknown Event-Type in config. Entry skipped: " << name; + } + } +} + +std::string mitk::XML2EventParser::ReadXMLStringAttribute(const 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(); +} + +bool mitk::XML2EventParser::ReadXMLBooleanAttribute(const std::string& name, const char** atts) +{ + std::string s = ReadXMLStringAttribute(name, atts); + std::transform(s.begin(), s.end(), s.begin(), ::toupper); + + return s == "TRUE"; +} + +mitk::XML2EventParser::XML2EventParser(const std::string& filename, const us::Module* module) +{ + if (module == NULL) + { + module = us::GetModuleContext()->GetModule(); + } + us::ModuleResource resource = module->GetResource("Interactions/" + filename); + if (!resource.IsValid()) + { + MITK_ERROR << "Resource not valid. State machine pattern in module " << module->GetName() + << " not found: /Interactions/" << filename; + return; + } + + us::ModuleResourceStream stream(resource); + this->SetStream(&stream); + bool success = this->Parse(); + if (!success) + MITK_ERROR << "Error occured during parsing of EventXML File."; +} + +mitk::XML2EventParser::XML2EventParser(std::istream &inputStream) +{ + this->SetStream(&inputStream); + bool success = this->Parse(); + if (!success) + MITK_ERROR << "Error occured during parsing of EventXML File."; +} + +} diff --git a/Core/Code/Interactions/mitkXML2EventParser.h b/Core/Code/Interactions/mitkXML2EventParser.h new file mode 100755 index 0000000000..30ad4e4dbf --- /dev/null +++ b/Core/Code/Interactions/mitkXML2EventParser.h @@ -0,0 +1,105 @@ +/*=================================================================== + + 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 mitkXML2EventParser_h +#define mitkXML2EventParser_h + +#include + +#include "mitkPropertyList.h" + +#include + +#include "mitkInteractionEvent.h" + +namespace us { +class Module; +} + +namespace mitk +{ + +/** + * \class InteractionEventList + * \brief Generates a list of InteractionEvents based on an XML file- + * + * @sa EventRecorder + * @ingroup Interaction + **/ +class XML2EventParser : public vtkXMLParser +{ + +public: + + /** + * @brief Construct an InteractionEventList object based on a XML configuration file. + * + * Uses the specified resource file containing an XML event configuration to + * construct an EventConfig object. If the resource is invalid, the created + * EventConfig object will also be invalid. + * + * @param filename The resource name relative to the Interactions resource folder. + * @param module + */ + XML2EventParser(const std::string& filename, const us::Module* module = NULL); + + /** + * @brief Construct an InteractionEventList object based on a XML configuration file. + * + * Uses the specified istream refering to a file containing an XML event configuration to + * construct an EventConfig object. If the resource is invalid, the created + * EventConfig object will also be invalid. + * + * @param inputStream std::ifstream to XML configuration file + */ + XML2EventParser(std::istream &inputStream); + + typedef std::vector EventContainerType; + + EventContainerType GetInteractions() + { + return m_InteractionList; + } + + ~XML2EventParser(){}; +protected: + + /** + * @brief Derived from XMLReader + **/ + void StartElement(const char* elementName, const char **atts); + + /** + * @brief Derived from XMLReader + **/ + void EndElement(const char* elementName); + + std::string ReadXMLStringAttribute(const std::string& name, const char** atts); + bool ReadXMLBooleanAttribute(const std::string& name, const char** atts); + +private: + + + PropertyList::Pointer m_EventPropertyList; + + EventContainerType m_InteractionList; + + +}; + +} // namespace mitk + +#endif /* mitkStateMachineConfig_h */ diff --git a/Core/Code/Rendering/mitkBaseRenderer.cpp b/Core/Code/Rendering/mitkBaseRenderer.cpp index 30ceb8082c..e443ee8593 100644 --- a/Core/Code/Rendering/mitkBaseRenderer.cpp +++ b/Core/Code/Rendering/mitkBaseRenderer.cpp @@ -1,889 +1,888 @@ /*=================================================================== 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 "mitkBaseRenderer.h" #include "mitkMapper.h" #include "mitkResliceMethodProperty.h" #include "mitkKeyEvent.h" // Geometries #include "mitkPlaneGeometry.h" #include "mitkSlicedGeometry3D.h" // Controllers #include "mitkCameraController.h" #include "mitkSliceNavigationController.h" #include "mitkCameraRotationController.h" #include "mitkVtkInteractorCameraController.h" #ifdef MITK_USE_TD_MOUSE #include "mitkTDMouseVtkCameraController.h" #else #include "mitkCameraController.h" #endif #include "mitkVtkLayerController.h" // Events // TODO: INTERACTION_LEGACY #include "mitkEventMapper.h" #include "mitkGlobalInteraction.h" #include "mitkPositionEvent.h" #include "mitkDisplayPositionEvent.h" #include "mitkProperties.h" #include "mitkWeakPointerProperty.h" #include "mitkInteractionConst.h" #include "mitkOverlayManager.h" // VTK #include #include #include #include #include #include #include mitk::BaseRenderer::BaseRendererMapType mitk::BaseRenderer::baseRendererMap; mitk::BaseRenderer* mitk::BaseRenderer::GetInstance(vtkRenderWindow * renWin) { for (BaseRendererMapType::iterator mapit = baseRendererMap.begin(); mapit != baseRendererMap.end(); mapit++) { if ((*mapit).first == renWin) return (*mapit).second; } return NULL; } void mitk::BaseRenderer::AddInstance(vtkRenderWindow* renWin, BaseRenderer* baseRenderer) { if (renWin == NULL || baseRenderer == NULL) return; // ensure that no BaseRenderer is managed twice mitk::BaseRenderer::RemoveInstance(renWin); baseRendererMap.insert(BaseRendererMapType::value_type(renWin, baseRenderer)); } void mitk::BaseRenderer::RemoveInstance(vtkRenderWindow* renWin) { BaseRendererMapType::iterator mapit = baseRendererMap.find(renWin); if (mapit != baseRendererMap.end()) baseRendererMap.erase(mapit); } mitk::BaseRenderer* mitk::BaseRenderer::GetByName(const std::string& name) { for (BaseRendererMapType::iterator mapit = baseRendererMap.begin(); mapit != baseRendererMap.end(); mapit++) { if ((*mapit).second->m_Name == name) return (*mapit).second; } return NULL; } vtkRenderWindow* mitk::BaseRenderer::GetRenderWindowByName(const std::string& name) { for (BaseRendererMapType::iterator mapit = baseRendererMap.begin(); mapit != baseRendererMap.end(); mapit++) { if ((*mapit).second->m_Name == name) return (*mapit).first; } return NULL; } mitk::BaseRenderer::BaseRenderer(const char* name, vtkRenderWindow * renWin, mitk::RenderingManager* rm) : m_RenderWindow(NULL), m_VtkRenderer(NULL), m_MapperID(defaultMapper), m_DataStorage(NULL), m_RenderingManager(rm), m_LastUpdateTime(0), m_CameraController( NULL), m_SliceNavigationController(NULL), m_CameraRotationController(NULL), /*m_Size(),*/ m_Focused(false), m_WorldGeometry(NULL), m_WorldTimeGeometry(NULL), m_CurrentWorldGeometry(NULL), m_CurrentWorldGeometry2D(NULL), m_DisplayGeometry( NULL), m_Slice(0), m_TimeStep(), m_CurrentWorldGeometry2DUpdateTime(), m_DisplayGeometryUpdateTime(), m_TimeStepUpdateTime(), m_WorldGeometryData( NULL), m_DisplayGeometryData(NULL), m_CurrentWorldGeometry2DData(NULL), m_WorldGeometryNode(NULL), m_DisplayGeometryNode(NULL), m_CurrentWorldGeometry2DNode( NULL), m_DisplayGeometryTransformTime(0), m_CurrentWorldGeometry2DTransformTime(0), m_Name(name), /*m_Bounds(),*/m_EmptyWorldGeometry( true), m_DepthPeelingEnabled(true), m_MaxNumberOfPeels(100), m_NumberOfVisibleLODEnabledMappers(0) { m_Bounds[0] = 0; m_Bounds[1] = 0; m_Bounds[2] = 0; m_Bounds[3] = 0; m_Bounds[4] = 0; m_Bounds[5] = 0; if (name != NULL) { m_Name = name; } else { m_Name = "unnamed renderer"; itkWarningMacro(<< "Created unnamed renderer. Bad for serialization. Please choose a name."); } if (renWin != NULL) { m_RenderWindow = renWin; m_RenderWindow->Register(NULL); } else { itkWarningMacro(<< "Created mitkBaseRenderer without vtkRenderWindow present."); } m_Size[0] = 0; m_Size[1] = 0; //instances.insert( this ); //adding this BaseRenderer to the List of all BaseRenderer // TODO: INTERACTION_LEGACY m_RenderingManager->GetGlobalInteraction()->AddFocusElement(this); m_BindDispatcherInteractor = new mitk::BindDispatcherInteractor( GetName() ); WeakPointerProperty::Pointer rendererProp = WeakPointerProperty::New((itk::Object*) this); m_CurrentWorldGeometry2D = mitk::PlaneGeometry::New(); m_CurrentWorldGeometry2DData = mitk::Geometry2DData::New(); m_CurrentWorldGeometry2DData->SetGeometry2D(m_CurrentWorldGeometry2D); m_CurrentWorldGeometry2DNode = mitk::DataNode::New(); m_CurrentWorldGeometry2DNode->SetData(m_CurrentWorldGeometry2DData); m_CurrentWorldGeometry2DNode->GetPropertyList()->SetProperty("renderer", rendererProp); m_CurrentWorldGeometry2DNode->GetPropertyList()->SetProperty("layer", IntProperty::New(1000)); m_CurrentWorldGeometry2DNode->SetProperty("reslice.thickslices", mitk::ResliceMethodProperty::New()); m_CurrentWorldGeometry2DNode->SetProperty("reslice.thickslices.num", mitk::IntProperty::New(1)); m_CurrentWorldGeometry2DTransformTime = m_CurrentWorldGeometry2DNode->GetVtkTransform()->GetMTime(); m_DisplayGeometry = mitk::DisplayGeometry::New(); m_DisplayGeometry->SetWorldGeometry(m_CurrentWorldGeometry2D); m_DisplayGeometryData = mitk::Geometry2DData::New(); m_DisplayGeometryData->SetGeometry2D(m_DisplayGeometry); m_DisplayGeometryNode = mitk::DataNode::New(); m_DisplayGeometryNode->SetData(m_DisplayGeometryData); m_DisplayGeometryNode->GetPropertyList()->SetProperty("renderer", rendererProp); m_DisplayGeometryTransformTime = m_DisplayGeometryNode->GetVtkTransform()->GetMTime(); mitk::SliceNavigationController::Pointer sliceNavigationController = mitk::SliceNavigationController::New("navigation"); sliceNavigationController->SetRenderer(this); sliceNavigationController->ConnectGeometrySliceEvent(this); sliceNavigationController->ConnectGeometryUpdateEvent(this); sliceNavigationController->ConnectGeometryTimeEvent(this, false); m_SliceNavigationController = sliceNavigationController; m_CameraRotationController = mitk::CameraRotationController::New(); m_CameraRotationController->SetRenderWindow(m_RenderWindow); m_CameraRotationController->AcquireCamera(); //if TD Mouse Interaction is activated, then call TDMouseVtkCameraController instead of VtkInteractorCameraController #ifdef MITK_USE_TD_MOUSE m_CameraController = mitk::TDMouseVtkCameraController::New(); #else m_CameraController = mitk::CameraController::New(NULL); #endif m_VtkRenderer = vtkRenderer::New(); if (mitk::VtkLayerController::GetInstance(m_RenderWindow) == NULL) { mitk::VtkLayerController::AddInstance(m_RenderWindow, m_VtkRenderer); mitk::VtkLayerController::GetInstance(m_RenderWindow)->InsertSceneRenderer(m_VtkRenderer); } else mitk::VtkLayerController::GetInstance(m_RenderWindow)->InsertSceneRenderer(m_VtkRenderer); } mitk::BaseRenderer::~BaseRenderer() { if (m_OverlayManager.IsNotNull()) { m_OverlayManager->RemoveBaseRenderer(this); } if (m_VtkRenderer != NULL) { m_VtkRenderer->Delete(); m_VtkRenderer = NULL; } if (m_CameraController.IsNotNull()) m_CameraController->SetRenderer(NULL); m_RenderingManager->GetGlobalInteraction()->RemoveFocusElement(this); mitk::VtkLayerController::RemoveInstance(m_RenderWindow); RemoveAllLocalStorages(); m_DataStorage = NULL; if (m_BindDispatcherInteractor != NULL) { delete m_BindDispatcherInteractor; } if (m_RenderWindow != NULL) { m_RenderWindow->Delete(); m_RenderWindow = NULL; } } void mitk::BaseRenderer::RemoveAllLocalStorages() { this->InvokeEvent(mitk::BaseRenderer::RendererResetEvent()); std::list::iterator it; for (it = m_RegisteredLocalStorageHandlers.begin(); it != m_RegisteredLocalStorageHandlers.end(); it++) (*it)->ClearLocalStorage(this, false); m_RegisteredLocalStorageHandlers.clear(); } void mitk::BaseRenderer::RegisterLocalStorageHandler(mitk::BaseLocalStorageHandler *lsh) { m_RegisteredLocalStorageHandlers.push_back(lsh); } mitk::Dispatcher::Pointer mitk::BaseRenderer::GetDispatcher() const { return m_BindDispatcherInteractor->GetDispatcher(); } -mitk::Point3D mitk::BaseRenderer::Map2DRendererPositionTo3DWorldPosition(Point2D* mousePosition) const +mitk::Point3D mitk::BaseRenderer::Map2DRendererPositionTo3DWorldPosition(const Point2D mousePosition) const { Point2D p_mm; Point3D position; + if (m_MapperID == 1) { - GetDisplayGeometry()->ULDisplayToDisplay(*mousePosition, *mousePosition); - GetDisplayGeometry()->DisplayToWorld(*mousePosition, p_mm); + GetDisplayGeometry()->DisplayToWorld(mousePosition, p_mm); GetDisplayGeometry()->Map(p_mm, position); } else if (m_MapperID == 2) { - GetDisplayGeometry()->ULDisplayToDisplay(*mousePosition, *mousePosition); - PickWorldPoint(*mousePosition, position); + PickWorldPoint(mousePosition, position); } return position; } void mitk::BaseRenderer::UnregisterLocalStorageHandler(mitk::BaseLocalStorageHandler *lsh) { m_RegisteredLocalStorageHandlers.remove(lsh); } void mitk::BaseRenderer::SetDataStorage(DataStorage* storage) { if (storage != NULL) { m_DataStorage = storage; m_BindDispatcherInteractor->SetDataStorage(m_DataStorage); this->Modified(); } } const mitk::BaseRenderer::MapperSlotId mitk::BaseRenderer::defaultMapper = 1; void mitk::BaseRenderer::Paint() { } void mitk::BaseRenderer::Initialize() { } void mitk::BaseRenderer::Resize(int w, int h) { m_Size[0] = w; m_Size[1] = h; if (m_CameraController) m_CameraController->Resize(w, h); //(formerly problematic on windows: vtkSizeBug) GetDisplayGeometry()->SetSizeInDisplayUnits(w, h); } void mitk::BaseRenderer::InitRenderer(vtkRenderWindow* renderwindow) { if (m_RenderWindow != NULL) { m_RenderWindow->Delete(); } m_RenderWindow = renderwindow; if (m_RenderWindow != NULL) { m_RenderWindow->Register(NULL); } RemoveAllLocalStorages(); if (m_CameraController.IsNotNull()) { m_CameraController->SetRenderer(this); } //BUG (#1551) added settings for depth peeling m_RenderWindow->SetAlphaBitPlanes(1); m_VtkRenderer->SetUseDepthPeeling(m_DepthPeelingEnabled); m_VtkRenderer->SetMaximumNumberOfPeels(m_MaxNumberOfPeels); m_VtkRenderer->SetOcclusionRatio(0.1); } void mitk::BaseRenderer::InitSize(int w, int h) { m_Size[0] = w; m_Size[1] = h; GetDisplayGeometry()->SetSizeInDisplayUnits(w, h, false); GetDisplayGeometry()->Fit(); } void mitk::BaseRenderer::SetSlice(unsigned int slice) { if (m_Slice != slice) { m_Slice = slice; if (m_WorldTimeGeometry.IsNotNull()) { SlicedGeometry3D* slicedWorldGeometry = dynamic_cast(m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep).GetPointer()); if (slicedWorldGeometry != NULL) { if (m_Slice >= slicedWorldGeometry->GetSlices()) m_Slice = slicedWorldGeometry->GetSlices() - 1; SetCurrentWorldGeometry2D(slicedWorldGeometry->GetGeometry2D(m_Slice)); SetCurrentWorldGeometry(slicedWorldGeometry); } } else Modified(); } } void mitk::BaseRenderer::SetOverlayManager(itk::SmartPointer overlayManager) { if(overlayManager.IsNull()) return; if(this->m_OverlayManager.IsNotNull()) { if(this->m_OverlayManager.GetPointer() == overlayManager.GetPointer()) { return; } else { this->m_OverlayManager->RemoveBaseRenderer(this); } } this->m_OverlayManager = overlayManager; this->m_OverlayManager->AddBaseRenderer(this); //TODO } itk::SmartPointer mitk::BaseRenderer::GetOverlayManager() { if(this->m_OverlayManager.IsNull()) { m_OverlayManager = mitk::OverlayManager::New(); m_OverlayManager->AddBaseRenderer(this); } return this->m_OverlayManager; } void mitk::BaseRenderer::SetTimeStep(unsigned int timeStep) { if (m_TimeStep != timeStep) { m_TimeStep = timeStep; m_TimeStepUpdateTime.Modified(); if (m_WorldTimeGeometry.IsNotNull()) { if (m_TimeStep >= m_WorldTimeGeometry->CountTimeSteps()) m_TimeStep = m_WorldTimeGeometry->CountTimeSteps() - 1; SlicedGeometry3D* slicedWorldGeometry = dynamic_cast(m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep).GetPointer()); if (slicedWorldGeometry != NULL) { SetCurrentWorldGeometry2D(slicedWorldGeometry->GetGeometry2D(m_Slice)); SetCurrentWorldGeometry(slicedWorldGeometry); } } else Modified(); } } int mitk::BaseRenderer::GetTimeStep(const mitk::BaseData* data) const { if ((data == NULL) || (data->IsInitialized() == false)) { return -1; } return data->GetTimeGeometry()->TimePointToTimeStep(GetTime()); } mitk::ScalarType mitk::BaseRenderer::GetTime() const { if (m_WorldTimeGeometry.IsNull()) { return 0; } else { ScalarType timeInMS = m_WorldTimeGeometry->TimeStepToTimePoint(GetTimeStep()); if (timeInMS == ScalarTypeNumericTraits::NonpositiveMin()) return 0; else return timeInMS; } } void mitk::BaseRenderer::SetWorldTimeGeometry(mitk::TimeGeometry* geometry) { assert(geometry != NULL); itkDebugMacro("setting WorldTimeGeometry to " << geometry); if (m_WorldTimeGeometry != geometry) { if (geometry->GetBoundingBoxInWorld()->GetDiagonalLength2() == 0) return; m_WorldTimeGeometry = geometry; itkDebugMacro("setting WorldTimeGeometry to " << m_WorldTimeGeometry); if (m_TimeStep >= m_WorldTimeGeometry->CountTimeSteps()) m_TimeStep = m_WorldTimeGeometry->CountTimeSteps() - 1; Geometry3D* geometry3d; geometry3d = m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep); SetWorldGeometry3D(geometry3d); } } void mitk::BaseRenderer::SetWorldGeometry3D(mitk::Geometry3D* geometry) { itkDebugMacro("setting WorldGeometry3D to " << geometry); if (m_WorldGeometry != geometry) { if (geometry->GetBoundingBox()->GetDiagonalLength2() == 0) return; m_WorldGeometry = geometry; SlicedGeometry3D* slicedWorldGeometry; slicedWorldGeometry = dynamic_cast(geometry); Geometry2D::Pointer geometry2d; if (slicedWorldGeometry != NULL) { if (m_Slice >= slicedWorldGeometry->GetSlices() && (m_Slice != 0)) m_Slice = slicedWorldGeometry->GetSlices() - 1; geometry2d = slicedWorldGeometry->GetGeometry2D(m_Slice); if (geometry2d.IsNull()) { PlaneGeometry::Pointer plane = mitk::PlaneGeometry::New(); plane->InitializeStandardPlane(slicedWorldGeometry); geometry2d = plane; } SetCurrentWorldGeometry(slicedWorldGeometry); } else { geometry2d = dynamic_cast(geometry); if (geometry2d.IsNull()) { PlaneGeometry::Pointer plane = PlaneGeometry::New(); plane->InitializeStandardPlane(geometry); geometry2d = plane; } SetCurrentWorldGeometry(geometry); } SetCurrentWorldGeometry2D(geometry2d); // calls Modified() } if (m_CurrentWorldGeometry2D.IsNull()) itkWarningMacro("m_CurrentWorldGeometry2D is NULL"); } void mitk::BaseRenderer::SetDisplayGeometry(mitk::DisplayGeometry* geometry2d) { itkDebugMacro("setting DisplayGeometry to " << geometry2d); if (m_DisplayGeometry != geometry2d) { m_DisplayGeometry = geometry2d; m_DisplayGeometryData->SetGeometry2D(m_DisplayGeometry); m_DisplayGeometryUpdateTime.Modified(); Modified(); } } void mitk::BaseRenderer::SetCurrentWorldGeometry2D(mitk::Geometry2D* geometry2d) { if (m_CurrentWorldGeometry2D != geometry2d) { m_CurrentWorldGeometry2D = geometry2d; m_CurrentWorldGeometry2DData->SetGeometry2D(m_CurrentWorldGeometry2D); m_DisplayGeometry->SetWorldGeometry(m_CurrentWorldGeometry2D); m_CurrentWorldGeometry2DUpdateTime.Modified(); Modified(); } } void mitk::BaseRenderer::SendUpdateSlice() { m_DisplayGeometryUpdateTime.Modified(); m_CurrentWorldGeometry2DUpdateTime.Modified(); } void mitk::BaseRenderer::SetCurrentWorldGeometry(mitk::Geometry3D* geometry) { m_CurrentWorldGeometry = geometry; if (geometry == NULL) { m_Bounds[0] = 0; m_Bounds[1] = 0; m_Bounds[2] = 0; m_Bounds[3] = 0; m_Bounds[4] = 0; m_Bounds[5] = 0; m_EmptyWorldGeometry = true; return; } BoundingBox::Pointer boundingBox = m_CurrentWorldGeometry->CalculateBoundingBoxRelativeToTransform(NULL); const BoundingBox::BoundsArrayType& worldBounds = boundingBox->GetBounds(); m_Bounds[0] = worldBounds[0]; m_Bounds[1] = worldBounds[1]; m_Bounds[2] = worldBounds[2]; m_Bounds[3] = worldBounds[3]; m_Bounds[4] = worldBounds[4]; m_Bounds[5] = worldBounds[5]; if (boundingBox->GetDiagonalLength2() <= mitk::eps) m_EmptyWorldGeometry = true; else m_EmptyWorldGeometry = false; } void mitk::BaseRenderer::UpdateOverlays() { if(m_OverlayManager.IsNotNull()) { m_OverlayManager->UpdateOverlays(this); } } void mitk::BaseRenderer::SetGeometry(const itk::EventObject & geometrySendEvent) { const SliceNavigationController::GeometrySendEvent* sendEvent = dynamic_cast(&geometrySendEvent); assert(sendEvent!=NULL); SetWorldTimeGeometry(sendEvent->GetTimeGeometry()); } void mitk::BaseRenderer::UpdateGeometry(const itk::EventObject & geometryUpdateEvent) { const SliceNavigationController::GeometryUpdateEvent* updateEvent = dynamic_cast(&geometryUpdateEvent); if (updateEvent == NULL) return; if (m_CurrentWorldGeometry.IsNotNull()) { SlicedGeometry3D* slicedWorldGeometry = dynamic_cast(m_CurrentWorldGeometry.GetPointer()); if (slicedWorldGeometry) { Geometry2D* geometry2D = slicedWorldGeometry->GetGeometry2D(m_Slice); SetCurrentWorldGeometry2D(geometry2D); // calls Modified() } } } void mitk::BaseRenderer::SetGeometrySlice(const itk::EventObject & geometrySliceEvent) { const SliceNavigationController::GeometrySliceEvent* sliceEvent = dynamic_cast(&geometrySliceEvent); assert(sliceEvent!=NULL); SetSlice(sliceEvent->GetPos()); } void mitk::BaseRenderer::SetGeometryTime(const itk::EventObject & geometryTimeEvent) { const SliceNavigationController::GeometryTimeEvent * timeEvent = dynamic_cast(&geometryTimeEvent); assert(timeEvent!=NULL); SetTimeStep(timeEvent->GetPos()); } const double* mitk::BaseRenderer::GetBounds() const { return m_Bounds; } void mitk::BaseRenderer::MousePressEvent(mitk::MouseEvent *me) { //set the Focus on the renderer /*bool success =*/m_RenderingManager->GetGlobalInteraction()->SetFocus(this); /* if (! success) mitk::StatusBar::GetInstance()->DisplayText("Warning! from mitkBaseRenderer.cpp: Couldn't focus this BaseRenderer!"); */ //if (m_CameraController) //{ // if(me->GetButtonState()!=512) // provisorisch: Ctrl nicht durchlassen. Bald wird aus m_CameraController eine StateMachine // m_CameraController->MousePressEvent(me); //} if (m_MapperID == 1) { Point2D p(me->GetDisplayPosition()); Point2D p_mm; Point3D position; GetDisplayGeometry()->ULDisplayToDisplay(p, p); GetDisplayGeometry()->DisplayToWorld(p, p_mm); GetDisplayGeometry()->Map(p_mm, position); mitk::PositionEvent event(this, me->GetType(), me->GetButton(), me->GetButtonState(), mitk::Key_unknown, p, position); mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction()); } else if (m_MapperID > 1) //==2 for 3D and ==5 for stencil { Point2D p(me->GetDisplayPosition()); GetDisplayGeometry()->ULDisplayToDisplay(p, p); me->SetDisplayPosition(p); mitk::EventMapper::MapEvent(me, m_RenderingManager->GetGlobalInteraction()); } } void mitk::BaseRenderer::MouseReleaseEvent(mitk::MouseEvent *me) { //if (m_CameraController) //{ // if(me->GetButtonState()!=512) // provisorisch: Ctrl nicht durchlassen. Bald wird aus m_CameraController eine StateMachine // m_CameraController->MouseReleaseEvent(me); //} if (m_MapperID == 1) { Point2D p(me->GetDisplayPosition()); Point2D p_mm; Point3D position; GetDisplayGeometry()->ULDisplayToDisplay(p, p); GetDisplayGeometry()->DisplayToWorld(p, p_mm); GetDisplayGeometry()->Map(p_mm, position); mitk::PositionEvent event(this, me->GetType(), me->GetButton(), me->GetButtonState(), mitk::Key_unknown, p, position); mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction()); } else if (m_MapperID == 2) { Point2D p(me->GetDisplayPosition()); GetDisplayGeometry()->ULDisplayToDisplay(p, p); me->SetDisplayPosition(p); mitk::EventMapper::MapEvent(me, m_RenderingManager->GetGlobalInteraction()); } } void mitk::BaseRenderer::MouseMoveEvent(mitk::MouseEvent *me) { //if (m_CameraController) //{ // if((me->GetButtonState()<=512) || (me->GetButtonState()>=516))// provisorisch: Ctrl nicht durchlassen. Bald wird aus m_CameraController eine StateMachine // m_CameraController->MouseMoveEvent(me); //} if (m_MapperID == 1) { Point2D p(me->GetDisplayPosition()); Point2D p_mm; Point3D position; GetDisplayGeometry()->ULDisplayToDisplay(p, p); GetDisplayGeometry()->DisplayToWorld(p, p_mm); GetDisplayGeometry()->Map(p_mm, position); mitk::PositionEvent event(this, me->GetType(), me->GetButton(), me->GetButtonState(), mitk::Key_unknown, p, position); mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction()); } else if (m_MapperID == 2) { Point2D p(me->GetDisplayPosition()); GetDisplayGeometry()->ULDisplayToDisplay(p, p); me->SetDisplayPosition(p); mitk::EventMapper::MapEvent(me, m_RenderingManager->GetGlobalInteraction()); } } void mitk::BaseRenderer::PickWorldPoint(const mitk::Point2D& displayPoint, mitk::Point3D& worldPoint) const { mitk::Point2D worldPoint2D; GetDisplayGeometry()->DisplayToWorld(displayPoint, worldPoint2D); GetDisplayGeometry()->Map(worldPoint2D, worldPoint); } void mitk::BaseRenderer::WheelEvent(mitk::WheelEvent * we) { if (m_MapperID == 1) { Point2D p(we->GetDisplayPosition()); Point2D p_mm; Point3D position; GetDisplayGeometry()->ULDisplayToDisplay(p, p); GetDisplayGeometry()->DisplayToWorld(p, p_mm); GetDisplayGeometry()->Map(p_mm, position); mitk::PositionEvent event(this, we->GetType(), we->GetButton(), we->GetButtonState(), mitk::Key_unknown, p, position); mitk::EventMapper::MapEvent(we, m_RenderingManager->GetGlobalInteraction()); mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction()); } else if (m_MapperID == 2) { Point2D p(we->GetDisplayPosition()); GetDisplayGeometry()->ULDisplayToDisplay(p, p); we->SetDisplayPosition(p); mitk::EventMapper::MapEvent(we, m_RenderingManager->GetGlobalInteraction()); } } void mitk::BaseRenderer::KeyPressEvent(mitk::KeyEvent *ke) { if (m_MapperID == 1) { Point2D p(ke->GetDisplayPosition()); Point2D p_mm; Point3D position; GetDisplayGeometry()->ULDisplayToDisplay(p, p); GetDisplayGeometry()->DisplayToWorld(p, p_mm); GetDisplayGeometry()->Map(p_mm, position); mitk::KeyEvent event(this, ke->GetType(), ke->GetButton(), ke->GetButtonState(), ke->GetKey(), ke->GetText(), p); mitk::EventMapper::MapEvent(&event, m_RenderingManager->GetGlobalInteraction()); } else if (m_MapperID == 2) { Point2D p(ke->GetDisplayPosition()); GetDisplayGeometry()->ULDisplayToDisplay(p, p); ke->SetDisplayPosition(p); mitk::EventMapper::MapEvent(ke, m_RenderingManager->GetGlobalInteraction()); } } void mitk::BaseRenderer::DrawOverlayMouse(mitk::Point2D& itkNotUsed(p2d)) { MITK_INFO<<"BaseRenderer::DrawOverlayMouse()- should be inconcret implementation OpenGLRenderer."<RequestUpdate(this->m_RenderWindow); } void mitk::BaseRenderer::ForceImmediateUpdate() { m_RenderingManager->ForceImmediateUpdate(this->m_RenderWindow); } unsigned int mitk::BaseRenderer::GetNumberOfVisibleLODEnabledMappers() const { return m_NumberOfVisibleLODEnabledMappers; } mitk::RenderingManager* mitk::BaseRenderer::GetRenderingManager() const { return m_RenderingManager.GetPointer(); } /*! Sets the new Navigation controller */ void mitk::BaseRenderer::SetSliceNavigationController(mitk::SliceNavigationController *SlicenavigationController) { if (SlicenavigationController == NULL) return; //disconnect old from globalinteraction m_RenderingManager->GetGlobalInteraction()->RemoveListener(SlicenavigationController); //copy worldgeometry SlicenavigationController->SetInputWorldTimeGeometry(SlicenavigationController->GetCreatedWorldGeometry()); SlicenavigationController->Update(); //set new m_SliceNavigationController = SlicenavigationController; m_SliceNavigationController->SetRenderer(this); if (m_SliceNavigationController.IsNotNull()) { m_SliceNavigationController->ConnectGeometrySliceEvent(this); m_SliceNavigationController->ConnectGeometryUpdateEvent(this); m_SliceNavigationController->ConnectGeometryTimeEvent(this, false); } } /*! Sets the new camera controller and deletes the vtkRenderWindowInteractor in case of the VTKInteractorCameraController */ void mitk::BaseRenderer::SetCameraController(CameraController* cameraController) { mitk::VtkInteractorCameraController::Pointer vtkInteractorCameraController = dynamic_cast(cameraController); if (vtkInteractorCameraController.IsNotNull()) MITK_INFO<<"!!!WARNING!!!: RenderWindow interaction events are no longer handled via CameraController (See Bug #954)."<SetRenderer(NULL); m_CameraController = NULL; m_CameraController = cameraController; m_CameraController->SetRenderer(this); } void mitk::BaseRenderer::PrintSelf(std::ostream& os, itk::Indent indent) const { os << indent << " MapperID: " << m_MapperID << std::endl; os << indent << " Slice: " << m_Slice << std::endl; os << indent << " TimeStep: " << m_TimeStep << std::endl; os << indent << " WorldGeometry: "; if (m_WorldGeometry.IsNull()) os << "NULL" << std::endl; else m_WorldGeometry->Print(os, indent); os << indent << " CurrentWorldGeometry2D: "; if (m_CurrentWorldGeometry2D.IsNull()) os << "NULL" << std::endl; else m_CurrentWorldGeometry2D->Print(os, indent); os << indent << " CurrentWorldGeometry2DUpdateTime: " << m_CurrentWorldGeometry2DUpdateTime << std::endl; os << indent << " CurrentWorldGeometry2DTransformTime: " << m_CurrentWorldGeometry2DTransformTime << std::endl; os << indent << " DisplayGeometry: "; if (m_DisplayGeometry.IsNull()) os << "NULL" << std::endl; else m_DisplayGeometry->Print(os, indent); os << indent << " DisplayGeometryTransformTime: " << m_DisplayGeometryTransformTime << std::endl; Superclass::PrintSelf(os, indent); } void mitk::BaseRenderer::SetDepthPeelingEnabled(bool enabled) { m_DepthPeelingEnabled = enabled; m_VtkRenderer->SetUseDepthPeeling(enabled); } void mitk::BaseRenderer::SetMaxNumberOfPeels(int maxNumber) { m_MaxNumberOfPeels = maxNumber; m_VtkRenderer->SetMaximumNumberOfPeels(maxNumber); } diff --git a/Core/Code/Rendering/mitkBaseRenderer.h b/Core/Code/Rendering/mitkBaseRenderer.h index 27049d754b..9b04ed28a7 100644 --- a/Core/Code/Rendering/mitkBaseRenderer.h +++ b/Core/Code/Rendering/mitkBaseRenderer.h @@ -1,644 +1,644 @@ /*=================================================================== 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 BASERENDERER_H_HEADER_INCLUDED_C1CCA0F4 #define BASERENDERER_H_HEADER_INCLUDED_C1CCA0F4 #include "mitkDataStorage.h" #include "mitkGeometry2D.h" #include "mitkTimeGeometry.h" #include "mitkDisplayGeometry.h" #include "mitkGeometry2DData.h" #include "mitkCameraController.h" #include "mitkDisplayPositionEvent.h" #include "mitkWheelEvent.h" //#include "mitkMapper.h" #include "mitkSliceNavigationController.h" #include "mitkCameraController.h" #include "mitkCameraRotationController.h" #include "mitkBindDispatcherInteractor.h" #include "mitkDispatcher.h" #include #include #include #include // DEPRECATED #include namespace mitk { class NavigationController; class SliceNavigationController; class CameraRotationController; class CameraController; class DataStorage; class Mapper; class BaseLocalStorageHandler; class OverlayManager; //##Documentation //## @brief Organizes the rendering process //## //## Organizes the rendering process. A Renderer contains a reference to a //## DataStorage and asks the mappers of the data objects to render //## the data into the renderwindow it is associated to. //## //## \#Render() checks if rendering is currently allowed by calling //## RenderWindow::PrepareRendering(). Initialization of a rendering context //## can also be performed in this method. //## //## The actual rendering code has been moved to \#Repaint() //## Both \#Repaint() and \#Update() are declared protected now. //## //## Note: Separation of the Repaint and Update processes (rendering vs //## creating a vtk prop tree) still needs to be worked on. The whole //## rendering process also should be reworked to use VTK based classes for //## both 2D and 3D rendering. //## @ingroup Renderer class MITK_CORE_EXPORT BaseRenderer: public itk::Object { public: typedef std::map BaseRendererMapType; static BaseRendererMapType baseRendererMap; static BaseRenderer* GetInstance(vtkRenderWindow * renWin); static void AddInstance(vtkRenderWindow* renWin, BaseRenderer* baseRenderer); static void RemoveInstance(vtkRenderWindow* renWin); static BaseRenderer* GetByName(const std::string& name); static vtkRenderWindow* GetRenderWindowByName(const std::string& name); #pragma GCC visibility push(default) itkEventMacro( RendererResetEvent, itk::AnyEvent ); #pragma GCC visibility pop /** Standard class typedefs. */ mitkClassMacro(BaseRenderer, itk::Object); BaseRenderer(const char* name = NULL, vtkRenderWindow * renWin = NULL, mitk::RenderingManager* rm = NULL); //##Documentation //## @brief MapperSlotId defines which kind of mapper (e.g., 2D or 3D) shoud be used. typedef int MapperSlotId; enum StandardMapperSlot { Standard2D = 1, Standard3D = 2 }; virtual void SetDataStorage(DataStorage* storage); ///< set the datastorage that will be used for rendering //##Documentation //## return the DataStorage that is used for rendering virtual DataStorage::Pointer GetDataStorage() const { return m_DataStorage.GetPointer(); } //##Documentation //## @brief Access the RenderWindow into which this renderer renders. vtkRenderWindow* GetRenderWindow() const { return m_RenderWindow; } vtkRenderer* GetVtkRenderer() const { return m_VtkRenderer; } //##Documentation //## @brief Returns the Dispatcher which handles Events for this BaseRenderer Dispatcher::Pointer GetDispatcher() const; //##Documentation //## @brief Default mapper id to use. static const MapperSlotId defaultMapper; //##Documentation //## @brief Do the rendering and flush the result. virtual void Paint(); //##Documentation //## @brief Initialize the RenderWindow. Should only be called from RenderWindow. virtual void Initialize(); //##Documentation //## @brief Called to inform the renderer that the RenderWindow has been resized. virtual void Resize(int w, int h); //##Documentation //## @brief Initialize the renderer with a RenderWindow (@a renderwindow). virtual void InitRenderer(vtkRenderWindow* renderwindow); //##Documentation //## @brief Set the initial size. Called by RenderWindow after it has become //## visible for the first time. virtual void InitSize(int w, int h); //##Documentation //## @brief Draws a point on the widget. //## Should be used during conferences to show the position of the remote mouse virtual void DrawOverlayMouse(Point2D& p2d); //##Documentation //## @brief Set/Get the WorldGeometry (m_WorldGeometry) for 3D and 2D rendering, that describing the //## (maximal) area to be rendered. //## //## Depending of the type of the passed Geometry3D more or less information can be extracted: //## \li if it is a Geometry2D (which is a sub-class of Geometry3D), m_CurrentWorldGeometry2D is //## also set to point to it. m_WorldTimeGeometry is set to NULL. //## \li if it is a TimeGeometry, m_WorldTimeGeometry is also set to point to it. //## If m_WorldTimeGeometry contains instances of SlicedGeometry3D, m_CurrentWorldGeometry2D is set to //## one of geometries stored in the SlicedGeometry3D according to the value of m_Slice; otherwise //## a PlaneGeometry describing the top of the bounding-box of the Geometry3D is set as the //## m_CurrentWorldGeometry2D. //## \li otherwise a PlaneGeometry describing the top of the bounding-box of the Geometry3D //## is set as the m_CurrentWorldGeometry2D. m_WorldTimeGeometry is set to NULL. //## @todo add calculation of PlaneGeometry describing the top of the bounding-box of the Geometry3D //## when the passed Geometry3D is not sliced. //## \sa m_WorldGeometry //## \sa m_WorldTimeGeometry //## \sa m_CurrentWorldGeometry2D virtual void SetWorldGeometry3D(Geometry3D* geometry); virtual void SetWorldTimeGeometry(mitk::TimeGeometry* geometry); /** * \deprecatedSince{2013_09} Please use TimeGeometry instead of TimeSlicedGeometry. For more information see http://www.mitk.org/Development/Refactoring%20of%20the%20Geometry%20Classes%20-%20Part%201 */ DEPRECATED(void SetWorldGeometry3D(TimeSlicedGeometry* geometry)); itkGetConstObjectMacro(WorldGeometry, Geometry3D) itkGetObjectMacro(WorldGeometry, Geometry3D) itkGetConstObjectMacro(WorldTimeGeometry, TimeGeometry) itkGetObjectMacro(WorldTimeGeometry, TimeGeometry) //##Documentation //## @brief Get the current 3D-worldgeometry (m_CurrentWorldGeometry) used for 3D-rendering itkGetConstObjectMacro(CurrentWorldGeometry, Geometry3D) //##Documentation //## @brief Get the current 2D-worldgeometry (m_CurrentWorldGeometry2D) used for 2D-rendering itkGetConstObjectMacro(CurrentWorldGeometry2D, Geometry2D) //##Documentation //## Calculates the bounds of the DataStorage (if it contains any valid data), //## creates a geometry from these bounds and sets it as world geometry of the renderer. //## //## Call this method to re-initialize the renderer to the current DataStorage //## (e.g. after loading an additional dataset), to ensure that the view is //## aligned correctly. //## \warn This is not implemented yet. virtual bool SetWorldGeometryToDataStorageBounds() { return false; } //##Documentation //## @brief Set/Get the DisplayGeometry (for 2D rendering) //## //## The DisplayGeometry describes which part of the Geometry2D m_CurrentWorldGeometry2D //## is displayed. virtual void SetDisplayGeometry(DisplayGeometry* geometry2d); itkGetConstObjectMacro(DisplayGeometry, DisplayGeometry) itkGetObjectMacro(DisplayGeometry, DisplayGeometry) //##Documentation //## @brief Set/Get m_Slice which defines together with m_TimeStep the 2D geometry //## stored in m_WorldTimeGeometry used as m_CurrentWorldGeometry2D //## //## \sa m_Slice virtual void SetSlice(unsigned int slice); //##Documentation //## @brief Sets an OverlayManager which is used to add various Overlays to this //## renderer. If an OverlayManager was already set it will be overwritten. void SetOverlayManager(itk::SmartPointer overlayManager); //##Documentation //## @brief Get the OverlayManager registered with this renderer //## if none was set, it will be created at this point. itk::SmartPointer GetOverlayManager(); itkGetConstMacro(Slice, unsigned int) //##Documentation //## @brief Set/Get m_TimeStep which defines together with m_Slice the 2D geometry //## stored in m_WorldTimeGeometry used as m_CurrentWorldGeometry2D //## //## \sa m_TimeStep virtual void SetTimeStep(unsigned int timeStep); itkGetConstMacro(TimeStep, unsigned int) //##Documentation //## @brief Get the time-step of a BaseData object which //## exists at the time of the currently displayed content //## //## Returns -1 or mitk::BaseData::m_TimeSteps if there //## is no data at the current time. //## \sa GetTimeStep, m_TimeStep int GetTimeStep(const BaseData* data) const; //##Documentation //## @brief Get the time in ms of the currently displayed content //## //## \sa GetTimeStep, m_TimeStep ScalarType GetTime() const; //##Documentation //## @brief SetWorldGeometry is called according to the geometrySliceEvent, //## which is supposed to be a SliceNavigationController::GeometrySendEvent virtual void SetGeometry(const itk::EventObject & geometrySliceEvent); //##Documentation //## @brief UpdateWorldGeometry is called to re-read the 2D geometry from the //## slice navigation controller virtual void UpdateGeometry(const itk::EventObject & geometrySliceEvent); //##Documentation //## @brief SetSlice is called according to the geometrySliceEvent, //## which is supposed to be a SliceNavigationController::GeometrySliceEvent virtual void SetGeometrySlice(const itk::EventObject & geometrySliceEvent); //##Documentation //## @brief SetTimeStep is called according to the geometrySliceEvent, //## which is supposed to be a SliceNavigationController::GeometryTimeEvent virtual void SetGeometryTime(const itk::EventObject & geometryTimeEvent); //##Documentation //## @brief Get a data object containing the DisplayGeometry (for 2D rendering) itkGetObjectMacro(DisplayGeometryData, Geometry2DData) //##Documentation //## @brief Get a data object containing the WorldGeometry (for 2D rendering) itkGetObjectMacro(WorldGeometryData, Geometry2DData) //##Documentation //## @brief Get a DataNode pointing to a data object containing the WorldGeometry (3D and 2D rendering) itkGetObjectMacro(WorldGeometryNode, DataNode) //##Documentation //## @brief Get a DataNode pointing to a data object containing the DisplayGeometry (for 2D rendering) itkGetObjectMacro(DisplayGeometryNode, DataNode) //##Documentation //## @brief Get a DataNode pointing to a data object containing the current 2D-worldgeometry m_CurrentWorldGeometry2D (for 2D rendering) itkGetObjectMacro(CurrentWorldGeometry2DNode, DataNode) //##Documentation //## @brief Sets timestamp of CurrentWorldGeometry2D and DisplayGeometry and forces so reslicing in that renderwindow void SendUpdateSlice(); //##Documentation //## @brief Get timestamp of last call of SetCurrentWorldGeometry2D unsigned long GetCurrentWorldGeometry2DUpdateTime() { return m_CurrentWorldGeometry2DUpdateTime; } //##Documentation //## @brief Get timestamp of last call of SetDisplayGeometry unsigned long GetDisplayGeometryUpdateTime() { return m_CurrentWorldGeometry2DUpdateTime; } //##Documentation //## @brief Get timestamp of last change of current TimeStep unsigned long GetTimeStepUpdateTime() { return m_TimeStepUpdateTime; } //##Documentation //## @brief Perform a picking: find the x,y,z world coordinate of a //## display x,y coordinate. //## @warning Has to be overwritten in subclasses for the 3D-case. //## //## Implemented here only for 2D-rendering by using //## m_DisplayGeometry virtual void PickWorldPoint(const Point2D& diplayPosition, Point3D& worldPosition) const; /** \brief Determines the object (mitk::DataNode) closest to the current * position by means of picking * * \warning Implementation currently empty for 2D rendering; intended to be * implemented for 3D renderers */ virtual DataNode* PickObject(const Point2D& /*displayPosition*/, Point3D& /*worldPosition*/) const { return NULL; } //##Documentation //## @brief Get the MapperSlotId to use. itkGetMacro(MapperID, MapperSlotId) itkGetConstMacro(MapperID, MapperSlotId) //##Documentation //## @brief Set the MapperSlotId to use. itkSetMacro(MapperID, MapperSlotId) //##Documentation //## @brief Has the renderer the focus? itkGetMacro(Focused, bool) //##Documentation //## @brief Tell the renderer that it is focused. The caller is responsible for focus management, //## not the renderer itself. itkSetMacro(Focused, bool) //##Documentation //## @brief Sets whether depth peeling is enabled or not void SetDepthPeelingEnabled(bool enabled); //##Documentation //## @brief Sets maximal number of peels void SetMaxNumberOfPeels(int maxNumber); itkGetMacro(Size, int*) void SetSliceNavigationController(SliceNavigationController* SlicenavigationController); void SetCameraController(CameraController* cameraController); itkGetObjectMacro(CameraController, CameraController) itkGetObjectMacro(SliceNavigationController, SliceNavigationController) itkGetObjectMacro(CameraRotationController, CameraRotationController) itkGetMacro(EmptyWorldGeometry, bool) //##Documentation //## @brief Mouse event dispatchers //## @note for internal use only. preliminary. virtual void MousePressEvent(MouseEvent*); //##Documentation //## @brief Mouse event dispatchers //## @note for internal use only. preliminary. virtual void MouseReleaseEvent(MouseEvent*); //##Documentation //## @brief Mouse event dispatchers //## @note for internal use only. preliminary. virtual void MouseMoveEvent(MouseEvent*); //##Documentation //## @brief Wheel event dispatcher //## @note for internal use only. preliminary. virtual void WheelEvent(mitk::WheelEvent* we); //##Documentation //## @brief Key event dispatcher //## @note for internal use only. preliminary. virtual void KeyPressEvent(KeyEvent*); //##Documentation //## @brief get the name of the Renderer //## @note const char * GetName() const { return m_Name.c_str(); } //##Documentation //## @brief get the x_size of the RendererWindow //## @note int GetSizeX() const { return m_Size[0]; } //##Documentation //## @brief get the y_size of the RendererWindow //## @note int GetSizeY() const { return m_Size[1]; } const double* GetBounds() const; void RequestUpdate(); void ForceImmediateUpdate(); /** Returns number of mappers which are visible and have level-of-detail * rendering enabled */ unsigned int GetNumberOfVisibleLODEnabledMappers() const; ///** //* \brief Setter for the RenderingManager that handles this instance of BaseRenderer //*/ //void SetRenderingManager( mitk::RenderingManager* ); /** * \brief Getter for the RenderingManager that handles this instance of BaseRenderer */ virtual mitk::RenderingManager* GetRenderingManager() const; /** * \brief Provides (1) world coordinates for a given mouse position and (2) * translates mousePosition to Display coordinates */ - virtual Point3D Map2DRendererPositionTo3DWorldPosition(Point2D* mousePosition) const; + virtual Point3D Map2DRendererPositionTo3DWorldPosition(const Point2D mousePosition) const; protected: virtual ~BaseRenderer(); //##Documentation //## @brief Call update of all mappers. To be implemented in subclasses. virtual void Update() = 0; vtkRenderWindow* m_RenderWindow; vtkRenderer* m_VtkRenderer; //##Documentation //## @brief MapperSlotId to use. Defines which kind of mapper (e.g., 2D or 3D) shoud be used. MapperSlotId m_MapperID; //##Documentation //## @brief The DataStorage that is used for rendering. DataStorage::Pointer m_DataStorage; //##Documentation //## @brief The RenderingManager that manages this instance RenderingManager::Pointer m_RenderingManager; //##Documentation //## @brief Timestamp of last call of Update(). unsigned long m_LastUpdateTime; //##Documentation //## @brief CameraController for 3D rendering //## @note preliminary. CameraController::Pointer m_CameraController; SliceNavigationController::Pointer m_SliceNavigationController; CameraRotationController::Pointer m_CameraRotationController; //##Documentation //## @brief Size of the RenderWindow. int m_Size[2]; //##Documentation //## @brief Contains whether the renderer that it is focused. The caller of //## SetFocused is responsible for focus management, not the renderer itself. //## is doubled because of mitk::FocusManager in GlobalInteraction!!! (ingmar) bool m_Focused; //##Documentation //## @brief Sets m_CurrentWorldGeometry2D virtual void SetCurrentWorldGeometry2D(Geometry2D* geometry2d); //##Documentation //## @brief Sets m_CurrentWorldGeometry virtual void SetCurrentWorldGeometry(Geometry3D* geometry); //##Documentation //## @brief This method is called during the rendering process to update or render the Overlays //## which are stored in the OverlayManager void UpdateOverlays(); private: //##Documentation //## Pointer to the worldgeometry, describing the maximal area to be rendered //## (3D as well as 2D). //## It is const, since we are not allowed to change it (it may be taken //## directly from the geometry of an image-slice and thus it would be //## very strange when suddenly the image-slice changes its geometry). //## \sa SetWorldGeometry Geometry3D::Pointer m_WorldGeometry; itk::SmartPointer m_OverlayManager; //##Documentation //## m_WorldTimeGeometry is set by SetWorldGeometry if the passed Geometry3D is a //## TimeGeometry (or a sub-class of it). If it contains instances of SlicedGeometry3D, //## m_Slice and m_TimeStep (set via SetSlice and SetTimeStep, respectively) define //## which 2D geometry stored in m_WorldTimeGeometry (if available) //## is used as m_CurrentWorldGeometry2D. //## \sa m_CurrentWorldGeometry2D TimeGeometry::Pointer m_WorldTimeGeometry; //##Documentation //## Pointer to the current 3D-worldgeometry. Geometry3D::Pointer m_CurrentWorldGeometry; //##Documentation //## Pointer to the current 2D-worldgeometry. The 2D-worldgeometry //## describes the maximal area (2D manifold) to be rendered in case we //## are doing 2D-rendering. More precisely, a subpart of this according //## to m_DisplayGeometry is displayed. //## It is const, since we are not allowed to change it (it may be taken //## directly from the geometry of an image-slice and thus it would be //## very strange when suddenly the image-slice changes its geometry). Geometry2D::Pointer m_CurrentWorldGeometry2D; //##Documentation //## Pointer to the displaygeometry. The displaygeometry describes the //## geometry of the \em visible area in the window controlled by the renderer //## in case we are doing 2D-rendering. //## It is const, since we are not allowed to change it. DisplayGeometry::Pointer m_DisplayGeometry; //##Documentation //## Defines together with m_Slice which 2D geometry stored in m_WorldTimeGeometry //## is used as m_CurrentWorldGeometry2D: m_WorldTimeGeometry->GetGeometry2D(m_Slice, m_TimeStep). //## \sa m_WorldTimeGeometry unsigned int m_Slice; //##Documentation //## Defines together with m_TimeStep which 2D geometry stored in m_WorldTimeGeometry //## is used as m_CurrentWorldGeometry2D: m_WorldTimeGeometry->GetGeometry2D(m_Slice, m_TimeStep). //## \sa m_WorldTimeGeometry unsigned int m_TimeStep; //##Documentation //## @brief timestamp of last call of SetWorldGeometry itk::TimeStamp m_CurrentWorldGeometry2DUpdateTime; //##Documentation //## @brief timestamp of last call of SetDisplayGeometry itk::TimeStamp m_DisplayGeometryUpdateTime; //##Documentation //## @brief timestamp of last change of the current time step itk::TimeStamp m_TimeStepUpdateTime; //##Documentation //## @brief Helper class which establishes connection between Interactors and Dispatcher via a common DataStorage. BindDispatcherInteractor* m_BindDispatcherInteractor; protected: virtual void PrintSelf(std::ostream& os, itk::Indent indent) const; //##Documentation //## Data object containing the m_WorldGeometry defined above. Geometry2DData::Pointer m_WorldGeometryData; //##Documentation //## Data object containing the m_DisplayGeometry defined above. Geometry2DData::Pointer m_DisplayGeometryData; //##Documentation //## Data object containing the m_CurrentWorldGeometry2D defined above. Geometry2DData::Pointer m_CurrentWorldGeometry2DData; //##Documentation //## DataNode objects containing the m_WorldGeometryData defined above. DataNode::Pointer m_WorldGeometryNode; //##Documentation //## DataNode objects containing the m_DisplayGeometryData defined above. DataNode::Pointer m_DisplayGeometryNode; //##Documentation //## DataNode objects containing the m_CurrentWorldGeometry2DData defined above. DataNode::Pointer m_CurrentWorldGeometry2DNode; //##Documentation //## @brief test only unsigned long m_DisplayGeometryTransformTime; //##Documentation //## @brief test only unsigned long m_CurrentWorldGeometry2DTransformTime; std::string m_Name; double m_Bounds[6]; bool m_EmptyWorldGeometry; bool m_DepthPeelingEnabled; int m_MaxNumberOfPeels; typedef std::set LODEnabledMappersType; /** Number of mappers which are visible and have level-of-detail * rendering enabled */ unsigned int m_NumberOfVisibleLODEnabledMappers; // Local Storage Handling for mappers protected: std::list m_RegisteredLocalStorageHandlers; public: void RemoveAllLocalStorages(); void RegisterLocalStorageHandler(mitk::BaseLocalStorageHandler *lsh); void UnregisterLocalStorageHandler(mitk::BaseLocalStorageHandler *lsh); }; } // namespace mitk #endif /* BASERENDERER_H_HEADER_INCLUDED_C1CCA0F4 */ diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index b5d08c751e..4d6b3bac3f 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,188 +1,189 @@ # tests with no extra command line parameter set(MODULE_TESTS # IMPORTANT: If you plan to deactivate / comment out a test please write a bug number to the commented out line of code. # # Example: #mitkMyTest #this test is commented out because of bug 12345 # # It is important that the bug is open and that the test will be activated again before the bug is closed. This assures that # no test is forgotten after it was commented out. If there is no bug for your current problem, please add a new one and # mark it as critical. ################## DISABLED TESTS ################################################# #mitkAbstractTransformGeometryTest.cpp #seems as tested class mitkExternAbstractTransformGeometry doesnt exist any more #mitkStateMachineContainerTest.cpp #rewrite test, indirect since no longer exported Bug 14529 #mitkRegistrationBaseTest.cpp #tested class mitkRegistrationBase doesn't exist any more #mitkSegmentationInterpolationTest.cpp #file doesn't exist! #mitkPipelineSmartPointerCorrectnessTest.cpp #file doesn't exist! #mitkITKThreadingTest.cpp #test outdated because itk::Semaphore was removed from ITK #mitkAbstractTransformPlaneGeometryTest.cpp #mitkVtkAbstractTransformPlaneGeometry doesn't exist any more #mitkTestUtilSharedLibrary.cpp #Linker problem with this test... #mitkTextOverlay2DSymbolsRenderingTest.cpp #Implementation of the tested feature is not finished yet. Ask Christoph or see bug 15104 for details. ################# RUNNING TESTS ################################################### mitkAccessByItkTest.cpp mitkCoreObjectFactoryTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkDispatcherTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry2DTest.cpp mitkGeometry3DTest.cpp mitkGeometry3DEqualTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageEqualTest.cpp mitkImageDataItemTest.cpp mitkImageGeneratorTest.cpp mitkIOUtilTest.cpp mitkBaseDataTest.cpp mitkImportItkImageTest.cpp mitkGrabItkImageMemoryTest.cpp mitkInstantiateAccessFunctionTest.cpp mitkInteractorTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp mitkPointSetEqualTest.cpp mitkPointSetFileIOTest.cpp mitkPointSetTest.cpp mitkPointSetWriterTest.cpp mitkPointSetReaderTest.cpp mitkPointSetInteractorTest.cpp + mitkPointSetDataInteractorTest.cpp mitkPropertyTest.cpp mitkPropertyListTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceEqualTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp mitkStepperTest.cpp itkTotalVariationDenoisingImageFilterTest.cpp mitkRenderingManagerTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp mitkVectorTest.cpp mitkClippedSurfaceBoundsCalculatorTest.cpp mitkExceptionTest.cpp mitkExtractSliceFilterTest.cpp mitkLogTest.cpp mitkImageDimensionConverterTest.cpp mitkLoggingAdapterTest.cpp mitkUIDGeneratorTest.cpp mitkShaderRepositoryTest.cpp mitkPlanePositionManagerTest.cpp mitkAffineTransformBaseTest.cpp mitkPropertyAliasesTest.cpp mitkPropertyDescriptionsTest.cpp mitkPropertyExtensionsTest.cpp mitkPropertyFiltersTest.cpp mitkTinyXMLTest.cpp mitkRawImageFileReaderTest.cpp mitkInteractionEventTest.cpp mitkLookupTableTest.cpp mitkSTLFileReaderTest.cpp ) # test with image filename as an extra command line parameter set(MODULE_IMAGE_TESTS mitkImageTimeSelectorTest.cpp #only runs on images mitkImageAccessorTest.cpp #only runs on images mitkDataNodeFactoryTest.cpp #runs on all types of data ) set(MODULE_SURFACE_TESTS mitkSurfaceVtkWriterTest.cpp #only runs on surfaces mitkDataNodeFactoryTest.cpp #runs on all types of data ) # list of images for which the tests are run set(MODULE_TESTIMAGES US4DCyl.nrrd Pic3D.nrrd Pic2DplusT.nrrd BallBinary30x30x30.nrrd Png2D-bw.png ) set(MODULE_TESTSURFACES binary.stl ball.stl ) set(MODULE_CUSTOM_TESTS mitkDataStorageTest.cpp mitkDataNodeTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkEventMapperTest.cpp mitkEventConfigTest.cpp mitkNodeDependentPointSetInteractorTest.cpp mitkStateMachineFactoryTest.cpp mitkPointSetLocaleTest.cpp mitkImageTest.cpp mitkImageWriterTest.cpp mitkImageVtkMapper2DTest.cpp mitkImageVtkMapper2DLevelWindowTest.cpp mitkImageVtkMapper2DOpacityTest.cpp mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp mitkImageVtkMapper2DColorTest.cpp mitkImageVtkMapper2DSwivelTest.cpp mitkImageVtkMapper2DTransferFunctionTest.cpp mitkImageVtkMapper2DLookupTableTest.cpp mitkSurfaceVtkMapper3DTest mitkSurfaceVtkMapper3DTexturedSphereTest.cpp mitkSurfaceGLMapper2DColorTest.cpp mitkSurfaceGLMapper2DOpacityTest.cpp mitkVolumeCalculatorTest.cpp mitkLevelWindowManagerTest.cpp mitkPointSetVtkMapper2DTest.cpp mitkPointSetVtkMapper2DImageTest.cpp mitkPointSetVtkMapper2DGlyphTypeTest.cpp mitkPointSetVtkMapper2DTransformedPointsTest.cpp mitkLabelOverlay3DRendering2DTest.cpp mitkLabelOverlay3DRendering3DTest.cpp mitkTextOverlay2DRenderingTest.cpp mitkTextOverlay2DLayouterRenderingTest.cpp mitkTextOverlay3DRendering2DTest.cpp mitkTextOverlay3DRendering3DTest.cpp mitkTextOverlay3DColorRenderingTest.cpp mitkVTKRenderWindowSizeTest.cpp mitkMultiComponentImageDataComparisonFilterTest.cpp mitkImageToItkTest.cpp mitkImageSliceSelectorTest.cpp ) set(MODULE_RESOURCE_FILES Interactions/AddAndRemovePoints.xml Interactions/globalConfig.xml Interactions/StatemachineTest.xml Interactions/StatemachineConfigTest.xml ) # Create an artificial module initializing class for # the usServiceListenerTest.cpp usFunctionGenerateExecutableInit(testdriver_init_file IDENTIFIER ${MODULE_NAME}TestDriver ) # Embed the resources set(testdriver_resources ) usFunctionEmbedResources(testdriver_resources EXECUTABLE_NAME ${MODULE_NAME}TestDriver ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Resources FILES ${MODULE_RESOURCE_FILES} ) set(TEST_CPP_FILES ${testdriver_init_file} ${testdriver_resources}) diff --git a/Core/Code/Testing/mitkEventConfigTest.cpp b/Core/Code/Testing/mitkEventConfigTest.cpp index 5272e55844..71d657dfa1 100644 --- a/Core/Code/Testing/mitkEventConfigTest.cpp +++ b/Core/Code/Testing/mitkEventConfigTest.cpp @@ -1,161 +1,162 @@ /*=================================================================== 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 "mitkTestingMacros.h" #include "mitkEventConfig.h" #include "mitkPropertyList.h" #include "mitkInteractionEvent.h" #include "mitkInteractionEventConst.h" #include "mitkMouseMoveEvent.h" #include "mitkMouseWheelEvent.h" #include "mitkMouseReleaseEvent.h" #include "mitkInteractionKeyEvent.h" #include "mitkMousePressEvent.h" #include "usModule.h" #include "usGetModuleContext.h" #include #include #include int mitkEventConfigTest(int argc, char* argv[]) { MITK_TEST_BEGIN("EventConfig") if (argc != 2) { MITK_ERROR << "Test needs configuration test file as parameter."; return -1; } /* * Loads a test a Config file and test if Config is build up correctly, * and if mapping from mitkEvents to EventVariant names works properly. * Indirectly this also tests the EventFactory Class, since we also test if the events have been constructed properly. * * The configuration object is constructed in three different ways, * each one is tested here. */ // Construction using compiled-in resrouces: us::Module *module = us::GetModuleContext()->GetModule(); mitk::EventConfig newConfig("StatemachineConfigTest.xml",module); MITK_TEST_CONDITION_REQUIRED( newConfig.IsValid() == true , "01 Check if file can be loaded and is valid" ); /* * Test the global properties: * Test if stored values match the ones in the test config file. */ mitk::PropertyList::Pointer properties = newConfig.GetAttributes(); std::string prop1, prop2; MITK_TEST_CONDITION_REQUIRED( properties->GetStringProperty("property1",prop1) && prop1 == "yes" && properties->GetStringProperty("scrollModus",prop2) && prop2 == "leftright" , "02 Check Global Properties"); /* * Check if Events get mapped to the proper Variants */ mitk::Point2D pos; - mitk::MousePressEvent::Pointer mpe1 = mitk::MousePressEvent::New(NULL,pos,mitk::InteractionEvent::MiddleMouseButton | mitk::InteractionEvent::LeftMouseButton ,mitk::InteractionEvent::ControlKey | mitk::InteractionEvent::AltKey,mitk::InteractionEvent::LeftMouseButton ); - mitk::MousePressEvent::Pointer standard1 = mitk::MousePressEvent::New(NULL,pos,mitk::InteractionEvent::LeftMouseButton,mitk::InteractionEvent::NoKey ,mitk::InteractionEvent::LeftMouseButton ); - mitk::MouseMoveEvent::Pointer mme1 = mitk::MouseMoveEvent::New(NULL,pos,mitk::InteractionEvent::RightMouseButton | mitk::InteractionEvent::LeftMouseButton,mitk::InteractionEvent::ShiftKey ); - mitk::MouseMoveEvent::Pointer mme2 = mitk::MouseMoveEvent::New(NULL,pos,mitk::InteractionEvent::RightMouseButton,mitk::InteractionEvent::ShiftKey ); - mitk::MouseWheelEvent::Pointer mwe1 = mitk::MouseWheelEvent::New(NULL,pos,mitk::InteractionEvent::RightMouseButton,mitk::InteractionEvent::ShiftKey,-2 ); + mitk::Point3D worldPos; + mitk::MousePressEvent::Pointer mpe1 = mitk::MousePressEvent::New(NULL,pos,worldPos,mitk::InteractionEvent::MiddleMouseButton | mitk::InteractionEvent::LeftMouseButton ,mitk::InteractionEvent::ControlKey | mitk::InteractionEvent::AltKey,mitk::InteractionEvent::LeftMouseButton ); + mitk::MousePressEvent::Pointer standard1 = mitk::MousePressEvent::New(NULL,pos,worldPos,mitk::InteractionEvent::LeftMouseButton,mitk::InteractionEvent::NoKey ,mitk::InteractionEvent::LeftMouseButton ); + mitk::MouseMoveEvent::Pointer mme1 = mitk::MouseMoveEvent::New(NULL,pos,worldPos,mitk::InteractionEvent::RightMouseButton | mitk::InteractionEvent::LeftMouseButton,mitk::InteractionEvent::ShiftKey ); + mitk::MouseMoveEvent::Pointer mme2 = mitk::MouseMoveEvent::New(NULL,pos,worldPos,mitk::InteractionEvent::RightMouseButton,mitk::InteractionEvent::ShiftKey ); + mitk::MouseWheelEvent::Pointer mwe1 = mitk::MouseWheelEvent::New(NULL,pos,worldPos,mitk::InteractionEvent::RightMouseButton,mitk::InteractionEvent::ShiftKey,-2 ); mitk::InteractionKeyEvent::Pointer ke = mitk::InteractionKeyEvent::New(NULL,"l",mitk::InteractionEvent::NoKey ); MITK_TEST_CONDITION_REQUIRED( newConfig.GetMappedEvent(mpe1.GetPointer()) == "Variant1" && newConfig.GetMappedEvent(standard1.GetPointer()) == "Standard1" && newConfig.GetMappedEvent(mme1.GetPointer()) == "Move2" && newConfig.GetMappedEvent(ke.GetPointer()) == "Key1" && newConfig.GetMappedEvent(mme2.GetPointer()) == "" // does not exist in file , "03 Check Mouse- and Key-Events " ); // Construction providing a input stream std::ifstream configStream(argv[1]); mitk::EventConfig newConfig2(configStream); MITK_TEST_CONDITION_REQUIRED( newConfig2.IsValid() == true , "01 Check if file can be loaded and is valid" ); /* * Test the global properties: * Test if stored values match the ones in the test config file. */ properties = newConfig2.GetAttributes(); MITK_TEST_CONDITION_REQUIRED( properties->GetStringProperty("property1",prop1) && prop1 == "yes" && properties->GetStringProperty("scrollModus",prop2) && prop2 == "leftright" , "02 Check Global Properties"); /* * Check if Events get mapped to the proper Variants */ MITK_TEST_CONDITION_REQUIRED( newConfig2.GetMappedEvent(mpe1.GetPointer()) == "Variant1" && newConfig2.GetMappedEvent(standard1.GetPointer()) == "Standard1" && newConfig2.GetMappedEvent(mme1.GetPointer()) == "Move2" && newConfig2.GetMappedEvent(ke.GetPointer()) == "Key1" && newConfig2.GetMappedEvent(mme2.GetPointer()) == "" // does not exist in file , "03 Check Mouse- and Key-Events " ); // always end with this! // Construction providing a property list std::vector configDescription; mitk::PropertyList::Pointer propertyList1 = mitk::PropertyList::New(); propertyList1->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventClass().c_str(), "MousePressEvent"); propertyList1->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventVariant().c_str(), "MousePressEventVariant"); propertyList1->SetStringProperty("Modifiers","CTRL,ALT"); configDescription.push_back(propertyList1); mitk::PropertyList::Pointer propertyList2 = mitk::PropertyList::New(); propertyList2->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventClass().c_str(), "MOUSERELEASEEVENT"); propertyList2->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventVariant().c_str(), "MouseReleaseEventVariant"); propertyList2->SetStringProperty("Modifiers","SHIFT"); configDescription.push_back(propertyList2); mitk::PropertyList::Pointer propertyList3 = mitk::PropertyList::New(); propertyList3->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventClass().c_str(), "MOUSERELEASEEVENT"); propertyList3->SetStringProperty(mitk::InteractionEventConst::xmlParameterEventVariant().c_str(), "MouseReleaseEventVariant"); propertyList3->SetStringProperty("Modifiers","ALT"); configDescription.push_back(propertyList3); mitk::EventConfig newConfig3( configDescription ); - mitk::MousePressEvent::Pointer mousePress1 = mitk::MousePressEvent::New(NULL,pos,mitk::InteractionEvent::NoButton,mitk::InteractionEvent::AltKey | mitk::InteractionEvent::ControlKey ,mitk::InteractionEvent::NoButton ); - mitk::MouseReleaseEvent::Pointer mouseRelease1 = mitk::MouseReleaseEvent::New(NULL,pos,mitk::InteractionEvent::NoButton,mitk::InteractionEvent::ShiftKey ,mitk::InteractionEvent::NoButton ); + mitk::MousePressEvent::Pointer mousePress1 = mitk::MousePressEvent::New(NULL,pos,worldPos,mitk::InteractionEvent::NoButton,mitk::InteractionEvent::AltKey | mitk::InteractionEvent::ControlKey ,mitk::InteractionEvent::NoButton ); + mitk::MouseReleaseEvent::Pointer mouseRelease1 = mitk::MouseReleaseEvent::New(NULL,pos,worldPos,mitk::InteractionEvent::NoButton,mitk::InteractionEvent::ShiftKey ,mitk::InteractionEvent::NoButton ); // create a second event with the same name but different modifiers... - mitk::MouseReleaseEvent::Pointer mouseRelease2 = mitk::MouseReleaseEvent::New(NULL,pos,mitk::InteractionEvent::NoButton,mitk::InteractionEvent::AltKey ,mitk::InteractionEvent::NoButton ); + mitk::MouseReleaseEvent::Pointer mouseRelease2 = mitk::MouseReleaseEvent::New(NULL,pos,worldPos,mitk::InteractionEvent::NoButton,mitk::InteractionEvent::AltKey ,mitk::InteractionEvent::NoButton ); MITK_TEST_CONDITION_REQUIRED( newConfig3.GetMappedEvent(mousePress1.GetPointer()) == "MousePressEventVariant" && newConfig3.GetMappedEvent(mouseRelease1.GetPointer()) == "MouseReleaseEventVariant" && newConfig3.GetMappedEvent(mouseRelease2.GetPointer()) == "MouseReleaseEventVariant", "04 Check Mouseevents from PropertyLists" ); MITK_TEST_END() } diff --git a/Core/Code/Testing/mitkInteractionEventTest.cpp b/Core/Code/Testing/mitkInteractionEventTest.cpp index 6017b66343..993c420311 100644 --- a/Core/Code/Testing/mitkInteractionEventTest.cpp +++ b/Core/Code/Testing/mitkInteractionEventTest.cpp @@ -1,96 +1,101 @@ /*=================================================================== 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 "mitkMousePressEvent.h" #include "mitkMouseReleaseEvent.h" #include "mitkMouseMoveEvent.h" #include "mitkVtkPropRenderer.h" #include "mitkInteractionEventConst.h" #include "mitkTestingMacros.h" int mitkInteractionEventTest(int /*argc*/, char* /*argv*/[]) { /* * Create different Events, fill them with data. * And check if isEqual method is implemented properly. */ MITK_TEST_BEGIN("InteractionEvent") mitk::VtkPropRenderer::Pointer renderer = NULL; mitk::InteractionEvent::MouseButtons buttonStates = mitk::InteractionEvent::LeftMouseButton | mitk::InteractionEvent::RightMouseButton; mitk::InteractionEvent::MouseButtons eventButton = mitk::InteractionEvent::LeftMouseButton; mitk::InteractionEvent::ModifierKeys modifiers = mitk::InteractionEvent::ControlKey | mitk::InteractionEvent::AltKey; mitk::Point2D point; point[0] = 17; point[1] = 170; + mitk::Point3D worldPos; + worldPos[0] = 0.5; + worldPos[1] = 10.609; + worldPos[2] = 5.0; + // MousePress Events - mitk::MousePressEvent::Pointer me1 = mitk::MousePressEvent::New(renderer,point, buttonStates, modifiers, eventButton); - mitk::MousePressEvent::Pointer me2 = mitk::MousePressEvent::New(renderer,point, buttonStates, modifiers, eventButton); + mitk::MousePressEvent::Pointer me1 = mitk::MousePressEvent::New(renderer, point, worldPos, buttonStates, modifiers, eventButton); + mitk::MousePressEvent::Pointer me2 = mitk::MousePressEvent::New(renderer, point, worldPos, buttonStates, modifiers, eventButton); point[0] = 178; point[1] = 170; - mitk::MousePressEvent::Pointer me3 = mitk::MousePressEvent::New(renderer,point, buttonStates, modifiers, eventButton); + mitk::MousePressEvent::Pointer me3 = mitk::MousePressEvent::New(renderer, point, worldPos, buttonStates, modifiers, eventButton); modifiers = mitk::InteractionEvent::ControlKey; - mitk::MousePressEvent::Pointer me4 = mitk::MousePressEvent::New(renderer,point, buttonStates, modifiers, eventButton); + mitk::MousePressEvent::Pointer me4 = mitk::MousePressEvent::New(renderer, point, worldPos, buttonStates, modifiers, eventButton); MITK_TEST_CONDITION_REQUIRED( *me1 == *me2 && *me1 == *me3 && *me2 == *me3 && *me3 != *me4 , "Checking isEqual and Constructors of mitk::InteractionEvent, mitk::MousePressEvent"); // MouseReleaseEvents - mitk::MouseReleaseEvent::Pointer mr1 = mitk::MouseReleaseEvent::New(renderer,point, buttonStates, modifiers, eventButton); - mitk::MouseReleaseEvent::Pointer mr2 = mitk::MouseReleaseEvent::New(renderer,point, buttonStates, modifiers, eventButton); + mitk::MouseReleaseEvent::Pointer mr1 = mitk::MouseReleaseEvent::New(renderer, point, worldPos, buttonStates, modifiers, eventButton); + mitk::MouseReleaseEvent::Pointer mr2 = mitk::MouseReleaseEvent::New(renderer, point, worldPos, buttonStates, modifiers, eventButton); point[0] = 178; point[1] = 170; - mitk::MouseReleaseEvent::Pointer mr3 = mitk::MouseReleaseEvent::New(renderer,point, buttonStates, modifiers, eventButton); + mitk::MouseReleaseEvent::Pointer mr3 = mitk::MouseReleaseEvent::New(renderer, point, worldPos, buttonStates, modifiers, eventButton); eventButton = mitk::InteractionEvent::RightMouseButton; - mitk::MouseReleaseEvent::Pointer mr4 = mitk::MouseReleaseEvent::New(renderer,point, buttonStates, modifiers, eventButton); + mitk::MouseReleaseEvent::Pointer mr4 = mitk::MouseReleaseEvent::New(renderer, point, worldPos, buttonStates, modifiers, eventButton); MITK_TEST_CONDITION_REQUIRED( *mr1 == *mr2 && *mr1 == *mr3 && *mr2 == *mr3 && *mr3 != *mr4 , "Checking isEqual and Constructors of mitk::InteractionEvent, mitk::MouseReleaseEvent"); // MouseMoveEvents - mitk::MouseMoveEvent::Pointer mm1 = mitk::MouseMoveEvent::New(renderer,point, buttonStates, modifiers); + mitk::MouseMoveEvent::Pointer mm1 = mitk::MouseMoveEvent::New(renderer, point, worldPos, buttonStates, modifiers); point[0] = 178; point[1] = 170; - mitk::MouseMoveEvent::Pointer mm3 = mitk::MouseMoveEvent::New(renderer,point, buttonStates, modifiers); + mitk::MouseMoveEvent::Pointer mm3 = mitk::MouseMoveEvent::New(renderer, point, worldPos, buttonStates, modifiers); modifiers = mitk::InteractionEvent::AltKey; - mitk::MouseMoveEvent::Pointer mm4 = mitk::MouseMoveEvent::New(renderer,point, buttonStates, modifiers); + mitk::MouseMoveEvent::Pointer mm4 = mitk::MouseMoveEvent::New(renderer, point, worldPos, buttonStates, modifiers); MITK_TEST_CONDITION_REQUIRED( *mm1 == *mm3 && *mm3 != *mm4 , "Checking isEqual and Constructors of mitk::InteractionEvent, mitk::MouseMoveEvent"); // always end with this! MITK_TEST_END() } diff --git a/Core/Code/Testing/mitkPointSetDataInteractorTest.cpp b/Core/Code/Testing/mitkPointSetDataInteractorTest.cpp new file mode 100644 index 0000000000..94c8f660db --- /dev/null +++ b/Core/Code/Testing/mitkPointSetDataInteractorTest.cpp @@ -0,0 +1,95 @@ +/*=================================================================== + +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 "mitkTestingMacros.h" +#include +#include + +#include +#include +#include +#include + + +class mitkPointSetDataInteractorTestSuite : public mitk::TestFixture +{ + + CPPUNIT_TEST_SUITE(mitkPointSetDataInteractorTestSuite); + MITK_TEST(AddPointInteraction); + CPPUNIT_TEST_SUITE_END(); + + +private: + mitk::DataNode::Pointer m_TestPointSetNode; + mitk::PointSetDataInteractor::Pointer m_DataInteractor; + mitk::PointSet::Pointer m_TestPointSet; + +public: + + void setUp() + { + //Create DataNode as a container for our PointSet to be tested + m_TestPointSetNode = mitk::DataNode::New(); + + // Create PointSetData Interactor + m_DataInteractor = mitk::PointSetDataInteractor::New(); + // Load the according state machine for regular point set interaction + m_DataInteractor->LoadStateMachine("PointSet.xml"); + // Set the configuration file that defines the triggers for the transitions + m_DataInteractor->SetEventConfig("PointSetConfig.xml"); + // set the DataNode (which already is added to the DataStorage) + m_DataInteractor->SetDataNode(m_TestPointSetNode); + + //Create new PointSet which will receive the interaction input + m_TestPointSet = mitk::PointSet::New(); + m_TestPointSetNode->SetData(m_TestPointSet); + } + + void tearDown() + { + //destroy all objects + m_TestPointSetNode = NULL; + m_TestPointSet = NULL; + m_DataInteractor = NULL; + } + + void AddPointInteraction() + { + //Path to the reference PointSet + std::string referencePointSetPath = "/Users/schroedt/Desktop/pointsetTestRef.mps"; + + //Path to the interaction xml file + std::string interactionXmlPath = "/Users/schroedt/Desktop/pointsetTest.xml"; + + //Create test helper to initialize all necessary objects for interaction + mitk::InteractionTestHelper interactionTestHelper(interactionXmlPath); + + //Add our test node to the DataStorage of our test helper + interactionTestHelper.AddNodeToStorage(m_TestPointSetNode); + + //Start Interaction + interactionTestHelper.PlaybackInteraction(); + + //Load the reference PointSet + mitk::PointSet::Pointer referencePointSet = mitk::IOUtil::LoadPointSet(referencePointSetPath); + + //Compare reference with the result of the interaction + MITK_ASSERT_EQUAL(m_TestPointSet.GetPointer(), referencePointSet.GetPointer(), ""); + } + +}; + +MITK_TEST_SUITE_REGISTRATION(mitkPointSetDataInteractor) diff --git a/Core/Code/TestingHelper/files.cmake b/Core/Code/TestingHelper/files.cmake index 89d9b62a64..bce4101306 100644 --- a/Core/Code/TestingHelper/files.cmake +++ b/Core/Code/TestingHelper/files.cmake @@ -1,10 +1,11 @@ set(H_FILES mitkTestCaller.h mitkTestFixture.h mitkTestingMacros.h ) set(CPP_FILES mitkRenderingTestHelper.cpp + mitkInteractionTestHelper.cpp ) diff --git a/Core/Code/TestingHelper/mitkInteractionTestHelper.cpp b/Core/Code/TestingHelper/mitkInteractionTestHelper.cpp new file mode 100644 index 0000000000..cdab85df9c --- /dev/null +++ b/Core/Code/TestingHelper/mitkInteractionTestHelper.cpp @@ -0,0 +1,199 @@ +/*=================================================================== + +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. + +===================================================================*/ + + +//MITK +#include +#include +#include +#include +#include + +//us +#include + +#include + + + +mitk::InteractionTestHelper::InteractionTestHelper(const std::string &interactionXmlFilePath) + : m_InteractionFilePath(interactionXmlFilePath) +{ + this->Initialize(interactionXmlFilePath); +} + +void mitk::InteractionTestHelper::Initialize(const std::string &interactionXmlFilePath) +{ + //TiXmlDocument document(interactionXmlPath.c_str()); + TiXmlDocument document(interactionXmlFilePath); + bool loadOkay = document.LoadFile(); + if (loadOkay) + { + // Global interaction must(!) be initialized + if(! mitk::GlobalInteraction::GetInstance()->IsInitialized()) + mitk::GlobalInteraction::GetInstance()->Initialize("global"); + + //get RenderingManager instance + mitk::RenderingManager* rm = mitk::RenderingManager::GetInstance(); + + //create data storage + m_DataStorage = mitk::StandaloneDataStorage::New(); + + //for each renderer found create a render window and configure + for( TiXmlElement* element = document.FirstChildElement(mitk::InteractionEventConst::xmlTagInteractions())->FirstChildElement(mitk::InteractionEventConst::xmlTagConfigRoot())->FirstChildElement(mitk::InteractionEventConst::xmlTagRenderer()); + element != NULL; + element = element->NextSiblingElement(mitk::InteractionEventConst::xmlTagRenderer()) ) + { + //get name of renderer + const char* rendererName = element->Attribute(mitk::InteractionEventConst::xmlEventPropertyRendererName().c_str()); + + //get view direction + int viewDirectionNum = std::atoi(element->Attribute(mitk::InteractionEventConst::xmlEventPropertyViewDirection())->c_str()); + mitk::SliceNavigationController::ViewDirection viewDirection = static_cast(viewDirectionNum); + + //create renderWindow, renderer and dispatcher + mitk::RenderWindow::Pointer rw = mitk::RenderWindow::New(NULL, rendererName, rm); //VtkRenderWindow is created within constructor if NULL + + //set storage of renderer + rw->GetRenderer()->SetDataStorage(m_DataStorage); + + //set view direction to axial + rw->GetSliceNavigationController()->SetDefaultViewDirection( viewDirection ); + + //set renderer to render 2D + rw->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D); + + //connect SliceNavigationControllers to timestep changed event of TimeNavigationController + rw->GetSliceNavigationController()->ConnectGeometryTimeEvent(rm->GetTimeNavigationController(), false); + rm->GetTimeNavigationController()->ConnectGeometryTimeEvent(rw->GetSliceNavigationController(), false); + + //add to list of kown render windows + m_RenderWindowList.push_back(rw); + } + + //########### register display interactor to handle scroll events ################## + //use MouseModeSwitcher to ensure that the statemachine of DisplayInteractor is loaded correctly + m_MouseModeSwitcher = mitk::MouseModeSwitcher::New(); + } + else + { + mitkThrow() << "Can not load interaction xml file <" << m_InteractionFilePath << ">"; + } +} + +mitk::InteractionTestHelper::~InteractionTestHelper() +{ + //unregister renderers + InteractionTestHelper::RenderWindowListType::iterator it = m_RenderWindowList.begin(); + InteractionTestHelper::RenderWindowListType::iterator end = m_RenderWindowList.end(); + + for(; it != end; it++) + { + mitk::BaseRenderer::RemoveInstance((*it)->GetVtkRenderWindow()); + } +} + + +mitk::DataStorage::Pointer mitk::InteractionTestHelper::GetDataStorage() +{ + return m_DataStorage; +} + + +void mitk::InteractionTestHelper::AddNodeToStorage(mitk::DataNode::Pointer node) +{ + this->m_DataStorage->Add(node); + mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(m_DataStorage); +} + + +void mitk::InteractionTestHelper::PlaybackInteraction() +{ + //load events if not loaded yet + if(m_Events.empty()) + this->LoadInteraction(); + + //playback all events in queue + for (unsigned long i=0; i < m_Events.size(); ++i) + { + //let dispatcher of sending renderer process the event + m_Events.at(i)->GetSender()->GetDispatcher()->ProcessEvent(m_Events.at(i)); + } +} + + +void mitk::InteractionTestHelper::LoadInteraction() +{ + //load interaction pattern from xml file + std::ifstream xmlStream(m_InteractionFilePath.c_str()); + mitk::XML2EventParser parser(xmlStream); + m_Events = parser.GetInteractions(); + xmlStream.close(); +} + + +void mitk::InteractionTestHelper::SetTimeStep(int newTimeStep) +{ + bool timeStepIsvalid = mitk::RenderingManager::GetInstance()->GetTimeNavigationController()->GetCreatedWorldGeometry()->IsValidTimeStep(newTimeStep); + + if(timeStepIsvalid) + { + mitk::RenderingManager::GetInstance()->GetTimeNavigationController()->GetTime()->SetPos(newTimeStep); + } +} + + +mitk::RenderWindow* mitk::InteractionTestHelper::GetRenderWindowByName(const std::string &name) +{ + InteractionTestHelper::RenderWindowListType::iterator it = m_RenderWindowList.begin(); + InteractionTestHelper::RenderWindowListType::iterator end = m_RenderWindowList.end(); + + for(; it != end; it++) + { + if( name.compare( (*it)->GetRenderer()->GetName() ) == 0) + return (*it).GetPointer(); + } + + return NULL; +} + + +mitk::RenderWindow* mitk::InteractionTestHelper::GetRenderWindowByDefaultViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection) +{ + InteractionTestHelper::RenderWindowListType::iterator it = m_RenderWindowList.begin(); + InteractionTestHelper::RenderWindowListType::iterator end = m_RenderWindowList.end(); + + for(; it != end; it++) + { + if( viewDirection == (*it)->GetSliceNavigationController()->GetDefaultViewDirection() ) + return (*it).GetPointer(); + } + + return NULL; +} + + +mitk::RenderWindow* mitk::InteractionTestHelper::GetRenderWindow(unsigned int index) +{ + if( index < m_RenderWindowList.size() ) + { + return m_RenderWindowList.at(index).GetPointer(); + } + else + { + return NULL; + } +} diff --git a/Core/Code/TestingHelper/mitkInteractionTestHelper.h b/Core/Code/TestingHelper/mitkInteractionTestHelper.h new file mode 100644 index 0000000000..03fcc08766 --- /dev/null +++ b/Core/Code/TestingHelper/mitkInteractionTestHelper.h @@ -0,0 +1,140 @@ +/*=================================================================== + +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 mitkInteractionTestHelper_h +#define mitkInteractionTestHelper_h + +#include +#include +#include +#include +#include + +#include + +class vtkRenderWindow; +class vtkRenderer; + +namespace mitk +{ + +/** @brief Creates everything needed to load and playback interaction events. + * + * The interaction is loaded from an xml file and the event are created. This file is + * usually a recorded user interaction with the GUI. This can be done with InteractionEventRecorder + * plugin. Also all necessary objects to handle interaction events are generated. + * The user of this class is responsible to add the data object to interact with to the data storage + * of InteractionTestHelper. And must also make sure that a proper data interactor is associated with the data object. + * + * To test a PointSet interaction for instance make sure you have a PointSet node and a PointSetDataInteractor. + * Then just add the node to the storage of the your InteractionTestHelper by calling InteractionTestHelper::AddNodeToStorage. + * Use InteractionTestHelper::PlaybackInteraction to execute. The result can afterwards be compared to a reference object. + * + * Make sure to destroy the test helper instance after each test, since all render windows and its renderers have to be unregistered. + * + * \sa XML2EventParser + * \sa EventFactory + * \sa EventRecorder +*/ +class MITK_TESTINGHELPER_EXPORT InteractionTestHelper +{ + +public: + + /** + * @brief InteractionTestHelper set up all neseccary objects by calling Initialize. + * @param interactionXmlFilePath path to xml file containing events and configuration information for the render windows. + */ + InteractionTestHelper(const std::string &interactionXmlFilePath); + + //unregisters all render windows and its renderers. + virtual ~InteractionTestHelper(); + + /** @brief Returns the datastorage, in order to modify the data inside a rendering test. + **/ + mitk::DataStorage::Pointer GetDataStorage(); + + /** + * @brief AddNodeToStorage Add a node to the datastorage and perform a reinit which is necessary for rendering. + * @param node The data you want to add. + */ + void AddNodeToStorage(mitk::DataNode::Pointer node); + + /** + * @brief PlaybackInteraction playback loaded interaction by passing events to the dispatcher. + */ + void PlaybackInteraction(); + + /** + * @brief SetTimeStep Sets timesteps of all SliceNavigationControllers to given timestep. + * @param newTimeStep new timestep + * + * Does the same as using ImageNavigators Time slider. Use this if your data was modified in a timestep other than 0. + */ + void SetTimeStep(int newTimeStep); + + typedef std::vector RenderWindowListType; + + const RenderWindowListType& GetRenderWindowList() { return m_RenderWindowList;} + + /** + * @brief GetRenderWindowByName Get renderWindow by the name of its renderer. + * @param name The name of the renderer of the desired renderWindow. + * @return NULL if not found. + */ + RenderWindow* GetRenderWindowByName(const std::string &name); + + /** + * @brief GetRenderWindowByDefaultViewDirection Get a renderWindow by its default viewdirection. + * @param viewDirection + * @return NULL if not found. + */ + RenderWindow* GetRenderWindowByDefaultViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection); + + /** + * @brief GetRenderWindow Get renderWindow at position 'index'. + * @param index Position within the renderWindow list. + * @return NULL if index is out of bounds. + */ + RenderWindow* GetRenderWindow(unsigned int index); + +protected: + + + /** + * @brief Initialize Internal method to initialize the renderwindow and set the datastorage. + * @throws mitk::Exception if interaction xml file can not be loaded. + */ + void Initialize(const std::string &interactionXmlFilePath); + + /** + * @brief LoadInteraction loads events from xml file. + * @param interactionXmlPath path to xml file with interaction events. + */ + void LoadInteraction(); + + + mitk::XML2EventParser::EventContainerType m_Events; // List with loaded interaction events + + std::string m_InteractionFilePath; + + RenderWindowListType m_RenderWindowList; + mitk::DataStorage::Pointer m_DataStorage; + mitk::MouseModeSwitcher::Pointer m_MouseModeSwitcher; + +}; +}//namespace mitk +#endif diff --git a/Core/Code/files.cmake b/Core/Code/files.cmake index e1741ada2a..68842e7252 100644 --- a/Core/Code/files.cmake +++ b/Core/Code/files.cmake @@ -1,414 +1,416 @@ set(H_FILES Algorithms/itkImportMitkImageContainer.h Algorithms/itkImportMitkImageContainer.txx Algorithms/itkLocalVariationImageFilter.h Algorithms/itkLocalVariationImageFilter.txx Algorithms/itkMITKScalarImageToHistogramGenerator.h Algorithms/itkMITKScalarImageToHistogramGenerator.txx Algorithms/itkTotalVariationDenoisingImageFilter.h Algorithms/itkTotalVariationDenoisingImageFilter.txx Algorithms/itkTotalVariationSingleIterationImageFilter.h Algorithms/itkTotalVariationSingleIterationImageFilter.txx Algorithms/mitkBilateralFilter.h Algorithms/mitkBilateralFilter.cpp Algorithms/mitkInstantiateAccessFunctions.h Algorithms/mitkPixelTypeList.h Algorithms/mitkPPArithmeticDec.h Algorithms/mitkPPArgCount.h Algorithms/mitkPPCat.h Algorithms/mitkPPConfig.h Algorithms/mitkPPControlExprIIf.h Algorithms/mitkPPControlIf.h Algorithms/mitkPPControlIIf.h Algorithms/mitkPPDebugError.h Algorithms/mitkPPDetailAutoRec.h Algorithms/mitkPPDetailDMCAutoRec.h Algorithms/mitkPPExpand.h Algorithms/mitkPPFacilitiesEmpty.h Algorithms/mitkPPFacilitiesExpand.h Algorithms/mitkPPLogicalBool.h Algorithms/mitkPPRepetitionDetailDMCFor.h Algorithms/mitkPPRepetitionDetailEDGFor.h Algorithms/mitkPPRepetitionDetailFor.h Algorithms/mitkPPRepetitionDetailMSVCFor.h Algorithms/mitkPPRepetitionFor.h Algorithms/mitkPPSeqElem.h Algorithms/mitkPPSeqForEach.h Algorithms/mitkPPSeqForEachProduct.h Algorithms/mitkPPSeq.h Algorithms/mitkPPSeqEnum.h Algorithms/mitkPPSeqSize.h Algorithms/mitkPPSeqToTuple.h Algorithms/mitkPPStringize.h Algorithms/mitkPPTupleEat.h Algorithms/mitkPPTupleElem.h Algorithms/mitkPPTupleRem.h Algorithms/mitkClippedSurfaceBoundsCalculator.h Algorithms/mitkExtractSliceFilter.h Algorithms/mitkConvert2Dto3DImageFilter.h Algorithms/mitkPlaneClipping.h Common/mitkCommon.h Common/mitkExceptionMacro.h DataManagement/mitkProportionalTimeGeometry.h DataManagement/mitkTimeGeometry.h DataManagement/mitkImageAccessByItk.h DataManagement/mitkImageCast.h DataManagement/mitkImagePixelAccessor.h DataManagement/mitkImagePixelReadAccessor.h DataManagement/mitkImagePixelWriteAccessor.h DataManagement/mitkImageReadAccessor.h DataManagement/mitkImageWriteAccessor.h DataManagement/mitkITKImageImport.h DataManagement/mitkITKImageImport.txx DataManagement/mitkImageToItk.h DataManagement/mitkImageToItk.txx DataManagement/mitkTimeSlicedGeometry.h # Deprecated, empty for compatibilty reasons. DataManagement/mitkPropertyListReplacedObserver.cpp Interactions/mitkEventMapperAddOn.h Interfaces/mitkIDataNodeReader.h Rendering/mitkLocalStorageHandler.h Rendering/Colortables/HotIron.h Rendering/Colortables/Jet.h Rendering/Colortables/PET20.h Rendering/Colortables/PETColor.h IO/mitkPixelTypeTraits.h ) set(CPP_FILES Algorithms/mitkBaseDataSource.cpp Algorithms/mitkCompareImageDataFilter.cpp Algorithms/mitkMultiComponentImageDataComparisonFilter.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkImageToSurfaceFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToImageFilter.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Algorithms/mitkExtractSliceFilter.cpp Algorithms/mitkConvert2Dto3DImageFilter.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkCoreActivator.cpp Controllers/mitkFocusManager.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSlicesCoordinator.cpp Controllers/mitkSlicesRotator.cpp Controllers/mitkSlicesSwiveller.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkInteractorCameraController.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkProportionalTimeGeometry.cpp DataManagement/mitkTimeGeometry.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkDataStorage.cpp # DataManagement/mitkDataTree.cpp DataManagement/mitkDataNode.cpp DataManagement/mitkDataNodeFactory.cpp # DataManagement/mitkDataTreeStorage.cpp DataManagement/mitkDisplayGeometry.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkGeometry2D.cpp DataManagement/mitkGeometry2DData.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkImage.cpp DataManagement/mitkImageAccessorBase.cpp DataManagement/mitkImageCaster.cpp DataManagement/mitkImageCastPart1.cpp DataManagement/mitkImageCastPart2.cpp DataManagement/mitkImageCastPart3.cpp DataManagement/mitkImageCastPart4.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageVtkAccessor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkLandmarkBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTables.cpp # specializations of GenericLookupTable DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModeOperation.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFirstLevel.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateSource.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkPropertyObserver.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkApplyTransformMatrixOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStateTransitionOperation.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkVector.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkVtkVolumeRenderingProperty.cpp DataManagement/mitkWeakPointerProperty.cpp DataManagement/mitkRenderingModeProperty.cpp DataManagement/mitkShaderProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkMaterial.cpp DataManagement/mitkPointSetShapeProperty.cpp DataManagement/mitkFloatPropertyExtension.cpp DataManagement/mitkIntPropertyExtension.cpp DataManagement/mitkPropertyExtension.cpp DataManagement/mitkPropertyFilter.cpp DataManagement/mitkPropertyAliases.cpp DataManagement/mitkPropertyDescriptions.cpp DataManagement/mitkPropertyExtensions.cpp DataManagement/mitkPropertyFilters.cpp Interactions/mitkAction.cpp Interactions/mitkAffineInteractor.cpp Interactions/mitkBindDispatcherInteractor.cpp Interactions/mitkCoordinateSupplier.cpp Interactions/mitkDataInteractor.cpp Interactions/mitkDispatcher.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkDisplayInteractor.cpp Interactions/mitkDisplayPositionEvent.cpp # Interactions/mitkDisplayVectorInteractorLevelWindow.cpp # legacy, prob even now unneeded # Interactions/mitkDisplayVectorInteractorScroll.cpp Interactions/mitkEvent.cpp Interactions/mitkEventConfig.cpp Interactions/mitkEventDescription.cpp Interactions/mitkEventFactory.cpp Interactions/mitkInteractionEventHandler.cpp Interactions/mitkEventMapper.cpp + Interactions/mitkEventRecorder.cpp Interactions/mitkEventStateMachine.cpp Interactions/mitkGlobalInteraction.cpp Interactions/mitkInteractor.cpp Interactions/mitkInternalEvent.cpp Interactions/mitkInteractionEvent.cpp Interactions/mitkInteractionEventConst.cpp Interactions/mitkInteractionPositionEvent.cpp Interactions/mitkInteractionKeyEvent.cpp Interactions/mitkMousePressEvent.cpp Interactions/mitkMouseMoveEvent.cpp Interactions/mitkMouseReleaseEvent.cpp Interactions/mitkMouseWheelEvent.cpp Interactions/mitkMouseDoubleClickEvent.cpp Interactions/mitkMouseModeSwitcher.cpp Interactions/mitkMouseMovePointSetInteractor.cpp Interactions/mitkMoveBaseDataInteractor.cpp Interactions/mitkNodeDepententPointSetInteractor.cpp Interactions/mitkPointSetDataInteractor.cpp Interactions/mitkPointSetInteractor.cpp Interactions/mitkPositionEvent.cpp Interactions/mitkPositionTracker.cpp Interactions/mitkStateMachineAction.cpp Interactions/mitkStateMachineCondition.cpp Interactions/mitkStateMachineState.cpp Interactions/mitkStateMachineTransition.cpp Interactions/mitkState.cpp Interactions/mitkStateMachineContainer.cpp Interactions/mitkStateEvent.cpp Interactions/mitkStateMachine.cpp Interactions/mitkStateMachineFactory.cpp Interactions/mitkTransition.cpp Interactions/mitkWheelEvent.cpp Interactions/mitkKeyEvent.cpp Interactions/mitkVtkEventAdapter.cpp Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkCrosshairPositionEvent.cpp + Interactions/mitkXML2EventParser.cpp Interfaces/mitkInteractionEventObserver.cpp Interfaces/mitkIShaderRepository.cpp Interfaces/mitkIPropertyAliases.cpp Interfaces/mitkIPropertyDescriptions.cpp Interfaces/mitkIPropertyExtensions.cpp Interfaces/mitkIPropertyFilters.cpp Interfaces/mitkIPersistenceService.cpp IO/mitkBaseDataIOFactory.cpp IO/mitkCoreDataNodeReader.cpp IO/mitkDicomSeriesReader.cpp IO/mitkDicomSR_LoadDICOMScalar.cpp IO/mitkDicomSR_LoadDICOMScalar4D.cpp IO/mitkDicomSR_LoadDICOMRGBPixel.cpp IO/mitkDicomSR_LoadDICOMRGBPixel4D.cpp IO/mitkDicomSR_ImageBlockDescriptor.cpp IO/mitkDicomSR_GantryTiltInformation.cpp IO/mitkDicomSR_SliceGroupingResult.cpp IO/mitkFileReader.cpp IO/mitkFileSeriesReader.cpp IO/mitkFileWriter.cpp # IO/mitkIpPicGet.c IO/mitkImageGenerator.cpp IO/mitkImageWriter.cpp IO/mitkImageWriterFactory.cpp IO/mitkItkImageFileIOFactory.cpp IO/mitkItkImageFileReader.cpp IO/mitkItkLoggingAdapter.cpp IO/mitkItkPictureWrite.cpp IO/mitkIOUtil.cpp IO/mitkLookupTableProperty.cpp IO/mitkOperation.cpp # IO/mitkPicFileIOFactory.cpp # IO/mitkPicFileReader.cpp # IO/mitkPicFileWriter.cpp # IO/mitkPicHelper.cpp # IO/mitkPicVolumeTimeSeriesIOFactory.cpp # IO/mitkPicVolumeTimeSeriesReader.cpp IO/mitkPixelType.cpp IO/mitkPointSetIOFactory.cpp IO/mitkPointSetReader.cpp IO/mitkPointSetWriter.cpp IO/mitkPointSetWriterFactory.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSTLFileIOFactory.cpp IO/mitkSTLFileReader.cpp IO/mitkSurfaceVtkWriter.cpp IO/mitkSurfaceVtkWriterFactory.cpp IO/mitkVtkLoggingAdapter.cpp IO/mitkVtiFileIOFactory.cpp IO/mitkVtiFileReader.cpp IO/mitkVtkImageIOFactory.cpp IO/mitkVtkImageReader.cpp IO/mitkVtkSurfaceIOFactory.cpp IO/mitkVtkSurfaceReader.cpp IO/vtkPointSetXMLParser.cpp IO/mitkLog.cpp Rendering/mitkBaseRenderer.cpp Rendering/mitkVtkMapper.cpp Rendering/mitkRenderWindowFrame.cpp Rendering/mitkGeometry2DDataMapper2D.cpp Rendering/mitkGeometry2DDataVtkMapper3D.cpp Rendering/mitkGLMapper.cpp Rendering/mitkGradientBackground.cpp Rendering/mitkManufacturerLogo.cpp Rendering/mitkMapper.cpp Rendering/mitkPointSetGLMapper2D.cpp Rendering/mitkPointSetVtkMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkPolyDataGLMapper2D.cpp Rendering/mitkSurfaceGLMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVolumeDataVtkMapper3D.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkShaderRepository.cpp Rendering/mitkImageVtkMapper2D.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkMitkLevelWindowFilter.cpp Rendering/vtkNeverTranslucentTexture.cpp Rendering/mitkOverlay.cpp Rendering/mitkVtkOverlay.cpp Rendering/mitkVtkOverlay2D.cpp Rendering/mitkVtkOverlay3D.cpp Rendering/mitkOverlayManager.cpp Rendering/mitkAbstractOverlayLayouter.cpp Rendering/mitkTextOverlay2D.cpp Rendering/mitkTextOverlay3D.cpp Rendering/mitkLabelOverlay3D.cpp Rendering/mitkOverlay2DLayouter.cpp Rendering/mitkScaleLegendOverlay Common/mitkException.cpp Common/mitkCommon.h Common/mitkCoreObjectFactoryBase.cpp Common/mitkCoreObjectFactory.cpp Common/mitkCoreServices.cpp ) set(RESOURCE_FILES Interactions/globalConfig.xml Interactions/DisplayInteraction.xml Interactions/DisplayConfig.xml Interactions/DisplayConfigPACS.xml Interactions/DisplayConfigPACSPan.xml Interactions/DisplayConfigPACSScroll.xml Interactions/DisplayConfigPACSZoom.xml Interactions/DisplayConfigPACSLevelWindow.xml Interactions/DisplayConfigMITK.xml Interactions/PointSet.xml Interactions/Legacy/StateMachine.xml Interactions/Legacy/DisplayConfigMITKTools.xml Interactions/PointSetConfig.xml Shaders/mitkShaderLighting.xml mitkLevelWindowPresets.xml ) diff --git a/Modules/Qmitk/QmitkRenderWindow.cpp b/Modules/Qmitk/QmitkRenderWindow.cpp index 277449458e..1970c7bf45 100644 --- a/Modules/Qmitk/QmitkRenderWindow.cpp +++ b/Modules/Qmitk/QmitkRenderWindow.cpp @@ -1,522 +1,541 @@ /*=================================================================== 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 "QmitkRenderWindow.h" #include #include #include #include #include #include #include #include #include "QmitkEventAdapter.h" // TODO: INTERACTION_LEGACY #include "mitkMousePressEvent.h" #include "mitkMouseMoveEvent.h" #include "mitkMouseDoubleClickEvent.h" #include "mitkMouseReleaseEvent.h" #include "mitkInteractionKeyEvent.h" #include "mitkMouseWheelEvent.h" #include "mitkInternalEvent.h" #include "QmitkRenderWindowMenu.h" QmitkRenderWindow::QmitkRenderWindow(QWidget *parent, QString name, mitk::VtkPropRenderer* /*renderer*/, mitk::RenderingManager* renderingManager) : QVTKWidget(parent), m_ResendQtEvents(true), m_MenuWidget(NULL), m_MenuWidgetActivated(false), m_LayoutIndex(0) { Initialize(renderingManager, name.toStdString().c_str()); // Initialize mitkRenderWindowBase setFocusPolicy(Qt::StrongFocus); setMouseTracking(true); } QmitkRenderWindow::~QmitkRenderWindow() { Destroy(); // Destroy mitkRenderWindowBase } void QmitkRenderWindow::SetResendQtEvents(bool resend) { m_ResendQtEvents = resend; } void QmitkRenderWindow::SetLayoutIndex(unsigned int layoutIndex) { m_LayoutIndex = layoutIndex; if (m_MenuWidget) m_MenuWidget->SetLayoutIndex(layoutIndex); } unsigned int QmitkRenderWindow::GetLayoutIndex() { if (m_MenuWidget) return m_MenuWidget->GetLayoutIndex(); else return 0; } void QmitkRenderWindow::LayoutDesignListChanged(int layoutDesignIndex) { if (m_MenuWidget) m_MenuWidget->UpdateLayoutDesignList(layoutDesignIndex); } void QmitkRenderWindow::mousePressEvent(QMouseEvent *me) { + mitk::Point2D displayPos = GetMousePosition(me); + mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(me)); - mitk::MousePressEvent::Pointer mPressEvent = mitk::MousePressEvent::New(m_Renderer, GetMousePosition(me), GetButtonState(me), - GetModifiers(me), GetEventButton(me)); + mitk::MousePressEvent::Pointer mPressEvent = mitk::MousePressEvent::New(m_Renderer, + displayPos, + worldPos, + GetButtonState(me), + GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mPressEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); this->mousePressMitkEvent(&myevent); QVTKWidget::mousePressEvent(me); } if (m_ResendQtEvents) me->ignore(); } void QmitkRenderWindow::mouseDoubleClickEvent( QMouseEvent *me ) { - mitk::MouseDoubleClickEvent::Pointer mPressEvent = mitk::MouseDoubleClickEvent::New(m_Renderer, GetMousePosition(me), GetButtonState(me), + mitk::Point2D displayPos = GetMousePosition(me); + mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(me)); + + mitk::MouseDoubleClickEvent::Pointer mPressEvent = mitk::MouseDoubleClickEvent::New(m_Renderer,displayPos, worldPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mPressEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); this->mousePressMitkEvent(&myevent); QVTKWidget::mousePressEvent(me); } if (m_ResendQtEvents) me->ignore(); } void QmitkRenderWindow::mouseReleaseEvent(QMouseEvent *me) { - mitk::MouseReleaseEvent::Pointer mReleaseEvent = mitk::MouseReleaseEvent::New(m_Renderer, GetMousePosition(me), GetButtonState(me), + + mitk::Point2D displayPos = GetMousePosition(me); + mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(me)); + + mitk::MouseReleaseEvent::Pointer mReleaseEvent = mitk::MouseReleaseEvent::New(m_Renderer, displayPos,worldPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mReleaseEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); this->mouseReleaseMitkEvent(&myevent); QVTKWidget::mouseReleaseEvent(me); } if (m_ResendQtEvents) me->ignore(); } void QmitkRenderWindow::mouseMoveEvent(QMouseEvent *me) { + mitk::Point2D displayPos = GetMousePosition(me); + mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(me)); + this->AdjustRenderWindowMenuVisibility(me->pos()); - mitk::MouseMoveEvent::Pointer mMoveEvent = mitk::MouseMoveEvent::New(m_Renderer, GetMousePosition(me), GetButtonState(me), + mitk::MouseMoveEvent::Pointer mMoveEvent = mitk::MouseMoveEvent::New(m_Renderer, displayPos, worldPos, GetButtonState(me), GetModifiers(me)); if (!this->HandleEvent(mMoveEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); this->mouseMoveMitkEvent(&myevent); QVTKWidget::mouseMoveEvent(me); } } void QmitkRenderWindow::wheelEvent(QWheelEvent *we) { - mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(m_Renderer, GetMousePosition(we), GetButtonState(we), + mitk::Point2D displayPos = GetMousePosition(we); + mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(we)); + + mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(m_Renderer, displayPos,worldPos, GetButtonState(we), GetModifiers(we), GetDelta(we)); if (!this->HandleEvent(mWheelEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::WheelEvent myevent(QmitkEventAdapter::AdaptWheelEvent(m_Renderer, we)); this->wheelMitkEvent(&myevent); QVTKWidget::wheelEvent(we); } if (m_ResendQtEvents) we->ignore(); } void QmitkRenderWindow::keyPressEvent(QKeyEvent *ke) { mitk::InteractionEvent::ModifierKeys modifiers = GetModifiers(ke); std::string key = GetKeyLetter(ke); mitk::InteractionKeyEvent::Pointer keyEvent = mitk::InteractionKeyEvent::New(m_Renderer, key, modifiers); if (!this->HandleEvent(keyEvent.GetPointer())) { // TODO: INTERACTION_LEGACY QPoint cp = mapFromGlobal(QCursor::pos()); mitk::KeyEvent mke(QmitkEventAdapter::AdaptKeyEvent(m_Renderer, ke, cp)); this->keyPressMitkEvent(&mke); ke->accept(); QVTKWidget::keyPressEvent(ke); } if (m_ResendQtEvents) ke->ignore(); } void QmitkRenderWindow::enterEvent(QEvent *e) { // TODO implement new event QVTKWidget::enterEvent(e); } void QmitkRenderWindow::DeferredHideMenu() { MITK_DEBUG << "QmitkRenderWindow::DeferredHideMenu"; if (m_MenuWidget) m_MenuWidget->HideMenu(); } void QmitkRenderWindow::leaveEvent(QEvent *e) { mitk::InternalEvent::Pointer internalEvent = mitk::InternalEvent::New(this->m_Renderer, NULL, "LeaveRenderWindow"); if (!this->HandleEvent(internalEvent.GetPointer())) if (m_MenuWidget) m_MenuWidget->smoothHide(); QVTKWidget::leaveEvent(e); } void QmitkRenderWindow::paintEvent(QPaintEvent* /*event*/) { //We are using our own interaction and thus have to call the rendering manually. this->GetRenderer()->GetRenderingManager()->RequestUpdate(GetRenderWindow()); } void QmitkRenderWindow::resizeEvent(QResizeEvent* event) { this->resizeMitkEvent(event->size().width(), event->size().height()); QVTKWidget::resizeEvent(event); emit resized(); } void QmitkRenderWindow::moveEvent(QMoveEvent* event) { QVTKWidget::moveEvent(event); // after a move the overlays need to be positioned emit moved(); } void QmitkRenderWindow::showEvent(QShowEvent* event) { QVTKWidget::showEvent(event); // this singleshot is necessary to have the overlays positioned correctly after initial show // simple call of moved() is no use here!! QTimer::singleShot(0, this, SIGNAL( moved() )); } void QmitkRenderWindow::ActivateMenuWidget(bool state, QmitkStdMultiWidget* stdMultiWidget) { m_MenuWidgetActivated = state; if (!m_MenuWidgetActivated && m_MenuWidget) { //disconnect Signal/Slot Connection disconnect(m_MenuWidget, SIGNAL( SignalChangeLayoutDesign(int) ), this, SLOT(OnChangeLayoutDesign(int))); disconnect(m_MenuWidget, SIGNAL( ResetView() ), this, SIGNAL( ResetView())); disconnect(m_MenuWidget, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SIGNAL( ChangeCrosshairRotationMode(int))); delete m_MenuWidget; m_MenuWidget = 0; } else if (m_MenuWidgetActivated && !m_MenuWidget) { //create render window MenuBar for split, close Window or set new setting. m_MenuWidget = new QmitkRenderWindowMenu(this, 0, m_Renderer, stdMultiWidget); m_MenuWidget->SetLayoutIndex(m_LayoutIndex); //create Signal/Slot Connection connect(m_MenuWidget, SIGNAL( SignalChangeLayoutDesign(int) ), this, SLOT(OnChangeLayoutDesign(int))); connect(m_MenuWidget, SIGNAL( ResetView() ), this, SIGNAL( ResetView())); connect(m_MenuWidget, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SIGNAL( ChangeCrosshairRotationMode(int))); } } void QmitkRenderWindow::AdjustRenderWindowMenuVisibility(const QPoint& /*pos*/) { if (m_MenuWidget) { m_MenuWidget->ShowMenu(); m_MenuWidget->MoveWidgetToCorrectPos(1.0f); } } void QmitkRenderWindow::HideRenderWindowMenu() { // DEPRECATED METHOD } void QmitkRenderWindow::OnChangeLayoutDesign(int layoutDesignIndex) { emit SignalLayoutDesignChanged(layoutDesignIndex); } void QmitkRenderWindow::OnWidgetPlaneModeChanged(int mode) { if (m_MenuWidget) m_MenuWidget->NotifyNewWidgetPlanesMode(mode); } void QmitkRenderWindow::FullScreenMode(bool state) { if (m_MenuWidget) m_MenuWidget->ChangeFullScreenMode(state); } void QmitkRenderWindow::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasFormat("application/x-mitk-datanodes")) { event->accept(); } } void QmitkRenderWindow::dropEvent(QDropEvent * event) { if (event->mimeData()->hasFormat("application/x-mitk-datanodes")) { QString arg = QString(event->mimeData()->data("application/x-mitk-datanodes").data()); QStringList listOfDataNodes = arg.split(","); std::vector vectorOfDataNodePointers; for (int i = 0; i < listOfDataNodes.size(); i++) { long val = listOfDataNodes[i].toLong(); mitk::DataNode* node = static_cast((void*) val); vectorOfDataNodePointers.push_back(node); } emit NodesDropped(this, vectorOfDataNodePointers); } } mitk::Point2D QmitkRenderWindow::GetMousePosition(QMouseEvent* me) const { - mitk::Point2D point; point[0] = me->x(); point[1] = me->y(); + m_Renderer->GetDisplayGeometry()->ULDisplayToDisplay(point, point); return point; } mitk::Point2D QmitkRenderWindow::GetMousePosition(QWheelEvent* we) const { mitk::Point2D point; point[0] = we->x(); point[1] = we->y(); + m_Renderer->GetDisplayGeometry()->ULDisplayToDisplay(point, point); return point; } mitk::InteractionEvent::MouseButtons QmitkRenderWindow::GetEventButton(QMouseEvent* me) const { mitk::InteractionEvent::MouseButtons eventButton; switch (me->button()) { case Qt::LeftButton: eventButton = mitk::InteractionEvent::LeftMouseButton; break; case Qt::RightButton: eventButton = mitk::InteractionEvent::RightMouseButton; break; case Qt::MidButton: eventButton = mitk::InteractionEvent::MiddleMouseButton; break; default: eventButton = mitk::InteractionEvent::NoButton; break; } return eventButton; } mitk::InteractionEvent::MouseButtons QmitkRenderWindow::GetButtonState(QMouseEvent* me) const { mitk::InteractionEvent::MouseButtons buttonState = mitk::InteractionEvent::NoButton; if (me->buttons() & Qt::LeftButton) { buttonState = buttonState | mitk::InteractionEvent::LeftMouseButton; } if (me->buttons() & Qt::RightButton) { buttonState = buttonState | mitk::InteractionEvent::RightMouseButton; } if (me->buttons() & Qt::MidButton) { buttonState = buttonState | mitk::InteractionEvent::MiddleMouseButton; } return buttonState; } mitk::InteractionEvent::ModifierKeys QmitkRenderWindow::GetModifiers(QInputEvent* me) const { mitk::InteractionEvent::ModifierKeys modifiers = mitk::InteractionEvent::NoKey; if (me->modifiers() & Qt::ALT) { modifiers = modifiers | mitk::InteractionEvent::AltKey; } if (me->modifiers() & Qt::CTRL) { modifiers = modifiers | mitk::InteractionEvent::ControlKey; } if (me->modifiers() & Qt::SHIFT) { modifiers = modifiers | mitk::InteractionEvent::ShiftKey; } return modifiers; } mitk::InteractionEvent::MouseButtons QmitkRenderWindow::GetButtonState(QWheelEvent* we) const { mitk::InteractionEvent::MouseButtons buttonState = mitk::InteractionEvent::NoButton; if (we->buttons() & Qt::LeftButton) { buttonState = buttonState | mitk::InteractionEvent::LeftMouseButton; } if (we->buttons() & Qt::RightButton) { buttonState = buttonState | mitk::InteractionEvent::RightMouseButton; } if (we->buttons() & Qt::MidButton) { buttonState = buttonState | mitk::InteractionEvent::MiddleMouseButton; } return buttonState; } std::string QmitkRenderWindow::GetKeyLetter(QKeyEvent *ke) const { // Converting Qt Key Event to string element. std::string key = ""; int tkey = ke->key(); if (tkey < 128) { //standard ascii letter key = (char) toupper(tkey); } else { // special keys switch (tkey) { case Qt::Key_Return: key = mitk::InteractionEvent::KeyReturn; break; case Qt::Key_Enter: key = mitk::InteractionEvent::KeyEnter; break; case Qt::Key_Escape: key = mitk::InteractionEvent::KeyEnter; break; case Qt::Key_Delete: key = mitk::InteractionEvent::KeyDelete; break; case Qt::Key_Up: key = mitk::InteractionEvent::KeyArrowUp; break; case Qt::Key_Down: key = mitk::InteractionEvent::KeyArrowDown; break; case Qt::Key_Left: key = mitk::InteractionEvent::KeyArrowLeft; break; case Qt::Key_Right: key = mitk::InteractionEvent::KeyArrowRight; break; case Qt::Key_F1: key = mitk::InteractionEvent::KeyF1; break; case Qt::Key_F2: key = mitk::InteractionEvent::KeyF2; break; case Qt::Key_F3: key = mitk::InteractionEvent::KeyF3; break; case Qt::Key_F4: key = mitk::InteractionEvent::KeyF4; break; case Qt::Key_F5: key = mitk::InteractionEvent::KeyF5; break; case Qt::Key_F6: key = mitk::InteractionEvent::KeyF6; break; case Qt::Key_F7: key = mitk::InteractionEvent::KeyF7; break; case Qt::Key_F8: key = mitk::InteractionEvent::KeyF8; break; case Qt::Key_F9: key = mitk::InteractionEvent::KeyF9; break; case Qt::Key_F10: key = mitk::InteractionEvent::KeyF10; break; case Qt::Key_F11: key = mitk::InteractionEvent::KeyF11; break; case Qt::Key_F12: key = mitk::InteractionEvent::KeyF12; break; case Qt::Key_End: key = mitk::InteractionEvent::KeyEnd; break; case Qt::Key_Home: key = mitk::InteractionEvent::KeyPos1; break; case Qt::Key_Insert: key = mitk::InteractionEvent::KeyInsert; break; case Qt::Key_PageDown: key = mitk::InteractionEvent::KeyPageDown; break; case Qt::Key_PageUp: key = mitk::InteractionEvent::KeyPageUp; break; case Qt::Key_Space: key = mitk::InteractionEvent::KeySpace; break; } } return key; } int QmitkRenderWindow::GetDelta(QWheelEvent* we) const { return we->delta(); } diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index be564e382b..778c013e6d 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,56 +1,57 @@ # Plug-ins must be ordered according to their dependencies if (MITK_USE_Qt4) set(MITK_EXT_PLUGINS org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF org.mitk.diffusionimaging:OFF org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.dtiatlasapp:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.meshdecimation:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.registration:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF + org.mitk.gui.qt.eventrecorder:OFF ) else() set(MITK_EXT_PLUGINS # empty so far ) endif() diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/CMakeLists.txt b/Plugins/org.mitk.gui.qt.eventrecorder/CMakeLists.txt new file mode 100644 index 0000000000..975204ac07 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/CMakeLists.txt @@ -0,0 +1,7 @@ +project(org_mitk_gui_gt_eventrecorder) + +MACRO_CREATE_MITK_CTK_PLUGIN( + EXPORT_DIRECTIVE EVENTRECORDER_EXPORT + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDENCIES QmitkExt +) diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/Manual.dox b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/Manual.dox new file mode 100644 index 0000000000..905b3c790f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/Manual.dox @@ -0,0 +1,18 @@ +/** +\page org_mitk_gui_gt_eventrecorder Eventrecorder + +\image html icon.xpm "Icon of Eventrecorder" + +Available sections: + - \ref org_mitk_gui_gt_eventrecorderOverview + +\section org_mitk_gui_gt_eventrecorderOverview +Describe the features of your awesome plugin here +
    +
  • Increases productivity +
  • Creates beautiful images +
  • Generates PhD thesis +
  • Brings world peace +
+ +*/ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/icon.xpm b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/icon.xpm new file mode 100644 index 0000000000..9057c20bc6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/UserManual/icon.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * icon_xpm[] = { +"16 16 2 1", +" c #FF0000", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..a690d5a53b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_gt_eventrecorder org.mitk.gui.gt.eventrecorder + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_gt_eventrecorder_internal Internal + \ingroup org_mitk_gui_gt_eventrecorder + + \brief This subcategory includes the internal classes of the org.mitk.gui.gt.eventrecorder plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/files.cmake b/Plugins/org.mitk.gui.qt.eventrecorder/files.cmake new file mode 100644 index 0000000000..5be0c9a560 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/files.cmake @@ -0,0 +1,46 @@ +set(SRC_CPP_FILES + +) + +set(INTERNAL_CPP_FILES + org_mitk_gui_gt_eventrecorder_Activator.cpp + InteractionEventRecorder.cpp +) + +set(UI_FILES + src/internal/InteractionEventRecorderControls.ui +) + +set(MOC_H_FILES + src/internal/org_mitk_gui_gt_eventrecorder_Activator.h + src/internal/InteractionEventRecorder.h +) + +# list of resource files which can be used by the plug-in +# system without loading the plug-ins shared library, +# for example the icon used in the menu and tabs for the +# plug-in views in the workbench +set(CACHED_RESOURCE_FILES + plugin.xml + resources/play.png + resources/rec.png + resources/stop_rec.png + resources/stop.png + resources/icon.png +) + +# list of Qt .qrc files which contain additional resources +# specific to this plugin +set(QRC_FILES + +) + +set(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + set(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.eventrecorder/manifest_headers.cmake new file mode 100644 index 0000000000..f3074cf0d1 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "Eventrecorder") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "") +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/plugin.xml b/Plugins/org.mitk.gui.qt.eventrecorder/plugin.xml new file mode 100644 index 0000000000..badc8a57e9 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/resources/icon.png b/Plugins/org.mitk.gui.qt.eventrecorder/resources/icon.png new file mode 100644 index 0000000000..1ba21ea418 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.eventrecorder/resources/icon.png differ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/resources/play.png b/Plugins/org.mitk.gui.qt.eventrecorder/resources/play.png new file mode 100644 index 0000000000..2c8daffd22 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.eventrecorder/resources/play.png differ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/resources/rec.png b/Plugins/org.mitk.gui.qt.eventrecorder/resources/rec.png new file mode 100644 index 0000000000..fae3cb02e2 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.eventrecorder/resources/rec.png differ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/resources/stop.png b/Plugins/org.mitk.gui.qt.eventrecorder/resources/stop.png new file mode 100644 index 0000000000..5d73b8b985 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.eventrecorder/resources/stop.png differ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/resources/stop_rec.png b/Plugins/org.mitk.gui.qt.eventrecorder/resources/stop_rec.png new file mode 100644 index 0000000000..e646c77910 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.eventrecorder/resources/stop_rec.png differ diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp new file mode 100644 index 0000000000..9bbaea2dea --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.cpp @@ -0,0 +1,110 @@ +/*=================================================================== + +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. + +===================================================================*/ + + +// Blueberry +#include +#include + +// Qmitk +#include "InteractionEventRecorder.h" + +// Qt +#include +#include +// us +#include "usGetModuleContext.h" +#include "usModuleContext.h" +#include "usModuleResource.h" + +#include +#include +#include +#include "QmitkRenderWindow.h" + + +US_INITIALIZE_MODULE("InteractionEventRecorder","liborg_mitk_gui_qt_eventrecorder") + + +const std::string InteractionEventRecorder::VIEW_ID = "org.mitk.views.interactioneventrecorder"; + +void InteractionEventRecorder::SetFocus() +{ + m_Controls.textFileName->setFocus(); +} + +void InteractionEventRecorder::StartRecording() +{ + MITK_INFO << "Start Recording"; + m_CurrentObserver->SetOutputFile(m_Controls.textFileName->text().toStdString()); + m_CurrentObserver->StartRecording(); +} + +void InteractionEventRecorder::StopRecording() +{ + MITK_INFO << "Stop Recording"; + m_CurrentObserver->StopRecording(); +} + +void InteractionEventRecorder::Play() +{ + std::ifstream xmlStream(m_Controls.textFileName->text().toStdString().c_str()); + mitk::XML2EventParser parser(xmlStream); + mitk::XML2EventParser::EventContainerType events = parser.GetInteractions(); + + MITK_INFO << "parsed events"; + for (int i=0; i < events.size(); ++i) + { + //this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetRenderer()->GetDispatcher()->ProcessEvent(events.at(i)); + events.at(i)->GetSender()->GetDispatcher()->ProcessEvent(events.at(i)); + } + MITK_INFO << "DONE"; + +} + +void InteractionEventRecorder::OpenFile() +{ + QString fn = QFileDialog::getOpenFileName(NULL, "Open File...", + QString(), "All Files (*)"); + if (!fn.isEmpty()) + this->m_Controls.textFileName->setText(fn); +} + +void InteractionEventRecorder::CreateQtPartControl( QWidget *parent ) +{ + // create GUI widgets from the Qt Designer's .ui file + m_Controls.setupUi( parent ); + connect( m_Controls.btnStopRecording, SIGNAL(clicked()), this, SLOT(StopRecording()) ); + connect( m_Controls.btnStartRecording, SIGNAL(clicked()), this, SLOT(StartRecording()) ); + connect( m_Controls.btnPlay, SIGNAL(clicked()), this, SLOT(Play()) ); + connect( m_Controls.btnOpenFile, SIGNAL(clicked()), this, SLOT(OpenFile()) ); + + m_CurrentObserver = new mitk::EventRecorder(); + // Register as listener via micro services + us::ServiceProperties props; + + props["name"] = std::string("EventRecorder"); + m_ServiceRegistration = us::GetModuleContext()->RegisterService(m_CurrentObserver,props); + + + /* + +delete m_CurrentObserverDEBUG; + m_ServiceRegistrationDEBUG.Unregister(); + */ +} + + diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h new file mode 100644 index 0000000000..c360c4c394 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorder.h @@ -0,0 +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. + +===================================================================*/ + + +#ifndef InteractionEventRecorder_h +#define InteractionEventRecorder_h + +#include + +#include + +#include "ui_InteractionEventRecorderControls.h" + +#include "mitkInteractionEventObserver.h" +#include "mitkEventRecorder.h" + +/** + \brief InteractionEventRecorder + + Demontrates the use of InteractionOversers. + + Allows to record all mouse interaction in the renderwindows save it as XML file. And also replay the interaction. + + \sa QmitkAbstractView + \ingroup ${plugin_target}_internal +*/ +class InteractionEventRecorder : public QmitkAbstractView +{ + // this is needed for all Qt objects that should have a Qt meta-object + // (everything that derives from QObject and wants to have signal/slots) + Q_OBJECT + + public: + + static const std::string VIEW_ID; + + protected slots: + + /// \brief Called when the user clicks the GUI button + + void StartRecording(); + void StopRecording(); + void OpenFile(); + void Play(); + + protected: + + virtual void CreateQtPartControl(QWidget *parent); + + virtual void SetFocus(); + + + + Ui::InteractionEventRecorderControls m_Controls; + + private: + mitk::EventRecorder* m_CurrentObserver; + + us::ServiceRegistration m_ServiceRegistration; + +}; + +#endif // InteractionEventRecorder_h diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui new file mode 100644 index 0000000000..abc23bf9b9 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/InteractionEventRecorderControls.ui @@ -0,0 +1,183 @@ + + + InteractionEventRecorderControls + + + + 0 + 0 + 432 + 359 + + + + + 0 + 0 + + + + QmitkTemplate + + + + + + Filename to store interaction + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 20 + + + + + + + + + 30 + 20 + + + + Open file + + + ... + + + + + + + + + + + Record + + + + + + + :/org.mitk.gui.gt.eventrecorder/resources/rec.png:/org.mitk.gui.gt.eventrecorder/resources/rec.png + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Stop recording + + + + + + + :/org.mitk.gui.gt.eventrecorder/resources/stop_rec.png:/org.mitk.gui.gt.eventrecorder/resources/stop_rec.png + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Play + + + + + + + :/org.mitk.gui.gt.eventrecorder/resources/play.png:/org.mitk.gui.gt.eventrecorder/resources/play.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 200 + + + + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.cpp b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.cpp new file mode 100644 index 0000000000..0631ac9380 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.cpp @@ -0,0 +1,38 @@ +/*=================================================================== + +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 "org_mitk_gui_gt_eventrecorder_Activator.h" + +#include + +#include "InteractionEventRecorder.h" + +namespace mitk { + +void org_mitk_gui_gt_eventrecorder_Activator::start(ctkPluginContext* context) +{ + BERRY_REGISTER_EXTENSION_CLASS(InteractionEventRecorder, context) +} + +void org_mitk_gui_gt_eventrecorder_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} + +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_gt_eventrecorder, mitk::org_mitk_gui_gt_eventrecorder_Activator) diff --git a/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.h b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.h new file mode 100644 index 0000000000..ccb98449c8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.eventrecorder/src/internal/org_mitk_gui_gt_eventrecorder_Activator.h @@ -0,0 +1,40 @@ +/*=================================================================== + +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 org_mitk_gui_gt_eventrecorder_Activator_h +#define org_mitk_gui_gt_eventrecorder_Activator_h + +#include + +namespace mitk { + +class org_mitk_gui_gt_eventrecorder_Activator : + public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + +}; // org_mitk_gui_gt_eventrecorder_Activator + +} + +#endif // org_mitk_gui_gt_eventrecorder_Activator_h