Skip to content

Commit

Permalink
Gui: GestureNavigationStyle: logging option
Browse files Browse the repository at this point in the history
To enable logging, execute:

App.ParamGet("User parameter:BaseApp/Preferences/View").SetBool("NavigationDebug",True)
  • Loading branch information
DeepSOIC committed May 27, 2019
1 parent 6d7400f commit 5a4373a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
50 changes: 35 additions & 15 deletions src/Gui/GestureNavigationStyle.cpp
Expand Up @@ -227,7 +227,8 @@ class NS::NaviMachine : public sc::state_machine<NS::NaviMachine, NS::IdleState>

public:
virtual void processEvent(NS::Event& ev) {
ev.log();
if (ns.logging)
ev.log();
this->process_event(ev);
}
};
Expand All @@ -239,8 +240,10 @@ class NS::IdleState : public sc::state<NS::IdleState, NS::NaviMachine>

IdleState(my_context ctx):my_base(ctx)
{
this->outermost_context().ns.setViewingMode(NavigationStyle::IDLE);
Base::Console().Log(" -> IdleState\n");
auto &ns = this->outermost_context().ns;
ns.setViewingMode(NavigationStyle::IDLE);
if (ns.logging)
Base::Console().Log(" -> IdleState\n");
}
virtual ~IdleState(){}

