2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * ***** END GPL LICENSE BLOCK *****
21 #ifndef __CONTROLLER_H__
22 #define __CONTROLLER_H__
24 /** \file blender/freestyle/intern/application/Controller.h
26 * \brief The spinal tap of the system.
27 * \author Stephane Grabli
33 //#include "ConfigIO.h"
34 #include "../geometry/FastGrid.h"
35 #include "../scene_graph/SceneHash.h"
36 #include "../system/Interpreter.h"
37 #include "../system/ProgressBar.h"
38 #include "../system/Precision.h"
39 #include "../system/RenderMonitor.h"
40 #include "../system/TimeUtils.h"
41 #include "../view_map/FEdgeXDetector.h"
42 #include "../view_map/ViewMapBuilder.h"
45 #include "render_types.h"
46 #include "DNA_scene_types.h"
49 #ifdef WITH_CXX_GUARDEDALLOC
50 #include "MEM_guardedalloc.h"
62 class InteractiveShader;
72 void setView(AppView *iView);
73 void setRenderMonitor(RenderMonitor *iRenderMonitor);
74 void setPassDiffuse(float *buf, int width, int height);
75 void setPassZ(float *buf, int width, int height);
76 void setContext(bContext *C);
81 int LoadMesh(Render *re, SceneRenderLayer *srl);
82 int Load3DSFile(const char *iFileName);
84 void ComputeViewMap();
85 void ComputeSteerableViewMap();
86 void saveSteerableViewMapImages();
87 void toggleEdgeTesselationNature(Nature::EdgeNature iNature);
89 void ResetRenderCount();
90 Render *RenderStrokes(Render *re, bool render);
91 void SwapStyleModules(unsigned i1, unsigned i2);
92 void InsertStyleModule(unsigned index, const char *iFileName);
93 void InsertStyleModule(unsigned index, const char *iName, const char *iBuffer);
94 void InsertStyleModule(unsigned index, const char *iName, struct Text *iText);
95 void AddStyleModule(const char *iFileName);
96 void RemoveStyleModule(unsigned index);
97 void ReloadStyleModule(unsigned index, const char * iFileName);
100 void DeleteWingedEdge();
101 void DeleteViewMap(bool freeCache = false);
102 void toggleLayer(unsigned index, bool iDisplay);
103 void setModified(unsigned index, bool iMod);
104 void resetModified(bool iMod=false);
105 void updateCausalStyleModules(unsigned index);
106 void displayDensityCurves(int x, int y);
108 ViewEdge *SelectViewEdge(real x, real y);
109 FEdge *SelectFEdge(real x, real y);
110 NodeGroup *BuildRep(vector<ViewEdge*>::iterator vedges_begin, vector<ViewEdge*>::iterator vedges_end) ;
113 NodeGroup *debugNode() {return _DebugNode;}
114 AppView *view() {return _pView;}
115 NodeGroup *debugScene() {return _DebugNode;}
116 Grid& grid() {return _Grid;}
119 void toggleVisibilityAlgo();
120 void setVisibilityAlgo(int algo);
121 int getVisibilityAlgo();
123 void setViewMapCache(bool iBool);
124 bool getViewMapCache() const;
125 void setQuantitativeInvisibility(bool iBool); // if true, we compute quantitativeInvisibility
126 bool getQuantitativeInvisibility() const;
127 void setFaceSmoothness(bool iBool);
128 bool getFaceSmoothness() const;
130 void setComputeRidgesAndValleysFlag(bool b);
131 bool getComputeRidgesAndValleysFlag() const;
132 void setComputeSuggestiveContoursFlag(bool b);
133 bool getComputeSuggestiveContoursFlag() const;
134 void setComputeMaterialBoundariesFlag(bool b);
135 bool getComputeMaterialBoundariesFlag() const;
137 void setComputeSteerableViewMapFlag(bool iBool);
138 bool getComputeSteerableViewMapFlag() const;
139 void setCreaseAngle(float angle) {_creaseAngle = angle;}
140 float getCreaseAngle() const {return _creaseAngle;}
141 void setSphereRadius(float s) {_sphereRadius = s;}
142 float getSphereRadius() const {return _sphereRadius;}
143 void setSuggestiveContourKrDerivativeEpsilon(float dkr) {_suggestiveContourKrDerivativeEpsilon = dkr;}
144 float getSuggestiveContourKrDerivativeEpsilon() const {return _suggestiveContourKrDerivativeEpsilon;}
146 void setModelsDir(const string& dir);
147 string getModelsDir() const;
148 void setModulesDir(const string& dir);
149 string getModulesDir() const;
151 bool hitViewMapCache();
153 void resetInterpreter();
156 // Viewmap data structure
164 //AppMainWindow *_pMainWindow;
166 // List of models currently loaded
167 vector<string> _ListOfModels;
169 // Current directories
170 //ConfigIO* _current_dirs;
178 Viewer2DWindow *_pView2DWindow;
182 RenderMonitor *_pRenderMonitor;
186 NodeGroup *_RootNode;
188 // Winged-Edge structure
189 WingedEdge *_winged_edge;
191 // Silhouette structure:
193 std::vector<SShape*> _SShapes;
198 NodeGroup *_SilhouetteNode;
199 NodeGroup *_ProjectedSilhouette;
200 NodeGroup *_VisibleProjectedSilhouette;
203 NodeGroup *_DebugNode;
206 //NodeUser<ViewMap> *_ViewMapNode; // FIXME
212 ProgressBar *_ProgressBar;
214 // edges tesselation nature
215 int _edgeTesselationNature;
220 BBox<Vec3r> _Scene3dBBox;
221 unsigned int _SceneNumFaces;
228 //AppStyleWindow *_pStyleWindow;
229 //AppOptionsWindow *_pOptionsWindow;
230 //AppDensityCurvesWindow *_pDensityCurvesWindow;
232 ViewMapBuilder::visibility_algo _VisibilityAlgo;
234 // Script Interpreter
240 bool _EnableViewMapCache;
242 bool _EnableFaceSmoothness;
244 bool _ComputeSuggestive;
245 bool _ComputeMaterialBoundaries;
248 float _suggestiveContourKrDerivativeEpsilon;
250 bool _ComputeSteerableViewMap;
252 FEdgeXDetector edgeDetector;
254 SceneHash sceneHashFunc;
257 #ifdef WITH_CXX_GUARDEDALLOC
258 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Controller")
262 extern Controller *g_pController;
264 } /* namespace Freestyle */
266 #endif // __CONTROLLER_H__