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

6
src/Application/ProjectionMappingState.cpp

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

7
src/ofxPiMapper.cpp

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

4
src/ofxPiMapper.h

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

Loading…
Cancel
Save