Browse Source

Add ofxPiMapper::setImageSource()

Also fix ofxPiMapper::setVideoSource() to stop only video sources and not crash.
master
Krisjanis Rijnieks 7 years ago
parent
commit
06545df724
  1. 35
      src/Application/Application.cpp
  2. 1
      src/Application/Application.h
  3. 4
      src/ofxPiMapper.cpp
  4. 1
      src/ofxPiMapper.h

35
src/Application/Application.cpp

@ -488,9 +488,12 @@ void Application::setVideoSource(std::string fileName){
if(ofIsStringInString(loadedVideos[i], fileName)){
if(getSurfaceManager()->getSelectedSurface() != 0){
BaseSource * source = getSurfaceManager()->getSelectedSurface()->getSource();
VideoSource * video = dynamic_cast<VideoSource *>(source);
video->stop();
if(source->getType() == SOURCE_TYPE_VIDEO){
VideoSource * video = dynamic_cast<VideoSource *>(source);
video->stop();
}
getCmdManager()->exec(
new SetSourceCmd(
SourceType::SOURCE_TYPE_VIDEO,
@ -505,6 +508,32 @@ void Application::setVideoSource(std::string fileName){
}
}
void Application::setImageSource(std::string fileName){
vector<std::string> loadedImages = getMediaServer()->getImageNames();
for(auto i = 0; i < loadedImages.size(); i++){
if(ofIsStringInString(loadedImages[i], fileName)){
if(getSurfaceManager()->getSelectedSurface() != 0){
BaseSource * source = getSurfaceManager()->getSelectedSurface()->getSource();
if(source->getType() == SOURCE_TYPE_VIDEO){
VideoSource * video = dynamic_cast<VideoSource *>(source);
video->stop();
}
getCmdManager()->exec(
new SetSourceCmd(
SourceType::SOURCE_TYPE_IMAGE,
getMediaServer()->getImagePaths()[i],
getSurfaceManager()->getSelectedSurface(),
&Gui::instance()->getSourcesEditorWidget()));
}else{
getCmdManager()->exec(new SelNextSurfaceCmd(getSurfaceManager()));
}
break;
}
}
}
void Application::addGridRow(){
if(getSurfaceManager()->getSelectedSurface() != 0){
if(getSurfaceManager()->getSelectedSurface()->getType() ==

1
src/Application/Application.h

@ -131,6 +131,7 @@ class Application {
void setNextSource();
void setFboSource(std::string sourceId);
void setVideoSource(std::string fileName);
void setImageSource(std::string fileName);
void addGridRow();
void addGridColumn();
void removeGridRow();

4
src/ofxPiMapper.cpp

@ -190,6 +190,10 @@ void ofxPiMapper::setVideoSource(std::string fileName){
_application.setVideoSource(fileName);
}
void ofxPiMapper::setImageSource(std::string fileName){
_application.setImageSource(fileName);
}
void ofxPiMapper::reboot(){
_application.reboot();
}

1
src/ofxPiMapper.h

@ -87,6 +87,7 @@ class ofxPiMapper {
void setNextSource();
void setFboSource(std::string sourceId);
void setVideoSource(std::string fileName);
void setImageSource(std::string fileName);
// System commands
void reboot();

Loading…
Cancel
Save