diff --git a/src/Application/SettingsLoader.cpp b/src/Application/SettingsLoader.cpp index a21eec8..9f8d5fd 100644 --- a/src/Application/SettingsLoader.cpp +++ b/src/Application/SettingsLoader.cpp @@ -71,7 +71,7 @@ bool SettingsLoader::load( if(sourceName != "" && sourceName != "none" && sourceType != ""){ // Load source depending on type - int typeEnum = SourceType::GetSourceTypeEnum(sourceType); + SourceType typeEnum = SourceTypeHelper::GetSourceTypeHelperEnum(sourceType); if(typeEnum == SourceType::SOURCE_TYPE_FBO){ // Load FBO source using sourceName @@ -200,7 +200,7 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){ xmlSettings->addTag("source"); xmlSettings->pushTag("source"); - string sourceTypeName = SourceType::GetSourceTypeName(surface->getSource()->getType()); + string sourceTypeName = SourceTypeHelper::GetSourceTypeHelperName(surface->getSource()->getType()); xmlSettings->addValue("source-type", sourceTypeName); string sourceName = surface->getSource()->getName(); diff --git a/src/Commands/SetNextSourceCmd.cpp b/src/Commands/SetNextSourceCmd.cpp index c0f2476..d55d5d7 100644 --- a/src/Commands/SetNextSourceCmd.cpp +++ b/src/Commands/SetNextSourceCmd.cpp @@ -71,24 +71,7 @@ void SetNextSourceCmd::exec(){ if(_nextSourceIndex >= _sources.size()){ _nextSourceIndex = 0; } - - // Load new source - /* - BaseSource * newSource; - if(_sources[_nextSourceIndex].type == SourceType::SOURCE_TYPE_IMAGE){ - newSource = mediaServer->loadImage(_sources[_nextSourceIndex].id); - }else{ - newSource = mediaServer->loadMedia( - _sources[_nextSourceIndex].id, - _sources[_nextSourceIndex].type); - } - - _surface->setSource(newSource); - - // Unload old one - mediaServer->unloadMedia(sourceId); - */ - + if(_sources[_nextSourceIndex].type == SourceType::SOURCE_TYPE_IMAGE){ _sourcesEditor->setImageSource(_sources[_nextSourceIndex].id); }else if(_sources[_nextSourceIndex].type == SourceType::SOURCE_TYPE_VIDEO){ @@ -104,20 +87,7 @@ void SetNextSourceCmd::exec(){ void SetNextSourceCmd::undo(){ ofLogNotice("SetNextSourceCmd", "undo"); - - /* - MediaServer * mediaServer = _sourcesEditor->getMediaServer(); - // Load back old source - BaseSource * prevSource = mediaServer->loadMedia( - _sources[_sourceIndex].id, - _sources[_sourceIndex].type); - - _surface->setSource(prevSource); - - mediaServer->unloadMedia(_sources[_nextSourceIndex].id); - */ - if(_sources[_sourceIndex].type == SourceType::SOURCE_TYPE_IMAGE){ _sourcesEditor->setImageSource(_sources[_sourceIndex].id); }else if(_sources[_sourceIndex].type == SourceType::SOURCE_TYPE_VIDEO){ diff --git a/src/Commands/SetSourceCmd.cpp b/src/Commands/SetSourceCmd.cpp index e886bef..984155b 100644 --- a/src/Commands/SetSourceCmd.cpp +++ b/src/Commands/SetSourceCmd.cpp @@ -17,7 +17,7 @@ SetSourceCmd::SetSourceCmd(int sourceType, void SetSourceCmd::exec(){ ofLogNotice("SetSourceCmd", "exec"); - _oldSourceType = _surface->getSource()->getType(); + _oldSourceTypeHelper = _surface->getSource()->getType(); if(_surface->getSource()->isLoadable()){ _oldSourceId = _surface->getSource()->getPath(); }else{ @@ -38,13 +38,13 @@ void SetSourceCmd::exec(){ void SetSourceCmd::undo(){ ofLogNotice("SetSourceCmd", "undo"); - if(_oldSourceType == SourceType::SOURCE_TYPE_IMAGE){ + if(_oldSourceTypeHelper == SourceType::SOURCE_TYPE_IMAGE){ _sourcesEditor->setImageSource(_oldSourceId); - }else if(_oldSourceType == SourceType::SOURCE_TYPE_VIDEO){ + }else if(_oldSourceTypeHelper == SourceType::SOURCE_TYPE_VIDEO){ _sourcesEditor->setVideoSource(_oldSourceId); - }else if(_oldSourceType == SourceType::SOURCE_TYPE_FBO){ + }else if(_oldSourceTypeHelper == SourceType::SOURCE_TYPE_FBO){ _sourcesEditor->setFboSource(_oldSourceId); - }else if(_oldSourceType == SourceType::SOURCE_TYPE_NONE){ + }else if(_oldSourceTypeHelper == SourceType::SOURCE_TYPE_NONE){ _sourcesEditor->clearSource(); } diff --git a/src/Commands/SetSourceCmd.h b/src/Commands/SetSourceCmd.h index c7515a8..ac639c8 100644 --- a/src/Commands/SetSourceCmd.h +++ b/src/Commands/SetSourceCmd.h @@ -29,7 +29,7 @@ class SetSourceCmd : public BaseUndoCmd { BaseSurface * _surface; SourcesEditorWidget * _sourcesEditor; - int _oldSourceType; + int _oldSourceTypeHelper; string _oldSourceId; }; diff --git a/src/Sources/BaseSource.cpp b/src/Sources/BaseSource.cpp index b8cdc0b..3ab1f92 100644 --- a/src/Sources/BaseSource.cpp +++ b/src/Sources/BaseSource.cpp @@ -31,7 +31,7 @@ bool BaseSource::isLoaded(){ return loaded; } -int BaseSource::getType(){ +SourceType BaseSource::getType(){ return type; } diff --git a/src/Sources/BaseSource.h b/src/Sources/BaseSource.h index 43f4ad5..c034739 100644 --- a/src/Sources/BaseSource.h +++ b/src/Sources/BaseSource.h @@ -8,7 +8,6 @@ namespace piMapper { // Use this for adding generative sources to your surfaces class BaseSource { - public: BaseSource(); BaseSource(ofTexture * newTexture); // Only one clean way of passing the texture @@ -17,7 +16,7 @@ class BaseSource { string & getName(); bool isLoadable(); // Maybe the loading features shoud go to a derrived class bool isLoaded(); // as BaseSourceLoadable - int getType(); + SourceType getType(); string & getPath(); virtual void clear(){} virtual void togglePause(){} @@ -36,8 +35,7 @@ class BaseSource { string path; // This is set only if loadable is true bool loadable; // If the source can be loaded from disk like image and video bool loaded; // Is the source loaded? - int type; - + SourceType type; }; } // namespace piMapper diff --git a/src/Sources/ImageSource.cpp b/src/Sources/ImageSource.cpp index 20ea40d..75ded43 100644 --- a/src/Sources/ImageSource.cpp +++ b/src/Sources/ImageSource.cpp @@ -4,7 +4,6 @@ namespace ofx { namespace piMapper { ImageSource::ImageSource(){ - //cout << "ImageSource" << endl; loadable = true; loaded = false; type = SourceType::SOURCE_TYPE_IMAGE; @@ -14,9 +13,7 @@ ImageSource::~ImageSource(){} void ImageSource::loadImage(string & filePath){ path = filePath; - //cout << "loading image: " << filePath << endl; setNameFromPath(filePath); - //cout << "path: " << path << endl; image = new ofImage(); #if (OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR >= 9) || OF_VERSION_MAJOR > 0 if(!image->load(filePath)){ @@ -24,7 +21,6 @@ void ImageSource::loadImage(string & filePath){ if(!image->loadImage(filePath)){ #endif ofLogWarning("ImageSource") << "Could not load image"; - //exit(EXIT_FAILURE); } #if (OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR >= 9) || OF_VERSION_MAJOR > 0 texture = &image->getTexture(); @@ -39,8 +35,6 @@ void ImageSource::clear(){ image->clear(); delete image; image = 0; - //path = ""; - //name = ""; loaded = false; } diff --git a/src/Sources/SourceType.h b/src/Sources/SourceType.h index 7ec1cd1..7c2ebac 100644 --- a/src/Sources/SourceType.h +++ b/src/Sources/SourceType.h @@ -10,14 +10,16 @@ namespace ofx { namespace piMapper { -class SourceType { +enum SourceType { + SOURCE_TYPE_NONE, + SOURCE_TYPE_IMAGE, + SOURCE_TYPE_VIDEO, + SOURCE_TYPE_FBO +}; +class SourceTypeHelper { public: - enum { - SOURCE_TYPE_NONE, SOURCE_TYPE_IMAGE, SOURCE_TYPE_VIDEO, SOURCE_TYPE_FBO - }; - - static string GetSourceTypeName(int sourceTypeEnum){ + static string GetSourceTypeHelperName(SourceType sourceTypeEnum){ if(sourceTypeEnum == SOURCE_TYPE_IMAGE){ return SOURCE_TYPE_NAME_IMAGE; }else if(sourceTypeEnum == SOURCE_TYPE_VIDEO){ @@ -29,12 +31,12 @@ class SourceType { }else{ stringstream ss; ss << "Invalid source type: " << sourceTypeEnum; - ofLogFatalError("SourceType") << ss.str(); + ofLogFatalError("SourceTypeHelper") << ss.str(); exit(EXIT_FAILURE); } } - static int GetSourceTypeEnum(string sourceTypeName){ + static SourceType GetSourceTypeHelperEnum(string sourceTypeName){ if(sourceTypeName == SOURCE_TYPE_NAME_IMAGE){ return SOURCE_TYPE_IMAGE; }else if(sourceTypeName == SOURCE_TYPE_NAME_VIDEO){ @@ -46,11 +48,10 @@ class SourceType { }else{ stringstream ss; ss << "Invalid source type name: " << sourceTypeName; - ofLogFatalError("SourceType") << ss.str(); + ofLogFatalError("SourceTypeHelper") << ss.str(); exit(EXIT_FAILURE); } } - }; } // namespace piMapper