-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbezierelement.cpp
51 lines (39 loc) · 1.1 KB
/
bezierelement.cpp
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
50
51
#include "bezierelement.h"
#include <QPainter>
#include <QPen>
#include "bezierpicker.h"
#include "basespace.h"
BezierElement::BezierElement(BaseElement *parent, BaseSpace *space, QRectF initRect):
LineElement(parent,space,initRect)
{
setElementName(m_space->nameElementAuto(this->type()));
// delete m_picker;
m_picker = createPicker();
}
void BezierElement::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QPainterPath path;
painter->setPen(pen());
// painter->setBrush(brush());
path.moveTo(m_points.at(0));
int i=1;
while ( i + 2 < m_points.size()) {
path.cubicTo(m_points.at(i), m_points.at(i+1), m_points.at(i+2));
i += 3;
}
while (i < m_points.size()) {
path.lineTo(m_points.at(i));
++i;
}
// while (i < m_points.size()) {
// path.lineTo(m_points.at(i));
// ++i;
// }
painter->drawPath(path);
}
BasePicker *BezierElement::createPicker()
{
return new BezierPicker(this);
}