|
@ -3,13 +3,7 @@ |
|
|
namespace ofx { |
|
|
namespace ofx { |
|
|
namespace piMapper { |
|
|
namespace piMapper { |
|
|
|
|
|
|
|
|
SetNextSourceCmd::SetNextSourceCmd(int sourceType, |
|
|
SetNextSourceCmd::SetNextSourceCmd(BaseSurface * surface, SourcesEditor * sourcesEditor){ |
|
|
string sourceId, |
|
|
|
|
|
BaseSurface * surface, |
|
|
|
|
|
SourcesEditor * sourcesEditor){ |
|
|
|
|
|
|
|
|
|
|
|
_sourceType = sourceType; |
|
|
|
|
|
_sourceId = sourceId; |
|
|
|
|
|
_surface = surface; |
|
|
_surface = surface; |
|
|
_sourcesEditor = sourcesEditor; |
|
|
_sourcesEditor = sourcesEditor; |
|
|
} |
|
|
} |
|
@ -17,39 +11,87 @@ SetNextSourceCmd::SetNextSourceCmd(int sourceType, |
|
|
void SetNextSourceCmd::exec(){ |
|
|
void SetNextSourceCmd::exec(){ |
|
|
ofLogNotice("SetNextSourceCmd", "exec"); |
|
|
ofLogNotice("SetNextSourceCmd", "exec"); |
|
|
|
|
|
|
|
|
_oldSourceType = _surface->getSource()->getType(); |
|
|
// Get current source
|
|
|
if(_surface->getSource()->isLoadable()){ |
|
|
BaseSource * source = _surface->getSource(); |
|
|
_oldSourceId = _surface->getSource()->getPath(); |
|
|
int sourceType = source->getType(); |
|
|
|
|
|
|
|
|
|
|
|
string sourceId; |
|
|
|
|
|
if(source->isLoadable()){ |
|
|
|
|
|
sourceId = source->getPath(); |
|
|
}else{ |
|
|
}else{ |
|
|
_oldSourceId = _surface->getSource()->getName(); |
|
|
sourceId = source->getName(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(_sourceType == SourceType::SOURCE_TYPE_IMAGE){ |
|
|
// MediaServer shortcut
|
|
|
_sourcesEditor->setImageSource(_sourceId); |
|
|
MediaServer * mediaServer = _sourcesEditor->getMediaServer(); |
|
|
}else if(_sourceType == SourceType::SOURCE_TYPE_VIDEO){ |
|
|
|
|
|
_sourcesEditor->setVideoSource(_sourceId); |
|
|
// Read sources into a single vector
|
|
|
}else if(_sourceType == SourceType::SOURCE_TYPE_FBO){ |
|
|
for(unsigned int i = 0; i < mediaServer->getImagePaths().size(); ++i){ |
|
|
_sourcesEditor->setFboSource(_sourceId); |
|
|
SourceData data; |
|
|
}else if(_sourceType == SourceType::SOURCE_TYPE_NONE){ |
|
|
data.type = SourceType::SOURCE_TYPE_IMAGE; |
|
|
_sourcesEditor->clearSource(); |
|
|
data.id = mediaServer->getImagePaths()[i]; |
|
|
|
|
|
_sources.push_back(data); |
|
|
|
|
|
} |
|
|
|
|
|
for(unsigned int i = 0; i < mediaServer->getVideoPaths().size(); ++i){ |
|
|
|
|
|
SourceData data; |
|
|
|
|
|
data.type = SourceType::SOURCE_TYPE_VIDEO; |
|
|
|
|
|
data.id = mediaServer->getVideoPaths()[i]; |
|
|
|
|
|
_sources.push_back(data); |
|
|
|
|
|
} |
|
|
|
|
|
for(unsigned int i = 0; i < mediaServer->getFboSourceNames().size(); ++i){ |
|
|
|
|
|
SourceData data; |
|
|
|
|
|
data.type = SourceType::SOURCE_TYPE_FBO; |
|
|
|
|
|
data.id = mediaServer->getFboSourceNames()[i]; |
|
|
|
|
|
_sources.push_back(data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(_sources.size() <= 0){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_sourceIndex = -1; |
|
|
|
|
|
|
|
|
|
|
|
// Search for current source among all
|
|
|
|
|
|
for(unsigned int i = 0; i < _sources.size(); ++i){ |
|
|
|
|
|
if(sourceType == _sources[i].type && sourceId == _sources[i].id){ |
|
|
|
|
|
_sourceIndex = i; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(_sourceIndex == -1){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_nextSourceIndex = _sourceIndex + 1; |
|
|
|
|
|
if(_nextSourceIndex >= _sources.size()){ |
|
|
|
|
|
_nextSourceIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Load new source
|
|
|
|
|
|
BaseSource * newSource = mediaServer->loadMedia( |
|
|
|
|
|
_sources[_nextSourceIndex].id, |
|
|
|
|
|
_sources[_nextSourceIndex].type); |
|
|
|
|
|
|
|
|
|
|
|
_surface->setSource(newSource); |
|
|
|
|
|
|
|
|
|
|
|
// Unload old one
|
|
|
|
|
|
mediaServer->unloadMedia(sourceId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SetNextSourceCmd::undo(){ |
|
|
void SetNextSourceCmd::undo(){ |
|
|
ofLogNotice("SetNextSourceCmd", "undo"); |
|
|
ofLogNotice("SetNextSourceCmd", "undo"); |
|
|
|
|
|
|
|
|
if(_oldSourceType == SourceType::SOURCE_TYPE_IMAGE){ |
|
|
MediaServer * mediaServer = _sourcesEditor->getMediaServer(); |
|
|
_sourcesEditor->setImageSource(_oldSourceId); |
|
|
|
|
|
}else if(_oldSourceType == SourceType::SOURCE_TYPE_VIDEO){ |
|
|
// Load back old source
|
|
|
_sourcesEditor->setVideoSource(_oldSourceId); |
|
|
BaseSource * prevSource = mediaServer->loadMedia( |
|
|
}else if(_oldSourceType == SourceType::SOURCE_TYPE_FBO){ |
|
|
_sources[_sourceIndex].id, |
|
|
_sourcesEditor->setFboSource(_oldSourceId); |
|
|
_sources[_sourceIndex].type); |
|
|
}else if(_oldSourceType == SourceType::SOURCE_TYPE_NONE){ |
|
|
|
|
|
_sourcesEditor->clearSource(); |
|
|
_surface->setSource(prevSource); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_surface = 0; |
|
|
mediaServer->unloadMedia(_sources[_nextSourceIndex].id); |
|
|
_sourcesEditor = 0; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} // namespace piMapper
|
|
|
} // namespace piMapper
|
|
|