[1007] | 1 | // generated by Fast Light User Interface Designer (fluid) version 2.0100 |
---|
| 2 | |
---|
| 3 | #include "GeoMeshViewUI.h" |
---|
| 4 | #include "resource.h" |
---|
| 5 | #include "GeoLodTreeConstructor.h" |
---|
| 6 | |
---|
| 7 | using namespace Geometry; |
---|
| 8 | using namespace std; |
---|
| 9 | |
---|
| 10 | //--------------------------------------------------------------------------- |
---|
| 11 | // Menu File Open Callback |
---|
| 12 | //--------------------------------------------------------------------------- |
---|
| 13 | inline void GeoMeshViewUI::cb_menuFileOpen_i(fltk::Item*, void*) |
---|
| 14 | { |
---|
| 15 | // Sets menus application state to NONE. |
---|
| 16 | mApplicationState = NONE; |
---|
| 17 | |
---|
| 18 | // Loads a mesh file. |
---|
| 19 | openMeshFile(); |
---|
| 20 | |
---|
| 21 | // Deactive Lod strip visualization. |
---|
| 22 | geoMeshView->deactiveLodStrip(); |
---|
| 23 | |
---|
| 24 | // Deactive Lod tree visualization. |
---|
| 25 | geoMeshView->deactiveLodTree(); |
---|
| 26 | |
---|
| 27 | geoMeshView->resetTextures(); |
---|
| 28 | BuildLoadTextureSubMeshMenu(); |
---|
| 29 | |
---|
| 30 | // Repaint the window. |
---|
| 31 | mMainWindow->redraw(); |
---|
| 32 | } |
---|
| 33 | |
---|
[993] | 34 | inline void GeoMeshViewUI::cb_menuFileLoadTexture_i(fltk::Item*, void*) |
---|
| 35 | { |
---|
[995] | 36 | static char pattern[] = "*.{jpg|tga|png|bmp}"; |
---|
| 37 | |
---|
[1007] | 38 | fltk::FileChooser *fcho = new fltk::FileChooser("",pattern,fltk::FileChooser::CREATE,"Open image file"); |
---|
| 39 | fcho->exec(); |
---|
| 40 | char filename[256]=""; |
---|
| 41 | if (fcho->value()) |
---|
| 42 | { |
---|
| 43 | strcpy(filename,fcho->value()); |
---|
| 44 | geoMeshView->LoadTexture(filename); |
---|
| 45 | } |
---|
[993] | 46 | } |
---|
| 47 | |
---|
| 48 | void GeoMeshViewUI::cb_menuFileLoadTexture(fltk::Item *o, void *v) |
---|
| 49 | { |
---|
[1007] | 50 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->parent()->user_data())) |
---|
| 51 | -> |
---|
[993] | 52 | cb_menuFileLoadTexture_i(o,v); |
---|
| 53 | } |
---|
[1007] | 54 | |
---|
[994] | 55 | inline void GeoMeshViewUI::cb_menuFileLoadTextureSubMesh_i(fltk::Item *item, void *) |
---|
| 56 | { |
---|
[995] | 57 | static char pattern[] = "*.{jpg|tga|png|bmp}"; |
---|
| 58 | |
---|
[994] | 59 | const char * label = item->label(); |
---|
| 60 | int isubmesh = label[strlen(label)-1]-48; |
---|
| 61 | |
---|
[1007] | 62 | fltk::FileChooser *fcho = new fltk::FileChooser("",pattern,fltk::FileChooser::CREATE,"Open image file"); |
---|
| 63 | fcho->exec(); |
---|
| 64 | char filename[256]=""; |
---|
| 65 | if (fcho->value()) |
---|
| 66 | { |
---|
| 67 | strcpy(filename,fcho->value()); |
---|
| 68 | geoMeshView->LoadTextureSubMesh(isubmesh,filename); |
---|
[994] | 69 | } |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | void GeoMeshViewUI::cb_menuFileLoadTextureSubMesh(fltk::Item *o, void *v) |
---|
| 73 | { |
---|
[1007] | 74 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->parent()->user_data())) |
---|
| 75 | -> |
---|
[994] | 76 | cb_menuFileLoadTextureSubMesh_i(o,v); |
---|
| 77 | } |
---|
[1007] | 78 | |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | //--------------------------------------------------------------------------- |
---|
| 82 | // Repaint the FPS label. |
---|
| 83 | //--------------------------------------------------------------------------- |
---|
| 84 | void GeoMeshViewUI::refreshFPS(int fps) |
---|
| 85 | { |
---|
| 86 | static char char_value[10]; |
---|
| 87 | |
---|
| 88 | // Translate the FPS count to a char value. |
---|
| 89 | sprintf(char_value,"FPS %d",fps); |
---|
| 90 | |
---|
| 91 | mFPS->label(char_value); |
---|
| 92 | |
---|
| 93 | // Repaint the window. |
---|
| 94 | mMainWindow->redraw(); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | void GeoMeshViewUI::cb_menuFileOpen(fltk::Item* o, void* v) |
---|
| 98 | { |
---|
| 99 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 100 | -> |
---|
| 101 | cb_menuFileOpen_i(o,v); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | //--------------------------------------------------------------------------- |
---|
| 105 | // Save callback |
---|
| 106 | //--------------------------------------------------------------------------- |
---|
| 107 | inline void GeoMeshViewUI::cb_menuFileSave_i(fltk::Item*, void*) |
---|
| 108 | { |
---|
| 109 | GeoMeshSaver *mesh_saver; |
---|
| 110 | |
---|
| 111 | // If there is a mesh object created. |
---|
| 112 | if (mGeoMesh != NULL) |
---|
| 113 | { |
---|
| 114 | // Create a mesh saver with mesh bounds. |
---|
| 115 | mesh_saver = new GeoMeshSaver(); |
---|
| 116 | |
---|
| 117 | // Save the file mesh. |
---|
| 118 | mesh_saver->save(mGeoMesh, mFileName); |
---|
| 119 | |
---|
| 120 | // Free memory. |
---|
| 121 | delete mesh_saver; |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | void GeoMeshViewUI::cb_menuFileSave(fltk::Item* o, void* v) |
---|
| 126 | { |
---|
| 127 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 128 | -> |
---|
| 129 | cb_menuFileSave_i(o,v); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | //--------------------------------------------------------------------------- |
---|
| 133 | // Save As Callback |
---|
| 134 | //--------------------------------------------------------------------------- |
---|
| 135 | inline void GeoMeshViewUI::cb_menuFileSaveAs_i(fltk::Item*, void*) |
---|
| 136 | { |
---|
| 137 | fltk::FileChooser *fcho; |
---|
| 138 | GeoMeshSaver *mesh_saver; |
---|
| 139 | char file_name[255]; |
---|
| 140 | char message[255]; |
---|
| 141 | char *ptr; |
---|
| 142 | int answer_yes; |
---|
| 143 | |
---|
| 144 | // Initialize answer to yes. |
---|
| 145 | answer_yes = 1; |
---|
| 146 | |
---|
| 147 | if (mGeoMesh != NULL) |
---|
| 148 | { |
---|
| 149 | fcho = new fltk::FileChooser("", |
---|
| 150 | "*.mesh", |
---|
| 151 | fltk::FileChooser::CREATE, |
---|
| 152 | "Save Mesh as"); |
---|
| 153 | |
---|
| 154 | fcho->exec(); |
---|
| 155 | |
---|
| 156 | if (fcho->value()) |
---|
| 157 | { |
---|
| 158 | // Gets file name. |
---|
| 159 | strcpy(file_name,fcho->value()); |
---|
| 160 | |
---|
| 161 | // Cut extension. |
---|
| 162 | ptr = strtok(file_name,"."); |
---|
| 163 | |
---|
| 164 | // If has extension. |
---|
| 165 | if (ptr) |
---|
| 166 | { |
---|
| 167 | strcpy(file_name,ptr); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | // Adds mesh extension. |
---|
| 171 | strcat(file_name,".mesh"); |
---|
| 172 | |
---|
| 173 | // If File Exists. |
---|
| 174 | if (fileExists(file_name)) |
---|
| 175 | { |
---|
| 176 | // Compose message. |
---|
| 177 | strcpy(message,"Do you want to replace "); |
---|
| 178 | strcat(message,filename_name(file_name)); |
---|
| 179 | strcat(message,"?"); |
---|
| 180 | |
---|
| 181 | // Question. |
---|
| 182 | answer_yes = fltk::ask(message); |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | // If answer yes to replace question. |
---|
| 186 | // or if file not exists. |
---|
| 187 | if (answer_yes) |
---|
| 188 | { |
---|
| 189 | mesh_saver = new GeoMeshSaver(); |
---|
| 190 | |
---|
| 191 | mesh_saver->save(mGeoMesh,filename_name(file_name)); |
---|
| 192 | |
---|
| 193 | delete mesh_saver; |
---|
| 194 | } |
---|
| 195 | } |
---|
| 196 | // Repaint the window. |
---|
| 197 | mMainWindow->redraw(); |
---|
| 198 | |
---|
| 199 | delete fcho; |
---|
| 200 | } |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | void GeoMeshViewUI::cb_menuFileSaveAs(fltk::Item* o, void* v) |
---|
| 204 | { |
---|
| 205 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 206 | -> |
---|
| 207 | cb_menuFileSaveAs_i(o,v); |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | //--------------------------------------------------------------------------- |
---|
| 211 | // Mesh info callback |
---|
| 212 | //--------------------------------------------------------------------------- |
---|
| 213 | inline void GeoMeshViewUI::cb_menuMeshInfo_i(fltk::Item*, void*) |
---|
| 214 | { |
---|
| 215 | // Show title. |
---|
| 216 | mProcessTitle->label("Mesh Info"); |
---|
| 217 | |
---|
| 218 | showMeshInfo(); |
---|
| 219 | mMainWindow->redraw(); |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | void GeoMeshViewUI::cb_menuMeshInfo(fltk::Item* o, void* v) |
---|
| 223 | { |
---|
| 224 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 225 | -> |
---|
| 226 | cb_menuMeshInfo_i(o,v); |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | //--------------------------------------------------------------------------- |
---|
| 230 | // Mesh Export to OBJ callback |
---|
| 231 | //--------------------------------------------------------------------------- |
---|
| 232 | inline void GeoMeshViewUI::cb_menuMeshExportOBJ_i(fltk::Item*, void*) |
---|
| 233 | { |
---|
| 234 | char *p; |
---|
| 235 | |
---|
| 236 | // Sets menus application state to NONE. |
---|
| 237 | mApplicationState = NONE; |
---|
| 238 | |
---|
| 239 | // Open file chooser dialog. |
---|
| 240 | p = fltk::file_chooser("Export to OBJ","*.obj",""); |
---|
| 241 | if (p && mGeoMesh) |
---|
| 242 | { |
---|
| 243 | mGeoMesh->exportToOBJ(p); |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | void GeoMeshViewUI::cb_menuMeshExportOBJ(fltk::Item* o, void* v) |
---|
| 248 | { |
---|
| 249 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 250 | -> |
---|
| 251 | cb_menuMeshExportOBJ_i(o,v); |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | //--------------------------------------------------------------------------- |
---|
| 255 | // Transform to Shared Vertex callback |
---|
| 256 | //--------------------------------------------------------------------------- |
---|
| 257 | inline void GeoMeshViewUI::cb_menuTransformSharedVertex_i(fltk::Item*, void*) |
---|
| 258 | { |
---|
| 259 | Mesh *mesh_aux; |
---|
| 260 | |
---|
| 261 | // if the undo mesh is not initialized. |
---|
| 262 | if (mGeoMesh != NULL) |
---|
| 263 | { |
---|
| 264 | // Deletes the actual mesh. |
---|
| 265 | delete mUndoMesh; |
---|
| 266 | |
---|
| 267 | mUndoMesh = new Mesh(); |
---|
| 268 | |
---|
| 269 | // Restore the previous mesh. |
---|
| 270 | *mUndoMesh = *mGeoMesh; |
---|
| 271 | |
---|
| 272 | // Transform NoSV Mesh to a SV Mesh. |
---|
| 273 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
| 274 | |
---|
| 275 | // Deletes the mesh No Shared Vertex. |
---|
| 276 | delete mGeoMesh; |
---|
| 277 | |
---|
| 278 | // Gets the mesh Shared Vertex. |
---|
| 279 | mGeoMesh = mesh_aux; |
---|
| 280 | |
---|
| 281 | // Visualize the mesh stripified. |
---|
| 282 | geoMeshView->setMesh(mGeoMesh); |
---|
| 283 | |
---|
| 284 | // Refresh mesh information. |
---|
| 285 | showMeshInfo(); |
---|
| 286 | |
---|
| 287 | // Repaint the window. |
---|
| 288 | mMainWindow->redraw(); |
---|
| 289 | } |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | void GeoMeshViewUI::cb_menuFileTransformSharedVertex(fltk::Item* o, void* v) |
---|
| 293 | { |
---|
| 294 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 295 | -> |
---|
| 296 | cb_menuTransformSharedVertex_i(o,v); |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | //--------------------------------------------------------------------------- |
---|
| 300 | // Quit Callback |
---|
| 301 | //--------------------------------------------------------------------------- |
---|
| 302 | inline void GeoMeshViewUI::cb_menuFileQuit_i(fltk::Item*, void*) |
---|
| 303 | { |
---|
| 304 | delete this; |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | void GeoMeshViewUI::cb_menuFileQuit(fltk::Item* o, void* v) |
---|
| 308 | { |
---|
| 309 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 310 | -> |
---|
| 311 | cb_menuFileQuit_i(o,v); |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | //--------------------------------------------------------------------------- |
---|
| 315 | // Undo Callback |
---|
| 316 | //--------------------------------------------------------------------------- |
---|
| 317 | inline void GeoMeshViewUI::cb_menuEditUndo_i(fltk::Item*, void*) |
---|
| 318 | { |
---|
| 319 | // Undo the mesh changes. |
---|
| 320 | undo(); |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | void GeoMeshViewUI::cb_menuEditUndo(fltk::Item* o, void* v) |
---|
| 324 | { |
---|
| 325 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 326 | -> |
---|
| 327 | cb_menuEditUndo_i(o,v); |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | //--------------------------------------------------------------------------- |
---|
| 331 | // Fit Callback |
---|
| 332 | //--------------------------------------------------------------------------- |
---|
| 333 | inline void GeoMeshViewUI::cb_menuEditFit_i(fltk::Item*, void*) |
---|
| 334 | { |
---|
| 335 | geoMeshView->fit(); |
---|
| 336 | mMainWindow->redraw(); |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | void GeoMeshViewUI::cb_menuEditFit(fltk::Item* o, void* v) |
---|
| 340 | { |
---|
| 341 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 342 | -> |
---|
| 343 | cb_menuEditFit_i(o,v); |
---|
| 344 | } |
---|
| 345 | |
---|
| 346 | //--------------------------------------------------------------------------- |
---|
| 347 | // Rotate Callback |
---|
| 348 | //--------------------------------------------------------------------------- |
---|
| 349 | inline void GeoMeshViewUI::cb_menuEditRotate_i(fltk::Item *item, void*) |
---|
| 350 | { |
---|
| 351 | // If the item is activated. |
---|
| 352 | if (item->value()) |
---|
| 353 | { |
---|
| 354 | menuEditPan->clear_value(); |
---|
| 355 | geoMeshView->deactivePan(); |
---|
| 356 | |
---|
| 357 | geoMeshView->activeRotate(); |
---|
| 358 | } |
---|
| 359 | else |
---|
| 360 | { |
---|
| 361 | menuEditPan->set_value(); |
---|
| 362 | geoMeshView->activePan(); |
---|
| 363 | |
---|
| 364 | geoMeshView->deactiveRotate(); |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | // Repaint the main window. |
---|
| 368 | mMainWindow->redraw(); |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | void GeoMeshViewUI::cb_menuEditRotate(fltk::Item* o, void* v) |
---|
| 372 | { |
---|
| 373 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 374 | -> |
---|
| 375 | cb_menuEditRotate_i(o,v); |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | //--------------------------------------------------------------------------- |
---|
| 379 | // Pan Callback |
---|
| 380 | //--------------------------------------------------------------------------- |
---|
| 381 | inline void GeoMeshViewUI::cb_menuEditPan_i(fltk::Item *item, void*) |
---|
| 382 | { |
---|
| 383 | // If the item is activated. |
---|
| 384 | if (item->value()) |
---|
| 385 | { |
---|
| 386 | geoMeshView->activePan(); |
---|
| 387 | |
---|
| 388 | menuEditRotate->clear_value(); |
---|
| 389 | geoMeshView->deactiveRotate(); |
---|
| 390 | } |
---|
| 391 | else |
---|
| 392 | { |
---|
| 393 | geoMeshView->deactivePan(); |
---|
| 394 | |
---|
| 395 | menuEditRotate->set_value(); |
---|
| 396 | geoMeshView->activeRotate(); |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | // Repaint the main window. |
---|
| 400 | mMainWindow->redraw(); |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | void GeoMeshViewUI::cb_menuEditPan(fltk::Item* o, void* v) |
---|
| 404 | { |
---|
| 405 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 406 | -> |
---|
| 407 | cb_menuEditPan_i(o,v); |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | //--------------------------------------------------------------------------- |
---|
| 411 | // Zoom Callback |
---|
| 412 | //--------------------------------------------------------------------------- |
---|
| 413 | inline void GeoMeshViewUI::cb_menuEditZoom_i(fltk::Item*, void*) |
---|
| 414 | { |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | void GeoMeshViewUI::cb_menuEditZoom(fltk::Item* o, void* v) |
---|
| 418 | { |
---|
| 419 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 420 | -> |
---|
| 421 | cb_menuEditZoom_i(o,v); |
---|
| 422 | } |
---|
| 423 | |
---|
| 424 | //--------------------------------------------------------------------------- |
---|
| 425 | // Wire Callback |
---|
| 426 | //--------------------------------------------------------------------------- |
---|
| 427 | inline void GeoMeshViewUI::cb_menuRenderWire_i(fltk::Item *item, void*) |
---|
| 428 | { |
---|
| 429 | if (item->value()) |
---|
| 430 | { |
---|
| 431 | geoMeshView->activeWire(); |
---|
| 432 | } |
---|
| 433 | else |
---|
| 434 | { |
---|
| 435 | geoMeshView->deactiveWire(); |
---|
| 436 | } |
---|
| 437 | |
---|
| 438 | // Repaint the canvas. |
---|
| 439 | //geoMeshView->redraw(); |
---|
| 440 | |
---|
| 441 | // Repaint the main window. |
---|
| 442 | mMainWindow->redraw(); |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | void GeoMeshViewUI::cb_menuRenderWire(fltk::Item* o, void* v) |
---|
| 446 | { |
---|
| 447 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 448 | -> |
---|
| 449 | cb_menuRenderWire_i(o,v); |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | //--------------------------------------------------------------------------- |
---|
| 453 | // Solid Callback |
---|
| 454 | //--------------------------------------------------------------------------- |
---|
| 455 | inline void GeoMeshViewUI::cb_menuRenderSolid_i(fltk::Item *item, void*) |
---|
| 456 | { |
---|
| 457 | if (item->value()) |
---|
| 458 | { |
---|
| 459 | geoMeshView->activeSolid(); |
---|
| 460 | } |
---|
| 461 | else |
---|
| 462 | { |
---|
| 463 | geoMeshView->deactiveSolid(); |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | // Repaint the canvas. |
---|
| 467 | //geoMeshView->redraw(); |
---|
| 468 | |
---|
| 469 | // Repaint the main window. |
---|
| 470 | mMainWindow->redraw(); |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | void GeoMeshViewUI::cb_menuRenderSolid(fltk::Item* o, void* v) |
---|
| 474 | { |
---|
| 475 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 476 | -> |
---|
| 477 | cb_menuRenderSolid_i(o,v); |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | //--------------------------------------------------------------------------- |
---|
| 481 | // CW callback |
---|
| 482 | //--------------------------------------------------------------------------- |
---|
| 483 | inline void GeoMeshViewUI::cb_menuRenderCW_i(fltk::Item *item, void*) |
---|
| 484 | { |
---|
| 485 | // Clear the CCW state. |
---|
| 486 | menuRenderCCW->clear_value(); |
---|
| 487 | geoMeshView->deactiveCCW(); |
---|
| 488 | |
---|
| 489 | // If the item is activated. |
---|
| 490 | if (item->value()) |
---|
| 491 | { |
---|
| 492 | geoMeshView->activeCW(); |
---|
| 493 | } |
---|
| 494 | else |
---|
| 495 | { |
---|
| 496 | geoMeshView->deactiveCW(); |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | // Repaint the main window. |
---|
| 500 | mMainWindow->redraw(); |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | void GeoMeshViewUI::cb_menuRenderCW(fltk::Item* o, void* v) |
---|
| 504 | { |
---|
| 505 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 506 | -> |
---|
| 507 | cb_menuRenderCW_i(o,v); |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | //--------------------------------------------------------------------------- |
---|
| 511 | // CCW callback |
---|
| 512 | //--------------------------------------------------------------------------- |
---|
| 513 | inline void GeoMeshViewUI::cb_menuRenderCCW_i(fltk::Item *item, void*) |
---|
| 514 | { |
---|
| 515 | // Clear the CW state. |
---|
| 516 | menuRenderCW->clear_value(); |
---|
| 517 | geoMeshView->deactiveCW(); |
---|
| 518 | |
---|
| 519 | // If the item is activated. |
---|
| 520 | if (item->value()) |
---|
| 521 | { |
---|
| 522 | geoMeshView->activeCCW(); |
---|
| 523 | } |
---|
| 524 | else |
---|
| 525 | { |
---|
| 526 | geoMeshView->deactiveCCW(); |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | // Repaint the main window. |
---|
| 530 | mMainWindow->redraw(); |
---|
| 531 | } |
---|
| 532 | |
---|
| 533 | void GeoMeshViewUI::cb_menuRenderCCW(fltk::Item* o, void* v) |
---|
| 534 | { |
---|
| 535 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 536 | -> |
---|
| 537 | cb_menuRenderCCW_i(o,v); |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | //--------------------------------------------------------------------------- |
---|
| 541 | // Flat callback |
---|
| 542 | //--------------------------------------------------------------------------- |
---|
| 543 | inline void GeoMeshViewUI::cb_menuRenderFlat_i(fltk::Item*, void*) |
---|
| 544 | { |
---|
| 545 | // Deactive smooth flag. |
---|
| 546 | menuRenderSmooth->clear_value(); |
---|
| 547 | |
---|
| 548 | // Sets flat lighting. |
---|
| 549 | geoMeshView->flat(); |
---|
| 550 | |
---|
| 551 | // Repaint the main window. |
---|
| 552 | mMainWindow->redraw(); |
---|
| 553 | } |
---|
| 554 | |
---|
| 555 | void GeoMeshViewUI::cb_menuRenderFlat(fltk::Item* o, void* v) |
---|
| 556 | { |
---|
| 557 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 558 | -> |
---|
| 559 | cb_menuRenderFlat_i(o,v); |
---|
| 560 | } |
---|
| 561 | |
---|
| 562 | //--------------------------------------------------------------------------- |
---|
| 563 | // Smooth Callback |
---|
| 564 | //--------------------------------------------------------------------------- |
---|
| 565 | inline void GeoMeshViewUI::cb_menuRenderSmooth_i(fltk::Item*, void*) |
---|
| 566 | { |
---|
| 567 | // Deactive flat flag. |
---|
| 568 | menuRenderFlat->clear_value(); |
---|
| 569 | |
---|
| 570 | // Sets smooth lighting. |
---|
| 571 | geoMeshView->smooth(); |
---|
| 572 | |
---|
| 573 | // Repaint the main window. |
---|
| 574 | mMainWindow->redraw(); |
---|
| 575 | } |
---|
| 576 | |
---|
| 577 | void GeoMeshViewUI::cb_menuRenderSmooth(fltk::Item* o, void* v) |
---|
| 578 | { |
---|
| 579 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 580 | -> |
---|
| 581 | cb_menuRenderSmooth_i(o,v); |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | //--------------------------------------------------------------------------- |
---|
| 585 | // Textures callback |
---|
| 586 | //--------------------------------------------------------------------------- |
---|
| 587 | inline void GeoMeshViewUI::cb_menuRenderTextures_i(fltk::Item*, void*) |
---|
| 588 | { |
---|
| 589 | // Repaint the main window. |
---|
| 590 | mMainWindow->redraw(); |
---|
| 591 | if (geoMeshView->isTextureMappingEnabled()) |
---|
| 592 | geoMeshView->disableTextureMapping(); |
---|
| 593 | else |
---|
| 594 | geoMeshView->enableTextureMapping(); |
---|
| 595 | } |
---|
| 596 | |
---|
| 597 | void GeoMeshViewUI::cb_menuRenderTextures(fltk::Item* o, void* v) |
---|
| 598 | { |
---|
| 599 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 600 | -> |
---|
| 601 | cb_menuRenderTextures_i(o,v); |
---|
| 602 | } |
---|
| 603 | |
---|
| 604 | //--------------------------------------------------------------------------- |
---|
| 605 | // Stripify Callback |
---|
| 606 | //--------------------------------------------------------------------------- |
---|
| 607 | inline void GeoMeshViewUI::cb_menuStripify_i(fltk::Item*, void*) |
---|
| 608 | { |
---|
| 609 | // Show title. |
---|
| 610 | mProcessTitle->label("Stripify"); |
---|
| 611 | mProcessBar->position(0); |
---|
| 612 | |
---|
| 613 | // Hide the right panel. |
---|
| 614 | hideRightPanel(); |
---|
| 615 | |
---|
| 616 | // Show the stripify panel. |
---|
| 617 | showStripify(); |
---|
| 618 | |
---|
| 619 | // Sets menus application state to STRIPIFY. |
---|
| 620 | mApplicationState = STRIPIFY; |
---|
| 621 | |
---|
| 622 | // Repaint the window. |
---|
| 623 | mMainWindow->redraw(); |
---|
| 624 | } |
---|
| 625 | |
---|
| 626 | void GeoMeshViewUI::cb_menuStripify(fltk::Item* o, void* v) |
---|
| 627 | { |
---|
| 628 | ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) |
---|
| 629 | -> |
---|
| 630 | cb_menuStripify_i(o,v); |
---|
| 631 | } |
---|
| 632 | |
---|
| 633 | //--------------------------------------------------------------------------- |
---|
| 634 | // Simplify Callback |
---|
| 635 | //--------------------------------------------------------------------------- |
---|
| 636 | inline void GeoMeshViewUI::cb_menuSimplify_i(fltk::ItemGroup*, void*) |
---|
| 637 | { |
---|
| 638 | } |
---|
| 639 | |
---|
| 640 | void GeoMeshViewUI::cb_menuSimplify(fltk::ItemGroup* o, void* v) |
---|
| 641 | { |
---|
| 642 | ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) |
---|
| 643 | -> |
---|
| 644 | cb_menuSimplify_i(o,v); |
---|
| 645 | } |
---|
| 646 | |
---|
| 647 | //--------------------------------------------------------------------------- |
---|
| 648 | // Edge collapse Callback |
---|
| 649 | //--------------------------------------------------------------------------- |
---|
| 650 | inline void GeoMeshViewUI::cb_menuSimplifyEdgeCollapse_i(fltk::Item*, void*) |
---|
| 651 | { |
---|
| 652 | // Show title. |
---|
| 653 | mProcessTitle->label("Mesh Simplification"); |
---|
| 654 | mProcessBar->position(0); |
---|
| 655 | |
---|
| 656 | // Hide the right panel. |
---|
| 657 | hideRightPanel(); |
---|
| 658 | |
---|
| 659 | // Show the edge collapse panel. |
---|
| 660 | showEdgeCollapse(); |
---|
| 661 | |
---|
| 662 | // Sets menus application state to EDGE_COLLAPSE. |
---|
| 663 | mApplicationState = EDGE_COLLAPSE; |
---|
| 664 | |
---|
| 665 | // Repaint the window. |
---|
| 666 | mMainWindow->redraw(); |
---|
| 667 | |
---|
| 668 | } |
---|
| 669 | |
---|
| 670 | void GeoMeshViewUI::cb_menuSimplifyEdgeCollapse(fltk::Item* o, void* v) |
---|
| 671 | { |
---|
| 672 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 673 | -> |
---|
| 674 | cb_menuSimplifyEdgeCollapse_i(o,v); |
---|
| 675 | } |
---|
| 676 | |
---|
| 677 | //--------------------------------------------------------------------------- |
---|
| 678 | // Leaves collapse Callback |
---|
| 679 | //--------------------------------------------------------------------------- |
---|
| 680 | inline void GeoMeshViewUI::cb_menuSimplifyLeavesCollapse_i(fltk::Item*, void*) |
---|
| 681 | { |
---|
| 682 | // Show title. |
---|
| 683 | mProcessTitle->label("Leaves Simplification"); |
---|
| 684 | mProcessBar->position(0); |
---|
| 685 | |
---|
| 686 | // Hide the right panel. |
---|
| 687 | hideRightPanel(); |
---|
| 688 | |
---|
| 689 | // Show the leaves collapse panel. |
---|
| 690 | showLeavesCollapse(); |
---|
| 691 | |
---|
| 692 | // Sets menus application state to LEAVES_COLLAPSE. |
---|
| 693 | mApplicationState = LEAVES_COLLAPSE; |
---|
| 694 | |
---|
| 695 | // Repaint the window. |
---|
| 696 | mMainWindow->redraw(); |
---|
| 697 | } |
---|
| 698 | |
---|
| 699 | void GeoMeshViewUI::cb_menuSimplifyLeavesCollapse(fltk::Item* o, void* v) |
---|
| 700 | { |
---|
| 701 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 702 | -> |
---|
| 703 | cb_menuSimplifyLeavesCollapse_i(o,v); |
---|
| 704 | } |
---|
| 705 | |
---|
| 706 | //--------------------------------------------------------------------------- |
---|
| 707 | // Tree select leaves simplification Callback |
---|
| 708 | //--------------------------------------------------------------------------- |
---|
| 709 | inline void GeoMeshViewUI::cb_menuSelectLeaves_i(fltk::Item*, void*) |
---|
| 710 | { |
---|
| 711 | // Show title. |
---|
| 712 | mProcessTitle->label("Select Leaves"); |
---|
| 713 | |
---|
| 714 | showMeshInfo(); |
---|
| 715 | mButtonProcess->show(); |
---|
| 716 | mButtonProcess->activate(); |
---|
| 717 | mApplicationState = SELECT_LEAVES; |
---|
| 718 | } |
---|
| 719 | |
---|
| 720 | void GeoMeshViewUI::cb_menuSelectLeaves(fltk::Item* o, void* v) |
---|
| 721 | { |
---|
| 722 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 723 | -> |
---|
| 724 | cb_menuSelectLeaves_i(o,v); |
---|
| 725 | } |
---|
| 726 | |
---|
| 727 | //--------------------------------------------------------------------------- |
---|
| 728 | // Auto Generate LodStrips Callback |
---|
| 729 | //--------------------------------------------------------------------------- |
---|
| 730 | inline void GeoMeshViewUI::cb_menuLodStripsGenerate_i(fltk::Item*, void*) |
---|
| 731 | { |
---|
| 732 | // Show title. |
---|
| 733 | mProcessTitle->label("Generate LodStrips"); |
---|
| 734 | mProcessBar->position(0); |
---|
| 735 | mBuildBar->position(0); |
---|
| 736 | |
---|
| 737 | // Hide the right panel. |
---|
| 738 | hideRightPanel(); |
---|
| 739 | |
---|
| 740 | // Show the LodStrips panel. |
---|
| 741 | showAutoGenerateLodStrips(); |
---|
| 742 | |
---|
| 743 | // Sets menus application state to LODSTRIPS_AUTO. |
---|
| 744 | mApplicationState = LODSTRIPS_AUTO; |
---|
| 745 | |
---|
| 746 | // Repaint the window. |
---|
| 747 | mMainWindow->redraw(); |
---|
| 748 | } |
---|
| 749 | |
---|
| 750 | void GeoMeshViewUI::cb_menuLodStripsGenerate(fltk::Item* o, void* v) |
---|
| 751 | { |
---|
| 752 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 753 | -> |
---|
| 754 | cb_menuLodStripsGenerate_i(o,v); |
---|
| 755 | } |
---|
| 756 | |
---|
| 757 | //--------------------------------------------------------------------------- |
---|
| 758 | // Auto Generate LodStrips Callback |
---|
| 759 | //--------------------------------------------------------------------------- |
---|
| 760 | inline void GeoMeshViewUI::cb_menuLodTreesGenerate_i(fltk::Item*, void*) |
---|
| 761 | { |
---|
| 762 | // Show title. |
---|
| 763 | mProcessTitle->label("Generate LodTree"); |
---|
| 764 | mProcessBar->position(0); |
---|
| 765 | mBuildBar->position(0); |
---|
| 766 | |
---|
| 767 | // Hide the right panel. |
---|
| 768 | hideRightPanel(); |
---|
| 769 | |
---|
| 770 | // Show the LodStrips panel. |
---|
| 771 | showAutoGenerateLodTrees(); |
---|
| 772 | |
---|
| 773 | // Sets menus application state to LODSTRIPS_AUTO. |
---|
| 774 | mApplicationState = LODTREES_AUTO; |
---|
| 775 | |
---|
| 776 | // Repaint the window. |
---|
| 777 | mMainWindow->redraw(); |
---|
| 778 | } |
---|
| 779 | |
---|
| 780 | void GeoMeshViewUI::cb_menuLodTreesGenerate(fltk::Item* o, void* v) |
---|
| 781 | { |
---|
| 782 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 783 | -> |
---|
| 784 | cb_menuLodTreesGenerate_i(o,v); |
---|
| 785 | } |
---|
| 786 | |
---|
| 787 | |
---|
| 788 | //--------------------------------------------------------------------------- |
---|
| 789 | // Visualize LodStrips Callback |
---|
| 790 | //--------------------------------------------------------------------------- |
---|
| 791 | inline void GeoMeshViewUI::cb_menuLodStripsVisualize_i(fltk::Item*, void*) |
---|
| 792 | { |
---|
| 793 | fltk::FileChooser *fcho; |
---|
| 794 | const char *lod_file; |
---|
| 795 | |
---|
| 796 | // Sets menus application state to NONE. |
---|
| 797 | mApplicationState = NONE; |
---|
| 798 | |
---|
| 799 | // Deactive Lod strip visualization. |
---|
| 800 | geoMeshView->deactiveLodStrip(); |
---|
| 801 | geoMeshView->deactiveLodTree(); |
---|
| 802 | |
---|
| 803 | // Loads a mesh file. |
---|
| 804 | openMeshFile(); |
---|
| 805 | |
---|
| 806 | |
---|
| 807 | // If an object is loaded. |
---|
| 808 | if (mGeoMesh != NULL) |
---|
| 809 | { |
---|
| 810 | fcho = new fltk::FileChooser("", |
---|
| 811 | "*.lod", |
---|
| 812 | fltk::FileChooser::CREATE, |
---|
| 813 | "Open Lod file"); |
---|
| 814 | |
---|
| 815 | fcho->exec(); |
---|
| 816 | |
---|
| 817 | // If a file was selected. |
---|
| 818 | if (fcho->value()) |
---|
| 819 | { |
---|
| 820 | // Build lod strips library. |
---|
| 821 | setLodStripsLibrary(string(fcho->value()), mGeoMesh); |
---|
| 822 | |
---|
| 823 | // Sets the aplication mode. |
---|
| 824 | mApplicationState = VISUALIZE_LODSTRIPS; |
---|
| 825 | } |
---|
| 826 | |
---|
| 827 | // Free memory. |
---|
| 828 | delete fcho; |
---|
| 829 | |
---|
| 830 | // Hide the right panel. |
---|
| 831 | hideRightPanel(); |
---|
| 832 | |
---|
| 833 | // Show title. |
---|
| 834 | mProcessTitle->label("Visualize LodStrips"); |
---|
| 835 | |
---|
| 836 | // Show the Visulize LodStrips panel. |
---|
| 837 | showLodStripSlider(); |
---|
| 838 | |
---|
| 839 | // Repaint the window. |
---|
| 840 | mMainWindow->redraw(); |
---|
| 841 | |
---|
| 842 | } |
---|
| 843 | } |
---|
| 844 | |
---|
| 845 | inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) |
---|
| 846 | { |
---|
| 847 | fltk::FileChooser *fcho; |
---|
| 848 | const char *lod_file; |
---|
| 849 | |
---|
| 850 | // Sets menus application state to NONE. |
---|
| 851 | mApplicationState = NONE; |
---|
| 852 | |
---|
| 853 | // Deactive Lod strip visualization. |
---|
| 854 | geoMeshView->deactiveLodTree(); |
---|
| 855 | geoMeshView->deactiveLodStrip(); |
---|
| 856 | |
---|
| 857 | // Loads a mesh file. |
---|
| 858 | openMeshFile(); |
---|
| 859 | |
---|
| 860 | /*if (geoMeshView->getLeavesSubmesh()==-1) |
---|
| 861 | { |
---|
| 862 | fltk::alert("No se ha seleccionado el submesh de hojas!"); |
---|
| 863 | return; |
---|
| 864 | }*/ |
---|
| 865 | |
---|
| 866 | // If an object is loaded. |
---|
| 867 | if (mGeoMesh != NULL) |
---|
| 868 | { |
---|
| 869 | // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS |
---|
| 870 | int leafsSubMeshID = -1; |
---|
| 871 | |
---|
| 872 | for (int i=0; i<mGeoMesh->mSubMeshCount; i++) |
---|
| 873 | { |
---|
| 874 | if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) |
---|
| 875 | { |
---|
| 876 | leafsSubMeshID=i; |
---|
| 877 | break; |
---|
| 878 | } |
---|
| 879 | } |
---|
| 880 | |
---|
| 881 | // If an object is loaded. |
---|
| 882 | if (mGeoMesh != NULL) |
---|
| 883 | { |
---|
| 884 | fcho = new fltk::FileChooser("", |
---|
| 885 | "*.lod", |
---|
| 886 | fltk::FileChooser::CREATE, |
---|
| 887 | "Open Lod file"); |
---|
| 888 | |
---|
| 889 | fcho->exec(); |
---|
| 890 | |
---|
| 891 | // If a file was selected. |
---|
| 892 | if (fcho->value()) |
---|
| 893 | { |
---|
| 894 | // Build lod strips library. |
---|
| 895 | |
---|
| 896 | std::string lodstripFile(fcho->value()); |
---|
| 897 | delete fcho; |
---|
| 898 | fcho = new fltk::FileChooser("", |
---|
| 899 | "*.leafseq", |
---|
| 900 | fltk::FileChooser::CREATE, |
---|
| 901 | "Open LeafSeq file"); |
---|
| 902 | |
---|
| 903 | fcho->exec(); |
---|
| 904 | |
---|
| 905 | if (fcho->value()) |
---|
| 906 | { |
---|
| 907 | std::string leafseqFile(fcho->value()); |
---|
| 908 | |
---|
| 909 | setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); |
---|
| 910 | |
---|
| 911 | // Sets the aplication mode. |
---|
| 912 | mApplicationState = VISUALIZE_LODTREES; |
---|
| 913 | } |
---|
| 914 | } |
---|
| 915 | |
---|
| 916 | // Free memory. |
---|
| 917 | delete fcho; |
---|
| 918 | |
---|
| 919 | // Hide the right panel. |
---|
| 920 | hideRightPanel(); |
---|
| 921 | |
---|
| 922 | // Show title. |
---|
| 923 | mProcessTitle->label("Visualize LodTrees"); |
---|
| 924 | |
---|
| 925 | // Show the Visulize LodTree panel. |
---|
| 926 | showLodStripSlider(); |
---|
| 927 | showLodTreeSlider(); |
---|
| 928 | |
---|
| 929 | // Repaint the window. |
---|
| 930 | mMainWindow->redraw(); |
---|
| 931 | } |
---|
| 932 | } |
---|
| 933 | } |
---|
| 934 | |
---|
| 935 | void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) |
---|
| 936 | { |
---|
| 937 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 938 | -> |
---|
| 939 | cb_menuLodTreesVisualize_i(o,v); |
---|
| 940 | } |
---|
| 941 | |
---|
| 942 | void GeoMeshViewUI::cb_menuLodStripsVisualize(fltk::Item* o, void* v) |
---|
| 943 | { |
---|
| 944 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 945 | -> |
---|
| 946 | cb_menuLodStripsVisualize_i(o,v); |
---|
| 947 | } |
---|
| 948 | |
---|
| 949 | //--------------------------------------------------------------------------- |
---|
| 950 | // Open LodStrip trunk Callback |
---|
| 951 | //--------------------------------------------------------------------------- |
---|
| 952 | inline void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*) |
---|
| 953 | { |
---|
| 954 | } |
---|
| 955 | |
---|
| 956 | void GeoMeshViewUI::cb_menuLodTreesOpenLodStripTrunk(fltk::Item* o, void* v) |
---|
| 957 | { |
---|
| 958 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 959 | -> |
---|
| 960 | cb_menuLodTreesOpenLodStripTrunk_i(o,v); |
---|
| 961 | } |
---|
| 962 | |
---|
| 963 | //--------------------------------------------------------------------------- |
---|
| 964 | // Open leaves simplification Callback |
---|
| 965 | //--------------------------------------------------------------------------- |
---|
| 966 | inline void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*) |
---|
| 967 | { |
---|
| 968 | // Hide the right panel. |
---|
| 969 | hideRightPanel(); |
---|
| 970 | |
---|
| 971 | // Show the LodTrees panel. |
---|
| 972 | showOpenLeavesSimplification(); |
---|
| 973 | |
---|
| 974 | // Sets menus application state to LODTREES. |
---|
| 975 | mApplicationState = LODTREES; |
---|
| 976 | |
---|
| 977 | // Repaint the window. |
---|
| 978 | mMainWindow->redraw(); |
---|
| 979 | } |
---|
| 980 | |
---|
| 981 | void GeoMeshViewUI::cb_menuLodTreesOpenLeavesSimplification(fltk::Item* o, void* v) |
---|
| 982 | { |
---|
| 983 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 984 | -> |
---|
| 985 | cb_menuLodTreesOpenLeavesSimplification_i(o,v); |
---|
| 986 | } |
---|
| 987 | |
---|
| 988 | |
---|
| 989 | |
---|
| 990 | //--------------------------------------------------------------------------- |
---|
| 991 | // About Callback |
---|
| 992 | //--------------------------------------------------------------------------- |
---|
| 993 | inline void GeoMeshViewUI::cb_menuHelpAbout_i(fltk::Item*, void*) |
---|
| 994 | { |
---|
| 995 | new GTAboutDialog(); |
---|
| 996 | } |
---|
| 997 | |
---|
| 998 | void GeoMeshViewUI::cb_menuHelpAbout(fltk::Item* o, void* v) |
---|
| 999 | { |
---|
| 1000 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 1001 | -> |
---|
| 1002 | cb_menuHelpAbout_i(o,v); |
---|
| 1003 | } |
---|
| 1004 | |
---|
| 1005 | //--------------------------------------------------------------------------- |
---|
| 1006 | // Button Process Callback |
---|
| 1007 | //--------------------------------------------------------------------------- |
---|
| 1008 | inline void GeoMeshViewUI::cb_mButtonProcess_i(fltk::Button*, void*) |
---|
| 1009 | { |
---|
| 1010 | bool error; |
---|
| 1011 | Mesh *mesh_aux; |
---|
| 1012 | |
---|
| 1013 | // Sets the progress bar to process bar. |
---|
| 1014 | progressBarType = PROCESS; |
---|
| 1015 | mProcessBar->position(0); |
---|
| 1016 | |
---|
| 1017 | // Initialize error flag. |
---|
| 1018 | error = false; |
---|
| 1019 | |
---|
| 1020 | // If there is a mesh object. |
---|
| 1021 | if (mGeoMesh != NULL) |
---|
| 1022 | { |
---|
| 1023 | // Choose between aplication state. |
---|
| 1024 | switch(mApplicationState) |
---|
| 1025 | { |
---|
| 1026 | // Stripify state. |
---|
| 1027 | case STRIPIFY: |
---|
| 1028 | |
---|
| 1029 | // Stripify the mesh object. |
---|
| 1030 | stripify(); |
---|
| 1031 | |
---|
| 1032 | break; |
---|
| 1033 | |
---|
| 1034 | // Simplify edge collapse state. |
---|
| 1035 | case EDGE_COLLAPSE: |
---|
| 1036 | |
---|
| 1037 | // Check submeshes for triangles strips. |
---|
| 1038 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
| 1039 | { |
---|
| 1040 | // If current submesh is in triangle strips. |
---|
| 1041 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
| 1042 | { |
---|
| 1043 | error = true; |
---|
| 1044 | } |
---|
| 1045 | } |
---|
| 1046 | |
---|
| 1047 | // if the mesh is stripified. |
---|
| 1048 | if (error) |
---|
| 1049 | { |
---|
| 1050 | fltk::alert("Can't simplify a mesh in triagle strips."); |
---|
| 1051 | } |
---|
| 1052 | else |
---|
| 1053 | { |
---|
| 1054 | // Simplify the mesh object. |
---|
| 1055 | if(simplifyEdgeCollapse()) |
---|
| 1056 | { |
---|
| 1057 | delete mMeshSimplifier; |
---|
| 1058 | geoMeshView->restoreContext(); |
---|
| 1059 | } |
---|
| 1060 | } |
---|
| 1061 | break; |
---|
| 1062 | |
---|
| 1063 | // Simplify leaves |
---|
| 1064 | case LEAVES_COLLAPSE: |
---|
| 1065 | |
---|
| 1066 | // Simplify the mesh object. |
---|
| 1067 | simplifyLeavesCollapse(); |
---|
| 1068 | |
---|
| 1069 | // Create the leaves simplification sequence. |
---|
| 1070 | createLeavesSequence("leavesSimplification.txt"); |
---|
| 1071 | |
---|
| 1072 | break; |
---|
| 1073 | |
---|
| 1074 | // Simplify and generate simplification sequence. |
---|
| 1075 | case LODTREES_AUTO: |
---|
| 1076 | if (idMeshLeaves==(unsigned short)-1) |
---|
| 1077 | { |
---|
| 1078 | fltk::alert("Leaves submesh not selected!"); |
---|
| 1079 | } |
---|
| 1080 | else |
---|
| 1081 | { |
---|
| 1082 | std::cout << "Simplificando hojas..."; |
---|
| 1083 | simplifyLeavesCollapse(); |
---|
| 1084 | std::cout << "OK!" << std::endl; |
---|
| 1085 | |
---|
| 1086 | // std::cout << "Creando secuencia de simplificacion de hojas..."; |
---|
| 1087 | // createLeavesSequence("leavesSimplification.txt"); |
---|
| 1088 | // std::cout << "OK!" << std::endl; |
---|
| 1089 | |
---|
| 1090 | undo(); |
---|
| 1091 | |
---|
| 1092 | |
---|
| 1093 | std::cout << "Simplificando tronco..."; |
---|
| 1094 | std::cout << "OK!" << std::endl; |
---|
| 1095 | |
---|
| 1096 | // Transform NoSV Mesh to a SV Mesh. |
---|
| 1097 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
| 1098 | |
---|
| 1099 | // Deletes the mesh No Shared Vertex. |
---|
| 1100 | delete mGeoMesh; |
---|
| 1101 | |
---|
| 1102 | // Gets the mesh Shared Vertex. |
---|
| 1103 | mGeoMesh = mesh_aux; |
---|
| 1104 | |
---|
| 1105 | geoMeshView->setMesh(mGeoMesh); |
---|
| 1106 | |
---|
| 1107 | // Simplify the mesh object. |
---|
| 1108 | if (simplifyEdgeCollapse()) |
---|
| 1109 | { |
---|
| 1110 | // Create the simplification sequence. |
---|
| 1111 | createSimplificationSequence(); |
---|
| 1112 | |
---|
| 1113 | // Show build process. |
---|
| 1114 | activeBuildProcess(); |
---|
| 1115 | } |
---|
| 1116 | |
---|
| 1117 | } |
---|
| 1118 | |
---|
| 1119 | break; |
---|
| 1120 | |
---|
| 1121 | case LODSTRIPS_AUTO: |
---|
| 1122 | |
---|
| 1123 | // Check submeshes for triangles strips. |
---|
| 1124 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
| 1125 | { |
---|
| 1126 | // If current submesh is in triangle strips. |
---|
| 1127 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
| 1128 | { |
---|
| 1129 | error = true; |
---|
| 1130 | } |
---|
| 1131 | } |
---|
| 1132 | |
---|
| 1133 | // if the mesh is stripified. |
---|
| 1134 | if (error) |
---|
| 1135 | { |
---|
| 1136 | fltk::alert("Can't simplify a mesh in triagle strips."); |
---|
| 1137 | } |
---|
| 1138 | else |
---|
| 1139 | { |
---|
| 1140 | // Transform NoSV Mesh to a SV Mesh. |
---|
| 1141 | mesh_aux = mGeoMesh->toSharedVertex(); |
---|
| 1142 | |
---|
| 1143 | // Deletes the mesh No Shared Vertex. |
---|
| 1144 | delete mGeoMesh; |
---|
| 1145 | |
---|
| 1146 | // Gets the mesh Shared Vertex. |
---|
| 1147 | mGeoMesh = mesh_aux; |
---|
| 1148 | |
---|
| 1149 | // Visualize mesh. |
---|
| 1150 | geoMeshView->setMesh(mGeoMesh); |
---|
| 1151 | |
---|
| 1152 | // Simplify the mesh object. |
---|
| 1153 | if (simplifyEdgeCollapse()) |
---|
| 1154 | { |
---|
| 1155 | // Create the simplification sequence. |
---|
| 1156 | createSimplificationSequence(); |
---|
| 1157 | |
---|
| 1158 | delete mMeshSimplifier; |
---|
| 1159 | geoMeshView->restoreContext(); |
---|
| 1160 | |
---|
| 1161 | // Show build process. |
---|
| 1162 | activeBuildProcess(); |
---|
| 1163 | } |
---|
| 1164 | } |
---|
| 1165 | |
---|
| 1166 | break; |
---|
| 1167 | |
---|
| 1168 | // Añadido 23-12-2005 |
---|
| 1169 | case SELECT_LEAVES: |
---|
| 1170 | |
---|
| 1171 | idMeshLeaves = paintMesh(); |
---|
| 1172 | |
---|
| 1173 | // Set the leaves submesh. |
---|
| 1174 | geoMeshView->setLeavesSubMesh(idMeshLeaves); |
---|
| 1175 | |
---|
| 1176 | // Refresh mesh info. |
---|
| 1177 | showMeshInfo(); |
---|
| 1178 | |
---|
| 1179 | break; |
---|
| 1180 | } |
---|
| 1181 | |
---|
| 1182 | // Refresh geometry attributes. |
---|
| 1183 | refreshApplicationBar(); |
---|
| 1184 | } |
---|
| 1185 | |
---|
| 1186 | // Repaint the GL Window. |
---|
| 1187 | mMainWindow->redraw(); |
---|
| 1188 | } |
---|
| 1189 | |
---|
| 1190 | void GeoMeshViewUI::cb_mButtonProcess(fltk::Button* o, void* v) |
---|
| 1191 | { |
---|
| 1192 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 1193 | -> |
---|
| 1194 | cb_mButtonProcess_i(o,v); |
---|
| 1195 | } |
---|
| 1196 | |
---|
| 1197 | //--------------------------------------------------------------------------- |
---|
| 1198 | // Button Sort Callback |
---|
| 1199 | //--------------------------------------------------------------------------- |
---|
| 1200 | inline void GeoMeshViewUI::cb_mButtonSort_i(fltk::Button*, void*) |
---|
| 1201 | { |
---|
| 1202 | } |
---|
| 1203 | |
---|
| 1204 | void GeoMeshViewUI::cb_mButtonSort(fltk::Button* o, void* v) |
---|
| 1205 | { |
---|
| 1206 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 1207 | -> |
---|
| 1208 | cb_mButtonSort_i(o,v); |
---|
| 1209 | } |
---|
| 1210 | |
---|
| 1211 | //--------------------------------------------------------------------------- |
---|
| 1212 | // Button Build Callback |
---|
| 1213 | //--------------------------------------------------------------------------- |
---|
| 1214 | inline void GeoMeshViewUI::cb_mButtonBuild_i(fltk::Button*, void*) |
---|
| 1215 | { |
---|
| 1216 | char *file_name = NULL; |
---|
| 1217 | GeoMeshSaver *mesh_saver; |
---|
| 1218 | Serializer *oSerializer; |
---|
| 1219 | |
---|
| 1220 | // Sets the progress bar to process bar. |
---|
| 1221 | progressBarType = BUILD; |
---|
| 1222 | |
---|
| 1223 | // Reset the build bar. |
---|
| 1224 | mBuildBar->position(0); |
---|
| 1225 | |
---|
| 1226 | // If there is a mesh object. |
---|
| 1227 | if (mGeoMesh != NULL) |
---|
| 1228 | { |
---|
| 1229 | // Choose between aplication state. |
---|
| 1230 | switch(mApplicationState) |
---|
| 1231 | { |
---|
| 1232 | // Build the LOD file. |
---|
| 1233 | case LODTREES_AUTO: |
---|
| 1234 | |
---|
| 1235 | // Open file chooser dialog. |
---|
| 1236 | file_name = fltk::file_chooser("Build LOD","*",""); |
---|
| 1237 | if (!file_name) |
---|
| 1238 | break; |
---|
| 1239 | |
---|
| 1240 | std::cout << "Creando secuencia de simplificacion de hojas..."; |
---|
| 1241 | createLeavesSequence(file_name+std::string(".leafseq")); |
---|
| 1242 | std::cout << "OK!" << std::endl; |
---|
| 1243 | |
---|
| 1244 | /* TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); |
---|
| 1245 | auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); |
---|
| 1246 | |
---|
| 1247 | if (auxTreeSimpSequence && mGeoMesh) |
---|
| 1248 | { |
---|
| 1249 | LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); |
---|
| 1250 | delete auxLodTreeConstructor; |
---|
| 1251 | } |
---|
| 1252 | else |
---|
| 1253 | { |
---|
| 1254 | fltk::alert("There is no leaf simplification sequence."); |
---|
| 1255 | break; |
---|
| 1256 | } |
---|
| 1257 | |
---|
| 1258 | |
---|
| 1259 | delete auxTreeSimpSequence;*/ |
---|
| 1260 | |
---|
| 1261 | |
---|
| 1262 | case LODSTRIPS_AUTO: |
---|
| 1263 | |
---|
| 1264 | // Builder |
---|
| 1265 | if (!file_name) |
---|
| 1266 | file_name = fltk::file_chooser("Build LOD","*",""); |
---|
| 1267 | // If a file was selected. |
---|
| 1268 | if (file_name) |
---|
| 1269 | { |
---|
| 1270 | // Undo the simplification changes. |
---|
| 1271 | undo(); |
---|
| 1272 | |
---|
| 1273 | // Stripify the mesh object. |
---|
| 1274 | stripify(); |
---|
| 1275 | |
---|
| 1276 | // Reset the build bar. |
---|
| 1277 | mBuildBar->position(0); |
---|
| 1278 | |
---|
| 1279 | // Simplification sequence. |
---|
| 1280 | oMeshSimpSequence = new MeshSimplificationSequence(); |
---|
| 1281 | |
---|
| 1282 | // Loads a simplification sequence file. |
---|
| 1283 | oMeshSimpSequence->Load(Serializer("SimplifSequence.txt",Serializer::READ)); |
---|
| 1284 | |
---|
| 1285 | // If the simplification sequence and the mesh exist. |
---|
| 1286 | if (oMeshSimpSequence && mGeoMesh) |
---|
| 1287 | { |
---|
| 1288 | oLodStrip = new LodStripsConstructor( mGeoMesh, |
---|
| 1289 | oMeshSimpSequence, |
---|
| 1290 | idMeshLeaves, |
---|
| 1291 | progress_function); |
---|
| 1292 | |
---|
| 1293 | oSerializer = new Serializer(strcat(file_name,".lod"),Serializer::Mode::WRITE); |
---|
| 1294 | |
---|
| 1295 | oLodStrip->Save(*oSerializer); |
---|
| 1296 | |
---|
| 1297 | // Close file. |
---|
| 1298 | delete oSerializer; |
---|
| 1299 | |
---|
| 1300 | // Deletes the previous mesh. |
---|
| 1301 | delete mUndoMesh; |
---|
| 1302 | |
---|
| 1303 | mUndoMesh = new Mesh(); |
---|
| 1304 | |
---|
| 1305 | // Sets the undo mesh. |
---|
| 1306 | *mUndoMesh = *mGeoMesh; |
---|
| 1307 | |
---|
| 1308 | delete mGeoMesh; |
---|
| 1309 | |
---|
| 1310 | mGeoMesh = oLodStrip->GetMesh(); |
---|
| 1311 | |
---|
| 1312 | geoMeshView->setMesh(mGeoMesh); |
---|
| 1313 | |
---|
| 1314 | mesh_saver = new GeoMeshSaver(); |
---|
| 1315 | file_name[strlen(file_name) - 4] = '\0'; |
---|
| 1316 | mesh_saver->save(mGeoMesh, strcat(file_name,".mesh")); |
---|
| 1317 | delete mesh_saver; |
---|
| 1318 | |
---|
| 1319 | } |
---|
| 1320 | else |
---|
| 1321 | { |
---|
| 1322 | // Error message. |
---|
| 1323 | fltk::alert("There is no simplification sequence."); |
---|
| 1324 | } |
---|
| 1325 | |
---|
| 1326 | // Deletes the siplification sequence object. |
---|
| 1327 | delete oMeshSimpSequence; |
---|
| 1328 | } |
---|
| 1329 | break; |
---|
| 1330 | } |
---|
| 1331 | // Refresh data aplication. |
---|
| 1332 | refreshApplicationBar(); |
---|
| 1333 | } |
---|
| 1334 | } |
---|
| 1335 | |
---|
| 1336 | void GeoMeshViewUI::cb_mButtonBuild(fltk::Button *o, void *v) |
---|
| 1337 | { |
---|
| 1338 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 1339 | -> |
---|
| 1340 | cb_mButtonBuild_i(o,v); |
---|
| 1341 | } |
---|
| 1342 | |
---|
| 1343 | //--------------------------------------------------------------------------- |
---|
| 1344 | // Lod Slider Callback |
---|
| 1345 | //--------------------------------------------------------------------------- |
---|
| 1346 | inline void GeoMeshViewUI::cb_mLodStripSlider_i(fltk::Slider *o, void *) |
---|
| 1347 | { |
---|
| 1348 | // Change the lod. |
---|
| 1349 | geoMeshView->GoToLod_LodStrip((unsigned int)o->value()); |
---|
| 1350 | |
---|
| 1351 | // Refresh data aplication. |
---|
| 1352 | refreshApplicationBar(); |
---|
| 1353 | |
---|
| 1354 | mMainWindow->flush(); |
---|
| 1355 | } |
---|
| 1356 | |
---|
| 1357 | void GeoMeshViewUI::cb_mLodStripSlider(fltk::Slider *o, void *v) |
---|
| 1358 | { |
---|
| 1359 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 1360 | -> |
---|
| 1361 | cb_mLodStripSlider_i(o,v); |
---|
| 1362 | } |
---|
| 1363 | |
---|
| 1364 | |
---|
| 1365 | //--------------------------------------------------------------------------- |
---|
| 1366 | // Lod Slider Callback for the foliage |
---|
| 1367 | //--------------------------------------------------------------------------- |
---|
| 1368 | inline void GeoMeshViewUI::cb_mLodTreeSlider_i(fltk::Slider *o, void *) |
---|
| 1369 | { |
---|
| 1370 | // Change the lod. |
---|
| 1371 | geoMeshView->GoToLod_LodTree((unsigned int)o->value()); |
---|
| 1372 | |
---|
| 1373 | // Refresh data aplication. |
---|
| 1374 | refreshApplicationBar(); |
---|
| 1375 | |
---|
| 1376 | mMainWindow->flush(); |
---|
| 1377 | } |
---|
| 1378 | |
---|
| 1379 | void GeoMeshViewUI::cb_mLodTreeSlider(fltk::Slider *o, void *v) |
---|
| 1380 | { |
---|
| 1381 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 1382 | -> |
---|
| 1383 | cb_mLodTreeSlider_i(o,v); |
---|
| 1384 | } |
---|
| 1385 | |
---|
| 1386 | |
---|
| 1387 | |
---|
| 1388 | //--------------------------------------------------------------------------- |
---|
| 1389 | // Mesh Info Callback |
---|
| 1390 | //--------------------------------------------------------------------------- |
---|
| 1391 | inline void GeoMeshViewUI::cb_mMeshInfo_i(fltk::Browser *, void *) |
---|
| 1392 | { |
---|
| 1393 | paintMesh(); |
---|
| 1394 | } |
---|
| 1395 | |
---|
| 1396 | void GeoMeshViewUI::cb_mMeshInfo(fltk::Browser* o, void* v) |
---|
| 1397 | { |
---|
| 1398 | ((GeoMeshViewUI*) (o->parent()->parent()->parent()->user_data())) |
---|
| 1399 | -> |
---|
| 1400 | cb_mMeshInfo_i(o,v); |
---|
| 1401 | } |
---|
| 1402 | |
---|
| 1403 | //--------------------------------------------------------------------------- |
---|
| 1404 | // Logo Callback |
---|
| 1405 | //--------------------------------------------------------------------------- |
---|
| 1406 | inline void GeoMeshViewUI::cb_mLogo_i(fltk::InvisibleBox*, void*) |
---|
| 1407 | { |
---|
| 1408 | } |
---|
| 1409 | |
---|
| 1410 | void GeoMeshViewUI::cb_mLogo(fltk::InvisibleBox* o, void* v) |
---|
| 1411 | { |
---|
| 1412 | ((GeoMeshViewUI*) (o->parent()->parent()->user_data())) |
---|
| 1413 | -> |
---|
| 1414 | cb_mLogo_i(o,v); |
---|
| 1415 | } |
---|
| 1416 | |
---|
| 1417 | //--------------------------------------------------------------------------- |
---|
| 1418 | // Active Build process. |
---|
| 1419 | //--------------------------------------------------------------------------- |
---|
| 1420 | void GeoMeshViewUI::activeBuildProcess() |
---|
| 1421 | { |
---|
| 1422 | //mButtonBuild->set_visible(); |
---|
| 1423 | mButtonBuild->activate(); |
---|
| 1424 | |
---|
| 1425 | //mBuildBar->set_visible(); |
---|
| 1426 | mBuildBar->activate(); |
---|
| 1427 | } |
---|
| 1428 | |
---|
| 1429 | //--------------------------------------------------------------------------- |
---|
| 1430 | // Show the stripify panel |
---|
| 1431 | //--------------------------------------------------------------------------- |
---|
| 1432 | void GeoMeshViewUI::showStripify() |
---|
| 1433 | { |
---|
| 1434 | /* |
---|
| 1435 | mTypeLabel->set_visible(); |
---|
| 1436 | mTypeLabel->activate(); |
---|
| 1437 | |
---|
| 1438 | mOneCacheStrip->set_visible(); |
---|
| 1439 | mOneCacheStrip->activate(); |
---|
| 1440 | |
---|
| 1441 | mQualityStrips->set_visible(); |
---|
| 1442 | mQualityStrips->activate(); |
---|
| 1443 | */ |
---|
| 1444 | |
---|
| 1445 | mButtonProcess->set_visible(); |
---|
| 1446 | mButtonProcess->activate(); |
---|
| 1447 | |
---|
| 1448 | mProcessBar->set_visible(); |
---|
| 1449 | mProcessBar->activate(); |
---|
| 1450 | } |
---|
| 1451 | |
---|
| 1452 | //--------------------------------------------------------------------------- |
---|
| 1453 | // Hide the stripify panel |
---|
| 1454 | //--------------------------------------------------------------------------- |
---|
| 1455 | void GeoMeshViewUI::hideStripify() |
---|
| 1456 | { |
---|
| 1457 | /* |
---|
| 1458 | mTypeLabel->hide(); |
---|
| 1459 | mTypeLabel->deactivate(); |
---|
| 1460 | */ |
---|
| 1461 | |
---|
| 1462 | mOneCacheStrip->hide(); |
---|
| 1463 | mOneCacheStrip->deactivate(); |
---|
| 1464 | |
---|
| 1465 | mQualityStrips->hide(); |
---|
| 1466 | mQualityStrips->deactivate(); |
---|
| 1467 | |
---|
| 1468 | mButtonProcess->hide(); |
---|
| 1469 | mButtonProcess->deactivate(); |
---|
| 1470 | |
---|
| 1471 | mProcessBar->hide(); |
---|
| 1472 | mProcessBar->deactivate(); |
---|
| 1473 | } |
---|
| 1474 | |
---|
| 1475 | //--------------------------------------------------------------------------- |
---|
| 1476 | // Show the Simplify Edge Collapse panel |
---|
| 1477 | //--------------------------------------------------------------------------- |
---|
| 1478 | void GeoMeshViewUI::showEdgeCollapse() |
---|
| 1479 | { |
---|
| 1480 | mMetricLabel->set_visible(); |
---|
| 1481 | mMetricLabel->activate(); |
---|
| 1482 | |
---|
| 1483 | mGeometryBased->set_visible(); |
---|
| 1484 | mGeometryBased->activate(); |
---|
| 1485 | mGeometryBased->set(); |
---|
| 1486 | |
---|
| 1487 | mViewPointDriven->set_visible(); |
---|
| 1488 | mViewPointDriven->activate(); |
---|
| 1489 | |
---|
| 1490 | /* |
---|
| 1491 | mTypeLabel->set_visible(); |
---|
| 1492 | mTypeLabel->activate(); |
---|
| 1493 | |
---|
| 1494 | mChangeVertices->set_visible(); |
---|
| 1495 | mChangeVertices->activate(); |
---|
| 1496 | */ |
---|
| 1497 | |
---|
| 1498 | mMeshReductionLabel->set_visible(); |
---|
| 1499 | mMeshReductionLabel->activate(); |
---|
| 1500 | |
---|
| 1501 | mPercent->set_visible(); |
---|
| 1502 | mPercent->activate(); |
---|
| 1503 | mPercent->set(); |
---|
| 1504 | |
---|
| 1505 | mVerticesNumber->set_visible(); |
---|
| 1506 | mVerticesNumber->activate(); |
---|
| 1507 | |
---|
| 1508 | mMeshReduction->set_visible(); |
---|
| 1509 | |
---|
| 1510 | // Allows floating point. |
---|
| 1511 | mMeshReduction->type(fltk::FloatInput::FLOAT); |
---|
| 1512 | |
---|
| 1513 | mMeshReduction->activate(); |
---|
| 1514 | |
---|
| 1515 | mButtonProcess->set_visible(); |
---|
| 1516 | mButtonProcess->activate(); |
---|
| 1517 | |
---|
| 1518 | mProcessBar->set_visible(); |
---|
| 1519 | mProcessBar->activate(); |
---|
| 1520 | } |
---|
| 1521 | |
---|
| 1522 | //--------------------------------------------------------------------------- |
---|
| 1523 | // Hide the Simplify Edge Collapse |
---|
| 1524 | //--------------------------------------------------------------------------- |
---|
| 1525 | void GeoMeshViewUI::hideEdgeCollapse() |
---|
| 1526 | { |
---|
| 1527 | mMetricLabel->hide(); |
---|
| 1528 | mMetricLabel->deactivate(); |
---|
| 1529 | |
---|
| 1530 | mGeometryBased->hide(); |
---|
| 1531 | mGeometryBased->deactivate(); |
---|
| 1532 | |
---|
| 1533 | mViewPointDriven->hide(); |
---|
| 1534 | mViewPointDriven->deactivate(); |
---|
| 1535 | |
---|
| 1536 | /* |
---|
| 1537 | mTypeLabel->hide(); |
---|
| 1538 | mTypeLabel->deactivate(); |
---|
| 1539 | |
---|
| 1540 | mChangeVertices->hide(); |
---|
| 1541 | mChangeVertices->deactivate(); |
---|
| 1542 | */ |
---|
| 1543 | |
---|
| 1544 | mMeshReductionLabel->hide(); |
---|
| 1545 | mMeshReductionLabel->deactivate(); |
---|
| 1546 | |
---|
| 1547 | mPercent->hide(); |
---|
| 1548 | mPercent->deactivate(); |
---|
| 1549 | |
---|
| 1550 | mVerticesNumber->hide(); |
---|
| 1551 | mVerticesNumber->deactivate(); |
---|
| 1552 | |
---|
| 1553 | mMeshReduction->hide(); |
---|
| 1554 | mMeshReduction->deactivate(); |
---|
| 1555 | |
---|
| 1556 | mButtonProcess->hide(); |
---|
| 1557 | mButtonProcess->deactivate(); |
---|
| 1558 | |
---|
| 1559 | mProcessBar->hide(); |
---|
| 1560 | mProcessBar->deactivate(); |
---|
| 1561 | } |
---|
| 1562 | |
---|
| 1563 | //--------------------------------------------------------------------------- |
---|
| 1564 | // Show the Simlify Leaves Collapse |
---|
| 1565 | //--------------------------------------------------------------------------- |
---|
| 1566 | void GeoMeshViewUI::showLeavesCollapse() |
---|
| 1567 | { |
---|
| 1568 | mMetricLabel->set_visible(); |
---|
| 1569 | mMetricLabel->activate(); |
---|
| 1570 | |
---|
| 1571 | mGeometryBased->set_visible(); |
---|
| 1572 | mGeometryBased->activate(); |
---|
| 1573 | mGeometryBased->set(); |
---|
| 1574 | |
---|
| 1575 | mViewPointDriven->set_visible(); |
---|
| 1576 | mViewPointDriven->activate(); |
---|
| 1577 | |
---|
| 1578 | /* |
---|
| 1579 | mTypeLabel->set_visible(); |
---|
| 1580 | mTypeLabel->activate(); |
---|
| 1581 | |
---|
| 1582 | mChangeTexture->set_visible(); |
---|
| 1583 | mChangeTexture->activate(); |
---|
| 1584 | */ |
---|
| 1585 | |
---|
| 1586 | mMeshReductionLabel->set_visible(); |
---|
| 1587 | mMeshReductionLabel->activate(); |
---|
| 1588 | |
---|
| 1589 | mPercent->set_visible(); |
---|
| 1590 | mPercent->activate(); |
---|
| 1591 | mPercent->set(); |
---|
| 1592 | |
---|
| 1593 | mVerticesNumber->set_visible(); |
---|
| 1594 | mVerticesNumber->activate(); |
---|
| 1595 | |
---|
| 1596 | mMeshReduction->set_visible(); |
---|
| 1597 | mMeshReduction->type(fltk::FloatInput::FLOAT); |
---|
| 1598 | mMeshReduction->activate(); |
---|
| 1599 | |
---|
| 1600 | mButtonProcess->set_visible(); |
---|
| 1601 | mButtonProcess->activate(); |
---|
| 1602 | |
---|
| 1603 | mProcessBar->set_visible(); |
---|
| 1604 | mProcessBar->activate(); |
---|
| 1605 | } |
---|
| 1606 | |
---|
| 1607 | //--------------------------------------------------------------------------- |
---|
| 1608 | // Hide the Simplify Leaves Collapse |
---|
| 1609 | //--------------------------------------------------------------------------- |
---|
| 1610 | void GeoMeshViewUI::hideLeavesCollapse() |
---|
| 1611 | { |
---|
| 1612 | mMetricLabel->hide(); |
---|
| 1613 | mMetricLabel->deactivate(); |
---|
| 1614 | |
---|
| 1615 | mGeometryBased->hide(); |
---|
| 1616 | mGeometryBased->deactivate(); |
---|
| 1617 | |
---|
| 1618 | mViewPointDriven->hide(); |
---|
| 1619 | mViewPointDriven->deactivate(); |
---|
| 1620 | |
---|
| 1621 | /* |
---|
| 1622 | mTypeLabel->hide(); |
---|
| 1623 | mTypeLabel->deactivate(); |
---|
| 1624 | |
---|
| 1625 | mChangeTexture->hide(); |
---|
| 1626 | mChangeTexture->deactivate(); |
---|
| 1627 | */ |
---|
| 1628 | |
---|
| 1629 | mMeshReductionLabel->hide(); |
---|
| 1630 | mMeshReductionLabel->deactivate(); |
---|
| 1631 | |
---|
| 1632 | mPercent->hide(); |
---|
| 1633 | mPercent->deactivate(); |
---|
| 1634 | |
---|
| 1635 | mVerticesNumber->hide(); |
---|
| 1636 | mVerticesNumber->deactivate(); |
---|
| 1637 | |
---|
| 1638 | mMeshReduction->hide(); |
---|
| 1639 | mMeshReduction->deactivate(); |
---|
| 1640 | |
---|
| 1641 | mButtonProcess->hide(); |
---|
| 1642 | mButtonProcess->deactivate(); |
---|
| 1643 | |
---|
| 1644 | mProcessBar->hide(); |
---|
| 1645 | mProcessBar->deactivate(); |
---|
| 1646 | } |
---|
| 1647 | |
---|
| 1648 | //--------------------------------------------------------------------------- |
---|
| 1649 | // Show the LodStrips Panel |
---|
| 1650 | //--------------------------------------------------------------------------- |
---|
| 1651 | void GeoMeshViewUI::showOpenMeshSimplification() |
---|
| 1652 | { |
---|
| 1653 | mButtonProcess->set_visible(); |
---|
| 1654 | mButtonProcess->activate(); |
---|
| 1655 | |
---|
| 1656 | mProcessBar->set_visible(); |
---|
| 1657 | mProcessBar->activate(); |
---|
| 1658 | |
---|
| 1659 | mButtonBuild->set_visible(); |
---|
| 1660 | mButtonBuild->activate(); |
---|
| 1661 | |
---|
| 1662 | mBuildBar->set_visible(); |
---|
| 1663 | mBuildBar->activate(); |
---|
| 1664 | } |
---|
| 1665 | |
---|
| 1666 | //--------------------------------------------------------------------------- |
---|
| 1667 | // Hide the LodStrips Panel |
---|
| 1668 | //--------------------------------------------------------------------------- |
---|
| 1669 | void GeoMeshViewUI::hideOpenMeshSimplification() |
---|
| 1670 | { |
---|
| 1671 | mButtonProcess->hide(); |
---|
| 1672 | mButtonProcess->deactivate(); |
---|
| 1673 | |
---|
| 1674 | mProcessBar->hide(); |
---|
| 1675 | mProcessBar->deactivate(); |
---|
| 1676 | |
---|
| 1677 | mButtonBuild->hide(); |
---|
| 1678 | mButtonBuild->deactivate(); |
---|
| 1679 | |
---|
| 1680 | mBuildBar->hide(); |
---|
| 1681 | mBuildBar->deactivate(); |
---|
| 1682 | } |
---|
| 1683 | |
---|
| 1684 | //--------------------------------------------------------------------------- |
---|
| 1685 | // Shows the auto generate LodStrips panel |
---|
| 1686 | //--------------------------------------------------------------------------- |
---|
| 1687 | void GeoMeshViewUI::showAutoGenerateLodStrips() |
---|
| 1688 | { |
---|
| 1689 | // Shows the simplify panel. |
---|
| 1690 | showEdgeCollapse(); |
---|
| 1691 | |
---|
| 1692 | mButtonBuild->set_visible(); |
---|
| 1693 | //mButtonBuild->activate(); |
---|
| 1694 | |
---|
| 1695 | mBuildBar->set_visible(); |
---|
| 1696 | //mBuildBar->activate(); |
---|
| 1697 | } |
---|
| 1698 | //--------------------------------------------------------------------------- |
---|
| 1699 | // Shows the auto generate LodStrips panel |
---|
| 1700 | //--------------------------------------------------------------------------- |
---|
| 1701 | void GeoMeshViewUI::showAutoGenerateLodTrees() |
---|
| 1702 | { |
---|
| 1703 | // Shows the simplify panel. |
---|
| 1704 | showEdgeCollapse(); |
---|
| 1705 | |
---|
| 1706 | mButtonBuild->set_visible(); |
---|
| 1707 | //mButtonBuild->activate(); |
---|
| 1708 | |
---|
| 1709 | mBuildBar->set_visible(); |
---|
| 1710 | //mBuildBar->activate(); |
---|
| 1711 | } |
---|
| 1712 | |
---|
| 1713 | //--------------------------------------------------------------------------- |
---|
| 1714 | // Show the LodStrips visulization panel |
---|
| 1715 | //--------------------------------------------------------------------------- |
---|
| 1716 | void GeoMeshViewUI::showLodStripSlider() |
---|
| 1717 | { |
---|
| 1718 | mLodStripSlider->set_visible(); |
---|
| 1719 | mLodStripSlider->activate(); |
---|
| 1720 | } |
---|
| 1721 | |
---|
| 1722 | //--------------------------------------------------------------------------- |
---|
| 1723 | // Hide the LodStrips visualization panel |
---|
| 1724 | //--------------------------------------------------------------------------- |
---|
| 1725 | void GeoMeshViewUI::hideLodStripSlider() |
---|
| 1726 | { |
---|
| 1727 | mLodStripSlider->hide(); |
---|
| 1728 | mLodStripSlider->deactivate(); |
---|
| 1729 | } |
---|
| 1730 | |
---|
| 1731 | //--------------------------------------------------------------------------- |
---|
| 1732 | // Show the LodTree visulization panel |
---|
| 1733 | //--------------------------------------------------------------------------- |
---|
| 1734 | void GeoMeshViewUI::showLodTreeSlider() |
---|
| 1735 | { |
---|
| 1736 | mLodTreeSlider->set_visible(); |
---|
| 1737 | mLodTreeSlider->activate(); |
---|
| 1738 | } |
---|
| 1739 | |
---|
| 1740 | //--------------------------------------------------------------------------- |
---|
| 1741 | // Hide the LodTree visualization panel |
---|
| 1742 | //--------------------------------------------------------------------------- |
---|
| 1743 | void GeoMeshViewUI::hideLodTreeSlider() |
---|
| 1744 | { |
---|
| 1745 | mLodTreeSlider->hide(); |
---|
| 1746 | mLodTreeSlider->deactivate(); |
---|
| 1747 | } |
---|
| 1748 | |
---|
| 1749 | |
---|
| 1750 | //--------------------------------------------------------------------------- |
---|
| 1751 | // Show the LodTrees Panel |
---|
| 1752 | //--------------------------------------------------------------------------- |
---|
| 1753 | void GeoMeshViewUI::showOpenLeavesSimplification() |
---|
| 1754 | { |
---|
| 1755 | mButtonBuild->set_visible(); |
---|
| 1756 | mButtonBuild->activate(); |
---|
| 1757 | |
---|
| 1758 | mBuildBar->set_visible(); |
---|
| 1759 | mBuildBar->activate(); |
---|
| 1760 | } |
---|
| 1761 | |
---|
| 1762 | //--------------------------------------------------------------------------- |
---|
| 1763 | // Hide the LodTrees Panel |
---|
| 1764 | //--------------------------------------------------------------------------- |
---|
| 1765 | void GeoMeshViewUI::hideOpenLeavesSimplification() |
---|
| 1766 | { |
---|
| 1767 | mButtonBuild->hide(); |
---|
| 1768 | mButtonBuild->deactivate(); |
---|
| 1769 | |
---|
| 1770 | mBuildBar->hide(); |
---|
| 1771 | mBuildBar->deactivate(); |
---|
| 1772 | } |
---|
| 1773 | |
---|
| 1774 | //--------------------------------------------------------------------------- |
---|
| 1775 | // Show the mesh info browser |
---|
| 1776 | //--------------------------------------------------------------------------- |
---|
| 1777 | void GeoMeshViewUI::showMeshInfo() |
---|
| 1778 | { |
---|
| 1779 | char type[10]; |
---|
| 1780 | |
---|
| 1781 | if (mGeoMesh) |
---|
| 1782 | { |
---|
| 1783 | // Remove previous mesh information |
---|
| 1784 | this->mMeshInfo->remove_all(); |
---|
| 1785 | ogeometry = new fltk::ItemGroup("Geometry"); |
---|
| 1786 | ogeometry->begin(); |
---|
| 1787 | |
---|
| 1788 | fltk::ItemGroup **oprueba; |
---|
| 1789 | oprueba=new fltk::ItemGroup*[mGeoMesh->mSubMeshCount]; |
---|
| 1790 | for(int i=0; i<mGeoMesh->mSubMeshCount;i++) |
---|
| 1791 | { |
---|
| 1792 | char *cadena=new char[256]; |
---|
| 1793 | |
---|
| 1794 | if (geoMeshView->getLeavesSubMesh() >= 0) |
---|
| 1795 | { |
---|
| 1796 | if (geoMeshView->getLeavesSubMesh() == i) |
---|
| 1797 | { |
---|
| 1798 | strcpy(type,"(Leaves)"); |
---|
| 1799 | } |
---|
| 1800 | else |
---|
| 1801 | { |
---|
| 1802 | strcpy(type,"(Trunc)"); |
---|
| 1803 | } |
---|
| 1804 | } |
---|
| 1805 | else |
---|
| 1806 | { |
---|
| 1807 | strcpy(type,""); |
---|
| 1808 | } |
---|
| 1809 | |
---|
| 1810 | // Submesh identifier. |
---|
| 1811 | sprintf(cadena,"SubMesh %d %s",i,type); |
---|
| 1812 | |
---|
| 1813 | oprueba[i] = new fltk::ItemGroup(cadena); |
---|
| 1814 | oprueba[i]->begin(); |
---|
| 1815 | fltk::Item *sharedGeometry; |
---|
| 1816 | if (mGeoMesh->mSubMesh[i].mSharedVertexBuffer) |
---|
| 1817 | { |
---|
| 1818 | sharedGeometry = new fltk::Item("Shared Geometry: Yes"); |
---|
| 1819 | } |
---|
| 1820 | else |
---|
| 1821 | { |
---|
| 1822 | sharedGeometry = new fltk::Item("Shared Geometry: No"); |
---|
| 1823 | } |
---|
| 1824 | |
---|
| 1825 | // Adds material name. |
---|
| 1826 | char *cadena2=new char[100]; |
---|
| 1827 | sprintf(cadena2, "Material: %s",mGeoMesh->mSubMesh[i].mMaterialName); |
---|
| 1828 | |
---|
| 1829 | fltk::Item *geomaterial = new fltk::Item(cadena2); |
---|
| 1830 | |
---|
| 1831 | char *cadena3=new char[100]; |
---|
| 1832 | |
---|
| 1833 | sprintf(cadena3, "Number of indexes: %d",mGeoMesh->mSubMesh[i].mIndexCount); |
---|
| 1834 | fltk::Item *numberIndex = new fltk::Item(cadena3); |
---|
| 1835 | if (mGeoMesh->mSubMesh[i].mType==Geometry::GEO_TRIANGLE_LIST) |
---|
| 1836 | { |
---|
| 1837 | fltk::Item *type = new fltk::Item("Triangle List"); |
---|
| 1838 | } |
---|
| 1839 | else |
---|
| 1840 | { |
---|
| 1841 | fltk::Item *type = new fltk::Item("Triangle Strips"); |
---|
| 1842 | } |
---|
| 1843 | |
---|
| 1844 | char *cadenavertex=new char[30]; |
---|
| 1845 | sprintf(cadenavertex, "Number of vertices: %d",mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount); |
---|
| 1846 | fltk::Item *numberVertex = new fltk::Item(cadenavertex); |
---|
| 1847 | |
---|
| 1848 | if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) |
---|
| 1849 | { |
---|
| 1850 | fltk::Item *normals = new fltk::Item("Normals: Yes"); |
---|
| 1851 | } |
---|
| 1852 | else |
---|
| 1853 | { |
---|
| 1854 | fltk::Item *normals = new fltk::Item("Normals: No"); |
---|
| 1855 | } |
---|
| 1856 | |
---|
| 1857 | if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) |
---|
| 1858 | { |
---|
| 1859 | fltk::Item *textures = new fltk::Item("Textures: Yes"); |
---|
| 1860 | } |
---|
| 1861 | else |
---|
| 1862 | { |
---|
| 1863 | fltk::Item *textures = new fltk::Item("Textures: No"); |
---|
| 1864 | } |
---|
| 1865 | |
---|
| 1866 | |
---|
| 1867 | oprueba[i]->end(); |
---|
| 1868 | } |
---|
| 1869 | ogeometry->end(); |
---|
| 1870 | this->mMeshInfo->add(ogeometry); |
---|
| 1871 | } |
---|
| 1872 | |
---|
| 1873 | // Hide the right panel. |
---|
| 1874 | hideRightPanel(); |
---|
| 1875 | |
---|
| 1876 | mMeshInfo->set_visible(); |
---|
| 1877 | mMeshInfo->activate(); |
---|
| 1878 | } |
---|
| 1879 | |
---|
| 1880 | //--------------------------------------------------------------------------- |
---|
| 1881 | // Hide the mesh info browser |
---|
| 1882 | //--------------------------------------------------------------------------- |
---|
| 1883 | void GeoMeshViewUI::hideMeshInfo() |
---|
| 1884 | { |
---|
| 1885 | mMeshInfo->hide(); |
---|
| 1886 | mMeshInfo->deactivate(); |
---|
| 1887 | } |
---|
| 1888 | |
---|
| 1889 | //--------------------------------------------------------------------------- |
---|
| 1890 | // Hide the right panel |
---|
| 1891 | //--------------------------------------------------------------------------- |
---|
| 1892 | void GeoMeshViewUI::hideRightPanel() |
---|
| 1893 | { |
---|
| 1894 | hideStripify(); |
---|
| 1895 | hideEdgeCollapse(); |
---|
| 1896 | hideLeavesCollapse(); |
---|
| 1897 | hideOpenMeshSimplification(); |
---|
| 1898 | hideOpenLeavesSimplification(); |
---|
| 1899 | hideLodStripSlider(); |
---|
| 1900 | hideLodTreeSlider(); |
---|
| 1901 | hideMeshInfo(); |
---|
| 1902 | } |
---|
| 1903 | |
---|
| 1904 | //--------------------------------------------------------------------------- |
---|
| 1905 | // Get the number of vertices |
---|
| 1906 | //--------------------------------------------------------------------------- |
---|
| 1907 | size_t GeoMeshViewUI::getVertexCount(Mesh *geoMesh) |
---|
| 1908 | { |
---|
| 1909 | size_t vertex_count; |
---|
| 1910 | SubMesh *geoSubMesh; |
---|
| 1911 | |
---|
| 1912 | vertex_count = geoMesh->mVertexBuffer->mVertexCount; |
---|
| 1913 | |
---|
| 1914 | // For each submesh. |
---|
| 1915 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
| 1916 | { |
---|
| 1917 | // Gets the actual submesh. |
---|
| 1918 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
| 1919 | |
---|
| 1920 | // If the mesh does not have shared vertex. |
---|
| 1921 | if (!geoSubMesh->mSharedVertexBuffer) |
---|
| 1922 | { |
---|
| 1923 | // Adds the vertex of the submesh to the total count. |
---|
| 1924 | vertex_count += geoSubMesh->mVertexBuffer->mVertexCount; |
---|
| 1925 | } |
---|
| 1926 | } |
---|
| 1927 | |
---|
| 1928 | return vertex_count; |
---|
| 1929 | } |
---|
| 1930 | |
---|
| 1931 | //--------------------------------------------------------------------------- |
---|
| 1932 | // Get the number of triangles |
---|
| 1933 | //--------------------------------------------------------------------------- |
---|
| 1934 | size_t GeoMeshViewUI::getTriangleCount(Geometry::Mesh *geoMesh) |
---|
| 1935 | { |
---|
| 1936 | size_t triangle_count; |
---|
| 1937 | SubMesh *geoSubMesh; |
---|
| 1938 | |
---|
| 1939 | // Initialize the triangle count. |
---|
| 1940 | triangle_count = 0; |
---|
| 1941 | |
---|
| 1942 | // If the application is in visualize lodstrips mode. |
---|
| 1943 | if (mApplicationState == VISUALIZE_LODSTRIPS) |
---|
| 1944 | { |
---|
| 1945 | triangle_count = geoMeshView->getLodStripsTriangleCount(); |
---|
| 1946 | } |
---|
| 1947 | else |
---|
| 1948 | { |
---|
| 1949 | // For each submesh. |
---|
| 1950 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
| 1951 | { |
---|
| 1952 | // Gets the actual submesh. |
---|
| 1953 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
| 1954 | |
---|
| 1955 | switch (geoSubMesh->mType) |
---|
| 1956 | { |
---|
| 1957 | case GEO_TRIANGLE_LIST: |
---|
| 1958 | triangle_count += geoSubMesh->mIndexCount / 3; |
---|
| 1959 | break; |
---|
| 1960 | case GEO_TRIANGLE_STRIPS: |
---|
| 1961 | triangle_count += geoSubMesh->mIndexCount - 2; |
---|
| 1962 | break; |
---|
| 1963 | } |
---|
| 1964 | } |
---|
| 1965 | } |
---|
| 1966 | |
---|
| 1967 | return triangle_count; |
---|
| 1968 | } |
---|
| 1969 | |
---|
| 1970 | //--------------------------------------------------------------------------- |
---|
| 1971 | // Get the number of strips |
---|
| 1972 | //--------------------------------------------------------------------------- |
---|
| 1973 | size_t GeoMeshViewUI::getStripCount(Geometry::Mesh *geoMesh) |
---|
| 1974 | { |
---|
| 1975 | size_t strip_count; |
---|
| 1976 | SubMesh *geoSubMesh; |
---|
| 1977 | |
---|
| 1978 | // Initialize the triangle count. |
---|
| 1979 | strip_count = 0; |
---|
| 1980 | |
---|
| 1981 | // For each submesh. |
---|
| 1982 | for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) |
---|
| 1983 | { |
---|
| 1984 | // Gets the actual submesh. |
---|
| 1985 | geoSubMesh = &geoMesh->mSubMesh[submesh]; |
---|
| 1986 | |
---|
| 1987 | if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) |
---|
| 1988 | { |
---|
| 1989 | strip_count += geoSubMesh->mStripCount; |
---|
| 1990 | } |
---|
| 1991 | } |
---|
| 1992 | |
---|
| 1993 | return strip_count; |
---|
| 1994 | } |
---|
| 1995 | |
---|
| 1996 | //--------------------------------------------------------------------------- |
---|
| 1997 | // It paints the submesh selected by the mMeshInfo tree |
---|
| 1998 | // Trate the mMeshInfo event |
---|
| 1999 | //--------------------------------------------------------------------------- |
---|
| 2000 | int GeoMeshViewUI::paintMesh(void) |
---|
| 2001 | { |
---|
| 2002 | char selectedTag[100]; |
---|
| 2003 | char *pch; |
---|
| 2004 | char *p; |
---|
| 2005 | int meshNumber; |
---|
| 2006 | |
---|
| 2007 | // Initializa mesh to not selected. |
---|
| 2008 | meshNumber = -1; |
---|
| 2009 | |
---|
| 2010 | // Shows the selected object label |
---|
| 2011 | strcpy(selectedTag,mMeshInfo->goto_focus()->label()); |
---|
| 2012 | |
---|
| 2013 | p=strstr(selectedTag,"SubMesh "); |
---|
| 2014 | |
---|
| 2015 | // If the item begins with string "SubMesh" |
---|
| 2016 | if (p!=NULL) |
---|
| 2017 | { |
---|
| 2018 | pch = strtok (selectedTag," "); |
---|
| 2019 | pch = strtok (NULL, " "); |
---|
| 2020 | sscanf(pch,"%d",&meshNumber); |
---|
| 2021 | } |
---|
| 2022 | |
---|
| 2023 | geoMeshView->setSubMeshSelected(meshNumber); |
---|
| 2024 | geoMeshView->redraw(); |
---|
| 2025 | |
---|
| 2026 | return meshNumber; |
---|
| 2027 | } |
---|
| 2028 | |
---|
| 2029 | //--------------------------------------------------------------------------- |
---|
| 2030 | // Simplify the mesh object. |
---|
| 2031 | //--------------------------------------------------------------------------- |
---|
| 2032 | bool GeoMeshViewUI::simplifyEdgeCollapse() |
---|
| 2033 | { |
---|
| 2034 | Real percent; |
---|
| 2035 | |
---|
| 2036 | // If input field empty. |
---|
| 2037 | if (mMeshReduction->fvalue() <= 0.0) |
---|
| 2038 | { |
---|
| 2039 | return false; |
---|
| 2040 | } |
---|
| 2041 | |
---|
| 2042 | geoMeshView->saveContext(); |
---|
| 2043 | |
---|
| 2044 | // Debug. |
---|
| 2045 | cout << "Mesh Reduction: " |
---|
| 2046 | << mMeshReduction->fvalue() |
---|
| 2047 | << endl; |
---|
| 2048 | |
---|
| 2049 | // Gets simplify option. |
---|
| 2050 | if (mGeometryBased->value()) |
---|
| 2051 | { |
---|
| 2052 | simplificationState = MESHSIMP; |
---|
| 2053 | mMeshSimplifier = new GeometryBasedSimplifier(mGeoMesh, |
---|
| 2054 | |
---|
| 2055 | progress_function); |
---|
| 2056 | } |
---|
| 2057 | else |
---|
| 2058 | { |
---|
| 2059 | simplificationState = VIEWPOINTDRIVEN; |
---|
| 2060 | mMeshSimplifier = new ViewPointDrivenSimplifier(mGeoMesh, |
---|
| 2061 | |
---|
| 2062 | progress_function); |
---|
| 2063 | } |
---|
| 2064 | |
---|
| 2065 | mMeshSimplifier->setMeshLeaves(idMeshLeaves); |
---|
| 2066 | |
---|
| 2067 | if (mPercent->value()) |
---|
| 2068 | { |
---|
| 2069 | // Simplificación por porcentaje |
---|
| 2070 | if (mMeshReduction->fvalue() <= 100.0 && |
---|
| 2071 | mMeshReduction->fvalue() > 0.0) |
---|
| 2072 | { |
---|
| 2073 | percent = mMeshReduction->fvalue(); |
---|
| 2074 | percent = percent / 100.0; |
---|
| 2075 | |
---|
| 2076 | // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. |
---|
| 2077 | mMeshSimplifier->Simplify(percent); |
---|
| 2078 | |
---|
| 2079 | // Deletes the previous mesh. |
---|
| 2080 | delete mUndoMesh; |
---|
| 2081 | |
---|
| 2082 | mUndoMesh = new Mesh(); |
---|
| 2083 | |
---|
| 2084 | // Sets the undo mesh. |
---|
| 2085 | *mUndoMesh = *mGeoMesh; |
---|
| 2086 | |
---|
| 2087 | delete mGeoMesh; |
---|
| 2088 | |
---|
| 2089 | mGeoMesh = mMeshSimplifier->GetMesh(); |
---|
| 2090 | |
---|
| 2091 | // Visualize mesh. |
---|
| 2092 | geoMeshView->setMesh(mGeoMesh); |
---|
| 2093 | |
---|
| 2094 | } |
---|
| 2095 | else |
---|
| 2096 | { |
---|
| 2097 | fltk::alert("Wrong value for simplification.\n" |
---|
| 2098 | "Valid values [0..100]"); |
---|
| 2099 | |
---|
| 2100 | return false; |
---|
| 2101 | } |
---|
| 2102 | } |
---|
| 2103 | else |
---|
| 2104 | { |
---|
| 2105 | // Simplificar hasta un número de vértices. |
---|
| 2106 | uint32 v = (uint32)mMeshReduction->fvalue(); |
---|
| 2107 | |
---|
| 2108 | // Simplifica el geomesh -> Parámetro es un factor LOD [0,1]. |
---|
| 2109 | mMeshSimplifier->Simplify(v); |
---|
| 2110 | |
---|
| 2111 | // Deletes the previous mesh. |
---|
| 2112 | delete mUndoMesh; |
---|
| 2113 | |
---|
| 2114 | mUndoMesh = new Mesh(); |
---|
| 2115 | |
---|
| 2116 | // Sets the undo mesh. |
---|
| 2117 | *mUndoMesh = *mGeoMesh; |
---|
| 2118 | |
---|
| 2119 | delete mGeoMesh; |
---|
| 2120 | |
---|
| 2121 | mGeoMesh = mMeshSimplifier->GetMesh(); |
---|
| 2122 | |
---|
| 2123 | // Visualize the mesh. |
---|
| 2124 | geoMeshView->setMesh(mGeoMesh); |
---|
| 2125 | } |
---|
| 2126 | |
---|
| 2127 | return true; |
---|
| 2128 | } |
---|
| 2129 | |
---|
| 2130 | //--------------------------------------------------------------------------- |
---|
| 2131 | // Simplify the mesh object. |
---|
| 2132 | //--------------------------------------------------------------------------- |
---|
| 2133 | void GeoMeshViewUI::simplifyLeavesCollapse() |
---|
| 2134 | { |
---|
| 2135 | bool error; |
---|
| 2136 | uint32 vi; |
---|
| 2137 | |
---|
| 2138 | // Initialize error flag. |
---|
| 2139 | error = false; |
---|
| 2140 | |
---|
| 2141 | // Check submeshes for triangles strips. |
---|
| 2142 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
| 2143 | { |
---|
| 2144 | // If current submesh is in triangle strips. |
---|
| 2145 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
| 2146 | { |
---|
| 2147 | error = true; |
---|
| 2148 | } |
---|
| 2149 | } |
---|
| 2150 | |
---|
| 2151 | // if the mesh is stripified. |
---|
| 2152 | if (error) |
---|
| 2153 | { |
---|
| 2154 | fltk::alert("Can't simplify a tree in triagle strips."); |
---|
| 2155 | } |
---|
| 2156 | // if the mesh is in triangle list. |
---|
| 2157 | else |
---|
| 2158 | { |
---|
| 2159 | simplificationState = HOJAS; |
---|
| 2160 | |
---|
| 2161 | mTreeSimplifier = new TreeSimplifier(mGeoMesh, progress_function); |
---|
| 2162 | vi = (uint32)mMeshReduction->fvalue(); |
---|
| 2163 | |
---|
| 2164 | // Simplify |
---|
| 2165 | if(idMeshLeaves != (unsigned short)-1) |
---|
| 2166 | { |
---|
| 2167 | // Simplify |
---|
| 2168 | mTreeSimplifier->Simplify(vi, idMeshLeaves); |
---|
| 2169 | |
---|
| 2170 | // Deletes the previous mesh. |
---|
| 2171 | delete mUndoMesh; |
---|
| 2172 | |
---|
| 2173 | mUndoMesh = new Mesh(); |
---|
| 2174 | |
---|
| 2175 | // Sets the undo mesh. |
---|
| 2176 | *mUndoMesh = *mGeoMesh; |
---|
| 2177 | |
---|
| 2178 | delete mGeoMesh; |
---|
| 2179 | |
---|
| 2180 | mGeoMesh = mTreeSimplifier->GetMesh(); |
---|
| 2181 | |
---|
| 2182 | geoMeshView->setMesh(mGeoMesh); |
---|
| 2183 | } |
---|
| 2184 | else |
---|
| 2185 | { |
---|
| 2186 | fltk::alert("You must select the mesh that contains the leaves."); |
---|
| 2187 | } |
---|
| 2188 | } |
---|
| 2189 | } |
---|
| 2190 | |
---|
| 2191 | //--------------------------------------------------------------------------- |
---|
| 2192 | // Create a simplification sequence of the simplification method. |
---|
| 2193 | //--------------------------------------------------------------------------- |
---|
| 2194 | void GeoMeshViewUI::createSimplificationSequence() |
---|
| 2195 | { |
---|
| 2196 | MeshSimplificationSequence *secsimpl; |
---|
| 2197 | |
---|
| 2198 | secsimpl = mMeshSimplifier->GetSimplificationSequence(); |
---|
| 2199 | |
---|
| 2200 | secsimpl->putMeshName(nombremesh); // Nombre del mesh para guardar la secuencia de simplificación |
---|
| 2201 | secsimpl->Save(Geometry::Serializer("SimplifSequence.txt",Serializer::WRITE)); |
---|
| 2202 | |
---|
| 2203 | //delete secsimpl; |
---|
| 2204 | } |
---|
| 2205 | |
---|
| 2206 | //--------------------------------------------------------------------------- |
---|
| 2207 | // Create a simplification sequence of the leaves. |
---|
| 2208 | //--------------------------------------------------------------------------- |
---|
| 2209 | void GeoMeshViewUI::createLeavesSequence(const std::string &filename) |
---|
| 2210 | { |
---|
| 2211 | TreeSimplificationSequence *tree_sequencer; |
---|
| 2212 | |
---|
| 2213 | tree_sequencer = mTreeSimplifier->GetSimplificationSequence(); |
---|
| 2214 | |
---|
| 2215 | tree_sequencer->putMeshName(nombremesh); |
---|
| 2216 | tree_sequencer->Save(Serializer(filename,Serializer::WRITE)); |
---|
| 2217 | |
---|
| 2218 | delete tree_sequencer; |
---|
| 2219 | } |
---|
| 2220 | |
---|
| 2221 | //--------------------------------------------------------------------------- |
---|
| 2222 | // Stripify the mesh object. |
---|
| 2223 | //--------------------------------------------------------------------------- |
---|
| 2224 | void GeoMeshViewUI::stripify() |
---|
| 2225 | { |
---|
| 2226 | bool error; |
---|
| 2227 | char char_value[10]; |
---|
| 2228 | CustomStripifier *geoStripifier; |
---|
| 2229 | |
---|
| 2230 | // Initialize error flag. |
---|
| 2231 | error = false; |
---|
| 2232 | |
---|
| 2233 | // Check submeshes for triangles strips. |
---|
| 2234 | for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) |
---|
| 2235 | { |
---|
| 2236 | // If current submesh is in triangle strips. |
---|
| 2237 | if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) |
---|
| 2238 | { |
---|
| 2239 | error = true; |
---|
| 2240 | } |
---|
| 2241 | } |
---|
| 2242 | |
---|
| 2243 | // if the mesh is stripified. |
---|
| 2244 | if (error) |
---|
| 2245 | { |
---|
| 2246 | fltk::alert("The mesh is already in strips."); |
---|
| 2247 | } |
---|
| 2248 | // if the mesh is in triangle list. |
---|
| 2249 | else |
---|
| 2250 | { |
---|
| 2251 | //Stripify. |
---|
| 2252 | geoStripifier = new CustomStripifier(mGeoMesh); |
---|
| 2253 | |
---|
| 2254 | // Set the progress bar function. |
---|
| 2255 | geoStripifier->SetProgressFunc(progress_function); |
---|
| 2256 | |
---|
| 2257 | // Sets the leaves submesh if exists. |
---|
| 2258 | geoStripifier->SetSubMeshLeaves(idMeshLeaves); |
---|
| 2259 | |
---|
| 2260 | if (geoStripifier->Stripify()) |
---|
| 2261 | { |
---|
| 2262 | // Deletes the mesh object. |
---|
| 2263 | delete mUndoMesh; |
---|
| 2264 | |
---|
| 2265 | mUndoMesh = new Mesh(); |
---|
| 2266 | |
---|
| 2267 | *mUndoMesh = *mGeoMesh; |
---|
| 2268 | |
---|
| 2269 | delete mGeoMesh; |
---|
| 2270 | |
---|
| 2271 | // Gets the mesh stripified. |
---|
| 2272 | mGeoMesh = geoStripifier->GetMesh(); |
---|
| 2273 | |
---|
| 2274 | // Visualize the mesh stripified. |
---|
| 2275 | geoMeshView->setMesh(mGeoMesh); |
---|
| 2276 | |
---|
| 2277 | // Store the color of the strips. |
---|
| 2278 | geoMeshView->setStripColors(); |
---|
| 2279 | } |
---|
| 2280 | else |
---|
| 2281 | { |
---|
| 2282 | // Error message. |
---|
| 2283 | fltk::alert("Impossible to stripify. The mesh is not manifold"); |
---|
| 2284 | } |
---|
| 2285 | |
---|
| 2286 | // Deletes the stripifier object. |
---|
| 2287 | delete geoStripifier; |
---|
| 2288 | } |
---|
| 2289 | } |
---|
| 2290 | |
---|
| 2291 | //--------------------------------------------------------------------------- |
---|
| 2292 | // Method that undo then mesh changes. |
---|
| 2293 | //--------------------------------------------------------------------------- |
---|
| 2294 | void GeoMeshViewUI::undo() |
---|
| 2295 | { |
---|
| 2296 | // if the undo mesh is not initialized. |
---|
| 2297 | if (mUndoMesh != NULL) |
---|
| 2298 | { |
---|
| 2299 | // Deletes the actual mesh. |
---|
| 2300 | delete mGeoMesh; |
---|
| 2301 | |
---|
| 2302 | mGeoMesh = new Mesh(); |
---|
| 2303 | |
---|
| 2304 | // Restore the previous mesh. |
---|
| 2305 | *mGeoMesh = *mUndoMesh; |
---|
| 2306 | |
---|
| 2307 | // Visualize the mesh. |
---|
| 2308 | geoMeshView->setMesh(mGeoMesh); |
---|
| 2309 | |
---|
| 2310 | // Refresh geometry attributes. |
---|
| 2311 | refreshApplicationBar(); |
---|
| 2312 | |
---|
| 2313 | // Repaint the window. |
---|
| 2314 | mMainWindow->redraw(); |
---|
| 2315 | } |
---|
| 2316 | } |
---|
| 2317 | |
---|
| 2318 | //--------------------------------------------------------------------------- |
---|
| 2319 | // Refresh number of vertices, triangles, strips, ... |
---|
| 2320 | //--------------------------------------------------------------------------- |
---|
| 2321 | void GeoMeshViewUI::refreshApplicationBar() |
---|
| 2322 | { |
---|
| 2323 | static char vertices_value[50]; |
---|
| 2324 | static char triangles_value[50]; |
---|
| 2325 | static char strips_value[50]; |
---|
| 2326 | |
---|
| 2327 | // Translate the vertex count to a char value. |
---|
| 2328 | sprintf(vertices_value,"Vertices %d",getVertexCount(mGeoMesh)); |
---|
| 2329 | |
---|
| 2330 | mVertices->label(vertices_value); |
---|
| 2331 | |
---|
| 2332 | // Translate the triangle count to a char value. |
---|
| 2333 | sprintf(triangles_value,"Triangles %d",getTriangleCount(mGeoMesh)); |
---|
| 2334 | |
---|
| 2335 | mTriangles->label(triangles_value); |
---|
| 2336 | |
---|
| 2337 | // Translate the triangle count to a char value. |
---|
| 2338 | sprintf(strips_value,"Strips %d",getStripCount(mGeoMesh)); |
---|
| 2339 | |
---|
| 2340 | mStrips->label(strips_value); |
---|
| 2341 | } |
---|
| 2342 | |
---|
| 2343 | // Method that updates the porgress bar. |
---|
| 2344 | float GeoMeshViewUI::updateProgressBar(float v) |
---|
| 2345 | { |
---|
| 2346 | fltk::ProgressBar *progressBar; |
---|
| 2347 | |
---|
| 2348 | // Choose progress bar to update. |
---|
| 2349 | switch(progressBarType) |
---|
| 2350 | { |
---|
| 2351 | case PROCESS: |
---|
| 2352 | progressBar = mProcessBar; |
---|
| 2353 | break; |
---|
| 2354 | case BUILD: |
---|
| 2355 | progressBar = mBuildBar; |
---|
| 2356 | break; |
---|
| 2357 | } |
---|
| 2358 | |
---|
| 2359 | // Update progress bar. |
---|
| 2360 | progressBar->step(v); |
---|
| 2361 | progressBar->step(); |
---|
| 2362 | mMainWindow->flush(); |
---|
| 2363 | //mMainWindow->redraw(); |
---|
| 2364 | |
---|
| 2365 | return 0; |
---|
| 2366 | } |
---|
| 2367 | |
---|
| 2368 | //--------------------------------------------------------------------------- |
---|
| 2369 | // Initialize the lodstripslibrary for visualization. |
---|
| 2370 | //--------------------------------------------------------------------------- |
---|
| 2371 | void GeoMeshViewUI::setLodStripsLibrary(std::string lodfile, Mesh *geomesh) |
---|
| 2372 | { |
---|
| 2373 | // If there is no lod strips object. |
---|
| 2374 | if (lodStripsLib) |
---|
| 2375 | { |
---|
| 2376 | delete lodStripsLib; |
---|
| 2377 | } |
---|
| 2378 | |
---|
| 2379 | // New lod strips object. |
---|
| 2380 | lodStripsLib = new LodStripsLibrary(lodfile, geomesh); |
---|
| 2381 | |
---|
| 2382 | // Sets the slider range. |
---|
| 2383 | mLodStripSlider->range(lodStripsLib->MinLod(),lodStripsLib->MaxLod()); |
---|
| 2384 | |
---|
| 2385 | // Pass to geomeshview the lod strips object. |
---|
| 2386 | geoMeshView->setLodStripsLibrary(lodStripsLib); |
---|
| 2387 | |
---|
| 2388 | // Puts the slider in the max position. |
---|
| 2389 | //mLodStripSlider->value(lodStripsLib->MinLod()); |
---|
| 2390 | } |
---|
| 2391 | |
---|
| 2392 | //--------------------------------------------------------------------------- |
---|
| 2393 | // Initialize the lodTreelibrary for visualization. |
---|
| 2394 | //--------------------------------------------------------------------------- |
---|
| 2395 | //void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) |
---|
| 2396 | void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh *geomesh, uint32 ileafSubMesh) |
---|
| 2397 | |
---|
| 2398 | { |
---|
| 2399 | // If there is no lod strips object. |
---|
| 2400 | if (lodTreeLib) |
---|
| 2401 | { |
---|
| 2402 | delete lodTreeLib; |
---|
| 2403 | } |
---|
| 2404 | |
---|
| 2405 | // New lod strips object. |
---|
| 2406 | /* lodTreeLib = new Geometry::LodTreeLibrary(lodfile, geomesh,"\\\\quake\\home\\\Modelos\\betula_populifolia\\vertices.obj", |
---|
| 2407 | "\\\\quake\\home\\\Modelos\\betula_populifolia\\hojas.obj", |
---|
| 2408 | "\\\\quake\\home\\\Modelos\\betula_populifolia\\simplifica.obj");*/ |
---|
| 2409 | |
---|
| 2410 | lodTreeLib = new Geometry::LodTreeLibrary(lodfile,leafseqfile,geomesh,ileafSubMesh); |
---|
| 2411 | |
---|
| 2412 | // Sets the slider range. |
---|
| 2413 | mLodStripSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); |
---|
| 2414 | mLodTreeSlider->range(lodTreeLib->MaxFoliageLod(), lodTreeLib->MinFoliageLod()); |
---|
| 2415 | |
---|
| 2416 | // Pass to geomeshview the lod strips object. |
---|
| 2417 | geoMeshView->setLodTreesLibrary(lodTreeLib); |
---|
| 2418 | |
---|
| 2419 | // Puts the slider in the max position. |
---|
| 2420 | mLodStripSlider->value(lodTreeLib->MinTrunkLod()); |
---|
| 2421 | mLodTreeSlider->value(lodTreeLib->MinFoliageLod()); |
---|
| 2422 | } |
---|
| 2423 | |
---|
| 2424 | //--------------------------------------------------------------------------- |
---|
| 2425 | // Open a mesh file. |
---|
| 2426 | //--------------------------------------------------------------------------- |
---|
| 2427 | void GeoMeshViewUI::openMeshFile() |
---|
| 2428 | { |
---|
| 2429 | Mesh *mesh_loaded; |
---|
| 2430 | fltk::FileChooser *fcho; |
---|
| 2431 | static char char_value[10]; |
---|
| 2432 | static char title[256]; |
---|
| 2433 | |
---|
| 2434 | fcho = new fltk::FileChooser("", |
---|
| 2435 | "*.mesh", |
---|
| 2436 | fltk::FileChooser::CREATE, |
---|
| 2437 | "Open mesh file"); |
---|
| 2438 | |
---|
| 2439 | fcho->exec(); |
---|
| 2440 | |
---|
| 2441 | // File name. |
---|
| 2442 | mFileName = (char *)fcho->value(); |
---|
| 2443 | |
---|
| 2444 | if (mFileName) |
---|
| 2445 | { |
---|
| 2446 | // Loads a new mesh. |
---|
| 2447 | mesh_loaded = geoMeshLoader->load(mFileName); |
---|
| 2448 | |
---|
| 2449 | // If no error happens. |
---|
| 2450 | if (mesh_loaded) |
---|
| 2451 | { |
---|
| 2452 | // Identify the mesh that stores the leaves |
---|
| 2453 | idMeshLeaves = -1; |
---|
| 2454 | |
---|
| 2455 | // Delete the current mesh. |
---|
| 2456 | delete mGeoMesh; |
---|
| 2457 | delete mUndoMesh; |
---|
| 2458 | |
---|
| 2459 | // Assigns mesh loaded. |
---|
| 2460 | mGeoMesh = mesh_loaded; |
---|
| 2461 | |
---|
| 2462 | // Set Window Title. |
---|
| 2463 | strcpy(title,filename_name(mFileName)); |
---|
| 2464 | mMainWindow->label(strcat(title," - GeoTool")); |
---|
| 2465 | |
---|
| 2466 | // Stores the name of the mesh. |
---|
| 2467 | nombremesh = new char[255]; |
---|
| 2468 | strcpy(nombremesh,mFileName); |
---|
| 2469 | |
---|
| 2470 | // Reset the undo mesh. |
---|
| 2471 | mUndoMesh = new Mesh(); |
---|
| 2472 | *mUndoMesh = *mGeoMesh; |
---|
| 2473 | |
---|
| 2474 | // Translate the MB count to a char value. |
---|
| 2475 | sprintf(char_value, |
---|
| 2476 | "MB %.3f", |
---|
| 2477 | (float)geoMeshLoader->getFileSize()/1024/1024); |
---|
| 2478 | |
---|
| 2479 | mMB->label(char_value); |
---|
| 2480 | |
---|
| 2481 | // Visualize mesh. |
---|
| 2482 | geoMeshView->setMesh(mGeoMesh); |
---|
| 2483 | |
---|
| 2484 | // Hide right panel. |
---|
| 2485 | hideRightPanel(); |
---|
| 2486 | |
---|
| 2487 | // Quit culling. |
---|
| 2488 | menuRenderCW->clear_value(); |
---|
| 2489 | menuRenderCCW->clear_value(); |
---|
| 2490 | geoMeshView->deactiveCW(); |
---|
| 2491 | geoMeshView->deactiveCCW(); |
---|
| 2492 | |
---|
| 2493 | // Deactive solid mode and wire. |
---|
| 2494 | menuRenderSolid->clear_value(); |
---|
| 2495 | menuRenderWire->clear_value(); |
---|
| 2496 | geoMeshView->deactiveSolid(); |
---|
| 2497 | geoMeshView->deactiveWire(); |
---|
| 2498 | |
---|
| 2499 | // Fit model in midle. |
---|
| 2500 | geoMeshView->fit(); |
---|
| 2501 | |
---|
| 2502 | // Lighting smooth. |
---|
| 2503 | menuRenderFlat->clear_value(); |
---|
| 2504 | menuRenderSmooth->set_value(); |
---|
| 2505 | geoMeshView->smooth(); |
---|
| 2506 | |
---|
| 2507 | // Show title. |
---|
| 2508 | mProcessTitle->label("Mesh Info"); |
---|
| 2509 | |
---|
| 2510 | // Shows the mesh info. |
---|
| 2511 | showMeshInfo(); |
---|
| 2512 | |
---|
| 2513 | // if the mesh is stripified. |
---|
| 2514 | geoMeshView->setStripColors(); |
---|
| 2515 | |
---|
| 2516 | // Refresh geometry attributes. |
---|
| 2517 | refreshApplicationBar(); |
---|
| 2518 | |
---|
| 2519 | // Restore simplification state. |
---|
| 2520 | simplificationState = NO_SIMPLIFICATION; |
---|
| 2521 | } |
---|
| 2522 | } |
---|
| 2523 | // Free memory. |
---|
| 2524 | delete fcho; |
---|
| 2525 | } |
---|
| 2526 | |
---|
| 2527 | //--------------------------------------------------------------------------- |
---|
| 2528 | // If file exists. |
---|
| 2529 | //--------------------------------------------------------------------------- |
---|
| 2530 | bool GeoMeshViewUI::fileExists(const char *fileNameMesh) |
---|
| 2531 | { |
---|
| 2532 | FILE *pFile; |
---|
| 2533 | |
---|
| 2534 | // Open the mesh file. |
---|
| 2535 | pFile = fopen(fileNameMesh, "r"); |
---|
| 2536 | |
---|
| 2537 | if (pFile) |
---|
| 2538 | { |
---|
| 2539 | return true; |
---|
| 2540 | } |
---|
| 2541 | else |
---|
| 2542 | { |
---|
| 2543 | return false; |
---|
| 2544 | } |
---|
| 2545 | } |
---|
| 2546 | |
---|
| 2547 | /******************/ |
---|
| 2548 | /* Constructor */ |
---|
| 2549 | /******************/ |
---|
| 2550 | GeoMeshViewUI::GeoMeshViewUI(TIPOFUNC fun) |
---|
| 2551 | { |
---|
| 2552 | progress_function = fun; |
---|
| 2553 | fltk::gifImage *logo; |
---|
| 2554 | |
---|
| 2555 | // Initialize the file name. |
---|
| 2556 | mFileName = NULL; |
---|
| 2557 | |
---|
| 2558 | // Initialize the 3D object. |
---|
| 2559 | mGeoMesh = NULL; |
---|
| 2560 | mUndoMesh = NULL; |
---|
| 2561 | |
---|
| 2562 | // Initialize the lod strip object. |
---|
| 2563 | lodStripsLib = NULL; |
---|
| 2564 | lodTreeLib = NULL; |
---|
| 2565 | |
---|
| 2566 | // Identify the mesh that stores the leaves |
---|
| 2567 | idMeshLeaves = -1; |
---|
| 2568 | |
---|
| 2569 | // Initialize the loader of meshes. |
---|
| 2570 | geoMeshLoader = new GeoMeshLoader(); |
---|
| 2571 | |
---|
| 2572 | // Initialize the menus application state. |
---|
| 2573 | mApplicationState = NONE; |
---|
| 2574 | |
---|
| 2575 | SubMeshNames=NULL; |
---|
| 2576 | |
---|
| 2577 | { |
---|
| 2578 | fltk::Window* o = new fltk::Window(800, 600,"GeoTool"); |
---|
| 2579 | |
---|
| 2580 | mMainWindow = o; |
---|
| 2581 | |
---|
| 2582 | // Program Icon for Win32. |
---|
| 2583 | mMainWindow->icon((char *)LoadIcon( GetModuleHandle(0), |
---|
| 2584 | MAKEINTRESOURCE(GEOICON))); |
---|
| 2585 | |
---|
| 2586 | // Double buffer. |
---|
| 2587 | mMainWindow->set_double_buffer(); |
---|
| 2588 | |
---|
| 2589 | o->user_data((void*)(this)); |
---|
| 2590 | o->begin(); |
---|
| 2591 | |
---|
| 2592 | { |
---|
| 2593 | fltk::Group* o = new fltk::Group(0, 27, 806, 559); |
---|
| 2594 | o->begin(); |
---|
| 2595 | |
---|
| 2596 | { |
---|
| 2597 | fltk::Group* o; |
---|
| 2598 | o = MainView = new fltk::Group(0, 0, 570, 530); |
---|
| 2599 | o->begin(); |
---|
| 2600 | |
---|
| 2601 | { |
---|
| 2602 | fltk::InvisibleBox* o; |
---|
| 2603 | o = cframe = new fltk::InvisibleBox(0, 0, 570, 530); |
---|
| 2604 | o->box(fltk::FLAT_BOX); |
---|
| 2605 | o->color((fltk::Color)0xffffff00); |
---|
| 2606 | //fltk::Group::current()->resizable(o); |
---|
| 2607 | } |
---|
| 2608 | |
---|
| 2609 | { |
---|
| 2610 | GeoMeshView* o; |
---|
| 2611 | o = geoMeshView = new GeoMeshView( 0,0,570,530,0,this); |
---|
| 2612 | } |
---|
| 2613 | |
---|
| 2614 | o->end(); |
---|
| 2615 | |
---|
| 2616 | fltk::Group::current()->resizable(o); |
---|
| 2617 | |
---|
| 2618 | } |
---|
| 2619 | |
---|
| 2620 | { |
---|
| 2621 | fltk::Group* o; |
---|
| 2622 | o = MainView = new fltk::Group(570, 0, 230, 530); |
---|
| 2623 | o->begin(); |
---|
| 2624 | |
---|
| 2625 | { |
---|
| 2626 | fltk::Button* o; |
---|
| 2627 | //o = mButtonProcess = new fltk::Button(665, 410, 73, 25, "Process"); |
---|
| 2628 | o = mButtonProcess = new fltk::Button(75, 410, 73, 25, "Process"); |
---|
| 2629 | o->callback((fltk::Callback*)cb_mButtonProcess); |
---|
| 2630 | o->hide(); |
---|
| 2631 | o->deactivate(); |
---|
| 2632 | } |
---|
| 2633 | |
---|
| 2634 | { |
---|
| 2635 | fltk::ProgressBar* o; |
---|
| 2636 | //o = mProcessBar = new fltk::ProgressBar(616, 435, 175, 18); |
---|
| 2637 | o = mProcessBar = new fltk::ProgressBar(16, 435, 195, 18); |
---|
| 2638 | o->hide(); |
---|
| 2639 | o->deactivate(); |
---|
| 2640 | } |
---|
| 2641 | |
---|
| 2642 | { |
---|
| 2643 | fltk::Button* o; |
---|
| 2644 | o = mButtonSort = new fltk::Button(75, 375, 73, 25, "Sort"); |
---|
| 2645 | o->callback((fltk::Callback*)cb_mButtonSort); |
---|
| 2646 | o->hide(); |
---|
| 2647 | o->deactivate(); |
---|
| 2648 | } |
---|
| 2649 | |
---|
| 2650 | { |
---|
| 2651 | fltk::ProgressBar* o; |
---|
| 2652 | o = mSortBar = new fltk::ProgressBar(16, 390, 195, 18); |
---|
| 2653 | o->hide(); |
---|
| 2654 | o->deactivate(); |
---|
| 2655 | } |
---|
| 2656 | |
---|
| 2657 | { |
---|
| 2658 | fltk::Button* o; |
---|
| 2659 | o = mButtonBuild = new fltk::Button(75, 455, 73, 25, "Build"); |
---|
| 2660 | o->callback((fltk::Callback*)cb_mButtonBuild); |
---|
| 2661 | o->hide(); |
---|
| 2662 | o->deactivate(); |
---|
| 2663 | } |
---|
| 2664 | |
---|
| 2665 | { |
---|
| 2666 | fltk::ProgressBar* o; |
---|
| 2667 | o = mBuildBar = new fltk::ProgressBar(16, 480, 195, 18); |
---|
| 2668 | o->hide(); |
---|
| 2669 | o->deactivate(); |
---|
| 2670 | } |
---|
| 2671 | |
---|
| 2672 | { |
---|
| 2673 | fltk::Slider* o; |
---|
| 2674 | o = mLodStripSlider = new fltk::Slider(16, 50, 30, 450); |
---|
| 2675 | o->type(fltk::Slider::TICK_BELOW); |
---|
| 2676 | o->set_vertical(); |
---|
| 2677 | o->callback((fltk::Callback*)cb_mLodStripSlider); |
---|
| 2678 | o->hide(); |
---|
| 2679 | o->deactivate(); |
---|
| 2680 | } |
---|
| 2681 | { |
---|
| 2682 | fltk::Slider* o; |
---|
| 2683 | o = mLodTreeSlider = new fltk::Slider(46, 50, 30, 450); |
---|
| 2684 | o->type(fltk::Slider::TICK_BELOW); |
---|
| 2685 | o->set_vertical(); |
---|
| 2686 | o->callback((fltk::Callback*)cb_mLodTreeSlider); |
---|
| 2687 | o->hide(); |
---|
| 2688 | o->deactivate(); |
---|
| 2689 | } |
---|
| 2690 | |
---|
| 2691 | { |
---|
| 2692 | mMetricLabel = new fltk::Output(26, 28, 5, 25, "Metric"); |
---|
| 2693 | fltk::Output* o = mMetricLabel; |
---|
| 2694 | o->set_vertical(); |
---|
| 2695 | o->box(fltk::NO_BOX); |
---|
| 2696 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 2697 | o->color((fltk::Color)0xe0dfe300); |
---|
| 2698 | o->align(fltk::ALIGN_RIGHT); |
---|
| 2699 | } |
---|
| 2700 | |
---|
| 2701 | { |
---|
| 2702 | fltk::Group* o; |
---|
| 2703 | o = MainView = new fltk::Group(30, 40, 30, 60); |
---|
| 2704 | o->begin(); |
---|
| 2705 | { |
---|
| 2706 | mGeometryBased = new fltk::RadioButton(0, 8, 25, 25, "Geometry based"); |
---|
| 2707 | mViewPointDriven = new fltk::RadioButton(0, 23, 25, 25, "Viewpoint driven"); |
---|
| 2708 | } |
---|
| 2709 | o->end(); |
---|
| 2710 | } |
---|
| 2711 | |
---|
| 2712 | //mChangeVertices = new fltk::CheckButton(30, 104, 25, 25, "Change vertices"); |
---|
| 2713 | |
---|
| 2714 | { |
---|
| 2715 | mProcessTitle = new fltk::Widget(0, 0, 230, 25, ""); |
---|
| 2716 | fltk::Widget* o = mProcessTitle; |
---|
| 2717 | o->set_vertical(); |
---|
| 2718 | o->box(fltk::NO_BOX); |
---|
| 2719 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 2720 | o->labelsize(15.0); |
---|
| 2721 | o->color((fltk::Color)0xe0dfe300); |
---|
| 2722 | o->align(fltk::ALIGN_CENTER); |
---|
| 2723 | } |
---|
| 2724 | |
---|
| 2725 | /* |
---|
| 2726 | { |
---|
| 2727 | mTypeLabel = new fltk::Output(26, 82, 5, 25, "Type"); |
---|
| 2728 | fltk::Output* o = mTypeLabel; |
---|
| 2729 | o->set_vertical(); |
---|
| 2730 | o->box(fltk::NO_BOX); |
---|
| 2731 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 2732 | o->color((fltk::Color)0xe0dfe300); |
---|
| 2733 | o->align(fltk::ALIGN_RIGHT); |
---|
| 2734 | } |
---|
| 2735 | */ |
---|
| 2736 | |
---|
| 2737 | { |
---|
| 2738 | mMeshReductionLabel = new fltk::Output(26, 124, 5, 25, "Mesh Reduction"); |
---|
| 2739 | fltk::Output* o = mMeshReductionLabel; |
---|
| 2740 | o->set_vertical(); |
---|
| 2741 | o->box(fltk::NO_BOX); |
---|
| 2742 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 2743 | o->color((fltk::Color)0xe0dfe300); |
---|
| 2744 | o->align(fltk::ALIGN_RIGHT); |
---|
| 2745 | } |
---|
| 2746 | |
---|
| 2747 | //mChangeTexture = new fltk::CheckButton(30, 104, 25, 25, "Change texture"); |
---|
| 2748 | |
---|
| 2749 | { |
---|
| 2750 | fltk::Group* o; |
---|
| 2751 | o = MainView = new fltk::Group(30, 140, 30, 60); |
---|
| 2752 | o->begin(); |
---|
| 2753 | |
---|
| 2754 | { |
---|
| 2755 | mPercent = new fltk::RadioButton(0, 5, 25, 25, "%"); |
---|
| 2756 | mVerticesNumber = new fltk::RadioButton(0, 20, 25, 25, "Vertices number"); |
---|
| 2757 | } |
---|
| 2758 | o->end(); |
---|
| 2759 | } |
---|
| 2760 | |
---|
| 2761 | { |
---|
| 2762 | mMeshReduction = new fltk::FloatInput(75, 181, 75, 21, "Value:"); |
---|
| 2763 | fltk::FloatInput* o = mMeshReduction; |
---|
| 2764 | o->type(1); |
---|
| 2765 | } |
---|
| 2766 | |
---|
| 2767 | { |
---|
| 2768 | fltk::Group* o; |
---|
| 2769 | o = MainView = new fltk::Group(30, 100, 30, 60); |
---|
| 2770 | o->begin(); |
---|
| 2771 | |
---|
| 2772 | { |
---|
| 2773 | mOneCacheStrip = new fltk::RadioButton(0, 4, 25, 25, "One cache strip"); |
---|
| 2774 | mQualityStrips = new fltk::RadioButton(0, 23, 25, 25, "Quality strips"); |
---|
| 2775 | } |
---|
| 2776 | o->end(); |
---|
| 2777 | } |
---|
| 2778 | |
---|
| 2779 | { |
---|
| 2780 | fltk::Browser* o = mMeshInfo = new fltk::Browser(0, 20, 230, 380); |
---|
| 2781 | o->set_vertical(); |
---|
| 2782 | o->callback((fltk::Callback*)cb_mMeshInfo); |
---|
| 2783 | } |
---|
| 2784 | o->end(); |
---|
| 2785 | } |
---|
| 2786 | |
---|
| 2787 | o->end(); |
---|
| 2788 | |
---|
| 2789 | fltk::Group::current()->resizable(o); |
---|
| 2790 | } |
---|
| 2791 | |
---|
| 2792 | { |
---|
| 2793 | fltk::MenuBar* o = menuBar = new fltk::MenuBar(1, 2, 801, 21); |
---|
| 2794 | o->begin(); |
---|
| 2795 | |
---|
| 2796 | // Menu File. |
---|
| 2797 | { |
---|
| 2798 | fltk::ItemGroup* o = menuFile = new fltk::ItemGroup("File"); |
---|
| 2799 | o->begin(); |
---|
| 2800 | |
---|
| 2801 | { |
---|
| 2802 | fltk::Item* o = menuFileOpen = new fltk::Item("Open"); |
---|
| 2803 | o->callback((fltk::Callback*)cb_menuFileOpen); |
---|
| 2804 | } |
---|
| 2805 | |
---|
| 2806 | { |
---|
| 2807 | fltk::Item* o = menuFileSave = new fltk::Item("Save"); |
---|
| 2808 | o->callback((fltk::Callback*)cb_menuFileSave); |
---|
| 2809 | } |
---|
| 2810 | |
---|
| 2811 | { |
---|
| 2812 | fltk::Item* o = menuFileSaveAs = new fltk::Item("Save As"); |
---|
| 2813 | o->callback((fltk::Callback*)cb_menuFileSaveAs); |
---|
| 2814 | } |
---|
| 2815 | |
---|
| 2816 | { |
---|
| 2817 | fltk::Item* o = menuMeshExportOBJ = new fltk::Item("Export to OBJ"); |
---|
| 2818 | o->callback((fltk::Callback*)cb_menuMeshExportOBJ); |
---|
| 2819 | } |
---|
| 2820 | |
---|
| 2821 | //{ |
---|
| 2822 | // fltk::Item* o = menuFileTransformSharedVertex = new fltk::Item("Transform to Shared Vertex"); |
---|
| 2823 | // o->callback((fltk::Callback*)cb_menuFileTransformSharedVertex); |
---|
| 2824 | //} |
---|
| 2825 | |
---|
| 2826 | { |
---|
| 2827 | menuLoadTextures = new fltk::ItemGroup("Load Textures"); |
---|
| 2828 | o->add(menuLoadTextures); |
---|
| 2829 | } |
---|
| 2830 | |
---|
| 2831 | { |
---|
| 2832 | fltk::Item* o = menuFileQuit = new fltk::Item("Quit"); |
---|
| 2833 | o->callback((fltk::Callback*)cb_menuFileQuit); |
---|
| 2834 | } |
---|
| 2835 | |
---|
| 2836 | o->end(); |
---|
| 2837 | } |
---|
| 2838 | |
---|
| 2839 | // Menu Edit. |
---|
| 2840 | { |
---|
| 2841 | fltk::ItemGroup* o = menuEdit = new fltk::ItemGroup("Edit"); |
---|
| 2842 | o->begin(); |
---|
| 2843 | |
---|
| 2844 | { |
---|
| 2845 | fltk::Item* o = menuEditUndo = new fltk::Item("Undo"); |
---|
| 2846 | o->callback((fltk::Callback*)cb_menuEditUndo); |
---|
| 2847 | } |
---|
| 2848 | |
---|
| 2849 | { |
---|
| 2850 | fltk::Item* o = menuEditFit = new fltk::Item("Fit"); |
---|
| 2851 | o->callback((fltk::Callback*)cb_menuEditFit); |
---|
| 2852 | |
---|
| 2853 | } |
---|
| 2854 | |
---|
| 2855 | { |
---|
| 2856 | fltk::Item* o = menuEditRotate = new fltk::Item("Rotate"); |
---|
| 2857 | o->type(fltk::Item::RADIO); |
---|
| 2858 | o->set_value(); |
---|
| 2859 | o->callback((fltk::Callback*)cb_menuEditRotate); |
---|
| 2860 | } |
---|
| 2861 | |
---|
| 2862 | { |
---|
| 2863 | fltk::Item* o = menuEditPan = new fltk::Item("Pan"); |
---|
| 2864 | o->type(fltk::Item::RADIO); |
---|
| 2865 | o->callback((fltk::Callback*)cb_menuEditPan); |
---|
| 2866 | } |
---|
| 2867 | |
---|
| 2868 | //{ |
---|
| 2869 | // fltk::Item* o = menuEditZoom = new fltk::Item("Zoom"); |
---|
| 2870 | // o->callback((fltk::Callback*)cb_menuEditZoom); |
---|
| 2871 | //} |
---|
| 2872 | |
---|
| 2873 | new fltk::Divider(); |
---|
| 2874 | |
---|
| 2875 | { |
---|
| 2876 | fltk::Item* o = menuMeshInfo = new fltk::Item("Mesh info"); |
---|
| 2877 | o->callback((fltk::Callback*)cb_menuMeshInfo); |
---|
| 2878 | } |
---|
| 2879 | |
---|
| 2880 | { |
---|
| 2881 | fltk::Item* o; |
---|
| 2882 | o = menuSelectLeaves = new fltk::Item("Select leaves"); |
---|
| 2883 | o->callback((fltk::Callback*)cb_menuSelectLeaves); |
---|
| 2884 | } |
---|
| 2885 | |
---|
| 2886 | o->end(); |
---|
| 2887 | } |
---|
| 2888 | |
---|
| 2889 | // Menu Render. |
---|
| 2890 | { |
---|
| 2891 | fltk::ItemGroup* o = menuRender = new fltk::ItemGroup("Render"); |
---|
| 2892 | o->begin(); |
---|
| 2893 | |
---|
| 2894 | { |
---|
| 2895 | fltk::Item* o = menuRenderWire = new fltk::Item("Wire"); |
---|
| 2896 | o->type(fltk::Item::RADIO); |
---|
| 2897 | o->callback((fltk::Callback*)cb_menuRenderWire); |
---|
| 2898 | } |
---|
| 2899 | |
---|
| 2900 | { |
---|
| 2901 | fltk::Item* o = menuRenderSolid = new fltk::Item("Solid"); |
---|
| 2902 | o->type(fltk::Item::RADIO); |
---|
| 2903 | o->callback((fltk::Callback*)cb_menuRenderSolid); |
---|
| 2904 | } |
---|
| 2905 | |
---|
| 2906 | //new fltk::Divider(); |
---|
| 2907 | |
---|
| 2908 | { |
---|
| 2909 | fltk::Item* o = menuRenderCW = new fltk::Item("CW"); |
---|
| 2910 | o->type(fltk::Item::RADIO); |
---|
| 2911 | o->callback((fltk::Callback*)cb_menuRenderCW); |
---|
| 2912 | |
---|
| 2913 | //o->hide(); |
---|
| 2914 | } |
---|
| 2915 | |
---|
| 2916 | { |
---|
| 2917 | fltk::Item* o = menuRenderCCW = new fltk::Item("CCW"); |
---|
| 2918 | o->type(fltk::Item::RADIO); |
---|
| 2919 | o->set_value(); |
---|
| 2920 | o->callback((fltk::Callback*)cb_menuRenderCCW); |
---|
| 2921 | |
---|
| 2922 | //o->hide(); |
---|
| 2923 | } |
---|
| 2924 | |
---|
| 2925 | new fltk::Divider(); |
---|
| 2926 | |
---|
| 2927 | { |
---|
| 2928 | fltk::Item* o = menuRenderFlat = new fltk::Item("Flat"); |
---|
| 2929 | o->type(fltk::Item::RADIO); |
---|
| 2930 | o->clear_value(); |
---|
| 2931 | o->callback((fltk::Callback*)cb_menuRenderFlat); |
---|
| 2932 | } |
---|
| 2933 | |
---|
| 2934 | { |
---|
| 2935 | fltk::Item* o = menuRenderSmooth = new fltk::Item("Smooth"); |
---|
| 2936 | o->type(fltk::Item::RADIO); |
---|
| 2937 | o->set_value(); |
---|
| 2938 | o->callback((fltk::Callback*)cb_menuRenderSmooth); |
---|
| 2939 | } |
---|
| 2940 | |
---|
| 2941 | new fltk::Divider(); |
---|
| 2942 | |
---|
| 2943 | { |
---|
| 2944 | fltk::Item* o = menuRenderTextures = new fltk::Item("Texture mapping"); |
---|
| 2945 | o->type(fltk::Item::RADIO); |
---|
| 2946 | o->set_value(); |
---|
| 2947 | o->callback((fltk::Callback*)cb_menuRenderTextures); |
---|
| 2948 | } |
---|
| 2949 | |
---|
| 2950 | o->end(); |
---|
| 2951 | } |
---|
| 2952 | |
---|
| 2953 | // Menu Stripify. |
---|
| 2954 | { |
---|
| 2955 | fltk::Item* o = menuStripify = new fltk::Item("Stripify"); |
---|
| 2956 | o->callback((fltk::Callback*)cb_menuStripify); |
---|
| 2957 | } |
---|
| 2958 | |
---|
| 2959 | // Menu Simplify. |
---|
| 2960 | { |
---|
| 2961 | fltk::ItemGroup* o = menuSimplify = new fltk::ItemGroup("Simplify"); |
---|
| 2962 | o->callback((fltk::Callback*)cb_menuSimplify); |
---|
| 2963 | o->begin(); |
---|
| 2964 | |
---|
| 2965 | { |
---|
| 2966 | fltk::Item* o; |
---|
| 2967 | o = menuSimplifyEdgeCollapse = new fltk::Item("Mesh Simplification"); |
---|
| 2968 | o->callback((fltk::Callback*)cb_menuSimplifyEdgeCollapse); |
---|
| 2969 | } |
---|
| 2970 | |
---|
| 2971 | { |
---|
| 2972 | fltk::Item* o; |
---|
| 2973 | o = menuSimplifyLeavesCollapse = new fltk::Item("Leaves Simplification"); |
---|
| 2974 | o->callback((fltk::Callback*)cb_menuSimplifyLeavesCollapse); |
---|
| 2975 | } |
---|
| 2976 | |
---|
| 2977 | o->end(); |
---|
| 2978 | } |
---|
| 2979 | |
---|
| 2980 | // Menu LodStrips. |
---|
| 2981 | { |
---|
| 2982 | fltk::ItemGroup* o; |
---|
| 2983 | o = menuLodStrips = new fltk::ItemGroup("LodStrips"); |
---|
| 2984 | o->begin(); |
---|
| 2985 | |
---|
| 2986 | { |
---|
| 2987 | fltk::Item* o; |
---|
| 2988 | o = menuLodStripsGenerate = new fltk::Item("Generate"); |
---|
| 2989 | o->callback((fltk::Callback*)cb_menuLodStripsGenerate); |
---|
| 2990 | } |
---|
| 2991 | |
---|
| 2992 | { |
---|
| 2993 | fltk::Item* o; |
---|
| 2994 | o = menuLodStripsVisualize = new fltk::Item("Visualize"); |
---|
| 2995 | o->callback((fltk::Callback*)cb_menuLodStripsVisualize); |
---|
| 2996 | } |
---|
| 2997 | |
---|
| 2998 | o->end(); |
---|
| 2999 | } |
---|
| 3000 | |
---|
| 3001 | // Menu LodTrees. |
---|
| 3002 | |
---|
| 3003 | { |
---|
| 3004 | fltk::ItemGroup* o; |
---|
| 3005 | o = menuLodTrees = new fltk::ItemGroup("LodTrees"); |
---|
| 3006 | o->begin(); |
---|
| 3007 | |
---|
| 3008 | { |
---|
| 3009 | fltk::Item* o; |
---|
| 3010 | o = menuLodTreesGenerate = new fltk::Item("Generate"); |
---|
| 3011 | o->callback((fltk::Callback*)cb_menuLodTreesGenerate); |
---|
| 3012 | } |
---|
| 3013 | { |
---|
| 3014 | fltk::Item* o; |
---|
| 3015 | o = menuLodTreesVisualize = new fltk::Item("Visualize"); |
---|
| 3016 | o->callback((fltk::Callback*)cb_menuLodTreesVisualize); |
---|
| 3017 | } |
---|
| 3018 | |
---|
| 3019 | o->end(); |
---|
| 3020 | } |
---|
| 3021 | |
---|
| 3022 | |
---|
| 3023 | { |
---|
| 3024 | fltk::ItemGroup* o = new fltk::ItemGroup("?"); |
---|
| 3025 | o->begin(); |
---|
| 3026 | |
---|
| 3027 | { |
---|
| 3028 | fltk::Item* o = menuHelpAbout = new fltk::Item("About"); |
---|
| 3029 | o->callback((fltk::Callback*)cb_menuHelpAbout); |
---|
| 3030 | } |
---|
| 3031 | |
---|
| 3032 | o->end(); |
---|
| 3033 | } |
---|
| 3034 | |
---|
| 3035 | /* { |
---|
| 3036 | fltk::SharedImage *gifLogo = logo->get("media\\logos\\logo.gif"); |
---|
| 3037 | |
---|
| 3038 | //o->callback((fltk::Callback*)cb_mLogo); |
---|
| 3039 | |
---|
| 3040 | mLogo = new fltk::InvisibleBox(406, 1, 43, 13); |
---|
| 3041 | mLogo->image(gifLogo); |
---|
| 3042 | }*/ |
---|
| 3043 | |
---|
| 3044 | o->end(); |
---|
| 3045 | } |
---|
| 3046 | |
---|
| 3047 | { |
---|
| 3048 | fltk::Group* o; |
---|
| 3049 | o = ApplicationBar = new fltk::Group(0, 570, 807, 28); |
---|
| 3050 | o->box(fltk::BORDER_BOX); |
---|
| 3051 | o->begin(); |
---|
| 3052 | |
---|
| 3053 | { |
---|
| 3054 | fltk::Widget* o; |
---|
| 3055 | o = mFPS = new fltk::Widget(10, 4, 30, 15, "FPS "); |
---|
| 3056 | o->box(fltk::NO_BOX); |
---|
| 3057 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 3058 | o->color((fltk::Color)0xe0dfe300); |
---|
| 3059 | } |
---|
| 3060 | |
---|
| 3061 | { |
---|
| 3062 | fltk::Widget* o; |
---|
| 3063 | o = mVertices = new fltk::Widget(154, 4, 40, 15, "Vertices"); |
---|
| 3064 | o->box(fltk::NO_BOX); |
---|
| 3065 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 3066 | o->color((fltk::Color)0xe0dfe300); |
---|
| 3067 | } |
---|
| 3068 | |
---|
| 3069 | { |
---|
| 3070 | fltk::Widget* o; |
---|
| 3071 | o = mTriangles = new fltk::Widget(254, 3, 40, 15, "Triangles"); |
---|
| 3072 | o->box(fltk::NO_BOX); |
---|
| 3073 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 3074 | o->color((fltk::Color)0xe0dfe300); |
---|
| 3075 | |
---|
| 3076 | // Hide triangle count. |
---|
| 3077 | o->hide(); |
---|
| 3078 | } |
---|
| 3079 | |
---|
| 3080 | { |
---|
| 3081 | fltk::Widget* o; |
---|
| 3082 | o = mStrips = new fltk::Widget(354, 3, 30, 15, "Strips"); |
---|
| 3083 | o->box(fltk::NO_BOX); |
---|
| 3084 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 3085 | o->color((fltk::Color)0xe0dfe300); |
---|
| 3086 | } |
---|
| 3087 | |
---|
| 3088 | //{ |
---|
| 3089 | // fltk::Widget* o; |
---|
| 3090 | // o = mQuads = new fltk::Widget(454, 4, 40, 15, "Quads"); |
---|
| 3091 | // o->box(fltk::NO_BOX); |
---|
| 3092 | // o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 3093 | // o->color((fltk::Color)0xe0dfe300); |
---|
| 3094 | //} |
---|
| 3095 | |
---|
| 3096 | { |
---|
| 3097 | fltk::Widget* o; |
---|
| 3098 | o = mMB = new fltk::Widget(740, 3, 30, 15, "MB"); |
---|
| 3099 | o->box(fltk::NO_BOX); |
---|
| 3100 | o->labelfont(fltk::HELVETICA_BOLD); |
---|
| 3101 | o->color((fltk::Color)0xe0dfe300); |
---|
| 3102 | } |
---|
| 3103 | o->end(); |
---|
| 3104 | } |
---|
| 3105 | |
---|
| 3106 | |
---|
| 3107 | o->end(); |
---|
| 3108 | } |
---|
| 3109 | |
---|
| 3110 | fltk::focus(geoMeshView); |
---|
| 3111 | |
---|
| 3112 | |
---|
| 3113 | /*Hide Right Panel*/ |
---|
| 3114 | hideRightPanel(); |
---|
| 3115 | |
---|
| 3116 | mMainWindow->show(); |
---|
| 3117 | } |
---|
| 3118 | |
---|
| 3119 | /****************/ |
---|
| 3120 | /* Destroyer */ |
---|
| 3121 | /****************/ |
---|
| 3122 | GeoMeshViewUI::~GeoMeshViewUI() |
---|
| 3123 | { |
---|
| 3124 | delete geoMeshLoader; |
---|
| 3125 | mMainWindow->destroy(); |
---|
| 3126 | } |
---|
| 3127 | |
---|
| 3128 | // Shows the main window. |
---|
| 3129 | void GeoMeshViewUI::show() |
---|
| 3130 | { |
---|
| 3131 | } |
---|
| 3132 | |
---|
| 3133 | |
---|
| 3134 | void GeoMeshViewUI::BuildLoadTextureSubMeshMenu(void) |
---|
| 3135 | { |
---|
| 3136 | if (SubMeshNames) |
---|
| 3137 | { |
---|
| 3138 | menuLoadTextures->clear(); |
---|
| 3139 | for (int i=0; i<numSubMeshNames; i++) |
---|
| 3140 | { |
---|
| 3141 | delete[] SubMeshNames[i]; |
---|
| 3142 | } |
---|
| 3143 | delete[] SubMeshNames; |
---|
| 3144 | } |
---|
| 3145 | |
---|
| 3146 | menuFileLoadTexture = new fltk::Item("Entire model"); |
---|
| 3147 | menuFileLoadTexture->callback((fltk::Callback*)cb_menuFileLoadTexture); |
---|
| 3148 | menuLoadTextures->add(menuFileLoadTexture); |
---|
| 3149 | |
---|
| 3150 | numSubMeshNames=geoMeshView->getSubMeshCount(); |
---|
| 3151 | SubMeshNames=new char*[numSubMeshNames]; |
---|
| 3152 | |
---|
| 3153 | for (int i=0; i<numSubMeshNames; i++) |
---|
| 3154 | { |
---|
| 3155 | SubMeshNames[i]=new char[10]; |
---|
| 3156 | |
---|
| 3157 | sprintf(SubMeshNames[i],"submesh %d",i); |
---|
| 3158 | fltk::Item *item = new fltk::Item(SubMeshNames[i]); |
---|
| 3159 | item->callback((fltk::Callback*)cb_menuFileLoadTextureSubMesh); |
---|
| 3160 | menuLoadTextures->add(item); |
---|
| 3161 | } |
---|
| 3162 | } |
---|