Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Controller.h « application « intern « freestyle « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6c41733db3668716b179211b3537a7a3e2458c12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#pragma once

/** \file
 * \ingroup freestyle
 * \brief The spinal tap of the system.
 */

#include <string>

#include "../geometry/FastGrid.h"
#include "../scene_graph/SceneHash.h"
#include "../system/Precision.h"
#include "../system/TimeUtils.h"
#include "../view_map/FEdgeXDetector.h"
#include "../view_map/ViewMapBuilder.h"

#ifdef WITH_CXX_GUARDEDALLOC
#  include "MEM_guardedalloc.h"
#endif

namespace Freestyle {

class AppCanvas;
class AppView;
class Interpreter;
class NodeGroup;
class ProgressBar;
class RenderMonitor;
class SShape;
class ViewEdge;
class ViewMap;

class Controller {
 public:
  Controller();
  ~Controller();

  void setView(AppView *iView);
  void setRenderMonitor(RenderMonitor *iRenderMonitor);
  void setPassDiffuse(float *buf, int width, int height);
  void setPassZ(float *buf, int width, int height);
  void setContext(bContext *C);

  // soc
  void init_options();

  int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph);
  int Load3DSFile(const char *iFileName);
  void CloseFile();
  void ComputeViewMap();
  void ComputeSteerableViewMap();
  void saveSteerableViewMapImages();
  void toggleEdgeTesselationNature(Nature::EdgeNature iNature);
  int DrawStrokes();
  void ResetRenderCount();
  Render *RenderStrokes(Render *re, bool render);
  void SwapStyleModules(unsigned i1, unsigned i2);
  void InsertStyleModule(unsigned index, const char *iFileName);
  void InsertStyleModule(unsigned index, const char *iName, const char *iBuffer);
  void InsertStyleModule(unsigned index, const char *iName, struct Text *iText);
  void AddStyleModule(const char *iFileName);
  void RemoveStyleModule(unsigned index);
  void ReloadStyleModule(unsigned index, const char *iFileName);
  void Clear();
  void ClearRootNode();
  void DeleteWingedEdge();
  void DeleteViewMap(bool freeCache = false);
  void toggleLayer(unsigned index, bool iDisplay);
  void setModified(unsigned index, bool iMod);
  void resetModified(bool iMod = false);
  void updateCausalStyleModules(unsigned index);
  void displayDensityCurves(int x, int y);

  ViewEdge *SelectViewEdge(real x, real y);
  FEdge *SelectFEdge(real x, real y);
  NodeGroup *BuildRep(vector<ViewEdge *>::iterator vedges_begin,
                      vector<ViewEdge *>::iterator vedges_end);

#if 0
  NodeGroup *debugNode()
  {
    return _DebugNode;
  }
  AppView *view()
  {
    return _pView;
  }
  NodeGroup *debugScene()
  {
    return _DebugNode;
  }
  Grid &grid()
  {
    return _Grid;
  }
#endif

  void toggleVisibilityAlgo();
  void setVisibilityAlgo(int algo);
  int getVisibilityAlgo();

  void setViewMapCache(bool iBool);
  bool getViewMapCache() const;
  void setQuantitativeInvisibility(bool iBool);  // if true, we compute quantitativeInvisibility
  bool getQuantitativeInvisibility() const;
  void setFaceSmoothness(bool iBool);
  bool getFaceSmoothness() const;

  void setComputeRidgesAndValleysFlag(bool b);
  bool getComputeRidgesAndValleysFlag() const;
  void setComputeSuggestiveContoursFlag(bool b);
  bool getComputeSuggestiveContoursFlag() const;
  void setComputeMaterialBoundariesFlag(bool b);
  bool getComputeMaterialBoundariesFlag() const;

  void setComputeSteerableViewMapFlag(bool iBool);
  bool getComputeSteerableViewMapFlag() const;
  void setCreaseAngle(float angle)
  {
    _creaseAngle = angle;
  }
  float getCreaseAngle() const
  {
    return _creaseAngle;
  }
  void setSphereRadius(float s)
  {
    _sphereRadius = s;
  }
  float getSphereRadius() const
  {
    return _sphereRadius;
  }
  void setSuggestiveContourKrDerivativeEpsilon(float dkr)
  {
    _suggestiveContourKrDerivativeEpsilon = dkr;
  }
  float getSuggestiveContourKrDerivativeEpsilon() const
  {
    return _suggestiveContourKrDerivativeEpsilon;
  }

  void setModelsDir(const string &dir);
  string getModelsDir() const;
  void setModulesDir(const string &dir);
  string getModulesDir() const;

  bool hitViewMapCache();

  void resetInterpreter();

 public:
  // Viewmap data structure
  ViewMap *_ViewMap;

  // Canvas
  AppCanvas *_Canvas;

 private:
  // Main Window:
  // AppMainWindow *_pMainWindow;

  // List of models currently loaded
  vector<string> _ListOfModels;

  // Current directories
  // ConfigIO* _current_dirs;

  // View
  // 3D
  AppView *_pView;

  // 2D
#if 0
  Viewer2DWindow *_pView2DWindow;
  Viewer2D *_pView2D;
#endif

  RenderMonitor *_pRenderMonitor;

  // Model
  // Drawing Structure
  NodeGroup *_RootNode;

  // Winged-Edge structure
  WingedEdge *_winged_edge;

#if 0
  // Silhouette structure:
  std::vector<SShape *> _SShapes;
  NodeGroup *_SRoot;

  // Silhouette
  NodeGroup *_SilhouetteNode;
  NodeGroup *_ProjectedSilhouette;
  NodeGroup *_VisibleProjectedSilhouette;

  // more Debug info
  NodeGroup *_DebugNode;
#endif

  // debug
  // NodeUser<ViewMap> *_ViewMapNode; // FIXME

  // Chronometer:
  Chronometer _Chrono;

  // Progress Bar
  ProgressBar *_ProgressBar;

  // edges tesselation nature
  int _edgeTesselationNature;

  FastGrid _Grid;
  // HashGrid _Grid;

  BBox<Vec3r> _Scene3dBBox;
  unsigned int _SceneNumFaces;
#if 0
  real _minEdgeSize;
#endif
  real _EPSILON;
  real _bboxDiag;

  int _render_count;

  // AppStyleWindow *_pStyleWindow;
  // AppOptionsWindow *_pOptionsWindow;
  // AppDensityCurvesWindow *_pDensityCurvesWindow;

  ViewMapBuilder::visibility_algo _VisibilityAlgo;

  // Script Interpreter
  Interpreter *_inter;

  string _help_index;
  string _browser_cmd;

  bool _EnableViewMapCache;
  bool _EnableQI;
  bool _EnableFaceSmoothness;
  bool _ComputeRidges;
  bool _ComputeSuggestive;
  bool _ComputeMaterialBoundaries;
  float _creaseAngle;
  float _sphereRadius;
  float _suggestiveContourKrDerivativeEpsilon;

  bool _ComputeSteerableViewMap;

  FEdgeXDetector edgeDetector;

  SceneHash sceneHashFunc;
  real prevSceneHash;

#ifdef WITH_CXX_GUARDEDALLOC
  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Controller")
#endif
};

extern Controller *g_pController;

} /* namespace Freestyle */