all benchmark just polygon interrupt missing

This commit is contained in:
Jonas Mucke
2020-01-15 18:09:23 +01:00
parent 84f6bc84da
commit d17bf4850c
5 changed files with 734 additions and 15 deletions

View File

@@ -47,6 +47,5 @@ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
}
void IntelliRasterImage::setPolygon(const std::vector<QPoint>& polygonData){
qDebug() << "Raster Image has no polygon data " << polygonData.size() <<"\n";
return;
}

View File

@@ -5,9 +5,9 @@ IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, In
this->Area=Area;
this->colorPicker=colorPicker;
this->Toolsettings=Toolsettings;
this->isDrawing = false;
}
IntelliTool::~IntelliTool(){
}

View File

@@ -7,38 +7,38 @@
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
isPointNearStart = false;
isDrawing = false;
drawingOfPolygon = false;
isInside = false;
this->ActiveType = Tooltype::POLYGON;
}
IntelliToolPolygon::~IntelliToolPolygon(){
if(isDrawing) {
if(drawingOfPolygon) {
IntelliTool::onMouseRightPressed(0,0);
}
}
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x >= 0 && y >= 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x >= 0 && y >= 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
QPoint Point(x,y);
isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
}
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x >= 0 && y >= 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
else if(!drawingOfPolygon && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x >= 0 && y >= 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
isInside = true;
}
if(isInside && !isDrawing) {
if(isInside && !drawingOfPolygon) {
IntelliTool::onMouseLeftPressed(x,y);
QPoint drawingPoint = QPoint(x,y);
isDrawing = true;
drawingOfPolygon = true;
QPointList.push_back(drawingPoint);
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->calculateVisiblity();
}
else if(isDrawing && isNearStart(x,y,QPointList.front())) {
else if(drawingOfPolygon && isNearStart(x,y,QPointList.front())) {
if(QPointList.size() > 2) {
isPointNearStart = true;
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
@@ -46,13 +46,14 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
}
else{
isInside = false;
isDrawing = false;
drawingOfPolygon = false;
QPointList.clear();
IntelliTool::onMouseRightPressed(x,y);
IntelliTool::onMouseRightReleased(x,y);
}
}
else if(isDrawing) {
else if(drawingOfPolygon) {
QPoint drawingPoint(x,y);
QPointList.push_back(drawingPoint);
this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
@@ -71,7 +72,7 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
if(isPointNearStart) {
isInside = false;
isPointNearStart = false;
isDrawing = false;
drawingOfPolygon = false;
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
QPoint Point;
QColor colorTwo(colorPicker->getSecondColor());
@@ -99,7 +100,7 @@ void IntelliToolPolygon::onMouseRightReleased(int x, int y){
void IntelliToolPolygon::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
if(!isDrawing) {
if(!drawingOfPolygon) {
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
}
}

View File

@@ -25,9 +25,9 @@ class IntelliToolPolygon : public IntelliTool
bool isNearStart(int x, int y, QPoint Startpoint);
/*!
* \brief IsDrawing true while drawing, else false.
* \brief drawingOfPolygon true while drawing, else false.
*/
bool isDrawing;
bool drawingOfPolygon;
/*!
* \brief isInside Checks if Point is inside Image

View File

@@ -35,6 +35,8 @@ private slots:
void cleanupTestCase();
//void test_case1();
///Test here
//test painting area
void test_addLayer();
void test_deleteLayer();
@@ -90,6 +92,65 @@ private slots:
//test Triangulation
void test_Triangulation_Coverage();
///Benchmark here
//bench painting area
void bench_addLayer();
void bench_deleteLayer();
void bench_setActive();
void bench_setAlpha();
void bench_floodFill();
void bench_moveActive();
void bench_setPolygon();
void bench_setLayerUp();
void bench_setLayerDown();
void bench_createTools();
//bench Raster-Image operations
void bench_RasterImage_drawPixel();
void bench_RasterImage_drawLine();
void bench_RasterImage_drawPoint();
void bench_RasterImage_getDisplayable();
void bench_RasterImage_getPixelColor();
void bench_RasterImage_getImageData();
void bench_RasterImage_setImageData();
//bench Shaped-Image operations
void bench_ShapedImage_drawPixel();
void bench_ShapedImage_drawLine();
void bench_ShapedImage_drawPoint();
void bench_ShapedImage_getDisplayable();
void bench_ShapedImage_getPixelColor();
void bench_ShapedImage_getImageData();
void bench_ShapedImage_setImageData();
//bench tools
void bench_Circle_fullDraw();
void bench_Circle_interruptedDraw();
void bench_FloodFill_fullDraw();
void bench_FloodFill_interruptedDraw();
void bench_Line_fullDraw();
void bench_Line_interruptedDraw();
void bench_Pen_fullDraw();
void bench_Pen_interruptedDraw();
void bench_Plain_fullDraw();
void bench_Plain_interruptedDraw();
void bench_Polygon_fullDraw();
//void bench_Polygon_interruptedDraw();
void bench_Rectangle_fullDraw();
void bench_Rectangle_interruptedDraw();
//bench Triangulation
void bench_Triangulation_Coverage();
};
UnitTest::UnitTest()
@@ -672,6 +733,7 @@ void UnitTest::test_Circle_interruptedDraw(){
}
void UnitTest::test_FloodFill_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
@@ -714,6 +776,7 @@ void UnitTest::test_FloodFill_interruptedDraw(){
area->deleteLayer(0);
}
void UnitTest::test_Line_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
@@ -896,6 +959,7 @@ void UnitTest::test_Polygon_fullDraw(){
area->deleteLayer(0);
}
void UnitTest::test_Polygon_interruptedDraw(){
area->addLayer(201,201,10,20,IntelliImage::ImageType::RASTERIMAGE);
std::vector<QPoint> points{
@@ -951,6 +1015,7 @@ void UnitTest::test_Polygon_interruptedDraw(){
area->deleteLayer(0);
}
void UnitTest::test_Rectangle_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
@@ -996,6 +1061,7 @@ void UnitTest::test_Rectangle_interruptedDraw(){
area->deleteLayer(0);
}
//test Triangulation
void UnitTest::test_Triangulation_Coverage(){
std::vector<QPoint> points{
@@ -1024,6 +1090,659 @@ void UnitTest::test_Triangulation_Coverage(){
QCOMPARE(IntelliTriangulation::isInPolygon(tria, test[3]), false);
}
///Benchmarks here
void UnitTest::bench_addLayer(){
QBENCHMARK{
area->addLayer(200,200,0,0,IntelliImage::ImageType::RASTERIMAGE);
}
area->deleteLayer(0);
}
void UnitTest::bench_deleteLayer(){
area->addLayer(200,200,0,0,IntelliImage::ImageType::RASTERIMAGE);
QBENCHMARK{
area->deleteLayer(0);
}
}
void UnitTest::bench_setActive(){
area->addLayer(200,200,0,0,IntelliImage::ImageType::RASTERIMAGE);
area->addLayer(200,200,0,0,IntelliImage::ImageType::RASTERIMAGE);
QBENCHMARK{
area->setLayerActive(0);
}
area->deleteLayer(1);
area->deleteLayer(0);
}
void UnitTest::bench_setAlpha(){
area->addLayer(200,200,0,0,IntelliImage::ImageType::RASTERIMAGE);
QBENCHMARK{
area->setLayerAlpha(0,0);
}
area->deleteLayer(0);
}
void UnitTest::bench_floodFill(){
area->addLayer(200,200,0,0,IntelliImage::ImageType::RASTERIMAGE);
QBENCHMARK{
area->floodFill(255,255,255,255);
}
area->deleteLayer(0);
}
void UnitTest::bench_moveActive(){
area->addLayer(200,200,0,0,IntelliImage::ImageType::RASTERIMAGE);
area->addLayer(200,200,0,0,IntelliImage::ImageType::RASTERIMAGE);
area->setLayerActive(0);
QBENCHMARK{
area->moveActiveLayer(1);
}
area->deleteLayer(1);
area->deleteLayer(0);
}
void UnitTest::bench_setPolygon(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
std::vector<QPoint> polygon{
QPoint(10,00),
QPoint(00,10),
QPoint(10,10),
QPoint(00,10)
};
QBENCHMARK{
area->layerBundle[1].image->setPolygon(polygon);
}
area->deleteLayer(0);
}
void UnitTest::bench_setLayerUp(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->setLayerActive(0);
QBENCHMARK{
area->selectLayerUp();
}
area->deleteLayer(1);
area->deleteLayer(0);
}
void UnitTest::bench_setLayerDown(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
QBENCHMARK{
area->selectLayerDown();
}
area->deleteLayer(1);
area->deleteLayer(0);
}
void UnitTest::bench_createTools(){
QBENCHMARK{
area->createPenTool();
}
QBENCHMARK{
area->createLineTool();
}
QBENCHMARK{
area->createPlainTool();
}
QBENCHMARK{
area->createCircleTool();
}
QBENCHMARK{
area->createPolygonTool();
}
QBENCHMARK{
area->createFloodFillTool();
}
QBENCHMARK{
area->createRectangleTool();
}
}
void UnitTest::bench_RasterImage_drawPixel(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
QPoint point(0,0);
QBENCHMARK{
area->layerBundle[0].image->drawPixel(point, QColor(0,0,0,255));
}
area->deleteLayer(0);
}
void UnitTest::bench_RasterImage_drawLine(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
QPoint point1(000,000);
QPoint point2(200,200);
QBENCHMARK{
area->layerBundle[0].image->drawLine(point1, point2, QColor(0,0,0,255), 1);
}
area->deleteLayer(0);
}
void UnitTest::bench_RasterImage_drawPoint(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
QPoint point(000,000);
QBENCHMARK{
area->layerBundle[0].image->drawPoint(point, QColor(0,0,0,255), 1);
}
area->deleteLayer(0);
}
void UnitTest::bench_RasterImage_getDisplayable(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
QBENCHMARK{
area->layerBundle[0].image->getDisplayable(QSize(200,200),255);
}
area->deleteLayer(0);
}
void UnitTest::bench_RasterImage_getPixelColor(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
QPoint point(000,000);
QBENCHMARK{
area->layerBundle[0].image->getPixelColor(point);
}
area->deleteLayer(0);
}
void UnitTest::bench_RasterImage_getImageData(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
QBENCHMARK{
area->layerBundle[0].image->getImageData();
}
area->deleteLayer(0);
}
void UnitTest::bench_RasterImage_setImageData(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
QImage img = area->layerBundle[0].image->getImageData();
QBENCHMARK{
area->layerBundle[0].image->setImageData(img);
}
area->deleteLayer(0);
}
void UnitTest::bench_ShapedImage_drawPixel(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
QPoint point(0,0);
QBENCHMARK{
area->layerBundle[0].image->drawPixel(point, QColor(0,0,0,255));
}
area->deleteLayer(0);
}
void UnitTest::bench_ShapedImage_drawLine(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
QPoint point1(000,000);
QPoint point2(200,200);
QBENCHMARK{
area->layerBundle[0].image->drawLine(point1, point2, QColor(0,0,0,255), 1);
}
area->deleteLayer(0);
}
void UnitTest::bench_ShapedImage_drawPoint(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
QPoint point(000,000);
QBENCHMARK{
area->layerBundle[0].image->drawPoint(point, QColor(0,0,0,255), 1);
}
area->deleteLayer(0);
}
void UnitTest::bench_ShapedImage_getDisplayable(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
QBENCHMARK{
area->layerBundle[0].image->getDisplayable(QSize(200,200),255);
}
area->deleteLayer(0);
}
void UnitTest::bench_ShapedImage_getPixelColor(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
QPoint point(000,000);
QBENCHMARK{
area->layerBundle[0].image->getPixelColor(point);
}
area->deleteLayer(0);
}
void UnitTest::bench_ShapedImage_getImageData(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
QBENCHMARK{
area->layerBundle[0].image->getImageData();
}
area->deleteLayer(0);
}
void UnitTest::bench_ShapedImage_setImageData(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
QImage img = area->layerBundle[0].image->getImageData();
QBENCHMARK{
area->layerBundle[0].image->setImageData(img);
}
area->deleteLayer(0);
}
void UnitTest::bench_Circle_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createCircleTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Circle_interruptedDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createCircleTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseRightPressed(point2.x(), point2.y());
area->Tool->onMouseRightReleased(point2.x(),point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_FloodFill_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createFloodFillTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_FloodFill_interruptedDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createFloodFillTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseRightPressed(point2.x(), point2.y());
area->Tool->onMouseRightReleased(point2.x(),point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Line_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createLineTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Line_interruptedDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createLineTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseRightPressed(point2.x(), point2.y());
area->Tool->onMouseRightReleased(point2.x(),point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Pen_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createPenTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Pen_interruptedDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createPenTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseRightPressed(point2.x(), point2.y());
area->Tool->onMouseRightReleased(point2.x(),point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Plain_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createPlainTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Plain_interruptedDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createPlainTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,100);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseRightPressed(point2.x(), point2.y());
area->Tool->onMouseRightReleased(point2.x(),point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Polygon_fullDraw(){
area->addLayer(21,21,10,20,IntelliImage::ImageType::RASTERIMAGE);
std::vector<QPoint> points{
QPoint(10,00),
QPoint(00,10),
QPoint(10,20),
QPoint(20,10)
};
std::vector<QPoint> test{
QPoint(00,00),
QPoint(00,20),
QPoint(20,00),
QPoint(20,20),
QPoint(10,10)
};
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createPolygonTool();
area->floodFill(255,0,0,255);
QBENCHMARK{
area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
area->Tool->onMouseMoved(points[1].x(), points[1].y());
area->Tool->onMouseLeftPressed(points[1].x(), points[1].y());
area->Tool->onMouseLeftReleased(points[1].x(), points[1].y());
area->Tool->onMouseMoved(points[2].x(), points[2].y());
area->Tool->onMouseLeftPressed(points[2].x(), points[2].y());
area->Tool->onMouseLeftReleased(points[2].x(), points[2].y());
area->Tool->onMouseMoved(points[3].x(), points[3].y());
area->Tool->onMouseLeftPressed(points[3].x(), points[3].y());
area->Tool->onMouseLeftReleased(points[3].x(), points[3].y());
area->Tool->onMouseMoved(points[0].x(), points[0].y());
area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
}
area->deleteLayer(0);
}
/*
void UnitTest::bench_Polygon_interruptedDraw(){
area->addLayer(201,201,10,20,IntelliImage::ImageType::RASTERIMAGE);
std::vector<QPoint> points{
QPoint(100,000),
QPoint(000,100),
QPoint(100,200),
QPoint(200,100)
};
std::vector<QPoint> test{
QPoint(000,000),
QPoint(000,200),
QPoint(200,000),
QPoint(200,200),
QPoint(100,100)
};
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createPolygonTool();
area->floodFill(255,0,0,255);
QBENCHMARK{
area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
area->Tool->onMouseMoved(points[1].x(), points[1].y());
area->Tool->onMouseLeftPressed(points[1].x(), points[1].y());
area->Tool->onMouseLeftReleased(points[1].x(), points[1].y());
area->Tool->onMouseMoved(points[2].x(), points[2].y());
area->Tool->onMouseLeftPressed(points[2].x(), points[2].y());
area->Tool->onMouseLeftReleased(points[2].x(), points[2].y());
area->Tool->onMouseMoved(points[3].x(), points[3].y());
area->Tool->onMouseLeftPressed(points[3].x(), points[3].y());
area->Tool->onMouseLeftReleased(points[3].x(), points[3].y());
area->Tool->onMouseRightPressed(points[0].x(), points[0].y());
area->Tool->onMouseRightReleased(points[0].x(), points[0].y());
}
area->deleteLayer(0);
}
*/
void UnitTest::bench_Rectangle_fullDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createRectangleTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,150);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Rectangle_interruptedDraw(){
area->addLayer(200,400,10,20,IntelliImage::ImageType::RASTERIMAGE);
area->colorPicker.setFirstColor(QColor(255,255,255,255));
area->colorPicker.setSecondColor(QColor(0,0,0,255));
area->createRectangleTool();
area->floodFill(255,0,0,255);
QPoint point1(100,100);
QPoint point2(150,150);
QBENCHMARK{
area->Tool->onMouseLeftPressed(point1.x(), point1.y());
area->Tool->onMouseMoved(point2.x(), point2.y());
area->Tool->onMouseRightPressed(point2.x(), point2.y());
area->Tool->onMouseRightReleased(point2.x(),point2.y());
area->Tool->onMouseLeftReleased(point2.x(), point2.y());
}
area->deleteLayer(0);
}
void UnitTest::bench_Triangulation_Coverage(){
std::vector<QPoint> points{
QPoint(10,00),
QPoint(00,10),
QPoint(10,20),
QPoint(20,10)
};
std::vector<QPoint> test{
QPoint(00,00),
QPoint(00,20),
QPoint(20,00),
QPoint(20,20),
QPoint(10,10)
};
QBENCHMARK{
std::vector<Triangle> tria = IntelliTriangulation::calculateTriangles(points);
QPoint point;
for(int i=0; i<200; i++){
point.setX(i);
for(int j=0; j<200; j++){
point.setY(j);
IntelliTriangulation::isInPolygon(tria, point);
}
}
}
}
QTEST_MAIN(UnitTest)
#include "tst_unittest.moc"