void SolveSpaceUI::AddToRecentList(const std::string &filename) { RemoveFromRecentList(filename); for(int src = MAX_RECENT - 2; src >= 0; src--) { RecentFile[src+1] = RecentFile[src]; } RecentFile[0] = filename; RefreshRecentMenus(); }
void SolveSpace::AddToRecentList(char *file) { RemoveFromRecentList(file); int src; for(src = MAX_RECENT - 2; src >= 0; src--) { strcpy(RecentFile[src+1], RecentFile[src]); } strcpy(RecentFile[0], file); RefreshRecentMenus(); }
void SolveSpace::MenuFile(int id) { if(id >= RECENT_OPEN && id < (RECENT_OPEN+MAX_RECENT)) { if(!SS.OkayToStartNewFile()) return; char newFile[MAX_PATH]; strcpy(newFile, RecentFile[id-RECENT_OPEN]); RemoveFromRecentList(newFile); if(SS.LoadFromFile(newFile)) { strcpy(SS.saveFile, newFile); AddToRecentList(newFile); } else { strcpy(SS.saveFile, ""); SS.NewFile(); } SS.AfterNewFile(); return; } switch(id) { case GraphicsWindow::MNU_NEW: if(!SS.OkayToStartNewFile()) break; strcpy(SS.saveFile, ""); SS.NewFile(); SS.AfterNewFile(); break; case GraphicsWindow::MNU_OPEN: { if(!SS.OkayToStartNewFile()) break; char newFile[MAX_PATH] = ""; if(GetOpenFile(newFile, SLVS_EXT, SLVS_PATTERN)) { if(SS.LoadFromFile(newFile)) { strcpy(SS.saveFile, newFile); AddToRecentList(newFile); } else { strcpy(SS.saveFile, ""); SS.NewFile(); } SS.AfterNewFile(); } break; } case GraphicsWindow::MNU_SAVE: SS.GetFilenameAndSave(false); break; case GraphicsWindow::MNU_SAVE_AS: SS.GetFilenameAndSave(true); break; case GraphicsWindow::MNU_EXPORT_PNG: { char exportFile[MAX_PATH] = ""; if(!GetSaveFile(exportFile, PNG_EXT, PNG_PATTERN)) break; SS.ExportAsPngTo(exportFile); break; } case GraphicsWindow::MNU_EXPORT_VIEW: { char exportFile[MAX_PATH] = ""; if(!GetSaveFile(exportFile, VEC_EXT, VEC_PATTERN)) break; // If the user is exporting something where it would be // inappropriate to include the constraints, then warn. if(SS.GW.showConstraints && (StringEndsIn(exportFile, ".txt") || fabs(SS.exportOffset) > LENGTH_EPS)) { Message("Constraints are currently shown, and will be exported " "in the toolpath. This is probably not what you want; " "hide them by clicking the link at the top of the " "text window."); } SS.ExportViewOrWireframeTo(exportFile, false); break; } case GraphicsWindow::MNU_EXPORT_WIREFRAME: { char exportFile[MAX_PATH] = ""; if(!GetSaveFile(exportFile, V3D_EXT, V3D_PATTERN)) break; SS.ExportViewOrWireframeTo(exportFile, true); break; } case GraphicsWindow::MNU_EXPORT_SECTION: { char exportFile[MAX_PATH] = ""; if(!GetSaveFile(exportFile, VEC_EXT, VEC_PATTERN)) break; SS.ExportSectionTo(exportFile); break; } case GraphicsWindow::MNU_EXPORT_MESH: { char exportFile[MAX_PATH] = ""; if(!GetSaveFile(exportFile, MESH_EXT, MESH_PATTERN)) break; SS.ExportMeshTo(exportFile); break; } case GraphicsWindow::MNU_EXPORT_SURFACES: { char exportFile[MAX_PATH] = ""; if(!GetSaveFile(exportFile, SRF_EXT, SRF_PATTERN)) break; StepFileWriter sfw; ZERO(&sfw); sfw.ExportSurfacesTo(exportFile); break; } case GraphicsWindow::MNU_EXIT: if(!SS.OkayToStartNewFile()) break; SS.Exit(); break; default: oops(); } SS.UpdateWindowTitle(); }