1 /**************************************************************************/
2 /*  Copyright 2009 Tim Day                                                */
3 /*                                                                        */
4 /*  This file is part of Fracplanet                                       */
5 /*                                                                        */
6 /*  Fracplanet is free software: you can redistribute it and/or modify    */
7 /*  it under the terms of the GNU General Public License as published by  */
8 /*  the Free Software Foundation, either version 3 of the License, or     */
9 /*  (at your option) any later version.                                   */
10 /*                                                                        */
11 /*  Fracplanet is distributed in the hope that it will be useful,         */
12 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
13 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         */
14 /*  GNU General Public License for more details.                          */
15 /*                                                                        */
16 /*  You should have received a copy of the GNU General Public License     */
17 /*  along with Fracplanet.  If not, see <http://www.gnu.org/licenses/>.   */
18 /**************************************************************************/
19 
20 /*! \file
21   \brief Interface for class FracplanetMain.
22 */
23 
24 #ifndef _fracplanet_main_h_
25 #define _fracplanet_main_h_
26 
27 #include "common.h"
28 #include "control_about.h"
29 #include "control_render.h"
30 #include "control_save.h"
31 #include "control_terrain.h"
32 #include "parameters_render.h"
33 #include "parameters_save.h"
34 #include "parameters_terrain.h"
35 #include "random.h"
36 
37 #include "triangle_mesh_cloud.h"
38 #include "triangle_mesh_terrain.h"
39 #include "triangle_mesh_viewer.h"
40 
41 //! Top level GUI component for fracplanet application: contains parameter controls and viewing area
42 class FracplanetMain : public QWidget,public Progress
43 {
44  private:
45 
46   Q_OBJECT
47 
48  public:
49 
50   FracplanetMain(QWidget* parent,QApplication* app,const boost::program_options::variables_map& opts,bool verbose);
51   ~FracplanetMain();
52 
53   virtual void progress_start(uint target,const std::string&);
54   virtual void progress_stall(const std::string& reason);
55   virtual void progress_step(uint step);
56   virtual void progress_complete(const std::string&);
57 
58  public slots:
59 
60   //! Invoked by ControlTerrain to generate new TriangleMesh.
61   void regenerate();
62 
63   //! Invoked by ControlSave to save to file (POV-Ray format).
64   void save_pov();
65 
66   //! Invoked by ControlSave to save to file (Blender format).
67   void save_blender();
68 
69   //! Invoked by ControlSave to save to file as texture(s).
70   void save_texture();
71 
72  private:
73 
74   //! Control logging.
75   const bool _verbose;
76 
77   QApplication*const application;
78 
79   //! Owned terrain.
80   boost::scoped_ptr<const TriangleMeshTerrain> mesh_terrain;
81 
82   //! Owned clouds, if any.
83   boost::scoped_ptr<const TriangleMeshCloud> mesh_cloud;
84 
85   //! Downcast version for use by mesh viewer.
86   std::vector<const TriangleMesh*> meshes;
87 
88   ParametersTerrain parameters_terrain;
89   ParametersCloud parameters_cloud;
90   ParametersRender parameters_render;
91   ParametersSave parameters_save;
92 
93   ControlTerrain* control_terrain;
94   ControlRender* control_render;
95   ControlSave* control_save;
96   ControlAbout* control_about;
97 
98   boost::scoped_ptr<TriangleMeshViewer> viewer;
99 
100   QTabWidget* tab;
101 
102   uint last_step;
103 
104   std::unique_ptr<QProgressDialog> progress_dialog;
105   std::string progress_info;
106   bool progress_was_stalled;
107 };
108 
109 #endif
110