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