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