Browse Source

Rename `addFboSource()` to `registerFboSource()` and refactor a bit

master
Krisjanis Rijnieks 10 years ago
parent
commit
e425856a93
  1. 48
      src/ofxPiMapper.cpp
  2. 30
      src/ofxPiMapper.h

48
src/ofxPiMapper.cpp

@ -1,18 +1,17 @@
#include "ofxPiMapper.h"
ofxPiMapper::ofxPiMapper(): bShowInfo(false), isSetUp(false){
ofxPiMapper::ofxPiMapper() {
bShowInfo = false;
isSetUp = false;
}
void ofxPiMapper::setup(){
void ofxPiMapper::setup() {
ofLogNotice("ofxPiMapper") << "Setting up...";
// Assign media server to other pi mapper components
surfaceManager.setMediaServer(&mediaServer);
gui.setMediaServer(&mediaServer);
gui.setCmdManager(&cmdManager);
// Check if we have user surfaces defined, if not - load default
if (ofFile::doesFileExist(PIMAPPER_USER_SURFACES_XML_FILE)){
ofLogNotice("ofxPiMapper") << "Loading user surfaces from " << PIMAPPER_USER_SURFACES_XML_FILE;
surfaceManager.loadXmlSettings(PIMAPPER_USER_SURFACES_XML_FILE);
@ -21,30 +20,20 @@ void ofxPiMapper::setup(){
surfaceManager.loadXmlSettings(PIMAPPER_DEF_SURFACES_XML_FILE);
}
// The GUI needs something to interface with
gui.setSurfaceManager(&surfaceManager);
isSetUp = true;
ofLogNotice("ofxPiMapper") << "Done setting up";
_application = new ofx::piMapper::Application(this);
}
void ofxPiMapper::stateSetup() {
// TODO: test state imp
}
void ofxPiMapper::draw(){
void ofxPiMapper::draw() {
if (!isSetUp) {
return;
}
// Draw the piMapper GUI
gui.draw();
if (bShowInfo){
// Draw instructions
stringstream ss;
ss << "There are 4 modes:\n\n";
ss << " 1. Presentation mode\n";
@ -58,23 +47,19 @@ void ofxPiMapper::draw(){
ss << "Press <s> to save the composition\n";
ss << "Press <f> to toggle fullscreen\n";
ss << "Press <i> to hide this message";
ofDrawBitmapStringHighlight(ss.str(), 10, 20, ofColor(0, 0, 0, 100),
ofColor(255, 255, 255, 200));
ofDrawBitmapStringHighlight(ss.str(), 10, 20,
ofColor(0, 0, 0, 100),
ofColor(255, 255, 255, 200));
}
// TODO: remove undo test completely
//ofDrawBitmapStringHighlight(ofToString(undoTestValue), 200, 200);
_application->draw();
} // draw
void ofxPiMapper::addFboSource(ofx::piMapper::FboSource &fboSource){
void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource) {
mediaServer.addFboSource(fboSource);
} // addFboSource
}
void ofxPiMapper::addTriangleSurface(){
void ofxPiMapper::addTriangleSurface() {
int surfaceType = ofx::piMapper::SurfaceType::TRIANGLE_SURFACE;
vector<ofVec2f> vertices;
@ -91,11 +76,9 @@ void ofxPiMapper::addTriangleSurface(){
// Select this surface right away
surfaceManager.selectSurface(surfaceManager.size() - 1);
} // addTriangleSurface
void ofxPiMapper::addQuadSurface(){
void ofxPiMapper::addQuadSurface() {
int surfaceType = ofx::piMapper::SurfaceType::QUAD_SURFACE;
vector<ofVec2f> vertices;
@ -115,7 +98,6 @@ void ofxPiMapper::addQuadSurface(){
// select this surface right away
surfaceManager.selectSurface(surfaceManager.size() - 1);
} // addQuadSurface
ofx::piMapper::CmdManager & ofxPiMapper::getCmdManager() {
@ -126,10 +108,10 @@ ofx::piMapper::SurfaceManagerGui & ofxPiMapper::getGui() {
return gui;
}
ofx::piMapper::MediaServer& ofxPiMapper::getMediaServer(){
ofx::piMapper::MediaServer & ofxPiMapper::getMediaServer() {
return mediaServer;
}
ofx::piMapper::SurfaceManager& ofxPiMapper::getSurfaceManager(){
ofx::piMapper::SurfaceManager & ofxPiMapper::getSurfaceManager() {
return surfaceManager;
}

30
src/ofxPiMapper.h

@ -5,14 +5,10 @@
#include "SurfaceManagerGui.h"
#include "MediaServer.h"
#include "FboSource.h"
// Command design pattern includes
#include "BaseCmd.h"
#include "CmdManager.h"
#include "RmSurfaceCmd.h"
// Main view with state design pattern
#include "Application.h" // Main application entry point
#include "Application.h"
#define PIMAPPER_DEF_SURFACES_XML_FILE "defaultSurfaces.xml"
#define PIMAPPER_USER_SURFACES_XML_FILE "surfaces.xml"
@ -23,34 +19,23 @@ namespace ofx {
}
}
class ofxPiMapper{
class ofxPiMapper {
public:
ofxPiMapper();
void setup();
void stateSetup();
void draw();
void addFboSource(ofx::piMapper::FboSource& fboSource);
void registerFboSource(ofx::piMapper::FboSource & fboSource);
void addTriangleSurface();
void addQuadSurface();
// Toggle help / info
void showInfo() { bShowInfo = true; };
void hideInfo() { bShowInfo = false; };
void toggleInfo() { bShowInfo = !bShowInfo; }
// Getters
ofx::piMapper::CmdManager & getCmdManager();
ofx::piMapper::SurfaceManagerGui & getGui();
// Discussion:
// Maybe these should be static as this would allow to access them
// from anywhere within ofxPiMapper.
ofx::piMapper::MediaServer& getMediaServer();
ofx::piMapper::SurfaceManager& getSurfaceManager();
ofx::piMapper::MediaServer & getMediaServer();
ofx::piMapper::SurfaceManager & getSurfaceManager();
ofx::piMapper::CmdManager cmdManager;
ofx::piMapper::SurfaceManager surfaceManager;
@ -58,11 +43,6 @@ class ofxPiMapper{
bool isSetUp;
bool bShowInfo;
ofx::piMapper::MediaServer mediaServer;
// Discussion: Here now the GUI points only to surface manager,
// maybe it should be as a separate layer?
ofx::piMapper::SurfaceManagerGui gui;
ofx::piMapper::Application * _application;
};
Loading…
Cancel
Save