Blender  V3.3
StyleModule.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include <iostream>
11 #include <string>
12 
13 #include "Operators.h"
14 #include "StrokeLayer.h"
15 #include "StrokeShader.h"
16 
17 #include "../system/Interpreter.h"
18 #include "../system/StringUtils.h"
19 
20 #ifdef WITH_CXX_GUARDEDALLOC
21 # include "MEM_guardedalloc.h"
22 #endif
23 
24 using namespace std;
25 
26 namespace Freestyle {
27 
28 class StyleModule {
29  public:
30  StyleModule(const string &file_name, Interpreter *inter) : _file_name(file_name)
31  {
32  _always_refresh = false;
33  _causal = false;
34  _drawable = true;
35  _modified = true;
36  _displayed = true;
37  _inter = inter;
38  }
39 
40  virtual ~StyleModule()
41  {
42  }
43 
45  {
46  if (!_inter) {
47  cerr << "Error: no interpreter was found to execute the script" << endl;
48  return NULL;
49  }
50 
51  if (!_drawable) {
52  cerr << "Error: not drawable" << endl;
53  return NULL;
54  }
55 
57 
58  if (interpret()) {
59  cerr << "Error: interpretation failed" << endl;
61  return NULL;
62  }
63 
64  Operators::StrokesContainer *strokes_set = Operators::getStrokesSet();
65  if (strokes_set->empty()) {
66  cerr << "Error: strokes set empty" << endl;
68  return NULL;
69  }
70 
71  StrokeLayer *sl = new StrokeLayer;
72  for (Operators::StrokesContainer::iterator it = strokes_set->begin(); it != strokes_set->end();
73  ++it) {
74  sl->AddStroke(*it);
75  }
76 
78  return sl;
79  }
80 
81  protected:
82  virtual int interpret()
83  {
84  return _inter->interpretFile(_file_name);
85  }
86 
87  public:
88  // accessors
89  const string getFileName() const
90  {
91  return _file_name;
92  }
93 
94  bool getAlwaysRefresh() const
95  {
96  return _always_refresh;
97  }
98 
99  bool getCausal() const
100  {
101  return _causal;
102  }
103 
104  bool getDrawable() const
105  {
106  return _drawable;
107  }
108 
109  bool getModified() const
110  {
111  return _modified;
112  }
113 
114  bool getDisplayed() const
115  {
116  return _displayed;
117  }
118 
119  // modifiers
120  void setFileName(const string &file_name)
121  {
122  _file_name = file_name;
123  }
124 
125  void setAlwaysRefresh(bool b = true)
126  {
127  _always_refresh = b;
128  }
129 
130  void setCausal(bool b = true)
131  {
132  _causal = b;
133  }
134 
135  void setDrawable(bool b = true)
136  {
137  _drawable = b;
138  }
139 
140  void setModified(bool b = true)
141  {
142  if (_always_refresh) {
143  return;
144  }
145  _modified = b;
146  }
147 
148  void setDisplayed(bool b = true)
149  {
150  _displayed = b;
151  }
152 
153  private:
154  string _file_name;
155  bool _always_refresh;
156  bool _causal;
157  bool _drawable;
158  bool _modified;
159  bool _displayed;
160 
161  protected:
163 
164 #ifdef WITH_CXX_GUARDEDALLOC
165  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StyleModule")
166 #endif
167 };
168 
169 } /* namespace Freestyle */
Read Guarded memory(de)allocation.
Class gathering stroke creation algorithms.
Class to define a layer of strokes.
Class defining StrokeShader.
vector< Stroke * > StrokesContainer
Definition: Operators.h:39
void AddStroke(Stroke *iStroke)
Definition: StrokeLayer.h:79
bool getAlwaysRefresh() const
Definition: StyleModule.h:94
void setCausal(bool b=true)
Definition: StyleModule.h:130
bool getDrawable() const
Definition: StyleModule.h:104
void setAlwaysRefresh(bool b=true)
Definition: StyleModule.h:125
bool getDisplayed() const
Definition: StyleModule.h:114
void setDrawable(bool b=true)
Definition: StyleModule.h:135
void setFileName(const string &file_name)
Definition: StyleModule.h:120
virtual int interpret()
Definition: StyleModule.h:82
bool getModified() const
Definition: StyleModule.h:109
const string getFileName() const
Definition: StyleModule.h:89
void setModified(bool b=true)
Definition: StyleModule.h:140
void setDisplayed(bool b=true)
Definition: StyleModule.h:148
bool getCausal() const
Definition: StyleModule.h:99
Interpreter * _inter
Definition: StyleModule.h:162
StrokeLayer * execute()
Definition: StyleModule.h:44
StyleModule(const string &file_name, Interpreter *inter)
Definition: StyleModule.h:30
ccl_gpu_kernel_postfix ccl_global float int int int int float bool reset
clear internal cached data and reset random seed
inherits from class Rep
Definition: AppCanvas.cpp:18
static const pxr::TfToken b("b", pxr::TfToken::Immortal)