Browse Source

Integrate projection mapping gui surface and joint events

Now the mouse pressed events from surfaces and joints in projection mapping mode are generating commands in the application layer
master
Krisjanis Rijnieks 9 years ago
parent
commit
5dc8c9dc36
  1. 11
      src/Application/Application.cpp
  2. 2
      src/Application/Application.h
  3. 3
      src/Application/ApplicationBaseState.h
  4. 6
      src/Application/GuiEventType.h
  5. 14
      src/Application/ProjectionMappingState.cpp
  6. 5
      src/Application/ProjectionMappingState.h

11
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);
}

2
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);

3
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){}
};

6
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
};
};

14
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

5
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;

Loading…
Cancel
Save