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