-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolsethandling.cpp
More file actions
290 lines (222 loc) · 8.85 KB
/
Copy pathtoolsethandling.cpp
File metadata and controls
290 lines (222 loc) · 8.85 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#include "toolsethandling.h"
const QString ToolSetHandling::RECTANGLE("RECTANGLE");
const QString ToolSetHandling::ELLIPSE("ELLIPSE");
const QString ToolSetHandling::SQUIRCLE("SQUIRCLE");
const QString ToolSetHandling::FREE_HAND_LINE("FREE_HAND_LINE");
const QString ToolSetHandling::CONVEX_POLYGON("CONVEX_POLYGON");
const QString ToolSetHandling::STRAIGHT_LINE("STRAIGHT_LINE");
const QString ToolSetHandling::LINEAR_GRADIENT_SHAPE("LINEAR_GRADIENT_SHAPE");
const QString ToolSetHandling::CONICAL_GRADIENT_SHAPE("CONICAL_GRADIENT_SHAPE");
const QString ToolSetHandling::RADIAL_GRADIENT_SHAPE("RADIAL_GRADIENT_SHAPE");
const QString ToolSetHandling::TEXT_BOX("TEXT_BOX");
const QString ToolSetHandling::PAINT_BUCKET("PAINT_BUCKET");
ToolSetHandling::ToolSetHandling() {
}
QStack<QString> ToolSetHandling::verifyLastAction() {
return m_orderOfActions;
}
void ToolSetHandling::addLastActionToStack(QString objType) {
m_orderOfActions.append(objType);
}
QStack<QString> ToolSetHandling::getOrderOfObjectsDrawn() {
return m_orderOfActions;
}
int ToolSetHandling::getPositionOfLastActionAdded() {
return (m_orderOfActions.size()-1);
}
void ToolSetHandling::removeLastActionFromStack() {
m_orderOfActions.pop();
}
void ToolSetHandling::setActionPosAndShapePos(int actionPos,
int shapePos) {
m_posMap.insert(actionPos, shapePos);
}
QMap<int, int> ToolSetHandling::getPosMap() {
return m_posMap;
}
void ToolSetHandling::removeLastPosStored(int keyValueToRemove) {
m_posMap.remove(keyValueToRemove);
}
void ToolSetHandling::addRectangleToQueue(Rectangle rectangle) {
addLastActionToStack(RECTANGLE);
rectangle.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_rectangleQueue.append(rectangle);
}
void ToolSetHandling::removeLastRectangle() {
m_rectangleQueue.pop_back();
}
QQueue<Rectangle> ToolSetHandling::getQueueOfRectangles() {
return m_rectangleQueue;
}
void ToolSetHandling::removeFrontRectFromQueue() {
m_rectangleQueue.removeFirst();
}
void ToolSetHandling::addEllipseToQueue(Ellipse ellipse) {
addLastActionToStack(ELLIPSE);
ellipse.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_ellipseQueue.append(ellipse);
}
void ToolSetHandling::removeLastEllipse() {
m_ellipseQueue.pop_back();
}
QQueue<Ellipse> ToolSetHandling::getQueueOfEllipses() {
return m_ellipseQueue;
}
void ToolSetHandling::removeFrontEllipseFromQueue() {
m_ellipseQueue.removeFirst();
}
void ToolSetHandling::addSquircleToQueue(Squircle squircle) {
addLastActionToStack(SQUIRCLE);
squircle.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_squircleQueue.append(squircle);
}
void ToolSetHandling::removeLastSquircle() {
m_squircleQueue.pop_back();
}
QQueue<Squircle> ToolSetHandling::getQueueOfSquircles() {
return m_squircleQueue;
}
void ToolSetHandling::removeFrontSquircleFromQueue() {
m_squircleQueue.removeFirst();
}
void ToolSetHandling::addFreeHandLineToQueue(FreeHandLine freeHandLine) {
addLastActionToStack(FREE_HAND_LINE);
freeHandLine.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_freeHandLineQueue.append(freeHandLine);
}
void ToolSetHandling::removeLastFreeHandLine() {
m_freeHandLineQueue.pop_back();
}
QQueue<FreeHandLine> ToolSetHandling::getQueueOfFreeHandLines() {
return m_freeHandLineQueue;
}
void ToolSetHandling::removeFrontFreeHandLineFromQueue() {
m_freeHandLineQueue.removeFirst();
}
FreeHandLine& ToolSetHandling::obtainCurFreeHandLineInstance() {
return m_freeHandLineQueue.last();
}
void ToolSetHandling::addConvexPolygonToQueue(ConvexPolygon convexPolygon) {
addLastActionToStack(CONVEX_POLYGON);
convexPolygon.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_convexPolygonQueue.append(convexPolygon);
}
void ToolSetHandling::removeLastConvexPolygon() {
m_convexPolygonQueue.pop_back();
}
QQueue<ConvexPolygon> ToolSetHandling::getQueueOfConvexPolygons() {
return m_convexPolygonQueue;
}
void ToolSetHandling::addStraightLineToQueue(StraightLine straightLine) {
addLastActionToStack(STRAIGHT_LINE);
straightLine.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_straightLineQueue.append(straightLine);
}
void ToolSetHandling::removeLastStraightLine() {
m_straightLineQueue.pop_back();
}
QQueue<StraightLine> ToolSetHandling::getQueueOfStraightLines() {
return m_straightLineQueue;
}
void ToolSetHandling::addLinearGradientShapeToQueue(LinearGradientShape linearGradientShape) {
addLastActionToStack(LINEAR_GRADIENT_SHAPE);
linearGradientShape.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_linearGradientShapeQueue.append(linearGradientShape);
}
void ToolSetHandling::removeLastLinearGradientShape() {
m_linearGradientShapeQueue.pop_back();
}
QQueue<LinearGradientShape> ToolSetHandling::getQueueOfLinearGradientShapes() {
return m_linearGradientShapeQueue;
}
void ToolSetHandling::updateLinearGradient(QLinearGradient linearGradient) {
int indexLastElement = (m_linearGradientShapeQueue.size() - 1);
LinearGradientShape linearGradientShape = m_linearGradientShapeQueue.at(indexLastElement);
m_linearGradientShapeQueue.pop_back();
linearGradientShape.setLinearGradient(linearGradient);
m_linearGradientShapeQueue.append(linearGradientShape);
}
void ToolSetHandling::addConicalGradientShapeToQueue(ConicalGradientShape conicalGradientShape) {
addLastActionToStack(CONICAL_GRADIENT_SHAPE);
conicalGradientShape.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_conicalGradientShapeQueue.append(conicalGradientShape);
}
void ToolSetHandling::removeLastConicalGradientShape() {
m_conicalGradientShapeQueue.pop_back();
}
QQueue<ConicalGradientShape> ToolSetHandling::getQueueOfConicalGradientShapes() {
return m_conicalGradientShapeQueue;
}
void ToolSetHandling::updateConicalGradient(QConicalGradient conicalGradient) {
int indexLastElement = (m_conicalGradientShapeQueue.size() - 1);
ConicalGradientShape conicalGradientShape = m_conicalGradientShapeQueue.at(indexLastElement);
m_conicalGradientShapeQueue.pop_back();
conicalGradientShape.setConicalGradient(conicalGradient);
m_conicalGradientShapeQueue.append(conicalGradientShape);
}
void ToolSetHandling::addRadialGradientShapeToQueue(RadialGradientShape radialGradientShape) {
addLastActionToStack(RADIAL_GRADIENT_SHAPE);
radialGradientShape.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_radialGradientShapeQueue.append(radialGradientShape);
}
void ToolSetHandling::removeLastRadialGradientShape() {
m_radialGradientShapeQueue.pop_back();
}
QQueue<RadialGradientShape> ToolSetHandling::getQueueOfRadialGradientShapes() {
return m_radialGradientShapeQueue;
}
void ToolSetHandling::updateRadialGradient(QRadialGradient radialGradient) {
int indexLastElement = (m_radialGradientShapeQueue.size() - 1);
RadialGradientShape radialGradientShape = m_radialGradientShapeQueue.at(indexLastElement);
m_radialGradientShapeQueue.pop_back();
radialGradientShape.setRadialGradient(radialGradient);
m_radialGradientShapeQueue.append(radialGradientShape);
}
void ToolSetHandling::addTextBoxToQueue(TextBox textBox) {
addLastActionToStack(TEXT_BOX);
textBox.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_textBoxQueue.append(textBox);
}
void ToolSetHandling::removeLastTextBox() {
m_textBoxQueue.pop_back();
}
QQueue<TextBox> ToolSetHandling::getQueueOfTextBoxes() {
return m_textBoxQueue;
}
void ToolSetHandling::updateTextBox(QString textWritten) {
int indexLastElement = (m_textBoxQueue.size() - 1);
TextBox textBox = m_textBoxQueue.at(indexLastElement);
m_textBoxQueue.pop_back();
textBox.setWrittenText(textWritten);
m_textBoxQueue.append(textBox);
}
void ToolSetHandling::addCoords(int x1, int x2, int y1, int y2) {
int indexLastElement = (m_textBoxQueue.size() - 1);
TextBox textBox = m_textBoxQueue.at(indexLastElement);
m_textBoxQueue.pop_back();
textBox.setCoords(x1, x2, y1, y2);
m_textBoxQueue.append(textBox);
}
void ToolSetHandling::addFont(QFont font) {
int indexLastElement = (m_textBoxQueue.size() - 1);
TextBox textBox = m_textBoxQueue.at(indexLastElement);
m_textBoxQueue.pop_back();
textBox.setFont(font);
m_textBoxQueue.append(textBox);
}
QFont ToolSetHandling::getFont() {
int indexLastElement = (m_textBoxQueue.size() - 1);
TextBox textBox = m_textBoxQueue.at(indexLastElement);
return textBox.getFont();
}
void ToolSetHandling::addPaintBucketToQueue(PaintBucket paintBucket) {
addLastActionToStack(PAINT_BUCKET);
paintBucket.setPosInOrderOfActions(getPositionOfLastActionAdded());
m_paintBucketQueue.append(paintBucket);
}
void ToolSetHandling::removeLastPaintBucket() {
m_paintBucketQueue.pop_back();
}
QQueue<PaintBucket> ToolSetHandling::getQueueOfPaintBuckets() {
return m_paintBucketQueue;
}