Blender  V2.93
Controller.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
24 #include <string>
25 
26 #include "../geometry/FastGrid.h"
27 #include "../scene_graph/SceneHash.h"
28 #include "../system/Precision.h"
29 #include "../system/TimeUtils.h"
30 #include "../view_map/FEdgeXDetector.h"
31 #include "../view_map/ViewMapBuilder.h"
32 
33 #ifdef WITH_CXX_GUARDEDALLOC
34 # include "MEM_guardedalloc.h"
35 #endif
36 
37 namespace Freestyle {
38 
39 class AppCanvas;
40 class AppView;
41 class Interpreter;
42 class NodeGroup;
43 class ProgressBar;
44 class RenderMonitor;
45 class SShape;
46 class ViewEdge;
47 class ViewMap;
48 
49 class Controller {
50  public:
51  Controller();
52  ~Controller();
53 
54  void setView(AppView *iView);
55  void setRenderMonitor(RenderMonitor *iRenderMonitor);
56  void setPassDiffuse(float *buf, int width, int height);
57  void setPassZ(float *buf, int width, int height);
58  void setContext(bContext *C);
59 
60  // soc
61  void init_options();
62 
63  int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph);
64  int Load3DSFile(const char *iFileName);
65  void CloseFile();
66  void ComputeViewMap();
70  int DrawStrokes();
71  void ResetRenderCount();
72  Render *RenderStrokes(Render *re, bool render);
73  void SwapStyleModules(unsigned i1, unsigned i2);
74  void InsertStyleModule(unsigned index, const char *iFileName);
75  void InsertStyleModule(unsigned index, const char *iName, const char *iBuffer);
76  void InsertStyleModule(unsigned index, const char *iName, struct Text *iText);
77  void AddStyleModule(const char *iFileName);
78  void RemoveStyleModule(unsigned index);
79  void ReloadStyleModule(unsigned index, const char *iFileName);
80  void Clear();
81  void ClearRootNode();
82  void DeleteWingedEdge();
83  void DeleteViewMap(bool freeCache = false);
84  void toggleLayer(unsigned index, bool iDisplay);
85  void setModified(unsigned index, bool iMod);
86  void resetModified(bool iMod = false);
87  void updateCausalStyleModules(unsigned index);
88  void displayDensityCurves(int x, int y);
89 
92  NodeGroup *BuildRep(vector<ViewEdge *>::iterator vedges_begin,
93  vector<ViewEdge *>::iterator vedges_end);
94 
95 #if 0
96  NodeGroup *debugNode()
97  {
98  return _DebugNode;
99  }
100  AppView *view()
101  {
102  return _pView;
103  }
104  NodeGroup *debugScene()
105  {
106  return _DebugNode;
107  }
108  Grid &grid()
109  {
110  return _Grid;
111  }
112 #endif
113 
114  void toggleVisibilityAlgo();
115  void setVisibilityAlgo(int algo);
116  int getVisibilityAlgo();
117 
118  void setViewMapCache(bool iBool);
119  bool getViewMapCache() const;
120  void setQuantitativeInvisibility(bool iBool); // if true, we compute quantitativeInvisibility
121  bool getQuantitativeInvisibility() const;
122  void setFaceSmoothness(bool iBool);
123  bool getFaceSmoothness() const;
124 
125  void setComputeRidgesAndValleysFlag(bool b);
126  bool getComputeRidgesAndValleysFlag() const;
131 
132  void setComputeSteerableViewMapFlag(bool iBool);
133  bool getComputeSteerableViewMapFlag() const;
134  void setCreaseAngle(float angle)
135  {
136  _creaseAngle = angle;
137  }
138  float getCreaseAngle() const
139  {
140  return _creaseAngle;
141  }
142  void setSphereRadius(float s)
143  {
144  _sphereRadius = s;
145  }
146  float getSphereRadius() const
147  {
148  return _sphereRadius;
149  }
151  {
152  _suggestiveContourKrDerivativeEpsilon = dkr;
153  }
155  {
156  return _suggestiveContourKrDerivativeEpsilon;
157  }
158 
159  void setModelsDir(const string &dir);
160  string getModelsDir() const;
161  void setModulesDir(const string &dir);
162  string getModulesDir() const;
163 
164  bool hitViewMapCache();
165 
166  void resetInterpreter();
167 
168  public:
169  // Viewmap data structure
171 
172  // Canvas
174 
175  private:
176  // Main Window:
177  // AppMainWindow *_pMainWindow;
178 
179  // List of models currently loaded
180  vector<string> _ListOfModels;
181 
182  // Current directories
183  // ConfigIO* _current_dirs;
184 
185  // View
186  // 3D
187  AppView *_pView;
188 
189  // 2D
190 #if 0
191  Viewer2DWindow *_pView2DWindow;
192  Viewer2D *_pView2D;
193 #endif
194 
195  RenderMonitor *_pRenderMonitor;
196 
197  // Model
198  // Drawing Structure
199  NodeGroup *_RootNode;
200 
201  // Winged-Edge structure
202  WingedEdge *_winged_edge;
203 
204 #if 0
205  // Silhouette structure:
206  std::vector<SShape *> _SShapes;
207  NodeGroup *_SRoot;
208 
209  // Silhouette
210  NodeGroup *_SilhouetteNode;
211  NodeGroup *_ProjectedSilhouette;
212  NodeGroup *_VisibleProjectedSilhouette;
213 
214  // more Debug info
215  NodeGroup *_DebugNode;
216 #endif
217 
218  // debug
219  // NodeUser<ViewMap> *_ViewMapNode; // FIXME
220 
221  // Chronometer:
222  Chronometer _Chrono;
223 
224  // Progress Bar
225  ProgressBar *_ProgressBar;
226 
227  // edges tesselation nature
228  int _edgeTesselationNature;
229 
230  FastGrid _Grid;
231  // HashGrid _Grid;
232 
233  BBox<Vec3r> _Scene3dBBox;
234  unsigned int _SceneNumFaces;
235 #if 0
236  real _minEdgeSize;
237 #endif
238  real _EPSILON;
239  real _bboxDiag;
240 
241  int _render_count;
242 
243  // AppStyleWindow *_pStyleWindow;
244  // AppOptionsWindow *_pOptionsWindow;
245  // AppDensityCurvesWindow *_pDensityCurvesWindow;
246 
247  ViewMapBuilder::visibility_algo _VisibilityAlgo;
248 
249  // Script Interpreter
250  Interpreter *_inter;
251 
252  string _help_index;
253  string _browser_cmd;
254 
255  bool _EnableViewMapCache;
256  bool _EnableQI;
257  bool _EnableFaceSmoothness;
258  bool _ComputeRidges;
259  bool _ComputeSuggestive;
260  bool _ComputeMaterialBoundaries;
261  float _creaseAngle;
262  float _sphereRadius;
263  float _suggestiveContourKrDerivativeEpsilon;
264 
265  bool _ComputeSteerableViewMap;
266 
267  FEdgeXDetector edgeDetector;
268 
269  SceneHash sceneHashFunc;
270  real prevSceneHash;
271 
272 #ifdef WITH_CXX_GUARDEDALLOC
273  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Controller")
274 #endif
275 };
276 
277 extern Controller *g_pController;
278 
279 } /* namespace Freestyle */
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
static AppView * view
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Separate Set Z Dilate Combine Combine Color Channel Split ID Combine Luminance Directional Alpha Distance Hue Movie Ellipse Bokeh View Corner Anti Mix RGB Hue Separate TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC Boolean Random Edge Subdivision Point Object Attribute Attribute Attribute Color Attribute Attribute Vector Point Attribute Sample Collection Attribute Attribute Combine Attribute Grid
#define C
Definition: RandGen.cpp:39
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
Render * RenderStrokes(Render *re, bool render)
Definition: Controller.cpp:905
string getModelsDir() const
void setComputeSuggestiveContoursFlag(bool b)
Definition: Controller.cpp:848
void setPassZ(float *buf, int width, int height)
Definition: Controller.cpp:210
bool getFaceSmoothness() const
Definition: Controller.cpp:833
void updateCausalStyleModules(unsigned index)
Definition: Controller.cpp:998
bool getComputeMaterialBoundariesFlag() const
Definition: Controller.cpp:863
bool getComputeSteerableViewMapFlag() const
Definition: Controller.cpp:873
void toggleLayer(unsigned index, bool iDisplay)
Definition: Controller.cpp:986
void setSphereRadius(float s)
Definition: Controller.h:142
void setComputeMaterialBoundariesFlag(bool b)
Definition: Controller.cpp:858
void setVisibilityAlgo(int algo)
Definition: Controller.cpp:757
void AddStyleModule(const char *iFileName)
Definition: Controller.cpp:960
void setComputeRidgesAndValleysFlag(bool b)
Definition: Controller.cpp:838
void setFaceSmoothness(bool iBool)
Definition: Controller.cpp:828
void setPassDiffuse(float *buf, int width, int height)
Definition: Controller.cpp:203
ViewEdge * SelectViewEdge(real x, real y)
void saveSteerableViewMapImages()
Definition: Controller.cpp:734
int Load3DSFile(const char *iFileName)
void toggleEdgeTesselationNature(Nature::EdgeNature iNature)
void SwapStyleModules(unsigned i1, unsigned i2)
Definition: Controller.cpp:981
float getSphereRadius() const
Definition: Controller.h:146
void RemoveStyleModule(unsigned index)
Definition: Controller.cpp:965
void ReloadStyleModule(unsigned index, const char *iFileName)
Definition: Controller.cpp:975
bool getQuantitativeInvisibility() const
Definition: Controller.cpp:823
FEdge * SelectFEdge(real x, real y)
void setModulesDir(const string &dir)
void DeleteViewMap(bool freeCache=false)
Definition: Controller.cpp:421
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
Definition: Controller.cpp:235
bool getComputeSuggestiveContoursFlag() const
Definition: Controller.cpp:853
string getModulesDir() const
NodeGroup * BuildRep(vector< ViewEdge * >::iterator vedges_begin, vector< ViewEdge * >::iterator vedges_end)
void setViewMapCache(bool iBool)
Definition: Controller.cpp:808
void setQuantitativeInvisibility(bool iBool)
Definition: Controller.cpp:818
void setContext(bContext *C)
Definition: Controller.cpp:217
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
Definition: Controller.h:150
void setComputeSteerableViewMapFlag(bool iBool)
Definition: Controller.cpp:868
void setCreaseAngle(float angle)
Definition: Controller.h:134
float getCreaseAngle() const
Definition: Controller.h:138
void setModified(unsigned index, bool iMod)
Definition: Controller.cpp:991
void InsertStyleModule(unsigned index, const char *iFileName)
Definition: Controller.cpp:937
bool getComputeRidgesAndValleysFlag() const
Definition: Controller.cpp:843
float getSuggestiveContourKrDerivativeEpsilon() const
Definition: Controller.h:154
void setView(AppView *iView)
Definition: Controller.cpp:188
void resetModified(bool iMod=false)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
Definition: Controller.cpp:198
bool getViewMapCache() const
Definition: Controller.cpp:813
void displayDensityCurves(int x, int y)
AppCanvas * _Canvas
Definition: Controller.h:173
void setModelsDir(const string &dir)
const Depsgraph * depsgraph
unsigned short EdgeNature
Definition: Nature.h:46
inherits from class Rep
Definition: AppCanvas.cpp:32
static unsigned x[3]
Definition: RandGen.cpp:87
Controller * g_pController
double real
Definition: Precision.h:26