source: GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp @ 841

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