41 setZValue(nodeZValue);
44 this->signaler = NULL;
47 this->proxyNode = NULL;
48 this->nodeType = VuoRendererNode::node;
53 this->nodeClass = QString::fromUtf8(nodeClass->
getClassName().c_str());
57 this->nodeClass = this->nodeClass.normalized(QString::NormalizationForm_C);
66 this->setFlags(QGraphicsItem::ItemIsMovable |
67 QGraphicsItem::ItemIsSelectable |
68 QGraphicsItem::ItemIsFocusable |
69 QGraphicsItem::ItemSendsGeometryChanges);
71 this->setAcceptHoverEvents(
true);
74 vector<VuoRendererPort *> inputs;
81 setInputPorts(inputs);
85 vector<VuoRendererPort *> outputs;
89 bool isFunctionPort =
false;
92 setOutputPorts(outputs);
95 setPos(baseNode->
getX(), baseNode->
getY());
258 painter->fillPath(this->subcompositionIndicatorPath, QBrush(QColor::fromRgb(255,255,255,128)));
267 QRectF nodeOuterFrameRect;
270 nodeOuterFrameRect = QRectF(
271 nodeInnerFrameRect.left() - VuoRendererNode::outerBorderWidth,
273 nodeInnerFrameRect.width() + 2*VuoRendererNode::outerBorderWidth,
279 QPainterPath nodeOuterFrame;
283 nodeOuterFrame.moveTo(nodeOuterFrameRect.right(), nodeOuterFrameRect.center().y());
284 addRoundedCorner(nodeOuterFrame,
true, nodeOuterFrameRect.bottomRight(), nodeHeaderBottomCornerRadius,
false,
false);
285 addRoundedCorner(nodeOuterFrame,
true, nodeOuterFrameRect.bottomLeft(), nodeHeaderBottomCornerRadius,
false,
true);
290 QPainterPath nodeInnerFrame;
293 qreal bw = VuoRendererNode::outerBorderWidth;
294 nodeInnerFrame.moveTo(nodeInnerFrameRect.topLeft() - QPoint(bw, 0) - QPoint(0, nodeHeaderBottomCornerRadius));
295 nodeInnerFrame.lineTo(nodeInnerFrameRect.topRight() + QPoint(bw, 0) - QPoint(0, nodeHeaderBottomCornerRadius));
300 return qMakePair(nodeOuterFrame, nodeInnerFrame);
309 if (!isSubcomposition)
310 return QPainterPath();
315 QPainterPath rectPath;
316 rectPath.addRect(QRectF(-0.5 + nodeInnerFrameRect.right() - iconRightOffset,
317 -4. - 1.5*rectSideLength,
322 QPainterPathStroker rectStroker;
323 QPainterPath topLeftStroke = rectStroker.createStroke(rectPath);
326 rectPath.translate(-0.5 + rectSideLength/2,
327 -0.5 + rectSideLength/2);
328 QPainterPath bottomRightStroke = rectStroker.createStroke(rectPath);
331 return topLeftStroke.united(bottomRightStroke);
342 for (
unsigned int i =
inputPorts.size()-1; i > portIndex; --i)
351 qreal currentTypecastOffset = tp->
getPortPath(
true,
true).boundingRect().width()
355 if (currentTypecastOffset > maxOffset)
356 maxOffset = currentTypecastOffset;
360 qreal currentConstantOffset = port->
getPortPath().boundingRect().width()
364 if (currentConstantOffset > maxOffset)
365 maxOffset = currentConstantOffset;
373 qreal targetDrawerOffset =
inputPorts[portIndex]->getRenderer()->getAttachedInputDrawer()->getMaxDrawerLabelWidth()
376 return targetDrawerOffset + maxOffset;
403 QRectF updatedFrameRect;
404 QString nodeTitle = QString::fromUtf8(
getBase()->getTitle().c_str());
408 nodeTitle = nodeTitle.normalized(QString::NormalizationForm_C);
411 qreal maxPortRowWidth=0;
415 size_t portRowCount = max(inputPortCount, outputPortCount);
416 for (
int portRow = 0; portRow < portRowCount; ++portRow)
422 qreal thisRowWidth = 0;
423 if (adjustedInputPortRow < inputPortCount)
432 if (adjustedOutputPortRow < outputPortCount)
433 thisRowWidth +=
outputPorts[adjustedOutputPortRow]->getNameRect().width();
435 if(thisRowWidth > maxPortRowWidth)
436 maxPortRowWidth = thisRowWidth;
442 if (this->nodeIsSubcomposition)
443 nodeClassWidth += VuoRendererNode::iconRightOffset;
447 int unalignedFrameWidth =
451 + nodeTitleHorizontalMargin * 2.
477 - 2*VuoRendererNode::outerBorderWidth;
479 if (alignedFrameWidth < unalignedFrameWidth)
482 updatedFrameRect.setWidth(alignedFrameWidth);
485 updatedFrameRect.setHeight(
495 this->frameRect = updatedFrameRect;
596 drawNodeFrame(painter, frameRect, colors);
600 QString nodeTitle = QString::fromUtf8(
getBase()->getTitle().c_str());
604 nodeTitle = nodeTitle.normalized(QString::NormalizationForm_C);
608 nodeTitleBoundingRect = QRectF(
609 nodeTitleHorizontalMargin
616 painter->setFont(font);
617 painter->drawText(nodeTitleBoundingRect,Qt::AlignLeft,nodeTitle);
629 -nodeClassHeight - 2.,
634 painter->setFont(font);
635 painter->drawText(r,Qt::AlignLeft,nodeClass);
645 QString text = notAvailable ?
"Not Available" :
"Not Installed";
649 if (
getBase()->getNodeClass()->isPro())
651 QFontMetrics fm(font);
653 stickerRect.setSize(QSize(16,16));
654 stickerRect.moveCenter(frameRect.center().toPoint());
655 stickerRect.translate(-fm.boundingRect(text).width()/2 - 12, -2);
656 QIcon(
":/Icons/menuitem-pro.svg").paint(painter, stickerRect);
661 painter->setFont(font);
662 painter->drawText(frameRect, Qt::AlignCenter, text);
726 QVariant newValue = value;
728 if (change == QGraphicsItem::ItemPositionChange)
740 newValue = value.toPoint();
747 (*it)->setCacheModeForPortAndChildren(QGraphicsItem::NoCache);
748 (*it)->updateGeometry();
754 (*it)->setCacheModeForPortAndChildren(QGraphicsItem::NoCache);
755 (*it)->updateGeometry();
766 if (change == QGraphicsItem::ItemPositionHasChanged)
768 QPointF newPos = value.toPointF();
769 if ((
getBase()->getX() != newPos.x()) || (
getBase()->getY() != newPos.y()))
779 set<VuoRendererNode *> movedNodes;
785 movedNodes.insert(
this);
796 if (change == QGraphicsItem::ItemSelectedHasChanged)
807 attachment->update();
810 attachmentInputPort->update();
831 return QGraphicsItem::itemChange(change, newValue);
924 set<VuoCable *> connectedCables;
925 connectedCables.insert(connectedInputCables.begin(), connectedInputCables.end());
926 connectedCables.insert(connectedOutputCables.begin(), connectedOutputCables.end());
928 return connectedCables;
938 set<VuoCable *> connectedInputCables;
941 for(vector<VuoPort *>::iterator inputPort =
inputPorts.begin(); inputPort !=
inputPorts.end(); ++inputPort)
943 vector<VuoCable *> inputCables = (*inputPort)->getConnectedCables(includePublishedCables);
944 connectedInputCables.insert(inputCables.begin(), inputCables.end());
946 if ((*inputPort)->hasRenderer())
952 connectedInputCables.insert(childPortInputCables.begin(), childPortInputCables.end());
957 return connectedInputCables;
1165 this->setCacheMode(QGraphicsItem::NoCache);
1167 this->setCacheMode(mode);
1169 for (vector<VuoRendererPort *>::iterator it =
inputPorts.begin(); it !=
inputPorts.end(); ++it)
1170 (*it)->setCacheModeForPortAndChildren(mode);
1173 (*it)->setCacheModeForPortAndChildren(mode);