diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 180e4a1..c21639b 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -14,7 +14,10 @@ Application::Application(){ ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed); ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased); ofAddListener(ofEvents().mousePressed, this, &Application::onMousePressed); + ofAddListener(Gui::instance()->event, this, &Application::onGuiEvent); + ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed); + ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed); } void Application::setup(){ @@ -120,6 +123,14 @@ void Application::onGuiEvent(GuiEvent & e){ cout << "GUI EVENT: " << e.args.x << ", " << e.args.y << ", " << e.type << endl; } +void Application::onJointPressed(GuiJointEvent & e){ + _state->onJointPressed(this, e); +} + +void Application::onSurfacePressed(GuiSurfaceEvent & e){ + _state->onSurfacePressed(this, e); +} + void Application::addFboSource(FboSource & fboSource){ _mediaServer.addFboSource(fboSource); } diff --git a/src/Application/Application.h b/src/Application/Application.h index 48c8fb6..896762c 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -46,6 +46,8 @@ class Application : public KeyListener { void onMousePressed(ofMouseEventArgs & args); // Then we catch GUI events with this one and create commands void onGuiEvent(GuiEvent & e); + void onJointPressed(GuiJointEvent & e); + void onSurfacePressed(GuiSurfaceEvent & e); // Every state should have it's own GUI layer void addFboSource(FboSource & fboSource); diff --git a/src/Application/ApplicationBaseState.h b/src/Application/ApplicationBaseState.h index 519dc81..9d75f9a 100644 --- a/src/Application/ApplicationBaseState.h +++ b/src/Application/ApplicationBaseState.h @@ -2,6 +2,7 @@ #include "ofEvents.h" #include "ofLog.h" +#include "Gui.h" namespace ofx { namespace piMapper { @@ -16,6 +17,8 @@ class ApplicationBaseState { // Event handler virtual methods virtual void onKeyPressed(Application * app, ofKeyEventArgs & args){} + virtual void onJointPressed(Application * app, GuiJointEvent & e){} + virtual void onSurfacePressed(Application * app, GuiSurfaceEvent & e){} }; diff --git a/src/Application/GuiEventType.h b/src/Application/GuiEventType.h index 7b60128..2a8caf0 100644 --- a/src/Application/GuiEventType.h +++ b/src/Application/GuiEventType.h @@ -8,9 +8,9 @@ struct GuiEventType { SURFACE_HIT, SURFACE_DRAGGED, SURFACE_RELEASED, - HANDLE_HIT, - HANDLE_DRAGGED, - HANDLE_RELEASED + JOINT_PRESSED, + JOINT_RELEASED, + JOINT_DRAGGED }; }; diff --git a/src/Application/ProjectionMappingState.cpp b/src/Application/ProjectionMappingState.cpp index 4e56ba2..cf2c444 100644 --- a/src/Application/ProjectionMappingState.cpp +++ b/src/Application/ProjectionMappingState.cpp @@ -174,5 +174,19 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar } } +void ProjectionMappingState::onJointPressed(Application * app, GuiJointEvent & e){ + app->getCmdManager()->exec(new SelVertexCmd(app->getSurfaceManager(), e.jointIndex)); + app->getCmdManager()->exec(new MvSurfaceVertCmd( + e.jointIndex, + app->getSurfaceManager()->getSelectedSurface())); +} + +void ProjectionMappingState::onSurfacePressed(Application * app, GuiSurfaceEvent & e){ + cout << "ProjectionMappingState::onSurfacePressed" << endl; + if(app->getSurfaceManager()->getSelectedSurface() != e.surface){ + app->getCmdManager()->exec(new SelSurfaceCmd(app->getSurfaceManager(), e.surface )); + } +} + } // namespace piMapper } // namespace ofx \ No newline at end of file diff --git a/src/Application/ProjectionMappingState.h b/src/Application/ProjectionMappingState.h index 10cef68..4dbdad8 100644 --- a/src/Application/ProjectionMappingState.h +++ b/src/Application/ProjectionMappingState.h @@ -14,9 +14,12 @@ #include "SelPrevSurfaceCmd.h" #include "SelNextVertexCmd.h" #include "SelPrevVertexCmd.h" +#include "SelVertexCmd.h" +#include "SelSurfaceCmd.h" #include "MvSelectionCmd.h" #include "TogglePerspectiveCmd.h" #include "SurfaceType.h" +#include "Gui.h" namespace ofx { namespace piMapper { @@ -27,6 +30,8 @@ class ProjectionMappingState : public ApplicationBaseState { static ProjectionMappingState * instance(); void draw(Application * app); void onKeyPressed(Application * app, ofKeyEventArgs & args); + void onJointPressed(Application * app, GuiJointEvent & e); + void onSurfacePressed(Application * app, GuiSurfaceEvent & e); private: static ProjectionMappingState * _instance;