Browse Source

Add `SurfaceManager` as pointer in `ofxPiMapper` root class

Update the rest of the code to treat `getSurfaceManager()` return value as a pointer.
master
Krisjanis Rijnieks 10 years ago
parent
commit
a681bfbd49
  1. 2
      src/Application/Application.cpp
  2. 6
      src/Commands/AddSurfaceCmd.cpp
  3. 8
      src/Commands/RmSurfaceCmd.cpp
  4. 11
      src/ofxPiMapper.cpp
  5. 4
      src/ofxPiMapper.h

2
src/Application/Application.cpp

@ -72,7 +72,7 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
break; break;
case 's': case 's':
_ofxPiMapper->getSurfaceManager().saveXmlSettings( _ofxPiMapper->getSurfaceManager()->saveXmlSettings(
PIMAPPER_USER_SURFACES_XML_FILE); PIMAPPER_USER_SURFACES_XML_FILE);
break; break;

6
src/Commands/AddSurfaceCmd.cpp

@ -18,7 +18,7 @@ void AddSurfaceCmd::exec(){
void AddSurfaceCmd::undo(){ void AddSurfaceCmd::undo(){
ofLogNotice("AddSurfaceCmd", "undo"); ofLogNotice("AddSurfaceCmd", "undo");
_app->getSurfaceManager().removeSurface(); _app->getSurfaceManager()->removeSurface();
} }
void AddSurfaceCmd::addTriangleSurface(){ void AddSurfaceCmd::addTriangleSurface(){
@ -34,7 +34,7 @@ void AddSurfaceCmd::addTriangleSurface(){
texCoords.push_back(ofVec2f(0.5f, 0.0f)); texCoords.push_back(ofVec2f(0.5f, 0.0f));
texCoords.push_back(ofVec2f(1.0f, 1.0f)); texCoords.push_back(ofVec2f(1.0f, 1.0f));
texCoords.push_back(ofVec2f(0.0f, 1.0f)); texCoords.push_back(ofVec2f(0.0f, 1.0f));
_app->getSurfaceManager().createSurface(surfaceType, vertices, texCoords); _app->getSurfaceManager()->createSurface(surfaceType, vertices, texCoords);
} }
void AddSurfaceCmd::addQuadSurface(){ void AddSurfaceCmd::addQuadSurface(){
@ -53,7 +53,7 @@ void AddSurfaceCmd::addQuadSurface(){
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 1.0f))); texCoords.push_back(ofVec2f(ofVec2f(1.0f, 1.0f)));
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 1.0f))); texCoords.push_back(ofVec2f(ofVec2f(0.0f, 1.0f)));
_app->getSurfaceManager().createSurface(surfaceType, vertices, texCoords); _app->getSurfaceManager()->createSurface(surfaceType, vertices, texCoords);
} }
} // namespace piMapper } // namespace piMapper

8
src/Commands/RmSurfaceCmd.cpp

