Browse Source

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
master
Krisjanis Rijnieks 10 years ago
parent
commit
2306be1c5d
  1. 20
      src/Application/Application.cpp
  2. 26
      src/Application/Application.h
  3. 12
      src/Application/ApplicationBaseState.cpp
  4. 18
      src/Application/ApplicationBaseState.h
  5. 20
      src/Application/PresentationState.cpp
  6. 21
      src/Application/PresentationState.h
  7. 19
      src/Application/ProjectionMappingState.cpp
  8. 21
      src/Application/ProjectionMappingState.h
  9. 19
      src/Application/SourceSelectionState.cpp
  10. 21
      src/Application/SourceSelectionState.h
  11. 19
      src/Application/TextureMappingState.cpp
  12. 21
      src/Application/TextureMappingState.h
  13. 20
      src/Views/MainView.cpp
  14. 29
      src/Views/MainView.h
  15. 21
      src/Views/PresentationViewState.cpp
  16. 24
      src/Views/PresentationViewState.h
  17. 20
      src/Views/ProjectionMappingViewState.cpp
  18. 24
      src/Views/ProjectionMappingViewState.h
  19. 20
      src/Views/SourceSelectionViewState.cpp
  20. 24
      src/Views/SourceSelectionViewState.h
  21. 20
      src/Views/TextureMappingViewState.cpp
  22. 24
      src/Views/TextureMappingViewState.h
  23. 12
      src/Views/ViewState.cpp
  24. 21
      src/Views/ViewState.h
  25. 4
      src/ofxPiMapper.cpp
  26. 10
      src/ofxPiMapper.h

20
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

26
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

12
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

18
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

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

21
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

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

21
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

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

21
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

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

21
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

20
src/Views/MainView.cpp

@ -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

29
src/Views/MainView.h

@ -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

21
src/Views/PresentationViewState.cpp

@ -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");
}
}
}

24
src/Views/PresentationViewState.h

@ -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

20
src/Views/ProjectionMappingViewState.cpp

@ -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");
}
}
}

24
src/Views/ProjectionMappingViewState.h

@ -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

20
src/Views/SourceSelectionViewState.cpp

@ -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");
}
}
}

24
src/Views/SourceSelectionViewState.h

@ -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

20
src/Views/TextureMappingViewState.cpp

@ -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");
}
}
}

24
src/Views/TextureMappingViewState.h

@ -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

12
src/Views/ViewState.cpp

@ -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

21
src/Views/ViewState.h

@ -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

4
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

10
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;
};
Loading…
Cancel
Save