diff --git a/lib/qtgraph/node.cpp b/lib/qtgraph/node.cpp index 13fcc39..51d074e 100644 --- a/lib/qtgraph/node.cpp +++ b/lib/qtgraph/node.cpp @@ -48,9 +48,9 @@ Edge* Node::edgeTo(const Node* n) const QRectF Node::boundingRect() const { - qreal adjust = 2; - return QRectF( -m_radius - adjust, -m_radius - adjust, - m_radius*2 + adjust, m_radius*2 + adjust); + const qreal adjust = 0; + return QRectF( -m_radius - adjust, -m_radius - adjust, + m_radius*2 + adjust, m_radius*2 + adjust); } QPainterPath Node::shape() const @@ -62,23 +62,16 @@ QPainterPath Node::shape() const void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem* option, QWidget *) { - QRadialGradient gradient(-3, -3, m_radius); if (isSelected()) { - gradient.setCenter(3, 3); - gradient.setFocalPoint(3, 3); - gradient.setColorAt(0, Qt::red); - gradient.setColorAt(1, Qt::darkRed); + painter->setBrush(Qt::red); } else if (option->state & QStyle::State_MouseOver) { - gradient.setColorAt(0, Qt::green); - gradient.setColorAt(1, Qt::darkGreen); + painter->setBrush(Qt::green); } else { - gradient.setColorAt(0, Qt::yellow); - gradient.setColorAt(1, Qt::darkYellow); + painter->setBrush(Qt::yellow); } - painter->setBrush(gradient); painter->setPen(QPen(Qt::black, 0)); - painter->drawEllipse(-m_radius, -m_radius, m_radius*2, m_radius*2); + painter->drawEllipse(QRectF( -m_radius, -m_radius, m_radius*2, m_radius*2)); } QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) diff --git a/lib/qtgraph/node.hpp b/lib/qtgraph/node.hpp index e766d98..acf7210 100644 --- a/lib/qtgraph/node.hpp +++ b/lib/qtgraph/node.hpp @@ -11,8 +11,7 @@ class QGraphicsSceneMouseEvent; class Node : public QGraphicsItem { public: - Node(GraphWidget *graphWidget, - qreal radius = 4); + Node(GraphWidget *graphWidget, qreal radius = 0.2); void addEdge(Edge *edge); void removeEdge(Edge* edge);