Vuo  2.4.0
VuoRendererValueListForReadOnlyDictionary.cc
Go to the documentation of this file.
1
14#include "VuoNodeClass.hh"
15#include "VuoPort.hh"
16#include "VuoRendererPort.hh"
17
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
49string 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
64void 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,
73 timeOfLastActivity);
74
75
76 // Drawer frame
77 painter->fillPath(getDrawerPath(false), drawerColors->nodeFill());
78
79 // Child input ports
81
82 delete drawerColors;
83}
84
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
103{
104 QPainterPath p;
105 p.addPath(getDrawerPath(false));
106
107 return p;
108}
109
116{
118 return false;
119
120 VuoPort *hostPort = getUnderlyingHostPortForNode(baseNode);
121 VuoNode *hostNode = getUnderlyingHostNodeForNode(baseNode);
122 bool providesValuesToMakeReadOnlyDictionaryNode = (hostPort &&
123 (hostPort->getClass()->getName() == "values") &&
125 return providesValuesToMakeReadOnlyDictionaryNode;
126}
127
133{
134 VuoNode *hostNode = getUnderlyingHostNode();
135 if (!hostNode)
136 return NULL;
137
138 VuoPort *keyListInputPort = hostNode->getInputPortWithName("keys");
139 return getListNodeConnectedToInputPort(keyListInputPort);
140}
141
146{
147 // The port that will ultimately make use of this node's output values is two nodes downstream.
149}
150
155{
156 // The node that will ultimately make use of this node's output values is two nodes downstream.
158}
159
164{
165 return getDrawerPath(false).boundingRect();
166}
167
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}