Vuo  2.3.2
VuoRendererItem.cc
Go to the documentation of this file.
1 
10 #include "VuoRendererItem.hh"
12 
13 bool VuoRendererItem::drawBoundingRects = false;
14 bool VuoRendererItem::snapToGrid = false;
15 
19 void VuoRendererItem::setDrawBoundingRects(bool drawBoundingRects)
20 {
21  VuoRendererItem::drawBoundingRects = drawBoundingRects;
22 }
23 
28 {
29  return VuoRendererItem::drawBoundingRects;
30 }
31 
36 {
37  VuoRendererItem::snapToGrid = snap;
38 }
39 
45 {
46  return VuoRendererItem::snapToGrid;
47 }
48 
55 {
56  VuoRendererComposition *composition = dynamic_cast<VuoRendererComposition *>(scene());
57  return (composition && composition->getRenderNodeActivity());
58 }
59 
65 {
66  VuoRendererComposition *composition = dynamic_cast<VuoRendererComposition *>(scene());
67  return (composition && composition->getRenderHiddenCables());
68 }
69 
73 QGraphicsItem::CacheMode VuoRendererItem::getCurrentDefaultCacheMode() const
74 {
75  VuoRendererComposition *composition = dynamic_cast<VuoRendererComposition *>(scene());
76  if (composition)
77  return composition->getCurrentDefaultCacheMode();
78  else
79  return QGraphicsItem::NoCache;
80 }
81 
82 VuoRendererItem::VuoRendererItem()
83 {
84 }
85 
89 void VuoRendererItem::setSelectable(bool selectable)
90 {
91  if (selectable)
92  setFlags(flags() | QGraphicsItem::ItemIsSelectable);
93  else
94  setFlags(flags() &~ QGraphicsItem::ItemIsSelectable);
95 }
96 
100 void VuoRendererItem::drawRect(QPainter *painter, QRectF rect)
101 {
102  if (!drawBoundingRects)
103  return;
104 
105  painter->setPen(QPen(QColor(255,0,0),0));
106  painter->setBrush(Qt::NoBrush);
107  painter->drawRect(rect);
108 }
109 
113 void VuoRendererItem::drawBoundingRect(QPainter *painter)
114 {
115  if (!drawBoundingRects)
116  return;
117 
118  drawRect(painter, boundingRect());
119 }
120 
124 void VuoRendererItem::addRoundedCorner(QPainterPath &path, bool drawLine, QPointF sharpCornerPoint, qreal radius, bool isTop, bool isLeft)
125 {
126  QPointF p(
127  sharpCornerPoint.x() + (isTop ? (isLeft ? 0 : -radius) : (isLeft ? radius : 0)),
128  sharpCornerPoint.y() + (isTop ? (isLeft ? radius : 0) : (isLeft ? 0 : -radius))
129  );
130  if (drawLine)
131  path.lineTo(p);
132  else
133  path.moveTo(p);
134 
135  path.cubicTo(
136  sharpCornerPoint.x() + (isTop ? (isLeft ? 0 : -radius/2.) : (isLeft ? radius/2. : 0)),
137  sharpCornerPoint.y() + (isTop ? (isLeft ? radius/2. : 0) : (isLeft ? 0 : -radius/2.)),
138 
139  sharpCornerPoint.x() + (isTop ? (isLeft ? radius/2. : 0) : (isLeft ? 0 : -radius/2.)),
140  sharpCornerPoint.y() + (isTop ? (isLeft ? 0 : radius/2.) : (isLeft ? -radius/2. : 0)),
141 
142  sharpCornerPoint.x() + (isTop ? (isLeft ? radius : 0) : (isLeft ? 0 : -radius)),
143  sharpCornerPoint.y() + (isTop ? (isLeft ? 0 : radius) : (isLeft ? -radius : 0))
144  );
145 }