From c149613721abb9aecd670e301aa881953d393a86 Mon Sep 17 00:00:00 2001 From: Theodoros Papatheodorou Date: Sun, 19 Nov 2017 00:01:28 +0000 Subject: [PATCH 1/3] removed references to rPI only addons so that it runs on desktop --- example/addons.make | 1 - example_camera/addons.make | 1 - 2 files changed, 2 deletions(-) diff --git a/example/addons.make b/example/addons.make index aee7c01..0d1404c 100644 --- a/example/addons.make +++ b/example/addons.make @@ -1,4 +1,3 @@ ofxPiMapper ofxXmlSettings ofxGui -ofxOMXPlayer diff --git a/example_camera/addons.make b/example_camera/addons.make index c3aa2a3..0d1404c 100644 --- a/example_camera/addons.make +++ b/example_camera/addons.make @@ -1,4 +1,3 @@ ofxPiMapper ofxXmlSettings ofxGui -ofxRPiCameraVideoGrabber From 9357530b34de70c64cfd6c938d04b09f00b79a92 Mon Sep 17 00:00:00 2001 From: Theodoros Papatheodorou Date: Thu, 23 Nov 2017 15:05:06 +0000 Subject: [PATCH 2/3] added ability to select a source by string name. Basically accessor functions to the SetSourceCmd class --- src/Application/Application.cpp | 45 +++++++++++++++++++++------------ src/Application/Application.h | 35 ++++++++++++------------- src/ofxPiMapper.cpp | 4 +++ src/ofxPiMapper.h | 21 +++++++-------- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 88aa30b..7ecaf44 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -7,16 +7,16 @@ namespace piMapper { Application::Application(){ _keySequence = ""; _surfaceManager.setMediaServer(&_mediaServer); - + // Set initial mode setState(PresentationMode::instance()); ofHideCursor(); - + ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed); ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed); ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed); ofAddListener(Gui::instance()->guiEvent, this, &Application::onGuiEvent); - + _lastSaveTime = 0.0f; _autoSaveInterval = 60.0f; } @@ -35,7 +35,7 @@ void Application::setup(){ throw runtime_error("ofxPiMapper: Failed to create default settings file."); } } - + // Setup all states. PresentationMode::instance()->setup(this); TextureMappingMode::instance()->setup(this); @@ -49,7 +49,7 @@ void Application::setup(){ void Application::update(){ _mediaServer.update(); _state->update(this); - + // Autosave, do it only of the mode is not presentation mode if(_state != PresentationMode::instance()){ float timeNow = ofGetElapsedTimef(); @@ -72,7 +72,7 @@ void Application::draw(){ // Here we handle application state changes only void Application::onKeyPressed(ofKeyEventArgs & args){ - + // Key sequence based commands. Last three keys are taken into account. _keySequence += args.key; if(_keySequence.size() >= 3){ @@ -100,11 +100,11 @@ void Application::onKeyPressed(ofKeyEventArgs & args){ case OF_KEY_SHIFT: _shiftKeyDown = true; break; - + case '/': _shiftKeyDown = !_shiftKeyDown; break; - + case '1': setPresentationMode(); break; @@ -132,7 +132,7 @@ void Application::onKeyPressed(ofKeyEventArgs & args){ case 'z': undo(); break; - + case 'n': setNextPreset(); break; @@ -325,14 +325,14 @@ void Application::selectPrevVertex(){ void Application::selectVertex(int surface, int vertex){ if(getSurfaceManager()->size()){ - + // TODO: use one command instead of two - + getCmdManager()->exec( new SelSurfaceCmd( getSurfaceManager(), getSurfaceManager()->getSurface(surface))); - + getCmdManager()->exec( new SelVertexCmd( getSurfaceManager(), @@ -398,7 +398,7 @@ void Application::moveLayerUp(){ getSurfaceManager()->getActivePreset()->size() - 1)){ return; } - + getCmdManager()->exec( new MvLayerUpCmd( getSurfaceManager()->getActivePreset(), @@ -412,7 +412,7 @@ void Application::moveLayerDown(){ getSurfaceManager()->getActivePreset()->at(0)){ return; } - + getCmdManager()->exec( new MvLayerDnCmd( 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(){ if(getSurfaceManager()->getSelectedSurface() != 0){ if(getSurfaceManager()->getSelectedSurface()->getType() == @@ -519,7 +532,7 @@ void Application::togglePause(){ if(getSurfaceManager()->getSelectedSurface() == 0){ return; } - + if(getSurfaceManager()->getSelectedSurface()->getSource()->getType() == SourceType::SOURCE_TYPE_VIDEO){ getCmdManager()->exec( @@ -535,7 +548,7 @@ void Application::moveTexCoord(int texCoordIndex, ofVec2f by){ getCmdManager()->exec(new MvAllTexCoordsCmd( getSurfaceManager()->getSelectedSurface(), &Gui::instance()->getTextureEditorWidget())); - + Gui::instance()->getTextureEditorWidget().moveSelection(by); } } diff --git a/src/Application/Application.h b/src/Application/Application.h index 0e81208..fd455da 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -66,22 +66,22 @@ class Application { void setup(); void update(); void draw(); - + void onKeyPressed(ofKeyEventArgs & args); void onKeyReleased(ofKeyEventArgs & args); - + // We use this to pass mouse events into the GUI layer void onMousePressed(ofMouseEventArgs & args); void onMouseReleased(ofMouseEventArgs & args); void onMouseDragged(ofMouseEventArgs & args); - + // Then we catch GUI events with this one and create commands void onJointPressed(GuiJointEvent & e); void onSurfacePressed(GuiSurfaceEvent & e); void onBackgroundPressed(GuiBackgroundEvent & e); - + void onGuiEvent(GuiEvent & e); - + void addFboSource(FboSource & fboSource); void addFboSource(FboSource * fboSource); void createSurface(SurfaceType type); @@ -97,7 +97,7 @@ class Application { SurfaceManager * getSurfaceManager(){ return &_surfaceManager; } CmdManager * getCmdManager(){ return &_cmdManager; } MediaServer * getMediaServer(){ return &_mediaServer; } - + // Command executors void selectSurface(int i); void selectNextSurface(); @@ -107,14 +107,14 @@ class Application { void selectVertex(int surface, int vertex); void selectNextTexCoord(); void selectPrevTexCoord(); - - /* + + /* Context sensitive move. Moves vertex when in projection mapping mode. Moves texture coordinate when in texture mapping mode. */ void moveSelection(ofVec2f by); - + void setPresentationMode(); void setTextureMode(); void setProjectionMode(); @@ -125,6 +125,7 @@ class Application { void scaleDown(); void duplicateSurface(); void setNextSource(); + void setFboSource(string sourceId); void addGridRow(); void addGridColumn(); void removeGridRow(); @@ -135,33 +136,33 @@ class Application { // Make it so that other parts of the application react to the change. void undo(); void deselect(); - + void setPreset(unsigned int i); void setNextPreset(); - + // System commands void reboot(); void shutdown(); - + protected: void setState(ApplicationBaseMode * st); - + private: friend class ApplicationBaseMode; friend class SetApplicationModeCmd; ApplicationBaseMode * _state; - + CmdManager _cmdManager; MediaServer _mediaServer; SurfaceManager _surfaceManager; Info _info; - + bool _shiftKeyDown; - + float _lastSaveTime; float _autoSaveInterval; - + string _keySequence; }; diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index 4289c12..43d40da 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -166,6 +166,10 @@ void ofxPiMapper::setNextSource(){ _application.setNextSource(); } +void ofxPiMapper::setFboSource(string sourceId){ + _application.setFboSource(sourceId); +} + void ofxPiMapper::reboot(){ _application.reboot(); } diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 12c4205..f85643b 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -14,31 +14,31 @@ class ofxPiMapper { void setup(); void update(); void draw(); - + void keyPressed(int key); void keyReleased(int key); - + void mousePressed(int x, int y, int button); void mouseReleased(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); - + // Application void setInfoText(string text); void toggleInfo(); void undo(); void deselect(); - + // Modes void setMode(ofx::piMapper::Mode m); ofx::piMapper::Mode getMode(); - + // Project void saveProject(); bool loadProject(string filename); - + // Presets unsigned int getNumPresets(); unsigned int getActivePresetIndex(); @@ -46,7 +46,7 @@ class ofxPiMapper { void setNextPreset(); void cloneActivePreset(); void eraseActivePreset(); - + // Surfaces, active preset unsigned int getNumSurfaces(); int getSelectedSurface(); @@ -69,10 +69,11 @@ class ofxPiMapper { void moveSelection(ofVec2f by); void createSurface(ofx::piMapper::SurfaceType type); void eraseSurface(int i); - + // Sources, selected surface void setNextSource(); - + void setFboSource(string sourceId); + // System commands void reboot(); void shutdown(); From 8b67854e6754d5fead1f51bda4a30fba08e9de38 Mon Sep 17 00:00:00 2001 From: Theodoros Papatheodorou Date: Thu, 23 Nov 2017 15:31:33 +0000 Subject: [PATCH 3/3] made examples compatible with Rpi again by adding correct addons --- example/addons.make | 1 + example_camera/addons.make | 1 + 2 files changed, 2 insertions(+) diff --git a/example/addons.make b/example/addons.make index 0d1404c..aee7c01 100644 --- a/example/addons.make +++ b/example/addons.make @@ -1,3 +1,4 @@ ofxPiMapper ofxXmlSettings ofxGui +ofxOMXPlayer diff --git a/example_camera/addons.make b/example_camera/addons.make index 0d1404c..c3aa2a3 100644 --- a/example_camera/addons.make +++ b/example_camera/addons.make @@ -1,3 +1,4 @@ ofxPiMapper ofxXmlSettings ofxGui +ofxRPiCameraVideoGrabber