Blender V5.0
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
11
12#include <iostream>
13#include <string>
14
15#include "Operators.h"
16#include "StrokeLayer.h"
17#include "StrokeShader.h"
18
21
22#include "MEM_guardedalloc.h"
23
24using namespace std;
25
26namespace Freestyle {
27
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
43 {
44 if (!_inter) {
45 cerr << "Error: no interpreter was found to execute the script" << endl;
46 return nullptr;
47 }
48
49 if (!_drawable) {
50 cerr << "Error: not drawable" << endl;
51 return nullptr;
52 }
53
55
56 if (interpret()) {
57 cerr << "Error: interpretation failed" << endl;
59 return nullptr;
60 }
61
63 if (strokes_set->empty()) {
64 cerr << "Error: strokes set empty" << endl;
66 return nullptr;
67 }
68
69 StrokeLayer *sl = new StrokeLayer;
70 for (Operators::StrokesContainer::iterator it = strokes_set->begin(); it != strokes_set->end();
71 ++it)
72 {
73 sl->AddStroke(*it);
74 }
75
77 return sl;
78 }
79
80 protected:
81 virtual int interpret()
82 {
83 return _inter->interpretFile(_file_name);
84 }
85
86 public:
87 // accessors
88 const string getFileName() const
89 {
90 return _file_name;
91 }
92
93 bool getAlwaysRefresh() const
94 {
95 return _always_refresh;
96 }
97
98 bool getCausal() const
99 {
100 return _causal;
101 }
102
103 bool getDrawable() const
104 {
105 return _drawable;
106 }
107
108 bool getModified() const
109 {
110 return _modified;
111 }
112
113 bool getDisplayed() const
114 {
115 return _displayed;
116 }
117
118 // modifiers
119 void setFileName(const string &file_name)
120 {
121 _file_name = file_name;
122 }
123
124 void setAlwaysRefresh(bool b = true)
125 {
126 _always_refresh = b;
127 }
128
129 void setCausal(bool b = true)
130 {
131 _causal = b;
132 }
133
134 void setDrawable(bool b = true)
135 {
136 _drawable = b;
137 }
138
139 void setModified(bool b = true)
140 {
141 if (_always_refresh) {
142 return;
143 }
144 _modified = b;
145 }
146
147 void setDisplayed(bool b = true)
148 {
149 _displayed = b;
150 }
151
152 private:
153 string _file_name;
154 bool _always_refresh;
155 bool _causal;
156 bool _drawable;
157 bool _modified;
158 bool _displayed;
159
160 protected:
162
163 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StyleModule")
164};
165
166} /* 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.
static void reset(bool removeStrokes=true)
static StrokesContainer * getStrokesSet()
Definition Operators.h:255
vector< Stroke * > StrokesContainer
Definition Operators.h:39
void AddStroke(Stroke *iStroke)
Definition StrokeLayer.h:77
bool getAlwaysRefresh() const
Definition StyleModule.h:93
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:81
bool getModified() const
const string getFileName() const
Definition StyleModule.h:88
void setModified(bool b=true)
void setDisplayed(bool b=true)
bool getCausal() const
Definition StyleModule.h:98
StyleModule(const string &file_name, Interpreter *inter)
Definition StyleModule.h:30
StrokeLayer * execute()
Definition StyleModule.h:42
inherits from class Rep
Definition AppCanvas.cpp:20