-
Notifications
You must be signed in to change notification settings - Fork 6
/
line.cpp
46 lines (34 loc) · 1.01 KB
/
line.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
#include "line.h"
#include <QPainter>
Line::Line(QPointF point,QColor color,int LineWeight, QObject *parent) :
Figure(point,parent)
{
/*
* Setting the color and Line weight and then make the name
* Accoding to a counter to the class shapes (lCount)
*/
Q_UNUSED(point)
shapeColor=color;
this->LineWeight=LineWeight;
this->name=QString("Line %1").arg(lCount);
lCount++;
}
Line::~Line()
{
}
void Line::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
// Setting the color, Line weight and the shape type
painter->setPen(QPen(shapeColor, LineWeight));
shapeTypeName = "Line";
// Draw the line with the start, end point and the painter
QLineF line(startPoint().x(),startPoint().y(),endPoint().x(),endPoint().y());
//Fill shape in case fill button
// if(isFilled){
// painter->setBrush(shapeColor);
// }
painter->drawLine(line);
this->perimeter=line.length();
Q_UNUSED(option)
Q_UNUSED(widget)
}