33 std::vector<const ControlSpec*>::iterator i =
_specList.begin();
34 std::vector<const ControlSpec*>::iterator
const e =
_specList.end();
35 for (; i != e; ++i)
delete *i;
68inline bool isWS(
const char*
source,
int start,
int end) {
69 for (
int i = start; i < end; ++i)
70 if (
source[i] !=
'\n')
return false;
77 typedef std::vector<std::pair<int, int> > Comments;
78 const Comments& comments =
expr.getComments();
79 const std::string& s =
expr.getExpr();
82 for (Comments::const_iterator i = comments.begin(); i != comments.end(); ++i) {
84 return s.substr(i->first, i->second - i->first + 1);
94 int numParsed = sscanf(comment.c_str(),
"#%lf,%lf\n", &
_min, &
_max);
102 std::stringstream ss;
122 int numParsed = sscanf(comment.c_str(),
"#%lf,%lf\n", &
_min, &
_max);
123 if (numParsed != 2) {
130 std::stringstream ss;
145 for (
int i = 1; i < num - 2; i += 3)
162 std::stringstream ss;
165 <<
"curve(" << _lookupText;
166 int num = _vec.size();
167 for (
int i = 0; i < num; ++i) ss << _vec[i]._pos << _vec[i]._val << (
int)_vec[i]._interp;
182ExprCcurveAssignSpec::
190 int num = cnode->numChildren();
191 for(
int i = 1; i < num - 2; i += 3)
192 if(
dynamic_cast<const ExprNumNode*
>(cnode->child(i+1)))
200ExprCcurveAssignSpec::toString()
const
202 std::stringstream ss;
208 int num = _vec.size();
209 for(
int i = 0; i < num; ++i)
215 << (
int)_vec[i]._interp;
221const ExprCcurveAssignSpec*
222ExprCcurveAssignSpec::match(
const ExprNode* node)
225 return new ExprCcurveAssignSpec(*assign);
234 std::stringstream ss;
256 char* name =
new char[comment.length() + 1];
257 char* type =
new char[comment.length() + 1];
258 int numMatched = sscanf(comment.c_str(),
"#%s %s\n", type, name);
261 if (numMatched == 2) {
263 if (!strcmp(type,
"string"))
265 else if (!strcmp(type,
"file"))
267 else if (!strcmp(type,
"directory"))
271 if (valid)
return new ExprStrSpec(*strnode, name, newType);
Generic Expression control specification.
std::string _name
Name of control.
InterpType
Supported interpolation types.
Node that compute a local variable assignment.
const std::string & name() const
Curve assignment expression. Assignment of curve to a variable.
ExprCurveAssignSpec(const ExprAssignNode &node)
std::string _lookupText
Lookup subexpression text.
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
static const ExprCurveAssignSpec * match(const ExprNode *node)
std::vector< typename Curve< T >::CV > _vec
Control points of curve spline.
Node that calls a function.
short int endPos() const
Access end position in input string.
int numChildren() const
Number of children.
const Expression * expr() const
Access expression.
const ExprNode * child(size_t i) const
Get 0 indexed child.
std::string toString() const
Access to original string representation of current expression.
Node that stores a numeric constant.
Variable equals scalar control specification.
ExprScalarAssignSpec(const ExprAssignNode &node)
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
double _min
Range of values.
static const ExprScalarAssignSpec * match(const ExprNode *node)
Node that stores a string.
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
ExprStrSpec(const ExprStrNode &node, char *name, Type type)
Takes name and type comments and takes ownership of them!
static const ExprStrSpec * match(const ExprNode *node)
Variable equals vector control specification.
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
double _min
Range of values.
const Vec3d & value() const
static const ExprVectorAssignSpec * match(const ExprNode *node)
ExprVectorAssignSpec(const ExprAssignNode &node)
std::vector< const ControlSpec * > _specList
std::vector< constControlSpec * >::const_iterator const end() const
std::vector< constControlSpec * >::const_iterator begin() const
virtual bool examine(const ExprNode *examinee)
const ExprStrNode * isString(const ExprNode *testee)
std::string findComment(const ExprNode &node)
Checks if there is whitespace in the range specified in the string.
const ExprAssignNode * isVectorAssign(const ExprNode *testee)
const ExprAssignNode * isCcurveAssign(const ExprNode *testee)
const ExprAssignNode * isScalarAssign(const ExprNode *testee)
const ExprAssignNode * isCurveAssign(const ExprNode *testee)
bool isWS(const char *source, int start, int end)
Returns true if no newline separates comment and node.
</pre >< h3 > Binding our variable reference</h3 > If we now tried to use the variable would still not be found by our expressions To make it bindable we need to override the resolveVar() function as follows</pre >< h3 > Variable setting</h3 > Next we need to make a way of setting the variable As the controlling code will use the expression it will repeatedly alternate between setting the independent variables that are used and calling evaluate(). What it has to do depends very much on the application. In this case we only need to set the independent variable x as</pre >< h2 > Evaluating expressions</h2 > Evaluating an expression is pretty easy But before we can do that we need to make an instance< pre > GrapherExpr expr("x+x^2")
When x is within< i > range</i > of source
For any rgb or hsl value(except for negative s values)