@ -11,8 +11,8 @@ RmSurfaceCmd::RmSurfaceCmd(ofxPiMapper * app){
void RmSurfaceCmd::exec(){ void RmSurfaceCmd::exec(){
// Store the surface, this implies that the surfaceManager's // Store the surface, this implies that the surfaceManager's
// removeSelectedSurface does not destroy the surface. // removeSelectedSurface does not destroy the surface.
_surface = _app->surfaceManager.getSelectedSurface(); _surface = _app->getSurfaceManager()->getSelectedSurface();
_app->surfaceManager.removeSelectedSurface(); _app->getSurfaceManager()->removeSelectedSurface();
} }
void RmSurfaceCmd::undo(){ void RmSurfaceCmd::undo(){
@ -20,8 +20,8 @@ void RmSurfaceCmd::undo(){
if(_surface == 0){ if(_surface == 0){
ofLogError("RmSurfaceCmd", "No surface stored"); ofLogError("RmSurfaceCmd", "No surface stored");
} }
_app->surfaceManager.addSurface(_surface); _app->getSurfaceManager()->addSurface(_surface);
_app->surfaceManager.selectSurface(_surface); _app->getSurfaceManager()->selectSurface(_surface);
_surface = 0; _surface = 0;
} }

11
src/ofxPiMapper.cpp

@ -6,13 +6,14 @@ ofxPiMapper::ofxPiMapper(){
_gui = new ofx::piMapper::SurfaceManagerGui(); _gui = new ofx::piMapper::SurfaceManagerGui();
_cmdManager = new ofx::piMapper::CmdManager(); _cmdManager = new ofx::piMapper::CmdManager();
_mediaServer = new ofx::piMapper::MediaServer(); _mediaServer = new ofx::piMapper::MediaServer();
_surfaceManager = new ofx::piMapper::SurfaceManager();
_info = new ofx::piMapper::Info(); _info = new ofx::piMapper::Info();
} }
void ofxPiMapper::setup(){ void ofxPiMapper::setup(){
ofLogNotice("ofxPiMapper") << "Setting up..."; ofLogNotice("ofxPiMapper") << "Setting up...";
surfaceManager.setMediaServer(_mediaServer); _surfaceManager->setMediaServer(_mediaServer);
_gui->setMediaServer(_mediaServer); _gui->setMediaServer(_mediaServer);
_gui->setCmdManager(_cmdManager); _gui->setCmdManager(_cmdManager);
@ -24,7 +25,7 @@ void ofxPiMapper::setup(){
} }
} }
_gui->setSurfaceManager(&surfaceManager); _gui->setSurfaceManager(_surfaceManager);
isSetUp = true; isSetUp = true;
ofLogNotice("ofxPiMapper") << "Done setting up"; ofLogNotice("ofxPiMapper") << "Done setting up";
_application = new ofx::piMapper::Application(this); _application = new ofx::piMapper::Application(this);
@ -48,7 +49,7 @@ bool ofxPiMapper::loadXmlSettings(string fileName){
ofLogError("ofxPiMapper::loadXmlSettings()") << fileName << " does not exist"; ofLogError("ofxPiMapper::loadXmlSettings()") << fileName << " does not exist";
return false; return false;
} }
if(!surfaceManager.loadXmlSettings(fileName)){ if(!_surfaceManager->loadXmlSettings(fileName)){
ofLogError("ofxPiMapper::loadXmlSettings()") << "Failed to load " << fileName << endl; ofLogError("ofxPiMapper::loadXmlSettings()") << "Failed to load " << fileName << endl;
return false; return false;
} }
@ -63,8 +64,8 @@ ofx::piMapper::SurfaceManagerGui * ofxPiMapper::getGui(){
return _gui; return _gui;
} }
ofx::piMapper::SurfaceManager & ofxPiMapper::getSurfaceManager(){ ofx::piMapper::SurfaceManager * ofxPiMapper::getSurfaceManager(){
return surfaceManager; return _surfaceManager;
} }
ofx::piMapper::Info * ofxPiMapper::getInfo(){ ofx::piMapper::Info * ofxPiMapper::getInfo(){

4
src/ofxPiMapper.h

@ -32,8 +32,7 @@ class ofxPiMapper {
ofx::piMapper::CmdManager * getCmdManager(); ofx::piMapper::CmdManager * getCmdManager();
ofx::piMapper::SurfaceManagerGui * getGui(); ofx::piMapper::SurfaceManagerGui * getGui();
ofx::piMapper::SurfaceManager & getSurfaceManager(); ofx::piMapper::SurfaceManager * getSurfaceManager();
ofx::piMapper::SurfaceManager surfaceManager;
ofx::piMapper::Info * getInfo(); ofx::piMapper::Info * getInfo();
private: private:
@ -41,6 +40,7 @@ class ofxPiMapper {
bool bShowInfo; bool bShowInfo;
ofx::piMapper::CmdManager * _cmdManager; ofx::piMapper::CmdManager * _cmdManager;
ofx::piMapper::MediaServer * _mediaServer; ofx::piMapper::MediaServer * _mediaServer;
ofx::piMapper::SurfaceManager * _surfaceManager;
ofx::piMapper::SurfaceManagerGui * _gui; ofx::piMapper::SurfaceManagerGui * _gui;
ofx::piMapper::Application * _application; ofx::piMapper::Application * _application;
ofx::piMapper::Info * _info; ofx::piMapper::Info * _info;

Loading…
Cancel
Save