//-------------------------------------------------------------- void ofApp::keyPressed(int key){ if (key == 'r') { cam.beginRecording(); } if (key == 'R') { cam.endRecording(); } if (key == ' ') { if (!ofGetKeyPressed(OF_KEY_SHIFT)) { cam.play(); } else { cam.pause(); } } if (key == 'l') { ofFileDialogResult result = ofSystemLoadDialog("Choose a folder of recorded data", true, ofToDataPath("")); if (result.getPath() != "") { cam.setPlaybackPath(result.getPath()); } } if (key == 'L') { cam.setLive(); } }
//---------- void Model::populateInspector(ofxCvGui::ElementGroupPtr inspector) { auto loadButton = make_shared<ofxCvGui::Widgets::Button>("Load model...", [this]() { auto result = ofSystemLoadDialog("Load model using Assimp"); if (result.bSuccess) { this->modelLoader->loadModel(result.filePath); this->filename.set(result.filePath); } }); inspector->add(loadButton); inspector->add(make_shared<LiveValue<string>>("Filename", [this]() { return this->filename.get(); })); auto clearModelButton = make_shared <ofxCvGui::Widgets::Button>("Clear model", [this]() { this->modelLoader->clear(); this->filename.set(""); }); //we put the listener on the loadButton since we'll be disabling clearModelButton //also it stops there being a circular reference where loadButton owns a listener stack which owns a lambda which owns loadButton loadButton->onUpdate += [this, clearModelButton](ofxCvGui::UpdateArguments &) { clearModelButton->setEnabled(!this->filename.get().empty()); }; inspector->add(clearModelButton); inspector->add(make_shared<Title>("Draw options", Title::Level::H3)); inspector->add(make_shared<Toggle>(this->drawVertices)); inspector->add(make_shared<Toggle>(this->drawWireframe)); inspector->add(make_shared<Toggle>(this->drawFaces)); inspector->add(make_shared<Title>("Model transform", Title::Level::H3)); inspector->add(make_shared<Toggle>(this->flipX)); inspector->add(make_shared<Toggle>(this->flipY)); inspector->add(make_shared<Toggle>(this->flipZ)); inspector->add(make_shared<Slider>(this->inputUnitScale)); }
//-------------------------------------------------------------- void santiSoundize::keyPressed(int key){ switch(key){ case 'f': ofToggleFullscreen(); break; case 's': ofSaveFrame(); break; case 'p': m_audio.setPaused(m_isPlaying); m_isPlaying = !m_isPlaying; break; case 'd': cout << "m_balls.size() " << m_balls.size() << endl; cout << "ofGetFrameRate() " << ofGetFrameRate() << endl; cout << "ofGetTargetFrameRate() " << ofGetTargetFrameRate() << endl; break; case 'o': ofFileDialogResult result = ofSystemLoadDialog("open audio file"); if (result.bSuccess){ m_audio.loadSound(result.getPath(),true); m_audio.play(); m_isPlaying = true; } break; } }
void patch::guiEvent(ofxUIEventArgs &e) { // int kind = e.widget->getKind(); string name = e.widget->getName(); if (name == "Image src btn" && ((ofxUIButton*)e.widget)->getValue()) { ofFileDialogResult openFileResult = ofSystemLoadDialog("Select an image (.jpg, .jpeg, .png or .bmp)"); if (openFileResult.bSuccess){ ofFile file (openFileResult.getPath()); if (file.exists()){ string fileExtension = ofToUpper(file.getExtension()); //We only want images if (fileExtension == "JPG" || fileExtension == "PNG" || fileExtension == "JPEG" || fileExtension == "GIF" || fileExtension == "BMP" ) { imageSrc = openFileResult.getPath(); ((ofxUITextInput*)inspector->getWidget("Image src"))->setTextString(imageSrc); } else return; } file.close(); } } }
/** * Controlls all Events happens in the Current View * @param newEvent event object including widget which fired the event */ void Controller::guiEvent(ofxUIEventArgs & newEvent) { string buttonName = newEvent.widget->getName(); if (buttonName == "MAINMIDDLE") { ofxUIButton * button = (ofxUIButton *) newEvent.widget; if (button->getValue() == 1) { // std::cout << "SAVE IMAGE" << std::endl; model_->saveImage(); } } else if (buttonName == "MAINLEFT") { //Open the Open File Dialog ofFileDialogResult openFileResult = ofSystemLoadDialog("Select a jpg or png"); //Check if the user opened a file if (openFileResult.bSuccess){ ofLogVerbose("User selected a file"); //We have a file, check it and process it model_->processOpenFileSelection(openFileResult); } else { ofLogVerbose("User hit cancel"); } } }
//-------------------------------------------------------------- bool testApp::loadNewProject(){ allLoaded = false; ofSystemAlertDialog("Select Someone's Name"); ofFileDialogResult r; r = ofSystemLoadDialog("Get Directory", true); if(!r.bSuccess){ return false; } string currentMediaFolder = r.getPath(); ofDirectory compBin(currentMediaFolder + pathDelim + "compositions"+pathDelim); if(!compBin.exists()){ compBin.create(true); } compBin.listDir(); int compNumber = compBin.numFiles(); currentCompositionDirectory = currentMediaFolder + pathDelim+"compositions"+pathDelim+"comp" + ofToString(compNumber) + pathDelim; currentCompIndex = compNumber; if(!loadAssetsFromCompositionDirectory(currentMediaFolder)){ return false; } saveComposition(); refreshCompButtons(); loadTimelineFromCurrentComp(); allLoaded = true; return true; }
void testApp::openProjectFile( ) { cout << "open Dialgoue!" << endl ; ofFileDialogResult loadResult = ofSystemLoadDialog( "Open Project XML" ) ; string path = loadResult.getPath() ; // cout << "end result XML path!" << endl ; projectXml.loadFile( path ) ; int numWordBlocks = projectXml.getNumTags( "wordBlock" ) ; quote.clearWordBlocks() ; quote.setup( ) ; for ( int i = 0 ; i < numWordBlocks ; i++ ) { projectXml.pushTag( "wordBlock" , i ) ; ofPoint translate = ofPoint( projectXml.getValue( "translateX" , 0 ) , projectXml.getValue( "translateY" , 0 ) ) ; string text = projectXml.getValue( "text" , "noText" ) ; string fontPath = "../" + projectXml.getValue( "fontPath" , "noFont" ) ; float fontSize = projectXml.getValue ( "fontSize" , 18 ) ; quote.addWordBlock( text , fontPath , translate , fontSize ) ; projectXml.popTag( ) ; } int numColorTags = projectXml.getNumTags( "color" ) ; cout << "numColorTags : " << numColorTags << endl ; colorPool.clear() ; inspector.colors.clear() ; for ( int c = 0 ; c < numColorTags ; c++ ) { projectXml.pushTag( "color" , c ) ; ofColor color ; color.r = projectXml.getValue( "r" , 125 ) ; color.g = projectXml.getValue( "g" , 125 ) ; color.b = projectXml.getValue( "b" , 125 ) ; //cout << "r : " << color.r << " g : " << color.g << " b : " << color.b << endl ; colorPool.addColor( color ) ; projectXml.popTag( ) ; inspector.colors.push_back( color ) ; } a_maxSpeed = projectXml.getValue ( "MAX SPEED" , a_maxSpeed , a_maxSpeed ) ; a_rOffsetMaxSpeed = projectXml.getValue ( "MAX SPEED R OFFSET" , a_rOffsetMaxSpeed , a_rOffsetMaxSpeed ) ; a_maxForce = projectXml.getValue ( "MAX FORCE" , a_maxForce , a_maxForce ) ; a_rOffsetMaxTurn = projectXml.getValue ( "MAX FORCE R OFFSET" , a_rOffsetMaxTurn , a_rOffsetMaxTurn ) ; a_targetBuffer = projectXml.getValue ( "BUFFER DIST" , a_targetBuffer , a_targetBuffer ) ; a_pathSampling = projectXml.getValue ( "PATH SAMPLING" , a_pathSampling , a_pathSampling ) ; a_numAgents = projectXml.getValue ( "NUM AGENTS" , a_numAgents , a_numAgents ) ; resetAgents( ) ; quote.bReadyToStart = true ; }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ switch (key) { case 'h': { bHide = !bHide; } break; case 's': { gui.saveToFile("settings.xml"); } break; case 'l': { ofFileDialogResult results = ofSystemLoadDialog(); openNIPlayer.setupFromONI(results.filePath); openNIPlayer.addDepthGenerator(); openNIPlayer.addImageGenerator(); openNIPlayer.setRegister(true); openNIPlayer.setMirror(true); openNIPlayer.addUserGenerator(); openNIPlayer.setMaxNumUsers(1); //1 for this one.... } break; default: break; } }
//-------------------------------------------------------------- void ofApp::setup(){ ofFileDialogResult r = ofSystemLoadDialog(); if(r.bSuccess){ if(img.load(r.getPath())){ img.resize(img.getWidth() /10, img.getHeight() / 10); mesh = ofMesh::plane(img.getWidth(), img.getHeight(),img.getWidth(), img.getHeight()); for (int i =0; i < img.getHeight(); i++) { for (int j = 0; j < img.getWidth(); j++) { int meshIndex = i*img.getWidth()+j; ofPoint v = mesh.getVertex(meshIndex); v.z = img.getColor(j, i).getLightness(); mesh.setVertex(meshIndex, v); mesh.addColor(img.getColor(j, i)); } } } } ofEnableDepthTest(); }
bool ofxTLDepthImageSequence::loadSequence(){ ofFileDialogResult r = ofSystemLoadDialog("Load Depth Sequence Directory", true); if(r.bSuccess){ return loadSequence(r.getPath()); } return false; }
//----------------------------------------------------------- void testApp::openSharedVideoFile(int i) { cout << "loading shared video " << endl; ofFileDialogResult dialog_result = ofSystemLoadDialog("load shared video file"); if(dialog_result.bSuccess) { if (sharedVideos[i].isLoaded()) { sharedVideos[i].closeMovie(); } string path = dialog_result.getPath(); sharedVideos[i].loadMovie(path); if(sharedVideos[i].isLoaded()) { cout << "shared video loaded" << endl; sharedVideosFiles[i] = path; sharedVideos[i].setLoopState(OF_LOOP_NORMAL); sharedVideos[i].play(); sharedVideos[i].setVolume(0); for(int j=0; j<36; j++) { if (quads[j].initialized) { quads[j].vids[i] = sharedVideos[i]; } } } } }
void THISTimeline::objectDidRelease(ofxMSAInteractiveObject* object, int x, int y, int button) { if(object == cancelExportButton){ exporter->cancelExport(); return; } if(exporting){ return; } if(object == newCompButton){ newComposition(); } else if(object == loadCompButton){ ofFileDialogResult result = ofSystemLoadDialog("Load Composition", true); if(result.bSuccess && ofDirectory::doesDirectoryExist(result.filePath, false)){ loadComposition(result.getPath()); } } if(object == exportEntireSequenceButton){ exportEntireSequence(); } if(object == exportCurrentViewButton){ exportCurrentView(); } }
void testApp::keyPressed(int key) { if (key == 'p') { // prints from your app's data directory. printer.printImage("test-image.png"); } else if(key == 'o') { ofFileDialogResult fileDialogResult = ofSystemLoadDialog("Select a valid image file"); if(fileDialogResult.bSuccess) { // ghetto way of testing the mime type ofImage validImageTest; if(validImageTest.loadImage(fileDialogResult.getPath())) { // by passing the true boolean, the printer will assume an absolute path to the image to print. printer.printImage(fileDialogResult.getPath(),true); } else { ofLog(OF_LOG_ERROR, "Please select a valid image."); } } } if (key == 'a') { printer.clearAllJobs(); } if(key == 'c') { printer.checkActiveJobStatus(); } }
ofxTLImageSequence* ofxTimeline::addImageSequence(string name){ ofFileDialogResult result = ofSystemLoadDialog("Load Sequence", true); if(result.bSuccess && ofDirectory::doesDirectoryExist(result.filePath, false)){ return addImageSequence(name, result.getPath()); } return NULL; }
bool testApp::loadNewScene(){ ofFileDialogResult r = ofSystemLoadDialog("Select a Scene", true); if(r.bSuccess){ return loadScene(r.getPath()); } return false; }
void VisualizationApp::changeFontPressed(bool & pressed){ if(!pressed){ ofFileDialogResult result = ofSystemLoadDialog("choose font",false); if(result.bSuccess){ TweetText::fontName = result.filePath; TweetText::font.loadFont(TweetText::fontName,TweetText::fontSize,true,true); } } }
string testApp::loadSlideshow() { ofFileDialogResult dialog_result = ofSystemLoadDialog("find slideshow folder", true); if(dialog_result.bSuccess) { string slideshowPath = dialog_result.getPath(); return slideshowPath; } }
//-------------------------------------------------------------- void testApp::loadCompositions(){ ofSystemAlertDialog("Select the MediaBin containing everyone's names"); ofFileDialogResult r = ofSystemLoadDialog("Select Media Bin", true); if(r.bSuccess){ mediaBinDirectory = r.getPath(); refreshCompButtons(); } }
//load file button void SoundCue::onLoadFileButtonEvent(ofxDatGuiButtonEvent e) { ofFileDialogResult openFileResult = ofSystemLoadDialog("Select a sound file"); if (openFileResult.bSuccess) { loadFile->setLabel(openFileResult.getPath()); filePath = openFileResult.getPath(); soundPlayer.load(filePath); soundPlayer.setVolume(0.75f); } }
//------------------------------------------------------------------------------------ void openPlaybackDialog() { ///add directory select const string defPath = ram::MOTION_DATA_DIR; const string info = "Open motions for a skeleton."; ofFileDialogResult ret = ofSystemLoadDialog(info, false, defPath); if (ret.bSuccess) openPlaybackFile(ret.getPath(), ret.getName()); }
//----------------------------------------------------------- void testApp::openVideoFile() { cout << "loading video " << endl; ofFileDialogResult dialog_result = ofSystemLoadDialog("load video file"); cout << "video loaded " << endl; if(dialog_result.bSuccess) { quads[activeQuad].loadVideoFromFile(dialog_result.getName(), dialog_result.getPath()); } }
//----------------------------------------------------------- void testApp::openAnimaFile() { cout << "loading 3d model " << endl; ofFileDialogResult dialog_result = ofSystemLoadDialog("load 3d model"); cout << "3d model loaded " << endl; if(dialog_result.bSuccess) { quads[activeQuad].loadAnimaFromFile(dialog_result.getName(), dialog_result.getPath()); } }
//----------------------------------------------------------- void testApp::openImageFile() { cout << "loading image " << endl; ofFileDialogResult dialog_result = ofSystemLoadDialog("load image file"); cout << "image loaded " << endl; if(dialog_result.bSuccess) { quads[activeQuad].loadImageFromFile(dialog_result.getName(), dialog_result.getPath()); } }
void KinectV2Classifier::eventLoad(ofxControlButtonEventArgs & evt) { if (!foundUser) { ofSystem("Error! You must have a skeleton detected first before loading the preset."); return; } ofFileDialogResult result = ofSystemLoadDialog("Select preset", false, ofToDataPath("")); if (result.bSuccess) { loadPreset(result.filePath); } }
void THISSequence::loadSequence() { ofFileDialogResult result = ofSystemLoadDialog("Load Sequence", true); if(result.bSuccess) { directory = result.getPath(); loadSequence(directory); } else { ofLog(OF_LOG_ERROR, "THIS_Sequence -- ERROR -- attempted loaded invalid directory '" + directory + "'."); } }
//-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ ofVec2f mouse(x,y); if(xmpp.getConnectionState()==ofxXMPPConnected && sendButton.inside(mouse) && selectedFriend!=-1){ ofFileDialogResult file = ofSystemLoadDialog("select a file to send",false); if(file.bSuccess){ xmppFileTransfer.sendFile(xmpp.getFriends()[selectedFriend].userName + "/" + xmpp.getFriends()[selectedFriend].resource,file.getPath()); } }else if(selectedFriend==-1){ ofSystemAlertDialog("No user selected to send a file"); } }
void ofxRGBDCaptureGui::loadDirectory(){ if(recorder.numFramesWaitingCompession() != 0){ ofSystemAlertDialog("Cannot change directory while files are converting"); return; } ofFileDialogResult r = ofSystemLoadDialog("Select Record Directory", true); if(r.bSuccess){ loadDirectory(r.getPath()); } }
/* Gère les événements du menu d'importation d'images */ void ofApp::onMenuImagesEvent(ofxDatGuiButtonEvent e) { // Bouton importer image sans transformation if (e.target == btnImportImgSansTrans) { ofFileDialogResult result; result = ofSystemLoadDialog("Importer une image sans transformation"); if (!result.fileName.empty()) { importerImage(imageArrierePlan, result.filePath); } menuImages->setVisible(false); } // Bouton importer image pivotée if (e.target == btnImportImgRotation) { ofFileDialogResult result; result = ofSystemLoadDialog("Importer une image pivotee"); if (!result.fileName.empty()) { importerImagePivotee(imageArrierePlan, result.filePath, ROTATION_90); } menuImages->setVisible(false); } // Bouton importer image en noir et blanc if (e.target == btnImportImgNoirEtBLanc) { ofFileDialogResult result; result = ofSystemLoadDialog("Importer une image en noir et blanc"); if (!result.fileName.empty()) { importerImageNoirEtBlanc(imageArrierePlan, result.filePath); } menuImages->setVisible(false); } // Bouton importer image sepia if (e.target == btnImportImgSepia) { ofFileDialogResult result; result = ofSystemLoadDialog("Importer une image en sepia"); if (!result.fileName.empty()) { importerImageSepia(imageArrierePlan, result.filePath); } menuImages->setVisible(false); } }
void testApp::openFontDialogue( ) { // cout << "open Font Dialogue!" << endl ; ofFileDialogResult fontResult = ofSystemLoadDialog( "Open New .otf or .ttf font file" , false ) ; string path = fontResult.getPath() ; // cout << "path : " << path << endl ; inspector.addFont( path ) ; }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ if(key == 13) chgColorNumStr =""; if(key == 8 || key == 127){ if( pos != 0 ){ pos--; chgColorNumStr = chgColorNumStr.substr(0,pos); }else chgColorNumStr = ""; }else if((key >= 48 && key <= 57) || (key == 44) || (key == 46) || (key == 47)){ chgColorNumStr.append(1, (char) key); pos++; } switch (key) { case 'O': case 'o': bLoad = false; bAnal = false; bCreate = false; bFileDone = false; pos = 0; imageCnt = 0; colorCnt = 0; folderPath = ""; colorTable.clear(); openFileResult = ofSystemLoadDialog("Select a Folder",true); folderPath = openFileResult.getPath(); break; case 'L': case 'l': bPushLoad = true; break; case 'A': case 'a': bPushAnal = true; break; case 'C': case 'c': bPushCreate = true; break; case ' ': bImageMakePush = true; break; } }