bool getFileList(std::string path, std::string mask, bool case_sensitive, std::vector<std::string> & tabfiles, bool rec, bool addFiles, bool addDir) { path = mtools::toUtf8(mtools::trailingSlash(path, true)); dirent** list = nullptr; int nb = fl_filename_list(path.c_str(), &list); if (nb < 0) return false; for (int i = 0; i < nb; i++) { std::string f = mtools::toIso8859(list[i]->d_name); if (( f == std::string("./")) || (f == std::string("../"))) continue; if (!fl_filename_isdir((path + list[i]->d_name).c_str())) { if ((addFiles) && (mtools::matchFileMask(f, mask,case_sensitive))) tabfiles.push_back(f); } else { if (addDir) tabfiles.push_back(f); if (rec) { size_t pos = tabfiles.size(); if (!getFileList(path + list[i]->d_name, mask, case_sensitive, tabfiles, rec, addFiles, addDir)) { fl_filename_free_list(&list, nb); return false; } for (size_t j = pos; j < tabfiles.size(); j++) { tabfiles[j] = f + tabfiles[j]; } } } } fl_filename_free_list(&list, nb); return true; }
void MainMenu::clear_favourites() { static Fl_String favourites; if(favourites.empty()) { favourites = fl_homedir(); favourites += "/.ede/favourites/"; if(!fl_file_exists(favourites)) { mkdir( favourites, 0777 ); } } dirent **files; int pNumFiles = fl_filename_list(favourites, &files); if (pNumFiles > 10) { for (int i=0; i<(pNumFiles-10); i++) { if (strcmp(files[i]->d_name, ".") != 0 && strcmp(files[i]->d_name, "..") != 0 ) { Fl_String filename(favourites); filename += files[i]->d_name; unlink(filename); } } } for(int i = 0; i < pNumFiles; i++) free(files[i]); if(pNumFiles && files) free(files); }
void fillItems() { char *file; Fl_String path(fl_homedir()); path += "/.ede/schemes"; dirent **files; int count = fl_filename_list(path, &files); if (count > 0) { new Fl_Item("Active"); schemeListBox->value("Active"); for(int n=0; n<count; n++) { file = files[n]->d_name; if( strcmp(file, ".") && strcmp(file, "..")) { char *filename = fl_strdup_printf("%s/%s", (char*)path, file); if (!fl_is_dir(filename) && fl_file_match(file, "*.scheme") && strcmp(file, "Active.scheme")!=0) { new Fl_Item(strdup(fl_file_filename(filename))); } delete [] filename; } free(files[n]); } free(files); getSchemeColors(); //we apply first scheme - active.scheme } }
//----------------------------------------------------------------------------- int main(int argc, char** argv) { //---- s_pTbl_Items_Basic = new CN3TableBase<__TABLE_ITEM_BASIC>; std::string szFN = "Item_Org.tbl"; if(s_pTbl_Items_Basic->LoadFromFile(szFN.c_str()) == false) { printf("Failed to load Item_Org.tbl\n"); system("pause"); return -1; } //---- SQLHANDLE hEnv, hConn; SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hEnv); SQLSetEnvAttr(hEnv, SQL_ATTR_ODBC_VERSION, (void *)SQL_OV_ODBC3, 0); SQLAllocHandle(SQL_HANDLE_DBC, hEnv, &hConn); if(SQLConnect(hConn, _T("KN_online"), SQL_NTS, _T("knight"), SQL_NTS, _T("knight"), SQL_NTS) == SQL_ERROR) { printf("SQLConnect\n"); system("pause"); return -1; } SQLHANDLE hStmt; SQLAllocHandle(SQL_HANDLE_STMT, hConn, &hStmt); if(SQLExecDirect(hStmt, _T("SELECT TOP(5000) Num, strName FROM ITEM;"), SQL_NTS) == SQL_ERROR) {//TOP(10000) printf("SQLExecDirect\n"); system("pause"); return -1; } long count = 0; SQLINTEGER cbData; while(SQLFetch(hStmt) == SQL_SUCCESS) { _ITEM_TABLE* item = new _ITEM_TABLE(); SQLGetData(hStmt, 1, SQL_C_ULONG, &(item->m_iNum), sizeof(SQLUINTEGER), &cbData); SQLGetData(hStmt, 2, SQL_C_CHAR, item->m_sName, NAME_LENGTH, &cbData); ItemTableMap.PutData(count++, item); __TABLE_ITEM_BASIC* pItem = s_pTbl_Items_Basic->Find(item->m_iNum/1000*1000); if(!pItem) printf("Item \"%s\" is missing from the TBL!\n", item->m_sName); } SQLFreeHandle(SQL_HANDLE_STMT, hStmt); SQLDisconnect(hConn); SQLFreeHandle(SQL_HANDLE_DBC, hConn); SQLFreeHandle(SQL_HANDLE_ENV, hEnv); //---- dirent** dir_list; int num_files = fl_filename_list("./item", &dir_list); num_disp_files = 0; for(int i=0; i<num_files; ++i) { int len_fn = strlen(dir_list[i]->d_name); if(!strcmp(&dir_list[i]->d_name[len_fn-7], "n3cplug") || !strcmp(&dir_list[i]->d_name[len_fn-7], "n3cpart")) { disp_files = (char**)realloc(disp_files, ++num_disp_files*sizeof(char*)); disp_files[num_disp_files-1] = (char*)calloc(len_fn+1, sizeof(char)); memcpy(disp_files[num_disp_files-1], dir_list[i]->d_name, len_fn); //char* filename = disp_files[num_disp_files-1]; //N3MeshConverter::Convert(filename); } } fl_filename_free_list(&dir_list, num_files); //---- Fl::use_high_res_GL(true); Fl_Window window(1024, 720, "KO Item Editor"); GLItemViewer sw(window.w()-_gl_width, 30, _gl_width, _gl_height); m_sw = &sw; ItemTableView demo_table(0, 30, window.w()-(_gl_width+0), _gl_height); demo_table.selection_color(FL_YELLOW); demo_table.when(FL_WHEN_RELEASE|FL_WHEN_CHANGED); demo_table.table_box(FL_NO_BOX); demo_table.col_resize_min(4); demo_table.row_resize_min(4); demo_table.row_header(true); demo_table.row_header_width(60); demo_table.row_resize(true); demo_table.rows(num_disp_files /*ItemTableMap.GetSize()*/); demo_table.row_height_all(20); demo_table.col_header(true); demo_table.col_header_height(25); demo_table.col_resize(true); demo_table.cols(1 /*2*/); demo_table.col_width_all(150); Fl_Menu_Bar menubar(0, 0, window.w(), 30); menubar.menu(menu_table); menubar.callback(test_cb); // TODO: need to add the positions and widths/heights as variables Fl_Tabs info_tabs(0, _gl_height+40, window.w(), window.h()-_gl_height-30-10); Fl_Group group(0, _gl_height+40+35, window.w(), window.h()-_gl_height-30-10, "Table Info"); tbl_id = new Fl_Int_Input(80, _gl_height+30+35+20+5, 240, 30, "ID:"); tbl_ext_index = new Fl_Int_Input(80, _gl_height+30+35+20+40+5, 240, 30, "Ext Index:"); tbl_name = new Fl_Input (80, _gl_height+30+35+20+80+5, 240, 30, "Name:"); tbl_remark = new Fl_Input (80, _gl_height+30+35+20+120+5, 240, 30, "Remark:"); group.end(); Fl_Group group2(0, _gl_height+40+35, window.w(), window.h()-_gl_height-30-10, "Database Info"); Fl_Input input2(10, _gl_height+30+35+20, 240, 30); group2.end(); info_tabs.end(); window.end(); window.show(argc, argv); sw.show(); sw.redraw_overlay(); return Fl::run(); }
void PluginManager::registerDefaultPlugins() { if(CTX::instance()->solver.plugins){ // nothing here yet } if(CTX::instance()->post.plugins){ allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("StreamLines", GMSH_RegisterStreamLinesPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Particles", GMSH_RegisterParticlesPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutGrid", GMSH_RegisterCutGridPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Isosurface", GMSH_RegisterIsosurfacePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutPlane", GMSH_RegisterCutPlanePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutSphere", GMSH_RegisterCutSpherePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutBox", GMSH_RegisterCutBoxPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Skin", GMSH_RegisterSkinPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("MathEval", GMSH_RegisterMathEvalPlugin())); # if 1 // experimental (Amaury) allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("AnalyseCurvedMesh", GMSH_RegisterAnalyseCurvedMeshPlugin())); #endif allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CurvedBndDist", GMSH_RegisterCurvedBndDistPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("ModifyComponent", GMSH_RegisterModifyComponentPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("ExtractElements", GMSH_RegisterExtractElementsPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutParametric", GMSH_RegisterCutParametricPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("MakeSimplex", GMSH_RegisterMakeSimplexPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Smooth", GMSH_RegisterSmoothPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Transform", GMSH_RegisterTransformPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("LongitudeLatitude",GMSH_RegisterLongituteLatitudePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Warp", GMSH_RegisterWarpPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("SphericalRaise", GMSH_RegisterSphericalRaisePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("HarmonicToTime", GMSH_RegisterHarmonicToTimePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("ModulusPhase", GMSH_RegisterModulusPhasePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Integrate", GMSH_RegisterIntegratePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("MinMax", GMSH_RegisterMinMaxPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Gradient", GMSH_RegisterGradientPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Curl", GMSH_RegisterCurlPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Divergence", GMSH_RegisterDivergencePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Annotate", GMSH_RegisterAnnotatePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Remove", GMSH_RegisterRemovePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Eigenvectors", GMSH_RegisterEigenvectorsPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Eigenvalues", GMSH_RegisterEigenvaluesPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Lambda2", GMSH_RegisterLambda2Plugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Probe", GMSH_RegisterProbePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Triangulate", GMSH_RegisterTriangulatePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("ExtractEdges", GMSH_RegisterExtractEdgesPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("FieldFromAmplitudePhase", GMSH_RegisterFieldFromAmplitudePhasePlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("NearToFarField", GMSH_RegisterNearToFarFieldPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Bubbles", GMSH_RegisterBubblesPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("DiscretizationError", GMSH_RegisterDiscretizationErrorPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Scal2Tens", GMSH_RegisterScal2TensPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Scal2Vec", GMSH_RegisterScal2VecPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("NewView", GMSH_RegisterNewViewPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("SimplePartition", GMSH_RegisterSimplePartitionPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Crack", GMSH_RegisterCrackPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("FaultZone", GMSH_RegisterFaultZonePlugin())); #if defined(HAVE_TETGEN) allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Tetrahedralize", GMSH_RegisterTetrahedralizePlugin())); #endif #if defined(HAVE_KBIPACK) allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Homology", GMSH_RegisterHomologyComputationPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("HomologyPost", GMSH_RegisterHomologyPostProcessingPlugin())); #endif #if defined(HAVE_SOLVER) allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("Distance", GMSH_RegisterDistancePlugin())); #endif #if defined(HAVE_ANN) allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("NearestNeighbor", GMSH_RegisterNearestNeighborPlugin())); #endif #if defined(HAVE_DINTEGRATION) allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("CutMesh", GMSH_RegisterCutMeshPlugin())); #endif } #if defined(HAVE_FLTK) char *pluginsHome = getenv("GMSHPLUGINSHOME"); if(!pluginsHome) return; struct dirent **list; int nbFiles = fl_filename_list(pluginsHome, &list); if(nbFiles <= 0) return; for(int i = 0; i < nbFiles; i++) { std::string ext = SplitFileName(list[i]->d_name)[2]; if(ext == ".so" || ext == ".dll") addPlugin(list[i]->d_name); } for(int i = 0; i < nbFiles; i++) free(list[i]); free(list); #endif }