Browse Source

Merge remote-tracking branch 'kr15h/master' into magSlideShowSource

master
c-mendoza 8 years ago
parent
commit
c079f50ce7
  1. 45
      src/Application/Application.cpp
  2. 35
      src/Application/Application.h
  3. 4
      src/ofxPiMapper.cpp
  4. 21
      src/ofxPiMapper.h

45
src/Application/Application.cpp

@ -7,16 +7,16 @@ namespace piMapper {
Application::Application(){ Application::Application(){
_keySequence = ""; _keySequence = "";
_surfaceManager.setMediaServer(&_mediaServer); _surfaceManager.setMediaServer(&_mediaServer);
// Set initial mode // Set initial mode
setState(PresentationMode::instance()); setState(PresentationMode::instance());
ofHideCursor(); ofHideCursor();
ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed); ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed);
ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed); ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed);
ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed); ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed);
ofAddListener(Gui::instance()->guiEvent, this, &Application::onGuiEvent); ofAddListener(Gui::instance()->guiEvent, this, &Application::onGuiEvent);
_lastSaveTime = 0.0f; _lastSaveTime = 0.0f;
_autoSaveInterval = 60.0f; _autoSaveInterval = 60.0f;
} }
@ -35,7 +35,7 @@ void Application::setup(){
throw runtime_error("ofxPiMapper: Failed to create default settings file."); throw runtime_error("ofxPiMapper: Failed to create default settings file.");
} }
} }
// Setup all states. // Setup all states.
PresentationMode::instance()->setup(this); PresentationMode::instance()->setup(this);
TextureMappingMode::instance()->setup(this); TextureMappingMode::instance()->setup(this);
@ -49,7 +49,7 @@ void Application::setup(){
void Application::update(){ void Application::update(){
_mediaServer.update(); _mediaServer.update();
_state->update(this); _state->update(this);
// Autosave, do it only of the mode is not presentation mode // Autosave, do it only of the mode is not presentation mode
if(_state != PresentationMode::instance()){ if(_state != PresentationMode::instance()){
float timeNow = ofGetElapsedTimef(); float timeNow = ofGetElapsedTimef();
@ -72,7 +72,7 @@ void Application::draw(){
// Here we handle application state changes only // Here we handle application state changes only
void Application::onKeyPressed(ofKeyEventArgs & args){ void Application::onKeyPressed(ofKeyEventArgs & args){
// Key sequence based commands. Last three keys are taken into account. // Key sequence based commands. Last three keys are taken into account.
_keySequence += args.key; _keySequence += args.key;
if(_keySequence.size() >= 3){ if(_keySequence.size() >= 3){
@ -100,11 +100,11 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
case OF_KEY_SHIFT: case OF_KEY_SHIFT:
_shiftKeyDown = true; _shiftKeyDown = true;
break; break;
case '/': case '/':
_shiftKeyDown = !_shiftKeyDown; _shiftKeyDown = !_shiftKeyDown;
break; break;
case '1': case '1':
setPresentationMode(); setPresentationMode();
break; break;
@ -132,7 +132,7 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
case 'z': case 'z':
undo(); undo();
break; break;
case 'n': case 'n':
setNextPreset(); setNextPreset();
break; break;
@ -325,14 +325,14 @@ void Application::selectPrevVertex(){
void Application::selectVertex(int surface, int vertex){ void Application::selectVertex(int surface, int vertex){
if(getSurfaceManager()->size()){ if(getSurfaceManager()->size()){
// TODO: use one command instead of two // TODO: use one command instead of two
getCmdManager()->exec( getCmdManager()->exec(
new SelSurfaceCmd( new SelSurfaceCmd(
getSurfaceManager(), getSurfaceManager(),
getSurfaceManager()->getSurface(surface))); getSurfaceManager()->getSurface(surface)));
getCmdManager()->exec( getCmdManager()->exec(
new SelVertexCmd( new SelVertexCmd(
getSurfaceManager(), getSurfaceManager(),
@ -398,7 +398,7 @@ void Application::moveLayerUp(){
getSurfaceManager()->getActivePreset()->size() - 1)){ getSurfaceManager()->getActivePreset()->size() - 1)){
return; return;
} }
getCmdManager()->exec( getCmdManager()->exec(
new MvLayerUpCmd( new MvLayerUpCmd(
getSurfaceManager()->getActivePreset(), getSurfaceManager()->getActivePreset(),
@ -412,7 +412,7 @@ void Application::moveLayerDown(){
getSurfaceManager()->getActivePreset()->at(0)){ getSurfaceManager()->getActivePreset()->at(0)){
return; return;
} }
getCmdManager()->exec( getCmdManager()->exec(
new MvLayerDnCmd( new MvLayerDnCmd(
getSurfaceManager()->getActivePreset(), getSurfaceManager()->getActivePreset(),
@ -463,6 +463,19 @@ void Application::setNextSource(){
} }
} }
void Application::setFboSource(string sourceId){
if(getSurfaceManager()->getSelectedSurface() != 0){
getCmdManager()->exec(
new SetSourceCmd(
SourceType::SOURCE_TYPE_FBO,
sourceId,
getSurfaceManager()->getSelectedSurface(),
&Gui::instance()->getSourcesEditorWidget()));
}else{
getCmdManager()->exec(new SelNextSurfaceCmd(getSurfaceManager()));
}
}
void Application::addGridRow(){ void Application::addGridRow(){
if(getSurfaceManager()->getSelectedSurface() != 0){ if(getSurfaceManager()->getSelectedSurface() != 0){
if(getSurfaceManager()->getSelectedSurface()->getType() == if(getSurfaceManager()->getSelectedSurface()->getType() ==
@ -519,7 +532,7 @@ void Application::togglePause(){
if(getSurfaceManager()->getSelectedSurface() == 0){ if(getSurfaceManager()->getSelectedSurface() == 0){
return; return;
} }
if(getSurfaceManager()->getSelectedSurface()->getSource()->getType() == if(getSurfaceManager()->getSelectedSurface()->getSource()->getType() ==
SourceType::SOURCE_TYPE_VIDEO){ SourceType::SOURCE_TYPE_VIDEO){
getCmdManager()->exec( getCmdManager()->exec(
@ -535,7 +548,7 @@ void Application::moveTexCoord(int texCoordIndex, ofVec2f by){
getCmdManager()->exec(new MvAllTexCoordsCmd( getCmdManager()->exec(new MvAllTexCoordsCmd(
getSurfaceManager()->getSelectedSurface(), getSurfaceManager()->getSelectedSurface(),
&Gui::instance()->getTextureEditorWidget())); &Gui::instance()->getTextureEditorWidget()));
Gui::instance()->getTextureEditorWidget().moveSelection(by); Gui::instance()->getTextureEditorWidget().moveSelection(by);
} }
} }

35
src/Application/Application.h

@ -66,22 +66,22 @@ class Application {
void setup(); void setup();
void update(); void update();
void draw(); void draw();
void onKeyPressed(ofKeyEventArgs & args); void onKeyPressed(ofKeyEventArgs & args);
void onKeyReleased(ofKeyEventArgs & args); void onKeyReleased(ofKeyEventArgs & args);
// We use this to pass mouse events into the GUI layer // We use this to pass mouse events into the GUI layer
void onMousePressed(ofMouseEventArgs & args); void onMousePressed(ofMouseEventArgs & args);
void onMouseReleased(ofMouseEventArgs & args); void onMouseReleased(ofMouseEventArgs & args);
void onMouseDragged(ofMouseEventArgs & args); void onMouseDragged(ofMouseEventArgs & args);
// Then we catch GUI events with this one and create commands // Then we catch GUI events with this one and create commands
void onJointPressed(GuiJointEvent & e); void onJointPressed(GuiJointEvent & e);
void onSurfacePressed(GuiSurfaceEvent & e); void onSurfacePressed(GuiSurfaceEvent & e);
void onBackgroundPressed(GuiBackgroundEvent & e); void onBackgroundPressed(GuiBackgroundEvent & e);
void onGuiEvent(GuiEvent & e); void onGuiEvent(GuiEvent & e);
void addFboSource(FboSource & fboSource); void addFboSource(FboSource & fboSource);
void addFboSource(FboSource * fboSource); void addFboSource(FboSource * fboSource);
void createSurface(SurfaceType type); void createSurface(SurfaceType type);
@ -97,7 +97,7 @@ class Application {
SurfaceManager * getSurfaceManager(){ return &_surfaceManager; } SurfaceManager * getSurfaceManager(){ return &_surfaceManager; }
CmdManager * getCmdManager(){ return &_cmdManager; } CmdManager * getCmdManager(){ return &_cmdManager; }
MediaServer * getMediaServer(){ return &_mediaServer; } MediaServer * getMediaServer(){ return &_mediaServer; }
// Command executors // Command executors
void selectSurface(int i); void selectSurface(int i);
void selectNextSurface(); void selectNextSurface();
@ -107,14 +107,14 @@ class Application {
void selectVertex(int surface, int vertex); void selectVertex(int surface, int vertex);
void selectNextTexCoord(); void selectNextTexCoord();
void selectPrevTexCoord(); void selectPrevTexCoord();
/* /*
Context sensitive move. Context sensitive move.
Moves vertex when in projection mapping mode. Moves vertex when in projection mapping mode.
Moves texture coordinate when in texture mapping mode. Moves texture coordinate when in texture mapping mode.
*/ */
void moveSelection(ofVec2f by); void moveSelection(ofVec2f by);
void setPresentationMode(); void setPresentationMode();
void setTextureMode(); void setTextureMode();
void setProjectionMode(); void setProjectionMode();
@ -125,6 +125,7 @@ class Application {
void scaleDown(); void scaleDown();
void duplicateSurface(); void duplicateSurface();
void setNextSource(); void setNextSource();
void setFboSource(string sourceId);
void addGridRow(); void addGridRow();
void addGridColumn(); void addGridColumn();
void removeGridRow(); void removeGridRow();
@ -135,33 +136,33 @@ class Application {
// Make it so that other parts of the application react to the change. // Make it so that other parts of the application react to the change.
void undo(); void undo();
void deselect(); void deselect();
void setPreset(unsigned int i); void setPreset(unsigned int i);
void setNextPreset(); void setNextPreset();
// System commands // System commands
void reboot(); void reboot();
void shutdown(); void shutdown();
protected: protected:
void setState(ApplicationBaseMode * st); void setState(ApplicationBaseMode * st);
private: private:
friend class ApplicationBaseMode; friend class ApplicationBaseMode;
friend class SetApplicationModeCmd; friend class SetApplicationModeCmd;
ApplicationBaseMode * _state; ApplicationBaseMode * _state;
CmdManager _cmdManager; CmdManager _cmdManager;
MediaServer _mediaServer; MediaServer _mediaServer;
SurfaceManager _surfaceManager; SurfaceManager _surfaceManager;
Info _info; Info _info;
bool _shiftKeyDown; bool _shiftKeyDown;
float _lastSaveTime; float _lastSaveTime;
float _autoSaveInterval; float _autoSaveInterval;
string _keySequence; string _keySequence;
}; };

4
src/ofxPiMapper.cpp

@ -166,6 +166,10 @@ void ofxPiMapper::setNextSource(){
_application.setNextSource(); _application.setNextSource();
} }
void ofxPiMapper::setFboSource(string sourceId){
_application.setFboSource(sourceId);
}
void ofxPiMapper::reboot(){ void ofxPiMapper::reboot(){
_application.reboot(); _application.reboot();
} }

21
src/ofxPiMapper.h

@ -14,31 +14,31 @@ class ofxPiMapper {
void setup(); void setup();
void update(); void update();
void draw(); void draw();
void keyPressed(int key); void keyPressed(int key);
void keyReleased(int key); void keyReleased(int key);
void mousePressed(int x, int y, int button); void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button); void mouseReleased(int x, int y, int button);
void mouseDragged(int x, int y, int button); void mouseDragged(int x, int y, int button);
void registerFboSource(ofx::piMapper::FboSource & fboSource); void registerFboSource(ofx::piMapper::FboSource & fboSource);
void registerFboSource(ofx::piMapper::FboSource * fboSource); void registerFboSource(ofx::piMapper::FboSource * fboSource);
// Application // Application
void setInfoText(string text); void setInfoText(string text);
void toggleInfo(); void toggleInfo();
void undo(); void undo();
void deselect(); void deselect();
// Modes // Modes
void setMode(ofx::piMapper::Mode m); void setMode(ofx::piMapper::Mode m);
ofx::piMapper::Mode getMode(); ofx::piMapper::Mode getMode();
// Project // Project
void saveProject(); void saveProject();
bool loadProject(string filename); bool loadProject(string filename);
// Presets // Presets
unsigned int getNumPresets(); unsigned int getNumPresets();
unsigned int getActivePresetIndex(); unsigned int getActivePresetIndex();
@ -46,7 +46,7 @@ class ofxPiMapper {
void setNextPreset(); void setNextPreset();
void cloneActivePreset(); void cloneActivePreset();
void eraseActivePreset(); void eraseActivePreset();
// Surfaces, active preset // Surfaces, active preset
unsigned int getNumSurfaces(); unsigned int getNumSurfaces();
int getSelectedSurface(); int getSelectedSurface();
@ -69,10 +69,11 @@ class ofxPiMapper {
void moveSelection(ofVec2f by); void moveSelection(ofVec2f by);
void createSurface(ofx::piMapper::SurfaceType type); void createSurface(ofx::piMapper::SurfaceType type);
void eraseSurface(int i); void eraseSurface(int i);
// Sources, selected surface // Sources, selected surface
void setNextSource(); void setNextSource();
void setFboSource(string sourceId);
// System commands // System commands
void reboot(); void reboot();
void shutdown(); void shutdown();

Loading…
Cancel
Save