void skeleton_open_cb( Fl_Widget* w, void* ) { #ifdef HAVE_LIBPNG const char *p = fl_file_chooser( _("Open Skeleton"), "*.{ifs,png}", NULL ); if ( p != NULL ) { string skeleton; try { skeleton = ImageGray::getDescriptionFromPNG(p); } catch ( const int e ) { if ( e == 1 ) { // not a PNG file. Maybe an IFS file skeleton = IS::readStringInFile(p); } } #else const char *p = fl_file_chooser( _("Open Skeleton"), "*.ifs", NULL ); if ( p != NULL ) { string skeleton = IS::readStringInFile(p); #endif if ( !glito->skel.fromXML(skeleton) ) { fl_alert( _("Failed to open \"%s\"."), p ); } else { glito->setSystemType(); glito->state = PREVIEW; glito->needRedraw = true; } } } void skeleton_save_cb( Fl_Widget* w, void* ) { const char *p = fl_file_chooser( _("Save Skeleton"), "*.ifs", "*.ifs" ); if ( p != NULL ) { IS::saveStringToFile( p, glito->skel.toXML() ); } } void export_fractint_cb( Fl_Widget* w, void* ) { const char *p = fl_file_chooser( _("Export Skeleton to Fractint"), "*.ifs", "*.ifs" ); if ( p != NULL ) { const string file(p); IS::saveStringToFile( p, glito->skel.toFractint(file.substr(0,file.find('.'))) ); } glito->needRedraw = true; } #ifdef HAVE_LIBPNG void set_snapshotPath_cb( Fl_Widget* w, void* ) { glito->setSnapshotPath(); } void saveSnapshot_cb( Fl_Widget* w, void* ) { glito->saveSnapshot(); glito->needRedraw = true; }
inline char* moobyFileChooser(const char* message, const char* filespec, const std::string& last = std::string()) { char* toReturn; if (last.size()) toReturn = fl_file_chooser(message, filespec, last.c_str()); else toReturn = fl_file_chooser(message, filespec, NULL); #ifdef __LINUX__ Fl::wait(); #endif return toReturn; }
void load_callback(Fl_Button *button, void *) { if(button == loadSkeleton_button) if (lastSkeleton <= lastMotion) // cannot load new skeleton until motion is assigned to the current skeleton { char * filename = fl_file_chooser("Select filename","*.ASF",""); if(filename != NULL) { // Read skeleton from asf file pSkeleton = new Skeleton(filename, MOCAP_SCALE); lastSkeleton++; // Set the rotations for all bones in their local coordinate system to 0 // Set root position to (0, 0, 0) pSkeleton->setBasePosture(); displayer.LoadSkeleton(pSkeleton); glwindow->redraw(); } } if(button == loadMotion_button) { if ((lastSkeleton >= 0) && (lastSkeleton >= lastMotion)) { char * filename = fl_file_chooser("Select filename","*.AMC",""); if(filename != NULL) { // Read motion (.amc) file and create a motion pMotion = new Motion(filename, MOCAP_SCALE, pSkeleton); // backup the filename strcpy(lastMotionFilename, filename); // set sampled motion for display displayer.LoadMotion(pMotion); if (lastSkeleton > lastMotion) lastMotion++; UpdateMaxFrameNumber(); resetPostureAccordingFrameSlider(); frame_slider->value(currentFrameIndex); frame_slider->maximum((double)maxFrames); frame_slider->redraw(); glwindow->redraw(); Fl::flush(); } } // if (lastSkeleton > lastMotion) } glwindow->redraw(); }
void ClientGUI::mixing_state_load_dialog(void) { char *c_filename = NULL; std::string filter_str="*"+ mixing_ext; // display the file selector c_filename = fl_file_chooser("Output File",filter_str.c_str(),NULL); if (c_filename==NULL) return; std::string filename(c_filename); std::cout << "\n We are going to open filename " << filename; std::cout.flush(); if (client!=NULL) { client->load_mixing_state_from_file(filename); // make sure the mix window reflects the new values mixControlWindow_userRefresh(); // streamChannelWindow_userRefresh(); //mixingRateWindow_userRefresh(); //mixingControlWindow_userRefresh(); } else std::cout << "\n client pointer is NULL, error in mixing_state_load_dialog, start stream?"; std::cout.flush(); }
//--------------------------------- Callback Functions -------------------------------------------- void GraphicalUI::cb_load_scene(Fl_Menu_* o, void* v) { GraphicalUI* pUI=whoami(o); static char* lastFile = 0; char* newfile = fl_file_chooser("Open Scene?", "*.ray", NULL ); if (newfile != NULL) { char buf[256]; if (pUI->raytracer->loadScene(newfile)) { sprintf(buf, "Ray <%s>", newfile); stopTracing(); // terminate the previous rendering } else{ sprintf(buf, "Ray <Not Loaded>"); } pUI->m_mainWindow->label(buf); pUI->m_debuggingWindow->m_debuggingView->setDirty(); if( lastFile != 0 && strcmp(newfile, lastFile) != 0 ) pUI->m_debuggingWindow->m_debuggingView->resetCamera(); pUI->m_debuggingWindow->redraw(); } }
inline void ModelerUserInterface::cb_Open_i(Fl_Menu_*, void*) { char *filename = NULL; filename = fl_file_chooser("Open .pos File", "*.pos", NULL); if (filename) { std::ifstream ifs( filename ); if( !ifs ) { std::cerr << "Error: couldn't read position file " << filename << std::endl; return; } int controlNum; float value; while( ifs >> controlNum >> value ) { if( controlNum >= ModelerApplication::Instance()->GetNumControls() ) { break; } ModelerApplication::Instance()->SetControlValue(controlNum, value); } m_modelerView->redraw(); }; }
//----------------------------------------------------------------------------- void save_dat_cb(Fl_Widget*, void*v) { TableWindow* e = (TableWindow*)v; char *newfile = fl_file_chooser(mgl_gettext("Save Data?"), mgl_gettext("DAT Files (*.{dat,csv})\tAll Files (*)"), 0); if(newfile != NULL) e->var->Save(newfile); }
/************************************ * * Load Input Image * ***********************************/ void FastMarchingLevelSet::LoadInputImage( void ) { const char * filename = fl_file_chooser("Input Image filename","*.*",""); if( !filename ) { return; } this->ShowStatus("Loading input image file..."); try { this->FastMarchingLevelSetBase::LoadInputImage( filename ); } catch( itk::ExceptionObject & excp ) { fl_alert( excp.GetDescription() ); controlsGroup->deactivate(); return; } catch( ... ) { this->ShowStatus("Problems reading file format"); controlsGroup->deactivate(); return; } // Allocate a image of seeds of the same size m_SeedImage->SetRegions( m_ImageReader->GetOutput()->GetBufferedRegion() ); m_SeedImage->Allocate(); m_SeedImage->FillBuffer( itk::NumericTraits<SeedImageType::PixelType>::Zero ); this->ShowStatus("Input Image Loaded"); controlsGroup->activate(); }
void LoadModel(void *v) { char *params = (char*)v; if(!params){ params = (char*)fl_file_chooser("Open File?", "{*.skel}", "../src/skels" ); } if(!params) return; FILE *file = fopen(params, "r"); if(file == NULL){ cout << "Skel file does not exist" << endl; return; } ArticulatedBody *mod = new ArticulatedBody(); UI->mData->mModels.push_back(mod); UI->mData->mSelectedModel = mod; readSkelFile(file, mod); UI->CreateDofSliderWindow(); mod->InitModel(); UI->mGLWindow->mShowModel = true; UI->mShowModel_but->value(1); UI->mGLWindow->refresh(); cout << "number of dofs in model: " << UI->mData->mModels[0]->GetDofCount() << endl; }
//kle file chooser //messae, pattern et fname peuvent tous les trois contenir un caractère null //message=null pas de message //pattern=null alors tous les fichiers //fname=0 alors précédent filename static const char *fn_file_chooser_ex(const char *message, FN_PATTERN *pattern, const char *fname, int save) { #ifdef WIN32 FN_PATTERN all_files[] = {{"All Files","*"},{0,0}}; return win_file_chooser(message,(!pattern)?all_files:pattern,fname,save); #endif #ifdef LINUX const char *ret; //valeur de retour char *pattern_str=fn_pattern_to_fltk(pattern); //pas encore... if(!pattern_str) { fn_alert("Out of memory..."); return 0; } #ifdef USE_FLU if(!save) ret=flu_file_chooser(message,pattern_str,fname); else ret=flu_save_chooser(message,pattern_str,fname); #else ret=fl_file_chooser(message,pattern_str,fname,1 /* po relative*/); #endif free(pattern_str); //retourne ce qu'il doit retourner return ret; #endif }
void LoadC3d(void *v) { if(!UI->mData->mSelectedModel){ cout << "Load skeleton first"; return; } char *params = (char*)v; if(!params){ params = fl_file_chooser("Open File?", "{*.c3d}", "mocap/" ); } if(!params) return; char *c3dFilename = new char[80]; // load single c3d file C3dFileInfo *openFile = new C3dFileInfo(params); openFile->LoadFile(); UI->mData->mSelectedModel->mOpenedC3dFile = openFile; cout << "number of frames in c3d: " << openFile->GetFrameCount() << endl; UI->InitControlPanel(); UI->mGLWindow->mShowConstraints = true; UI->mShowConstr_but->value(1); }
int main(int argc, char **argv) { const char* fileName = NULL; if (argc == 2 && argv[1]) { fileName = argv[1]; } else { fileName = fl_file_chooser("Open file","*.dcm;*.png;*.jog;*.tiff;*.dcm;*.DCM;*.seq;*.pic;*.pic.gz;*.seq.gz;*.pic;*.pic.gz;*.png;*.stl",NULL); } if (!fileName) { exit(0);} UserInterface ui; mitk::SliceNavigationController::Pointer &sliceCtrl = ui.mainWid->sliceCtrl; sliceCtrl = mitk::SliceNavigationController::New("navigation"); ui.mainWid->InitRenderer(); ui.mainWid->GetRenderer()->SetMapperID(1); mitk::DataTree::Pointer tree = mitk::DataTree::New(); mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); factory->SetFileName( fileName ); factory->Update(); if (factory->GetNumberOfOutputs() > 1) { fl_alert("WARNING: More than one image in file. Only showing first one."); } mitk::DataTreePreOrderIterator it(tree); mitk::DataNode::Pointer node = factory->GetOutput( 0 ); assert(node.IsNotNull()); { it.Add( node ); ui.mainWid->SetNode(node); } ui.mainWid->GetRenderer()->SetData(&it); ui.mainWid->RequestUpdate(); mitk::BoundingBox::Pointer bb = mitk::DataTree::ComputeVisibleBoundingBox(&it); mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); geometry->Initialize(); geometry->SetBounds(bb->GetBounds()); //tell the navigator the geometry to be sliced (with geometry a Geometry3D::ConstPointer) sliceCtrl->SetInputWorldGeometry(geometry.GetPointer()); //tell the navigator in which direction it shall slice the data sliceCtrl->SetViewDirection(mitk::SliceNavigationController::Axial); //Connect one or more BaseRenderer to this navigator, i.e.: events sent //by the navigator when stepping through the slices (e.g. by //sliceCtrl->GetSlice()->Next()) will be received by the BaseRenderer //(in this example only slice-changes, see also ConnectGeometryTimeEvent //and ConnectGeometryEvents.) sliceCtrl->ConnectGeometrySliceEvent(ui.mainWid->GetRenderer()); //create a world geometry and send the information to the connected renderer(s) sliceCtrl->Update(); sliceCtrl->GetSlice()->SetPos(3); ui.sliceSlider->bounds(0,sliceCtrl->GetSlice()->GetSteps()-1); ui.sliceSlider->precision(0); ui.mainWid->RequestUpdate(); ui.mainWin->show(argc, argv); return Fl::run(); }
void load_callback(Fl_Widget *w, void *data) { //xfprintf(stderr,"load callback called\n"); policyFile = fl_file_chooser("choose policy value file",NULL,NULL,1); // fprintf(stderr,"file chosen: %s\n",policyFile); if (!policyFile) { policyFile = NULL; return; } DdNode **UPList= (DdNode **)malloc(2*(sizeof(DdNode *))); //load from this file into dd: act[numpolicies] and val[numpolicies] //load a new file into the gui... int numread = readDualOptimal(dd,policyFile,&UPList); if (numread == 0) { fl_message("Whoops! - that file didn't correspond to the problem you are working on"); return; } else if (numpolicies+1 >= MAXNUMPOLICIES) { fl_message("Whoops! - too many policies"); return; } act[numpolicies] = UPList[0]; Cudd_Ref(act[numpolicies]); val[numpolicies] = UPList[1]; Cudd_Ref(val[numpolicies]); free(UPList); // resize window window_width += 150; window->resize(window->x(),window->y(),window_width,window_height); menu_bar->resize(menu_bar->x(),menu_bar->y(),window_width,menubar_height-10); // add a new action_out[numpolicies] and value_out[numpolicies] and ask[numpolicies] field policyName[numpolicies] =new Fl_Text_Display(2*field_width+120+numpolicies*150,menubar_height,150,40); policyNameBuf[numpolicies] =new Fl_Text_Buffer(10); policyNameBuf[numpolicies]->append(policyFile); policyName[numpolicies]->buffer(policyNameBuf[numpolicies]); ask[numpolicies] = new Fl_Button(2*field_width+120+numpolicies*150,menubar_height+40,150,30,"query"); askindex[numpolicies] = numpolicies; ask[numpolicies]->callback(ask_callback, askindex+numpolicies); window->add(ask[numpolicies]); // position of this? action_out[numpolicies] = new Fl_Output(2*field_width+120+numpolicies*150,menubar_height+70,150,40); value_out[numpolicies] = new Fl_Output(2*field_width+120+numpolicies*150,menubar_height+110,150,40); window->add(action_out[numpolicies]); window->add(value_out[numpolicies]); window->add(policyName[numpolicies]); // increment numpolicies numpolicies++; window->redraw(); }
// Load and save files void loadCB(Fl_Widget*, TrainWindow* tw) { const char* fname = fl_file_chooser("Pick a Track File","*.txt","TrackFiles/track.txt"); if (fname) { tw->world.readPoints(fname); tw->damageMe(); } }
void ImpressionistUI::cb_load_dissolve_image(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc = whoami(o)->getDocument(); char* newfile = fl_file_chooser("Open File?", "*.bmp", pDoc->getImageName()); if (newfile != NULL) { pDoc->loadDissolveImage(newfile); } }
static void BrowseColors(Fl_Widget *wdg, void *arg) { ProjectOptionsDlg* dlg = (ProjectOptionsDlg*)arg; Fl_Input *inp = dlg->GetColors(); const char *dir = fl_file_chooser("Colors File", NULL, inp->value()); if (dir) inp->value(dir); }
int load_content(char* filespec_str) { char* selected_filespec_str = NULL; if (filespec_str && *filespec_str) { selected_filespec_str = filespec_str; } else { selected_filespec_str = fl_file_chooser( "Select Flume workspace content file", "Flume Files(*.flume)\tFlume Files(*.ume)\tText files (*.txt)\tAll Files (*)", NULL); } if (!selected_filespec_str) { return 0; } SAY(2, "LOADING FILE '%s'\n", selected_filespec_str); int lines = 0; FILE* f = fopen(selected_filespec_str, "r"); if (f) { char fileline_str[MAXENTRYLEN]; char content_str[(MAXENTRY+1)*MAXENTRYLEN] = ""; while (lines < MAXENTRY && fgets(fileline_str, MAXENTRYLEN, f)){ SAY(0, "File line is %d chars long\n", strlen(fileline_str)); fflush(0); if (strlen(fileline_str) > 1) { SAY(0, "Concatenating '%s'\n", fileline_str); fflush(0); strcat(content_str, fileline_str); if ( strlen(fileline_str) == (MAXENTRYLEN-1) && fileline_str[strlen(fileline_str)-1] != '\n') { strcat(content_str, "\n"); fl_alert("Line in file too long! It will be split.\n"); } lines++; } } if (!feof(f)) { SAY(3, "Row limit reached, extra file content ignored!\n"); } fclose(f); SAY(0, "File closed\n"); fflush(0); strcpy(CurrentFileSpec_str, selected_filespec_str); char* p = content_str + strlen(content_str) - 1; if (*p == '\n') { *p = '\0'; // clip final blank newline } if (WorkArea_p) { WorkArea_p->value(content_str); WorkArea_p->do_callback(); Unsaved = 0; update_main_win_title(); } return 1; } else { return 0; } }
// Called when the user chooses to load a SIFT database. void FeaturesUI::cb_load_image_database_sift(Fl_Menu_ *o, void *v) { FeaturesDoc *doc = who_am_i(o)->doc; char *name = fl_file_chooser("Open File", "*.kdb", NULL); if (name != NULL) { doc->load_image_database(name, true); } }
void GraphicalUI::cb_save_image(Fl_Menu_* o, void* v) { GraphicalUI* pUI=whoami(o); char* savefile = fl_file_chooser("Save Image?", "*.bmp", "save.bmp" ); if (savefile != NULL) { pUI->m_traceGlWindow->saveImage(savefile); } }
// Called when the user chooses the "Load Query Image" menu item. void FeaturesUI::cb_load_query_image(Fl_Menu_ *o, void *v) { FeaturesDoc *doc = who_am_i(o)->doc; char *name = fl_file_chooser("Open File", "{*.p[gp]m,*.jpg}", NULL); if (name != NULL) { doc->load_query_image(name); } }
// Called when the user chooses to load normal query features. void FeaturesUI::cb_load_query_features(Fl_Menu_ *o, void *v) { FeaturesDoc *doc = who_am_i(o)->doc; char *name = fl_file_chooser("Open File", "*.f", NULL); if (name != NULL) { doc->load_query_features(name, false); } }
//------------------------------------------------------------------ // Brings up a file chooser and then saves the painted image // This is called by the UI when the save image menu item is chosen //------------------------------------------------------------------ void ImpressionistUI::cb_save_image(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc=whoami(o)->getDocument(); char* newfile = fl_file_chooser("Save File?", "*.bmp", "save.bmp" ); if (newfile != NULL) { pDoc->saveImage(newfile); } }
//----------------------------------------------------------------------------- void load_dat_cb(Fl_Widget*, void*v) { TableWindow* e = (TableWindow*)v; char *newfile = fl_file_chooser(mgl_gettext("Load Data?"), mgl_gettext("DAT Files (*.{dat,csv})\tAll Files (*)"), 0); HMDT d = dynamic_cast<HMDT>(e->var); if(d && newfile != NULL) { d->Read(newfile); e->refresh(); } }
static void save_as_cb(Fl_Widget*, void*) { const char *p = fl_file_chooser(_("Save details to..."), "Text Files (*.txt)\tAll Files(*)", "dump.txt"); if(!p) return; /* so we can have EOL */ txt_buf->append("\n"); if(txt_buf->savefile(p) != 0) alert(_("Unable to save to %s. Please check permissions to write in this directory or file"), p); }
void save_parameters_cb( Fl_Widget* w, void* ) { const char* p = fl_file_chooser( _("Save Parameters"), "*.xml", paramFile.c_str() ); // bug in fltk ? the second time, paramFile is not shown in the file_chooser if ( p != NULL ) { paramFile = string(p); IS::ToXML() .elementIR( "parameters", glito->parametersToXML(0) ) .save( paramFile ); } }
void CFLTKEditor::Insert() { char pcFilename[512]; Fl_File_Chooser::sort = fl_casenumericsort; char *pcNewFile = fl_file_chooser(m_sFileChooserLoadTitle.c_str(), m_sFileChooserPattern.c_str(), pcFilename); if (pcNewFile != NULL) LoadFile(pcNewFile, GetEditor()->insert_position()); }
void CrashDialog::save(void) { const char* p = fl_file_chooser(_("Save details to..."), "Text Files (*.txt)\tAll Files(*)", "dump.txt"); if(!p) return; // so we can have EOL in file trace_buff->append("\n"); if(trace_buff->savefile(p) != 0) edelib::alert(_("Unable to save to %s. Please check permissions to write in this directory or file"), p); }
//----------------------------------------------------------------------------- void exp_dat_cb(Fl_Widget*, void*v) { TableWindow* e = (TableWindow*)v; const char *scheme, *newfile = fl_file_chooser(mgl_gettext("Export Data?"), mgl_gettext("PNG Files (*.png)\tAll Files (*)"), 0); if(newfile != NULL) { scheme = fl_input(mgl_gettext("Enter color scheme"),MGL_DEF_SCH); if(scheme) e->var->Export(newfile,scheme); } }
// @override bool MaskBrush::init(void) { char* newfile = fl_file_chooser("Load mask image?", "*.bmp", fileName); if (newfile == NULL) { return false; } if ((data = readBMP(newfile, width, height)) == NULL) { fl_alert("Can't load bitmap file"); return false; } return true; }
void ImpressionistUI::cb_load_dissolve(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc = whoami(o)->getDocument(); if (!pDoc->m_ucBitmap) { fl_alert("Please load a background image first."); return; } char* newfile = fl_file_chooser("Open File?", "*.bmp", pDoc->getImageName()); if (newfile != NULL) { pDoc->loadDissolveImage(newfile); } }