| 60 | |
| 61 | |
| 62 | void |
| 63 | NodePainter:: |
| 64 | drawNodeRect(QPainter* painter, |
| 65 | NodeGeometry const& geom, |
| 66 | NodeDataModel const* model, |
| 67 | NodeGraphicsObject const & graphicsObject) |
| 68 | { |
| 69 | NodeStyle const& nodeStyle = model->nodeStyle(); |
| 70 | |
| 71 | auto color = graphicsObject.isSelected() |
| 72 | ? nodeStyle.SelectedBoundaryColor |
| 73 | : nodeStyle.NormalBoundaryColor; |
| 74 | |
| 75 | if (geom.hovered()) |
| 76 | { |
| 77 | QPen p(color, nodeStyle.HoveredPenWidth); |
| 78 | painter->setPen(p); |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | QPen p(color, nodeStyle.PenWidth); |
| 83 | painter->setPen(p); |
| 84 | } |
| 85 | |
| 86 | QLinearGradient gradient(QPointF(0.0, 0.0), |
| 87 | QPointF(2.0, geom.height())); |
| 88 | |
| 89 | gradient.setColorAt(0.0, nodeStyle.GradientColor0); |
| 90 | gradient.setColorAt(0.03, nodeStyle.GradientColor1); |
| 91 | gradient.setColorAt(0.97, nodeStyle.GradientColor2); |
| 92 | gradient.setColorAt(1.0, nodeStyle.GradientColor3); |
| 93 | |
| 94 | painter->setBrush(gradient); |
| 95 | |
| 96 | float diam = nodeStyle.ConnectionPointDiameter; |
| 97 | |
| 98 | QRectF boundary( -diam, -diam, 2.0 * diam + geom.width(), 2.0 * diam + geom.height()); |
| 99 | |
| 100 | double const radius = 3.0; |
| 101 | |
| 102 | painter->drawRoundedRect(boundary, radius, radius); |
| 103 | } |
| 104 | |
| 105 | |
| 106 | void |