mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
kein bock mehr mach dein scheiß richtig das nächste mal
This commit is contained in:
@@ -10,6 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
TEMPLATE = app
|
||||
|
||||
SOURCES += tst_unittest.cpp \
|
||||
GUI/IntelliInputDialog.cpp \
|
||||
GUI/IntelliPhotoGui.cpp \
|
||||
Image/IntelliImage.cpp \
|
||||
Image/IntelliRasterImage.cpp \
|
||||
@@ -41,6 +42,7 @@ DISTFILES += \
|
||||
icons/rectangle-tool.svg
|
||||
|
||||
HEADERS += \
|
||||
GUI/IntelliInputDialog.h \
|
||||
GUI/IntelliPhotoGui.h \
|
||||
Image/IntelliImage.h \
|
||||
Image/IntelliRasterImage.h \
|
||||
|
||||
@@ -52,7 +52,7 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||
this->Canvas->image->calculateVisiblity();
|
||||
}
|
||||
}
|
||||
else if(drawingOfPolygon && isNearStart(x,y,QPointList.front())) {
|
||||
else if(drawingOfPolygon && QPointList.size() > 0 && isNearStart(x,y,QPointList.front())) {
|
||||
if(QPointList.size() > 2) {
|
||||
isPointNearStart = true;
|
||||
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
|
||||
@@ -90,7 +90,6 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
||||
if(isPointNearStart) {
|
||||
isInside = false;
|
||||
isPointNearStart = false;
|
||||
isDrawing = false;
|
||||
if(!isSettingPolygon) {
|
||||
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
|
||||
QPoint Point;
|
||||
@@ -139,17 +138,11 @@ void IntelliToolPolygon::onMouseMoved(int x, int y){
|
||||
}
|
||||
|
||||
bool IntelliToolPolygon::isNearStart(int x, int y, QPoint Startpoint){
|
||||
bool isNear = false;
|
||||
int StartX = Startpoint.x();
|
||||
int StartY = Startpoint.y();
|
||||
int valueToNear = 5;
|
||||
|
||||
for(int i = StartX - valueToNear; i < StartX + valueToNear; i++) {
|
||||
for(int j = StartY - valueToNear; j < StartY + valueToNear; j++) {
|
||||
if((i == x) && (j == y)) {
|
||||
isNear = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isNear;
|
||||
float euklid = sqrt(pow(static_cast<float>(StartX-x),2.f)+pow(static_cast<float>(StartY-y),2.f));
|
||||
|
||||
return static_cast<int>(euklid)<valueToNear;
|
||||
}
|
||||
|
||||
@@ -274,24 +274,6 @@ void UnitTest::test_floodFill(){
|
||||
}
|
||||
}
|
||||
|
||||
area->layerBundle[0].image->drawPlain(QColor(-1, -1, -1, -1));
|
||||
for(size_t i = 0; i<200; i++) {
|
||||
point.setX(static_cast<int>(i));
|
||||
for(size_t j = 0; i<200; i++) {
|
||||
point.setY(static_cast<int>(j));
|
||||
QVERIFY(area->layerBundle[static_cast<size_t>(area->activeLayer)].image->getPixelColor(point)==QColor(0,0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
area->layerBundle[0].image->drawPlain(QColor(256, 256, 256, 256));
|
||||
for(size_t i = 0; i<200; i++) {
|
||||
point.setX(static_cast<int>(i));
|
||||
for(size_t j = 0; i<200; i++) {
|
||||
point.setY(static_cast<int>(j));
|
||||
QVERIFY(area->layerBundle[static_cast<size_t>(area->activeLayer)].image->getPixelColor(point)==QColor(0,0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
area->deleteLayer(0);
|
||||
}
|
||||
|
||||
@@ -299,7 +281,7 @@ void UnitTest::test_moveActive(){
|
||||
area->addLayer(200,200,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
|
||||
area->addLayer(200,200,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
|
||||
|
||||
area->layerBundle[0].image->drawPlain(QColor(0, 0, 0, 255));
|
||||
area->layerBundle[1].image->drawPlain(QColor(0, 0, 0, 255));
|
||||
QPoint point(0,0);
|
||||
|
||||
area->moveActiveLayer(-1);
|
||||
@@ -1153,20 +1135,20 @@ void UnitTest::bench_moveActive(){
|
||||
}
|
||||
|
||||
void UnitTest::bench_setPolygon(){
|
||||
area->addLayer(200,200,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
|
||||
area->addLayer(200,200,10,20,IntelliImage::ImageType::SHAPEDIMAGE);
|
||||
|
||||
std::vector<QPoint> polygon{
|
||||
QPoint(10,00),
|
||||
QPoint(00,10),
|
||||
QPoint(10,10),
|
||||
QPoint(00,10)
|
||||
};
|
||||
std::vector<QPoint> polygon{
|
||||
QPoint(10,00),
|
||||
QPoint(00,10),
|
||||
QPoint(10,10),
|
||||
QPoint(00,10)
|
||||
};
|
||||
|
||||
QBENCHMARK{
|
||||
area->layerBundle[1].image->setPolygon(polygon);
|
||||
}
|
||||
QBENCHMARK{
|
||||
area->layerBundle[0].image->setPolygon(polygon);
|
||||
}
|
||||
|
||||
area->deleteLayer(0);
|
||||
area->deleteLayer(0);
|
||||
}
|
||||
|
||||
void UnitTest::bench_setLayerUp(){
|
||||
@@ -1578,65 +1560,65 @@ void UnitTest::bench_Plain_interruptedDraw(){
|
||||
}
|
||||
|
||||
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)
|
||||
};
|
||||
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)
|
||||
};
|
||||
|
||||
area->colorPicker.setFirstColor(QColor(255,255,255,255));
|
||||
area->colorPicker.setSecondColor(QColor(0,0,0,255));
|
||||
area->createPolygonTool();
|
||||
area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
|
||||
area->colorPicker.setFirstColor(QColor(255,255,255,255));
|
||||
area->colorPicker.setSecondColor(QColor(0,0,0,255));
|
||||
area->createPolygonTool();
|
||||
area->layerBundle[0].image->drawPlain(QColor(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());
|
||||
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[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[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[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->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
|
||||
area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
|
||||
}
|
||||
|
||||
area->deleteLayer(0);
|
||||
area->deleteLayer(0);
|
||||
}
|
||||
|
||||
|
||||
void UnitTest::bench_Polygon_interruptedDraw(){
|
||||
area->addLayer(201,201,10,20,IntelliImage::ImageType::RASTERIMAGE);
|
||||
std::vector<QPoint> points{
|
||||
QPoint(100,000)
|
||||
};
|
||||
area->addLayer(201,201,10,20,IntelliImage::ImageType::RASTERIMAGE);
|
||||
std::vector<QPoint> points{
|
||||
QPoint(100,000)
|
||||
};
|
||||
|
||||
|
||||
area->colorPicker.setFirstColor(QColor(255,255,255,255));
|
||||
area->colorPicker.setSecondColor(QColor(0,0,0,255));
|
||||
area->createPolygonTool();
|
||||
area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
|
||||
area->colorPicker.setFirstColor(QColor(255,255,255,255));
|
||||
area->colorPicker.setSecondColor(QColor(0,0,0,255));
|
||||
area->createPolygonTool();
|
||||
area->layerBundle[0].image->drawPlain(QColor(255, 0, 0, 255));
|
||||
|
||||
QBENCHMARK{
|
||||
area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
|
||||
area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
|
||||
QBENCHMARK{
|
||||
area->Tool->onMouseLeftPressed(points[0].x(), points[0].y());
|
||||
area->Tool->onMouseLeftReleased(points[0].x(), points[0].y());
|
||||
|
||||
area->Tool->onMouseRightPressed(points[0].x(), points[0].y());
|
||||
area->Tool->onMouseRightReleased(points[0].x(), points[0].y());
|
||||
}
|
||||
area->Tool->onMouseRightPressed(points[0].x(), points[0].y());
|
||||
area->Tool->onMouseRightReleased(points[0].x(), points[0].y());
|
||||
}
|
||||
|
||||
area->deleteLayer(0);
|
||||
area->deleteLayer(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user