| 126 | } |
| 127 | |
| 128 | void IPProcessEdge::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget *) |
| 129 | { |
| 130 | painter->setBrush(QBrush(_colorArrow.at(_typeIndex))); |
| 131 | painter->setPen(QColor(_colorArrow.at(_typeIndex))); |
| 132 | |
| 133 | // main line |
| 134 | if(_mouseOver) painter->setPen(QColor(192, 57, 43)); |
| 135 | |
| 136 | QLineF line2(_intersectionFrom.toPoint(), _intersectionTo.toPoint()); |
| 137 | painter->drawLine(line2); |
| 138 | |
| 139 | // arrow |
| 140 | QPolygonF arrowPolygon; |
| 141 | double arrowSize = 10; |
| 142 | double angle = ::acos(line2.dx() / line2.length()); |
| 143 | if (line2.dy() >= 0) |
| 144 | angle = (Pi * 2) - angle; |
| 145 | |
| 146 | QPointF arrowP1 = _intersectionTo - QPointF(sin(angle + Pi / 3) * arrowSize, |
| 147 | cos(angle + Pi / 3) * arrowSize); |
| 148 | QPointF arrowP2 = _intersectionTo - QPointF(sin(angle + Pi - Pi / 3) * arrowSize, |
| 149 | cos(angle + Pi - Pi / 3) * arrowSize); |
| 150 | arrowPolygon.clear(); |
| 151 | arrowPolygon << _intersectionTo << arrowP1 << arrowP2; |
| 152 | |
| 153 | // point at process item 1 |
| 154 | painter->drawEllipse(_intersectionFrom, 4, 4); |
| 155 | |
| 156 | // arrow at process item 2 |
| 157 | painter->drawPolygon(arrowPolygon); |
| 158 | |
| 159 | if(_mouseOver) |
| 160 | { |
| 161 | // draw cross |
| 162 | QPointF centerPoint = _intersectionFrom + 0.5*(_intersectionTo-_intersectionFrom); |
| 163 | |
| 164 | QLineF line1(centerPoint+QPointF(-5,-5), centerPoint+QPointF(5,5)); |
| 165 | QLineF line2(centerPoint+QPointF(-5,5), centerPoint+QPointF(5,-5)); |
| 166 | |
| 167 | QPen penRed(Qt::red); |
| 168 | penRed.setWidth(2); |
| 169 | |
| 170 | painter->setPen(penRed); |
| 171 | painter->drawLine(line1); |
| 172 | painter->drawLine(line2); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | |
| 177 | void IPProcessEdge::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |