Vuo
2.4.4
Loading...
Searching...
No Matches
base
VuoNode.cc
Go to the documentation of this file.
1
10
#include "
VuoNode.hh
"
11
12
#include "
VuoNodeClass.hh
"
13
#include "
VuoPort.hh
"
14
#include "
VuoStringUtilities.hh
"
15
16
#include <stdio.h>
17
18
24
VuoNode::VuoNode
(
VuoNodeClass
* nodeClass,
string
title,
VuoPort
* refreshPort, vector<VuoPort *> inputPorts, vector<VuoPort *> outputPorts,
double
x,
double
y,
bool
collapsed,
VuoNode::TintColor
tintColor)
25
:
VuoBase
<
VuoCompilerNode
,
VuoRendererNode
>(
"VuoNode"
)
26
{
27
this->nodeClass = nodeClass;
28
this->title = title;
29
this->refreshPort = refreshPort;
30
this->inputPorts = inputPorts;
31
this->outputPorts = outputPorts;
32
this->x = x;
33
this->y = y;
34
this->collapsed = collapsed;
35
this->tintColor = tintColor;
36
this->forbidden =
false
;
37
}
38
42
VuoNodeClass
*
VuoNode::getNodeClass
(
void
)
43
{
44
return
nodeClass;
45
}
46
50
VuoPort
*
VuoNode::getInputPortWithName
(
string
portName)
51
{
52
for
(vector<VuoPort *>::iterator i = inputPorts.begin(); i != inputPorts.end(); ++i)
53
if
(portName == (*i)->getClass()->getName())
54
return
*i;
55
56
return
NULL;
57
}
58
62
VuoPort
*
VuoNode::getOutputPortWithName
(
string
portName)
63
{
64
for
(vector<VuoPort *>::iterator i = outputPorts.begin(); i != outputPorts.end(); ++i)
65
if
(portName == (*i)->getClass()->getName())
66
return
*i;
67
68
return
NULL;
69
}
70
74
VuoPort
*
VuoNode::getRefreshPort
(
void
)
75
{
76
return
refreshPort;
77
}
78
82
vector<VuoPort *>
VuoNode::getInputPorts
(
void
)
83
{
84
return
inputPorts;
85
}
86
92
vector<VuoPort *>
VuoNode::getInputPortsBeforePort
(
VuoPort
*port)
93
{
94
vector<VuoPort *> foundPorts;
95
for
(vector<VuoPort *>::iterator i = inputPorts.begin(); i != inputPorts.end(); ++i)
96
if
((*i) == port)
97
return
foundPorts;
98
else
99
foundPorts.push_back(*i);
100
return
vector<VuoPort *>();
101
}
102
108
vector<VuoPort *>
VuoNode::getInputPortsAfterPort
(
VuoPort
*port)
109
{
110
vector<VuoPort *> foundPorts;
111
bool
found =
false
;
112
for
(vector<VuoPort *>::iterator i = inputPorts.begin(); i != inputPorts.end(); ++i)
113
{
114
if
(found)
115
foundPorts.push_back(*i);
116
if
((*i) == port)
117
found =
true
;
118
}
119
return
foundPorts;
120
}
121
125
vector<VuoPort *>
VuoNode::getOutputPorts
(
void
)
126
{
127
return
outputPorts;
128
}
129
135
vector<VuoPort *>
VuoNode::getOutputPortsBeforePort
(
VuoPort
*port)
136
{
137
vector<VuoPort *> foundPorts;
138
for
(vector<VuoPort *>::iterator i = outputPorts.begin(); i != outputPorts.end(); ++i)
139
if
((*i) == port)
140
return
foundPorts;
141
else
142
foundPorts.push_back(*i);
143
return
vector<VuoPort *>();
144
}
145
151
vector<VuoPort *>
VuoNode::getOutputPortsAfterPort
(
VuoPort
*port)
152
{
153
vector<VuoPort *> foundPorts;
154
bool
found =
false
;
155
for
(vector<VuoPort *>::iterator i = outputPorts.begin(); i != outputPorts.end(); ++i)
156
{
157
if
(found)
158
foundPorts.push_back(*i);
159
if
((*i) == port)
160
found =
true
;
161
}
162
return
foundPorts;
163
}
164
172
string
VuoNode::getTitle
(
void
)
173
{
174
return
title;
175
}
176
184
void
VuoNode::setTitle
(
string
title)
185
{
186
this->title = title;
187
}
188
192
bool
VuoNode::isTypecastNode
(
void
)
193
{
194
return
nodeClass->
isTypecastNodeClass
();
195
}
196
200
int
VuoNode::getX
(
void
)
201
{
202
return
x;
203
}
204
208
int
VuoNode::getY
(
void
)
209
{
210
return
y;
211
}
212
216
void
VuoNode::setX
(
int
x)
217
{
218
this->x = x;
219
}
220
224
void
VuoNode::setY
(
int
y)
225
{
226
this->y = y;
227
}
228
232
bool
VuoNode::isCollapsed
(
void
)
233
{
234
return
collapsed;
235
}
236
240
void
VuoNode::setCollapsed
(
bool
collapsed)
241
{
242
this->collapsed = collapsed;
243
}
244
248
enum
VuoNode::TintColor
VuoNode::getTintColor
(
void
)
249
{
250
return
tintColor;
251
}
252
256
string
VuoNode::getTintColorGraphvizName
(
void
)
257
{
258
return
getGraphvizNameForTint
(tintColor);
259
}
260
264
void
VuoNode::setTintColor
(
enum
VuoNode::TintColor
tintColor)
265
{
266
this->tintColor = tintColor;
267
}
268
272
bool
VuoNode::isForbidden
(
void
)
273
{
274
return
forbidden;
275
}
276
280
void
VuoNode::setForbidden
(
bool
forbidden)
281
{
282
this->forbidden = forbidden;
283
}
284
288
void
VuoNode::setRawGraphvizDeclaration
(
string
declaration)
289
{
290
this->rawGraphvizDeclaration = declaration;
291
}
292
297
string
VuoNode::getRawGraphvizDeclaration
(
void
)
298
{
299
return
rawGraphvizDeclaration;
300
}
301
306
string
VuoNode::getRawGraphvizIdentifier
(
void
)
307
{
308
string
identifier;
309
for
(
int
j = 0; j < rawGraphvizDeclaration.length() &&
VuoStringUtilities::isValidCharInIdentifier
(rawGraphvizDeclaration[j]); ++j)
310
identifier += rawGraphvizDeclaration[j];
311
return
identifier;
312
}
313
317
void
VuoNode::print
(
void
)
318
{
319
printf(
"VuoNode(%p,\"%s\")"
,
this
,title.c_str());
320
if
(
hasCompiler
())
321
printf(
" VuoCompilerNode(%p)"
,
getCompiler
());
322
if
(
hasRenderer
())
323
printf(
" VuoRendererNode(%p)"
,
getRenderer
());
324
printf(
"\n"
);
325
326
printf(
"\tposition (%d,%d)\n"
, x, y);
327
printf(
"\tcollapsed %s\n"
, collapsed ?
"true"
:
"false"
);
328
printf(
"\ttintColor %s\n"
,
getTintColorGraphvizName
().c_str());
329
330
for
(vector<VuoPort *>::iterator it = inputPorts.begin(); it != inputPorts.end(); ++it)
331
{
332
printf(
"\tinput "
);
333
(*it)->print();
334
}
335
336
for
(vector<VuoPort *>::iterator it = outputPorts.begin(); it != outputPorts.end(); ++it)
337
{
338
printf(
"\toutput "
);
339
(*it)->print();
340
}
341
342
fflush(stdout);
343
}
344
348
string
VuoNode::getGraphvizNameForTint
(
enum
TintColor
tintColor)
349
{
350
switch
(tintColor)
351
{
352
case
VuoNode::TintYellow:
353
return
"yellow"
;
354
case
VuoNode::TintTangerine:
355
return
"tangerine"
;
356
case
VuoNode::TintOrange:
357
return
"orange"
;
358
case
VuoNode::TintMagenta:
359
return
"magenta"
;
360
case
VuoNode::TintViolet:
361
return
"violet"
;
362
case
VuoNode::TintBlue:
363
return
"blue"
;
364
case
VuoNode::TintCyan:
365
return
"cyan"
;
366
case
VuoNode::TintGreen:
367
return
"green"
;
368
case
VuoNode::TintLime:
369
return
"lime"
;
370
default
:
371
return
""
;
372
}
373
}
374
378
enum
VuoNode::TintColor
VuoNode::getTintWithGraphvizName
(
string
tintName)
379
{
380
if
(tintName ==
"yellow"
)
381
return
VuoNode::TintYellow;
382
else
if
(tintName ==
"tangerine"
)
383
return
VuoNode::TintTangerine;
384
else
if
(tintName ==
"orange"
)
385
return
VuoNode::TintOrange;
386
else
if
(tintName ==
"magenta"
)
387
return
VuoNode::TintMagenta;
388
else
if
(tintName ==
"violet"
)
389
return
VuoNode::TintViolet;
390
else
if
(tintName ==
"blue"
)
391
return
VuoNode::TintBlue;
392
else
if
(tintName ==
"cyan"
)
393
return
VuoNode::TintCyan;
394
else
if
(tintName ==
"green"
)
395
return
VuoNode::TintGreen;
396
else
if
(tintName ==
"lime"
)
397
return
VuoNode::TintLime;
398
else
399
return
VuoNode::TintNone;
400
}
Generated on Thu Nov 9 2023 16:59:28 for Vuo by
1.9.8