| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include <boost/statechart/custom_reaction.hpp> |
| | #include <boost/statechart/state_machine.hpp> |
| | #include <boost/statechart/state.hpp> |
| |
|
| | #include "Camera.h" |
| | #include "NavigationStateChart.h" |
| | #include "View3DInventorViewer.h" |
| |
|
| |
|
| | using namespace Gui; |
| | namespace sc = boost::statechart; |
| | using NS = NavigationStateChart; |
| |
|
| | NS::Event::Event() |
| | : flags(new Flags) |
| | {} |
| |
|
| | bool NS::Event::isMouseButtonEvent() const |
| | { |
| | return this->inventor_event->isOfType(SoMouseButtonEvent::getClassTypeId()); |
| | } |
| |
|
| | const SoMouseButtonEvent* NS::Event::asMouseButtonEvent() const |
| | { |
| | return static_cast<const SoMouseButtonEvent*>(this->inventor_event); |
| | } |
| |
|
| | bool NS::Event::isPress(Button button) const |
| | { |
| | return SoMouseButtonEvent::isButtonPressEvent(this->inventor_event, button); |
| | } |
| |
|
| | bool NS::Event::isRelease(Button button) const |
| | { |
| | return SoMouseButtonEvent::isButtonReleaseEvent(this->inventor_event, button); |
| | } |
| |
|
| | bool NS::Event::isKeyPress(Key key) const |
| | { |
| | return SoKeyboardEvent::isKeyPressEvent(this->inventor_event, key); |
| | } |
| |
|
| | bool NS::Event::isKeyRelease(Key key) const |
| | { |
| | return SoKeyboardEvent::isKeyReleaseEvent(this->inventor_event, key); |
| | } |
| |
|
| | bool NS::Event::isKeyboardEvent() const |
| | { |
| | return this->inventor_event->isOfType(SoKeyboardEvent::getClassTypeId()); |
| | } |
| |
|
| | const SoKeyboardEvent* NS::Event::asKeyboardEvent() const |
| | { |
| | return static_cast<const SoKeyboardEvent*>(this->inventor_event); |
| | } |
| |
|
| | bool NS::Event::isLocation2Event() const |
| | { |
| | return this->inventor_event->isOfType(SoLocation2Event::getClassTypeId()); |
| | } |
| |
|
| | const SoLocation2Event* NS::Event::asLocation2Event() const |
| | { |
| | return static_cast<const SoLocation2Event*>(this->inventor_event); |
| | } |
| |
|
| | bool NS::Event::isMotion3Event() const |
| | { |
| | return this->inventor_event->isOfType(SoMotion3Event::getClassTypeId()); |
| | } |
| |
|
| | const SoMotion3Event* NS::Event::asMotion3Event() const |
| | { |
| | return static_cast<const SoMotion3Event*>(this->inventor_event); |
| | } |
| |
|
| | bool NS::Event::isDownButton(unsigned int state) const |
| | { |
| | return mbstate() == state; |
| | } |
| |
|
| | bool NS::Event::isDownNoButton() const |
| | { |
| | return mbstate() == 0; |
| | } |
| |
|
| | bool NS::Event::isDownButton1() const |
| | { |
| | return (mbstate() & BUTTON1DOWN) == BUTTON1DOWN; |
| | } |
| |
|
| | bool NS::Event::isDownButton2() const |
| | { |
| | return (mbstate() & BUTTON2DOWN) == BUTTON2DOWN; |
| | } |
| |
|
| | bool NS::Event::isDownButton3() const |
| | { |
| | return (mbstate() & BUTTON3DOWN) == BUTTON3DOWN; |
| | } |
| |
|
| | bool NS::Event::isDownControl() const |
| | { |
| | return (kbstate() & CTRLDOWN) == CTRLDOWN; |
| | } |
| |
|
| | bool NS::Event::isDownShift() const |
| | { |
| | return (kbstate() & SHIFTDOWN) == SHIFTDOWN; |
| | } |
| |
|
| | bool NS::Event::isDownAlt() const |
| | { |
| | return (kbstate() & ALTDOWN) == ALTDOWN; |
| | } |
| |
|
| |
|
| | |
| |
|
| | TYPESYSTEM_SOURCE_ABSTRACT(Gui::NavigationStateChart, Gui::UserNavigationStyle) |
| |
|
| | NavigationStateChart::NavigationStateChart() |
| | {} |
| |
|
| | NavigationStateChart::~NavigationStateChart() |
| | { |
| | naviMachine.reset(); |
| | } |
| |
|
| | SbBool NavigationStateChart::processSoEvent(const SoEvent* const ev) |
| | { |
| | |
| | |
| | |
| | if (this->isSeekMode()) { |
| | return inherited::processSoEvent(ev); |
| | } |
| |
|
| | |
| | if (!this->isSeekMode() && !this->isAnimating() && this->isViewing()) { |
| | this->setViewing(false); |
| | } |
| |
|
| | |
| | |
| | syncModifierKeys(ev); |
| |
|
| | |
| | if (!viewer->isEditing()) { |
| | if (handleEventInForeground(ev)) { |
| | return true; |
| | } |
| | } |
| |
|
| | NS::Event smev; |
| | smev.inventor_event = ev; |
| |
|
| | |
| | if (ev->isOfType(SoMotion3Event::getClassTypeId())) { |
| | smev.flags->processed = true; |
| | this->processMotionEvent(static_cast<const SoMotion3Event*>(ev)); |
| | return true; |
| | } |
| |
|
| | |
| | if (ev->isOfType(SoKeyboardEvent::getClassTypeId())) { |
| | const auto event = static_cast<const SoKeyboardEvent*>(ev); |
| | smev.flags->processed = processKeyboardEvent(event); |
| | } |
| |
|
| | if (smev.isMouseButtonEvent()) { |
| | const auto button = smev.asMouseButtonEvent()->getButton(); |
| | const SbBool press = smev.asMouseButtonEvent()->getState() == SoButtonEvent::DOWN; |
| | switch (button) { |
| | case SoMouseButtonEvent::BUTTON1: |
| | this->button1down = press; |
| | break; |
| | case SoMouseButtonEvent::BUTTON2: |
| | this->button2down = press; |
| | break; |
| | case SoMouseButtonEvent::BUTTON3: |
| | this->button3down = press; |
| | break; |
| | default: |
| | break; |
| | } |
| | } |
| |
|
| | smev.modifiers = (this->button1down ? NS::Event::BUTTON1DOWN : 0) |
| | | (this->button2down ? NS::Event::BUTTON2DOWN : 0) |
| | | (this->button3down ? NS::Event::BUTTON3DOWN : 0) |
| | | (this->ctrldown ? NS::Event::CTRLDOWN : 0) | (this->shiftdown ? NS::Event::SHIFTDOWN : 0) |
| | | (this->altdown ? NS::Event::ALTDOWN : 0); |
| |
|
| | if (!smev.flags->processed) { |
| | this->naviMachine->process_event(smev); |
| | } |
| |
|
| | if (!smev.flags->propagated && !smev.flags->processed) { |
| | return inherited::processSoEvent(ev); |
| | } |
| |
|
| | return smev.flags->processed; |
| | } |
| |
|