-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube.cpp
More file actions
50 lines (41 loc) · 1.66 KB
/
cube.cpp
File metadata and controls
50 lines (41 loc) · 1.66 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
49
50
#include "cube.h"
Cube::Cube(int _lineWidth, int _coefficient)
{
this->_lineWidth=_lineWidth;
this->_coefficient=_coefficient;
}
QString Cube::nameOfClass(){
return "Cube";
}
void Cube::showShape(QPainter &painter, bool isDraw){
int plus =qMax(_end.x(),_end.y())-qMax(_begin.x(),_begin.y())+_coefficient;
if(isDraw){
_position=0;
_pointBegin[_position] = _begin;
_pointEnd[_position] = QPoint(_begin.x()+_lineWidth,_begin.y()+_lineWidth);//checked
_position++;
_pointBegin[_position] = QPoint(_begin.x()+plus,_begin.y());
_pointEnd[_position] = QPoint(_begin.x()+plus+_lineWidth,_begin.y()+_lineWidth);
_position++;
_pointBegin[_position] = QPoint(_begin.x(),_begin.y()+plus);
_pointEnd[_position] = QPoint(_begin.x()+_lineWidth,_begin.y()+_lineWidth+plus);
_position++;
_pointBegin[_position] = QPoint(_begin.x()+plus,_begin.y()+plus);
_pointEnd[_position] = QPoint(_begin.x()+_lineWidth+plus,_begin.y()+_lineWidth+plus);
_position++;
_pointBegin[_position] = _begin;
_pointEnd[_position] = QPoint(_begin.x()+plus,_begin.y()+plus);
_position++;
_pointBegin[_position] = QPoint(_begin.x()+_lineWidth,_begin.y()+_lineWidth);
_pointEnd[_position] = QPoint(_begin.x()+plus+_lineWidth,_begin.y()+plus+_lineWidth);
}
for(int i=0;i<_totalShapes;i++){
if(i<_totalShapes-2){
Line::setCord(_pointBegin[i],_pointEnd[i]);
Line::showShape(painter,true);
}else{
Rect::setCord(_pointBegin[i],_pointEnd[i]);
Rect::showShape(painter,true);
}
}
}