Expand Down Expand Up @@ -357,6 +360,8 @@ class NS::AwaitingMoveState : public sc::state<NS::AwaitingMoveState, NS::NaviMa
AwaitingMoveState(my_context ctx):my_base(ctx)
{
auto &ns = this->outermost_context().ns;
if (ns.logging)
Base::Console().Log(" -> AwaitingMoveState\n");
ns.setViewingMode(NavigationStyle::IDLE);
this->base_pos = static_cast<const NS::Event*>(this->triggering_event())->inventor_event->getPosition();
this->since = static_cast<const NS::Event*>(this->triggering_event())->inventor_event->getTime();
Expand Down Expand Up @@ -493,9 +498,11 @@ class NS::RotateState : public sc::state<NS::RotateState, NS::NaviMachine>
public:
RotateState(my_context ctx):my_base(ctx)
{
this->outermost_context().ns.setViewingMode(NavigationStyle::DRAGGING);
auto &ns = this->outermost_context().ns;
ns.setViewingMode(NavigationStyle::DRAGGING);
this->base_pos = static_cast<const NS::Event*>(this->triggering_event())->inventor_event->getPosition();
Base::Console().Log(" -> RotateState\n");
if (ns.logging)
Base::Console().Log(" -> RotateState\n");
}
virtual ~RotateState(){}

Expand Down Expand Up @@ -537,7 +544,8 @@ class NS::PanState : public sc::state<NS::PanState, NS::NaviMachine>
auto &ns = this->outermost_context().ns;
ns.setViewingMode(NavigationStyle::PANNING);
this->base_pos = static_cast<const NS::Event*>(this->triggering_event())->inventor_event->getPosition();
Base::Console().Log(" -> PanState\n");
if (ns.logging)
Base::Console().Log(" -> PanState\n");
this->ratio = ns.viewer->getSoRenderManager()->getViewportRegion().getViewportAspectRatio();
ns.pan(ns.viewer->getSoRenderManager()->getCamera());//set up panningplane
}
Expand Down Expand Up @@ -583,7 +591,8 @@ class NS::StickyPanState : public sc::state<NS::StickyPanState, NS::NaviMachine>
auto &ns = this->outermost_context().ns;
ns.setViewingMode(NavigationStyle::PANNING);
this->base_pos = static_cast<const NS::Event*>(this->triggering_event())->inventor_event->getPosition();
Base::Console().Log(" -> StickyPanState\n");
if (ns.logging)
Base::Console().Log(" -> StickyPanState\n");
this->ratio = ns.viewer->getSoRenderManager()->getViewportRegion().getViewportAspectRatio();
ns.pan(ns.viewer->getSoRenderManager()->getCamera());//set up panningplane
}
Expand Down Expand Up @@ -628,7 +637,8 @@ class NS::TiltState : public sc::state<NS::TiltState, NS::NaviMachine>
auto &ns = this->outermost_context().ns;
ns.setViewingMode(NavigationStyle::DRAGGING);
this->base_pos = static_cast<const NS::Event*>(this->triggering_event())->inventor_event->getPosition();
Base::Console().Log(" -> TiltState\n");
if (ns.logging)
Base::Console().Log(" -> TiltState\n");
ns.pan(ns.viewer->getSoRenderManager()->getCamera());//set up panningplane
}
virtual ~TiltState(){}
Expand Down Expand Up @@ -677,7 +687,8 @@ class NS::GestureState : public sc::state<NS::GestureState, NS::NaviMachine>
auto &ns = this->outermost_context().ns;
ns.setViewingMode(NavigationStyle::PANNING);
this->base_pos = static_cast<const NS::Event*>(this->triggering_event())->inventor_event->getPosition();
Base::Console().Log(" -> GestureState\n");
if (ns.logging)
Base::Console().Log(" -> GestureState\n");
ns.pan(ns.viewer->getSoRenderManager()->getCamera());//set up panningplane
this->ratio = ns.viewer->getSoRenderManager()->getViewportRegion().getViewportAspectRatio();
enableTilt = !(App::GetApplication().GetParameterGroupByPath
Expand Down Expand Up @@ -754,7 +765,9 @@ class NS::AwaitingReleaseState : public sc::state<NS::AwaitingReleaseState, NS::
public:
AwaitingReleaseState(my_context ctx):my_base(ctx)
{
Base::Console().Log(" -> AwaitingReleaseState\n");
auto &ns = this->outermost_context().ns;
if (ns.logging)
Base::Console().Log(" -> AwaitingReleaseState\n");
}
virtual ~AwaitingReleaseState(){}

Expand Down Expand Up @@ -804,7 +817,8 @@ class NS::InteractState : public sc::state<NS::InteractState, NS::NaviMachine>
{
auto &ns = this->outermost_context().ns;
ns.setViewingMode(NavigationStyle::INTERACT);
Base::Console().Log(" -> InteractState\n");
if (ns.logging)
Base::Console().Log(" -> InteractState\n");
}
virtual ~InteractState(){}

Expand All @@ -831,6 +845,8 @@ GestureNavigationStyle::GestureNavigationStyle()
: naviMachine(new NS::NaviMachine(*this)),
postponedEvents(*this)
{
this->logging = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View")->GetBool("NavigationDebug");
mouseMoveThreshold = QApplication::startDragDistance();
naviMachine->initiate();

Expand Down Expand Up @@ -966,11 +982,13 @@ void GestureNavigationStyle::onRollGesture(int direction)
{
std::string cmd;
if (direction == +1){
Base::Console().Log("Roll forward gesture\n");
if (logging)
Base::Console().Log("Roll forward gesture\n");
cmd = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View")->GetASCII("GestureRollFwdCommand");
} else if (direction == -1) {
Base::Console().Log("Roll backward gesture\n");
if (logging)
Base::Console().Log("Roll backward gesture\n");
cmd = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View")->GetASCII("GestureRollBackCommand");
}
Expand Down Expand Up @@ -1002,8 +1020,10 @@ void GestureNavigationStyle::EventQueue::post(const NS::Event& ev)
{
ev.flags->processed = true;
this->push(*ev.asMouseButtonEvent());
Base::Console().Log("postponed: ");
ev.log();
if (ns.logging){
Base::Console().Log("postponed: ");
ev.log();
}
}

void GestureNavigationStyle::EventQueue::discardAll()
Expand Down
1 change: 1 addition & 0 deletions src/Gui/GestureNavigationStyle.h
Expand Up @@ -96,6 +96,7 @@ class GestureNavigationStyle: public UserNavigationStyle
int mouseMoveThreshold = 5;
///used by roll gesture detection logic, in AwaitingMoveState and AwaitingReleaseState.
int rollDir = 0;
bool logging = false;

protected: //helper functions
bool isDraggerUnderCursor(SbVec2s pos);
Expand Down

0 comments on commit 5a4373a

Please sign in to comment.