| 240 | } |
| 241 | |
| 242 | mitk::InteractionEvent::Pointer mitk::EventFactory::CreateEvent(PropertyList::Pointer list) |
| 243 | { |
| 244 | // |
| 245 | std::string eventClass, eventVariant; |
| 246 | list->GetStringProperty(InteractionEventConst::xmlParameterEventClass().c_str(), eventClass); |
| 247 | list->GetStringProperty(InteractionEventConst::xmlParameterEventVariant().c_str(), eventVariant); |
| 248 | |
| 249 | // Query all possible attributes, if they are not present, set their default values. |
| 250 | // Position Events & Key Events |
| 251 | std::string strModifiers; |
| 252 | InteractionEvent::ModifierKeys modifiers = InteractionEvent::NoKey; |
| 253 | std::string strEventButton; |
| 254 | InteractionEvent::MouseButtons eventButton = InteractionEvent::NoButton; |
| 255 | std::string strButtonState; |
| 256 | InteractionEvent::MouseButtons buttonState = InteractionEvent::NoButton; |
| 257 | std::string strKey; |
| 258 | std::string key; |
| 259 | std::string strWheelDelta; |
| 260 | int wheelDelta; |
| 261 | std::string strSignalName = ""; |
| 262 | |
| 263 | Point2D pos; |
| 264 | pos.Fill(0); |
| 265 | std::string strPos; |
| 266 | |
| 267 | // Position on screen |
| 268 | if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyPositionOnScreen().c_str(), strPos)) |
| 269 | { |
| 270 | // split comma separated string |
| 271 | int commaPos; |
| 272 | commaPos = strPos.find_first_of(','); |
| 273 | |
| 274 | pos[0] = static_cast<mitk::ScalarType>(std::atof(strPos.substr(0, commaPos).c_str())); |
| 275 | pos[1] = static_cast<mitk::ScalarType>(std::atof(strPos.substr(commaPos + 1, strPos.length()).c_str())); |
| 276 | } |
| 277 | |
| 278 | std::string strWorld; |
| 279 | Point3D worldPos; |
| 280 | worldPos.Fill(0); |
| 281 | // Position in world coordinates |
| 282 | if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyPositionInWorld().c_str(), strWorld)) |
| 283 | { |
| 284 | const std::vector<std::string> coords = split(strWorld, ','); |
| 285 | int i = 0; |
| 286 | for (auto it = coords.cbegin(); it != coords.cend(); ++it, ++i) |
| 287 | { |
| 288 | worldPos[i] = atof((*it).c_str()); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | // Parse modifier information |
| 293 | if (list->GetStringProperty(InteractionEventConst::xmlEventPropertyModifier().c_str(), strModifiers)) |
| 294 | { |
| 295 | std::vector<std::string> mods = split(strModifiers, ','); |
| 296 | for (auto it = mods.begin(); it != mods.end(); ++it) |
| 297 | { |
| 298 | std::transform((*it).cbegin(), (*it).cend(), (*it).begin(), ::toupper); |
| 299 | if (*it == "CTRL") |