38 #pragma clang diagnostic push
39 #pragma clang diagnostic ignored "-Wdocumentation"
40 #include <json-c/json.h>
41 #pragma clang diagnostic pop
57 bool isOutput,
bool isRefreshPort,
bool isFunctionPort)
66 this->isOutput = isOutput;
68 this->isFunctionPort = isFunctionPort;
70 this->isEligibleForSelection =
false;
72 this->typecastParentPort = NULL;
77 const int maxAnimationsPerPort = 4;
81 for (
int i = 0; i < maxAnimationsPerPort; ++i)
83 QGraphicsItemAnimation *animation =
new QGraphicsItemAnimation();
85 animations.push_back(animation);
91 setFlag(QGraphicsItem::ItemIsFocusable,
true);
92 setAcceptHoverEvents(
true);
108 void VuoRendererPort::addRoundedTriangle(QPainterPath &p, QPointF center, qreal radius, qreal cornerRadius)
110 p.moveTo(center + QPointF(radius,0));
111 for (
int theta = 0; theta <= 360; theta += 120)
113 QRectF rect(center.x() + (radius - cornerRadius)*cos(theta*M_PI/180.) - cornerRadius,
114 center.y() - (radius - cornerRadius)*sin(theta*M_PI/180.) - cornerRadius,
117 bool first = theta==0;
118 bool last = theta==360;
121 theta - (first ? 0 : 60),
122 (first||last ? 60 : 120));
146 getBase()->getClass()->getPortType(),
159 QString constantText,
166 QRectF innerPortRect = outerPortRect.adjusted(inset,inset,-inset,-inset);
171 QPointF topLeftCorner(left + .5, innerPortRect.top() - .24);
172 QPointF topRightCorner(innerPortRect.right() + .5, innerPortRect.top() - .24);
173 QPointF bottomRightCorner(innerPortRect.right() + .5, innerPortRect.bottom() - .43);
174 QPointF bottomLeftCorner(left + .5, innerPortRect.bottom() - .43);
176 p.moveTo(innerPortRect.right() + .5, innerPortRect.center().y());
178 addRoundedCorner(p,
true, bottomRightCorner, adjustedPortRadius,
false,
false);
179 addRoundedCorner(p,
true, bottomLeftCorner, adjustedPortRadius,
false,
true);
204 QRectF barrierRect = QRectF();
232 if (!paintDataAntenna && !paintEventAntenna)
233 return QPainterPath();
241 const qreal pixelOffset = -.3;
242 QPointF startPoint = (
getInput()? -QPointF(mastLength - (paintDataAntenna ? 0.5 : 0 ) + constantWidth, -pixelOffset) : QPointF(0, pixelOffset));
243 QPointF endPoint = (
getInput()? QPointF(-constantWidth, pixelOffset) : QPointF(mastLength + (paintDataAntenna ? 0.5 : 0 ), pixelOffset));
245 VuoCable cableBase(NULL, NULL, NULL, NULL);
249 QPainterPathStroker mastStroker;
250 mastStroker.setWidth(cableWidth);
251 mastStroker.setCapStyle(Qt::RoundCap);
252 QPainterPath antennaOutline = mastStroker.createStroke(mastPath);
255 qreal outerCrossbarXOffset = (paintDataAntenna? 1 : 0.5);
256 const QPointF outerCrossbarPos = (
getInput()? startPoint - QPointF(outerCrossbarXOffset, 0) :
257 endPoint + QPointF(outerCrossbarXOffset, 0));
258 const int crossbarSpacing = 5;
261 QPainterPath crossbars;
262 for (
int i = 0; i < 2; ++i)
264 crossbars.moveTo((outerCrossbarPos +
265 QPointF(QPointF(0, -0.5*crossbarHeight) +
266 QPointF((
getInput()? 1 : -1)*crossbarSpacing*i, 0))));
267 crossbars.lineTo((outerCrossbarPos +
268 QPointF(QPointF(0, 0.5*crossbarHeight) +
269 QPointF((
getInput()? 1 : -1)*crossbarSpacing*i, 0))));
273 QPainterPathStroker crossbarStroker;
274 crossbarStroker.setWidth(cableWidth*3/5);
275 crossbarStroker.setCapStyle(Qt::RoundCap);
276 antennaOutline += crossbarStroker.createStroke(crossbars);
278 return antennaOutline;
287 for (vector<VuoCable *>::iterator cable = connectedCables.begin(); cable != connectedCables.end(); ++cable)
288 if ((*cable)->hasRenderer() && (*cable)->getRenderer()->effectivelyCarriesData() &&
289 (*cable)->getRenderer()->getEffectivelyWireless() &&
290 (*cable)->getRenderer()->paintingDisabled())
301 for (vector<VuoCable *>::iterator cable = connectedCables.begin(); cable != connectedCables.end(); ++cable)
302 if ((*cable)->hasRenderer() && !(*cable)->getRenderer()->effectivelyCarriesData() &&
303 (*cable)->getRenderer()->getEffectivelyWireless() &&
304 (*cable)->getRenderer()->paintingDisabled())
315 if (renderedParentNode)
328 return VuoNode::TintNone;
342 set<VuoNode::TintColor> connectedPortTints;
346 if (connectedPortTints.size() > 1)
347 return VuoNode::TintNone;
350 if (connectedPortTints.size() == 1)
351 return *connectedPortTints.begin();
353 return VuoNode::TintNone;
361 set<VuoRendererPort *> connectedPorts;
362 foreach (
VuoCable *cable,
getBase()->getConnectedCables(includePublishedCables))
370 connectedPorts.insert(connectedPort->
getRenderer());
374 return connectedPorts;
393 if (underlyingAttachment &&
400 else if (underlyingAttachment)
407 return upstreamDrawer;
443 set<VuoRendererInputAttachment *> allUpstreamAttachments;
445 if (!directUpstreamAttachment)
446 return allUpstreamAttachments;
448 allUpstreamAttachments.insert(directUpstreamAttachment);
451 foreach (
VuoPort *port, inputPorts)
454 allUpstreamAttachments.insert(indirectUpstreamAttachments.begin(), indirectUpstreamAttachments.end());
457 return allUpstreamAttachments;
478 static QHash<QString, int> cachedTextWidths;
479 QHash<QString, int>::iterator i = cachedTextWidths.find(text);
480 if (i != cachedTextWidths.end())
484 .boundingRect(QRectF(0,0,0,0), Qt::TextIncludeTrailingSpaces, text)
486 cachedTextWidths.insert(text, textWidth);
504 return textRect.toAlignedRect();
522 QFont font = getPortNameFont();
523 QSizeF textSize = QFontMetricsF(font).size(0,text);
571 if (!parentItem()->parentItem())
582 return typecastParentPort;
590 this->typecastParentPort = typecastParentPort;
667 painter->drawPoint(barrierRect.center() + QPointF(0, -barrierRect.height()/2. + 1.75 + .17));
668 painter->drawPoint(barrierRect.center() + QPointF(0, barrierRect.height()/2. - 1.75 + .17));
676 QFont VuoRendererPort::getPortNameFont(
void)
const
704 painter->setFont(getPortNameFont());
705 painter->drawText(
getNameRect(), isOutput? Qt::AlignRight : Qt::AlignLeft, QString::fromStdString(name));
766 QFontMetricsF fontMetrics = QFontMetricsF(getPortNameFont());
767 const qreal marginFromPortName = 4;
768 const qreal triangleSize = 6;
769 qreal triangleLeft = qRound(
getNameRect().right() + marginFromPortName );
770 qreal triangleTop = qRound(
getNameRect().bottom() - fontMetrics.descent() - fontMetrics.xHeight() );
772 return QRectF(triangleLeft, triangleTop, triangleSize, triangleSize);
788 painter->fillPath(p, color);
816 if (!(scene() || publishedPort))
819 painter->setRenderHint(QPainter::Antialiasing,
true);
825 VuoRendererColors::noSelection);
827 bool isHovered = isEligibleForSelection;
832 bool effectivelyHovered = isHovered;
837 if (drawerHighlight < _eligibilityHighlight)
839 effectiveHighlight = drawerHighlight;
842 effectivelyHovered =
false;
868 else if (publishedPort)
876 bool showRightHalfOnly =
false;
886 qint64 timeNow = QDateTime::currentMSecsSinceEpoch();
887 const double fadeThreshold = 0.3;
888 qint64 childTimeOfLastActivity = drawerChildPort? drawerChildPort->
getTimeOfLastActivity() : VuoRendererItem::notTrackingActivity;
889 bool showingActiveEvent = (timeOfLastActivity != VuoRendererItem::notTrackingActivity) &&
891 (timeOfLastActivity == VuoRendererItem::activityInProgress));
892 bool childShowingActiveEvent = (childTimeOfLastActivity != VuoRendererItem::notTrackingActivity) &&
894 (childTimeOfLastActivity == VuoRendererItem::activityInProgress));
895 showRightHalfOnly = !effectivelyHovered && drawerChildPort &&
897 !(showingActiveEvent && !childShowingActiveEvent);
900 if (showRightHalfOnly)
903 painter->fillPath(portPath, portBrush);
905 if (showRightHalfOnly)
906 painter->setClipping(
false);
917 QColor swatchColor = QColor(c.r*255, c.g*255, c.b*255, c.a*255 * portBrush.color().alphaF());
921 bool isDark = colors->
isDark();
926 if ((a < 1) || (isDark ? l < .25 : l > .75))
929 QColor topLeftColor = colors->
nodeFrame();
930 painter->fillPath(portPath, topLeftColor);
934 QColor bottomRightColor = isDark ? Qt::black : Qt::white;
935 QTransform transform;
936 transform.scale(0.87, 0.87);
937 QPainterPath smallerCircle = portPath * transform;
939 QRectF r = portPath.boundingRect();
940 QPainterPath bottomRight;
941 bottomRight.moveTo(r.bottomLeft());
942 bottomRight.lineTo(r.topRight());
943 bottomRight.lineTo(r.bottomRight());
944 painter->setClipPath(smallerCircle);
945 painter->fillPath(bottomRight, bottomRightColor);
946 painter->setClipping(
false);
950 painter->fillPath(smallerCircle, swatchColor);
955 painter->fillPath(portPath, swatchColor);
959 painter->fillPath(portPath, portBrush);
962 QBrush constantFlagBackgroundBrush = colors->
constantFill();
968 painter->drawText(textRect, Qt::AlignLeft, constantText);
977 painter->fillPath(p, colors->
portIcon());
986 delete antennaColors;
1002 return ((! renderNodeActivity)? VuoRendererItem::notTrackingActivity :
1003 ((isTriggerPort && renderPortActivity)? timeLastEventFired :
1006 VuoRendererItem::notTrackingActivity))));
1015 return isEligibleForSelection;
1033 _eligibilityHighlight = eligibility;
1041 return _eligibilityHighlight;
1059 QGraphicsItem::CacheMode normalCacheMode = cacheMode();
1060 setCacheMode(QGraphicsItem::NoCache);
1062 prepareGeometryChange();
1065 setCacheMode(normalCacheMode);
1069 if (!cableDragUnderway && !disableConnectedCableHighlight)
1074 VuoRendererCable *cableToDisconnect = connectedCables.back()->getRenderer();
1086 QGraphicsItem::CacheMode normalCacheMode = cacheMode();
1087 setCacheMode(QGraphicsItem::NoCache);
1089 prepareGeometryChange();
1090 isEligibleForSelection =
false;
1092 setCacheMode(normalCacheMode);
1099 VuoRendererCable *cableToDisconnect = connectedCables.back()->getRenderer();
1119 bool fromPortIsEnabledOutput = (this->
getOutput() && this->isEnabled());
1120 bool toPortIsEnabledInput = (toPort && toPort->
getInput() && toPort->isEnabled());
1122 if (!(fromPortIsEnabledOutput && toPortIsEnabledInput))
1126 if (eventOnlyConnection)
1135 if (!fromDataType || !toDataType)
1139 if (!
dynamic_cast<VuoGenericType *
>(fromDataType) && (fromDataType == toDataType))
1173 string specializedTypeName =
"";
1193 *portToSpecialize = NULL;
1194 specializedTypeName =
"";
1199 bool fromPortIsEnabledOutput = (this->
getOutput() && this->isEnabled());
1200 bool toPortIsEnabledInput = (toPort && toPort->
getInput() && toPort->isEnabled());
1202 if (!(fromPortIsEnabledOutput && toPortIsEnabledInput))
1211 if (!(originalFromDataType && originalToDataType && currentFromDataType && currentToDataType))
1224 *portToSpecialize =
this;
1225 specializedTypeName = originalToDataType->
getModuleKey();
1233 *portToSpecialize = toPort;
1234 specializedTypeName = originalFromDataType->
getModuleKey();
1248 for (vector<VuoCable *>::iterator cable = cables.begin(); cable != cables.end(); ++cable)
1249 if ((*cable)->getToPort() == toPort->
getBase())
1272 (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter))
1294 return ((! isOutput) && (! isFunctionPort));
1318 return isFunctionPort;
1335 (
getBase()->getClass()->hasCompiler() &&
1345 this->prepareGeometryChange();
1355 if (change == QGraphicsItem::ItemPositionHasChanged)
1362 return QGraphicsItem::itemChange(change, value);
1392 if (portName ==
"url")
1397 if (portName ==
"folder")
1427 if (details && json_object_object_get_ex(details,
"isSave", &isSaveValue) && json_object_get_boolean(isSaveValue))
1434 return isRelativePath;
1453 for (vector<VuoCable *>::iterator cable = connectedCables.begin(); cable != connectedCables.end(); ++cable)
1454 if ((*cable)->hasRenderer() && (*cable)->getRenderer()->effectivelyCarriesData())
1467 int size = vsnprintf(NULL, 0,
format, args);
1470 char *formattedString = (
char *)malloc(size+1);
1472 vsnprintf(formattedString, size+1,
format, args);
1475 string s(formattedString);
1476 free(formattedString);
1499 if (! compilerEventPort)
1522 size_t maxLength = strlen(
"Matches wildcard (not case-sensitive)");
1524 VuoTextTruncation_Beginning :
1525 VuoTextTruncation_End);
1535 #define RETURN_SHORT_SUMMARY(type) \
1536 if (getDataType()->getModuleKey() == #type) \
1538 type value = type ## _makeFromString(getConstantAsString().c_str()); \
1539 type ## _retain(value); \
1540 string s = stringAndFree(type ## _getShortSummary(value)); \
1541 type ## _release(value); \
1568 if (typeName ==
"VuoData")
1582 double real = json_object_get_double(js);
1583 json_object_put(js);
1589 if (json_object_object_get_ex(portDetails,
"auto", &autoObject))
1590 if (real == json_object_get_double(autoObject))
1606 if (details && json_object_object_get_ex(details,
"menuItems", &menuItemsValue))
1610 if (portValue ==
"false")
1612 else if (portValue ==
"true")
1615 int len = json_object_array_length(menuItemsValue);
1616 for (
int i = 0; i < len; ++i)
1618 json_object *menuItem = json_object_array_get_idx(menuItemsValue, i);
1619 if (json_object_is_type(menuItem, json_type_object))
1622 if (json_object_object_get_ex(menuItem,
"value", &value))
1623 if ((json_object_is_type(value, json_type_string) && portValue == json_object_get_string(value))
1624 || (json_object_is_type(value, json_type_int ) && atol(portValue.c_str()) == json_object_get_int64(value)))
1627 if (json_object_object_get_ex(menuItem,
"name", &name))
1643 json_object_put(js);
1649 if (json_object_object_get_ex(portDetails,
"auto", &autoObject))
1650 if (i == json_object_get_int64(autoObject))
1654 return format(
"%lld", i);
1659 QList<float> pointList = QList<float>() << p.x << p.y;
1665 QList<float> pointList = QList<float>() << p.x << p.y << p.z;
1671 QList<float> pointList = QList<float>() << p.x << p.y << p.z << p.w;
1679 const char *fontName = NULL;
1680 if (json_object_object_get_ex(js,
"fontName", &o))
1681 fontName = json_object_get_string(o);
1683 double pointSize = 0;
1684 if (json_object_object_get_ex(js,
"pointSize", &o))
1685 pointSize = json_object_get_double(o);
1687 bool underline =
false;
1688 if (json_object_object_get_ex(js,
"underline", &o))
1689 underline = json_object_get_boolean(o);
1690 const char *underlineString = underline ?
" [U]" :
"";
1692 string outputString;
1694 outputString =
format(
"%s %gpt%s", fontName, pointSize, underlineString);
1696 json_object_put(js);
1698 return outputString;
1700 if (
getDataType()->getModuleKey()==
"VuoMathExpressionList")
1706 if (json_object_object_get_ex(js,
"expressions", &expressionsObject))
1708 if (json_object_get_type(expressionsObject) == json_type_array)
1710 int itemCount = json_object_array_length(expressionsObject);
1713 json_object *itemObject = json_object_array_get_idx(expressionsObject, 0);
1714 if (json_object_get_type(itemObject) == json_type_string)
1716 expression = json_object_get_string(itemObject);
1717 json_object_put(itemObject);
1723 json_object_put(js);
1727 if (
getDataType()->getModuleKey()==
"VuoRealRegulation")
1732 string outputString;
1733 if (json_object_object_get_ex(js,
"name", &o))
1734 outputString = json_object_get_string(o);
1736 json_object_put(js);
1738 return outputString;
1747 return format(
"%lu×%lu", value->pixelsWide, value->pixelsHigh);
1749 if (
getDataType()->getModuleKey()==
"VuoTransform")
1756 if (value.type == VuoTransformTypeTargeted)
1757 return format(
"(%g,%g,%g) toward (%g,%g,%g)",
1758 value.translation.x, value.translation.y, value.translation.z, value.rotationSource.target.x, value.rotationSource.target.y, value.rotationSource.target.z);
1761 if (value.type == VuoTransformTypeQuaternion)
1762 rotation =
format(
"‹%g,%g,%g,%g›",
1763 value.rotationSource.quaternion.x, value.rotationSource.quaternion.y, value.rotationSource.quaternion.z, value.rotationSource.quaternion.w);
1767 rotation =
format(
"(%g°,%g°,%g°)",
1771 return format(
"(%g,%g,%g) %s %g×%g×%g",
1772 value.translation.x, value.translation.y, value.translation.z, rotation.c_str(), value.scale.x, value.scale.y, value.scale.z);
1774 if (
getDataType()->getModuleKey()==
"VuoTransform2d")
1782 return format(
"(%g,%g) %g° %g×%g",
1783 value.translation.x, value.translation.y, rotationInDegrees, value.scale.x, value.scale.y);
1785 if (
getDataType()->getModuleKey()==
"VuoMovieFormat")
1790 const char *imageEncoding = NULL;
1791 if (json_object_object_get_ex(js,
"imageEncoding", &o))
1793 imageEncoding = json_object_get_string(o);
1794 if (strcasecmp(imageEncoding,
"jpeg") == 0)
1795 imageEncoding =
"JPEG";
1796 else if (strcasecmp(imageEncoding,
"h264") == 0)
1797 imageEncoding =
"H.264";
1798 else if (strcasecmp(imageEncoding,
"prores4444") == 0)
1799 imageEncoding =
"ProRes 4444";
1800 else if (strcasecmp(imageEncoding,
"prores422") == 0)
1801 imageEncoding =
"ProRes 422";
1802 else if (strcasecmp(imageEncoding,
"prores422-hq") == 0)
1803 imageEncoding =
"ProRes 422 HQ";
1804 else if (strcasecmp(imageEncoding,
"prores422-lt") == 0)
1805 imageEncoding =
"ProRes 422 LT";
1806 else if (strcasecmp(imageEncoding,
"prores422-proxy") == 0)
1807 imageEncoding =
"ProRes 422 Proxy";
1808 else if (strcmp(imageEncoding,
"hevc") == 0)
1809 imageEncoding =
"HEVC";
1810 else if (strcmp(imageEncoding,
"hevc-alpha") == 0)
1811 imageEncoding =
"HEVC+Alpha";
1814 const char *audioEncoding = NULL;
1815 if (json_object_object_get_ex(js,
"audioEncoding", &o))
1817 audioEncoding = json_object_get_string(o);
1818 if (strcmp(audioEncoding,
"LinearPCM") == 0)
1819 audioEncoding =
"Linear PCM";
1822 string outputString;
1823 if (imageEncoding && audioEncoding)
1824 outputString =
format(
"%s, %s", imageEncoding, audioEncoding);
1826 json_object_put(js);
1828 return outputString;
1836 if (json_object_object_get_ex(js,
"type", &o))
1840 if (type == VuoScreenType_Active)
1842 else if (type == VuoScreenType_Primary)
1844 else if (type == VuoScreenType_Secondary)
1845 label =
"Secondary";
1846 else if (type == VuoScreenType_MatchName)
1848 if (json_object_object_get_ex(js,
"name", &o))
1849 label = json_object_get_string(o);
1851 else if (type == VuoScreenType_MatchId)
1856 label = realizedScreen.
name;
1859 json_object_put(js);
1863 if (
getDataType()->getModuleKey()==
"VuoSerialDevice")
1868 const char *name = NULL;
1869 if (json_object_object_get_ex(js,
"name", &o))
1870 name = json_object_get_string(o);
1871 else if (json_object_object_get_ex(js,
"path", &o))
1872 name = json_object_get_string(o);
1874 string outputString =
"First";
1875 if (name && strlen(name))
1876 outputString = name;
1878 json_object_put(js);
1880 return outputString;
1882 if (
getDataType()->getModuleKey()==
"VuoMidiInputDevice")
1887 const char *name = NULL;
1888 if (json_object_object_get_ex(js,
"name", &o))
1889 name = json_object_get_string(o);
1891 string outputString =
"First";
1892 if (name && strlen(name))
1893 outputString = name;
1895 json_object_put(js);
1897 return outputString;
1899 if (
getDataType()->getModuleKey()==
"VuoMidiOutputDevice")
1904 const char *name = NULL;
1905 if (json_object_object_get_ex(js,
"name", &o))
1906 name = json_object_get_string(o);
1908 string outputString =
"First";
1909 if (name && strlen(name))
1910 outputString = name;
1912 json_object_put(js);
1914 return outputString;
1916 if (
getDataType()->getModuleKey()==
"VuoSyphonServerDescription")
1921 const char *name = NULL;
1922 if (json_object_object_get_ex(js,
"serverName", &o))
1924 const char *n = json_object_get_string(o);
1928 if (!name && json_object_object_get_ex(js,
"applicationName", &o))
1930 const char *n = json_object_get_string(o);
1935 string outputString =
"First";
1936 if (name && strlen(name))
1937 outputString = name;
1939 json_object_put(js);
1941 return outputString;
1943 if (
getDataType()->getModuleKey()==
"VuoVideoInputDevice")
1948 const char *name = NULL;
1949 if (json_object_object_get_ex(js,
"name", &o))
1950 name = json_object_get_string(o);
1951 else if (json_object_object_get_ex(js,
"id", &o))
1952 name = json_object_get_string(o);
1954 string outputString =
"Default";
1955 if (name && strlen(name))
1956 outputString = name;
1958 json_object_put(js);
1960 return outputString;
1964 if (
getDataType()->getModuleKey()==
"VuoHidDevice")
1969 QString outputString;
1970 if (json_object_object_get_ex(js,
"name", &o))
1972 outputString = json_object_get_string(o);
1975 outputString = outputString.section(
" (", 0, 0);
1977 json_object_put(js);
1979 return outputString.toStdString();
1981 if (
getDataType()->getModuleKey()==
"VuoOscInputDevice"
1982 ||
getDataType()->getModuleKey()==
"VuoOscOutputDevice")
1987 const char *name = NULL;
1988 if (json_object_object_get_ex(js,
"name", &o))
1989 name = json_object_get_string(o);
1991 string outputString =
"Auto";
1992 if (name && strlen(name))
1993 outputString = name;
1995 json_object_put(js);
1997 return outputString;
1999 if (
getDataType()->getModuleKey()==
"VuoArtNetInputDevice"
2000 ||
getDataType()->getModuleKey()==
"VuoArtNetOutputDevice")
2005 const char *name = NULL;
2006 if (json_object_object_get_ex(js,
"name", &o))
2007 name = json_object_get_string(o);
2010 if (
getDataType()->getModuleKey()==
"VuoArtNetInputDevice")
2017 if (json_object_object_get_ex(js,
"net", &o))
2018 net = json_object_get_int64(o);
2019 if (json_object_object_get_ex(js,
"subNet", &o))
2020 subNet = json_object_get_int64(o);
2021 if (json_object_object_get_ex(js,
"universe", &o))
2022 universe = json_object_get_int64(o);
2024 string outputString =
format(
"%s (%lld:%lld:%lld)", name, net, subNet, universe);
2026 json_object_put(js);
2028 return outputString;
2030 if (
getDataType()->getModuleKey()==
"VuoTempoRange")
2033 const char *tempoRange = json_object_get_string(js);
2036 if (strcmp(tempoRange,
"andante") == 0)
2037 return "70–110 BPM";
2038 else if (strcmp(tempoRange,
"moderato") == 0)
2039 return "100–140 BPM";
2040 else if (strcmp(tempoRange,
"allegro") == 0)
2041 return "120–180 BPM";
2042 else if (strcmp(tempoRange,
"presto") == 0)
2043 return "170–250 BPM";
2044 else if (strcmp(tempoRange,
"prestissimo") == 0)
2045 return "220–320 BPM";
2047 if (
getDataType()->getModuleKey()==
"VuoEdgeBlend")
2051 double cutoff = 0, gamma = 0, crop = 0;
2054 if (json_object_object_get_ex(js,
"cutoff", &o))
2055 cutoff = json_object_get_double(o);
2057 if (json_object_object_get_ex(js,
"gamma", &o))
2058 gamma = json_object_get_double(o);
2060 if (json_object_object_get_ex(js,
"crop", &o))
2061 crop = json_object_get_double(o);
2063 json_object_put(js);
2065 double cropPercent = -crop * 100;
2066 double cutoffPercent = cutoff * 100;
2070 return format(
"%.0f%%", cropPercent);
2072 return format(
"%.0f%% %.0f%%", cropPercent, cutoffPercent);
2074 return format(
"%.0f%% %.0f%% @ %.2gγ", cropPercent, cutoffPercent, gamma);
2084 if (json_object_object_get_ex(js,
"minimum", &o))
2085 minimum = json_object_get_double(o);
2087 if (json_object_object_get_ex(js,
"maximum", &o))
2088 maximum = json_object_get_double(o);
2090 json_object_put(js);
2093 return format(
"%.4g to %.4g", minimum, maximum);
2095 return format(
"%.4g to ∞", minimum);
2097 return format(
"-∞ to %.4g", maximum);
2099 return format(
"-∞ to ∞");
2101 if (
getDataType()->getModuleKey()==
"VuoIntegerRange")
2109 if (json_object_object_get_ex(js,
"minimum", &o))
2110 minimum = json_object_get_int64(o);
2112 if (json_object_object_get_ex(js,
"maximum", &o))
2113 maximum = json_object_get_int64(o);
2115 json_object_put(js);
2118 return format(
"%lld to %lld", minimum, maximum);
2120 return format(
"%lld to ∞", minimum);
2122 return format(
"-∞ to %lld", maximum);
2124 return format(
"-∞ to ∞");
2131 if (
getDataType()->getModuleKey() ==
"VuoTextComparison")
2136 if (
getDataType()->getModuleKey() ==
"VuoBlackmagicInputDevice"
2137 ||
getDataType()->getModuleKey() ==
"VuoBlackmagicOutputDevice")
2141 if (json_object_object_get_ex(js,
"name", &o))
2142 return json_object_get_string(o);
2146 if (
getDataType()->getModuleKey() ==
"VuoSpeechVoice")
2151 if (
getDataType()->getModuleKey() ==
"VuoRectangle")
2156 if (
getDataType()->getModuleKey() ==
"VuoNdiSource")
2160 if (json_object_object_get_ex(js,
"name", &o))
2161 return json_object_get_string(o);
2162 else if (json_object_object_get_ex(js,
"ipAddress", &o)
2163 && json_object_object_get_ex(js,
"port", &o2))
2164 return format(
"%s:%lld", json_object_get_string(o), json_object_get_int(o2));
2165 else if (json_object_object_get_ex(js,
"ipAddress", &o))
2166 return json_object_get_string(o);
2174 if (json_object_get_type(js) == json_type_string)
2176 string textWithoutQuotes = json_object_get_string(js);
2177 json_object_put(js);
2187 if (type ==
"VuoText"
2188 || type ==
"VuoImageFormat"
2189 || type ==
"VuoAudioEncoding"
2190 || type ==
"VuoBlackmagicConnection"
2191 || type ==
"VuoBlackmagicVideoMode"
2192 || type ==
"VuoMovieImageEncoding")
2193 return textWithoutQuotes;
2196 if (type ==
"VuoTableFormat")
2198 std::transform(textWithoutQuotes.begin(), textWithoutQuotes.end(), textWithoutQuotes.begin(), ::toupper);
2199 return textWithoutQuotes;
2204 for (
auto it = textWithoutQuotes.begin(); it != textWithoutQuotes.end();)
2207 textWithoutQuotes.erase(it);
2215 json_object_put(js);
2228 QGraphicsItem::CacheMode normalCacheMode = cacheMode();
2229 setCacheMode(QGraphicsItem::NoCache);
2239 setCacheMode(normalCacheMode);
2246 for (set<VuoCable *>::iterator i = cables.begin(); i != cables.end(); ++i)
2248 (*i)->getRenderer()->setPortConstantsChanged();
2249 (*i)->getRenderer()->updateGeometry();
2265 if (name.empty() || isAnimated)
2269 else if (sidebarPaintMode)
2271 else if (
isRefreshPort || isFunctionPort || typecastParentPort)
2286 const QString coordSeparator = QString(QLocale::system().decimalPoint() !=
','? QChar(
',') : QChar(
';')).append(
" ");
2287 QStringList coordStringList;
2289 foreach (
float coord, coordList)
2292 QString pointString = QString(
"(").append(coordStringList.join(coordSeparator).append(
")"));
2293 return pointString.toStdString();
2303 QString valueAsStringInUserLocale = QLocale::system().toString(value,
'g', 11);
2304 if (qAbs(value) >= 1000.0)
2305 valueAsStringInUserLocale.remove(QLocale::system().groupSeparator());
2307 return valueAsStringInUserLocale.toStdString();
2317 QString valueAsStringInUserLocale = QLocale::system().toString(value,
'g', 7);
2318 if (qAbs(value) >= 1000.0)
2319 valueAsStringInUserLocale.remove(QLocale::system().groupSeparator());
2321 return valueAsStringInUserLocale.toStdString();
2336 bool isMathExpressionInputToCalculateNode = (this->
getDataType() &&
2344 return (!isGeneric && !hasDictionaryType && !isMathExpressionInputToCalculateNode && !
dynamic_cast<const VuoRendererPublishedPort *
>(
this));
2353 vector <VuoRendererPublishedPort *> publishedPorts;
2362 return publishedPorts;
2371 vector <VuoRendererPublishedPort *> publishedPorts;
2380 return publishedPorts;
2397 this->timeLastEventFired = QDateTime::currentMSecsSinceEpoch();
2414 return this->animations;
2423 this->isAnimated = animated;
2432 this->setCacheMode(mode);
2446 setEnabled(!isAnimated &&
2447 ((
getBase()->hasCompiler() &&
getBase()->getClass()->hasCompiler()) ||
2464 return QString(
"[A-Za-z][A-Za-z0-9]{0,30}")
2466 .append(
"[0-9]{1,31}");
2480 portID.remove(QRegExp(
"[^A-Za-z0-9]"));
2483 if (!portID.contains(QRegExp(
"^[0-9]+$")))
2485 while (!portID.isEmpty() && !portID.contains(QRegExp(
"^[A-Za-z]")))
2486 portID = portID.right(portID.size()-1);
2490 portID = portID.left(31);
2495 VuoRendererPort::~VuoRendererPort()
2497 foreach (QGraphicsItemAnimation *animation, animations)