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