From a722ef1b2f9e3f3f5f5a68406ea8d1dce4f7c5d5 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Thu, 29 Sep 2016 16:48:59 +0300 Subject: [PATCH] Rename application states to modes --- src/Application/Application.cpp | 24 ++++++------ src/Application/Application.h | 20 +++++----- src/Application/Modes/ApplicationBaseMode.cpp | 12 ++++++ .../ApplicationBaseMode.h} | 6 +-- src/Application/Modes/PresentationMode.cpp | 29 ++++++++++++++ .../PresentationMode.h} | 8 ++-- .../ProjectionMappingMode.cpp} | 32 ++++++++-------- .../ProjectionMappingMode.h} | 8 ++-- .../SourceSelectionMode.cpp} | 12 +++--- .../SourceSelectionMode.h} | 6 +-- .../TextureMappingMode.cpp} | 38 +++++++++---------- .../TextureMappingMode.h} | 8 ++-- .../States/ApplicationBaseState.cpp | 12 ------ src/Application/States/PresentationState.cpp | 29 -------------- src/Commands/SetApplicationStateCmd.cpp | 10 ++--- src/Commands/SetApplicationStateCmd.h | 8 ++-- src/Commands/SetTexMapDrawModeCmd.cpp | 2 +- src/Commands/SetTexMapDrawModeCmd.h | 8 ++-- 18 files changed, 136 insertions(+), 136 deletions(-) create mode 100644 src/Application/Modes/ApplicationBaseMode.cpp rename src/Application/{States/ApplicationBaseState.h => Modes/ApplicationBaseMode.h} (87%) create mode 100644 src/Application/Modes/PresentationMode.cpp rename src/Application/{States/PresentationState.h => Modes/PresentationMode.h} (71%) rename src/Application/{States/ProjectionMappingState.cpp => Modes/ProjectionMappingMode.cpp} (90%) rename src/Application/{States/ProjectionMappingState.h => Modes/ProjectionMappingMode.h} (90%) rename src/Application/{States/SourceSelectionState.cpp => Modes/SourceSelectionMode.cpp} (69%) rename src/Application/{States/SourceSelectionState.h => Modes/SourceSelectionMode.h} (70%) rename src/Application/{States/TextureMappingState.cpp => Modes/TextureMappingMode.cpp} (86%) rename src/Application/{States/TextureMappingState.h => Modes/TextureMappingMode.h} (89%) delete mode 100644 src/Application/States/ApplicationBaseState.cpp delete mode 100644 src/Application/States/PresentationState.cpp diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 7a9ed17..e5aa039 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -1,5 +1,5 @@ #include "Application.h" -#include "PresentationState.h" +#include "PresentationMode.h" namespace ofx { namespace piMapper { @@ -9,7 +9,7 @@ Application::Application(){ _surfaceManager.setMediaServer(&_mediaServer); - setState(PresentationState::instance()); + setState(PresentationMode::instance()); ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed); ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased); ofAddListener(ofEvents().mousePressed, this, &Application::onMousePressed); @@ -43,10 +43,10 @@ void Application::setup(){ } // Setup all states. - PresentationState::instance()->setup(this); - TextureMappingState::instance()->setup(this); - ProjectionMappingState::instance()->setup(this); - SourceSelectionState::instance()->setup(this); + PresentationMode::instance()->setup(this); + TextureMappingMode::instance()->setup(this); + ProjectionMappingMode::instance()->setup(this); + SourceSelectionMode::instance()->setup(this); // TODO: Consider whether this is the right place for it Gui::instance()->getScaleWidget().setSurfaceManager(&_surfaceManager); @@ -56,7 +56,7 @@ void Application::update(){ _state->update(this); } -ApplicationBaseState * Application::getState(){ +ApplicationBaseMode * Application::getState(){ return _state; } @@ -95,25 +95,25 @@ void Application::onKeyPressed(ofKeyEventArgs & args){ case '1': _cmdManager.exec( new ofx::piMapper::SetApplicationStateCmd( - this, PresentationState::instance())); + this, PresentationMode::instance())); break; case '2': _cmdManager.exec( new ofx::piMapper::SetApplicationStateCmd( - this, TextureMappingState::instance())); + this, TextureMappingMode::instance())); break; case '3': _cmdManager.exec( new ofx::piMapper::SetApplicationStateCmd( - this, ProjectionMappingState::instance())); + this, ProjectionMappingMode::instance())); break; case '4': _cmdManager.exec( new ofx::piMapper::SetApplicationStateCmd( - this, SourceSelectionState::instance())); + this, SourceSelectionMode::instance())); break; case 'f': @@ -183,7 +183,7 @@ void Application::addFboSource(FboSource * fboSource){ _mediaServer.addFboSource(fboSource); } -void Application::setState(ApplicationBaseState * st){ +void Application::setState(ApplicationBaseMode * st){ _state = st; } diff --git a/src/Application/Application.h b/src/Application/Application.h index 79ec465..4d75cf8 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -6,11 +6,11 @@ #include "SetApplicationStateCmd.h" #include "ClearSurfacesCmd.h" -#include "ApplicationBaseState.h" -#include "PresentationState.h" -#include "ProjectionMappingState.h" -#include "TextureMappingState.h" -#include "SourceSelectionState.h" +#include "ApplicationBaseMode.h" +#include "PresentationMode.h" +#include "ProjectionMappingMode.h" +#include "TextureMappingMode.h" +#include "SourceSelectionMode.h" #include "FboSource.h" #include "Info.h" @@ -28,14 +28,14 @@ namespace ofx { namespace piMapper { -class ApplicationBaseState; +class ApplicationBaseMode; class Application : public KeyListener { public: Application(); - ApplicationBaseState * getState(); + ApplicationBaseMode * getState(); void setup(); void update(); @@ -70,13 +70,13 @@ class Application : public KeyListener { TerminalListener consoleListener; protected: - void setState(ApplicationBaseState * st); + void setState(ApplicationBaseMode * st); private: - friend class ApplicationBaseState; + friend class ApplicationBaseMode; friend class SetApplicationStateCmd; - ApplicationBaseState * _state; + ApplicationBaseMode * _state; CmdManager _cmdManager; MediaServer _mediaServer; diff --git a/src/Application/Modes/ApplicationBaseMode.cpp b/src/Application/Modes/ApplicationBaseMode.cpp new file mode 100644 index 0000000..d0941b8 --- /dev/null +++ b/src/Application/Modes/ApplicationBaseMode.cpp @@ -0,0 +1,12 @@ +#include "ApplicationBaseMode.h" +#include "PresentationMode.h" + +namespace ofx { +namespace piMapper { + +void ApplicationBaseMode::setState(Application * app, ApplicationBaseMode * st){ + app->setState(st); +} + +} // namespace piMapper +} // namespace ofx diff --git a/src/Application/States/ApplicationBaseState.h b/src/Application/Modes/ApplicationBaseMode.h similarity index 87% rename from src/Application/States/ApplicationBaseState.h rename to src/Application/Modes/ApplicationBaseMode.h index 109636f..c454e52 100644 --- a/src/Application/States/ApplicationBaseState.h +++ b/src/Application/Modes/ApplicationBaseMode.h @@ -9,13 +9,13 @@ namespace piMapper { class Application; -class ApplicationBaseState { +class ApplicationBaseMode { public: virtual void setup(Application * app){} virtual void update(Application * app){} virtual void draw(Application * app){} - virtual void setState(Application * app, ApplicationBaseState * st); + virtual void setState(Application * app, ApplicationBaseMode * st); // Event handler virtual methods virtual void onKeyPressed(Application * app, ofKeyEventArgs & args){} @@ -28,7 +28,7 @@ class ApplicationBaseState { virtual void onGuiEvent(Application * app, GuiEvent & e) = 0; - // These are only used by TextureMappingState for now. + // These are only used by TextureMappingMode for now. virtual ofPoint getTranslation(){ return ofPoint(0, 0); } virtual void setTranslation(ofPoint p){} diff --git a/src/Application/Modes/PresentationMode.cpp b/src/Application/Modes/PresentationMode.cpp new file mode 100644 index 0000000..57e0375 --- /dev/null +++ b/src/Application/Modes/PresentationMode.cpp @@ -0,0 +1,29 @@ +#include "PresentationMode.h" + +namespace ofx { +namespace piMapper { + +PresentationMode * PresentationMode::_instance = 0; + +PresentationMode * PresentationMode::instance(){ + if(_instance == 0){ + _instance = new ofx::piMapper::PresentationMode(); + } + return _instance; +} + +void PresentationMode::draw(Application * app){ + ofPushStyle(); + ofSetColor(255, 255, 255, 255); + app->getSurfaceManager()->draw(); + ofPopStyle(); +} + +void PresentationMode::onMousePressed(Application * app, ofMouseEventArgs & args){ + app->getCmdManager()->exec( + new ofx::piMapper::SetApplicationStateCmd( + app, ProjectionMappingMode::instance())); +} + +} // namespace piMapper +} // namespace ofx \ No newline at end of file diff --git a/src/Application/States/PresentationState.h b/src/Application/Modes/PresentationMode.h similarity index 71% rename from src/Application/States/PresentationState.h rename to src/Application/Modes/PresentationMode.h index 091a136..27a9faa 100644 --- a/src/Application/States/PresentationState.h +++ b/src/Application/Modes/PresentationMode.h @@ -5,23 +5,23 @@ #include "ofLog.h" #include "ofGraphics.h" #include "SetApplicationStateCmd.h" -#include "ProjectionMappingState.h" +#include "ProjectionMappingMode.h" #include "GuiMode.h" namespace ofx { namespace piMapper { -class PresentationState : public ApplicationBaseState { +class PresentationMode : public ApplicationBaseMode { public: - static PresentationState * instance(); + static PresentationMode * instance(); void draw(Application * app); void onMousePressed(Application * app, ofMouseEventArgs & args); void onGuiEvent(Application * app, GuiEvent & e){} private: - static PresentationState * _instance; + static PresentationMode * _instance; }; diff --git a/src/Application/States/ProjectionMappingState.cpp b/src/Application/Modes/ProjectionMappingMode.cpp similarity index 90% rename from src/Application/States/ProjectionMappingState.cpp rename to src/Application/Modes/ProjectionMappingMode.cpp index e048b33..dd1f644 100644 --- a/src/Application/States/ProjectionMappingState.cpp +++ b/src/Application/Modes/ProjectionMappingMode.cpp @@ -1,33 +1,33 @@ -#include "ProjectionMappingState.h" +#include "ProjectionMappingMode.h" namespace ofx { namespace piMapper { -ProjectionMappingState::ProjectionMappingState(){ +ProjectionMappingMode::ProjectionMappingMode(){ _surfaceScaleBeforeTransform = 1.0f; } -ProjectionMappingState * ProjectionMappingState::_instance = 0; +ProjectionMappingMode * ProjectionMappingMode::_instance = 0; -ProjectionMappingState * ProjectionMappingState::instance(){ +ProjectionMappingMode * ProjectionMappingMode::instance(){ if(_instance == 0){ - _instance = new ofx::piMapper::ProjectionMappingState(); + _instance = new ofx::piMapper::ProjectionMappingMode(); } return _instance; } -void ProjectionMappingState::setup(Application *app){ +void ProjectionMappingMode::setup(Application *app){ Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getLayerPanelWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getProjectionEditorWidget().setSurfaceManager(app->getSurfaceManager()); } -void ProjectionMappingState::update(Application * app){ +void ProjectionMappingMode::update(Application * app){ Gui::instance()->getProjectionEditorWidget().update(); Gui::instance()->getScaleWidget().update(); } -void ProjectionMappingState::draw(Application * app){ +void ProjectionMappingMode::draw(Application * app){ ofPushStyle(); ofSetColor(255, 255, 255, 255); app->getSurfaceManager()->draw(); @@ -45,7 +45,7 @@ void ProjectionMappingState::draw(Application * app){ Gui::instance()->getSurfaceHighlightWidget().draw(); } -void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ +void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){ switch(args.key){ case 't': @@ -287,7 +287,7 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar } } -void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs & args){ +void ProjectionMappingMode::onMousePressed(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMousePressed(args); CircleJoint * hitJoint = 0; @@ -328,13 +328,13 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs } } -void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){ +void ProjectionMappingMode::onMouseReleased(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseReleased(args); _bSurfaceDrag = false; // TODO: handle this locally Gui::instance()->getProjectionEditorWidget().stopDragJoints(); } -void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs & args){ +void ProjectionMappingMode::onMouseDragged(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseDragged(args); Gui::instance()->getProjectionEditorWidget().mouseDragged(args); @@ -347,14 +347,14 @@ void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs } } -void ProjectionMappingState::onJointPressed(Application * app, GuiJointEvent & e){ +void ProjectionMappingMode::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){ +void ProjectionMappingMode::onSurfacePressed(Application * app, GuiSurfaceEvent & e){ if(app->getSurfaceManager()->getSelectedSurface() != e.surface){ app->getCmdManager()->exec(new SelSurfaceCmd(app->getSurfaceManager(), e.surface )); } @@ -362,13 +362,13 @@ void ProjectionMappingState::onSurfacePressed(Application * app, GuiSurfaceEvent app->getCmdManager()->exec(new StartDragSurfaceCmd(e.surface)); } -void ProjectionMappingState::onBackgroundPressed(Application * app, GuiBackgroundEvent & e){ +void ProjectionMappingMode::onBackgroundPressed(Application * app, GuiBackgroundEvent & e){ if(app->getSurfaceManager()->getSelectedSurface() != 0){ app->getCmdManager()->exec(new DeselectSurfaceCmd(app->getSurfaceManager())); } } -void ProjectionMappingState::onGuiEvent(Application * app, GuiEvent & e){ +void ProjectionMappingMode::onGuiEvent(Application * app, GuiEvent & e){ // Scale widget now. More widgets later. if(e.widget == &Gui::instance()->getScaleWidget()){ diff --git a/src/Application/States/ProjectionMappingState.h b/src/Application/Modes/ProjectionMappingMode.h similarity index 90% rename from src/Application/States/ProjectionMappingState.h rename to src/Application/Modes/ProjectionMappingMode.h index c26db7e..1f72d5e 100644 --- a/src/Application/States/ProjectionMappingState.h +++ b/src/Application/Modes/ProjectionMappingMode.h @@ -36,10 +36,10 @@ namespace ofx { namespace piMapper { -class ProjectionMappingState : public ApplicationBaseState { +class ProjectionMappingMode : public ApplicationBaseMode { public: - static ProjectionMappingState * instance(); + static ProjectionMappingMode * instance(); void setup(Application * app); void update(Application * app); @@ -55,9 +55,9 @@ class ProjectionMappingState : public ApplicationBaseState { void onGuiEvent(Application * app, GuiEvent & e); private: - ProjectionMappingState(); + ProjectionMappingMode(); - static ProjectionMappingState * _instance; + static ProjectionMappingMode * _instance; float _surfaceScaleBeforeTransform; diff --git a/src/Application/States/SourceSelectionState.cpp b/src/Application/Modes/SourceSelectionMode.cpp similarity index 69% rename from src/Application/States/SourceSelectionState.cpp rename to src/Application/Modes/SourceSelectionMode.cpp index c39f93c..7c8f916 100644 --- a/src/Application/States/SourceSelectionState.cpp +++ b/src/Application/Modes/SourceSelectionMode.cpp @@ -1,25 +1,25 @@ -#include "SourceSelectionState.h" +#include "SourceSelectionMode.h" namespace ofx { namespace piMapper { -SourceSelectionState * SourceSelectionState::_instance = 0; +SourceSelectionMode * SourceSelectionMode::_instance = 0; -SourceSelectionState * SourceSelectionState::instance(){ +SourceSelectionMode * SourceSelectionMode::instance(){ if(_instance == 0){ - _instance = new ofx::piMapper::SourceSelectionState(); + _instance = new ofx::piMapper::SourceSelectionMode(); } return _instance; } -void SourceSelectionState::setup(Application * app){ +void SourceSelectionMode::setup(Application * app){ Gui::instance()->getSourcesEditorWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getSourcesEditorWidget().setMediaServer(app->getMediaServer()); Gui::instance()->getSourcesEditorWidget().setCmdManager(app->getCmdManager()); Gui::instance()->getSourcesEditorWidget().setup(); } -void SourceSelectionState::draw(Application * app){ +void SourceSelectionMode::draw(Application * app){ ofPushStyle(); ofSetColor(255, 255, 255, 255); app->getSurfaceManager()->draw(); diff --git a/src/Application/States/SourceSelectionState.h b/src/Application/Modes/SourceSelectionMode.h similarity index 70% rename from src/Application/States/SourceSelectionState.h rename to src/Application/Modes/SourceSelectionMode.h index 158005e..8c8a653 100644 --- a/src/Application/States/SourceSelectionState.h +++ b/src/Application/Modes/SourceSelectionMode.h @@ -9,17 +9,17 @@ namespace ofx { namespace piMapper { -class SourceSelectionState : public ApplicationBaseState { +class SourceSelectionMode : public ApplicationBaseMode { public: - static SourceSelectionState * instance(); + static SourceSelectionMode * instance(); void setup(Application * app); void draw(Application * app); void onGuiEvent(Application * app, GuiEvent & e){} private: - static SourceSelectionState * _instance; + static SourceSelectionMode * _instance; }; diff --git a/src/Application/States/TextureMappingState.cpp b/src/Application/Modes/TextureMappingMode.cpp similarity index 86% rename from src/Application/States/TextureMappingState.cpp rename to src/Application/Modes/TextureMappingMode.cpp index 36228d2..65e9d8a 100644 --- a/src/Application/States/TextureMappingState.cpp +++ b/src/Application/Modes/TextureMappingMode.cpp @@ -1,29 +1,29 @@ -#include "TextureMappingState.h" +#include "TextureMappingMode.h" namespace ofx { namespace piMapper { -TextureMappingState * TextureMappingState::_instance = 0; +TextureMappingMode * TextureMappingMode::_instance = 0; -TextureMappingState * TextureMappingState::instance(){ +TextureMappingMode * TextureMappingMode::instance(){ if(_instance == 0){ - _instance = new ofx::piMapper::TextureMappingState(); + _instance = new ofx::piMapper::TextureMappingMode(); } return _instance; } -TextureMappingState::TextureMappingState(){ +TextureMappingMode::TextureMappingMode(){ _bTranslateCanvas = false; _canvasTranslate = ofPoint(0, 0); _clickCanvasTranslate = ofPoint(0, 0); _drawMode = 0; } -void TextureMappingState::update(Application * app){ +void TextureMappingMode::update(Application * app){ Gui::instance()->getTextureEditorWidget().update(); } -void TextureMappingState::draw(Application * app){ +void TextureMappingMode::draw(Application * app){ ofPushMatrix(); ofTranslate(_canvasTranslate.x, _canvasTranslate.y); @@ -73,7 +73,7 @@ void TextureMappingState::draw(Application * app){ ofPopMatrix(); } -void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ +void TextureMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){ int key = args.key; float moveStep; @@ -146,7 +146,7 @@ void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args) } } -void TextureMappingState::onBackgroundPressed(Application * app, GuiBackgroundEvent & e){ +void TextureMappingMode::onBackgroundPressed(Application * app, GuiBackgroundEvent & e){ // Exec the command only if a joint is selected. bool selected = false; for(unsigned int i = 0; i < Gui::instance()->getTextureEditorWidget().getJoints().size(); ++i){ @@ -164,7 +164,7 @@ void TextureMappingState::onBackgroundPressed(Application * app, GuiBackgroundEv _bTranslateCanvas = true; } -void TextureMappingState::onMousePressed(Application * app, ofMouseEventArgs & args){ +void TextureMappingMode::onMousePressed(Application * app, ofMouseEventArgs & args){ _clickPosition = ofPoint(args.x, args.y); _prevCanvasTranslate = _canvasTranslate; @@ -213,7 +213,7 @@ void TextureMappingState::onMousePressed(Application * app, ofMouseEventArgs & a } } -void TextureMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){ +void TextureMappingMode::onMouseReleased(Application * app, ofMouseEventArgs & args){ _bTranslateCanvas = false; // If translation has happened, create an undoable command @@ -235,7 +235,7 @@ void TextureMappingState::onMouseReleased(Application * app, ofMouseEventArgs & } // TODO: Handle app->getGui()->clickPosition and app->getGui()->bDrag locally. -void TextureMappingState::onMouseDragged(Application * app, ofMouseEventArgs & args){ +void TextureMappingMode::onMouseDragged(Application * app, ofMouseEventArgs & args){ if(!_bTranslateCanvas){ args.x -= _canvasTranslate.x; args.y -= _canvasTranslate.y; @@ -254,7 +254,7 @@ void TextureMappingState::onMouseDragged(Application * app, ofMouseEventArgs & a } } -void TextureMappingState::drawTexture(Application * app){ +void TextureMappingMode::drawTexture(Application * app){ if(app->getSurfaceManager()->getSelectedSurface() != 0){ bool normalizedTexCoords = ofGetUsingNormalizedTexCoords(); ofEnableNormalizedTexCoords(); @@ -268,24 +268,24 @@ void TextureMappingState::drawTexture(Application * app){ } } -ofPoint TextureMappingState::getTranslation(){ +ofPoint TextureMappingMode::getTranslation(){ return _canvasTranslate; } -void TextureMappingState::setTranslation(ofPoint p){ +void TextureMappingMode::setTranslation(ofPoint p){ _canvasTranslate = p; _clickCanvasTranslate = p; } -void TextureMappingState::setDrawMode(int m){ +void TextureMappingMode::setDrawMode(int m){ _drawMode = m; } -int TextureMappingState::getDrawMode(){ +int TextureMappingMode::getDrawMode(){ return _drawMode; } -int TextureMappingState::getNextDrawMode(){ +int TextureMappingMode::getNextDrawMode(){ int nextDrawMode = _drawMode + 1; if(nextDrawMode > 2){ @@ -295,7 +295,7 @@ int TextureMappingState::getNextDrawMode(){ return nextDrawMode; } -int TextureMappingState::getPrevDrawMode(){ +int TextureMappingMode::getPrevDrawMode(){ int prevDrawMode = _drawMode - 1; if(prevDrawMode < 0){ diff --git a/src/Application/States/TextureMappingState.h b/src/Application/Modes/TextureMappingMode.h similarity index 89% rename from src/Application/States/TextureMappingState.h rename to src/Application/Modes/TextureMappingMode.h index b7dacd0..a48242f 100644 --- a/src/Application/States/TextureMappingState.h +++ b/src/Application/Modes/TextureMappingMode.h @@ -19,10 +19,10 @@ namespace ofx { namespace piMapper { -class TextureMappingState : public ApplicationBaseState { +class TextureMappingMode : public ApplicationBaseMode { public: - static TextureMappingState * instance(); + static TextureMappingMode * instance(); void update(Application * app); void draw(Application * app); @@ -44,9 +44,9 @@ class TextureMappingState : public ApplicationBaseState { int getPrevDrawMode(); private: - static TextureMappingState * _instance; + static TextureMappingMode * _instance; - TextureMappingState(); + TextureMappingMode(); bool _bTranslateCanvas; bool _bCropAreaDrag; diff --git a/src/Application/States/ApplicationBaseState.cpp b/src/Application/States/ApplicationBaseState.cpp deleted file mode 100644 index 1bc50ef..0000000 --- a/src/Application/States/ApplicationBaseState.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "ApplicationBaseState.h" -#include "PresentationState.h" - -namespace ofx { -namespace piMapper { - -void ApplicationBaseState::setState(Application * app, ApplicationBaseState * st){ - app->setState(st); -} - -} // namespace piMapper -} // namespace ofx diff --git a/src/Application/States/PresentationState.cpp b/src/Application/States/PresentationState.cpp deleted file mode 100644 index 21c38d2..0000000 --- a/src/Application/States/PresentationState.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "PresentationState.h" - -namespace ofx { -namespace piMapper { - -PresentationState * PresentationState::_instance = 0; - -PresentationState * PresentationState::instance(){ - if(_instance == 0){ - _instance = new ofx::piMapper::PresentationState(); - } - return _instance; -} - -void PresentationState::draw(Application * app){ - ofPushStyle(); - ofSetColor(255, 255, 255, 255); - app->getSurfaceManager()->draw(); - ofPopStyle(); -} - -void PresentationState::onMousePressed(Application * app, ofMouseEventArgs & args){ - app->getCmdManager()->exec( - new ofx::piMapper::SetApplicationStateCmd( - app, ProjectionMappingState::instance())); -} - -} // namespace piMapper -} // namespace ofx \ No newline at end of file diff --git a/src/Commands/SetApplicationStateCmd.cpp b/src/Commands/SetApplicationStateCmd.cpp index 841a610..a548ad0 100644 --- a/src/Commands/SetApplicationStateCmd.cpp +++ b/src/Commands/SetApplicationStateCmd.cpp @@ -4,7 +4,7 @@ namespace ofx { namespace piMapper { SetApplicationStateCmd::SetApplicationStateCmd(Application * app, - ApplicationBaseState * st){ + ApplicationBaseMode * st){ _application = app; _prevApplicationState = 0; @@ -20,13 +20,13 @@ void SetApplicationStateCmd::exec(){ Gui::instance()->getTextureEditorWidget().setSurface( _application->getSurfaceManager()->getSelectedSurface()); - if(_applicationState != PresentationState::instance()){ + if(_applicationState != PresentationMode::instance()){ ofShowCursor(); }else{ ofHideCursor(); } - if(_applicationState == SourceSelectionState::instance()){ + if(_applicationState == SourceSelectionMode::instance()){ Gui::instance()->getSourcesEditorWidget().enable(); }else{ Gui::instance()->getSourcesEditorWidget().disable(); @@ -41,13 +41,13 @@ void SetApplicationStateCmd::undo(){ Gui::instance()->getTextureEditorWidget().setSurface( _application->getSurfaceManager()->getSelectedSurface()); - if(_prevApplicationState != PresentationState::instance()){ + if(_prevApplicationState != PresentationMode::instance()){ ofShowCursor(); }else{ ofHideCursor(); } - if(_prevApplicationState == SourceSelectionState::instance()){ + if(_prevApplicationState == SourceSelectionMode::instance()){ Gui::instance()->getSourcesEditorWidget().enable(); }else{ Gui::instance()->getSourcesEditorWidget().disable(); diff --git a/src/Commands/SetApplicationStateCmd.h b/src/Commands/SetApplicationStateCmd.h index 39fe520..7ba094d 100644 --- a/src/Commands/SetApplicationStateCmd.h +++ b/src/Commands/SetApplicationStateCmd.h @@ -7,21 +7,21 @@ namespace ofx { namespace piMapper { class Application; -class ApplicationBaseState; +class ApplicationBaseMode; class SetApplicationStateCmd : public BaseUndoCmd { public: SetApplicationStateCmd(Application * app, - ApplicationBaseState * st); + ApplicationBaseMode * st); void exec(); void undo(); private: Application * _application; - ApplicationBaseState * _prevApplicationState; - ApplicationBaseState * _applicationState; + ApplicationBaseMode * _prevApplicationState; + ApplicationBaseMode * _applicationState; ofPoint _translation; diff --git a/src/Commands/SetTexMapDrawModeCmd.cpp b/src/Commands/SetTexMapDrawModeCmd.cpp index 380ce93..d80730c 100644 --- a/src/Commands/SetTexMapDrawModeCmd.cpp +++ b/src/Commands/SetTexMapDrawModeCmd.cpp @@ -3,7 +3,7 @@ namespace ofx { namespace piMapper { -SetTexMapDrawModeCmd::SetTexMapDrawModeCmd(TextureMappingState * s, int m){ +SetTexMapDrawModeCmd::SetTexMapDrawModeCmd(TextureMappingMode * s, int m){ _state = s; _newMode = m; } diff --git a/src/Commands/SetTexMapDrawModeCmd.h b/src/Commands/SetTexMapDrawModeCmd.h index 913cc71..9a40889 100644 --- a/src/Commands/SetTexMapDrawModeCmd.h +++ b/src/Commands/SetTexMapDrawModeCmd.h @@ -5,22 +5,22 @@ #pragma once #include "BaseCmd.h" -#include "TextureMappingState.h" +#include "TextureMappingMode.h" namespace ofx { namespace piMapper { -class TextureMappingState; +class TextureMappingMode; class SetTexMapDrawModeCmd : public BaseUndoCmd { public: - SetTexMapDrawModeCmd(TextureMappingState * s, int m); + SetTexMapDrawModeCmd(TextureMappingMode * s, int m); void exec(); void undo(); private: - TextureMappingState * _state; + TextureMappingMode * _state; int _oldMode; int _newMode;