Vuo  2.4.0
VuoRendererCable.hh
Go to the documentation of this file.
1
10#pragma once
11
12#include "VuoBaseDetail.hh"
13#include "VuoRendererItem.hh"
14#include "VuoRendererColors.hh"
15
16class VuoCable;
17
21class VuoRendererCable : public VuoRendererItem, public VuoBaseDetail<VuoCable>
22{
23public:
24 VuoRendererCable(VuoCable * baseCable);
25
26 static const qreal cableWidth;
27 static const qreal cableYankRadius;
28
29 QRectF boundingRect(void) const;
30 QPainterPath shape(void) const;
31 QPainterPath getCablePath(void) const;
32 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
33 QPointF getFloatingEndpointLoc();
34 void setFloatingEndpointLoc(QPointF loc);
35 void setFloatingEndpointAboveEventPort(bool aboveEventPort);
37 void setFrom(VuoNode *fromNode, VuoPort *fromPort);
38 void setTo(VuoNode *toNode, VuoPort *toPort);
39 bool effectivelyCarriesData(void) const;
40 bool getEffectivelyWireless() const;
41 void setWireless(bool wireless);
42 void removeFromScene();
46 bool yankZoneIncludes(QPointF scenePos);
50 void setPreviouslyAlwaysEventOnly(bool eventOnly);
51 void setHovered(bool hovered);
53 void updateGeometry(void);
56 bool paintingDisabled(void) const;
57 QPainterPath getCablePathForEndpoints(QPointF from, QPointF to) const;
58 static void getCableSpecs(bool cableCarriesData, qreal &cableWidth);
59 void setCacheModeForCableAndConnectedPorts(QGraphicsItem::CacheMode mode);
61
62private:
63 // Drawing configuration
64 QPainterPath getOutline(QPointF startPoint,
65 QPointF endPoint,
66 bool cableCarriesData);
67
68 void getYankZonePath(QPointF startPoint,
69 QPointF endPoint,
70 bool cableCarriesData,
71 bool toPortSupportsYanking,
72 QPainterPath &yankZone);
73 void arclineTo(QPainterPath &cablePath, QPointF to, float radius, float fromCableStandoff) const;
74
75 QPointF floatingEndpointLoc;
76 VuoPort *floatingEndpointPreviousToPort;
77 bool previouslyAlwaysEventOnly;
78 bool floatingEndpointAboveEventPort;
79 bool isHovered;
80 VuoRendererColors::HighlightType _eligibilityHighlight;
81 qint64 timeLastEventPropagated;
82
83 // Cached outline, and the cached attribute values used to calculate them.
84 QPainterPath cachedOutline;
85 QPair<QPointF, QPointF> cachedEndpointsForOutlines;
86 bool cachedCarriesDataValueForOutlines;
87 bool portConstantsChangedSinceLastCachedOutline;
88
89 // Cached yank zones, and the cached attribute values used to calculate them.
90 QPainterPath cachedYankZonePath;
91 QPair<QPointF, QPointF> cachedEndpointsForYankZone;
92 bool cachedCarriesDataValueForYankZone;
93 bool cachedToPortSupportsYankingValueForYankZone;
94
95 // Internal methods
96 QPointF getStartPoint(void) const;
97 QPointF getEndPoint(void) const;
98 bool isPublishedInputCableWithoutVisiblePublishedPort() const;
99 bool isPublishedOutputCableWithoutVisiblePublishedPort() const;
100 bool isConnectedToSelectedNode(void);
101};
102