33 std::vector<std::string> &
split(
const std::string &s,
char delim, std::vector<std::string> &elems)
35 std::stringstream ss(s);
37 while (std::getline(ss, item, delim))
39 elems.push_back(item);
44 std::vector<std::string>
split(
const std::string &s,
char delim)
46 std::vector<std::string> elems;
47 return split(s, delim, elems);
59 std::string eventClass =
event->GetNameOfClass();
60 std::transform(eventClass.cbegin(), eventClass.cend(), eventClass.begin(), ::toupper);
62 std::string strButtonState =
"";
63 if (eventClass ==
"MOUSEPRESSEVENT")
68 if (eventClass ==
"MOUSERELEASEEVENT")
73 if (eventClass ==
"MOUSEDOUBLECLICKEVENT")
78 if (eventClass ==
"MOUSEMOVEEVENT")
83 if (eventClass ==
"MOUSEWHEELEVENT")
91 strButtonState =
"LeftMouseButton";
95 if (strButtonState !=
"")
96 strButtonState +=
",";
98 strButtonState +=
"RightMouseButton";
102 if (strButtonState !=
"")
103 strButtonState +=
",";
105 strButtonState +=
"MiddleMouseButton";
107 return strButtonState;
118 std::string eventClass =
event->GetNameOfClass();
119 std::transform(eventClass.cbegin(), eventClass.cend(), eventClass.begin(), ::toupper);
120 std::string strModKeys =
"";
122 if (eventClass ==
"MOUSEPRESSEVENT")
127 if (eventClass ==
"MOUSERELEASEEVENT")
132 if (eventClass ==
"MOUSEDOUBLECLICKEVENT")
137 if (eventClass ==
"MOUSEMOVEEVENT")
142 if (eventClass ==
"MOUSEWHEELEVENT")
150 strModKeys =
"SHIFT";
154 if (strModKeys !=
"")
157 strModKeys +=
"CTRL";
161 if (strModKeys !=
"")
177 std::string eventClass =
event->GetNameOfClass();
178 std::transform(eventClass.cbegin(), eventClass.cend(), eventClass.begin(), ::toupper);
179 std::string stdButton =
"";
181 if (eventClass ==
"MOUSEPRESSEVENT")
186 if (eventClass ==
"MOUSERELEASEEVENT")
191 if (eventClass ==
"MOUSEDOUBLECLICKEVENT")
199 stdButton =
"LeftMouseButton";
203 stdButton =
"RightMouseButton";
207 stdButton =
"MiddleMouseButton";
219 std::stringstream ss;
224 ss << p[0] <<
"," << p[1] <<
"," << p[2];
236 std::stringstream ss;
241 ss << p[0] <<
"," << p[1];
249 std::string eventClass, eventVariant;
255 std::string strModifiers;
257 std::string strEventButton;
259 std::string strButtonState;
263 std::string strWheelDelta;
265 std::string strSignalName =
"";
276 commaPos = strPos.find_first_of(
',');
278 pos[0] =
static_cast<mitk::ScalarType>(std::atof(strPos.substr(0, commaPos).c_str()));
279 pos[1] =
static_cast<mitk::ScalarType>(std::atof(strPos.substr(commaPos + 1, strPos.length()).c_str()));
282 std::string strWorld;
288 const std::vector<std::string> coords =
split(strWorld,
',');
290 for (std::vector<std::string>::const_iterator it = coords.cbegin(); it != coords.cend(); ++it, ++i)
292 worldPos[i] = atof((*it).c_str());
299 std::vector<std::string> mods =
split(strModifiers,
',');
300 for (std::vector<std::string>::iterator it = mods.begin(); it != mods.end(); ++it)
302 std::transform((*it).cbegin(), (*it).cend(), (*it).begin(), ::toupper);
307 else if (*it ==
"ALT")
311 else if (*it ==
"SHIFT")
317 MITK_WARN <<
"mitkEventFactory: Invalid event modifier in config file :" << (*it);
325 std::transform(strEventButton.cbegin(), strEventButton.cend(), strEventButton.begin(), ::toupper);
326 if (strEventButton ==
"MIDDLEMOUSEBUTTON")
330 else if (strEventButton ==
"LEFTMOUSEBUTTON")
334 else if (strEventButton ==
"RIGHTMOUSEBUTTON")
340 MITK_WARN <<
"mitkEventFactory: Invalid event button in config file: " << strEventButton;
347 std::vector<std::string> mods =
split(strButtonState,
',');
348 for (std::vector<std::string>::iterator it = mods.begin(); it != mods.end(); ++it)
350 std::transform((*it).cbegin(), (*it).cend(), (*it).begin(), ::toupper);
351 if (*it ==
"MIDDLEMOUSEBUTTON")
355 else if (*it ==
"LEFTMOUSEBUTTON")
359 else if (*it ==
"RIGHTMOUSEBUTTON")
365 MITK_WARN <<
"mitkEventFactory: Invalid event buttonstate in config file:" << (*it);
386 std::transform(strWheelDelta.cbegin(), strWheelDelta.cend(), strWheelDelta.begin(), ::toupper);
387 if (strWheelDelta ==
"DOWN")
401 std::string strRenderer;
413 if (renderer == NULL)
422 std::transform(eventClass.cbegin(), eventClass.cend(), eventClass.begin(), ::toupper);
424 if (eventClass ==
"MOUSEPRESSEVENT")
427 buttonState = buttonState | eventButton;
430 else if (eventClass ==
"MOUSEDOUBLECLICKEVENT")
432 buttonState = buttonState | eventButton;
435 else if (eventClass ==
"MOUSEMOVEEVENT")
439 else if (eventClass ==
"MOUSERELEASEEVENT")
443 else if (eventClass ==
"INTERACTIONKEYEVENT")
447 else if (eventClass ==
"MOUSEWHEELEVENT")
451 else if (eventClass ==
"INTERACTIONPOSITIONEVENT")
455 else if (eventClass ==
"INTERNALEVENT")
459 else if (eventClass ==
"INTERACTIONEVENT")
465 MITK_WARN <<
"Event couldn't be constructed. Please check your StateMachine patterns and config files\n for the "
466 "following event class, which is not valid: "
479 std::string eventClass =
event->GetNameOfClass();
480 std::string eventXML =
483 std::transform(eventClass.cbegin(), eventClass.cend(), eventClass.begin(), ::toupper);
485 eventXML += eventClass +
"\" >\n";
487 if (eventClass ==
"MOUSEPRESSEVENT" || eventClass ==
"MOUSERELEASEEVENT" || eventClass ==
"MOUSEDOUBLECLICKEVENT" ||
488 eventClass ==
"MOUSEMOVEEVENT" || eventClass ==
"MOUSEWHEELEVENT")
490 if (!(eventClass ==
"MOUSEMOVEEVENT") && !(eventClass ==
"MOUSEWHEELEVENT"))
497 eventXML +=
"\"/>\n";
506 eventXML +=
"\"/>\n";
516 eventXML +=
"\"/>\n";
524 eventXML +=
"\"/>\n";
531 eventXML +=
"\"/>\n";
533 else if (eventClass ==
"INTERACTIONKEYEVENT")
542 eventXML +=
"\"/>\n";
546 MITK_WARN <<
"Event not recognized, discarding event of type " <<
event->GetNameOfClass();
548 if (eventClass ==
"MOUSEWHEELEVENT")
553 std::stringstream ss;
559 eventXML += ss.str();
560 eventXML +=
"\"/>\n";
565 eventXML += delta < 0 ?
"DOWN" :
"UP";
566 eventXML +=
"\"/>\n";
573 eventXML +=
event->GetSender()->GetName();
574 eventXML +=
"\"/>\n";
static const std::string xmlEventPropertyPositionInWorld()
static std::string EventToXML(InteractionEvent *event)
EventToXML Transforms an event into a XML tag describing it.
static const std::string xmlEventPropertyPositionOnScreen()
static const std::string xmlParameterName()
Super class for all position events.
static Pointer New(BaseRenderer *_arga, const Point2D &_argb, MouseButtons _argc, ModifierKeys _argd, MouseButtons _arge)
static const std::string xmlEventPropertyRendererName()
static const std::string xmlParameterValue()
ModifierKeys GetModifiers() const
Point3D GetPositionInWorld() const
static const std::string xmlEventPropertyEventButton()
static std::string GetPositionOnScreen(mitk::InteractionEvent *event)
GetPositionOnScreen Return PositionOnScreen as String.
ModifierKeys GetModifiers() const
static Pointer New(BaseRenderer *_arga, const Point2D &_argb, MouseButtons _argc, ModifierKeys _argd, MouseButtons _arge)
Organizes the rendering process.
static const std::string xmlEventPropertyModifier()
Class to create events from within the application to signal about internal events.
static std::string GetEventButton(mitk::InteractionEvent *event)
GetEventButton Return EventButton as String.
static Pointer New(BaseRenderer *_arga, const Point2D &_argb)
static const std::string xmlEventPropertyScrollDirection()
static const std::string xmlParameterEventClass()
static InteractionEvent::Pointer CreateEvent(PropertyList::Pointer eventDescription)
Point2D GetPointerPositionOnScreen() const
MouseButtons GetButtonStates() const
static Pointer New(BaseRenderer *_arg)
static std::string GetButtonState(mitk::InteractionEvent *event)
GetEventButton Return EventButton as String.
static const std::string xmlEventPropertyButtonState()
static const std::string xmlParameterEventVariant()
ModifierKeys GetModifiers() const
static Pointer New(BaseRenderer *_arga, const Point2D &_argb, MouseButtons _argc, ModifierKeys _argd, int _arge)
static Pointer New(BaseRenderer *_arga, const std::string &_argb, ModifierKeys _argc)
static BaseRendererMapType baseRendererMap
MouseButtons GetButtonStates() const
static const std::string xmlEventPropertyWheelDelta()
MouseButtons GetButtonStates() const
static const std::string xmlEventPropertyKey()
static Pointer New(BaseRenderer *_arga, const Point2D &_argb, MouseButtons _argc, ModifierKeys _argd)
ModifierKeys GetModifiers() const
MouseButtons GetEventButton() const
static const std::string xmlTagEventVariant()
static std::string GetModifierState(mitk::InteractionEvent *event)
GetModifierState Return ModifierState as String.
ModifierKeys GetModifiers() const
MouseButtons GetButtonStates() const
static Pointer New(BaseRenderer *_arga, const Point2D &_argb, MouseButtons _argc, ModifierKeys _argd, MouseButtons _arge)
MouseButtons GetEventButton() const
Handles key events. Takes a std::string for pressed key or special key description, mitk::ModifierKeys for modifiers
int GetWheelDelta() const
static BaseRenderer * GetByName(const std::string &name)
MouseButtons GetEventButton() const
static const std::string xmlEventPropertySignalName()
static Pointer New(BaseRenderer *_arga, DataInteractor *_argb, const std::string &_argc)
static std::string GetPositionInWorld(mitk::InteractionEvent *event)
GetPosition Return World Position as String.
std::string GetKey() const
static std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
MouseButtons GetButtonStates() const
static const std::string xmlTagAttribute()