// generated by Fast Light User Interface Designer (fluid) version 2.0100 #include "GeoMeshViewUI.h" #include "resource.h" #include "GeoLodTreeConstructor.h" using namespace Geometry; using namespace std; //--------------------------------------------------------------------------- // Menu File Open Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuFileOpen_i(fltk::Item*, void*) { // Sets menus application state to NONE. mApplicationState = NONE; // Loads a mesh file. openMeshFile(); // Deactive Lod strip visualization. geoMeshView->deactiveLodStrip(); // Deactive Lod tree visualization. geoMeshView->deactiveLodTree(); geoMeshView->resetTextures(); BuildLoadTextureSubMeshMenu(); // Repaint the window. mMainWindow->redraw(); } inline void GeoMeshViewUI::cb_menuFileLoadTexture_i(fltk::Item*, void*) { static char pattern[] = "*.{jpg|tga|png|bmp}"; fltk::FileChooser *fcho = new fltk::FileChooser("",pattern,fltk::FileChooser::CREATE,"Open image file"); fcho->exec(); char filename[256]=""; if (fcho->value()) { strcpy(filename,fcho->value()); geoMeshView->LoadTexture(filename); } } void GeoMeshViewUI::cb_menuFileLoadTexture(fltk::Item *o, void *v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->parent()->user_data())) -> cb_menuFileLoadTexture_i(o,v); } inline void GeoMeshViewUI::cb_menuFileLoadTextureSubMesh_i(fltk::Item *item, void *) { static char pattern[] = "*.{jpg|tga|png|bmp}"; const char * label = item->label(); int isubmesh = label[strlen(label)-1]-48; fltk::FileChooser *fcho = new fltk::FileChooser("",pattern,fltk::FileChooser::CREATE,"Open image file"); fcho->exec(); char filename[256]=""; if (fcho->value()) { strcpy(filename,fcho->value()); geoMeshView->LoadTextureSubMesh(isubmesh,filename); } } void GeoMeshViewUI::cb_menuFileLoadTextureSubMesh(fltk::Item *o, void *v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->parent()->user_data())) -> cb_menuFileLoadTextureSubMesh_i(o,v); } //--------------------------------------------------------------------------- // Repaint the FPS label. //--------------------------------------------------------------------------- void GeoMeshViewUI::refreshFPS(int fps) { static char char_value[10]; // Translate the FPS count to a char value. sprintf(char_value,"FPS %d",fps); mFPS->label(char_value); // Repaint the window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuFileOpen(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuFileOpen_i(o,v); } //--------------------------------------------------------------------------- // Save callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuFileSave_i(fltk::Item*, void*) { GeoMeshSaver *mesh_saver; // If there is a mesh object created. if (mGeoMesh != NULL) { // Create a mesh saver with mesh bounds. mesh_saver = new GeoMeshSaver(); // Save the file mesh. mesh_saver->save(mGeoMesh, mFileName); // Free memory. delete mesh_saver; } } void GeoMeshViewUI::cb_menuFileSave(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuFileSave_i(o,v); } //--------------------------------------------------------------------------- // Save As Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuFileSaveAs_i(fltk::Item*, void*) { fltk::FileChooser *fcho; GeoMeshSaver *mesh_saver; char file_name[255]; char message[255]; char *ptr; int answer_yes; // Initialize answer to yes. answer_yes = 1; if (mGeoMesh != NULL) { fcho = new fltk::FileChooser("", "*.mesh", fltk::FileChooser::CREATE, "Save Mesh as"); fcho->exec(); if (fcho->value()) { // Gets file name. strcpy(file_name,fcho->value()); // Cut extension. ptr = strtok(file_name,"."); // If has extension. if (ptr) { strcpy(file_name,ptr); } // Adds mesh extension. strcat(file_name,".mesh"); // If File Exists. if (fileExists(file_name)) { // Compose message. strcpy(message,"Do you want to replace "); strcat(message,filename_name(file_name)); strcat(message,"?"); // Question. answer_yes = fltk::ask(message); } // If answer yes to replace question. // or if file not exists. if (answer_yes) { mesh_saver = new GeoMeshSaver(); mesh_saver->save(mGeoMesh,filename_name(file_name)); delete mesh_saver; } } // Repaint the window. mMainWindow->redraw(); delete fcho; } } void GeoMeshViewUI::cb_menuFileSaveAs(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuFileSaveAs_i(o,v); } //--------------------------------------------------------------------------- // Mesh info callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuMeshInfo_i(fltk::Item*, void*) { // Show title. mProcessTitle->label("Mesh Info"); showMeshInfo(); mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuMeshInfo(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuMeshInfo_i(o,v); } //--------------------------------------------------------------------------- // Mesh Export to OBJ callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuMeshExportOBJ_i(fltk::Item*, void*) { char *p; // Sets menus application state to NONE. mApplicationState = NONE; // Open file chooser dialog. p = fltk::file_chooser("Export to OBJ","*.obj",""); if (p && mGeoMesh) { mGeoMesh->exportToOBJ(p); } } void GeoMeshViewUI::cb_menuMeshExportOBJ(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuMeshExportOBJ_i(o,v); } //--------------------------------------------------------------------------- // Transform to Shared Vertex callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuTransformSharedVertex_i(fltk::Item*, void*) { Mesh *mesh_aux; // if the undo mesh is not initialized. if (mGeoMesh != NULL) { // Deletes the actual mesh. delete mUndoMesh; mUndoMesh = new Mesh(); // Restore the previous mesh. *mUndoMesh = *mGeoMesh; // Transform NoSV Mesh to a SV Mesh. mesh_aux = mGeoMesh->toSharedVertex(); // Deletes the mesh No Shared Vertex. delete mGeoMesh; // Gets the mesh Shared Vertex. mGeoMesh = mesh_aux; // Visualize the mesh stripified. geoMeshView->setMesh(mGeoMesh); // Refresh mesh information. showMeshInfo(); // Repaint the window. mMainWindow->redraw(); } } void GeoMeshViewUI::cb_menuFileTransformSharedVertex(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuTransformSharedVertex_i(o,v); } //--------------------------------------------------------------------------- // Quit Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuFileQuit_i(fltk::Item*, void*) { delete this; } void GeoMeshViewUI::cb_menuFileQuit(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuFileQuit_i(o,v); } //--------------------------------------------------------------------------- // Undo Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuEditUndo_i(fltk::Item*, void*) { // Undo the mesh changes. undo(); } void GeoMeshViewUI::cb_menuEditUndo(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuEditUndo_i(o,v); } //--------------------------------------------------------------------------- // Fit Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuEditFit_i(fltk::Item*, void*) { geoMeshView->fit(); mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuEditFit(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuEditFit_i(o,v); } //--------------------------------------------------------------------------- // Rotate Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuEditRotate_i(fltk::Item *item, void*) { // If the item is activated. if (item->value()) { menuEditPan->clear_value(); geoMeshView->deactivePan(); geoMeshView->activeRotate(); } else { menuEditPan->set_value(); geoMeshView->activePan(); geoMeshView->deactiveRotate(); } // Repaint the main window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuEditRotate(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuEditRotate_i(o,v); } //--------------------------------------------------------------------------- // Pan Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuEditPan_i(fltk::Item *item, void*) { // If the item is activated. if (item->value()) { geoMeshView->activePan(); menuEditRotate->clear_value(); geoMeshView->deactiveRotate(); } else { geoMeshView->deactivePan(); menuEditRotate->set_value(); geoMeshView->activeRotate(); } // Repaint the main window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuEditPan(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuEditPan_i(o,v); } //--------------------------------------------------------------------------- // Zoom Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuEditZoom_i(fltk::Item*, void*) { } void GeoMeshViewUI::cb_menuEditZoom(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuEditZoom_i(o,v); } //--------------------------------------------------------------------------- // Wire Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuRenderWire_i(fltk::Item *item, void*) { if (item->value()) { geoMeshView->activeWire(); } else { geoMeshView->deactiveWire(); } // Repaint the canvas. //geoMeshView->redraw(); // Repaint the main window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuRenderWire(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuRenderWire_i(o,v); } //--------------------------------------------------------------------------- // Solid Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuRenderSolid_i(fltk::Item *item, void*) { if (item->value()) { geoMeshView->activeSolid(); } else { geoMeshView->deactiveSolid(); } // Repaint the canvas. //geoMeshView->redraw(); // Repaint the main window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuRenderSolid(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuRenderSolid_i(o,v); } //--------------------------------------------------------------------------- // CW callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuRenderCW_i(fltk::Item *item, void*) { // Clear the CCW state. menuRenderCCW->clear_value(); geoMeshView->deactiveCCW(); // If the item is activated. if (item->value()) { geoMeshView->activeCW(); } else { geoMeshView->deactiveCW(); } // Repaint the main window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuRenderCW(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuRenderCW_i(o,v); } //--------------------------------------------------------------------------- // CCW callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuRenderCCW_i(fltk::Item *item, void*) { // Clear the CW state. menuRenderCW->clear_value(); geoMeshView->deactiveCW(); // If the item is activated. if (item->value()) { geoMeshView->activeCCW(); } else { geoMeshView->deactiveCCW(); } // Repaint the main window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuRenderCCW(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuRenderCCW_i(o,v); } //--------------------------------------------------------------------------- // Flat callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuRenderFlat_i(fltk::Item*, void*) { // Deactive smooth flag. menuRenderSmooth->clear_value(); // Sets flat lighting. geoMeshView->flat(); // Repaint the main window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuRenderFlat(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuRenderFlat_i(o,v); } //--------------------------------------------------------------------------- // Smooth Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuRenderSmooth_i(fltk::Item*, void*) { // Deactive flat flag. menuRenderFlat->clear_value(); // Sets smooth lighting. geoMeshView->smooth(); // Repaint the main window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuRenderSmooth(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuRenderSmooth_i(o,v); } //--------------------------------------------------------------------------- // Textures callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuRenderTextures_i(fltk::Item*, void*) { // Repaint the main window. mMainWindow->redraw(); if (geoMeshView->isTextureMappingEnabled()) geoMeshView->disableTextureMapping(); else geoMeshView->enableTextureMapping(); } void GeoMeshViewUI::cb_menuRenderTextures(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuRenderTextures_i(o,v); } //--------------------------------------------------------------------------- // Stripify Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuStripify_i(fltk::Item*, void*) { // Show title. mProcessTitle->label("Stripify"); mProcessBar->position(0); // Hide the right panel. hideRightPanel(); // Show the stripify panel. showStripify(); // Sets menus application state to STRIPIFY. mApplicationState = STRIPIFY; // Repaint the window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuStripify(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) -> cb_menuStripify_i(o,v); } //--------------------------------------------------------------------------- // Simplify Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuSimplify_i(fltk::ItemGroup*, void*) { } void GeoMeshViewUI::cb_menuSimplify(fltk::ItemGroup* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) -> cb_menuSimplify_i(o,v); } //--------------------------------------------------------------------------- // Edge collapse Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuSimplifyEdgeCollapse_i(fltk::Item*, void*) { // Show title. mProcessTitle->label("Mesh Simplification"); mProcessBar->position(0); // Hide the right panel. hideRightPanel(); // Show the edge collapse panel. showEdgeCollapse(); // Sets menus application state to EDGE_COLLAPSE. mApplicationState = EDGE_COLLAPSE; // Repaint the window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuSimplifyEdgeCollapse(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuSimplifyEdgeCollapse_i(o,v); } //--------------------------------------------------------------------------- // Leaves collapse Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuSimplifyLeavesCollapse_i(fltk::Item*, void*) { // Show title. mProcessTitle->label("Leaves Simplification"); mProcessBar->position(0); // Hide the right panel. hideRightPanel(); // Show the leaves collapse panel. showLeavesCollapse(); // Sets menus application state to LEAVES_COLLAPSE. mApplicationState = LEAVES_COLLAPSE; // Repaint the window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuSimplifyLeavesCollapse(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuSimplifyLeavesCollapse_i(o,v); } //--------------------------------------------------------------------------- // Tree select leaves simplification Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuSelectLeaves_i(fltk::Item*, void*) { // Show title. mProcessTitle->label("Select Leaves"); showMeshInfo(); mButtonProcess->show(); mButtonProcess->activate(); mApplicationState = SELECT_LEAVES; } void GeoMeshViewUI::cb_menuSelectLeaves(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuSelectLeaves_i(o,v); } //--------------------------------------------------------------------------- // Auto Generate LodStrips Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuLodStripsGenerate_i(fltk::Item*, void*) { // Show title. mProcessTitle->label("Generate LodStrips"); mProcessBar->position(0); mBuildBar->position(0); // Hide the right panel. hideRightPanel(); // Show the LodStrips panel. showAutoGenerateLodStrips(); // Sets menus application state to LODSTRIPS_AUTO. mApplicationState = LODSTRIPS_AUTO; // Repaint the window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuLodStripsGenerate(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuLodStripsGenerate_i(o,v); } //--------------------------------------------------------------------------- // Auto Generate LodStrips Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuLodTreesGenerate_i(fltk::Item*, void*) { // Show title. mProcessTitle->label("Generate LodTree"); mProcessBar->position(0); mBuildBar->position(0); // Hide the right panel. hideRightPanel(); // Show the LodStrips panel. showAutoGenerateLodTrees(); // Sets menus application state to LODSTRIPS_AUTO. mApplicationState = LODTREES_AUTO; // Repaint the window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuLodTreesGenerate(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuLodTreesGenerate_i(o,v); } //--------------------------------------------------------------------------- // Visualize LodStrips Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuLodStripsVisualize_i(fltk::Item*, void*) { fltk::FileChooser *fcho; const char *lod_file; // Sets menus application state to NONE. mApplicationState = NONE; // Deactive Lod strip visualization. geoMeshView->deactiveLodStrip(); geoMeshView->deactiveLodTree(); // Loads a mesh file. openMeshFile(); // If an object is loaded. if (mGeoMesh != NULL) { fcho = new fltk::FileChooser("", "*.lod", fltk::FileChooser::CREATE, "Open Lod file"); fcho->exec(); // If a file was selected. if (fcho->value()) { // Build lod strips library. setLodStripsLibrary(string(fcho->value()), mGeoMesh); // Sets the aplication mode. mApplicationState = VISUALIZE_LODSTRIPS; } // Free memory. delete fcho; // Hide the right panel. hideRightPanel(); // Show title. mProcessTitle->label("Visualize LodStrips"); // Show the Visulize LodStrips panel. showLodStripSlider(); // Repaint the window. mMainWindow->redraw(); } } inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) { fltk::FileChooser *fcho; const char *lod_file; // Sets menus application state to NONE. mApplicationState = NONE; // Deactive Lod strip visualization. geoMeshView->deactiveLodTree(); geoMeshView->deactiveLodStrip(); // Loads a mesh file. openMeshFile(); /*if (geoMeshView->getLeavesSubmesh()==-1) { fltk::alert("No se ha seleccionado el submesh de hojas!"); return; }*/ // If an object is loaded. if (mGeoMesh != NULL) { // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS int leafsSubMeshID = -1; for (int i=0; imSubMeshCount; i++) { if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) { leafsSubMeshID=i; break; } } // If an object is loaded. if (mGeoMesh != NULL) { fcho = new fltk::FileChooser("", "*.lod", fltk::FileChooser::CREATE, "Open Lod file"); fcho->exec(); // If a file was selected. if (fcho->value()) { // Build lod strips library. std::string lodstripFile(fcho->value()); delete fcho; fcho = new fltk::FileChooser("", "*.leafseq", fltk::FileChooser::CREATE, "Open LeafSeq file"); fcho->exec(); if (fcho->value()) { std::string leafseqFile(fcho->value()); setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); // Sets the aplication mode. mApplicationState = VISUALIZE_LODTREES; } } // Free memory. delete fcho; // Hide the right panel. hideRightPanel(); // Show title. mProcessTitle->label("Visualize LodTrees"); // Show the Visulize LodTree panel. showLodStripSlider(); showLodTreeSlider(); // Repaint the window. mMainWindow->redraw(); } } } void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuLodTreesVisualize_i(o,v); } void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuLodStripsVisualize_i(o,v); } //--------------------------------------------------------------------------- // Open LodStrip trunk Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) { } void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuLodTreesOpenLodStripTrunk_i(o,v); } //--------------------------------------------------------------------------- // Open leaves simplification Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) { // Hide the right panel. hideRightPanel(); // Show the LodTrees panel. showOpenLeavesSimplification(); // Sets menus application state to LODTREES. mApplicationState = LODTREES; // Repaint the window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuLodTreesOpenLeavesSimplification_i(o,v); } //--------------------------------------------------------------------------- // About Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_menuHelpAbout_i(fltk::Item*, void*) { new GTAboutDialog(); } void GeoMeshViewUI::cb_menuHelpAbout(fltk::Item* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_menuHelpAbout_i(o,v); } //--------------------------------------------------------------------------- // Button Process Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_mButtonProcess_i(fltk::Button*, void*) { bool error; Mesh *mesh_aux; // Sets the progress bar to process bar. progressBarType = PROCESS; mProcessBar->position(0); // Initialize error flag. error = false; // If there is a mesh object. if (mGeoMesh != NULL) { // Choose between aplication state. switch(mApplicationState) { // Stripify state. case STRIPIFY: // Stripify the mesh object. stripify(); break; // Simplify edge collapse state. case EDGE_COLLAPSE: // Check submeshes for triangles strips. for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) { // If current submesh is in triangle strips. if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) { error = true; } } // if the mesh is stripified. if (error) { fltk::alert("Can't simplify a mesh in triagle strips."); } else { // Simplify the mesh object. if(simplifyEdgeCollapse()) { delete mMeshSimplifier; geoMeshView->restoreContext(); } } break; // Simplify leaves case LEAVES_COLLAPSE: // Simplify the mesh object. simplifyLeavesCollapse(); // Create the leaves simplification sequence. createLeavesSequence("leavesSimplification.txt"); break; // Simplify and generate simplification sequence. case LODTREES_AUTO: if (idMeshLeaves==(unsigned short)-1) { fltk::alert("Leaves submesh not selected!"); } else { std::cout << "Simplificando hojas..."; simplifyLeavesCollapse(); std::cout << "OK!" << std::endl; // std::cout << "Creando secuencia de simplificacion de hojas..."; // createLeavesSequence("leavesSimplification.txt"); // std::cout << "OK!" << std::endl; undo(); std::cout << "Simplificando tronco..."; std::cout << "OK!" << std::endl; // Transform NoSV Mesh to a SV Mesh. mesh_aux = mGeoMesh->toSharedVertex(); // Deletes the mesh No Shared Vertex. delete mGeoMesh; // Gets the mesh Shared Vertex. mGeoMesh = mesh_aux; geoMeshView->setMesh(mGeoMesh); // Simplify the mesh object. if (simplifyEdgeCollapse()) { // Create the simplification sequence. createSimplificationSequence(); // Show build process. activeBuildProcess(); } } break; case LODSTRIPS_AUTO: // Check submeshes for triangles strips. for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) { // If current submesh is in triangle strips. if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) { error = true; } } // if the mesh is stripified. if (error) { fltk::alert("Can't simplify a mesh in triagle strips."); } else { // Transform NoSV Mesh to a SV Mesh. mesh_aux = mGeoMesh->toSharedVertex(); // Deletes the mesh No Shared Vertex. delete mGeoMesh; // Gets the mesh Shared Vertex. mGeoMesh = mesh_aux; // Visualize mesh. geoMeshView->setMesh(mGeoMesh); // Simplify the mesh object. if (simplifyEdgeCollapse()) { // Create the simplification sequence. createSimplificationSequence(); delete mMeshSimplifier; geoMeshView->restoreContext(); // Show build process. activeBuildProcess(); } } break; // Añadido 23-12-2005 case SELECT_LEAVES: idMeshLeaves = paintMesh(); // Set the leaves submesh. geoMeshView->setLeavesSubMesh(idMeshLeaves); // Refresh mesh info. showMeshInfo(); break; } // Refresh geometry attributes. refreshApplicationBar(); } // Repaint the GL Window. mMainWindow->redraw(); } void GeoMeshViewUI::cb_mButtonProcess(fltk::Button* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_mButtonProcess_i(o,v); } //--------------------------------------------------------------------------- // Button Sort Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_mButtonSort_i(fltk::Button*, void*) { } void GeoMeshViewUI::cb_mButtonSort(fltk::Button* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_mButtonSort_i(o,v); } //--------------------------------------------------------------------------- // Button Build Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_mButtonBuild_i(fltk::Button*, void*) { char *file_name = NULL; GeoMeshSaver *mesh_saver; Serializer *oSerializer; // Sets the progress bar to process bar. progressBarType = BUILD; // Reset the build bar. mBuildBar->position(0); // If there is a mesh object. if (mGeoMesh != NULL) { // Choose between aplication state. switch(mApplicationState) { // Build the LOD file. case LODTREES_AUTO: // Open file chooser dialog. file_name = fltk::file_chooser("Build LOD","*",""); if (!file_name) break; std::cout << "Creando secuencia de simplificacion de hojas..."; createLeavesSequence(file_name+std::string(".leafseq")); std::cout << "OK!" << std::endl; /* TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); if (auxTreeSimpSequence && mGeoMesh) { LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); delete auxLodTreeConstructor; } else { fltk::alert("There is no leaf simplification sequence."); break; } delete auxTreeSimpSequence;*/ case LODSTRIPS_AUTO: // Builder if (!file_name) file_name = fltk::file_chooser("Build LOD","*",""); // If a file was selected. if (file_name) { // Undo the simplification changes. undo(); // Stripify the mesh object. stripify(); // Reset the build bar. mBuildBar->position(0); // Simplification sequence. oMeshSimpSequence = new MeshSimplificationSequence(); // Loads a simplification sequence file. oMeshSimpSequence->Load(Serializer("SimplifSequence.txt",Serializer::READ)); // If the simplification sequence and the mesh exist. if (oMeshSimpSequence && mGeoMesh) { oLodStrip = new LodStripsConstructor( mGeoMesh, oMeshSimpSequence, idMeshLeaves, progress_function); oSerializer = new Serializer(strcat(file_name,".lod"),Serializer::Mode::WRITE); oLodStrip->Save(*oSerializer); // Close file. delete oSerializer; // Deletes the previous mesh. delete mUndoMesh; mUndoMesh = new Mesh(); // Sets the undo mesh. *mUndoMesh = *mGeoMesh; delete mGeoMesh; mGeoMesh = oLodStrip->GetMesh(); geoMeshView->setMesh(mGeoMesh); mesh_saver = new GeoMeshSaver(); file_name[strlen(file_name) - 4] = '\0'; mesh_saver->save(mGeoMesh, strcat(file_name,".mesh")); delete mesh_saver; } else { // Error message. fltk::alert("There is no simplification sequence."); } // Deletes the siplification sequence object. delete oMeshSimpSequence; } break; } // Refresh data aplication. refreshApplicationBar(); } } void GeoMeshViewUI::cb_mButtonBuild(fltk::Button *o, void *v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_mButtonBuild_i(o,v); } //--------------------------------------------------------------------------- // Lod Slider Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_mLodStripSlider_i(fltk::Slider *o, void *) { // Change the lod. geoMeshView->GoToLod_LodStrip((unsigned int)o->value()); // Refresh data aplication. refreshApplicationBar(); mMainWindow->flush(); } void GeoMeshViewUI::cb_mLodStripSlider(fltk::Slider *o, void *v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_mLodStripSlider_i(o,v); } //--------------------------------------------------------------------------- // Lod Slider Callback for the foliage //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_mLodTreeSlider_i(fltk::Slider *o, void *) { // Change the lod. geoMeshView->GoToLod_LodTree((unsigned int)o->value()); // Refresh data aplication. refreshApplicationBar(); mMainWindow->flush(); } void GeoMeshViewUI::cb_mLodTreeSlider(fltk::Slider *o, void *v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_mLodTreeSlider_i(o,v); } //--------------------------------------------------------------------------- // Mesh Info Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_mMeshInfo_i(fltk::Browser *, void *) { paintMesh(); } void GeoMeshViewUI::cb_mMeshInfo(fltk::Browser* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) -> cb_mMeshInfo_i(o,v); } //--------------------------------------------------------------------------- // Logo Callback //--------------------------------------------------------------------------- inline void GeoMeshViewUI::cb_mLogo_i(fltk::InvisibleBox*, void*) { } void GeoMeshViewUI::cb_mLogo(fltk::InvisibleBox* o, void* v) { ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) -> cb_mLogo_i(o,v); } //--------------------------------------------------------------------------- // Active Build process. //--------------------------------------------------------------------------- void GeoMeshViewUI::activeBuildProcess() { //mButtonBuild->set_visible(); mButtonBuild->activate(); //mBuildBar->set_visible(); mBuildBar->activate(); } //--------------------------------------------------------------------------- // Show the stripify panel //--------------------------------------------------------------------------- void GeoMeshViewUI::showStripify() { /* mTypeLabel->set_visible(); mTypeLabel->activate(); mOneCacheStrip->set_visible(); mOneCacheStrip->activate(); mQualityStrips->set_visible(); mQualityStrips->activate(); */ mButtonProcess->set_visible(); mButtonProcess->activate(); mProcessBar->set_visible(); mProcessBar->activate(); } //--------------------------------------------------------------------------- // Hide the stripify panel //--------------------------------------------------------------------------- void GeoMeshViewUI::hideStripify() { /* mTypeLabel->hide(); mTypeLabel->deactivate(); */ mOneCacheStrip->hide(); mOneCacheStrip->deactivate(); mQualityStrips->hide(); mQualityStrips->deactivate(); mButtonProcess->hide(); mButtonProcess->deactivate(); mProcessBar->hide(); mProcessBar->deactivate(); } //--------------------------------------------------------------------------- // Show the Simplify Edge Collapse panel //--------------------------------------------------------------------------- void GeoMeshViewUI::showEdgeCollapse() { mMetricLabel->set_visible(); mMetricLabel->activate(); mGeometryBased->set_visible(); mGeometryBased->activate(); mGeometryBased->set(); mViewPointDriven->set_visible(); mViewPointDriven->activate(); /* mTypeLabel->set_visible(); mTypeLabel->activate(); mChangeVertices->set_visible(); mChangeVertices->activate(); */ mMeshReductionLabel->set_visible(); mMeshReductionLabel->activate(); mPercent->set_visible(); mPercent->activate(); mPercent->set(); mVerticesNumber->set_visible(); mVerticesNumber->activate(); mMeshReduction->set_visible(); // Allows floating point. mMeshReduction->type(fltk::FloatInput::FLOAT); mMeshReduction->activate(); mButtonProcess->set_visible(); mButtonProcess->activate(); mProcessBar->set_visible(); mProcessBar->activate(); } //--------------------------------------------------------------------------- // Hide the Simplify Edge Collapse //--------------------------------------------------------------------------- void GeoMeshViewUI::hideEdgeCollapse() { mMetricLabel->hide(); mMetricLabel->deactivate(); mGeometryBased->hide(); mGeometryBased->deactivate(); mViewPointDriven->hide(); mViewPointDriven->deactivate(); /* mTypeLabel->hide(); mTypeLabel->deactivate(); mChangeVertices->hide(); mChangeVertices->deactivate(); */ mMeshReductionLabel->hide(); mMeshReductionLabel->deactivate(); mPercent->hide(); mPercent->deactivate(); mVerticesNumber->hide(); mVerticesNumber->deactivate(); mMeshReduction->hide(); mMeshReduction->deactivate(); mButtonProcess->hide(); mButtonProcess->deactivate(); mProcessBar->hide(); mProcessBar->deactivate(); } //--------------------------------------------------------------------------- // Show the Simlify Leaves Collapse //--------------------------------------------------------------------------- void GeoMeshViewUI::showLeavesCollapse() { mMetricLabel->set_visible(); mMetricLabel->activate(); mGeometryBased->set_visible(); mGeometryBased->activate(); mGeometryBased->set(); mViewPointDriven->set_visible(); mViewPointDriven->activate(); /* mTypeLabel->set_visible(); mTypeLabel->activate(); mChangeTexture->set_visible(); mChangeTexture->activate(); */ mMeshReductionLabel->set_visible(); mMeshReductionLabel->activate(); mPercent->set_visible(); mPercent->activate(); mPercent->set(); mVerticesNumber->set_visible(); mVerticesNumber->activate(); mMeshReduction->set_visible(); mMeshReduction->type(fltk::FloatInput::FLOAT); mMeshReduction->activate(); mButtonProcess->set_visible(); mButtonProcess->activate(); mProcessBar->set_visible(); mProcessBar->activate(); } //--------------------------------------------------------------------------- // Hide the Simplify Leaves Collapse //--------------------------------------------------------------------------- void GeoMeshViewUI::hideLeavesCollapse() { mMetricLabel->hide(); mMetricLabel->deactivate(); mGeometryBased->hide(); mGeometryBased->deactivate(); mViewPointDriven->hide(); mViewPointDriven->deactivate(); /* mTypeLabel->hide(); mTypeLabel->deactivate(); mChangeTexture->hide(); mChangeTexture->deactivate(); */ mMeshReductionLabel->hide(); mMeshReductionLabel->deactivate(); mPercent->hide(); mPercent->deactivate(); mVerticesNumber->hide(); mVerticesNumber->deactivate(); mMeshReduction->hide(); mMeshReduction->deactivate(); mButtonProcess->hide(); mButtonProcess->deactivate(); mProcessBar->hide(); mProcessBar->deactivate(); } //--------------------------------------------------------------------------- // Show the LodStrips Panel //--------------------------------------------------------------------------- void GeoMeshViewUI::showOpenMeshSimplification() { mButtonProcess->set_visible(); mButtonProcess->activate(); mProcessBar->set_visible(); mProcessBar->activate(); mButtonBuild->set_visible(); mButtonBuild->activate(); mBuildBar->set_visible(); mBuildBar->activate(); } //--------------------------------------------------------------------------- // Hide the LodStrips Panel //--------------------------------------------------------------------------- void GeoMeshViewUI::hideOpenMeshSimplification() { mButtonProcess->hide(); mButtonProcess->deactivate(); mProcessBar->hide(); mProcessBar->deactivate(); mButtonBuild->hide(); mButtonBuild->deactivate(); mBuildBar->hide(); mBuildBar->deactivate(); } //--------------------------------------------------------------------------- // Shows the auto generate LodStrips panel //--------------------------------------------------------------------------- void GeoMeshViewUI::showAutoGenerateLodStrips() { // Shows the simplify panel. showEdgeCollapse(); mButtonBuild->set_visible(); //mButtonBuild->activate(); mBuildBar->set_visible(); //mBuildBar->activate(); } //--------------------------------------------------------------------------- // Shows the auto generate LodStrips panel //--------------------------------------------------------------------------- void GeoMeshViewUI::showAutoGenerateLodTrees() { // Shows the simplify panel. showEdgeCollapse(); mButtonBuild->set_visible(); //mButtonBuild->activate(); mBuildBar->set_visible(); //mBuildBar->activate(); } //--------------------------------------------------------------------------- // Show the LodStrips visulization panel //--------------------------------------------------------------------------- void GeoMeshViewUI::showLodStripSlider() { mLodStripSlider->set_visible(); mLodStripSlider->activate(); } //--------------------------------------------------------------------------- // Hide the LodStrips visualization panel //--------------------------------------------------------------------------- void GeoMeshViewUI::hideLodStripSlider() { mLodStripSlider->hide(); mLodStripSlider->deactivate(); } //--------------------------------------------------------------------------- // Show the LodTree visulization panel //--------------------------------------------------------------------------- void GeoMeshViewUI::showLodTreeSlider() { mLodTreeSlider->set_visible(); mLodTreeSlider->activate(); } //--------------------------------------------------------------------------- // Hide the LodTree visualization panel //--------------------------------------------------------------------------- void GeoMeshViewUI::hideLodTreeSlider() { mLodTreeSlider->hide(); mLodTreeSlider->deactivate(); } //--------------------------------------------------------------------------- // Show the LodTrees Panel //--------------------------------------------------------------------------- void GeoMeshViewUI::showOpenLeavesSimplification() { mButtonBuild->set_visible(); mButtonBuild->activate(); mBuildBar->set_visible(); mBuildBar->activate(); } //--------------------------------------------------------------------------- // Hide the LodTrees Panel //--------------------------------------------------------------------------- void GeoMeshViewUI::hideOpenLeavesSimplification() { mButtonBuild->hide(); mButtonBuild->deactivate(); mBuildBar->hide(); mBuildBar->deactivate(); } //--------------------------------------------------------------------------- // Show the mesh info browser //--------------------------------------------------------------------------- void GeoMeshViewUI::showMeshInfo() { char type[10]; if (mGeoMesh) { // Remove previous mesh information this->mMeshInfo->remove_all(); ogeometry = new fltk::ItemGroup("Geometry"); ogeometry->begin(); fltk::ItemGroup **oprueba; oprueba=new fltk::ItemGroup*[mGeoMesh->mSubMeshCount]; for(int i=0; imSubMeshCount;i++) { char *cadena=new char[256]; if (geoMeshView->getLeavesSubMesh() >= 0) { if (geoMeshView->getLeavesSubMesh() == i) { strcpy(type,"(Leaves)"); } else { strcpy(type,"(Trunc)"); } } else { strcpy(type,""); } // Submesh identifier. sprintf(cadena,"SubMesh %d %s",i,type); oprueba[i] = new fltk::ItemGroup(cadena); oprueba[i]->begin(); fltk::Item *sharedGeometry; if (mGeoMesh->mSubMesh[i].mSharedVertexBuffer) { sharedGeometry = new fltk::Item("Shared Geometry: Yes"); } else { sharedGeometry = new fltk::Item("Shared Geometry: No"); } // Adds material name. char *cadena2=new char[100]; sprintf(cadena2, "Material: %s",mGeoMesh->mSubMesh[i].mMaterialName); fltk::Item *geomaterial = new fltk::Item(cadena2); char *cadena3=new char[100]; sprintf(cadena3, "Number of indexes: %d",mGeoMesh->mSubMesh[i].mIndexCount); fltk::Item *numberIndex = new fltk::Item(cadena3); if (mGeoMesh->mSubMesh[i].mType==Geometry::GEO_TRIANGLE_LIST) { fltk::Item *type = new fltk::Item("Triangle List"); } else { fltk::Item *type = new fltk::Item("Triangle Strips"); } char *cadenavertex=new char[30]; sprintf(cadenavertex, "Number of vertices: %d",mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount); fltk::Item *numberVertex = new fltk::Item(cadenavertex); if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) { fltk::Item *normals = new fltk::Item("Normals: Yes"); } else { fltk::Item *normals = new fltk::Item("Normals: No"); } if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) { fltk::Item *textures = new fltk::Item("Textures: Yes"); } else { fltk::Item *textures = new fltk::Item("Textures: No"); } oprueba[i]->end(); } ogeometry->end(); this->mMeshInfo->add(ogeometry); } // Hide the right panel. hideRightPanel(); mMeshInfo->set_visible(); mMeshInfo->activate(); } //--------------------------------------------------------------------------- // Hide the mesh info browser //--------------------------------------------------------------------------- void GeoMeshViewUI::hideMeshInfo() { mMeshInfo->hide(); mMeshInfo->deactivate(); } //--------------------------------------------------------------------------- // Hide the right panel //--------------------------------------------------------------------------- void GeoMeshViewUI::hideRightPanel() { hideStripify(); hideEdgeCollapse(); hideLeavesCollapse(); hideOpenMeshSimplification(); hideOpenLeavesSimplification(); hideLodStripSlider(); hideLodTreeSlider(); hideMeshInfo(); } //--------------------------------------------------------------------------- // Get the number of vertices //--------------------------------------------------------------------------- size_t GeoMeshViewUI::getVertexCount(Mesh *geoMesh) { size_t vertex_count; SubMesh *geoSubMesh; vertex_count = geoMesh->mVertexBuffer->mVertexCount; // For each submesh. for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) { // Gets the actual submesh. geoSubMesh = &geoMesh->mSubMesh[submesh]; // If the mesh does not have shared vertex. if (!geoSubMesh->mSharedVertexBuffer) { // Adds the vertex of the submesh to the total count. vertex_count += geoSubMesh->mVertexBuffer->mVertexCount; } } return vertex_count; } //--------------------------------------------------------------------------- // Get the number of triangles //--------------------------------------------------------------------------- size_t GeoMeshViewUI::getTriangleCount(Geometry::Mesh *geoMesh) { size_t triangle_count; SubMesh *geoSubMesh; // Initialize the triangle count. triangle_count = 0; // If the application is in visualize lodstrips mode. if (mApplicationState == VISUALIZE_LODSTRIPS) { triangle_count = geoMeshView->getLodStripsTriangleCount(); } else { // For each submesh. for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) { // Gets the actual submesh. geoSubMesh = &geoMesh->mSubMesh[submesh]; switch (geoSubMesh->mType) { case GEO_TRIANGLE_LIST: triangle_count += geoSubMesh->mIndexCount / 3; break; case GEO_TRIANGLE_STRIPS: triangle_count += geoSubMesh->mIndexCount - 2; break; } } } return triangle_count; } //--------------------------------------------------------------------------- // Get the number of strips //--------------------------------------------------------------------------- size_t GeoMeshViewUI::getStripCount(Geometry::Mesh *geoMesh) { size_t strip_count; SubMesh *geoSubMesh; // Initialize the triangle count. strip_count = 0; // For each submesh. for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) { // Gets the actual submesh. geoSubMesh = &geoMesh->mSubMesh[submesh]; if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) { strip_count += geoSubMesh->mStripCount; } } return strip_count; } //--------------------------------------------------------------------------- // It paints the submesh selected by the mMeshInfo tree // Trate the mMeshInfo event //--------------------------------------------------------------------------- int GeoMeshViewUI::paintMesh(void) { char selectedTag[100]; char *pch; char *p; int meshNumber; // Initializa mesh to not selected. meshNumber = -1; // Shows the selected object label strcpy(selectedTag,mMeshInfo->goto_focus()->label()); p=strstr(selectedTag,"SubMesh "); // If the item begins with string "SubMesh" if (p!=NULL) { pch = strtok (selectedTag," "); pch = strtok (NULL, " "); sscanf(pch,"%d",&meshNumber); } geoMeshView->setSubMeshSelected(meshNumber); geoMeshView->redraw(); return meshNumber; } //--------------------------------------------------------------------------- // Simplify the mesh object. //--------------------------------------------------------------------------- bool GeoMeshViewUI::simplifyEdgeCollapse() { Real percent; // If input field empty. if (mMeshReduction->fvalue() <= 0.0) { return false; } geoMeshView->saveContext(); // Debug. cout << "Mesh Reduction: " << mMeshReduction->fvalue() << endl; // Gets simplify option. if (mGeometryBased->value()) { simplificationState = MESHSIMP; mMeshSimplifier = new GeometryBasedSimplifier(mGeoMesh, progress_function); } else { simplificationState = VIEWPOINTDRIVEN; mMeshSimplifier = new ViewPointDrivenSimplifier(mGeoMesh, progress_function); } mMeshSimplifier->setMeshLeaves(idMeshLeaves); if (mPercent->value()) { // Simplificación por porcentaje if (mMeshReduction->fvalue() <= 100.0 && mMeshReduction->fvalue() > 0.0) { percent = mMeshReduction->fvalue(); percent = percent / 100.0; // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. mMeshSimplifier->Simplify(percent); // Deletes the previous mesh. delete mUndoMesh; mUndoMesh = new Mesh(); // Sets the undo mesh. *mUndoMesh = *mGeoMesh; delete mGeoMesh; mGeoMesh = mMeshSimplifier->GetMesh(); // Visualize mesh. geoMeshView->setMesh(mGeoMesh); } else { fltk::alert("Wrong value for simplification.\n" "Valid values [0..100]"); return false; } } else { // Simplificar hasta un número de vértices. uint32 v = (uint32)mMeshReduction->fvalue(); // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. mMeshSimplifier->Simplify(v); // Deletes the previous mesh. delete mUndoMesh; mUndoMesh = new Mesh(); // Sets the undo mesh. *mUndoMesh = *mGeoMesh; delete mGeoMesh; mGeoMesh = mMeshSimplifier->GetMesh(); // Visualize the mesh. geoMeshView->setMesh(mGeoMesh); } return true; } //--------------------------------------------------------------------------- // Simplify the mesh object. //--------------------------------------------------------------------------- void GeoMeshViewUI::simplifyLeavesCollapse() { bool error; uint32 vi; // Initialize error flag. error = false; // Check submeshes for triangles strips. for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) { // If current submesh is in triangle strips. if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) { error = true; } } // if the mesh is stripified. if (error) { fltk::alert("Can't simplify a tree in triagle strips."); } // if the mesh is in triangle list. else { simplificationState = HOJAS; mTreeSimplifier = new TreeSimplifier(mGeoMesh, progress_function); vi = (uint32)mMeshReduction->fvalue(); // Simplify if(idMeshLeaves != (unsigned short)-1) { // Simplify mTreeSimplifier->Simplify(vi, idMeshLeaves); // Deletes the previous mesh. delete mUndoMesh; mUndoMesh = new Mesh(); // Sets the undo mesh. *mUndoMesh = *mGeoMesh; delete mGeoMesh; mGeoMesh = mTreeSimplifier->GetMesh(); geoMeshView->setMesh(mGeoMesh); } else { fltk::alert("You must select the mesh that contains the leaves."); } } } //--------------------------------------------------------------------------- // Create a simplification sequence of the simplification method. //--------------------------------------------------------------------------- void GeoMeshViewUI::createSimplificationSequence() { MeshSimplificationSequence *secsimpl; secsimpl = mMeshSimplifier->GetSimplificationSequence(); secsimpl->putMeshName(nombremesh); // Nombre del mesh para guardar la secuencia de simplificación secsimpl->Save(Geometry::Serializer("SimplifSequence.txt",Serializer::WRITE)); //delete secsimpl; } //--------------------------------------------------------------------------- // Create a simplification sequence of the leaves. //--------------------------------------------------------------------------- void GeoMeshViewUI::createLeavesSequence(const std::string &filename) { TreeSimplificationSequence *tree_sequencer; tree_sequencer = mTreeSimplifier->GetSimplificationSequence(); tree_sequencer->putMeshName(nombremesh); tree_sequencer->Save(Serializer(filename,Serializer::WRITE)); delete tree_sequencer; } //--------------------------------------------------------------------------- // Stripify the mesh object. //--------------------------------------------------------------------------- void GeoMeshViewUI::stripify() { bool error; char char_value[10]; CustomStripifier *geoStripifier; // Initialize error flag. error = false; // Check submeshes for triangles strips. for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) { // If current submesh is in triangle strips. if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) { error = true; } } // if the mesh is stripified. if (error) { fltk::alert("The mesh is already in strips."); } // if the mesh is in triangle list. else { //Stripify. geoStripifier = new CustomStripifier(mGeoMesh); // Set the progress bar function. geoStripifier->SetProgressFunc(progress_function); // Sets the leaves submesh if exists. geoStripifier->SetSubMeshLeaves(idMeshLeaves); if (geoStripifier->Stripify()) { // Deletes the mesh object. delete mUndoMesh; mUndoMesh = new Mesh(); *mUndoMesh = *mGeoMesh; delete mGeoMesh; // Gets the mesh stripified. mGeoMesh = geoStripifier->GetMesh(); // Visualize the mesh stripified. geoMeshView->setMesh(mGeoMesh); // Store the color of the strips. geoMeshView->setStripColors(); } else { // Error message. fltk::alert("Impossible to stripify. The mesh is not manifold"); } // Deletes the stripifier object. delete geoStripifier; } } //--------------------------------------------------------------------------- // Method that undo then mesh changes. //--------------------------------------------------------------------------- void GeoMeshViewUI::undo() { // if the undo mesh is not initialized. if (mUndoMesh != NULL) { // Deletes the actual mesh. delete mGeoMesh; mGeoMesh = new Mesh(); // Restore the previous mesh. *mGeoMesh = *mUndoMesh; // Visualize the mesh. geoMeshView->setMesh(mGeoMesh); // Refresh geometry attributes. refreshApplicationBar(); // Repaint the window. mMainWindow->redraw(); } } //--------------------------------------------------------------------------- // Refresh number of vertices, triangles, strips, ... //--------------------------------------------------------------------------- void GeoMeshViewUI::refreshApplicationBar() { static char vertices_value[50]; static char triangles_value[50]; static char strips_value[50]; // Translate the vertex count to a char value. sprintf(vertices_value,"Vertices %d",getVertexCount(mGeoMesh)); mVertices->label(vertices_value); // Translate the triangle count to a char value. sprintf(triangles_value,"Triangles %d",getTriangleCount(mGeoMesh)); mTriangles->label(triangles_value); // Translate the triangle count to a char value. sprintf(strips_value,"Strips %d",getStripCount(mGeoMesh)); mStrips->label(strips_value); } // Method that updates the porgress bar. float GeoMeshViewUI::updateProgressBar(float v) { fltk::ProgressBar *progressBar; // Choose progress bar to update. switch(progressBarType) { case PROCESS: progressBar = mProcessBar; break; case BUILD: progressBar = mBuildBar; break; } // Update progress bar. progressBar->step(v); progressBar->step(); mMainWindow->flush(); //mMainWindow->redraw(); return 0; } //--------------------------------------------------------------------------- // Initialize the lodstripslibrary for visualization. //--------------------------------------------------------------------------- void GeoMeshViewUI::setLodStripsLibrary(std::string lodfile, Mesh *geomesh) { // If there is no lod strips object. if (lodStripsLib) { delete lodStripsLib; } // New lod strips object. lodStripsLib = new LodStripsLibrary(lodfile, geomesh); // Sets the slider range. mLodStripSlider->range(lodStripsLib->MinLod(),lodStripsLib->MaxLod()); // Pass to geomeshview the lod strips object. geoMeshView->setLodStripsLibrary(lodStripsLib); // Puts the slider in the max position. //mLodStripSlider->value(lodStripsLib->MinLod()); } //--------------------------------------------------------------------------- // Initialize the lodTreelibrary for visualization. //--------------------------------------------------------------------------- //void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh *geomesh, uint32 ileafSubMesh) { // If there is no lod strips object. if (lodTreeLib) { delete lodTreeLib; } // New lod strips object. /* lodTreeLib = new Geometry::LodTreeLibrary(lodfile, geomesh,"\\\\quake\\home\\\Modelos\\betula_populifolia\\vertices.obj", "\\\\quake\\home\\\Modelos\\betula_populifolia\\hojas.obj", "\\\\quake\\home\\\Modelos\\betula_populifolia\\simplifica.obj");*/ lodTreeLib = new Geometry::LodTreeLibrary(lodfile,leafseqfile,geomesh,ileafSubMesh); // Sets the slider range. mLodStripSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); mLodTreeSlider->range(lodTreeLib->MaxFoliageLod(), lodTreeLib->MinFoliageLod()); // Pass to geomeshview the lod strips object. geoMeshView->setLodTreesLibrary(lodTreeLib); // Puts the slider in the max position. mLodStripSlider->value(lodTreeLib->MinTrunkLod()); mLodTreeSlider->value(lodTreeLib->MinFoliageLod()); } //--------------------------------------------------------------------------- // Open a mesh file. //--------------------------------------------------------------------------- void GeoMeshViewUI::openMeshFile() { Mesh *mesh_loaded; fltk::FileChooser *fcho; static char char_value[10]; static char title[256]; fcho = new fltk::FileChooser("", "*.mesh", fltk::FileChooser::CREATE, "Open mesh file"); fcho->exec(); // File name. mFileName = (char *)fcho->value(); if (mFileName) { // Loads a new mesh. mesh_loaded = geoMeshLoader->load(mFileName); // If no error happens. if (mesh_loaded) { // Identify the mesh that stores the leaves idMeshLeaves = -1; // Delete the current mesh. delete mGeoMesh; delete mUndoMesh; // Assigns mesh loaded. mGeoMesh = mesh_loaded; // Set Window Title. strcpy(title,filename_name(mFileName)); mMainWindow->label(strcat(title," - GeoTool")); // Stores the name of the mesh. nombremesh = new char[255]; strcpy(nombremesh,mFileName); // Reset the undo mesh. mUndoMesh = new Mesh(); *mUndoMesh = *mGeoMesh; // Translate the MB count to a char value. sprintf(char_value, "MB %.3f", (float)geoMeshLoader->getFileSize()/1024/1024); mMB->label(char_value); // Visualize mesh. geoMeshView->setMesh(mGeoMesh); // Hide right panel. hideRightPanel(); // Quit culling. menuRenderCW->clear_value(); menuRenderCCW->clear_value(); geoMeshView->deactiveCW(); geoMeshView->deactiveCCW(); // Deactive solid mode and wire. menuRenderSolid->clear_value(); menuRenderWire->clear_value(); geoMeshView->deactiveSolid(); geoMeshView->deactiveWire(); // Fit model in midle. geoMeshView->fit(); // Lighting smooth. menuRenderFlat->clear_value(); menuRenderSmooth->set_value(); geoMeshView->smooth(); // Show title. mProcessTitle->label("Mesh Info"); // Shows the mesh info. showMeshInfo(); // if the mesh is stripified. geoMeshView->setStripColors(); // Refresh geometry attributes. refreshApplicationBar(); // Restore simplification state. simplificationState = NO_SIMPLIFICATION; } } // Free memory. delete fcho; } //--------------------------------------------------------------------------- // If file exists. //--------------------------------------------------------------------------- bool GeoMeshViewUI::fileExists(const char *fileNameMesh) { FILE *pFile; // Open the mesh file. pFile = fopen(fileNameMesh, "r"); if (pFile) { return true; } else { return false; } } /******************/ /* Constructor */ /******************/ GeoMeshViewUI::GeoMeshViewUI(TIPOFUNC fun) { progress_function = fun; fltk::gifImage *logo; // Initialize the file name. mFileName = NULL; // Initialize the 3D object. mGeoMesh = NULL; mUndoMesh = NULL; // Initialize the lod strip object. lodStripsLib = NULL; lodTreeLib = NULL; // Identify the mesh that stores the leaves idMeshLeaves = -1; // Initialize the loader of meshes. geoMeshLoader = new GeoMeshLoader(); // Initialize the menus application state. mApplicationState = NONE; SubMeshNames=NULL; { fltk::Window* o = new fltk::Window(800, 600,"GeoTool"); mMainWindow = o; // Program Icon for Win32. mMainWindow->icon((char *)LoadIcon( GetModuleHandle(0), MAKEINTRESOURCE(GEOICON))); // Double buffer. mMainWindow->set_double_buffer(); o->user_data((void*)(this)); o->begin(); { fltk::Group* o = new fltk::Group(0, 27, 806, 559); o->begin(); { fltk::Group* o; o = MainView = new fltk::Group(0, 0, 570, 530); o->begin(); { fltk::InvisibleBox* o; o = cframe = new fltk::InvisibleBox(0, 0, 570, 530); o->box(fltk::FLAT_BOX); o->color((fltk::Color)0xffffff00); //fltk::Group::current()->resizable(o); } { GeoMeshView* o; o = geoMeshView = new GeoMeshView( 0,0,570,530,0,this); } o->end(); fltk::Group::current()->resizable(o); } { fltk::Group* o; o = MainView = new fltk::Group(570, 0, 230, 530); o->begin(); { fltk::Button* o; //o = mButtonProcess = new fltk::Button(665, 410, 73, 25, "Process"); o = mButtonProcess = new fltk::Button(75, 410, 73, 25, "Process"); o->callback((fltk::Callback*)cb_mButtonProcess); o->hide(); o->deactivate(); } { fltk::ProgressBar* o; //o = mProcessBar = new fltk::ProgressBar(616, 435, 175, 18); o = mProcessBar = new fltk::ProgressBar(16, 435, 195, 18); o->hide(); o->deactivate(); } { fltk::Button* o; o = mButtonSort = new fltk::Button(75, 375, 73, 25, "Sort"); o->callback((fltk::Callback*)cb_mButtonSort); o->hide(); o->deactivate(); } { fltk::ProgressBar* o; o = mSortBar = new fltk::ProgressBar(16, 390, 195, 18); o->hide(); o->deactivate(); } { fltk::Button* o; o = mButtonBuild = new fltk::Button(75, 455, 73, 25, "Build"); o->callback((fltk::Callback*)cb_mButtonBuild); o->hide(); o->deactivate(); } { fltk::ProgressBar* o; o = mBuildBar = new fltk::ProgressBar(16, 480, 195, 18); o->hide(); o->deactivate(); } { fltk::Slider* o; o = mLodStripSlider = new fltk::Slider(16, 50, 30, 450); o->type(fltk::Slider::TICK_BELOW); o->set_vertical(); o->callback((fltk::Callback*)cb_mLodStripSlider); o->hide(); o->deactivate(); } { fltk::Slider* o; o = mLodTreeSlider = new fltk::Slider(46, 50, 30, 450); o->type(fltk::Slider::TICK_BELOW); o->set_vertical(); o->callback((fltk::Callback*)cb_mLodTreeSlider); o->hide(); o->deactivate(); } { mMetricLabel = new fltk::Output(26, 28, 5, 25, "Metric"); fltk::Output* o = mMetricLabel; o->set_vertical(); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->color((fltk::Color)0xe0dfe300); o->align(fltk::ALIGN_RIGHT); } { fltk::Group* o; o = MainView = new fltk::Group(30, 40, 30, 60); o->begin(); { mGeometryBased = new fltk::RadioButton(0, 8, 25, 25, "Geometry based"); mViewPointDriven = new fltk::RadioButton(0, 23, 25, 25, "Viewpoint driven"); } o->end(); } //mChangeVertices = new fltk::CheckButton(30, 104, 25, 25, "Change vertices"); { mProcessTitle = new fltk::Widget(0, 0, 230, 25, ""); fltk::Widget* o = mProcessTitle; o->set_vertical(); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->labelsize(15.0); o->color((fltk::Color)0xe0dfe300); o->align(fltk::ALIGN_CENTER); } /* { mTypeLabel = new fltk::Output(26, 82, 5, 25, "Type"); fltk::Output* o = mTypeLabel; o->set_vertical(); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->color((fltk::Color)0xe0dfe300); o->align(fltk::ALIGN_RIGHT); } */ { mMeshReductionLabel = new fltk::Output(26, 124, 5, 25, "Mesh Reduction"); fltk::Output* o = mMeshReductionLabel; o->set_vertical(); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->color((fltk::Color)0xe0dfe300); o->align(fltk::ALIGN_RIGHT); } //mChangeTexture = new fltk::CheckButton(30, 104, 25, 25, "Change texture"); { fltk::Group* o; o = MainView = new fltk::Group(30, 140, 30, 60); o->begin(); { mPercent = new fltk::RadioButton(0, 5, 25, 25, "%"); mVerticesNumber = new fltk::RadioButton(0, 20, 25, 25, "Vertices number"); } o->end(); } { mMeshReduction = new fltk::FloatInput(75, 181, 75, 21, "Value:"); fltk::FloatInput* o = mMeshReduction; o->type(1); } { fltk::Group* o; o = MainView = new fltk::Group(30, 100, 30, 60); o->begin(); { mOneCacheStrip = new fltk::RadioButton(0, 4, 25, 25, "One cache strip"); mQualityStrips = new fltk::RadioButton(0, 23, 25, 25, "Quality strips"); } o->end(); } { fltk::Browser* o = mMeshInfo = new fltk::Browser(0, 20, 230, 380); o->set_vertical(); o->callback((fltk::Callback*)cb_mMeshInfo); } o->end(); } o->end(); fltk::Group::current()->resizable(o); } { fltk::MenuBar* o = menuBar = new fltk::MenuBar(1, 2, 801, 21); o->begin(); // Menu File. { fltk::ItemGroup* o = menuFile = new fltk::ItemGroup("File"); o->begin(); { fltk::Item* o = menuFileOpen = new fltk::Item("Open"); o->callback((fltk::Callback*)cb_menuFileOpen); } { fltk::Item* o = menuFileSave = new fltk::Item("Save"); o->callback((fltk::Callback*)cb_menuFileSave); } { fltk::Item* o = menuFileSaveAs = new fltk::Item("Save As"); o->callback((fltk::Callback*)cb_menuFileSaveAs); } { fltk::Item* o = menuMeshExportOBJ = new fltk::Item("Export to OBJ"); o->callback((fltk::Callback*)cb_menuMeshExportOBJ); } //{ // fltk::Item* o = menuFileTransformSharedVertex = new fltk::Item("Transform to Shared Vertex"); // o->callback((fltk::Callback*)cb_menuFileTransformSharedVertex); //} { menuLoadTextures = new fltk::ItemGroup("Load Textures"); o->add(menuLoadTextures); } { fltk::Item* o = menuFileQuit = new fltk::Item("Quit"); o->callback((fltk::Callback*)cb_menuFileQuit); } o->end(); } // Menu Edit. { fltk::ItemGroup* o = menuEdit = new fltk::ItemGroup("Edit"); o->begin(); { fltk::Item* o = menuEditUndo = new fltk::Item("Undo"); o->callback((fltk::Callback*)cb_menuEditUndo); } { fltk::Item* o = menuEditFit = new fltk::Item("Fit"); o->callback((fltk::Callback*)cb_menuEditFit); } { fltk::Item* o = menuEditRotate = new fltk::Item("Rotate"); o->type(fltk::Item::RADIO); o->set_value(); o->callback((fltk::Callback*)cb_menuEditRotate); } { fltk::Item* o = menuEditPan = new fltk::Item("Pan"); o->type(fltk::Item::RADIO); o->callback((fltk::Callback*)cb_menuEditPan); } //{ // fltk::Item* o = menuEditZoom = new fltk::Item("Zoom"); // o->callback((fltk::Callback*)cb_menuEditZoom); //} new fltk::Divider(); { fltk::Item* o = menuMeshInfo = new fltk::Item("Mesh info"); o->callback((fltk::Callback*)cb_menuMeshInfo); } { fltk::Item* o; o = menuSelectLeaves = new fltk::Item("Select leaves"); o->callback((fltk::Callback*)cb_menuSelectLeaves); } o->end(); } // Menu Render. { fltk::ItemGroup* o = menuRender = new fltk::ItemGroup("Render"); o->begin(); { fltk::Item* o = menuRenderWire = new fltk::Item("Wire"); o->type(fltk::Item::RADIO); o->callback((fltk::Callback*)cb_menuRenderWire); } { fltk::Item* o = menuRenderSolid = new fltk::Item("Solid"); o->type(fltk::Item::RADIO); o->callback((fltk::Callback*)cb_menuRenderSolid); } //new fltk::Divider(); { fltk::Item* o = menuRenderCW = new fltk::Item("CW"); o->type(fltk::Item::RADIO); o->callback((fltk::Callback*)cb_menuRenderCW); //o->hide(); } { fltk::Item* o = menuRenderCCW = new fltk::Item("CCW"); o->type(fltk::Item::RADIO); o->set_value(); o->callback((fltk::Callback*)cb_menuRenderCCW); //o->hide(); } new fltk::Divider(); { fltk::Item* o = menuRenderFlat = new fltk::Item("Flat"); o->type(fltk::Item::RADIO); o->clear_value(); o->callback((fltk::Callback*)cb_menuRenderFlat); } { fltk::Item* o = menuRenderSmooth = new fltk::Item("Smooth"); o->type(fltk::Item::RADIO); o->set_value(); o->callback((fltk::Callback*)cb_menuRenderSmooth); } new fltk::Divider(); { fltk::Item* o = menuRenderTextures = new fltk::Item("Texture mapping"); o->type(fltk::Item::RADIO); o->set_value(); o->callback((fltk::Callback*)cb_menuRenderTextures); } o->end(); } // Menu Stripify. { fltk::Item* o = menuStripify = new fltk::Item("Stripify"); o->callback((fltk::Callback*)cb_menuStripify); } // Menu Simplify. { fltk::ItemGroup* o = menuSimplify = new fltk::ItemGroup("Simplify"); o->callback((fltk::Callback*)cb_menuSimplify); o->begin(); { fltk::Item* o; o = menuSimplifyEdgeCollapse = new fltk::Item("Mesh Simplification"); o->callback((fltk::Callback*)cb_menuSimplifyEdgeCollapse); } { fltk::Item* o; o = menuSimplifyLeavesCollapse = new fltk::Item("Leaves Simplification"); o->callback((fltk::Callback*)cb_menuSimplifyLeavesCollapse); } o->end(); } // Menu LodStrips. { fltk::ItemGroup* o; o = menuLodStrips = new fltk::ItemGroup("LodStrips"); o->begin(); { fltk::Item* o; o = menuLodStripsGenerate = new fltk::Item("Generate"); o->callback((fltk::Callback*)cb_menuLodStripsGenerate); } { fltk::Item* o; o = menuLodStripsVisualize = new fltk::Item("Visualize"); o->callback((fltk::Callback*)cb_menuLodStripsVisualize); } o->end(); } // Menu LodTrees. { fltk::ItemGroup* o; o = menuLodTrees = new fltk::ItemGroup("LodTrees"); o->begin(); { fltk::Item* o; o = menuLodTreesGenerate = new fltk::Item("Generate"); o->callback((fltk::Callback*)cb_menuLodTreesGenerate); } { fltk::Item* o; o = menuLodTreesVisualize = new fltk::Item("Visualize"); o->callback((fltk::Callback*)cb_menuLodTreesVisualize); } o->end(); } { fltk::ItemGroup* o = new fltk::ItemGroup("?"); o->begin(); { fltk::Item* o = menuHelpAbout = new fltk::Item("About"); o->callback((fltk::Callback*)cb_menuHelpAbout); } o->end(); } /* { fltk::SharedImage *gifLogo = logo->get("media\\logos\\logo.gif"); //o->callback((fltk::Callback*)cb_mLogo); mLogo = new fltk::InvisibleBox(406, 1, 43, 13); mLogo->image(gifLogo); }*/ o->end(); } { fltk::Group* o; o = ApplicationBar = new fltk::Group(0, 570, 807, 28); o->box(fltk::BORDER_BOX); o->begin(); { fltk::Widget* o; o = mFPS = new fltk::Widget(10, 4, 30, 15, "FPS "); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->color((fltk::Color)0xe0dfe300); } { fltk::Widget* o; o = mVertices = new fltk::Widget(154, 4, 40, 15, "Vertices"); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->color((fltk::Color)0xe0dfe300); } { fltk::Widget* o; o = mTriangles = new fltk::Widget(254, 3, 40, 15, "Triangles"); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->color((fltk::Color)0xe0dfe300); // Hide triangle count. o->hide(); } { fltk::Widget* o; o = mStrips = new fltk::Widget(354, 3, 30, 15, "Strips"); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->color((fltk::Color)0xe0dfe300); } //{ // fltk::Widget* o; // o = mQuads = new fltk::Widget(454, 4, 40, 15, "Quads"); // o->box(fltk::NO_BOX); // o->labelfont(fltk::HELVETICA_BOLD); // o->color((fltk::Color)0xe0dfe300); //} { fltk::Widget* o; o = mMB = new fltk::Widget(740, 3, 30, 15, "MB"); o->box(fltk::NO_BOX); o->labelfont(fltk::HELVETICA_BOLD); o->color((fltk::Color)0xe0dfe300); } o->end(); } o->end(); } fltk::focus(geoMeshView); /*Hide Right Panel*/ hideRightPanel(); mMainWindow->show(); } /****************/ /* Destroyer */ /****************/ GeoMeshViewUI::~GeoMeshViewUI() { delete geoMeshLoader; mMainWindow->destroy(); } // Shows the main window. void GeoMeshViewUI::show() { } void GeoMeshViewUI::BuildLoadTextureSubMeshMenu(void) { if (SubMeshNames) { menuLoadTextures->clear(); for (int i=0; icallback((fltk::Callback*)cb_menuFileLoadTexture); menuLoadTextures->add(menuFileLoadTexture); numSubMeshNames=geoMeshView->getSubMeshCount(); SubMeshNames=new char*[numSubMeshNames]; for (int i=0; icallback((fltk::Callback*)cb_menuFileLoadTextureSubMesh); menuLoadTextures->add(item); } }