source: GTP/trunk/Lib/Geom/GeoTool/include/GeoMeshView.h @ 774

Revision 774, 5.5 KB checked in by gumbau, 18 years ago (diff)

GTGeometry and GeoTool? initial imports

Line 
1// generated by Fast Light User Interface Designer (fluid) version 2.0100
2#ifndef GeoMeshView_h
3#define GeoMeshView_h
4
5#include        <fltk/events.h>
6#include        <stdlib.h>
7#include        <time.h>
8#include        <iostream>
9#include        <GL/glut.h>
10#include        <fltk/GlWindow.h>
11#include        <GeoVertexBuffer.h>
12#include        <GeoMesh.h>
13//#ifndef       GeoMeshViewUI_h
14#include        <GeoMeshSaver.h>
15#include        <GeoMeshViewUI.h>
16//#include      <GeoLodStripsLibrary.h>
17//#endif
18
19class GeoMeshView : public fltk::GlWindow
20{
21        friend  class   GeoMeshViewUI;
22
23        public:
24
25        // this value determines the scaling factor used to draw the cube.
26        double  size;
27        double  mScaleFactor;
28        bool            mWire;
29        bool            mSolid;
30        bool            mCW;
31        bool            mCCW;
32        bool            mPan;
33        bool            mRotate;
34        bool            mLodStrip;
35
36        GeoMeshView(int                                         x,
37                        int                                             y,
38                        int                                             w,
39                        int                                             h,
40                        const   char            *l                                                      =       0,
41                        GeoMeshViewUI   *geoMeshViewUI  =       0);
42
43        /*      This function is callalled by the zoom slider
44         *     
45         */
46        void scale(double factor){size  =       factor;};
47
48        /* Set the rotation about the vertical (y ) axis.
49         *
50         * This function is called by the horizontal roller in GeoMeshViewUI
51         * and the initialize button in GeoMeshViewUI.
52         */
53        void v_angle(float angle){vAng=angle;};
54       
55        // Return the rotation about the vertical (y ) axis.
56        float v_angle(){return vAng;};
57       
58        /* Set the rotation about the horizontal (x ) axis.
59         *
60         * This function is called by the vertical roller in GeoMeshViewUI
61         and the
62         * initialize button in GeoMeshViewUI.
63         */
64        void h_angle(float angle){hAng=angle;};
65       
66        // the rotation about the horizontal (x ) axis.
67        float h_angle(){return hAng;};
68       
69        /* Sets the x shift of the cube view camera.
70         *
71         * This function is called by the slider in GeoMeshViewUI and the
72         * initialize button in GeoMeshViewUI.
73         */
74        void panx(float x){xshift=x;};
75       
76        /* Sets the y shift of the cube view camera.
77         *
78         * This function is called by the slider in GeoMeshViewUI and the
79         * initialize button in GeoMeshViewUI.
80         */
81        void pany(float y){yshift=y;};
82
83        //      Wire model.
84        void    activeWire(){mWire      =       true;};
85        void    deactiveWire(){mWire    =       false;};
86
87        //      Solid model.
88        void    activeSolid(){mSolid    =       true;};
89        void    deactiveSolid(){mSolid  =       false;};
90
91        //      Clockwise mode.
92        void    activeCW(){mCW  =       true;};
93        void    deactiveCW(){mCW        =       false;};
94
95        //      Counter Clockwise mode.
96        void    activeCCW(){mCCW        =       true;};
97        void    deactiveCCW(){mCCW      =       false;};
98
99        //      Pan mode.
100        void    activePan(){mPan        =       true;};
101        void    deactivePan(){mPan      =       false;};
102
103        //      Rotate mode.
104        void    activeRotate(){mRotate  =       true;};
105        void    deactiveRotate(){mRotate        =       false;};
106
107        //      LodStrip mode.
108        void    activeLodStrip(){mLodStrip      =       true;};
109        void    deactiveLodStrip(){mLodStrip    =       false;};
110
111        //      Ilumination modes.
112        void    flat(){glShadeModel(GL_FLAT);};
113        void    smooth(){glShadeModel(GL_SMOOTH);};
114
115        //      Fits the object in the window view.
116        void    fit()
117        {
118                vAng            = 0.0;
119                hAng            =       0.0;
120                size            =       0.0;
121                xshift  =       0.0;
122                yshift  =       0.0;
123        };
124
125        /* Sets the Mesh to display.
126        */
127        void    setMesh(Geometry::Mesh  *geomesh);
128
129        /* The widget class draw() override.
130         * The draw() function initialize Gl for another round of
131         * drawing then calls specialized functions for drawing each
132         * of the entities displayed in the cube view.
133         */
134        void draw();
135
136        //      Gets the bounding box.
137        Geometry::GeometryBounds        getBoundingBox();
138
139        //      Store one random color to each strip.
140        void    setStripColors();
141
142        //      Get the number of frames per second.
143        size_t  getFPS();
144
145        //      JGA
146        //      Sets the colorsubmeshi variable
147        void    setColorSubmeshi(int submeshIndex);
148
149        //      Sets the leaves submesh index.
150        void    setLeavesSubmesh(int submeshIndex);
151
152        //      Gets the leaves submesh index.
153        int     getLeavesSubmesh();
154
155        //      Gets the triangle count of the current lod.
156        size_t  getLodStripsTriangleCount();
157       
158        //      Sets the lodstripslibrary object.
159        void    setLodStripsLibrary(Geometry::LodStripsLibrary *lodstrips);
160
161        //      Change de Level of detail of the object.
162        void    GoToLod(unsigned int lod);
163
164        private:
165        /* Draw the cube boundaries
166         * Draw the faces of the cube using the boxv[] vertices, using
167         * GL_LINE_LOOP for the faces. The color is #defined by
168         * CUBECOLOR.
169         */
170
171        //      GeoMeshViewUI.
172        GeoMeshViewUI   *mGeoMeshViewUI;
173
174        //      LodStrips library object.
175        Geometry::LodStripsLibrary      *lodStripsLib;
176       
177        //      Flag tha activate / deactivate the color strips.
178        bool    colorStripsFlag;
179
180        // Stores the index of the mesh to paint of red color.
181        int             colorsubmeshi;
182
183        //      Frames per second.
184        size_t  mFPS;
185
186        //      StartTime for FPS.
187        clock_t mStartTime;
188
189        float           xMed;
190        float           yMed;
191        float           zMed;
192
193        int                     leavesSubmesh;
194       
195        //      Submesh count.
196        int                     mSubMeshCount;
197
198        //      Mesh to show.
199        Geometry::Mesh  *geoMesh;
200
201        virtual int     handle(int event);
202
203        //      Paint the mesh object.
204        void    drawGeoMesh(int selectedMesh);
205        void    drawTriangleList(int selectedMesh);
206        void    drawTriangleStrip();
207        void    drawLodStrip();
208        void    enableColorStrips();
209        void    disableColorStrips();
210        bool    getColorStrips();
211
212        //      Calculate the number of frames per second.
213        void    calcFPS();
214
215        //      Copy the mesh vertices to the vertex array.
216        void    refreshVertices(Geometry::Mesh  *geomesh);
217
218        float   vAng;
219        float   hAng;
220        float   xshift;
221        float   yshift;
222        int                     mMouseX;
223        int                     mMouseY;
224        int                     mSizeY;
225        GLfloat **mPosArray;
226        GLfloat **mNorArray;
227        GLfloat *mSharedPosArray;
228        GLfloat *mSharedNorArray;
229        GLuint  **mIndexArray;
230
231        struct  ColorElement
232        {
233                float   r;
234                float   g;
235                float   b;
236        };
237
238        ColorElement    *mStripColors;
239
240        //      Idetifier of Visualization List.
241        GLuint  mIdVisualList;
242};
243
244#endif
245
Note: See TracBrowser for help on using the repository browser.