1 | // generated by Fast Light User Interface Designer (fluid) version 2.0100 |
---|
2 | #ifndef GeoMeshViewUI_h |
---|
3 | #define GeoMeshViewUI_h |
---|
4 | #include "GL/glew.h" |
---|
5 | #ifdef _WIN32 |
---|
6 | #include "GL/wglew.h" |
---|
7 | #endif |
---|
8 | #include <stdio.h> |
---|
9 | #include <stdlib.h> |
---|
10 | #include <string.h> |
---|
11 | #include <fltk/run.h> |
---|
12 | #include <fltk/Group.h> |
---|
13 | #include <fltk/Window.h> |
---|
14 | #include <fltk/ask.h> |
---|
15 | #include <fltk/file_chooser.h> |
---|
16 | #include <fltk/FileChooser.h> |
---|
17 | #include <fltk/MenuBar.h> |
---|
18 | #include <fltk/Input.h> |
---|
19 | #include <fltk/Button.h> |
---|
20 | #include <fltk/ReturnButton.h> |
---|
21 | #include <fltk/TextBuffer.h> |
---|
22 | #include <fltk/TextEditor.h> |
---|
23 | #include <fltk/Input.h> |
---|
24 | #include <fltk/events.h> |
---|
25 | #include <fltk/InvisibleBox.h> |
---|
26 | #include <fltk/ItemGroup.h> |
---|
27 | #include <fltk/Item.h> |
---|
28 | #include <fltk/Divider.h> |
---|
29 | #include <fltk/Output.h> |
---|
30 | #include <fltk/Button.h> |
---|
31 | #include <fltk/ProgressBar.h> |
---|
32 | #include <fltk/CheckButton.h> |
---|
33 | #include <fltk/RadioButton.h> |
---|
34 | #include <fltk/FloatInput.h> |
---|
35 | #include <fltk/Browser.h> |
---|
36 | #include <fltk/Image.h> |
---|
37 | #include <fltk/SharedImage.h> |
---|
38 | #include <fltk/Slider.h> |
---|
39 | #include <GeoMesh.h> |
---|
40 | #include <GeoLodStripsLibrary.h> |
---|
41 | #include <GeoMeshView.h> |
---|
42 | #include <GeoMeshSaver.h> |
---|
43 | #include <GeoMeshSimplifier.h> |
---|
44 | #include <GeoMeshStripifier.h> |
---|
45 | #include <GeoTreeSimplifier.h> |
---|
46 | #include "GeoTreeSimpSequence.h" |
---|
47 | #include "GeoLodStripsConstructor.h" |
---|
48 | #include "GeoLodTreeLibrary.h" |
---|
49 | |
---|
50 | // About Dialog. |
---|
51 | #include "GTAboutDialog.h" |
---|
52 | #include "../resource.h" |
---|
53 | |
---|
54 | #include <GeoMaterialLoader.h> |
---|
55 | |
---|
56 | // State of the button process. |
---|
57 | enum ProcessState |
---|
58 | { |
---|
59 | NONE, |
---|
60 | STRIPIFY, |
---|
61 | EDGE_COLLAPSE, |
---|
62 | LEAVES_COLLAPSE, |
---|
63 | LODSTRIPS, |
---|
64 | LODSTRIPS_AUTO, |
---|
65 | LODTREES, |
---|
66 | LODTREES_AUTO, |
---|
67 | SELECT_LEAVES, |
---|
68 | VISUALIZE_LODSTRIPS, |
---|
69 | VISUALIZE_LODTREES |
---|
70 | }; |
---|
71 | |
---|
72 | // Simplification types |
---|
73 | enum SimplificationType |
---|
74 | { |
---|
75 | NO_SIMPLIFICATION, |
---|
76 | MESHSIMP, |
---|
77 | HOJAS, |
---|
78 | VIEWPOINTDRIVEN |
---|
79 | }; |
---|
80 | |
---|
81 | enum ProgressBarType |
---|
82 | { |
---|
83 | PROCESS, |
---|
84 | BUILD |
---|
85 | }; |
---|
86 | |
---|
87 | using namespace Geometry; |
---|
88 | |
---|
89 | class GeoMeshViewUI |
---|
90 | { |
---|
91 | friend class GeoMeshView; |
---|
92 | |
---|
93 | private: |
---|
94 | |
---|
95 | // File name Selected. |
---|
96 | char *mFileName; |
---|
97 | |
---|
98 | // The state of the application menus. |
---|
99 | ProcessState mApplicationState; |
---|
100 | |
---|
101 | // Mesh object(Model). |
---|
102 | Mesh *mGeoMesh; |
---|
103 | |
---|
104 | // Mesh for undo operation. |
---|
105 | Mesh *mUndoMesh; |
---|
106 | |
---|
107 | // Lod strips object. |
---|
108 | LodStripsLibrary *lodStripsLib; |
---|
109 | // Lod tree object. |
---|
110 | LodTreeLibrary *lodTreeLib; |
---|
111 | |
---|
112 | MeshSimplifier *mMeshSimplifier; |
---|
113 | TreeSimplifier *mTreeSimplifier; |
---|
114 | char *nombremesh; |
---|
115 | SimplificationType simplificationState; |
---|
116 | ProgressBarType progressBarType; |
---|
117 | |
---|
118 | MeshSimplificationSequence *oMeshSimpSequence; |
---|
119 | LodStripsConstructor *oLodStrip; |
---|
120 | GeoMeshLoader *geoMeshLoader; |
---|
121 | |
---|
122 | inline void cb_menuFileOpen_i(fltk::Item*, void*); |
---|
123 | static void cb_menuFileOpen(fltk::Item*, void*); |
---|
124 | inline void cb_menuFileSave_i(fltk::Item*, void*); |
---|
125 | static void cb_menuFileSave(fltk::Item*, void*); |
---|
126 | inline void cb_menuFileSaveAs_i(fltk::Item*, void*); |
---|
127 | static void cb_menuFileSaveAs(fltk::Item*, void*); |
---|
128 | inline void cb_menuFileLoadTexture_i(fltk::Item*, void*); |
---|
129 | static void cb_menuFileLoadTexture(fltk::Item*, void*); |
---|
130 | inline void cb_menuFileLoadTextureSubMesh_i(fltk::Item*, void*); |
---|
131 | static void cb_menuFileLoadTextureSubMesh(fltk::Item*, void*); |
---|
132 | |
---|
133 | inline void cb_menuMeshInfo_i(fltk::Item*, void*); |
---|
134 | static void cb_menuMeshInfo(fltk::Item*, void*); |
---|
135 | inline void cb_menuMeshExportOBJ_i(fltk::Item*, void*); |
---|
136 | static void cb_menuMeshExportOBJ(fltk::Item*, void*); |
---|
137 | inline void cb_menuTransformSharedVertex_i(fltk::Item*, void*); |
---|
138 | static void cb_menuFileTransformSharedVertex(fltk::Item* o, void* v); |
---|
139 | |
---|
140 | inline void cb_menuFileQuit_i(fltk::Item*, void*); |
---|
141 | static void cb_menuFileQuit(fltk::Item*, void*); |
---|
142 | inline void cb_menuEditUndo_i(fltk::Item*, void*); |
---|
143 | static void cb_menuEditUndo(fltk::Item*, void*); |
---|
144 | inline void cb_menuEditFit_i(fltk::Item*, void*); |
---|
145 | static void cb_menuEditFit(fltk::Item*, void*); |
---|
146 | inline void cb_menuEditRotate_i(fltk::Item*, void*); |
---|
147 | static void cb_menuEditRotate(fltk::Item*, void*); |
---|
148 | inline void cb_menuEditPan_i(fltk::Item*, void*); |
---|
149 | static void cb_menuEditPan(fltk::Item*, void*); |
---|
150 | inline void cb_menuEditZoom_i(fltk::Item*, void*); |
---|
151 | static void cb_menuEditZoom(fltk::Item*, void*); |
---|
152 | inline void cb_menuRenderWire_i(fltk::Item*, void*); |
---|
153 | static void cb_menuRenderWire(fltk::Item*, void*); |
---|
154 | inline void cb_menuRenderSolid_i(fltk::Item*, void*); |
---|
155 | static void cb_menuRenderSolid(fltk::Item*, void*); |
---|
156 | inline void cb_menuRenderCW_i(fltk::Item*, void*); |
---|
157 | static void cb_menuRenderCW(fltk::Item*, void*); |
---|
158 | inline void cb_menuRenderCCW_i(fltk::Item*, void*); |
---|
159 | static void cb_menuRenderCCW(fltk::Item*, void*); |
---|
160 | inline void cb_menuRenderFlat_i(fltk::Item*, void*); |
---|
161 | static void cb_menuRenderFlat(fltk::Item*, void*); |
---|
162 | inline void cb_menuRenderSmooth_i(fltk::Item*, void*); |
---|
163 | static void cb_menuRenderSmooth(fltk::Item*, void*); |
---|
164 | inline void cb_menuRenderTextures_i(fltk::Item*, void*); |
---|
165 | static void cb_menuRenderTextures(fltk::Item*, void*); |
---|
166 | inline void cb_menuStripify_i(fltk::Item*, void*); |
---|
167 | static void cb_menuStripify(fltk::Item*, void*); |
---|
168 | inline void cb_menuSimplify_i(fltk::ItemGroup*, void*); |
---|
169 | static void cb_menuSimplify(fltk::ItemGroup*, void*); |
---|
170 | inline void cb_menuSimplifyEdgeCollapse_i(fltk::Item*, void*); |
---|
171 | static void cb_menuSimplifyEdgeCollapse(fltk::Item*, void*); |
---|
172 | inline void cb_menuSimplifyLeavesCollapse_i(fltk::Item*, void*); |
---|
173 | static void cb_menuSimplifyLeavesCollapse(fltk::Item*, void*); |
---|
174 | |
---|
175 | inline void cb_menuLodStripsGenerate_i(fltk::Item*, void*); |
---|
176 | static void cb_menuLodStripsGenerate(fltk::Item*, void*); |
---|
177 | inline void cb_menuLodStripsVisualize_i(fltk::Item*, void*); |
---|
178 | static void cb_menuLodStripsVisualize(fltk::Item*, void*); |
---|
179 | |
---|
180 | inline void cb_menuSelectLeaves_i(fltk::Item*, void*); |
---|
181 | static void cb_menuSelectLeaves(fltk::Item*, void*); |
---|
182 | inline void cb_menuLodTreesOpenLodStripTrunk_i(fltk::Item*, void*); |
---|
183 | static void cb_menuLodTreesOpenLodStripTrunk(fltk::Item*, void*); |
---|
184 | inline void cb_menuLodTreesOpenLeavesSimplification_i(fltk::Item*, void*); |
---|
185 | static void cb_menuLodTreesOpenLeavesSimplification(fltk::Item*, void*); |
---|
186 | inline void cb_menuLodTreesGenerate_i(fltk::Item*, void*); |
---|
187 | static void cb_menuLodTreesGenerate(fltk::Item*, void*); |
---|
188 | inline void cb_menuLodTreesVisualize_i(fltk::Item*, void*); |
---|
189 | static void cb_menuLodTreesVisualize(fltk::Item*, void*); |
---|
190 | inline void cb_menuHelpAbout_i(fltk::Item*, void*); |
---|
191 | static void cb_menuHelpAbout(fltk::Item*, void*); |
---|
192 | |
---|
193 | inline void cb_mButtonProcess_i(fltk::Button*, void*); |
---|
194 | static void cb_mButtonProcess(fltk::Button*, void*); |
---|
195 | inline void cb_mButtonSort_i(fltk::Button*, void*); |
---|
196 | static void cb_mButtonSort(fltk::Button*, void*); |
---|
197 | inline void cb_mButtonBuild_i(fltk::Button*, void*); |
---|
198 | static void cb_mButtonBuild(fltk::Button*, void*); |
---|
199 | inline void cb_mMeshInfo_i(fltk::Browser*, void*); |
---|
200 | static void cb_mMeshInfo(fltk::Browser*, void*); |
---|
201 | inline void cb_mLodStripSlider_i(fltk::Slider*, void*); |
---|
202 | static void cb_mLodStripSlider(fltk::Slider*, void*); |
---|
203 | inline void cb_mLodTreeSlider_i(fltk::Slider*, void*); |
---|
204 | static void cb_mLodTreeSlider(fltk::Slider*, void*); |
---|
205 | |
---|
206 | // Logo's callback. |
---|
207 | inline void cb_mLogo_i(fltk::InvisibleBox*, void*); |
---|
208 | static void cb_mLogo(fltk::InvisibleBox*, void*); |
---|
209 | |
---|
210 | // Shows build process. |
---|
211 | void activeBuildProcess(); |
---|
212 | |
---|
213 | // Shows the stripify panel. |
---|
214 | void showStripify(); |
---|
215 | |
---|
216 | // Shows the simplify panels. |
---|
217 | void showEdgeCollapse(); |
---|
218 | void showLeavesCollapse(); |
---|
219 | |
---|
220 | // Shows the LodStrips panels. |
---|
221 | void showOpenMeshSimplification(); |
---|
222 | void showAutoGenerateLodStrips(); |
---|
223 | void showAutoGenerateLodTrees(); |
---|
224 | |
---|
225 | // Shows the LodTrees panel. |
---|
226 | void showOpenLeavesSimplification(); |
---|
227 | |
---|
228 | // Show the mesh info browser. |
---|
229 | void showMeshInfo(); |
---|
230 | |
---|
231 | // Show the LodStrips visulization panel. |
---|
232 | void showLodStripSlider(); |
---|
233 | void showLodTreeSlider(); |
---|
234 | |
---|
235 | void hideStripify(); |
---|
236 | void hideEdgeCollapse(); |
---|
237 | void hideLeavesCollapse(); |
---|
238 | void hideOpenMeshSimplification(); |
---|
239 | void hideOpenLeavesSimplification(); |
---|
240 | void hideRightPanel(); |
---|
241 | // Hide the mesh info browser. |
---|
242 | void hideMeshInfo(); |
---|
243 | |
---|
244 | // Hide the LodStrips visualization panel. |
---|
245 | void hideLodStripSlider(); |
---|
246 | void hideLodTreeSlider(); |
---|
247 | |
---|
248 | // Get the number of vertices. |
---|
249 | size_t getVertexCount(Mesh *geoMesh); |
---|
250 | |
---|
251 | // Get the number of triangles. |
---|
252 | size_t getTriangleCount(Mesh *geoMesh); |
---|
253 | |
---|
254 | // Get the number of strips. |
---|
255 | size_t getStripCount(Mesh *geoMesh); |
---|
256 | |
---|
257 | int paintMesh(); |
---|
258 | |
---|
259 | // Simplify the mesh object. |
---|
260 | bool simplifyEdgeCollapse(); |
---|
261 | |
---|
262 | // Simplify the mesh object. |
---|
263 | void simplifyLeavesCollapse(); |
---|
264 | |
---|
265 | // Create a siplification sequence of the simplification method. |
---|
266 | void createSimplificationSequence(); |
---|
267 | |
---|
268 | // Create a siplification sequence of the leaves. |
---|
269 | void createLeavesSequence(const std::string &); |
---|
270 | |
---|
271 | // Stripify the mesh object. |
---|
272 | void stripify(); |
---|
273 | |
---|
274 | // Method that undo then mesh changes. |
---|
275 | void undo(); |
---|
276 | |
---|
277 | // Refresh number of vertices, triangles, strips, ... |
---|
278 | void refreshApplicationBar(); |
---|
279 | |
---|
280 | // Open a mesh file. |
---|
281 | void openMeshFile(void); |
---|
282 | |
---|
283 | // Check if file exists. |
---|
284 | bool fileExists(const char *fileNameMesh); |
---|
285 | |
---|
286 | // Set textures to mesh model. |
---|
287 | void setTextures(); |
---|
288 | |
---|
289 | public: |
---|
290 | |
---|
291 | GeoMeshView *geoMeshView; |
---|
292 | fltk::Window *mMainWindow; |
---|
293 | fltk::Group *MainView; |
---|
294 | fltk::InvisibleBox *cframe; |
---|
295 | fltk::MenuBar *menuBar; |
---|
296 | fltk::ItemGroup *menuFile; |
---|
297 | fltk::Item *menuFileOpen; |
---|
298 | fltk::Item *menuFileSave; |
---|
299 | fltk::Item *menuFileSaveAs; |
---|
300 | fltk::Item *menuMeshInfo; |
---|
301 | fltk::Item *menuMeshExportOBJ; |
---|
302 | fltk::Item *menuFileTransformSharedVertex; |
---|
303 | fltk::ItemGroup *menuLoadTextures; |
---|
304 | fltk::Item *menuFileLoadTexture; |
---|
305 | |
---|
306 | fltk::Item *menuFileQuit; |
---|
307 | fltk::ItemGroup *menuEdit; |
---|
308 | fltk::Item *menuEditUndo; |
---|
309 | fltk::Item *menuEditFit; |
---|
310 | fltk::Item *menuEditRotate; |
---|
311 | fltk::Item *menuEditPan; |
---|
312 | fltk::Item *menuEditZoom; |
---|
313 | fltk::ItemGroup *menuRender; |
---|
314 | fltk::Item *menuRenderWire; |
---|
315 | fltk::Item *menuRenderSolid; |
---|
316 | fltk::Item *menuRenderCW; |
---|
317 | fltk::Item *menuRenderCCW; |
---|
318 | fltk::Item *menuRenderFlat; |
---|
319 | fltk::Item *menuRenderSmooth; |
---|
320 | fltk::Item *menuRenderTextures; |
---|
321 | fltk::Item *menuStripify; |
---|
322 | fltk::ItemGroup *menuSimplify; |
---|
323 | fltk::Item *menuSimplifyEdgeCollapse; |
---|
324 | fltk::Item *menuSimplifyLeavesCollapse; |
---|
325 | fltk::Item *menuSimplifySaveSequence; |
---|
326 | |
---|
327 | fltk::ItemGroup *menuLodStrips; |
---|
328 | fltk::Item *menuLodStripsGenerate; |
---|
329 | fltk::Item *menuLodStripsVisualize; |
---|
330 | fltk::ItemGroup *menuLodTrees; |
---|
331 | fltk::Item *menuLodTreesGenerate; |
---|
332 | fltk::Item *menuLodTreesVisualize; |
---|
333 | |
---|
334 | fltk::Item *menuSelectLeaves; |
---|
335 | fltk::Item *menuLodTreesOpenLodStripTrunk; |
---|
336 | fltk::Item *menuLodTreesOpenLeavesSimplification; |
---|
337 | fltk::Item *menuHelpAbout; |
---|
338 | fltk::InvisibleBox *mLogo; |
---|
339 | fltk::Group *ApplicationBar; |
---|
340 | fltk::Widget *mFPS; |
---|
341 | fltk::Widget *mVertices; |
---|
342 | fltk::Widget *mTriangles; |
---|
343 | fltk::Widget *mStrips; |
---|
344 | fltk::Widget *mQuads; |
---|
345 | fltk::Widget *mMB; |
---|
346 | fltk::Button *mButtonProcess; |
---|
347 | fltk::ProgressBar *mProcessBar; |
---|
348 | fltk::Button *mButtonSort; |
---|
349 | fltk::ProgressBar *mSortBar; |
---|
350 | fltk::Button *mButtonBuild; |
---|
351 | fltk::ProgressBar *mBuildBar; |
---|
352 | fltk::Slider *mLodStripSlider; |
---|
353 | fltk::Slider *mLodTreeSlider; |
---|
354 | fltk::CheckButton *mGeometryBased; |
---|
355 | fltk::CheckButton *mViewPointDriven; |
---|
356 | fltk::CheckButton *mChangeVertices; |
---|
357 | fltk::CheckButton *mChangeTexture; |
---|
358 | fltk::CheckButton *mPercent; |
---|
359 | fltk::CheckButton *mVerticesNumber; |
---|
360 | fltk::CheckButton *mOneCacheStrip; |
---|
361 | fltk::CheckButton *mQualityStrips; |
---|
362 | fltk::FloatInput *mMeshReduction; |
---|
363 | fltk::Widget *mProcessTitle; |
---|
364 | fltk::Output *mMetricLabel; |
---|
365 | fltk::Output *mTypeLabel; |
---|
366 | fltk::Output *mMeshReductionLabel; |
---|
367 | fltk::Browser *mMeshInfo; |
---|
368 | fltk::ItemGroup *ogeometry; |
---|
369 | |
---|
370 | // Repaint the FPS label. |
---|
371 | void refreshFPS(int fps); |
---|
372 | |
---|
373 | // Initialize the lodstripslibrary for visualization. |
---|
374 | void setLodStripsLibrary(const Geometry::LodStripsLibraryData *, Mesh *geomesh); |
---|
375 | // Initialize the lodtreelibrary for visualization. |
---|
376 | void setLodTreesLibrary(const Geometry::LodStripsLibraryData *, const Geometry::TreeSimplificationSequence *, Mesh *geomesh/*, uint32 ileafSubMesh*/); |
---|
377 | |
---|
378 | // Indentify the mesh of leaves. |
---|
379 | unsigned short idMeshLeaves; |
---|
380 | |
---|
381 | GeoMeshViewUI(TIPOFUNC fun=NULL); |
---|
382 | ~GeoMeshViewUI(); |
---|
383 | void show(); |
---|
384 | |
---|
385 | TIPOFUNC progress_function; |
---|
386 | float updateProgressBar(float); |
---|
387 | |
---|
388 | void BuildLoadTextureSubMeshMenu(void); |
---|
389 | int numSubMeshNames; |
---|
390 | char **SubMeshNames; |
---|
391 | |
---|
392 | }; |
---|
393 | |
---|
394 | #endif |
---|
395 | |
---|