diff --git a/DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp index ce4669e921..2c57b81aeb 100644 --- a/DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp +++ b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.cpp @@ -94,6 +94,30 @@ MainWindow::MainWindow(QWidget *parent) for (std::vector::iterator i = arrBooleanButtons.begin(); i != arrBooleanButtons.end(); i++) connect((QPushButton*)(*i), &QPushButton::clicked, this, &MainWindow::SetCommand); + + // Aggplus::CGraphicsPath *path1 = new Aggplus::CGraphicsPath; + // path1->StartFigure(); + // path1->MoveTo(200.0, 200.0); + // path1->LineTo(-200.0, 200.0); + // path1->LineTo(-200.0, -200.0); + // path1->LineTo(200.0, -200.0); + // path1->LineTo(200.0, 200.0); + // path1->CloseFigure(); + // SetCoords(ui->label_4, path1); + + // Aggplus::CGraphicsPath *path2 = new Aggplus::CGraphicsPath; + // path2->StartFigure(); + // path2->MoveTo(-100.0, -100.0); + // path2->LineTo(300.0, -100.0); + // path2->LineTo(300.0, 300.0); + // path2->LineTo(-100.0, 300.0); + // path2->LineTo(-100.0, -100.0); + // path2->CloseFigure(); + // SetCoords(ui->label_5, path2); + + // Aggplus::CGraphicsPath *result = Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection); + // Draw(result); + // SetCoords(ui->label_7, result); } void MainWindow::SetFigure() @@ -184,20 +208,20 @@ void MainWindow::AddPath(NSGraphics::IGraphicsRenderer* pathRenderer, Aggplus::C size_t length = path->GetPointCount(); std::vector points = path->GetPoints(0, length); - pathRenderer->PathCommandMoveTo(points[0].X, points[0].Y); - for (size_t i = 1; i < length; i++) + for (size_t i = 0; i < length; i++) { if (path->IsCurvePoint(i)) { - pathRenderer->PathCommandCurveTo(points[i].X, points[i].Y, points[i + 1].X, - points[i + 1].Y,points[i + 2].X, points[i + 2].Y); + pathRenderer->PathCommandCurveTo(points[i].X + NEGATIVE_OFFSET, points[i].Y + NEGATIVE_OFFSET, + points[i + 1].X + NEGATIVE_OFFSET, points[i + 1].Y + NEGATIVE_OFFSET, + points[i + 2].X + NEGATIVE_OFFSET, points[i + 2].Y + NEGATIVE_OFFSET); i += 2; } else if (path->IsMovePoint(i)) - pathRenderer->PathCommandMoveTo(points[i].X, points[i].Y); + pathRenderer->PathCommandMoveTo(points[i].X + NEGATIVE_OFFSET, points[i].Y + NEGATIVE_OFFSET); else - pathRenderer->PathCommandLineTo(points[i].X, points[i].Y); + pathRenderer->PathCommandLineTo(points[i].X + NEGATIVE_OFFSET, points[i].Y + NEGATIVE_OFFSET); } if (isResult) @@ -301,12 +325,12 @@ void MainWindow::CheckMousePress() return; } - QRectF rect1(RECTANGLE[0] + Offsets[0], - RECTANGLE[1] + Offsets[1], + QRectF rect1(RECTANGLE[0] + NEGATIVE_OFFSET + Offsets[0], + RECTANGLE[1] + NEGATIVE_OFFSET + Offsets[1], Scale[0] * RECTANGLE[2], Scale[0] * RECTANGLE[3]), - rect2(RECTANGLE[0] + Offsets[2], - RECTANGLE[1] + Offsets[3], + rect2(RECTANGLE[0] + NEGATIVE_OFFSET + Offsets[2], + RECTANGLE[1] + NEGATIVE_OFFSET + Offsets[3], Scale[1] * RECTANGLE[2], Scale[1] * RECTANGLE[3]); diff --git a/DesktopEditor/graphics/tests/booleanPaths/mainwindow.h b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.h index 86b5551c74..695050a83d 100644 --- a/DesktopEditor/graphics/tests/booleanPaths/mainwindow.h +++ b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.h @@ -14,7 +14,8 @@ class MainWindow; } QT_END_NAMESPACE -const double RECTANGLE[4] = {0.0, 0.0, 200.0, 200.0}; +const double NEGATIVE_OFFSET= 400.0; +const double RECTANGLE[4] = {-400.0, -400.0, 200.0, 200.0}; const double TRIANGLE[6] = {100.0, 0.0, 200.0, 200.0, 0.0, 100.0}; class CustomLabel : public QLabel @@ -81,12 +82,9 @@ public: private slots: void CheckMousePress(); void Move(); - void SetCommand(); void SetFigure(); - void on_horizontalSlider_sliderMoved(int position); - void on_horizontalSlider_2_sliderMoved(int position); public: diff --git a/DesktopEditor/graphics/tests/booleanPaths/mainwindow.ui b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.ui index 746db8ea2c..11cc9a2aaf 100644 --- a/DesktopEditor/graphics/tests/booleanPaths/mainwindow.ui +++ b/DesktopEditor/graphics/tests/booleanPaths/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1124 - 553 + 1441 + 859 @@ -19,8 +19,8 @@ 0 0 - 500 - 500 + 800 + 800 @@ -30,7 +30,7 @@ - 520 + 810 0 610 500 @@ -94,7 +94,7 @@ 10 - 270 + 250 63 20 @@ -107,9 +107,9 @@ 10 - 290 + 270 170 - 180 + 200 @@ -141,6 +141,19 @@ Qt::Horizontal + + + + 10 + 170 + 63 + 20 + + + + Scale: + + @@ -197,7 +210,7 @@ 10 - 270 + 250 63 20 @@ -210,9 +223,9 @@ 10 - 290 + 270 170 - 180 + 200 @@ -244,6 +257,19 @@ Qt::Horizontal + + + + 10 + 170 + 63 + 20 + + + + Scale: + + @@ -251,7 +277,7 @@ 410 10 191 - 320 + 480 @@ -261,7 +287,7 @@ 10 - 160 + 250 63 20 @@ -274,9 +300,9 @@ 10 - 180 + 270 170 - 130 + 200 @@ -333,7 +359,7 @@ 0 0 - 1124 + 1441 21