Vuo
2.4.4
Loading...
Searching...
No Matches
renderer
VuoRendererValueListForReadOnlyDictionary.cc
Go to the documentation of this file.
1
10
#include "
VuoRendererValueListForReadOnlyDictionary.hh
"
11
#include "
VuoRendererReadOnlyDictionary.hh
"
12
#include "
VuoCompilerMakeListNodeClass.hh
"
13
#include "
VuoCompilerInputEventPort.hh
"
14
#include "
VuoNodeClass.hh
"
15
#include "
VuoPort.hh
"
16
#include "
VuoRendererPort.hh
"
17
22
VuoRendererValueListForReadOnlyDictionary::VuoRendererValueListForReadOnlyDictionary
(
VuoNode
*baseNode,
VuoRendererSignaler
*signaler)
23
:
VuoRendererInputDrawer
(baseNode, signaler)
24
{
25
VuoNode
*makeKeyListNode =
getKeyListNode
();
26
vector<VuoPort *> makeKeyListNodeInputs;
27
if
(makeKeyListNode)
28
makeKeyListNodeInputs = makeKeyListNode->
getInputPorts
();
29
30
vector<VuoPort *>
inputPorts
= this->
getBase
()->
getInputPorts
();
31
for
(
int
i =
VuoNodeClass::unreservedInputPortStartIndex
; i <
inputPorts
.size(); ++i)
32
{
33
string
keyName =
" "
;
34
if
(i < makeKeyListNodeInputs.size())
35
{
36
VuoCompilerInputEventPort
*keyPort=
static_cast<
VuoCompilerInputEventPort
*
>
(makeKeyListNodeInputs[i]->getCompiler());
37
keyName = keyPort->
getData
()->
getInitialValue
();
38
}
39
40
inputPorts
[i]->getRenderer()->setPortNameToRender(getRenderedPortNameFormForText(keyName));
41
}
42
}
43
49
string
VuoRendererValueListForReadOnlyDictionary::getRenderedPortNameFormForText(
string
text)
50
{
51
json_object *js = json_tokener_parse(text.c_str());
52
string
textWithoutQuotes;
53
if
(json_object_get_type(js) == json_type_string)
54
textWithoutQuotes = json_object_get_string(js);
55
json_object_put(js);
56
57
return
textWithoutQuotes;
58
}
59
64
void
VuoRendererValueListForReadOnlyDictionary::paint
(QPainter *painter,
const
QStyleOptionGraphicsItem *option, QWidget *widget)
65
{
66
drawBoundingRect
(painter);
67
VuoRendererColors::SelectionType
selectionType = (
isEffectivelySelected
()? VuoRendererColors::directSelection : VuoRendererColors::noSelection);
68
qint64 timeOfLastActivity = (
getRenderActivity
()?
timeLastExecutionEnded
: VuoRendererItem::notTrackingActivity);
69
VuoRendererColors
*drawerColors =
new
VuoRendererColors
(
getBase
()->getTintColor(),
70
selectionType,
71
false
,
72
VuoRendererColors::noHighlight
,
73
timeOfLastActivity);
74
75
76
// Drawer frame
77
painter->fillPath(
getDrawerPath
(
false
), drawerColors->
nodeFill
());
78
79
// Child input ports
80
layoutPorts
();
81
82
delete
drawerColors;
83
}
84
88
QRectF
VuoRendererValueListForReadOnlyDictionary::boundingRect
(
void
)
const
89
{
90
QRectF r =
getDrawerPath
(
false
).boundingRect();
91
92
// Antialiasing bleed
93
r.adjust(-1,-1,1,1);
94
95
return
r.toAlignedRect();
96
}
97
102
QPainterPath
VuoRendererValueListForReadOnlyDictionary::shape
()
const
103
{
104
QPainterPath p;
105
p.addPath(
getDrawerPath
(
false
));
106
107
return
p;
108
}
109
115
bool
VuoRendererValueListForReadOnlyDictionary::isValueListForReadOnlyDictionary
(
VuoNode
*baseNode)
116
{
117
if
(!
VuoCompilerMakeListNodeClass::isMakeListNodeClassName
(baseNode->
getNodeClass
()->
getClassName
()))
118
return
false
;
119
120
VuoPort
*hostPort =
getUnderlyingHostPortForNode
(baseNode);
121
VuoNode
*hostNode =
getUnderlyingHostNodeForNode
(baseNode);
122
bool
providesValuesToMakeReadOnlyDictionaryNode = (hostPort &&
123
(hostPort->
getClass
()->
getName
() ==
"values"
) &&
124
(
VuoRendererReadOnlyDictionary::isReadOnlyDictionary
(hostNode)));
125
return
providesValuesToMakeReadOnlyDictionaryNode;
126
}
127
132
VuoNode
*
VuoRendererValueListForReadOnlyDictionary::getKeyListNode
()
133
{
134
VuoNode
*hostNode =
getUnderlyingHostNode
();
135
if
(!hostNode)
136
return
NULL;
137
138
VuoPort
*keyListInputPort = hostNode->
getInputPortWithName
(
"keys"
);
139
return
getListNodeConnectedToInputPort
(keyListInputPort);
140
}
141
145
VuoPort
*
VuoRendererValueListForReadOnlyDictionary::getRenderedHostPort
()
146
{
147
// The port that will ultimately make use of this node's output values is two nodes downstream.
148
return
getUnderlyingHostPortForNode
(
getUnderlyingHostNodeForNode
(this->
getBase
()));
149
}
150
154
VuoNode
*
VuoRendererValueListForReadOnlyDictionary::getRenderedHostNode
()
155
{
156
// The node that will ultimately make use of this node's output values is two nodes downstream.
157
return
getUnderlyingHostNodeForNode
(
getUnderlyingHostNodeForNode
(this->
getBase
()));
158
}
159
163
QRectF
VuoRendererValueListForReadOnlyDictionary::getOuterNodeFrameBoundingRect
(
void
)
const
164
{
165
return
getDrawerPath
(
false
).boundingRect();
166
}
167
173
set<VuoNode *>
VuoRendererValueListForReadOnlyDictionary::getCoattachments
(
void
)
174
{
175
VuoNode
*dictionaryNode =
getUnderlyingHostNode
();
176
VuoNode
*keyListNode =
getKeyListNode
();
177
178
set<VuoNode *> coattachments;
179
if
(dictionaryNode)
180
coattachments.insert(dictionaryNode);
181
if
(keyListNode)
182
coattachments.insert(keyListNode);
183
return
coattachments;
184
}
Generated on Thu Nov 9 2023 16:59:30 for Vuo by
1.9.8