void ViewProvider::eventCallback(void * ud, SoEventCallback * node) { const SoEvent * ev = node->getEvent(); Gui::View3DInventorViewer* viewer = reinterpret_cast<Gui::View3DInventorViewer*>(node->getUserData()); ViewProvider *self = reinterpret_cast<ViewProvider*>(ud); assert(self); try { // Keyboard events if (ev->getTypeId().isDerivedFrom(SoKeyboardEvent::getClassTypeId())) { SoKeyboardEvent * ke = (SoKeyboardEvent *)ev; const SbBool press = ke->getState() == SoButtonEvent::DOWN ? true : false; switch (ke->getKey()) { case SoKeyboardEvent::ESCAPE: if (self->keyPressed (press, ke->getKey())) { node->setHandled(); } else { Gui::TimerFunction* func = new Gui::TimerFunction(); func->setAutoDelete(true); Gui::Document* doc = Gui::Application::Instance->activeDocument(); func->setFunction(boost::bind(&Document::resetEdit, doc)); QTimer::singleShot(0, func, SLOT(timeout())); } break; default: // call the virtual method if (self->keyPressed (press, ke->getKey())) node->setHandled(); break; } } // switching the mouse buttons else if (ev->getTypeId().isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) { const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev; const int button = event->getButton(); const SbBool press = event->getState() == SoButtonEvent::DOWN ? true : false; // call the virtual method if (self->mouseButtonPressed(button,press,ev->getPosition(),viewer)) node->setHandled(); } // Mouse Movement handling else if (ev->getTypeId().isDerivedFrom(SoLocation2Event::getClassTypeId())) { if (self->mouseMove(ev->getPosition(),viewer)) node->setHandled(); } } catch (const Base::Exception& e) { Base::Console().Error("Unhandled exception in ViewProvider::eventCallback: %s\n", e.what()); } catch (const std::exception& e) { Base::Console().Error("Unhandled std exception in ViewProvider::eventCallback: %s\n", e.what()); } catch (...) { Base::Console().Error("Unhandled unknown C++ exception in ViewProvider::eventCallback"); } }