Blender V5.0
Controller.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11
12#include <string>
13
16#include "../system/Precision.h"
17#include "../system/TimeUtils.h"
20
21#include "MEM_guardedalloc.h"
22
23struct Depsgraph;
24struct Render;
25struct ViewLayer;
26
27namespace Freestyle {
28
29class AppCanvas;
30class AppView;
31class Interpreter;
32class NodeGroup;
33class ProgressBar;
34class RenderMonitor;
35class SShape;
36class ViewEdge;
37class ViewMap;
38
40 public:
41 Controller();
43
44 void setView(AppView *iView);
45 void setRenderMonitor(RenderMonitor *iRenderMonitor);
46 void setPassDiffuse(float *buf, int width, int height);
47 void setPassZ(float *buf, int width, int height);
48 void setContext(bContext *C);
49
50 // soc
51 void init_options();
52
53 int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph);
54 int Load3DSFile(const char *iFileName);
55 void CloseFile();
56 void ComputeViewMap();
60 int DrawStrokes();
61 void ResetRenderCount();
62 Render *RenderStrokes(Render *re, bool render);
63 void SwapStyleModules(uint i1, uint i2);
64 void InsertStyleModule(uint index, const char *iFileName);
65 void InsertStyleModule(uint index, const char *iName, const char *iBuffer);
66 void InsertStyleModule(uint index, const char *iName, struct Text *iText);
67 void AddStyleModule(const char *iFileName);
68 void RemoveStyleModule(uint index);
69 void ReloadStyleModule(uint index, const char *iFileName);
70 void Clear();
71 void ClearRootNode();
72 void DeleteWingedEdge();
73 void DeleteViewMap(bool freeCache = false);
74 void toggleLayer(uint index, bool iDisplay);
75 void setModified(uint index, bool iMod);
76 void resetModified(bool iMod = false);
78 void displayDensityCurves(int x, int y);
79
82 NodeGroup *BuildRep(vector<ViewEdge *>::iterator vedges_begin,
83 vector<ViewEdge *>::iterator vedges_end);
84
85#if 0
86 NodeGroup *debugNode()
87 {
88 return _DebugNode;
89 }
90 AppView *view()
91 {
92 return _pView;
93 }
94 NodeGroup *debugScene()
95 {
96 return _DebugNode;
97 }
98 Grid &grid()
99 {
100 return _Grid;
101 }
102#endif
103
105 void setVisibilityAlgo(int algo);
106 int getVisibilityAlgo();
107
108 void setViewMapCache(bool iBool);
109 bool getViewMapCache() const;
110 void setQuantitativeInvisibility(bool iBool); // if true, we compute quantitativeInvisibility
111 bool getQuantitativeInvisibility() const;
112 void setFaceSmoothness(bool iBool);
113 bool getFaceSmoothness() const;
114
121
122 void setComputeSteerableViewMapFlag(bool iBool);
125 {
126 _creaseAngle = angle;
127 }
128 float getCreaseAngle() const
129 {
130 return _creaseAngle;
131 }
132 void setSphereRadius(float s)
133 {
134 _sphereRadius = s;
135 }
136 float getSphereRadius() const
137 {
138 return _sphereRadius;
139 }
141 {
142 _suggestiveContourKrDerivativeEpsilon = dkr;
143 }
145 {
146 return _suggestiveContourKrDerivativeEpsilon;
147 }
148
149 void setModelsDir(const string &dir);
150 string getModelsDir() const;
151 void setModulesDir(const string &dir);
152 string getModulesDir() const;
153
154 bool hitViewMapCache();
155
156 void resetInterpreter();
157
158 public:
159 // Viewmap data structure
161
162 // Canvas
164
165 private:
166 // Main Window:
167 // AppMainWindow *_pMainWindow;
168
169 // List of models currently loaded
170 vector<string> _ListOfModels;
171
172 // Current directories
173 // ConfigIO* _current_dirs;
174
175 // View
176 // 3D
177 AppView *_pView;
178
179 // 2D
180#if 0
181 Viewer2DWindow *_pView2DWindow;
182 Viewer2D *_pView2D;
183#endif
184
185 RenderMonitor *_pRenderMonitor;
186
187 // Model
188 // Drawing Structure
189 NodeGroup *_RootNode;
190
191 // Winged-Edge structure
192 WingedEdge *_winged_edge;
193
194#if 0
195 // Silhouette structure:
196 std::vector<SShape *> _SShapes;
197 NodeGroup *_SRoot;
198
199 // Silhouette
200 NodeGroup *_SilhouetteNode;
201 NodeGroup *_ProjectedSilhouette;
202 NodeGroup *_VisibleProjectedSilhouette;
203
204 // more Debug info
205 NodeGroup *_DebugNode;
206#endif
207
208 // debug
209 // NodeUser<ViewMap> *_ViewMapNode; // FIXME
210
211 // Chronometer:
212 Chronometer _Chrono;
213
214 // Progress Bar
215 ProgressBar *_ProgressBar;
216
217 // edges tesselation nature
218 int _edgeTesselationNature;
219
220 FastGrid _Grid;
221 // HashGrid _Grid;
222
223 BBox<Vec3r> _Scene3dBBox;
224 uint _SceneNumFaces;
225#if 0
226 real _minEdgeSize;
227#endif
228 real _EPSILON;
229 real _bboxDiag;
230
231 int _render_count;
232
233 // AppStyleWindow *_pStyleWindow;
234 // AppOptionsWindow *_pOptionsWindow;
235 // AppDensityCurvesWindow *_pDensityCurvesWindow;
236
237 ViewMapBuilder::visibility_algo _VisibilityAlgo;
238
239 // Script Interpreter
240 Interpreter *_inter;
241
242 string _help_index;
243 string _browser_cmd;
244
245 bool _EnableViewMapCache;
246 bool _EnableQI;
247 bool _EnableFaceSmoothness;
248 bool _ComputeRidges;
249 bool _ComputeSuggestive;
250 bool _ComputeMaterialBoundaries;
251 float _creaseAngle;
252 float _sphereRadius;
253 float _suggestiveContourKrDerivativeEpsilon;
254
255 bool _ComputeSteerableViewMap;
256
257 FEdgeXDetector edgeDetector;
258
259 SceneHash sceneHashFunc;
260 real prevSceneHash;
261
262 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Controller")
263};
264
266
267} /* namespace Freestyle */
unsigned int uint
Detects/flags/builds extended features edges on the WXEdge structure.
static AppView * view
Class to define a cell grid surrounding the bounding box of the scene.
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:117
Read Guarded memory(de)allocation.
Define the float precision used in the program.
Class to measure elapsed time.
Class to build silhouette edges from a Winged-Edge structure.
BPy_StructRNA * depsgraph
Render * RenderStrokes(Render *re, bool render)
string getModelsDir() const
void setComputeSuggestiveContoursFlag(bool b)
void setPassZ(float *buf, int width, int height)
bool getFaceSmoothness() const
bool getComputeMaterialBoundariesFlag() const
bool getComputeSteerableViewMapFlag() const
void setSphereRadius(float s)
Definition Controller.h:132
FEdge * SelectFEdge(real x, real y)
void setComputeMaterialBoundariesFlag(bool b)
void setVisibilityAlgo(int algo)
void AddStyleModule(const char *iFileName)
void setComputeRidgesAndValleysFlag(bool b)
void ReloadStyleModule(uint index, const char *iFileName)
void setFaceSmoothness(bool iBool)
void setPassDiffuse(float *buf, int width, int height)
void setModified(uint index, bool iMod)
int Load3DSFile(const char *iFileName)
void toggleEdgeTesselationNature(Nature::EdgeNature iNature)
void updateCausalStyleModules(uint index)
float getSphereRadius() const
Definition Controller.h:136
bool getQuantitativeInvisibility() const
void setModulesDir(const string &dir)
void DeleteViewMap(bool freeCache=false)
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
bool getComputeSuggestiveContoursFlag() const
string getModulesDir() const
NodeGroup * BuildRep(vector< ViewEdge * >::iterator vedges_begin, vector< ViewEdge * >::iterator vedges_end)
void setViewMapCache(bool iBool)
void setQuantitativeInvisibility(bool iBool)
void toggleLayer(uint index, bool iDisplay)
void setContext(bContext *C)
void RemoveStyleModule(uint index)
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
Definition Controller.h:140
ViewEdge * SelectViewEdge(real x, real y)
void setComputeSteerableViewMapFlag(bool iBool)
void setCreaseAngle(float angle)
Definition Controller.h:124
float getCreaseAngle() const
Definition Controller.h:128
void SwapStyleModules(uint i1, uint i2)
bool getComputeRidgesAndValleysFlag() const
float getSuggestiveContourKrDerivativeEpsilon() const
Definition Controller.h:144
void setView(AppView *iView)
void resetModified(bool iMod=false)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
bool getViewMapCache() const
void displayDensityCurves(int x, int y)
void InsertStyleModule(uint index, const char *iFileName)
void setModelsDir(const string &dir)
ushort EdgeNature
Definition Nature.h:36
inherits from class Rep
Definition AppCanvas.cpp:20
Controller * g_pController
static uint x[3]
Definition RandGen.cpp:77
double real
Definition Precision.h:14