From 2306be1c5ddcb5a7bc9a5f6ba5a37d1b68d32bc6 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sat, 10 Oct 2015 13:52:18 +0300 Subject: [PATCH] Rename MainView to Application and not just that - Rename ViewState to ApplicationBaseState - Rename all ..ViewState's to just ..State's - Adjust ofxPiMapper main class so app compiles --- src/Application/Application.cpp | 20 +++++++++++++++ src/Application/Application.h | 26 +++++++++++++++++++ src/Application/ApplicationBaseState.cpp | 12 +++++++++ src/Application/ApplicationBaseState.h | 18 ++++++++++++++ src/Application/PresentationState.cpp | 20 +++++++++++++++ src/Application/PresentationState.h | 21 ++++++++++++++++ src/Application/ProjectionMappingState.cpp | 19 ++++++++++++++ src/Application/ProjectionMappingState.h | 21 ++++++++++++++++ src/Application/SourceSelectionState.cpp | 19 ++++++++++++++ src/Application/SourceSelectionState.h | 21 ++++++++++++++++ src/Application/TextureMappingState.cpp | 19 ++++++++++++++ src/Application/TextureMappingState.h | 21 ++++++++++++++++ src/Views/MainView.cpp | 20 --------------- src/Views/MainView.h | 29 ---------------------- src/Views/PresentationViewState.cpp | 21 ---------------- src/Views/PresentationViewState.h | 24 ------------------ src/Views/ProjectionMappingViewState.cpp | 20 --------------- src/Views/ProjectionMappingViewState.h | 24 ------------------ src/Views/SourceSelectionViewState.cpp | 20 --------------- src/Views/SourceSelectionViewState.h | 24 ------------------ src/Views/TextureMappingViewState.cpp | 20 --------------- src/Views/TextureMappingViewState.h | 24 ------------------ src/Views/ViewState.cpp | 12 --------- src/Views/ViewState.h | 21 ---------------- src/ofxPiMapper.cpp | 4 +-- src/ofxPiMapper.h | 10 ++------ 26 files changed, 241 insertions(+), 269 deletions(-) create mode 100644 src/Application/Application.cpp create mode 100644 src/Application/Application.h create mode 100644 src/Application/ApplicationBaseState.cpp create mode 100644 src/Application/ApplicationBaseState.h create mode 100644 src/Application/PresentationState.cpp create mode 100644 src/Application/PresentationState.h create mode 100644 src/Application/ProjectionMappingState.cpp create mode 100644 src/Application/ProjectionMappingState.h create mode 100644 src/Application/SourceSelectionState.cpp create mode 100644 src/Application/SourceSelectionState.h create mode 100644 src/Application/TextureMappingState.cpp create mode 100644 src/Application/TextureMappingState.h delete mode 100644 src/Views/MainView.cpp delete mode 100644 src/Views/MainView.h delete mode 100644 src/Views/PresentationViewState.cpp delete mode 100644 src/Views/PresentationViewState.h delete mode 100644 src/Views/ProjectionMappingViewState.cpp delete mode 100644 src/Views/ProjectionMappingViewState.h delete mode 100644 src/Views/SourceSelectionViewState.cpp delete mode 100644 src/Views/SourceSelectionViewState.h delete mode 100644 src/Views/TextureMappingViewState.cpp delete mode 100644 src/Views/TextureMappingViewState.h delete mode 100644 src/Views/ViewState.cpp delete mode 100644 src/Views/ViewState.h diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp new file mode 100644 index 0000000..8f169a8 --- /dev/null +++ b/src/Application/Application.cpp @@ -0,0 +1,20 @@ +#include "Application.h" +#include "PresentationState.h" + +namespace ofx { + namespace piMapper { + + Application::Application(){ + setState(PresentationState::instance()); + } + + void Application::draw(){ + _state->draw(this); + } + + void Application::setState(ApplicationBaseState * st){ + _state = st; + } + + } // namespace piMapper +} // namespace ofx diff --git a/src/Application/Application.h b/src/Application/Application.h new file mode 100644 index 0000000..70a3f5f --- /dev/null +++ b/src/Application/Application.h @@ -0,0 +1,26 @@ +#pragma once + +#include "ofEvents.h" +#include "ofLog.h" +#include "ApplicationBaseState.h" + +namespace ofx { + namespace piMapper { + + class ApplicationBaseState; + + class Application { + public: + Application(); + void draw(); + + protected: + void setState(ApplicationBaseState * st); + + private: + friend class ApplicationBaseState; + ApplicationBaseState * _state; + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Application/ApplicationBaseState.cpp b/src/Application/ApplicationBaseState.cpp new file mode 100644 index 0000000..48f827f --- /dev/null +++ b/src/Application/ApplicationBaseState.cpp @@ -0,0 +1,12 @@ +#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/ApplicationBaseState.h b/src/Application/ApplicationBaseState.h new file mode 100644 index 0000000..c396390 --- /dev/null +++ b/src/Application/ApplicationBaseState.h @@ -0,0 +1,18 @@ +#pragma once + +#include "ofEvents.h" +#include "ofLog.h" + +namespace ofx { + namespace piMapper { + + class Application; + + class ApplicationBaseState { + public: + virtual void draw(Application * app){}; + virtual void setState(Application * app, ApplicationBaseState * st); + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Application/PresentationState.cpp b/src/Application/PresentationState.cpp new file mode 100644 index 0000000..8f39563 --- /dev/null +++ b/src/Application/PresentationState.cpp @@ -0,0 +1,20 @@ +#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) { + ofSetColor(255, 255, 0); + ofDrawBitmapString("Presentation State", 10, 20); + } + } +} \ No newline at end of file diff --git a/src/Application/PresentationState.h b/src/Application/PresentationState.h new file mode 100644 index 0000000..9f5bd77 --- /dev/null +++ b/src/Application/PresentationState.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Application.h" +#include "ofEvents.h" +#include "ofLog.h" +#include "ofGraphics.h" + +namespace ofx { + namespace piMapper { + + class PresentationState : public ApplicationBaseState { + public: + static PresentationState * instance(); + void draw(Application * app); + + private: + static PresentationState * _instance; + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Application/ProjectionMappingState.cpp b/src/Application/ProjectionMappingState.cpp new file mode 100644 index 0000000..a60e1ec --- /dev/null +++ b/src/Application/ProjectionMappingState.cpp @@ -0,0 +1,19 @@ +#include "ProjectionMappingState.h" + +namespace ofx { + namespace piMapper { + + ProjectionMappingState * ProjectionMappingState::_instance = 0; + + ProjectionMappingState * ProjectionMappingState::instance() { + if (_instance == 0) { + _instance = new ofx::piMapper::ProjectionMappingState(); + } + return _instance; + } + + void ProjectionMappingState::draw(Application * app) { + ofDrawBitmapString("Projection Mapping State", 10, 20); + } + } +} \ No newline at end of file diff --git a/src/Application/ProjectionMappingState.h b/src/Application/ProjectionMappingState.h new file mode 100644 index 0000000..3e194b3 --- /dev/null +++ b/src/Application/ProjectionMappingState.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Application.h" +#include "ofEvents.h" +#include "ofLog.h" +#include "ofGraphics.h" + +namespace ofx { + namespace piMapper { + + class ProjectionMappingState : public ApplicationBaseState { + public: + static ProjectionMappingState * instance(); + void draw(Application * app); + + private: + static ProjectionMappingState * _instance; + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Application/SourceSelectionState.cpp b/src/Application/SourceSelectionState.cpp new file mode 100644 index 0000000..8277c76 --- /dev/null +++ b/src/Application/SourceSelectionState.cpp @@ -0,0 +1,19 @@ +#include "SourceSelectionState.h" + +namespace ofx { + namespace piMapper { + + SourceSelectionState * SourceSelectionState::_instance = 0; + + SourceSelectionState * SourceSelectionState::instance() { + if (_instance == 0) { + _instance = new ofx::piMapper::SourceSelectionState(); + } + return _instance; + } + + void SourceSelectionState::draw(Application * app) { + ofDrawBitmapString("Source Selection State", 10, 20); + } + } +} \ No newline at end of file diff --git a/src/Application/SourceSelectionState.h b/src/Application/SourceSelectionState.h new file mode 100644 index 0000000..197280a --- /dev/null +++ b/src/Application/SourceSelectionState.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Application.h" +#include "ofEvents.h" +#include "ofLog.h" +#include "ofGraphics.h" + +namespace ofx { + namespace piMapper { + + class SourceSelectionState : public ApplicationBaseState { + public: + static SourceSelectionState * instance(); + void draw(Application * app); + + private: + static SourceSelectionState * _instance; + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Application/TextureMappingState.cpp b/src/Application/TextureMappingState.cpp new file mode 100644 index 0000000..64e0710 --- /dev/null +++ b/src/Application/TextureMappingState.cpp @@ -0,0 +1,19 @@ +#include "TextureMappingState.h" + +namespace ofx { + namespace piMapper { + + TextureMappingState * TextureMappingState::_instance = 0; + + TextureMappingState * TextureMappingState::instance() { + if (_instance == 0) { + _instance = new ofx::piMapper::TextureMappingState(); + } + return _instance; + } + + void TextureMappingState::draw(Application * app) { + ofDrawBitmapString("Texture Mapping State", 10, 20); + } + } +} \ No newline at end of file diff --git a/src/Application/TextureMappingState.h b/src/Application/TextureMappingState.h new file mode 100644 index 0000000..259ad4a --- /dev/null +++ b/src/Application/TextureMappingState.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Application.h" +#include "ofEvents.h" +#include "ofLog.h" +#include "ofGraphics.h" + +namespace ofx { + namespace piMapper { + + class TextureMappingState : public ApplicationBaseState { + public: + static TextureMappingState * instance(); + void draw(Application * app); + + private: + static TextureMappingState * _instance; + }; + + } // namespace piMapper +} // namespace ofx diff --git a/src/Views/MainView.cpp b/src/Views/MainView.cpp deleted file mode 100644 index 294f33a..0000000 --- a/src/Views/MainView.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "MainView.h" -#include "PresentationViewState.h" - -namespace ofx { - namespace piMapper { - - MainView::MainView(){ - setState(PresentationViewState::instance()); - } - - void MainView::draw(){ - _state->draw(this); - } - - void MainView::setState(ViewState * st){ - _state = st; - } - - } // namespace piMapper -} // namespace ofx diff --git a/src/Views/MainView.h b/src/Views/MainView.h deleted file mode 100644 index a6b2eed..0000000 --- a/src/Views/MainView.h +++ /dev/null @@ -1,29 +0,0 @@ -// MainView -// Main entrance point for the visible part of this application -// Created by Krisjanis Rijnieks 2015-05-22 -#pragma once - -#include "ofEvents.h" -#include "ofLog.h" -#include "ViewState.h" - -namespace ofx { - namespace piMapper { - - class ViewState; - - class MainView { - public: - MainView(); - void draw(); - - protected: - void setState(ViewState * st); - - private: - friend class ViewState; - ViewState * _state; - }; - - } // namespace piMapper -} // namespace ofx diff --git a/src/Views/PresentationViewState.cpp b/src/Views/PresentationViewState.cpp deleted file mode 100644 index 7dc1853..0000000 --- a/src/Views/PresentationViewState.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "PresentationViewState.h" - -namespace ofx { - namespace piMapper { - - PresentationViewState * PresentationViewState::_instance = 0; - - PresentationViewState * PresentationViewState::instance() { - if (_instance == 0) { - _instance = new ofx::piMapper::PresentationViewState(); - } - return _instance; - } - - void PresentationViewState::draw(MainView * mv) { - ofSetColor(255, 255, 0); - ofDrawBitmapString("Presentation View State", 10, 20); - //ofLogNotice("PresentationViewState::draw"); - } - } -} \ No newline at end of file diff --git a/src/Views/PresentationViewState.h b/src/Views/PresentationViewState.h deleted file mode 100644 index a5beb5a..0000000 --- a/src/Views/PresentationViewState.h +++ /dev/null @@ -1,24 +0,0 @@ -// PresentationViewState -// Presentation view state singleton -// Created by Krisjanis Rijnieks 2015-05-24 -#pragma once - -#include "MainView.h" -#include "ofEvents.h" -#include "ofLog.h" -#include "ofGraphics.h" - -namespace ofx { - namespace piMapper { - - class PresentationViewState : public ViewState { - public: - static PresentationViewState * instance(); - void draw(MainView * mv); - - private: - static PresentationViewState * _instance; - }; - - } // namespace piMapper -} // namespace ofx diff --git a/src/Views/ProjectionMappingViewState.cpp b/src/Views/ProjectionMappingViewState.cpp deleted file mode 100644 index 49debb9..0000000 --- a/src/Views/ProjectionMappingViewState.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "ProjectionMappingViewState.h" - -namespace ofx { - namespace piMapper { - - ProjectionMappingViewState * ProjectionMappingViewState::_instance = 0; - - ProjectionMappingViewState * ProjectionMappingViewState::instance() { - if (_instance == 0) { - _instance = new ofx::piMapper::ProjectionMappingViewState(); - } - return _instance; - } - - void ProjectionMappingViewState::draw(MainView * mv) { - ofDrawBitmapString("Projection Mapping View State", 10, 20); - //ofLogNotice("ProjectionMappingViewState::draw"); - } - } -} \ No newline at end of file diff --git a/src/Views/ProjectionMappingViewState.h b/src/Views/ProjectionMappingViewState.h deleted file mode 100644 index 2a3004a..0000000 --- a/src/Views/ProjectionMappingViewState.h +++ /dev/null @@ -1,24 +0,0 @@ -// ProejectionMappingViewState -// Projection mapping view state singleton -// Created by Krisjanis Rijnieks 2015-09-17 -#pragma once - -#include "MainView.h" -#include "ofEvents.h" -#include "ofLog.h" -#include "ofGraphics.h" - -namespace ofx { - namespace piMapper { - - class ProjectionMappingViewState : public ViewState { - public: - static ProjectionMappingViewState * instance(); - void draw(MainView * mv); - - private: - static ProjectionMappingViewState * _instance; - }; - - } // namespace piMapper -} // namespace ofx diff --git a/src/Views/SourceSelectionViewState.cpp b/src/Views/SourceSelectionViewState.cpp deleted file mode 100644 index 0a0aa48..0000000 --- a/src/Views/SourceSelectionViewState.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "SourceSelectionViewState.h" - -namespace ofx { - namespace piMapper { - - SourceSelectionViewState * SourceSelectionViewState::_instance = 0; - - SourceSelectionViewState * SourceSelectionViewState::instance() { - if (_instance == 0) { - _instance = new ofx::piMapper::SourceSelectionViewState(); - } - return _instance; - } - - void SourceSelectionViewState::draw(MainView * mv) { - ofDrawBitmapString("Source Selection View State", 10, 20); - //ofLogNotice("SourceSelectionViewState::draw"); - } - } -} \ No newline at end of file diff --git a/src/Views/SourceSelectionViewState.h b/src/Views/SourceSelectionViewState.h deleted file mode 100644 index 6f436e9..0000000 --- a/src/Views/SourceSelectionViewState.h +++ /dev/null @@ -1,24 +0,0 @@ -// SourceSelectionViewState -// Source selection view state singleton -// Created by Krisjanis Rijnieks 2015-09-17 -#pragma once - -#include "MainView.h" -#include "ofEvents.h" -#include "ofLog.h" -#include "ofGraphics.h" - -namespace ofx { - namespace piMapper { - - class SourceSelectionViewState : public ViewState { - public: - static SourceSelectionViewState * instance(); - void draw(MainView * mv); - - private: - static SourceSelectionViewState * _instance; - }; - - } // namespace piMapper -} // namespace ofx diff --git a/src/Views/TextureMappingViewState.cpp b/src/Views/TextureMappingViewState.cpp deleted file mode 100644 index 8ab2fb1..0000000 --- a/src/Views/TextureMappingViewState.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "TextureMappingViewState.h" - -namespace ofx { - namespace piMapper { - - TextureMappingViewState * TextureMappingViewState::_instance = 0; - - TextureMappingViewState * TextureMappingViewState::instance() { - if (_instance == 0) { - _instance = new ofx::piMapper::TextureMappingViewState(); - } - return _instance; - } - - void TextureMappingViewState::draw(MainView * mv) { - ofDrawBitmapString("Texture Mapping View State", 10, 20); - //ofLogNotice("TextureMappingViewState::draw"); - } - } -} \ No newline at end of file diff --git a/src/Views/TextureMappingViewState.h b/src/Views/TextureMappingViewState.h deleted file mode 100644 index 808a19a..0000000 --- a/src/Views/TextureMappingViewState.h +++ /dev/null @@ -1,24 +0,0 @@ -// TextureMappingViewState -// Texture mapping view state singleton -// Created by Krisjanis Rijnieks 2015-09-17 -#pragma once - -#include "MainView.h" -#include "ofEvents.h" -#include "ofLog.h" -#include "ofGraphics.h" - -namespace ofx { - namespace piMapper { - - class TextureMappingViewState : public ViewState { - public: - static TextureMappingViewState * instance(); - void draw(MainView * mv); - - private: - static TextureMappingViewState * _instance; - }; - - } // namespace piMapper -} // namespace ofx diff --git a/src/Views/ViewState.cpp b/src/Views/ViewState.cpp deleted file mode 100644 index 18873b1..0000000 --- a/src/Views/ViewState.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "ViewState.h" -#include "PresentationViewState.h" - -namespace ofx { - namespace piMapper { - - void ViewState::setState(MainView * mv, ViewState * st) { - mv->setState(st); - } - - } // namespace piMapper -} // namespace ofx diff --git a/src/Views/ViewState.h b/src/Views/ViewState.h deleted file mode 100644 index 1331dec..0000000 --- a/src/Views/ViewState.h +++ /dev/null @@ -1,21 +0,0 @@ -// ViewState -// Base class for view states -// Created by Krisjanis Rijnieks 2015-06-03 -#pragma once - -#include "ofEvents.h" -#include "ofLog.h" - -namespace ofx { - namespace piMapper { - - class MainView; - - class ViewState { - public: - virtual void draw(MainView * mv){}; - virtual void setState(MainView * mainView, ViewState * state); - }; - - } // namespace piMapper -} // namespace ofx diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index c4d3880..329ebed 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -32,7 +32,7 @@ void ofxPiMapper::setup(){ ofLogNotice("ofxPiMapper") << "Done setting up"; - _mainView = new ofx::piMapper::MainView(); + _application = new ofx::piMapper::Application(); _keyboard = new ofx::piMapper::Keyboard(this); } @@ -71,7 +71,7 @@ void ofxPiMapper::draw(){ // TODO: remove undo test completely //ofDrawBitmapStringHighlight(ofToString(undoTestValue), 200, 200); - _mainView->draw(); + _application->draw(); } // draw diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 180bf60..9a560e1 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -1,9 +1,3 @@ -// ofxPiMapper -// Author: Krisjanis Rijnieks - -// On using prefixes like m or p (mMemberVariable, pMyPointer) -// http://stackoverflow.com/questions/1228161/why-use-prefixes-on-member-variables-in-c-classes - #pragma once #include "ofMain.h" @@ -19,7 +13,7 @@ #include "SetGuiModeCmd.h" // Main view with state design pattern -#include "MainView.h" +#include "Application.h" // Main application entry point #include "Keyboard.h" #define PIMAPPER_DEF_SURFACES_XML_FILE "defaultSurfaces.xml" @@ -78,6 +72,6 @@ class ofxPiMapper{ ofx::piMapper::SurfaceManagerGui gui; - ofx::piMapper::MainView * _mainView; + ofx::piMapper::Application * _application; ofx::piMapper::Keyboard * _keyboard; }; \ No newline at end of file