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

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