//-------------------------------------------------------------- string testApp::getSaveFileName() { //jump through hoops to create and save a file string previousFile = curList.getFileName(); ofFileDialogResult saveFileName; if(previousFile == "OnRabbit.csv" || previousFile == "RabbitDefaults.csv") saveFileName = ofSystemSaveDialog("", ""); else saveFileName = ofSystemSaveDialog(previousFile, ""); return saveFileName.getPath(); }
void ofApp::onMenuExportCapturesEcranEvent(ofxDatGuiButtonEvent e) { //S'il s'agit d'une capture d'écran totale, on passe par cet événement; s'il s'agit d'une capture d'écran partielle, ce sera traité lors du relâchement de la souris. captureEcranActive.debutX = 0; captureEcranActive.debutY = 0; if (!captureEcranActive.captureEcranPartielle) { // Bouton exporter capture sans transformation if (e.target == btnExportCaptureSansTrans) { captureEcranActive.largeur = ofGetWidth(); captureEcranActive.hauteur = ofGetHeight(); traiterCaptureEcranSansTransformation(); } // Bouton exporter capture pivotée if (e.target == btnExportCaptureRotation) { ofFileDialogResult result; result = ofSystemSaveDialog("Exporter une capture pivotee", "Exporter une capture pivotee"); if (!result.fileName.empty()) { captureEcranActive.largeur = ofGetWidth(); captureEcranActive.hauteur = ofGetHeight(); exporterImagePivotee(result.fileName, "png", captureEcranActive, ROTATION_90); } } // Bouton exporter capture en noir et blanc if (e.target == btnExportCaptureNoirEtBLanc) { ofFileDialogResult result; result = ofSystemSaveDialog("Exporter une capture en noir et blanc", "Exporter une capture en noir et blanc"); if (!result.fileName.empty()) { captureEcranActive.largeur = ofGetWidth(); captureEcranActive.hauteur = ofGetHeight(); exporterImageNoirEtBlanc(result.fileName, "png", captureEcranActive); } } // Bouton exporter capture sepia if (e.target == btnExportCaptureSepia) { ofFileDialogResult result; result = ofSystemSaveDialog("Exporter une capture en sepia", "Exporter une capture en sepia"); if (!result.fileName.empty()) { captureEcranActive.largeur = ofGetWidth(); captureEcranActive.hauteur = ofGetHeight(); exporterImageSepia(result.fileName, "png", captureEcranActive); } } } else { captureEcranEnCours = true; } menuExportCapturesEcran->setVisible(false); menuChoixTypeCaptureEcran->setVisible(false); }
void PuppetsHandler::exportScene() { ofFileDialogResult saveFileResult = ofSystemSaveDialog(DEFAULT_SCENE_NAME, "Select location to export scene:"); if (saveFileResult.bSuccess){ string path = saveFileResult.getPath(); string mkdirCommandString = "mkdir " + path; system(mkdirCommandString.c_str()); ofxXmlSettings info; for(int i = 0; i < puppets.size(); i++) { info.addTag("puppet"); info.pushTag("puppet",i); info.addValue("puppetdir", "puppet"+ofToString(i)); info.addValue("isControllable", puppets[i].isControllable()); info.addValue("layer", puppets[i].getLayer()); info.popTag(); if(puppets[i].isControllable()) { puppets[i].save(path + "/puppet" + ofToString(i)); } else { puppets[i].saveCachedFrames(path + "/puppet" + ofToString(i)); } } info.save(path + "/info.xml"); } }
void DataSet::saveCorrespondences(string filename) const { if (!hasData) { ofLogError("ofxGraycode::DataSet") << "Cannot save correspondences vector as we have no data yet"; return; } if (filename=="") { filename = this->getFilename(); if (filename=="") filename = ofSystemSaveDialog("sl.correspondences", "Save correspondences").getPath(); else filename += ".correspondences"; } vector<Correspondence> correspondences = this->getCorrespondencesVector(); ofstream fileOut; try { fileOut.open(ofToDataPath(filename, true).c_str(), ios::binary); uint32_t size = correspondences.size(); fileOut.write((char*)&size, sizeof(uint32_t)); vector<Correspondence>::iterator it; for (it = correspondences.begin(); it != correspondences.end(); it++) fileOut.write((char*)&(*it), sizeof(Correspondence)); fileOut.close(); } catch (...) { ofLogError("ofxGraycode") << "Save correspondences file write failed"; } }
//-------------------------------------------------------------- void gFrameApp::onFlow2SettingsSave() { ofFileDialogResult save_result = ofSystemSaveDialog("NewFlowSettings.xml", "save new flow settings"); string new_filename = save_result.getPath(); cout << new_filename << endl; if (new_filename != "") flow2_gui.saveToFile(new_filename); }
//-------------------------------------------------------------- void testApp::update(){ lock(); kinect.update(); unlock(); if (wdgSelectPath.getBang()) path = ofSystemSaveDialog("timelapse", "Timelapse save path").getPath(); }
//-------------------------------------------------------------- void ofApp::recExportPressed(){ ofBuffer buf = ofBufferFromFile(tempAudio, true); string tempPath = "audio_" + ofToString(int(frames)) + "_" + ofToString(int(frameRate)) + ".wav"; ofFileDialogResult saveFileResult = ofSystemSaveDialog(tempPath, "Save your file"); if (saveFileResult.bSuccess){ bool fileWritten = ofBufferToFile(saveFileResult.filePath, buf); } }
//----------------------------- void ofxLabGui::saveAsSettingsEvent( string & buttonName){ ofFileDialogResult r = ofSystemSaveDialog("Save XML File", "Save XML File"); string testPath = r.getPath(); if(r.bSuccess){ size_t found = testPath.find(".xml"); if (found == string::npos) testPath += ".xml"; saveSettings(testPath); } }
void Vinyl::exportVinyl(string currentLoadedFileName) { ofFileDialogResult result = ofSystemSaveDialog(currentLoadedFileName, "Export image"); ofFile exportingFile(result.filePath); string path = result.filePath; if (exportingFile.getExtension()!=".png"){ path += ".png"; } saveVinylImage(path); }
bool AppSystem::performFileSaveAction(FileAction action, std::string messageName, std::string defaultName) { return doWhilePaused([&]() { auto result = ofSystemSaveDialog(defaultName, messageName); if (!result.bSuccess) { return false; } return action(result); }); }
void PuppetsHandler::exportCurrentPuppet() { ofFileDialogResult saveFileResult = ofSystemSaveDialog(DEFAULT_PUPPET_NAME, "Select location to export puppet:"); if (saveFileResult.bSuccess){ string path = saveFileResult.getPath(); if(selectedPuppet()->isControllable()) { selectedPuppet()->save(path); } else { selectedPuppet()->saveCachedFrames(path); } } }
//----------------------------- void ofxLabGui::saveAsSettingsEvent( string & buttonName){ /* #ifndef WIN32 string test = fileDialog.getStringFromSaveDialog("Save As", NULL); #else string test = fileDialog.getStringFromSaveDialog("XML file (*.xml)\0*.xml\0", NULL); #endif */ ofFileDialogResult r = ofSystemSaveDialog("Save XML File", "Save XML File"); string testPath = r.getPath(); if(r.bSuccess){ size_t found = testPath.find(".xml"); if (found == string::npos) testPath += ".xml"; saveSettings(testPath); } }
void gui::Editor::controlChanged(Control *c) { string n = c->id.c_str(); if(n.find("new ")==0) { string ctrlType = n.substr(4); Control *ctrl = INSTANTIATE(ctrlType); ctrl->x = 100; ctrl->y = 100; Control *con = root->getControlById("root"); if(con!=NULL) { ((Container*)con)->addChild(ctrl); } else { root->addChild(ctrl); } } else if(n=="Save") { root->saveToXml("gui.xml"); } else if(n=="Save As...") { ofFileDialogResult result = ofSystemSaveDialog("default.xml", "Save As..."); if(result.bSuccess) { root->saveToXml(result.filePath); } } else if(n=="Delete") { if(focusedControl != NULL && focusedControl->parent!=NULL) { focusedControl->parent->removeChild(focusedControl); if(focusedControl==rolledOverControl) { rolledOverControl = NULL; } // let the inspector know we're deleting a control in case // its gui is pointing to it. inspector.setControl(NULL); delete focusedControl; focusedControl = NULL; } } else if(n=="Duplicate") { if(focusedControl != NULL && focusedControl->parent!=NULL) { Control *newControl = focusedControl->clone(); newControl->x += 10; newControl->y += 10; newControl->id += "1"; focusedControl->parent->addChild(newControl); focusedControl = newControl; } } }
//---------------------------------------------------------- ---- void ofApp::keyPressed (int key){ key = std::tolower(key); if( key == '\t' && !configView->isVisibleOnScreen()){ osciView->visible = !osciView->visible; if( osciView->visible ) lastMouseMoved = ofGetElapsedTimeMillis(); else lastMouseMoved = 0; } if( key == 'f' || key == OF_KEY_RETURN || key == OF_KEY_F11 ){ // nasty! osciView->fullscreenButton->clickAndNotify(); } if( key == OF_KEY_ESC ){ osciView->fullscreenButton->clickAndNotify(false); } if( key == ' ' ){ osciView->playButton->clickAndNotify(); } if( key == 'r' ){ clearFbos = true; } if( key == 'i' ){ showInfo ^= true; } if( key == 'e' && exporting == 0 ){ ofFileDialogResult res = ofSystemSaveDialog("images", "Create destination folder" ); if( res.bSuccess ){ exportDir = res.filePath; ofDirectory dir(exportDir); dir.create(); if( dir.exists() && !dir.isDirectory() ){ // don't export! } else{ exporting = 1; } } } }
void testApp::exportUIDs( ) { ofFileDialogResult saveResult = ofSystemSaveDialog( "NFC_ids.txt" , "select a filename to export UIDs" ) ; if ( saveResult.bSuccess ) { stringstream ss ; for ( int i = 0 ; i < readCardIds.size() ; i++ ) { ss << "[" << i << "] " << readCardIds[i] << endl ; } ofBuffer exportBuffer( ss.str() ) ; ofBufferToFile( saveResult.getPath() , exportBuffer , false ) ; } else { ofLogError( "User did not complete the dialog box ! Nothing has exported." ) ; } }
void testApp::exportPDF( ) { ofFileDialogResult result = ofSystemSaveDialog("quote", "Save your font layers" ) ; //ofBackground( 0 , 0, 0 ) ; for ( int i = 0 ; i < agents.size() ; i++ ) { string _fileName = result.getPath() +"_"+ ofToString( i ) + ".pdf" ; ofBeginSaveScreenAsPDF( _fileName ) ; ofSetColor( 255 , 255 , 255 , 0 ) ; ofRect( 0 , 0, ofGetWidth() , ofGetHeight() ) ; //ofTranslate( quote.charTranslateOffset.x , quote.charTranslateOffset.y ) ; // int wordIndex = quote.getQuotePathAt( i )->curLine ; // ofTranslate( quote.wordBlocks[ wordIndex ]->translate.x , quote.wordBlocks[ wordIndex ]->translate.y , 0 ) ; //ofSetColor( 0 , 0 , 0 ) ; //ofRect( 0 , 0, ofGetWidth() , ofGetHeight() ) ; agents[i]->draw( false ) ; agents[i]->drawEntirePath( ) ; ofEndSaveScreenAsPDF() ; } string combinedName = result.getPath() +"_combined.pdf" ; ofBeginSaveScreenAsPDF( combinedName ) ; ofSetColor( 255 , 255 , 255 , 0 ) ; ofRect( 0 , 0, ofGetWidth() , ofGetHeight() ) ; //ofTranslate( quote.charTranslateOffset.x , quote.charTranslateOffset.y ) ; for ( int i = 0 ; i < agents.size() ; i++ ) { //string _fileName = result.getPath() +"_"+ ofToString( i ) + ".pdf" ; //ofSetColor( 0 , 0 , 0 ) ; //ofRect( 0 , 0, ofGetWidth() , ofGetHeight() ) ; agents[i]->draw( false ) ; } ofEndSaveScreenAsPDF() ; }
ofFileDialogResult testApp::makeNewProjectViaDialog(){ #ifndef COMMAND_LINE_ONLY ofFileDialogResult res = ofSystemSaveDialog("newProjectName", "choose a folder for a new OF project :)"); if (res.fileName == "" || res.filePath == "") return res; //base.pushDirectory(res.fileName); // somehow an extra things here helps? vector <int> targetsToMake; if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); if( targetsToMake.size() == 0 ){ cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <<endl; ofSystemAlertDialog("Error: makeNewProjectViaDialog - must specifiy a project platform to generate"); } for(int i = 0; i < (int)targetsToMake.size(); i++){ setupForTarget(targetsToMake[i]); project->setup(target); if(project->create(res.filePath)){ vector<string> addonsToggles = panelAddons.getControlNames(); for (int i = 0; i < (int) addonsToggles.size(); i++){ ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); if(toggle){ ofAddon addon; addon.pathToOF = getOFRelPath(res.filePath); addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); printf("adding %s addons \n", addonsToggles[i].c_str()); project->addAddon(addon); } } project->save(true); } } return res; #endif }
void DataSet::save(string filename) { if (!hasData) { ofLogError() << "ofxGraycode::DataSet::save : cannot save, this set doesn't have data yet"; return; } if (filename=="") filename = ofSystemSaveDialog("dataset.sl", "Save ofxGrayCode::DataSet").getPath(); this->filename = filename; int width = this->data.getWidth(); int height = this->data.getHeight(); ofstream save(ofToDataPath(filename).c_str(), ios::binary); if (!save.is_open()) { ofLogError() << "ofxGraycode::DataSet::save failed to open file " << filename; return; } save << this->size() << endl; save << width << "\t" << height << endl; save << payloadWidth << "\t" << payloadHeight << endl; save << this->distanceThreshold << endl; uint32_t contained = 0; contained |= OFXGRAYCODE_DATASET_HAS_DATA; contained |= OFXGRAYCODE_DATASET_HAS_DATAINVERSE; contained |= OFXGRAYCODE_DATASET_HAS_MEAN; contained |= OFXGRAYCODE_DATASET_HAS_DISTANCE; contained |= OFXGRAYCODE_DATASET_HAS_ACTIVE; save.write((char*)&contained, sizeof(contained)); save.write((char*)data.getPixels(), this->size() * sizeof(uint32_t)); save.write((char*)dataInverse.getPixels(), this->getPayloadSize() * sizeof(uint32_t)); save.write((char*)mean.getPixels(), this->size() * sizeof(uint8_t)); save.write((char*)distance.getPixels(), this->size() * sizeof(uint32_t)); save.write((char*)active.getPixels(), this->size() * sizeof(uint8_t)); save.close(); }
bool ofxComposer::saveSnippet() { string snippetName = ""; ofxXmlSettings XML; ofFileDialogResult openFileResult; openFileResult = ofSystemSaveDialog("snippet.xml", "Save your Snippet"); if(openFileResult.bSuccess){ snippetName = openFileResult.getPath(); } bool saveOk = true; bool a; bool b; // Delete and create xml file if (XML.loadFile(snippetName)) { XML.clear(); // a = XML.saveFile(); } else { b = XML.saveFile(snippetName); XML.loadFile(snippetName); } map<int,int> idMap;// = new map<int, int>; int idAux = 1; for(map<int,patch*>::iterator it = patches.begin(); it != patches.end(); it++ ){ if(it->second->bActive) { idMap[it->second->getId()] = idAux; idAux++; } } for(map<int,patch*>::iterator it = patches.begin(); it != patches.end(); it++ ){ saveOk = saveOk && it->second->saveSnippetPatch(snippetName, idMap, XML); } XML.saveFile(snippetName); return saveOk; }
//--------- void ThreadSet::save(string filename) { if (filename == "") { auto result = ofSystemSaveDialog("lines_processed.xml", "Save xml of lines"); if (!result.bSuccess) { ofLogError() << "Didn't select a filename"; return; } else { filename = result.filePath; } } ofLogNotice() << "Saving all lines to " << filename; ofXml xml; xml.addChild("Lines"); xml.setTo("Lines"); for (auto thread : *this) { ofXml innerXml = thread.getXml(); xml.addXml(innerXml); } xml.save(filename); ofLogNotice() << "Saving complete"; }
//---------- void Decoder::savePreviews() { string filename = data.getFilename(); if (filename == "") { filename = ofSystemSaveDialog("DataSet", "Select output path for previews").getPath(); } if (projectorInCamera.isAllocated()) { projectorInCamera.save(filename + "-projectorInCamera.png"); } if (cameraInProjector.isAllocated()) { cameraInProjector.save(filename + "-cameraInProjector.png"); } if (data.getMedian().isAllocated()) { ofImage(data.getMedian()).save(filename + "-median.png"); } if (data.getMedianInverse().isAllocated()) { ofImage(data.getMedianInverse()).save(filename + "-medianInverse.png"); } }
void xmlgui::Editor::controlChanged(Event *e) { string n = e->control->id.c_str(); if(n.find("new ")==0) { string ctrlType = n.substr(4); Control *ctrl = INSTANTIATE(ctrlType); ctrl->x = 100; ctrl->y = 100; Control *con = root->getRoot(); if(con!=NULL) { ((Container*)con)->addChild(ctrl); } else { root->addChild(ctrl); } } else if(n=="Save") { root->getRoot()->saveToXml("gui.xml"); } else if(n=="Save As...") { ofFileDialogResult result = ofSystemSaveDialog("default.xml", "Save As..."); if(result.bSuccess) { root->getRoot()->saveToXml(result.filePath); } } else if(n=="Delete") { deleteFocusedControl(); } else if(n=="Duplicate") { if(focusedControl != NULL && focusedControl->parent!=NULL) { Control *newControl = focusedControl->clone(); newControl->x += 10; newControl->y += 10; newControl->id += "1"; focusedControl->parent->addChild(newControl); focusedControl = newControl; } } }
void testApp::saveData() { ofFileDialogResult f; f = ofSystemSaveDialog("pattern.svg", " "); string filePath = f.getPath(); string svg; svg += "<svg xmlns=\"http://www.w3.org/2000/svg\" "; svg += "width=\"" + ofToString(ofGetWidth()) + "\" "; svg += "height=\"" + ofToString(ofGetHeight()) + "\" "; svg += ">\n"; svg += "<title>" + f.getName() + "</title>\n"; svg += "<rect x =\"0\" y =\"0\" width=\"" + ofToString(ofGetWidth()) + "\" " + "height=\"" + ofToString(ofGetHeight()) + "\" "; svg += "fill=\"#ffffff\" />\n"; for(Circle c : circles) { ofVec3f parentPos = c.pos.getPosition(); svg += "<path d=\"M "; svg += ofToString(parentPos.x + c.tri[0].x) + " "; svg += ofToString(parentPos.y + c.tri[0].y) + " "; svg += "L "; svg += ofToString(parentPos.x + c.tri[1].x) + " "; svg += ofToString(parentPos.y + c.tri[1].y) + " "; svg += "L "; svg += ofToString(parentPos.x + c.tri[2].x) + " "; svg += ofToString(parentPos.y + c.tri[2].y) + " "; svg += " z \" fill=\"#000000\" /> \n"; } svg += "</svg>"; ofFile file(filePath, ofFile::WriteOnly); file.writeFromBuffer(ofBuffer(svg)); file.close(); }
ofFileDialogResult testApp::makeNewProjectViaDialog(){ ofFileDialogResult res = ofSystemSaveDialog("newProjectName", "choose a folder for a new OF project :)"); if (res.fileName == "" || res.filePath == "") return res; //base.pushDirectory(res.fileName); // somehow an extra things here helps? project->setup(target); if(project->create(res.filePath)){ vector<string> addonsToggles = panelAddons.getControlNames(); for (int i = 0; i < (int) addonsToggles.size(); i++){ ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); if(toggle){ ofAddon addon; addon.pathToOF = getOFRelPath(res.filePath); addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); printf("adding %s addons \n", addonsToggles[i].c_str()); project->addAddon(addon); } } project->save(); } return res; }
void testApp::guiEvent(ofxUIEventArgs &e) { string name = e.widget->getName(); int kind = e.widget->getKind(); cout << "got event from: " << name << endl; // if any paramenter needs to be adjusted, // the appropriate gvfhandler method will be called if(name == "amount of particles") { cout << nsNumDialer->getValue() << endl; gvfh.setNumberOfParticles(nsNumDialer->getValue()); } else if(name == "resampling threshold") { gvfh.gvf_rt((int) rtNumDialer->getValue()); } else if(name == "smoothing coefficient") { gvfh.gvf_std(soNumDialer->getValue()); } else if(name == "position" || name == "speed" || name == "scale" || name == "rotation") { std::vector<float> sigs; sigs.push_back(sigPosND->getValue()); sigs.push_back(sigSpeedND->getValue()); sigs.push_back(sigScaleND->getValue()); sigs.push_back(sigRotND->getValue()); gvfh.gvf_adaptspeed(sigs); } // if save or load is requested, // the appropriate dialog is shown and the task is carried out else if(name == "Save gesture(s)") { ofxUILabelButton *button = (ofxUILabelButton*) e.widget; if(button->getValue() && gvfh.getTemplateCount() > 0) { ofFileDialogResult dialogResult = ofSystemSaveDialog("my gestures.xml", "Save gestures"); if(dialogResult.bSuccess) { saveGestures(dialogResult); } } } else if(name == "Load gesture(s)") { ofxUILabelButton *button = (ofxUILabelButton*) e.widget; if(button->getValue()) { ofFileDialogResult dialogResult = ofSystemLoadDialog("Select the xml file containing gesture data"); if(dialogResult.bSuccess) { loadGestures(dialogResult); } } } }
void testApp::guiEvent(ofxUIEventArgs &e) { string name = e.widget->getName(); int kind = e.widget->getKind(); if(kind == OFX_UI_WIDGET_LABELBUTTON) { ofxUILabelButton *button = (ofxUILabelButton *) e.widget; } if (e.widget->getName() == "PAUSE") { ofxUIToggle *toggle = (ofxUIToggle *) e.widget; bPaused = toggle->getValue(); } if (e.widget->getName() == "CLEAR REGIONS") { ofxUILabelButton *button = (ofxUILabelButton *) e.widget; if (button->getValue()) { featureFinder.clearRegions(); } } else if(e.widget->getName() == "BLUR") { ofxUIToggle *toggle = (ofxUIToggle *) e.widget; featureFinder.bBlur = toggle->getValue(); } else if(e.widget->getName() == "STRETCH CONTRAST") { ofxUIToggle *toggle = (ofxUIToggle *) e.widget; featureFinder.bStretchContrast = toggle->getValue(); } else if(e.widget->getName() == "EQUALIZE HISTOGRAM") { ofxUIToggle *toggle = (ofxUIToggle *) e.widget; featureFinder.bEqualizeHistogram = toggle->getValue(); } else if(e.widget->getName() == "BLUR LEVEL") { ofxUISlider *slider = (ofxUISlider *) e.widget; featureFinder.setBlurLevel( slider->getScaledValue() ); } else if(e.widget->getName() == "OCTAVES") { ofxUISlider *slider = (ofxUISlider *) e.widget; featureFinder.octaves = slider->getScaledValue(); } else if(e.widget->getName() == "MIN HESSIAN") { ofxUISlider *slider = (ofxUISlider *) e.widget; featureFinder.hessianThreshold = slider->getScaledValue(); } else if(e.widget->getName() == "MIN MATCHES") { ofxUISlider *slider = (ofxUISlider *) e.widget; featureFinder.minMatchCount = slider->getScaledValue(); } else if(e.widget->getName() == "FULLSCREEN") { ofxUIToggle *toggle = (ofxUIToggle *) e.widget; ofSetFullscreen(toggle->getValue()); } else if (e.widget->getName() == "LOAD IMAGE") { ofxUILabelButton *button = (ofxUILabelButton *) e.widget; if (button->getValue()) { bPaused = true; this->openSampleImage(); } } else if (e.widget->getName() == "SAVE DESCRIPTORS") { ofxUILabelButton *button = (ofxUILabelButton *) e.widget; if (button->getValue()) { ofFileDialogResult res = ofSystemSaveDialog("object.yml", "Save Object Description"); if (res.bSuccess) { featureFinder.createAndSaveObject(res.getPath()); } } } else if (e.widget->getName() == "LOAD DESCRIPTORS") { ofxUILabelButton *button = (ofxUILabelButton *) e.widget; if (button->getValue()) { ofFileDialogResult res = ofSystemLoadDialog("Load Object Description"); if (res.bSuccess) { featureFinder.loadObject(res.getPath()); } } } else if (e.widget->getName() == "DRAW CIRCLES") { ofxUIToggle *toggle = (ofxUIToggle *) e.widget; featureFinder.bDrawCircles = toggle->getValue(); } else if (e.widget->getName() == "DETECT OBJECTS") { ofxUIToggle *toggle = (ofxUIToggle *) e.widget; bDetectObjects = toggle->getValue(); } processRawImage(); }
//-------------------------------------------------------------- void testApp::keyReleased(int key){ //NUEVA AREA TRIANGULAR if(key=='t') { numeros = !numeros; } if(key=='c') mostrar_cam = (mostrar_cam==1)?0:1; if(key=='n'&&nAreas<MAX_AREAS&&!modificar) { nAreas++; creando = true; modificar = false; modificar_area = false; cout<<"Seleccione 3 vertices, Area# "<<nAreas<<endl; } //NUEVO POLIGONO if(key=='p'&&!modificar) { if(!creando_poli&&nAreas<MAX_AREAS) { nAreas++; creando_poli = true; cout<<"Seleccione el numero de vertices que desee y presione la tecla p al terminar."<<endl; areas[nAreas-1].es_poligono = true; areas[nAreas-1].vertices = new ofPoint[MAX_VERTEX]; areas[nAreas-1].v_triang.assign(MAX_VERTEX,ofPoint()); areas[nAreas-1].triangulo.reserve(MAX_VERTEX); } else { creando_poli = false; cout<<"Poligono terminado"<<endl; areas[nAreas-1].calcular_textura(); } } //MOVER if(key=='m') { modificar=(modificar==1)?0:1; if(modificar) modificar_area = false; cout<<"Modificar = "<<modificar<<endl; } //MOVER AREA ORIGINAL if(key=='M') { modificar_area=(modificar_area==1)?0:1; if(modificar_area) modificar = false; cout<<"Modificar Area = "<<modificar_area<<endl; } //BORRAR if(key=='b') { borrar = true; modificar = false; modificar_area = false; cout<<"Borrar = 1"<<endl; } //CARGAR VIDEO if(key=='v') { cout<<"Cargando video"<<endl; ofFileDialogResult cargar_video = ofSystemLoadDialog("Seleccione un video o imagen para mascarear"); if(cargar_video.bSuccess) { videos[nVideos] = video(nVideos,ofPoint(0,(nVideos+1)*HEIGHT),ofPoint(WIDTH,HEIGHT),cargar_video.getPath()); nVideos++; cout<<"Video cargado: "<<cargar_video.getName()<<endl; } } //CARGAR ARCHIVO DE PUNTOS if(key=='l') { cout<<"Cargando Archivo de texto."<<endl; ofFileDialogResult cargar_areas = ofSystemLoadDialog("Seleccione un archivo de texto"); if(cargar_areas.bSuccess) { texto.open(ofToDataPath(cargar_areas.getPath()),ofFile::ReadWrite); char* temp = new char[8]; texto.getline(temp,3); string temp1 = temp; int tempAreas = ofToInt(temp1); if(nAreas+tempAreas<MAX_AREAS) { cout<<"Areas por agregar: "<<tempAreas-nAreas<<endl; for(int i=nAreas;i<nAreas+tempAreas;i++) { cout<<"i ="<<i<<endl; char * vert = new char[3]; texto.getline(vert,3,' '); string temp2 = vert; int vertices = ofToInt(temp2); cout<<"#Vertices = "<<vertices<<" Final del archivo = "<<texto.eof()<<endl; areas[i].es_poligono = true; areas[i].vertices = new ofPoint[vertices]; areas[i].v_triang.assign(vertices,ofPoint()); areas[i].triangulo.reserve(vertices); for(int j=0;j<vertices;j++) { texto.getline(temp,5,' '); string valor = temp; int x = ofToInt(valor); texto.getline(temp,5,' '); valor = temp; int y = ofToInt(valor); areas[i].caprutar_poli(x,y); } areas[i].calcular_textura(); delete vert; } nAreas+=tempAreas; } delete temp; } } if(key=='s') { ofFileDialogResult guardar = ofSystemSaveDialog("Guardar...","Guardar..."); texto.open(ofToDataPath(guardar.getPath()),ofFile::Mode::WriteOnly); if(texto.exists()) cout<<"Archivo creado = "<<texto.create()<<endl; texto<<nAreas<<endl; for(int i=0;i<nAreas;i++) { texto<<areas[i].vCapturados<<" "; for(int j=0;j<areas[i].vCapturados;j++) texto<<areas[i].vertices[j].x<<" "<<areas[i].vertices[j].y<<" "; } texto.close(); } }
//-------------------------------------------------------------- void ofApp::keyPressed(int key){ if (key == ' ') { const ofVec3f cursor = this->camera.getCursorWorld(); const ofVec3f cursorNormalised = (cursor - roomMin) / roomScale; const float epsilon = 0.01f; bool inside = true; inside &= cursorNormalised.x >= 0.0f - epsilon; inside &= cursorNormalised.x <= 1.0f + epsilon; inside &= cursorNormalised.y >= 0.0f - epsilon; inside &= cursorNormalised.y <= 1.0f + epsilon; inside &= cursorNormalised.z >= 0.0f - epsilon; inside &= cursorNormalised.z <= 1.0f + epsilon; if (inside) { switch (this->state) { case Waiting: this->newLine.s = this->cursor; this->state = Adding; break; case Adding: { this->lineSet.add(this->newLine); this->state = Waiting; break; } default: break; } } } if (key == 's') { auto result = ofSystemSaveDialog("lines.xml", "Save lines to binary file"); if (result.bSuccess) { this->lineSet.save(result.getPath()); } } if (key == 'l') { auto result = ofSystemLoadDialog(); if (result.bSuccess) { this->lineSet.load(result.getPath()); } } if (key == 'c') { this->lineSet.clear(); } if (key == OF_KEY_BACKSPACE) { this->lineSet.deleteSelected(); } if (key == OF_KEY_SHIFT) { this->shift = true; } if (key == 'h') { this->shadow ^= true; } if (key == 'g') { this->grid ^= true; } if (key == 'z') { this->lineSet.undo(); } }
void PMFileSelector::selectToSave(){ ofFileDialogResult result = ofSystemSaveDialog("hola.mov", "Select Save File"); text = result.getName(); filePath = result.getPath(); }
void testApp::saveProjectFile( ) { projectXml.clear( ) ; ofFileDialogResult saveResult = ofSystemSaveDialog( "myProject" , "Project Name?" ) ; string path = saveResult.getPath() ; // int index = path.find( ".xml" ) ; if ( index > 0 ) cout << "user added .xml" << endl ; else path += ".xml" ; // projectXml.setValue( "fontPath" , quote.fontPath ) ; // projectXml.setValue( "fontSize" , quote.fontSize ) ; for ( int i = 0 ; i < quote.wordBlocks.size() ; i++ ) { int tagNum = projectXml.addTag( "wordBlock" ) ; WordBlock * wb = quote.wordBlocks[i] ; projectXml.pushTag( "wordBlock" , tagNum ) ; projectXml.setValue( "text" , wb->word ) ; projectXml.setValue( "fontSize" , wb->fontSize ) ; string rawFontPath = wb->fontPath ; cout << "rawPath : " << rawFontPath << endl ; string shortFontPath = rawFontPath.substr ( 3 , rawFontPath.size() - 3 ) ; cout << "shortened fontPath: " << shortFontPath << endl ; projectXml.setValue( "fontPath" , shortFontPath ) ; projectXml.setValue( "translateX" , wb->translate.x ) ; projectXml.setValue( "translateY" , wb->translate.y ) ; //projectXml.setValue( "wordBlock" , quote.wordBlocks[i]->word , i ) ; projectXml.popTag( ) ; } for ( int c = 0 ; c < inspector.colors.size() ; c++ ) { //projectXml.addTag( "color" ) ; //projectXml.pushTag( "color" , c ) ; //int hexColor = colorPool.pool[c].toHex() ; //projectXml.setValue( "color" , hexColor ) ; projectXml.setValue( "r" , colorPool.pool[c].r ) ; projectXml.setValue( "g" , colorPool.pool[c].g ) ; projectXml.setValue( "b" , colorPool.pool[c].b ) ; // projectXml.popTag( ) ; } for ( int f = 0 ; f < inspector.fonts.size() ; f++ ) { projectXml.setValue( "fontPath" , inspector.fonts[f].filePath , f ) ; } projectXml.setValue ( "MAX SPEED" , a_maxSpeed ) ; projectXml.setValue ( "MAX SPEED R OFFSET" , a_rOffsetMaxSpeed ) ; projectXml.setValue ( "MAX FORCE" , a_maxForce ) ; projectXml.setValue ( "MAX FORCE R OFFSET" , a_rOffsetMaxTurn ) ; projectXml.setValue ( "BUFFER DIST" , a_targetBuffer ) ; projectXml.setValue ( "PATH SAMPLING" , a_pathSampling ) ; projectXml.setValue ( "NUM AGENTS" , a_numAgents ) ; projectXml.saveFile( path ) ; }