Browse Source

Add `_cmdManager` as a pointer to `ofxPiMapper` root class

- Change the getter to return pointer as well.
 - Update code elsewhere to call methods on `CmdManager` as if it was a pointer.
master
Krisjanis Rijnieks 10 years ago
parent
commit
2e311e89b0
  1. 10
      src/Application/Application.cpp
  2. 6
      src/Application/ProjectionMappingState.cpp
  3. 7
      src/ofxPiMapper.cpp
  4. 4
      src/ofxPiMapper.h

10
src/Application/Application.cpp

@ -36,28 +36,28 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
switch(args.key){ switch(args.key){
case '1': case '1':
_ofxPiMapper->getCmdManager().exec( _ofxPiMapper->getCmdManager()->exec(
new ofx::piMapper::SetApplicationStateCmd( new ofx::piMapper::SetApplicationStateCmd(
this, PresentationState::instance(), this, PresentationState::instance(),
&_ofxPiMapper->getGui(), GuiMode::NONE)); &_ofxPiMapper->getGui(), GuiMode::NONE));
break; break;
case '2': case '2':
_ofxPiMapper->getCmdManager().exec( _ofxPiMapper->getCmdManager()->exec(
new ofx::piMapper::SetApplicationStateCmd( new ofx::piMapper::SetApplicationStateCmd(
this, TextureMappingState::instance(), this, TextureMappingState::instance(),
&_ofxPiMapper->getGui(), GuiMode::TEXTURE_MAPPING)); &_ofxPiMapper->getGui(), GuiMode::TEXTURE_MAPPING));
break; break;
case '3': case '3':
_ofxPiMapper->getCmdManager().exec( _ofxPiMapper->getCmdManager()->exec(
new ofx::piMapper::SetApplicationStateCmd( new ofx::piMapper::SetApplicationStateCmd(
this, ProjectionMappingState::instance(), this, ProjectionMappingState::instance(),
&_ofxPiMapper->getGui(), GuiMode::PROJECTION_MAPPING)); &_ofxPiMapper->getGui(), GuiMode::PROJECTION_MAPPING));
break; break;
case '4': case '4':
_ofxPiMapper->getCmdManager().exec( _ofxPiMapper->getCmdManager()->exec(
new ofx::piMapper::SetApplicationStateCmd( new ofx::piMapper::SetApplicationStateCmd(
this, SourceSelectionState::instance(), this, SourceSelectionState::instance(),
&_ofxPiMapper->getGui(), GuiMode::SOURCE_SELECTION)); &_ofxPiMapper->getGui(), GuiMode::SOURCE_SELECTION));
@ -77,7 +77,7 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
break; break;
case 'z': case 'z':
_ofxPiMapper->getCmdManager().undo(); _ofxPiMapper->getCmdManager()->undo();
break; break;
default: default:

6
src/Application/ProjectionMappingState.cpp

@ -18,7 +18,7 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar
switch(args.key){ switch(args.key){
case 't': case 't':
app->getOfxPiMapper()->getCmdManager().exec( app->getOfxPiMapper()->getCmdManager()->exec(
new AddSurfaceCmd( new AddSurfaceCmd(
app->getOfxPiMapper(), app->getOfxPiMapper(),
SurfaceType::TRIANGLE_SURFACE) SurfaceType::TRIANGLE_SURFACE)
@ -26,7 +26,7 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar
break; break;
case 'q': case 'q':
app->getOfxPiMapper()->getCmdManager().exec( app->getOfxPiMapper()->getCmdManager()->exec(
new AddSurfaceCmd( new AddSurfaceCmd(
app->getOfxPiMapper(), app->getOfxPiMapper(),
SurfaceType::QUAD_SURFACE) SurfaceType::QUAD_SURFACE)
@ -34,7 +34,7 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar
break; break;
case OF_KEY_BACKSPACE: case OF_KEY_BACKSPACE:
app->getOfxPiMapper()->getCmdManager().exec( app->getOfxPiMapper()->getCmdManager()->exec(
new RmSurfaceCmd(app->getOfxPiMapper())); new RmSurfaceCmd(app->getOfxPiMapper()));
break; break;

7
src/ofxPiMapper.cpp

@ -3,6 +3,7 @@
ofxPiMapper::ofxPiMapper(){ ofxPiMapper::ofxPiMapper(){
bShowInfo = false; bShowInfo = false;
isSetUp = false; isSetUp = false;
_cmdManager = new ofx::piMapper::CmdManager();
_mediaServer = new ofx::piMapper::MediaServer(); _mediaServer = new ofx::piMapper::MediaServer();
_info = new ofx::piMapper::Info(); _info = new ofx::piMapper::Info();
} }
@ -12,7 +13,7 @@ void ofxPiMapper::setup(){
surfaceManager.setMediaServer(_mediaServer); surfaceManager.setMediaServer(_mediaServer);
gui.setMediaServer(_mediaServer); gui.setMediaServer(_mediaServer);
gui.setCmdManager(&cmdManager); gui.setCmdManager(_cmdManager);
if(!loadXmlSettings(PIMAPPER_USER_SURFACES_XML_FILE)){ if(!loadXmlSettings(PIMAPPER_USER_SURFACES_XML_FILE)){
ofLogWarning("ofxPiMapper::setup()") << "Failed to load user settings, go with default" << endl; ofLogWarning("ofxPiMapper::setup()") << "Failed to load user settings, go with default" << endl;
@ -53,8 +54,8 @@ bool ofxPiMapper::loadXmlSettings(string fileName){
return true; return true;
} }
ofx::piMapper::CmdManager & ofxPiMapper::getCmdManager(){ ofx::piMapper::CmdManager * ofxPiMapper::getCmdManager(){
return cmdManager; return _cmdManager;
} }
ofx::piMapper::SurfaceManagerGui & ofxPiMapper::getGui(){ ofx::piMapper::SurfaceManagerGui & ofxPiMapper::getGui(){

4
src/ofxPiMapper.h

@ -30,16 +30,16 @@ class ofxPiMapper {
void registerFboSource(ofx::piMapper::FboSource & fboSource); void registerFboSource(ofx::piMapper::FboSource & fboSource);
bool loadXmlSettings(string fileName); bool loadXmlSettings(string fileName);
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::CmdManager cmdManager;
ofx::piMapper::SurfaceManager surfaceManager; ofx::piMapper::SurfaceManager surfaceManager;
ofx::piMapper::Info * getInfo(); ofx::piMapper::Info * getInfo();
private: private:
bool isSetUp; bool isSetUp;
bool bShowInfo; bool bShowInfo;
ofx::piMapper::CmdManager * _cmdManager;
ofx::piMapper::MediaServer * _mediaServer; ofx::piMapper::MediaServer * _mediaServer;
ofx::piMapper::SurfaceManagerGui gui; ofx::piMapper::SurfaceManagerGui gui;
ofx::piMapper::Application * _application; ofx::piMapper::Application * _application;

Loading…
Cancel
Save