IntelliPhoto 0.7

tst_unittest.cpp
Go to the documentation of this file.
1 #include <QtTest>
2 #include <QCoreApplication>
3 // add necessary includes here
4 #include "GUI/IntelliPhotoGui.h"
5 #include "Image/IntelliImage.h"
6 #include "Image/IntelliRasterImage.h"
7 #include "Image/IntelliShapedImage.h"
8 #include "IntelliHelper/IntelliColorPicker.h"
9 #include "IntelliHelper/IntelliRenderSettings.h"
10 #include "IntelliHelper/IntelliToolsettings.h"
11 #include "IntelliHelper/IntelliTriangulation.h"
12 #include "Layer/PaintingArea.h"
13 #include "Tool/IntelliTool.h"
14 #include "Tool/IntelliToolCircle.h"
15 #include "Tool/IntelliToolFloodFill.h"
16 #include "Tool/IntelliToolLine.h"
17 #include "Tool/IntelliToolPen.h"
18 #include "Tool/IntelliToolPlain.h"
19 #include "Tool/IntelliToolPolygon.h"
20 #include "Tool/IntelliToolRectangle.h"
21
22 class UnitTest : public QObject
23 {
24 Q_OBJECT
25 private:
26 IntelliPhotoGui* gui;
27 PaintingArea* area;
28
29 public:
30 UnitTest();
31 ~UnitTest();
32
33 private slots:
34 void initTestCase();
35 void cleanupTestCase();
36 //void test_case1();
37
39
40
41 //test painting area
42 void test_addLayer();
43 void test_deleteLayer();
44 void test_setActive();
45 void test_setAlpha();
46 void test_floodFill();
47 void test_moveActive();
48 void test_setPolygon();
49 void test_setLayerUp();
50 void test_setLayerDown();
51
52 void test_createTools();
53
54 //test Raster-Image operations
55 void test_RasterImage_drawPixel();
56 void test_RasterImage_drawLine();
57 void test_RasterImage_drawPoint();
58 void test_RasterImage_getDisplayable();
59 void test_RasterImage_getPixelColor();
60 void test_RasterImage_getImageData();
61 void test_RasterImage_setImageData();
62
63 //test Shaped-Image operations
64 void test_ShapedImage_drawPixel();
65 void test_ShapedImage_drawLine();
66 void test_ShapedImage_drawPoint();
67 void test_ShapedImage_getDisplayable();
68 void test_ShapedImage_getPixelColor();
69 void test_ShapedImage_getImageData();
70 void test_ShapedImage_setImageData();
71
72 //test tools
73 void test_Circle_fullDraw();
74 void test_Circle_interruptedDraw();
75
76 void test_FloodFill_fullDraw();
77 void test_FloodFill_interruptedDraw();
78
79 void test_Line_fullDraw();
80 void test_Line_interruptedDraw();
81
82 void test_Pen_fullDraw();
83 void test_Pen_interruptedDraw();
84
85 void test_Plain_fullDraw();
86 void test_Plain_interruptedDraw();
87
88 void test_Polygon_fullDraw();
89 void test_Polygon_interruptedDraw();
90
91 void test_Rectangle_fullDraw();
92 void test_Rectangle_interruptedDraw();
93
94 //test Triangulation
95 void test_Triangulation_Coverage();
96
97
99
100 //bench painting area
101 void bench_addLayer();
102 void bench_deleteLayer();
103 void bench_setActive();
104 void bench_setAlpha();
105 void bench_floodFill();
106 void bench_moveActive();
107 void bench_setPolygon();
108 void bench_setLayerUp();
109 void bench_setLayerDown();
110
111 void bench_createTools();
112
113 //bench Raster-Image operations
114 void bench_RasterImage_drawPixel();
115 void bench_RasterImage_drawLine();
116 void bench_RasterImage_drawPoint();
117 void bench_RasterImage_getDisplayable();
118 void bench_RasterImage_getPixelColor();
119 void bench_RasterImage_getImageData();
120 void bench_RasterImage_setImageData();
121
122 //bench Shaped-Image operations
123 void bench_ShapedImage_drawPixel();
124 void bench_ShapedImage_drawLine();
125 void bench_ShapedImage_drawPoint();
126 void bench_ShapedImage_getDisplayable();
127 void bench_ShapedImage_getPixelColor();
128 void bench_ShapedImage_getImageData();
129 void bench_ShapedImage_setImageData();
130
131 //bench tools
132 void bench_Circle_fullDraw();
133 void bench_Circle_interruptedDraw();
134
135 void bench_FloodFill_fullDraw();
136 void bench_FloodFill_interruptedDraw();
137
138 void bench_Line_fullDraw();
139 void bench_Line_interruptedDraw();
140
141 void bench_Pen_fullDraw();
142 void bench_Pen_interruptedDraw();
143
144 void bench_Plain_fullDraw();
145 void bench_Plain_interruptedDraw();
146
147 void bench_Polygon_fullDraw();
148 void bench_Polygon_interruptedDraw();
149
150 void bench_Rectangle_fullDraw();
151 void bench_Rectangle_interruptedDraw();
152
153 //bench Triangulation
154 void bench_Triangulation_Coverage();
155 };
156
157 UnitTest::UnitTest()
158 {
159 gui = new IntelliPhotoGui();
160 area = gui->paintingArea;
161 }
162
163 UnitTest::~UnitTest()
164 {
165
166 }
167
168 void UnitTest::initTestCase()
169 {
170
171 }
172
173 void UnitTest::cleanupTestCase()
174 {
175
176 }
177
178 //test painting area
179 void UnitTest::test_addLayer(){
180 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
181
182 QCOMPARE(area->layerBundle.size(), 1);
183 QCOMPARE(area->activeLayer, 0);
184
185 QCOMPARE(area->layerBundle[static_cast<size_t>(area->activeLayer)].width, 200);
186 QCOMPARE(area->layerBundle[static_cast<size_t>(area->activeLayer)].widthOffset, 10);
187
188 QCOMPARE(area->layerBundle[static_cast<size_t>(area->activeLayer)].height, 200);
189 QCOMPARE(area->layerBundle[static_cast<size_t>(area->activeLayer)].heightOffset, 20);
190
191 area->deleteLayer(0);
192 }
193
194 void UnitTest::test_deleteLayer(){
195 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
196 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
197
198 area->deleteLayer(3);
199 QCOMPARE(area->layerBundle.size(), 2);
200 QCOMPARE(area->activeLayer, 1);
201
202 area->deleteLayer(-1);
203 QCOMPARE(area->layerBundle.size(), 2);
204 QCOMPARE(area->activeLayer, 1);
205
206 area->deleteLayer(1);
207 QCOMPARE(area->layerBundle.size(), 1);
208 QCOMPARE(area->activeLayer, 0);
209
210 area->deleteLayer(0);
211 QCOMPARE(area->layerBundle.size(), 0);
212 QCOMPARE(area->activeLayer, -1);
213
214 }
215
216 void UnitTest::test_setActive(){
217 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
218 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
219
220 area->setLayerActive(0);
221 QCOMPARE(area->activeLayer, 0);
222 area->setLayerActive(1);
223 QCOMPARE(area->activeLayer, 1);
224 area->setLayerActive(-1);
225 QCOMPARE(area->activeLayer, 1);
226 area->setLayerActive(3);
227 QCOMPARE(area->activeLayer, 1);
228
229 area->deleteLayer(0);
230 area->deleteLayer(0);
231 }
232
233 void UnitTest::test_setAlpha(){
234 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
235 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
236
237 area->setLayerAlpha(0,0);
238 QCOMPARE(area->layerBundle[0].alpha, 0);
239
240 area->setLayerAlpha(0,255);
241 QCOMPARE(area->layerBundle[0].alpha, 255);
242
243 area->setLayerAlpha(1,123);
244 QCOMPARE(area->layerBundle[1].alpha, 123);
245
246 area->setLayerAlpha(1,-12);
247 QCOMPARE(area->layerBundle[1].alpha, 123);
248
249 area->setLayerAlpha(1,300);
250 QCOMPARE(area->layerBundle[1].alpha, 123);
251
252 area->deleteLayer(1);
253 area->deleteLayer(0);
254 }
255
256 void UnitTest::test_floodFill(){
257 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
258
259 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
260 QPoint point;
261 for(size_t i = 0; i<200; i++) {
262 point.setX(static_cast<int>(i));
263 for(size_t j = 0; i<200; i++) {
264 point.setY(static_cast<int>(j));
265 QVERIFY(area->layerBundle[static_cast<size_t>(area->activeLayer)].image->getPixelColor(point)==QColor(255,255,255,255));
266 }
267 }
268
269 area->layerBundle[0].image->drawPlain(QColor(0, 0, 0, 0));
270 for(size_t i = 0; i<200; i++) {
271 point.setX(static_cast<int>(i));
272 for(size_t j = 0; i<200; i++) {
273 point.setY(static_cast<int>(j));
274 QVERIFY(area->layerBundle[static_cast<size_t>(area->activeLayer)].image->getPixelColor(point)==QColor(0,0,0,0));
275 }
276 }
277
278 area->deleteLayer(0);
279 }
280
281 void UnitTest::test_moveActive(){
282 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
283 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
284
285 area->layerBundle[1].image->drawPlain(QColor(0, 0, 0, 255));
286 QPoint point(0,0);
287
288 area->moveActiveLayer(-1);
289 QCOMPARE(area->activeLayer, 0);
290 QVERIFY(area->layerBundle[static_cast<size_t>(area->activeLayer)].image->getPixelColor(point)==QColor(0,0,0,255));
291
292 area->moveActiveLayer(-1);
293 QCOMPARE(area->activeLayer, 0);
294 QVERIFY(area->layerBundle[static_cast<size_t>(area->activeLayer)].image->getPixelColor(point)==QColor(0,0,0,255));
295
296 area->moveActiveLayer(1);
297 QCOMPARE(area->activeLayer, 1);
298 QVERIFY(area->layerBundle[static_cast<size_t>(area->activeLayer)].image->getPixelColor(point)==QColor(0,0,0,255));
299
300 area->moveActiveLayer(1);
301 QCOMPARE(area->activeLayer, 1);
302 QVERIFY(area->layerBundle[static_cast<size_t>(area->activeLayer)].image->getPixelColor(point)==QColor(0,0,0,255));
303
304 area->deleteLayer(1);
305 area->deleteLayer(0);
306 }
307
308 void UnitTest::test_setPolygon(){
309 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
310 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
311
312 std::vector<QPoint> polygon{
313 QPoint(10,00),
314 QPoint(00,10),
315 QPoint(10,10),
316 QPoint(00,10)
317 };
318
319 area->layerBundle[1].image->setPolygon(polygon);
320 IntelliShapedImage* image = dynamic_cast<IntelliShapedImage*>(area->layerBundle[1].image);
321 QCOMPARE(image->polygonData[0], polygon[0]);
322 QCOMPARE(image->polygonData[1], polygon[1]);
323 QCOMPARE(image->polygonData[2], polygon[2]);
324 QCOMPARE(image->polygonData[3], polygon[3]);
325
326 area->deleteLayer(1);
327 area->deleteLayer(0);
328 }
329
330 void UnitTest::test_setLayerUp(){
331 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
332 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
333
334 area->selectLayerUp();
335 QCOMPARE(area->activeLayer, 1);
336
337 area->setLayerActive(0);
338 QCOMPARE(area->activeLayer, 0);
339
340 area->selectLayerUp();
341 QCOMPARE(area->activeLayer, 1);
342
343 area->deleteLayer(1);
344 area->deleteLayer(0);
345 }
346
347 void UnitTest::test_setLayerDown(){
348 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
349 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
350
351 area->selectLayerDown();
352 QCOMPARE(area->activeLayer, 0);
353
354 area->selectLayerDown();
355 QCOMPARE(area->activeLayer, 0);
356
357 area->deleteLayer(1);
358 area->deleteLayer(0);
359
360 }
361
362 void UnitTest::test_createTools(){
363 QVERIFY(area->Tool == nullptr);
364
365 area->createPenTool();
366 QVERIFY(dynamic_cast<IntelliToolPen*>(area->Tool) != nullptr);
367
368 area->createLineTool();
369 QVERIFY(dynamic_cast<IntelliToolLine*>(area->Tool) != nullptr);
370
371 area->createPlainTool();
372 QVERIFY(dynamic_cast<IntelliToolPlainTool*>(area->Tool) != nullptr);
373
374 area->createCircleTool();
375 QVERIFY(dynamic_cast<IntelliToolCircle*>(area->Tool) != nullptr);
376
377 area->createPolygonTool();
378 QVERIFY(dynamic_cast<IntelliToolPolygon*>(area->Tool) != nullptr);
379
380 area->createFloodFillTool();
381 QVERIFY(dynamic_cast<IntelliToolFloodFill*>(area->Tool) != nullptr);
382
383 area->createRectangleTool();
384 QVERIFY(dynamic_cast<IntelliToolRectangle*>(area->Tool) != nullptr);
385 }
386
387 //test Raster-Image operations
388 void UnitTest::test_RasterImage_drawPixel(){
389 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
390
391 QPoint point(0,0);
392
393 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
394 area->layerBundle[0].image->drawPixel(point, QColor(0,0,0,255));
395
396 QVERIFY(area->layerBundle[0].image->getPixelColor(point) == QColor(0,0,0,255));
397
398 area->deleteLayer(0);
399 }
400
401 void UnitTest::test_RasterImage_drawLine(){
402 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
403
404 QPoint point1(0,0);
405 QPoint point2(10,10);
406 QPoint point3(5,5);
407 QPoint point4(6,5);
408
409 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
410 area->layerBundle[0].image->drawLine(point1, point2, QColor(0,0,0,255),1);
411 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(0,0,0,255));
412 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(0,0,0,255));
413 QVERIFY(area->layerBundle[0].image->getPixelColor(point3)==QColor(0,0,0,255));
414 QVERIFY(area->layerBundle[0].image->getPixelColor(point4)==QColor(255,255,255,255));
415
416 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
417 area->layerBundle[0].image->drawLine(point1, point2, QColor(0,0,0,255),3);
418 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(0,0,0,255));
419 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(0,0,0,255));
420 QVERIFY(area->layerBundle[0].image->getPixelColor(point3)==QColor(0,0,0,255));
421 QVERIFY(area->layerBundle[0].image->getPixelColor(point4)==QColor(0,0,0,255));
422
423 area->deleteLayer(0);
424 }
425
426 void UnitTest::test_RasterImage_drawPoint(){
427 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
428
429 QPoint point1(5,5);
430 QPoint point2(5,6);
431
432 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
433 area->layerBundle[0].image->drawPoint(point1, QColor(0,0,0,255),1);
434 QVERIFY(area->layerBundle[0].image->getPixelColor(point1) == QColor(0,0,0,255));
435 QVERIFY(area->layerBundle[0].image->getPixelColor(point2) == QColor(255,255,255,255));
436
437
438 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
439 area->layerBundle[0].image->drawPoint(point1, QColor(0,0,0,255),5);
440 QVERIFY(area->layerBundle[0].image->getPixelColor(point1) == QColor(0,0,0,255));
441 QVERIFY(area->layerBundle[0].image->getPixelColor(point2) == QColor(0,0,0,255));
442
443 area->deleteLayer(0);
444 }
445
446 void UnitTest::test_RasterImage_getDisplayable(){
447 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
448
449 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
450 QImage img = area->layerBundle[0].image->getDisplayable(QSize(200,200),255);
451 QPoint point;
452 for(size_t i = 0; i<200; i++) {
453 point.setX(static_cast<int>(i));
454 for(size_t j = 0; j<200; j++) {
455 point.setY(static_cast<int>(j));
456 QVERIFY(img.pixelColor(point) == QColor(255,255,255,255));
457 }
458 }
459
460 area->deleteLayer(0);
461 }
462
463 void UnitTest::test_RasterImage_getPixelColor(){
464 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
465
466 QPoint point(0,0);
467 area->layerBundle[0].image->drawPlain(QColor(0, 0, 0, 255));
468 QVERIFY(area->layerBundle[0].image->getPixelColor(point)==QColor(0,0,0,255));
469
470 area->deleteLayer(0);
471 }
472
473 void UnitTest::test_RasterImage_getImageData(){
474 area->addLayer(2,2,10,20,255,ImageType::RASTERIMAGE);
475
476 QImage img(2,2, QImage::Format_ARGB32);
477 img.setPixelColor(0,0, Qt::red);
478 img.setPixelColor(0,1, Qt::yellow);
479 img.setPixelColor(1,0, Qt::blue);
480 img.setPixelColor(1,1, Qt::green);
481
482 area->layerBundle[0].image->setImageData(img);
483 img = img.convertToFormat(QImage::Format_Indexed8);
484 QImage cpy = area->layerBundle[0].image->getImageData();
485
486 QPoint point1(0,0);
487 QPoint point2(0,1);
488 QPoint point3(1,0);
489 QPoint point4(1,1);
490 QVERIFY(cpy.pixelColor(point1) == img.pixelColor(point1));
491 QVERIFY(cpy.pixelColor(point2) == img.pixelColor(point2));
492 QVERIFY(cpy.pixelColor(point3) == img.pixelColor(point3));
493 QVERIFY(cpy.pixelColor(point4) == img.pixelColor(point4));
494
495 area->deleteLayer(0);
496 }
497
498 void UnitTest::test_RasterImage_setImageData(){
499 area->addLayer(2,2,10,20,255,ImageType::RASTERIMAGE);
500
501 QImage img(2,2, QImage::Format_ARGB32);
502 img.setPixelColor(0,0, Qt::red);
503 img.setPixelColor(0,1, Qt::yellow);
504 img.setPixelColor(1,0, Qt::blue);
505 img.setPixelColor(1,1, Qt::green);
506
507 area->layerBundle[0].image->setImageData(img);
508 img = img.convertToFormat(QImage::Format_Indexed8);
509
510 QPoint point1(0,0);
511 QPoint point2(0,1);
512 QPoint point3(1,0);
513 QPoint point4(1,1);
514 QVERIFY(area->layerBundle[0].image->getPixelColor(point1) == img.pixelColor(point1));
515 QVERIFY(area->layerBundle[0].image->getPixelColor(point2) == img.pixelColor(point2));
516 QVERIFY(area->layerBundle[0].image->getPixelColor(point3) == img.pixelColor(point3));
517 QVERIFY(area->layerBundle[0].image->getPixelColor(point4) == img.pixelColor(point4));
518
519 area->deleteLayer(0);
520 }
521
522 //test Shaped-Image operations
523 void UnitTest::test_ShapedImage_drawPixel(){
524 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
525
526 QPoint point(0,0);
527
528 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
529 area->layerBundle[0].image->drawPixel(point, QColor(0,0,0,255));
530
531 QVERIFY(area->layerBundle[0].image->getPixelColor(point) == QColor(0,0,0,255));
532
533 area->deleteLayer(0);
534 }
535
536 void UnitTest::test_ShapedImage_drawLine(){
537 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
538
539 QPoint point1(0,0);
540 QPoint point2(10,10);
541 QPoint point3(5,5);
542 QPoint point4(6,5);
543
544 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
545 area->layerBundle[0].image->drawLine(point1, point2, QColor(0,0,0,255),1);
546 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(0,0,0,255));
547 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(0,0,0,255));
548 QVERIFY(area->layerBundle[0].image->getPixelColor(point3)==QColor(0,0,0,255));
549 QVERIFY(area->layerBundle[0].image->getPixelColor(point4)==QColor(255,255,255,255));
550
551 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
552 area->layerBundle[0].image->drawLine(point1, point2, QColor(0,0,0,255),3);
553 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(0,0,0,255));
554 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(0,0,0,255));
555 QVERIFY(area->layerBundle[0].image->getPixelColor(point3)==QColor(0,0,0,255));
556 QVERIFY(area->layerBundle[0].image->getPixelColor(point4)==QColor(0,0,0,255));
557
558 area->deleteLayer(0);
559 }
560
561 void UnitTest::test_ShapedImage_drawPoint(){
562 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
563
564 QPoint point1(5,5);
565 QPoint point2(5,6);
566
567 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
568 area->layerBundle[0].image->drawPoint(point1, QColor(0,0,0,255),1);
569 QVERIFY(area->layerBundle[0].image->getPixelColor(point1) == QColor(0,0,0,255));
570 QVERIFY(area->layerBundle[0].image->getPixelColor(point2) == QColor(255,255,255,255));
571
572
573 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
574 area->layerBundle[0].image->drawPoint(point1, QColor(0,0,0,255),5);
575 QVERIFY(area->layerBundle[0].image->getPixelColor(point1) == QColor(0,0,0,255));
576 QVERIFY(area->layerBundle[0].image->getPixelColor(point2) == QColor(0,0,0,255));
577
578 area->deleteLayer(0);
579 }
580
581 void UnitTest::test_ShapedImage_getDisplayable(){
582 area->addLayer(21,21,10,20,255,ImageType::SHAPEDIMAGE);
583 std::vector<QPoint> points{
584 QPoint(10,00),
585 QPoint(00,10),
586 QPoint(10,20),
587 QPoint(20,10)
588 };
589
590 std::vector<QPoint> test{
591 QPoint(00,00),
592 QPoint(00,20),
593 QPoint(20,00),
594 QPoint(20,20),
595 QPoint(10,10)
596 };
597 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
598 area->layerBundle[0].image->setPolygon(points);
599 QSize size(21,21);
600 QImage img = area->layerBundle[0].image->getDisplayable(size,255);
601
602 QCOMPARE(img.pixelColor(points[0]).alpha(), 255);
603 QCOMPARE(img.pixelColor(points[1]).alpha(), 255);
604 QCOMPARE(img.pixelColor(points[2]).alpha(), 255);
605 QCOMPARE(img.pixelColor(points[3]).alpha(), 255);
606
607 QCOMPARE(img.pixelColor(test[4]).alpha(), 255);
608 QCOMPARE(img.pixelColor(test[0]).alpha(), 0);
609 QCOMPARE(img.pixelColor(test[1]).alpha(), 0);
610 QCOMPARE(img.pixelColor(test[2]).alpha(), 0);
611 QCOMPARE(img.pixelColor(test[3]).alpha(), 0);
612
613 area->deleteLayer(0);
614 }
615
616 void UnitTest::test_ShapedImage_getPixelColor(){
617 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
618
619 QPoint point(0,0);
620 area->layerBundle[0].image->drawPlain(QColor(0, 0, 0, 255));
621 QVERIFY(area->layerBundle[0].image->getPixelColor(point)==QColor(0,0,0,255));
622
623 area->deleteLayer(0);
624 }
625
626 void UnitTest::test_ShapedImage_getImageData(){
627 area->addLayer(2,2,10,20,255,ImageType::RASTERIMAGE);
628
629 QImage img(2,2, QImage::Format_ARGB32);
630 img.setPixelColor(0,0, Qt::red);
631 img.setPixelColor(0,1, Qt::yellow);
632 img.setPixelColor(1,0, Qt::blue);
633 img.setPixelColor(1,1, Qt::green);
634
635 area->layerBundle[0].image->setImageData(img);
636 img = img.convertToFormat(QImage::Format_Indexed8);
637 QImage cpy = area->layerBundle[0].image->getImageData();
638
639 QPoint point1(0,0);
640 QPoint point2(0,1);
641 QPoint point3(1,0);
642 QPoint point4(1,1);
643 QVERIFY(cpy.pixelColor(point1) == img.pixelColor(point1));
644 QVERIFY(cpy.pixelColor(point2) == img.pixelColor(point2));
645 QVERIFY(cpy.pixelColor(point3) == img.pixelColor(point3));
646 QVERIFY(cpy.pixelColor(point4) == img.pixelColor(point4));
647
648 area->deleteLayer(0);
649 }
650
651 void UnitTest::test_ShapedImage_setImageData(){
652 area->addLayer(2,2,10,20,255,ImageType::RASTERIMAGE);
653
654 QImage img(2,2, QImage::Format_ARGB32);
655 img.setPixelColor(0,0, Qt::red);
656 img.setPixelColor(0,1, Qt::yellow);
657 img.setPixelColor(1,0, Qt::blue);
658 img.setPixelColor(1,1, Qt::green);
659
660 area->layerBundle[0].image->setImageData(img);
661 img = img.convertToFormat(QImage::Format_Indexed8);
662
663 QPoint point1(0,0);
664 QPoint point2(0,1);
665 QPoint point3(1,0);
666 QPoint point4(1,1);
667 QVERIFY(area->layerBundle[0].image->getPixelColor(point1) == img.pixelColor(point1));
668 QVERIFY(area->layerBundle[0].image->getPixelColor(point2) == img.pixelColor(point2));
669 QVERIFY(area->layerBundle[0].image->getPixelColor(point3) == img.pixelColor(point3));
670 QVERIFY(area->layerBundle[0].image->getPixelColor(point4) == img.pixelColor(point4));
671
672 area->deleteLayer(0);
673 }
674
675 //test tools
676 void UnitTest::test_Circle_fullDraw(){
677 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
678 area->colorPicker.setFirstColor(QColor(255,255,255,255));
679 area->colorPicker.setSecondColor(QColor(0,0,0,255));
680 area->createCircleTool();
681 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
682
683 QPoint point1(100,100);
684 QPoint point2(150,100);
685 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
686 area->Tool->onMouseMoved(point2.x(), point2.y());
687 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
688
689
690 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==area->colorPicker.getSecondColor());
691 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==area->colorPicker.getFirstColor());
692
693 area->deleteLayer(0);
694 }
695
696 void UnitTest::test_Circle_interruptedDraw(){
697 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
698 area->colorPicker.setFirstColor(QColor(255,255,255,255));
699 area->colorPicker.setSecondColor(QColor(0,0,0,255));
700 area->createCircleTool();
701 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
702
703 QPoint point1(100,100);
704 QPoint point2(150,100);
705 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
706 area->Tool->onMouseMoved(point2.x(), point2.y());
707 area->Tool->onMouseRightPressed(point2.x(), point2.y());
708 area->Tool->onMouseRightReleased(point2.x(),point2.y());
709 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
710
711
712 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(255,0,0,255));
713 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(255,0,0,255));
714
715 area->deleteLayer(0);
716
717 }
718
719
720 void UnitTest::test_FloodFill_fullDraw(){
721 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
722 area->colorPicker.setFirstColor(QColor(255,255,255,255));
723 area->colorPicker.setSecondColor(QColor(0,0,0,255));
724 area->createFloodFillTool();
725 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
726
727 QPoint point1(100,100);
728 QPoint point2(150,100);
729 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
730 area->Tool->onMouseMoved(point2.x(), point2.y());
731 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
732
733
734 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==area->colorPicker.getFirstColor());
735 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==area->colorPicker.getFirstColor());
736
737 area->deleteLayer(0);
738 }
739
740 void UnitTest::test_FloodFill_interruptedDraw(){
741 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
742 area->colorPicker.setFirstColor(QColor(255,255,255,255));
743 area->colorPicker.setSecondColor(QColor(0,0,0,255));
744 area->createFloodFillTool();
745 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
746
747 QPoint point1(100,100);
748 QPoint point2(150,100);
749 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
750 area->Tool->onMouseMoved(point2.x(), point2.y());
751 area->Tool->onMouseRightPressed(point2.x(), point2.y());
752 area->Tool->onMouseRightReleased(point2.x(),point2.y());
753 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
754
755
756 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(255,0,0,255));
757 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(255,0,0,255));
758
759 area->deleteLayer(0);
760 }
761
762
763 void UnitTest::test_Line_fullDraw(){
764 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
765 area->colorPicker.setFirstColor(QColor(255,255,255,255));
766 area->colorPicker.setSecondColor(QColor(0,0,0,255));
767 area->createLineTool();
768 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
769
770 QPoint point1(100,100);
771 QPoint point2(150,100);
772 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
773 area->Tool->onMouseMoved(point2.x(), point2.y());
774 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
775
776
777 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==area->colorPicker.getFirstColor());
778 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==area->colorPicker.getFirstColor());
779
780 area->deleteLayer(0);
781 }
782
783 void UnitTest::test_Line_interruptedDraw(){
784 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
785 area->colorPicker.setFirstColor(QColor(255,255,255,255));
786 area->colorPicker.setSecondColor(QColor(0,0,0,255));
787 area->createLineTool();
788 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
789
790 QPoint point1(100,100);
791 QPoint point2(150,100);
792 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
793 area->Tool->onMouseMoved(point2.x(), point2.y());
794 area->Tool->onMouseRightPressed(point2.x(), point2.y());
795 area->Tool->onMouseRightReleased(point2.x(),point2.y());
796 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
797
798
799 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(255,0,0,255));
800 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(255,0,0,255));
801
802 area->deleteLayer(0);
803 }
804
805 void UnitTest::test_Pen_fullDraw(){
806 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
807 area->colorPicker.setFirstColor(QColor(255,255,255,255));
808 area->colorPicker.setSecondColor(QColor(0,0,0,255));
809 area->createPenTool();
810 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
811
812 QPoint point1(100,100);
813 QPoint point2(150,100);
814 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
815 area->Tool->onMouseMoved(point2.x(), point2.y());
816 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
817
818
819 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==area->colorPicker.getFirstColor());
820 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==area->colorPicker.getFirstColor());
821
822 area->deleteLayer(0);
823 }
824
825 void UnitTest::test_Pen_interruptedDraw(){
826 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
827 area->colorPicker.setFirstColor(QColor(255,255,255,255));
828 area->colorPicker.setSecondColor(QColor(0,0,0,255));
829 area->createPenTool();
830 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
831
832 QPoint point1(100,100);
833 QPoint point2(150,100);
834 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
835 area->Tool->onMouseMoved(point2.x(), point2.y());
836 area->Tool->onMouseRightPressed(point2.x(), point2.y());
837 area->Tool->onMouseRightReleased(point2.x(),point2.y());
838 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
839
840
841 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(255,0,0,255));
842 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(255,0,0,255));
843
844 area->deleteLayer(0);
845 }
846
847 void UnitTest::test_Plain_fullDraw(){
848 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
849 area->colorPicker.setFirstColor(QColor(255,255,255,255));
850 area->colorPicker.setSecondColor(QColor(0,0,0,255));
851 area->createPlainTool();
852 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
853
854 QPoint point1(100,100);
855 QPoint point2(150,100);
856 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
857 area->Tool->onMouseMoved(point2.x(), point2.y());
858 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
859
860
861 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==area->colorPicker.getFirstColor());
862 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==area->colorPicker.getFirstColor());
863
864 area->deleteLayer(0);
865 }
866
867 void UnitTest::test_Plain_interruptedDraw(){
868 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
869 area->colorPicker.setFirstColor(QColor(255,255,255,255));
870 area->colorPicker.setSecondColor(QColor(0,0,0,255));
871 area->createPlainTool();
872 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
873
874 QPoint point1(100,100);
875 QPoint point2(150,100);
876 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
877 area->Tool->onMouseMoved(point2.x(), point2.y());
878 area->Tool->onMouseRightPressed(point2.x(), point2.y());
879 area->Tool->onMouseRightReleased(point2.x(),point2.y());
880 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
881
882
883 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(255,0,0,255));
884 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(255,0,0,255));
885
886 area->deleteLayer(0);
887 }
888
889 void UnitTest::test_Polygon_fullDraw(){
890 area->addLayer(21,21,10,20,255,ImageType::RASTERIMAGE);
891 std::vector<QPoint> points{
892 QPoint(10,00),
893 QPoint(00,10),
894 QPoint(10,20),
895 QPoint(20,10)
896 };
897
898 std::vector<QPoint> test{
899 QPoint(00,00),
900 QPoint(00,20),
901 QPoint(20,00),
902 QPoint(20,20),
903 QPoint(10,10)
904 };
905
906 area->colorPicker.setFirstColor(QColor(255,255,255,255));
907 area->colorPicker.setSecondColor(QColor(0,0,0,255));
908 area->createPolygonTool();
909 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
910
911 area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
912 area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
913 area->Tool->onMouseMoved(points[1].x(), points[1].y());
914
915 area->Tool->onMouseLeftPressed(points[1].x(), points[1].y());
916 area->Tool->onMouseLeftReleased(points[1].x(), points[1].y());
917 area->Tool->onMouseMoved(points[2].x(), points[2].y());
918
919 area->Tool->onMouseLeftPressed(points[2].x(), points[2].y());
920 area->Tool->onMouseLeftReleased(points[2].x(), points[2].y());
921 area->Tool->onMouseMoved(points[3].x(), points[3].y());
922
923 area->Tool->onMouseLeftPressed(points[3].x(), points[3].y());
924 area->Tool->onMouseLeftReleased(points[3].x(), points[3].y());
925 area->Tool->onMouseMoved(points[0].x(), points[0].y());
926
927 area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
928 area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
929
930 QVERIFY(area->layerBundle[0].image->getPixelColor(points[0])==area->colorPicker.getFirstColor());
931 QVERIFY(area->layerBundle[0].image->getPixelColor(points[1])==area->colorPicker.getFirstColor());
932 QVERIFY(area->layerBundle[0].image->getPixelColor(points[2])==area->colorPicker.getFirstColor());
933 QVERIFY(area->layerBundle[0].image->getPixelColor(points[3])==area->colorPicker.getFirstColor());
934
935
936 QVERIFY(area->layerBundle[0].image->getPixelColor(test[4])==area->colorPicker.getSecondColor());
937 QVERIFY(area->layerBundle[0].image->getPixelColor(test[0])==QColor(255,0,0,255));
938 QVERIFY(area->layerBundle[0].image->getPixelColor(test[1])==QColor(255,0,0,255));
939 QVERIFY(area->layerBundle[0].image->getPixelColor(test[2])==QColor(255,0,0,255));
940 QVERIFY(area->layerBundle[0].image->getPixelColor(test[3])==QColor(255,0,0,255));
941
942 area->deleteLayer(0);
943 }
944
945
946 void UnitTest::test_Polygon_interruptedDraw(){
947 area->addLayer(201,201,10,20,255,ImageType::RASTERIMAGE);
948 std::vector<QPoint> points{
949 QPoint(100,000),
950 QPoint(000,100),
951 QPoint(100,200),
952 QPoint(200,100)
953 };
954
955 std::vector<QPoint> test{
956 QPoint(000,000),
957 QPoint(000,200),
958 QPoint(200,000),
959 QPoint(200,200),
960 QPoint(100,100)
961 };
962
963 area->colorPicker.setFirstColor(QColor(255,255,255,255));
964 area->colorPicker.setSecondColor(QColor(0,0,0,255));
965 area->createPolygonTool();
966 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
967
968 area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
969 area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
970 area->Tool->onMouseMoved(points[1].x(), points[1].y());
971
972 area->Tool->onMouseLeftPressed(points[1].x(), points[1].y());
973 area->Tool->onMouseLeftReleased(points[1].x(), points[1].y());
974 area->Tool->onMouseMoved(points[2].x(), points[2].y());
975
976 area->Tool->onMouseLeftPressed(points[2].x(), points[2].y());
977 area->Tool->onMouseLeftReleased(points[2].x(), points[2].y());
978 area->Tool->onMouseMoved(points[3].x(), points[3].y());
979
980 area->Tool->onMouseLeftPressed(points[3].x(), points[3].y());
981 area->Tool->onMouseLeftReleased(points[3].x(), points[3].y());
982
983 area->Tool->onMouseRightPressed(points[0].x(), points[0].y());
984 area->Tool->onMouseRightReleased(points[0].x(), points[0].y());
985
986
987 QVERIFY(area->layerBundle[0].image->getPixelColor(points[0])==QColor(255,0,0,255));
988 QVERIFY(area->layerBundle[0].image->getPixelColor(points[1])==QColor(255,0,0,255));
989 QVERIFY(area->layerBundle[0].image->getPixelColor(points[2])==QColor(255,0,0,255));
990 QVERIFY(area->layerBundle[0].image->getPixelColor(points[3])==QColor(255,0,0,255));
991
992 QVERIFY(area->layerBundle[0].image->getPixelColor(test[4])==QColor(255,0,0,255));
993 QVERIFY(area->layerBundle[0].image->getPixelColor(test[0])==QColor(255,0,0,255));
994 QVERIFY(area->layerBundle[0].image->getPixelColor(test[1])==QColor(255,0,0,255));
995 QVERIFY(area->layerBundle[0].image->getPixelColor(test[2])==QColor(255,0,0,255));
996 QVERIFY(area->layerBundle[0].image->getPixelColor(test[3])==QColor(255,0,0,255));
997
998 area->deleteLayer(0);
999 }
1000
1001
1002 void UnitTest::test_Rectangle_fullDraw(){
1003 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1004 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1005 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1006 area->createRectangleTool();
1007 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1008
1009 QPoint point1(100,100);
1010 QPoint point2(150,150);
1011 QPoint point3(125,125);
1012 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1013 area->Tool->onMouseMoved(point2.x(), point2.y());
1014 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1015
1016
1017 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==area->colorPicker.getFirstColor());
1018 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==area->colorPicker.getFirstColor());
1019 QVERIFY(area->layerBundle[0].image->getPixelColor(point3)==area->colorPicker.getSecondColor());
1020
1021 area->deleteLayer(0);
1022 }
1023
1024 void UnitTest::test_Rectangle_interruptedDraw(){
1025 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1026 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1027 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1028 area->createRectangleTool();
1029 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1030
1031 QPoint point1(100,100);
1032 QPoint point2(150,150);
1033 QPoint point3(125,125);
1034 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1035 area->Tool->onMouseMoved(point2.x(), point2.y());
1036 area->Tool->onMouseRightPressed(point2.x(), point2.y());
1037 area->Tool->onMouseRightReleased(point2.x(),point2.y());
1038 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1039
1040 QVERIFY(area->layerBundle[0].image->getPixelColor(point1)==QColor(255,0,0,255));
1041 QVERIFY(area->layerBundle[0].image->getPixelColor(point2)==QColor(255,0,0,255));
1042 QVERIFY(area->layerBundle[0].image->getPixelColor(point3)==QColor(255,0,0,255));
1043
1044 area->deleteLayer(0);
1045 }
1046
1047
1048 //test Triangulation
1049 void UnitTest::test_Triangulation_Coverage(){
1050 std::vector<QPoint> points{
1051 QPoint(10,00),
1052 QPoint(00,10),
1053 QPoint(10,20),
1054 QPoint(20,10)
1055 };
1056 std::vector<QPoint> test{
1057 QPoint(00,00),
1058 QPoint(00,20),
1059 QPoint(20,00),
1060 QPoint(20,20),
1061 QPoint(10,10)
1062 };
1063 std::vector<Triangle> tria = IntelliTriangulation::calculateTriangles(points);
1064 QCOMPARE(IntelliTriangulation::isInPolygon(tria, points[0]), true);
1065 QCOMPARE(IntelliTriangulation::isInPolygon(tria, points[1]), true);
1066 QCOMPARE(IntelliTriangulation::isInPolygon(tria, points[2]), true);
1067 QCOMPARE(IntelliTriangulation::isInPolygon(tria, points[3]), true);
1068
1069 QCOMPARE(IntelliTriangulation::isInPolygon(tria, test[4]), true);
1070 QCOMPARE(IntelliTriangulation::isInPolygon(tria, test[0]), false);
1071 QCOMPARE(IntelliTriangulation::isInPolygon(tria, test[1]), false);
1072 QCOMPARE(IntelliTriangulation::isInPolygon(tria, test[2]), false);
1073 QCOMPARE(IntelliTriangulation::isInPolygon(tria, test[3]), false);
1074 }
1075
1076
1078
1079 void UnitTest::bench_addLayer(){
1080 QBENCHMARK{
1081 area->addLayer(200,200,0,0,255,ImageType::RASTERIMAGE);
1082 }
1083 area->deleteLayer(0);
1084 }
1085
1086 void UnitTest::bench_deleteLayer(){
1087 area->addLayer(200,200,0,0,255,ImageType::RASTERIMAGE);
1088 QBENCHMARK{
1089 area->deleteLayer(0);
1090 }
1091 }
1092
1093 void UnitTest::bench_setActive(){
1094 area->addLayer(200,200,0,0,255,ImageType::RASTERIMAGE);
1095 area->addLayer(200,200,0,0,255,ImageType::RASTERIMAGE);
1096
1097 QBENCHMARK{
1098 area->setLayerActive(0);
1099 }
1100
1101 area->deleteLayer(1);
1102 area->deleteLayer(0);
1103 }
1104
1105 void UnitTest::bench_setAlpha(){
1106 area->addLayer(200,200,0,0,255,ImageType::RASTERIMAGE);
1107
1108 QBENCHMARK{
1109 area->setLayerAlpha(0,0);
1110 }
1111
1112 area->deleteLayer(0);
1113 }
1114
1115 void UnitTest::bench_floodFill(){
1116 area->addLayer(200,200,0,0,255,ImageType::RASTERIMAGE);
1117
1118 QBENCHMARK{
1119 area->layerBundle[0].image->drawPlain(QColor(255, 255, 255, 255));
1120 }
1121
1122 area->deleteLayer(0);
1123 }
1124
1125 void UnitTest::bench_moveActive(){
1126 area->addLayer(200,200,0,0,255,ImageType::RASTERIMAGE);
1127 area->addLayer(200,200,0,0,255,ImageType::RASTERIMAGE);
1128
1129 area->setLayerActive(0);
1130 QBENCHMARK{
1131 area->moveActiveLayer(1);
1132 }
1133
1134 area->deleteLayer(1);
1135 area->deleteLayer(0);
1136 }
1137
1138 void UnitTest::bench_setPolygon(){
1139 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
1140
1141 std::vector<QPoint> polygon{
1142 QPoint(10,00),
1143 QPoint(00,10),
1144 QPoint(10,10),
1145 QPoint(00,10)
1146 };
1147
1148 QBENCHMARK{
1149 area->layerBundle[0].image->setPolygon(polygon);
1150 }
1151
1152 area->deleteLayer(0);
1153 }
1154
1155 void UnitTest::bench_setLayerUp(){
1156 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1157 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1158
1159 area->setLayerActive(0);
1160 QBENCHMARK{
1161 area->selectLayerUp();
1162 }
1163
1164 area->deleteLayer(1);
1165 area->deleteLayer(0);
1166 }
1167
1168 void UnitTest::bench_setLayerDown(){
1169 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1170 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1171
1172 QBENCHMARK{
1173 area->selectLayerDown();
1174 }
1175
1176 area->deleteLayer(1);
1177 area->deleteLayer(0);
1178 }
1179
1180 void UnitTest::bench_createTools(){
1181 QBENCHMARK{
1182 area->createPenTool();
1183 }
1184
1185 QBENCHMARK{
1186 area->createLineTool();
1187 }
1188
1189 QBENCHMARK{
1190 area->createPlainTool();
1191 }
1192
1193 QBENCHMARK{
1194 area->createCircleTool();
1195 }
1196
1197 QBENCHMARK{
1198 area->createPolygonTool();
1199 }
1200
1201 QBENCHMARK{
1202 area->createFloodFillTool();
1203 }
1204
1205 QBENCHMARK{
1206 area->createRectangleTool();
1207 }
1208 }
1209
1210 void UnitTest::bench_RasterImage_drawPixel(){
1211 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1212
1213 QPoint point(0,0);
1214
1215 QBENCHMARK{
1216 area->layerBundle[0].image->drawPixel(point, QColor(0,0,0,255));
1217 }
1218
1219 area->deleteLayer(0);
1220 }
1221
1222 void UnitTest::bench_RasterImage_drawLine(){
1223 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1224
1225 QPoint point1(000,000);
1226 QPoint point2(200,200);
1227
1228 QBENCHMARK{
1229 area->layerBundle[0].image->drawLine(point1, point2, QColor(0,0,0,255), 1);
1230 }
1231
1232 area->deleteLayer(0);
1233 }
1234
1235 void UnitTest::bench_RasterImage_drawPoint(){
1236 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1237
1238 QPoint point(000,000);
1239
1240 QBENCHMARK{
1241 area->layerBundle[0].image->drawPoint(point, QColor(0,0,0,255), 1);
1242 }
1243
1244 area->deleteLayer(0);
1245 }
1246
1247 void UnitTest::bench_RasterImage_getDisplayable(){
1248 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1249
1250 QBENCHMARK{
1251 area->layerBundle[0].image->getDisplayable(QSize(200,200),255);
1252 }
1253
1254 area->deleteLayer(0);
1255 }
1256
1257 void UnitTest::bench_RasterImage_getPixelColor(){
1258 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1259
1260 QPoint point(000,000);
1261
1262 QBENCHMARK{
1263 area->layerBundle[0].image->getPixelColor(point);
1264 }
1265
1266 area->deleteLayer(0);
1267 }
1268
1269 void UnitTest::bench_RasterImage_getImageData(){
1270 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1271
1272 QBENCHMARK{
1273 area->layerBundle[0].image->getImageData();
1274 }
1275
1276 area->deleteLayer(0);
1277 }
1278
1279 void UnitTest::bench_RasterImage_setImageData(){
1280 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1281
1282 QImage img = area->layerBundle[0].image->getImageData();
1283 QBENCHMARK{
1284 area->layerBundle[0].image->setImageData(img);
1285 }
1286
1287 area->deleteLayer(0);
1288 }
1289
1290 void UnitTest::bench_ShapedImage_drawPixel(){
1291 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
1292
1293 QPoint point(0,0);
1294
1295 QBENCHMARK{
1296 area->layerBundle[0].image->drawPixel(point, QColor(0,0,0,255));
1297 }
1298
1299 area->deleteLayer(0);
1300 }
1301
1302 void UnitTest::bench_ShapedImage_drawLine(){
1303 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
1304
1305 QPoint point1(000,000);
1306 QPoint point2(200,200);
1307
1308 QBENCHMARK{
1309 area->layerBundle[0].image->drawLine(point1, point2, QColor(0,0,0,255), 1);
1310 }
1311
1312 area->deleteLayer(0);
1313 }
1314
1315 void UnitTest::bench_ShapedImage_drawPoint(){
1316 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
1317
1318 QPoint point(000,000);
1319
1320 QBENCHMARK{
1321 area->layerBundle[0].image->drawPoint(point, QColor(0,0,0,255), 1);
1322 }
1323
1324 area->deleteLayer(0);
1325 }
1326
1327 void UnitTest::bench_ShapedImage_getDisplayable(){
1328 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
1329
1330 QBENCHMARK{
1331 area->layerBundle[0].image->getDisplayable(QSize(200,200),255);
1332 }
1333
1334 area->deleteLayer(0);
1335 }
1336
1337 void UnitTest::bench_ShapedImage_getPixelColor(){
1338 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
1339
1340 QPoint point(000,000);
1341
1342 QBENCHMARK{
1343 area->layerBundle[0].image->getPixelColor(point);
1344 }
1345
1346 area->deleteLayer(0);
1347 }
1348
1349 void UnitTest::bench_ShapedImage_getImageData(){
1350 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
1351
1352 QBENCHMARK{
1353 area->layerBundle[0].image->getImageData();
1354 }
1355
1356 area->deleteLayer(0);
1357 }
1358
1359 void UnitTest::bench_ShapedImage_setImageData(){
1360 area->addLayer(200,200,10,20,255,ImageType::SHAPEDIMAGE);
1361
1362 QImage img = area->layerBundle[0].image->getImageData();
1363 QBENCHMARK{
1364 area->layerBundle[0].image->setImageData(img);
1365 }
1366
1367 area->deleteLayer(0);
1368 }
1369
1370 void UnitTest::bench_Circle_fullDraw(){
1371 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1372 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1373 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1374 area->createCircleTool();
1375 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1376
1377 QPoint point1(100,100);
1378 QPoint point2(150,100);
1379 QBENCHMARK{
1380 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1381 area->Tool->onMouseMoved(point2.x(), point2.y());
1382 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1383 }
1384
1385 area->deleteLayer(0);
1386 }
1387
1388 void UnitTest::bench_Circle_interruptedDraw(){
1389 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1390 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1391 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1392 area->createCircleTool();
1393 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1394
1395 QPoint point1(100,100);
1396 QPoint point2(150,100);
1397 QBENCHMARK{
1398 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1399 area->Tool->onMouseMoved(point2.x(), point2.y());
1400 area->Tool->onMouseRightPressed(point2.x(), point2.y());
1401 area->Tool->onMouseRightReleased(point2.x(),point2.y());
1402 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1403 }
1404
1405 area->deleteLayer(0);
1406 }
1407
1408
1409 void UnitTest::bench_FloodFill_fullDraw(){
1410 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1411 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1412 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1413 area->createFloodFillTool();
1414 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1415
1416 QPoint point1(100,100);
1417 QPoint point2(150,100);
1418 QBENCHMARK{
1419 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1420 area->Tool->onMouseMoved(point2.x(), point2.y());
1421 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1422 }
1423
1424 area->deleteLayer(0);
1425 }
1426
1427 void UnitTest::bench_FloodFill_interruptedDraw(){
1428 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1429 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1430 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1431 area->createFloodFillTool();
1432 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1433
1434 QPoint point1(100,100);
1435 QPoint point2(150,100);
1436 QBENCHMARK{
1437 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1438 area->Tool->onMouseMoved(point2.x(), point2.y());
1439 area->Tool->onMouseRightPressed(point2.x(), point2.y());
1440 area->Tool->onMouseRightReleased(point2.x(),point2.y());
1441 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1442 }
1443
1444 area->deleteLayer(0);
1445 }
1446
1447
1448 void UnitTest::bench_Line_fullDraw(){
1449 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1450 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1451 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1452 area->createLineTool();
1453 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1454
1455 QPoint point1(100,100);
1456 QPoint point2(150,100);
1457 QBENCHMARK{
1458 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1459 area->Tool->onMouseMoved(point2.x(), point2.y());
1460 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1461 }
1462
1463 area->deleteLayer(0);
1464 }
1465
1466 void UnitTest::bench_Line_interruptedDraw(){
1467 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1468 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1469 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1470 area->createLineTool();
1471 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1472
1473 QPoint point1(100,100);
1474 QPoint point2(150,100);
1475
1476 QBENCHMARK{
1477 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1478 area->Tool->onMouseMoved(point2.x(), point2.y());
1479 area->Tool->onMouseRightPressed(point2.x(), point2.y());
1480 area->Tool->onMouseRightReleased(point2.x(),point2.y());
1481 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1482 }
1483
1484 area->deleteLayer(0);
1485 }
1486
1487 void UnitTest::bench_Pen_fullDraw(){
1488 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1489 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1490 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1491 area->createPenTool();
1492 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1493
1494 QPoint point1(100,100);
1495 QPoint point2(150,100);
1496 QBENCHMARK{
1497 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1498 area->Tool->onMouseMoved(point2.x(), point2.y());
1499 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1500 }
1501
1502 area->deleteLayer(0);
1503 }
1504
1505 void UnitTest::bench_Pen_interruptedDraw(){
1506 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1507 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1508 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1509 area->createPenTool();
1510 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1511
1512 QPoint point1(100,100);
1513 QPoint point2(150,100);
1514 QBENCHMARK{
1515 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1516 area->Tool->onMouseMoved(point2.x(), point2.y());
1517 area->Tool->onMouseRightPressed(point2.x(), point2.y());
1518 area->Tool->onMouseRightReleased(point2.x(),point2.y());
1519 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1520 }
1521
1522 area->deleteLayer(0);
1523 }
1524
1525 void UnitTest::bench_Plain_fullDraw(){
1526 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1527 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1528 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1529 area->createPlainTool();
1530 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1531
1532 QPoint point1(100,100);
1533 QPoint point2(150,100);
1534 QBENCHMARK{
1535 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1536 area->Tool->onMouseMoved(point2.x(), point2.y());
1537 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1538 }
1539
1540 area->deleteLayer(0);
1541 }
1542
1543 void UnitTest::bench_Plain_interruptedDraw(){
1544 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1545 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1546 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1547 area->createPlainTool();
1548 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1549
1550 QPoint point1(100,100);
1551 QPoint point2(150,100);
1552 QBENCHMARK{
1553 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1554 area->Tool->onMouseMoved(point2.x(), point2.y());
1555 area->Tool->onMouseRightPressed(point2.x(), point2.y());
1556 area->Tool->onMouseRightReleased(point2.x(),point2.y());
1557 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1558 }
1559
1560 area->deleteLayer(0);
1561 }
1562
1563 void UnitTest::bench_Polygon_fullDraw(){
1564 area->addLayer(21,21,10,20,255,ImageType::RASTERIMAGE);
1565 std::vector<QPoint> points{
1566 QPoint(10,00),
1567 QPoint(00,10),
1568 QPoint(10,20),
1569 QPoint(20,10)
1570 };
1571
1572 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1573 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1574 area->createPolygonTool();
1575 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1576
1577 QBENCHMARK{
1578 area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
1579 area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
1580 area->Tool->onMouseMoved(points[1].x(), points[1].y());
1581
1582 area->Tool->onMouseLeftPressed(points[1].x(), points[1].y());
1583 area->Tool->onMouseLeftReleased(points[1].x(), points[1].y());
1584 area->Tool->onMouseMoved(points[2].x(), points[2].y());
1585
1586 area->Tool->onMouseLeftPressed(points[2].x(), points[2].y());
1587 area->Tool->onMouseLeftReleased(points[2].x(), points[2].y());
1588 area->Tool->onMouseMoved(points[3].x(), points[3].y());
1589
1590 area->Tool->onMouseLeftPressed(points[3].x(), points[3].y());
1591 area->Tool->onMouseLeftReleased(points[3].x(), points[3].y());
1592 area->Tool->onMouseMoved(points[0].x(), points[0].y());
1593
1594 area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
1595 area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
1596 }
1597
1598 area->deleteLayer(0);
1599 }
1600
1601
1602 void UnitTest::bench_Polygon_interruptedDraw(){
1603 area->addLayer(201,201,10,20,255,ImageType::RASTERIMAGE);
1604 std::vector<QPoint> points{
1605 QPoint(100,000)
1606 };
1607
1608
1609 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1610 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1611 area->createPolygonTool();
1612 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1613
1614 QBENCHMARK{
1615 area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
1616 area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
1617
1618 area->Tool->onMouseRightPressed(points[0].x(), points[0].y());
1619 area->Tool->onMouseRightReleased(points[0].x(), points[0].y());
1620 }
1621
1622 area->deleteLayer(0);
1623 }
1624
1625
1626 void UnitTest::bench_Rectangle_fullDraw(){
1627 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1628 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1629 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1630 area->createRectangleTool();
1631 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1632
1633 QPoint point1(100,100);
1634 QPoint point2(150,150);
1635
1636 QBENCHMARK{
1637 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1638 area->Tool->onMouseMoved(point2.x(), point2.y());
1639 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1640 }
1641
1642 area->deleteLayer(0);
1643 }
1644
1645 void UnitTest::bench_Rectangle_interruptedDraw(){
1646 area->addLayer(200,200,10,20,255,ImageType::RASTERIMAGE);
1647 area->colorPicker.setFirstColor(QColor(255,255,255,255));
1648 area->colorPicker.setSecondColor(QColor(0,0,0,255));
1649 area->createRectangleTool();
1650 area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
1651
1652 QPoint point1(100,100);
1653 QPoint point2(150,150);
1654 QBENCHMARK{
1655 area->Tool->onMouseLeftPressed(point1.x(), point1.y());
1656 area->Tool->onMouseMoved(point2.x(), point2.y());
1657 area->Tool->onMouseRightPressed(point2.x(), point2.y());
1658 area->Tool->onMouseRightReleased(point2.x(),point2.y());
1659 area->Tool->onMouseLeftReleased(point2.x(), point2.y());
1660 }
1661
1662 area->deleteLayer(0);
1663 }
1664
1665
1666 void UnitTest::bench_Triangulation_Coverage(){
1667 std::vector<QPoint> points{
1668 QPoint(10,00),
1669 QPoint(00,10),
1670 QPoint(10,20),
1671 QPoint(20,10)
1672 };
1673 std::vector<QPoint> test{
1674 QPoint(00,00),
1675 QPoint(00,20),
1676 QPoint(20,00),
1677 QPoint(20,20),
1678 QPoint(10,10)
1679 };
1680
1681 QBENCHMARK{
1682 std::vector<Triangle> tria = IntelliTriangulation::calculateTriangles(points);
1683 QPoint point;
1684 for(int i = 0; i<200; i++) {
1685 point.setX(i);
1686 for(int j = 0; j<200; j++) {
1687 point.setY(j);
1688 IntelliTriangulation::isInPolygon(tria, point);
1689 }
1690 }
1691 }
1692 }
1693
1694
1695 QTEST_MAIN(UnitTest)
1696
1697 #include "tst_unittest.moc"
PaintingArea::createCircleTool
void createCircleTool()
createCircleTool creates a Circle Tool.
Definition: PaintingArea.cpp:263
IntelliTool::onMouseRightPressed
virtual void onMouseRightPressed(int x, int y)
A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on....
Definition: IntelliTool.cpp:19
IntelliColorPicker::getFirstColor
QColor getFirstColor() const
A function to read the primary selected color.
Definition: IntelliColorPicker.cpp:15
ImageType::RASTERIMAGE
@ RASTERIMAGE
IntelliTool::onMouseLeftReleased
virtual void onMouseLeftReleased(int x, int y)
A function managing the left click Released of a Mouse. Call this in child classes!
Definition: IntelliTool.cpp:37
PaintingArea::createRectangleTool
void createRectangleTool()
createRectangleTool creates a Rectangle Tool.
Definition: PaintingArea.cpp:258
IntelliTool.h
IntelliToolPolygon.h
IntelliTool::onMouseLeftPressed
virtual void onMouseLeftPressed(int x, int y)
A function managing the left click Pressed of a Mouse. Resetting the current draw....
Definition: IntelliTool.cpp:30
IntelliShapedImage.h
IntelliImage.h
IntelliRenderSettings.h
PaintingArea::setLayerAlpha
void setLayerAlpha(int idx, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
Definition: PaintingArea.cpp:143
IntelliToolsettings.h
PaintingArea::setLayerActive
void setLayerActive(int idx)
The setLayerToActive method marks a specific layer as active.
Definition: PaintingArea.cpp:136
IntelliTriangulation::calculateTriangles
std::vector< Triangle > calculateTriangles(std::vector< QPoint > polyPoints)
A function to split a polygon in its spanning traingles by using Meisters Theorem of graph theory by ...
Definition: IntelliTriangulation.cpp:7
PaintingArea::deleteLayer
void deleteLayer(int idx, bool isTool=false)
The deleteLayer method removes a layer at a given idx.
Definition: PaintingArea.cpp:113
UnitTest::~UnitTest
~UnitTest()
Definition: mainUnitTest.cpp:108
IntelliPhotoGui
The IntelliPhotoGui base class handles the graphical user interface and events for the intelliPhoto p...
Definition: IntelliPhotoGui.h:34
IntelliColorPicker::setSecondColor
void setSecondColor(QColor Color)
A function to set the secondary color.
Definition: IntelliColorPicker.cpp:27
IntelliToolPlainTool
The IntelliToolPlainTool class represents a tool to fill the whole canvas with one color.
Definition: IntelliToolPlain.h:13
IntelliShapedImage
The IntelliShapedImage manages a Shapedimage.
Definition: IntelliShapedImage.h:13
UnitTest::UnitTest
UnitTest()
Definition: mainUnitTest.cpp:95
IntelliToolFloodFill.h
PaintingArea::createPlainTool
void createPlainTool()
createPlainTool creates a Plain Tool.
Definition: PaintingArea.cpp:248
PaintingArea
The PaintingArea class manages the methods and stores information about the current painting area,...
Definition: PaintingArea.h:57
PaintingArea::createPenTool
void createPenTool()
createPenTool creates a Pen Tool.
Definition: PaintingArea.cpp:243
IntelliToolPlain.h
IntelliRasterImage.h
IntelliColorPicker::getSecondColor
QColor getSecondColor() const
A function to read the secondary selected color.
Definition: IntelliColorPicker.cpp:19
IntelliToolRectangle
The IntelliToolRectangle class represents a tool to draw a rectangle.
Definition: IntelliToolRectangle.h:15
PaintingArea::createLineTool
void createLineTool()
createLineTool creates a Line Tool.
Definition: PaintingArea.cpp:253
IntelliToolLine.h
IntelliToolPen
The IntelliToolPen class represents a tool to draw a line.
Definition: IntelliToolPen.h:14
IntelliTool::onMouseRightReleased
virtual void onMouseRightReleased(int x, int y)
A function managing the right click Released of a Mouse. Merging the Canvas to Active....
Definition: IntelliTool.cpp:26
IntelliColorPicker.h
IntelliToolRectangle.h
IntelliPhotoGui.h
IntelliColorPicker::setFirstColor
void setFirstColor(QColor Color)
A function to set the primary color.
Definition: IntelliColorPicker.cpp:23
ImageType::SHAPEDIMAGE
@ SHAPEDIMAGE
PaintingArea::createPolygonTool
void createPolygonTool()
createPolygonTool creates a Polygon Tool.
Definition: PaintingArea.cpp:267
PaintingArea::moveActiveLayer
void moveActiveLayer(int idx)
The moveActiveLayer moves the active layer to a specific position in the layer stack.
Definition: PaintingArea.cpp:211
PaintingArea::colorPicker
IntelliColorPicker colorPicker
colorPicker a class to manage Tool color.
Definition: PaintingArea.h:286
PaintingArea.h
PaintingArea::createFloodFillTool
void createFloodFillTool()
createFloodFillTool creates a Floodfill Tool.
Definition: PaintingArea.cpp:272
UnitTest
Definition: mainUnitTest.cpp:8
IntelliToolFloodFill
The IntelliToolFloodFill class represents a tool to flood FIll a certian area.
Definition: IntelliToolFloodFill.h:14
IntelliToolPen.h
IntelliToolCircle
The IntelliToolCircle class represents a tool to draw a circle.
Definition: IntelliToolCircle.h:14
IntelliTool::onMouseMoved
virtual void onMouseMoved(int x, int y)
A function managing the mouse moved event. Call this in child classes!
Definition: IntelliTool.cpp:47
PaintingArea::addLayer
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, int alpha=255, ImageType type=ImageType::RASTERIMAGE)
The addLayer adds a layer to the current project/ painting area.
Definition: PaintingArea.cpp:94
IntelliToolPolygon
The IntelliToolPolygon managed the Drawing of Polygonforms.
Definition: IntelliToolPolygon.h:15
IntelliShapedImage::polygonData
std::vector< QPoint > polygonData
The Vertices of The Polygon. Needs to be a planar Polygon.
Definition: IntelliShapedImage.h:31
IntelliTriangulation::isInPolygon
bool isInPolygon(const std::vector< Triangle > &triangles, QPoint &point)
A function to check if a point lies in a polygon by checking its spanning triangles.
Definition: IntelliTriangulation.cpp:116
IntelliTriangulation.h
IntelliToolCircle.h
IntelliToolLine
The IntelliToolFloodFill class represents a tool to draw a line.
Definition: IntelliToolLine.h:13