-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgmovearcnode.cpp
More file actions
49 lines (39 loc) · 1.32 KB
/
gmovearcnode.cpp
File metadata and controls
49 lines (39 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "gmovearcnode.h"
#include <QPainter>
#include <QPointF>
#include <QDebug>
#include "gpad.h"
#include "gmove.h"
#include "gmovesmodel.h"
static const qreal D = 0.2;//0.06;
static const qreal R = D / 2;
static const qreal P = D / 3;
static const qreal DP = D + 2 * P;
static const qreal RP = R + P;
GMoveArcNode::GMoveArcNode(const QPersistentModelIndex &index, QGraphicsItem *parent)
: QGraphicsItem(parent),
mIndex(index)
{
setFlag(ItemIsSelectable);// | QGraphicsItem::ItemIsMovable);
setPos(mIndex.data(GPad::MoveArcCenterRole).toPointF());
setZValue(mIndex.data(GPad::MoveZRole).toDouble());
}
QRectF GMoveArcNode::boundingRect() const
{
return QRectF(-RP, -RP, DP, DP);
}
void GMoveArcNode::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{
bool selected = mIndex.data(GPad::SelectionRole).toBool();
QColor c(selected ? Qt::darkRed : Qt::darkBlue);
c.setAlpha(0xaa);
painter->setPen(QPen(Qt::NoPen));
painter->setBrush(QBrush(c));
painter->setRenderHint(QPainter::Antialiasing);
painter->drawEllipse(boundingRect());
}
QVariant GMoveArcNode::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
// qDebug() << __PRETTY_FUNCTION__ << change;
return QGraphicsItem::itemChange(change, value);
}