-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshoulderpaintarea.cpp
More file actions
128 lines (119 loc) · 3.74 KB
/
Copy pathshoulderpaintarea.cpp
File metadata and controls
128 lines (119 loc) · 3.74 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "shoulderpaintarea.h"
ShoulderPaintArea::ShoulderPaintArea(bool l, QWidget *parent) :
QWidget(parent)
{
m_shoulder = new Shoulder(l);
}
ShoulderPaintArea::~ShoulderPaintArea()
{
delete m_shoulder;
}
void ShoulderPaintArea::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event);
QPalette Pal(palette());
Pal.setColor(QPalette::Background, Qt::white);
setAutoFillBackground(true);
setPalette(Pal);
int ** slice = m_shoulder->GetSlice(m_nSlice);
QPainter painter(this);
for (int iz = 0; iz < Z(); iz++)
{
for (int ix = 0; ix < X(); ix++)
{
if (slice[iz][ix] != 0)
{
painter.drawRect(SCALE*SIZE_X_VOXEL*ix,
SCALE*SIZE_Z_VOXEL*(Z() - (iz+1)),
SCALE*SIZE_X_VOXEL, SCALE*SIZE_Z_VOXEL);
painter.fillRect(SCALE*SIZE_X_VOXEL*ix,
SCALE*SIZE_Z_VOXEL*(Z() - (iz+1)),
SCALE*SIZE_X_VOXEL, SCALE*SIZE_Z_VOXEL,
QColor(200, 200, 100, 127));
}
}
delete [] slice[iz];
}
delete [] slice;
if (Left())
{
painter.fillRect(SCALE*SIZE_X_VOXEL*(m_focusX-1),
SCALE*SIZE_Z_VOXEL*(Z() - m_focusZ),
SCALE*SIZE_X_VOXEL, SCALE*SIZE_Z_VOXEL,
QColor(200, 100, 100, 127));
}
else
{
painter.fillRect(SCALE*SIZE_X_VOXEL*(X() - m_focusX),
SCALE*SIZE_Z_VOXEL*(Z() - m_focusZ),
SCALE*SIZE_X_VOXEL, SCALE*SIZE_Z_VOXEL,
QColor(200, 100, 100, 127));
}
BezierCoords2D * coords = BezierCoords2D::FindAlpha(X()*SIZE_X_VOXEL,
Z()*SIZE_Z_VOXEL,
m_focusX*SIZE_X_VOXEL,
m_focusZ*SIZE_Z_VOXEL);
double alpha = coords->alpha();
delete coords;
auto line = m_shoulder->GetBezierLine(alpha);
auto from = line.front();
for (auto &point : line)
{
if (m_shoulder->Left()) {
painter.drawLine(
static_cast<int>(SCALE*from->x()),
static_cast<int>(SCALE*Z()*SIZE_Z_VOXEL - SCALE*from->z()),
static_cast<int>(SCALE*point->x()),
static_cast<int>(SCALE*Z()*SIZE_Z_VOXEL - SCALE*point->z())
);
} else {
painter.drawLine(
static_cast<int>(SCALE*X()*SIZE_X_VOXEL - SCALE*from->x()),
static_cast<int>(SCALE*Z()*SIZE_Z_VOXEL - SCALE*from->z()),
static_cast<int>(SCALE*X()*SIZE_X_VOXEL - SCALE*point->x()),
static_cast<int>(SCALE*Z()*SIZE_Z_VOXEL - SCALE*point->z())
);
}
from = point;
}
for (auto &point : line)
{
delete point;
}
}
void ShoulderPaintArea::DecSlice() {
if (m_nSlice > 0) {
m_nSlice--;
this->update();
}
}
void ShoulderPaintArea::IncSlice() {
if (m_nSlice < m_shoulder->Y() - 1) {
m_nSlice++;
this->update();
}
}
void ShoulderPaintArea::DecFocusX() {
if (m_focusX > 0) {
m_focusX--;
this->update();
}
}
void ShoulderPaintArea::IncFocusX() {
if (m_focusX < m_shoulder->X()) {
m_focusX++;
this->update();
}
}
void ShoulderPaintArea::DecFocusZ() {
if (m_focusZ > 0) {
m_focusZ--;
this->update();
}
}
void ShoulderPaintArea::IncFocusZ() {
if (m_focusZ < m_shoulder->Z()) {
m_focusZ++;
this->update();
}
}