-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelement.cpp
More file actions
49 lines (40 loc) · 965 Bytes
/
element.cpp
File metadata and controls
49 lines (40 loc) · 965 Bytes
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
49
#include <QPen>
#include <QBrush>
#include <QRectF>
#include "graph.h"
#include "element.h"
const QPen Element::DEFAULT_PEN = QPen(QBrush(QColor("mediumaquamarine")), 1, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin);
const QPen Element::HIGHLIGHT_PEN = QPen(QBrush(QColor("red")), 3, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin);
Element::Element(Graph *graph, QGraphicsItem *parent) :
QGraphicsObject(parent),
_graph(graph)
{
}
Element::~Element()
{
delete _inner;
}
QRectF Element::boundingRect() const
{
return _inner->boundingRect();
}
void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
_inner->paint(painter, option, widget);
}
void Element::highlight()
{
_inner->setPen(HIGHLIGHT_PEN);
}
void Element::unhighlight()
{
_inner->setPen(DEFAULT_PEN);
}
bool Element::isHighlighted()
{
return _inner->pen() == HIGHLIGHT_PEN;
}
bool Element::isUnhighlighted()
{
return _inner->pen() == DEFAULT_PEN;
}