From 9e1e641218471c6270851e8f7afa04c95cd480f0 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Fri, 29 Mar 2024 12:37:31 +0300 Subject: [PATCH 01/13] Add test for Linear and Radial gradients --- .../gradient/Gradient/Gradient.pro | 2 + .../gradient/Gradient/mainwindow.cpp | 587 ++------- .../gradient/Gradient/mainwindow.h | 60 +- .../gradient/Gradient/mainwindow.ui | 1149 ++++++++--------- 4 files changed, 692 insertions(+), 1106 deletions(-) diff --git a/Test/Applications/gradient/Gradient/Gradient.pro b/Test/Applications/gradient/Gradient/Gradient.pro index 651d8d614e..e72b388caa 100644 --- a/Test/Applications/gradient/Gradient/Gradient.pro +++ b/Test/Applications/gradient/Gradient/Gradient.pro @@ -1,5 +1,7 @@ QT += core gui widgets +QMAKE_CXXFLAGS += /permissive- + SOURCES += \ main.cpp \ mainwindow.cpp diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index d7db1069d8..50178652d0 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -26,6 +26,8 @@ MainWindow::MainWindow(QWidget *parent) ui->setupUi(this); ui->lable_test->setStyleSheet("QLabel { background-color : white;}"); points = {{0, 0}, {105, 0}, {105, 105}, {0, 105}}; + ui->stackedWidget->setCurrentIndex(0); + ui->statusbar->showMessage("Linear"); } @@ -98,533 +100,152 @@ void GenerateImg(QImage &img, std::vector &points, Info &info) { } } - - -void MainWindow::on_RenderPic_clicked() +void MainWindow::on_actionLinear_Gradient_triggered() { - /* - CApplicationFontsWorker oWorker; - oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache"; - oWorker.m_bIsNeedThumbnails = false; - if (!NSDirectory::Exists(oWorker.m_sDirectory)) - NSDirectory::CreateDirectory(oWorker.m_sDirectory); - - NSFonts::IApplicationFonts* pFonts = oWorker.Check(); - PdfReader::CPdfReader PDFREADER(pFonts); - PDFREADER.LoadFromFile(L"test.pdf"); - int page = ui->lineEdit->text().toInt(); - PDFREADER.ConvertToRaster(page + 1, L"testpdf.bmp", 1); - */ - - // QImage pm("testpdf.bmp"); - QImage pm(400, 400, QImage::Format_RGB888); - GenerateImg(pm, points, info); - //setColor2(pm, 0x0000FF); - //pm.invertPixels(); - ui->lable_test->setPixmap(QPixmap::fromImage(pm)); - ui->lable_test->setScaledContents(true); - // ui->lable_test->resize(pm.size()); - //pm.save("test.bmp"); - - // pFonts->Release(); + ui->stackedWidget->setCurrentIndex(0); + ui->statusbar->showMessage("Linear"); + info.gradient_type = c_BrushTypePathNewLinearGradient; } -void MainWindow::on_GradientType_itemDoubleClicked(QListWidgetItem *item) +void MainWindow::on_actionRadial_Gradient_triggered() { - on_GradientType_itemClicked(item); - on_RenderPic_clicked(); + ui->stackedWidget->setCurrentIndex(1); + ui->statusbar->showMessage("Radial"); + info.gradient_type = c_BrushTypePathRadialGradient; } -void MainWindow::on_GradientType_itemClicked(QListWidgetItem *item) +void MainWindow::on_BAW_Colorspace_Radio_Button_clicked() { - points = {{0, 0}, {105, 0}, {105, 105}, {0, 105}}; - if (item->text() == "Linear") { - info.gradient_type = c_BrushTypePathNewLinearGradient; + info.colorspace = BlackAndWhite; +} + +void MainWindow::on_RAB_Colorspace_Radio_Button_clicked() +{ + info.colorspace = RedAndBlue; +} + +void MainWindow::on_Pastel_Colorspace_Radio_Button_clicked() +{ + info.colorspace = Pastel; +} +void MainWindow::on_Rainbow_Colorspace_Radio_Button_clicked() +{ + info.colorspace = Rainbow; +} + +void MainWindow::on_pushButton_clicked() +{ + if (info.gradient_type == c_BrushTypePathNewLinearGradient) { + if (ui->First_X_Coordinate_Input->text() == "") { + ui->statusbar->showMessage("First X coordinate = NULL"); + return; + } + info.p0.x = ui->First_X_Coordinate_Input->text().toInt(); + if (ui->First_Y_Coordinate_Input->text() == "") { + ui->statusbar->showMessage("First Y coordinate = NULL"); + return; + } + info.p0.y = ui->First_Y_Coordinate_Input->text().toInt(); + if (ui->Second_X_Coordinate_Input->text() == "") { + ui->statusbar->showMessage("First X coordinate = NULL"); + return; + } + info.p1.x = ui->Second_X_Coordinate_Input->text().toInt(); + if (ui->Second_Y_Coordinate_Input->text() == "") { + ui->statusbar->showMessage("First X coordinate = NULL"); + return; + } + info.p1.y = ui->Second_Y_Coordinate_Input->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - } - else if (item->text() == "Radial") { - info.gradient_type = c_BrushTypePathRadialGradient; + } else if (info.gradient_type == c_BrushTypePathRadialGradient) { + if (ui->First_Center_X_Coordinate_Input->text() == "") { + ui->statusbar->showMessage("First Center X coordinate = NULL"); + return; + } + info.c0.x = ui->First_Center_X_Coordinate_Input->text().toInt(); + if (ui->First_Center_Y_Coordinate_Input->text() == "") { + ui->statusbar->showMessage("First Center Y coordinate = NULL"); + return; + } + info.c0.y = ui->First_Center_Y_Coordinate_Input->text().toInt(); + if (ui->Second_Center_X_Coordinate_Input->text() == "") { + ui->statusbar->showMessage("First Center X coordinate = NULL"); + return; + } + info.c1.x = ui->Second_Center_X_Coordinate_Input->text().toInt(); + if (ui->Second_Center_Y_Coordinate_Input->text() == "") { + ui->statusbar->showMessage("First Center X coordinate = NULL"); + return; + } + info.c1.y = ui->Second_Center_Y_Coordinate_Input->text().toInt(); + if (ui->First_Radius_Input->text() == "") { + ui->statusbar->showMessage("First Radius = NUll"); + return; + } + info.r0 = ui->First_Radius_Input->text().toInt(); + if (ui->Second_Radius_Input->text() == "") { + ui->statusbar->showMessage("Second Radius = NULL"); + return; + } + info.r1 = ui->Second_Radius_Input->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); + 0, 1, info.cont_b, info.cont_f); } - else if (item->text() == "Triangle") { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {}, false - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - } - else if (item->text() == "Functional" ) { - info.gradient_type = c_BrushTypePathNewLinearGradient; - info.ginfo = NSStructures::GInfoConstructor::get_functional(0, 1, 0, 1, - {400, 0, 0, 400, 0, 0}); - } - else if (item->text() == "TriangleParametric" ) { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.4f, 1.f}, true - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - } - else if (item->text() == "CoonsPatch" ) { - info.gradient_type = c_BrushTypePathNewLinearGradient; - info.ginfo = NSStructures::GInfoConstructor::get_curve( - { - {100, 300}, {50, 250}, {150, 150}, {100, 100}, - {150, 50}, {250, 150}, {300, 100}, {250, 150}, - {350, 250}, {300, 300}, {250, 350}, {150,250} - }, - {0, 0.5, 1, 0.5}, - {{0, 0, 255}, {255, 0, 255}, - {255, 0, 0}, {0, 255, 0}}, - false - ); - } - else if (item->text() == "TesnorCoonsPatch" ) { - info.gradient_type = c_BrushTypePathNewLinearGradient; - info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve( - { - {{100, 300}, {150, 250}, {50, 150}, {100,100}}, - {{150, 250}, {170, 230}, {170, 170}, {50, 150}}, - {{350, 250}, {230, 230}, {230, 170}, {150, 250}}, - {{300, 300}, {250, 250}, {350, 150}, {300, 100}} - }, - {{0, 0.5}, {1, 0.5}}, - {{{0, 0, 255}, {255, 0, 255}}, {{255, 0, 0}, {0, 255, 0}}}, - false - ); - } - else if (item->text() == "CoonsPatchParametric") { - info.gradient_type = c_BrushTypeCurveGradient; - info.ginfo = NSStructures::GInfoConstructor::get_curve( - { - {100, 300}, {50, 250}, {150, 150}, {100, 100}, - {150, 50}, {250, 150}, {300, 100}, {250, 150}, - {350, 250}, {300, 300}, {250, 350}, {150,250} - }, - {0, 0.5, 1, 0.5}, - {{0, 0, 255}, {255, 0, 255}, - {255, 0, 0}, {0, 255, 0}}, - true - ); - } - else if (item->text() == "TensorCoonsPatchParametric") { - info.gradient_type = c_BrushTypeTensorCurveGradient; - info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve( - { - {{100, 300}, {150, 250}, {50, 150}, {100,100}}, - {{150, 250}, {170, 230}, {170, 170}, {50, 150}}, - {{350, 250}, {230, 230}, {230, 170}, {150, 250}}, - {{300, 300}, {250, 250}, {350, 150}, {300, 100}} - }, - {{0, 0.5}, {1, 0.5}}, - {{{0, 0, 255}, {255, 0, 255}}, {{255, 0, 0}, {0, 255, 0}}}, - true - ); - } -} - - - -void MainWindow::on_ColorSpaces_itemClicked(QListWidgetItem *item) -{ - - if (item->text() == "Rainbow") { + if (info.colorspace == NoColorspaceType) { + ui->statusbar->showMessage("Colorspace - NULL"); + return; + } else if (info.colorspace == Rainbow) { info.c = {(LONG)0xFFff0000, (LONG)0xFFffa500, (LONG)0xFFffff00, (LONG)0xFF008000, (LONG)0xFF0000ff, (LONG)0xFFFF00FF}; info.p = {0.0,0.2,0.4,0.6,0.8,1}; info.n_colors = 6; info.ginfo.shading.function.set_linear_interpolation({0xFFff0000, 0xFFffa500, 0xFFffff00, 0xFF008000, 0xFF0000ff, 0xFFFF00FF} , {0.0f,0.2f,0.4f,0.6f,0.8f,1.0f}); - } - else if (item->text() == "Black and white") { + } else if (info.colorspace == BlackAndWhite) { info.c = {(LONG)0xFFFFFFFF, (LONG)0xFF000000}; info.p = {0.0, 1}; info.n_colors = 2; info.ginfo.shading.function.set_linear_interpolation({0xFFFFFFFF, 0xFF000000}, {0.0f, 1.0f}); - } - else if (item->text() == "Red Blue") { + } else if (info.colorspace == RedAndBlue) { info.c = {(LONG)0xFFFF0000, (LONG)0xFF0000FF}; info.p = {0.0, 1}; info.n_colors = 2; info.ginfo.shading.function.set_linear_interpolation({0xFFFF0000, 0xFF0000FF}, {0.0f, 1.0f}); - } - else if (item->text() == "Pastel") { + } else if (info.colorspace == Pastel) { info.c = {(LONG)0xfff39189, (LONG)0xff046582}; info.p = {0.0, 1}; info.n_colors = 2; info.ginfo.shading.function.set_linear_interpolation({0xfff39189, 0xff046582}, {0.0f, 1.0f}); } + + QImage pm(400, 400, QImage::Format_RGB888); + GenerateImg(pm, points, info); + ui->lable_test->setPixmap(QPixmap::fromImage(pm)); + ui->lable_test->setScaledContents(true); } -void MainWindow::on_ColorSpaces_itemDoubleClicked(QListWidgetItem *item) + +void MainWindow::on_Continue_Shading_Forward_clicked(bool checked) { - on_ColorSpaces_itemClicked(item); - on_RenderPic_clicked(); + info.cont_f = checked; } -void MainWindow::on_Point1X_sliderMoved(int position) -{ - info.p0.x= position; - if (info.gradient_type != c_BrushTypePathNewLinearGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_Point1Y_sliderMoved(int position) -{ - info.p0.y = position; - if (info.gradient_type != c_BrushTypePathNewLinearGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_Point2X_sliderMoved(int position) -{ - info.p1.x = position; - if (info.gradient_type != c_BrushTypePathNewLinearGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_Point2Y_sliderMoved(int position) -{ - info.p1.y = position; - if (info.gradient_type != c_BrushTypePathNewLinearGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - - -void MainWindow::on_CenterX0_valueChanged(int value) -{ - info.c0.x = value; - if (info.gradient_type != c_BrushTypePathRadialGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_CenterY0_valueChanged(int value) -{ - info.c0.y = value; - if (info.gradient_type != c_BrushTypePathRadialGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_CenterX1_valueChanged(int value) -{ - info.c1.x = value; - if (info.gradient_type != c_BrushTypePathRadialGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_CenterY1_valueChanged(int value) -{ - info.c1.y= value; - if (info.gradient_type != c_BrushTypePathRadialGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_r0slider_valueChanged(int value) -{ - info.r0 = value; - if (info.gradient_type != c_BrushTypePathRadialGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_r1slider_valueChanged(int value) -{ - info.r1 = value; - if (info.gradient_type != c_BrushTypePathRadialGradient) return; - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); -} - -void MainWindow::on_ContinueForvard_clicked(bool checked) -{ - info.cont_f= checked; - if (info.gradient_type == c_BrushTypePathNewLinearGradient) - { - info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); - } - if (info.gradient_type == c_BrushTypePathRadialGradient) - { - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); - } -} - -void MainWindow::on_ContinueBack_clicked(bool checked) +void MainWindow::on_checkBox_2_clicked(bool checked) { info.cont_b = checked; - if (info.gradient_type == c_BrushTypePathNewLinearGradient) - { - info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); - } - if (info.gradient_type == c_BrushTypePathRadialGradient) - { - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - on_RenderPic_clicked(); - } } - -void MainWindow::on_TrianglePoint1X_sliderMoved(int position) +void MainWindow::on_Continue_Shading_Forward_2_clicked(bool checked) { - - info.triangle[0].x = position; - if (info.ginfo.shading.shading_type == NSStructures::ShadingInfo::TriangleInterpolation) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {}, false - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - return; - } - else if (info.gradient_type == c_BrushTypeTriagnleMeshGradient) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.4f, 1.f}, true - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - } + info.cont_f = checked; } -void MainWindow::on_TrianglePoint1Y_sliderMoved(int position) + +void MainWindow::on_Continue_Shading_Backward_2_clicked(bool checked) { - info.triangle[0].y = position; - if (info.ginfo.shading.shading_type == NSStructures::ShadingInfo::TriangleInterpolation) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {}, false - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - return; - } - else if (info.gradient_type == c_BrushTypeTriagnleMeshGradient) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.4f, 1.f}, true - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - } + info.cont_b = checked; } -void MainWindow::on_TrianglePoint2X_sliderMoved(int position) -{ - info.triangle[1].x = position; - if (info.ginfo.shading.shading_type == NSStructures::ShadingInfo::TriangleInterpolation) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {}, false - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - return; - } - else if (info.gradient_type == c_BrushTypeTriagnleMeshGradient) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.4f, 1.f}, true - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - } -} - -void MainWindow::on_TrianglePoint2Y_sliderMoved(int position) -{ - info.triangle[1].y = position; - if (info.ginfo.shading.shading_type == NSStructures::ShadingInfo::TriangleInterpolation) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {}, false - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - return; - } - else if (info.gradient_type == c_BrushTypeTriagnleMeshGradient) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.4f, 1.f}, true - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - } -} - -void MainWindow::on_TrianglePoint3X_sliderMoved(int position) -{ - info.triangle[2].x = position; - if (info.ginfo.shading.shading_type == NSStructures::ShadingInfo::TriangleInterpolation) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {}, false - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - return; - } - else if (info.gradient_type == c_BrushTypeTriagnleMeshGradient) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.4f, 1.f}, true - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - } -} - -void MainWindow::on_TrianglePoint3Y_sliderMoved(int position) -{ - info.triangle[2].y = position; - if (info.ginfo.shading.shading_type == NSStructures::ShadingInfo::TriangleInterpolation) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {}, false - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - return; - } - else if (info.gradient_type == c_BrushTypeTriagnleMeshGradient) - { - info.gradient_type = c_BrushTypeTriagnleMeshGradient; - info.ginfo = NSStructures::GInfoConstructor::get_triangle( - info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.4f, 1.f}, true - ); - points = {}; - for (auto p : info.triangle) - { - points.push_back({p.x / 3.84, p.y / 3.84}); - } - on_RenderPic_clicked(); - } -} - -void MainWindow::on_LeftButton_clicked() -{ - int page = ui->lineEdit->text().toInt(); - ui->lineEdit->setText(QString::number(page - 1)); - on_RenderPic_clicked(); -} - -void MainWindow::on_RightButton_clicked() -{ - int page = ui->lineEdit->text().toInt(); - ui->lineEdit->setText(QString::number(page + 1)); - on_RenderPic_clicked(); -} diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index 9c2dedfcf7..935902d0eb 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -10,6 +10,14 @@ QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE +typedef enum { + NoColorspaceType, + Rainbow, + BlackAndWhite, + RedAndBlue, + Pastel +} ColorspaceType; + struct Point { Point(double _x = 0, double _y = 0) : x(_x), y(_y){} double x, y; @@ -30,7 +38,8 @@ struct Color { }; struct Info { - // Для теста адаптора все вынес в инфо. + ColorspaceType colorspace = NoColorspaceType; + float r0, r1; NSStructures::Point c0, c1; NSStructures::Point p0, p1; @@ -78,55 +87,28 @@ public: Info info; private slots: - void on_RenderPic_clicked(); - void on_GradientType_itemDoubleClicked(QListWidgetItem *item); + void on_actionLinear_Gradient_triggered(); - void on_GradientType_itemClicked(QListWidgetItem *item); + void on_actionRadial_Gradient_triggered(); - void on_ColorSpaces_itemClicked(QListWidgetItem *item); + void on_BAW_Colorspace_Radio_Button_clicked(); - void on_ColorSpaces_itemDoubleClicked(QListWidgetItem *item); + void on_RAB_Colorspace_Radio_Button_clicked(); - void on_Point1X_sliderMoved(int position); + void on_Pastel_Colorspace_Radio_Button_clicked(); - void on_Point1Y_sliderMoved(int position); + void on_Rainbow_Colorspace_Radio_Button_clicked(); - void on_Point2X_sliderMoved(int position); + void on_pushButton_clicked(); - void on_Point2Y_sliderMoved(int position); + void on_Continue_Shading_Forward_clicked(bool checked); - void on_CenterX0_valueChanged(int value); + void on_checkBox_2_clicked(bool checked); - void on_CenterY0_valueChanged(int value); + void on_Continue_Shading_Forward_2_clicked(bool checked); - void on_CenterX1_valueChanged(int value); - - void on_CenterY1_valueChanged(int value); - - void on_r0slider_valueChanged(int value); - - void on_r1slider_valueChanged(int value); - - void on_ContinueForvard_clicked(bool checked); - - void on_ContinueBack_clicked(bool checked); - - void on_TrianglePoint1X_sliderMoved(int position); - - void on_TrianglePoint1Y_sliderMoved(int position); - - void on_TrianglePoint2X_sliderMoved(int position); - - void on_TrianglePoint2Y_sliderMoved(int position); - - void on_TrianglePoint3X_sliderMoved(int position); - - void on_TrianglePoint3Y_sliderMoved(int position); - - void on_LeftButton_clicked(); - - void on_RightButton_clicked(); + void on_Continue_Shading_Backward_2_clicked(bool checked); private: Ui::MainWindow *ui; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index e743183e25..01316d85be 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1025 - 651 + 1098 + 706 @@ -17,598 +17,567 @@ true - - - - 0 - 0 - 400 - 400 - - - - QFrame::Box - - - QFrame::Sunken - - - - - - - - - 600 - 540 - 171 - 51 - - - - RenderPic - - - false - - - - - - 20 - 400 - 171 - 161 - - + - - Functional - + + + + + - - Linear - + + + + 535 + 0 + + + + + 535 + 16777215 + + + + + + + + + 10 + 10 + 201 + 161 + + + + + 201 + 161 + + + + + 201 + 161 + + + + Choose gradient colorspace + + + + + 20 + 30 + 112 + 26 + + + + Rainbow + + + + + + 20 + 60 + 161 + 26 + + + + Black and White + + + + + + 20 + 90 + 131 + 26 + + + + Red and Blue + + + + + + 20 + 120 + 112 + 26 + + + + Pastel + + + + + + + 10 + 180 + 511 + 401 + + + + 1 + + + + + + 0 + 0 + 371 + 160 + + + + Set Coordinates + + + + + 10 + 30 + 158 + 20 + + + + X Coordinate, First Point + + + + + + 10 + 50 + 113 + 28 + + + + + + + 10 + 80 + 157 + 20 + + + + Y Coordinate, First Point + + + + + + 10 + 100 + 113 + 28 + + + + + + + 180 + 30 + 180 + 20 + + + + X Coordinate, Second Point + + + + + + 180 + 50 + 113 + 28 + + + + + + + 180 + 80 + 179 + 20 + + + + Y Coordinate, Second Point + + + + + + 180 + 100 + 113 + 28 + + + + + + + + 380 + 0 + 131 + 161 + + + + Continue Shading + + + + + 20 + 50 + 93 + 26 + + + + Forward + + + + + + 20 + 100 + 93 + 26 + + + + Backward + + + + + + + 10 + 170 + 415 + 20 + + + + A linear gradient describes a color change along a straight line + + + Qt::AutoText + + + + + + 10 + 190 + 415 + 20 + + + + that is defined by two points. + + + Qt::AutoText + + + + + + + + 380 + 180 + 131 + 161 + + + + Continue Shading + + + + + 20 + 50 + 93 + 26 + + + + Forward + + + + + + 20 + 100 + 93 + 26 + + + + Backward + + + + + + + 0 + 10 + 510 + 160 + + + + Set Coordinates Of Circle Centers + + + + + 20 + 30 + 168 + 20 + + + + X Coordinate, First Center + + + + + + 20 + 50 + 113 + 28 + + + + + + + 20 + 80 + 167 + 20 + + + + Y Coordinate, First Center + + + + + + 20 + 100 + 113 + 28 + + + + + + + 280 + 30 + 187 + 20 + + + + Second Center X Coordinate + + + + + + 280 + 50 + 113 + 28 + + + + + + + 280 + 80 + 186 + 20 + + + + Second Center Y Coordinate + + + + + + 280 + 100 + 113 + 28 + + + + + + + + 0 + 180 + 371 + 100 + + + + Set Radius Of Circle + + + + + 20 + 30 + 75 + 20 + + + + First Radius + + + + + + 200 + 30 + 97 + 20 + + + + Second Radius + + + + + + 20 + 50 + 113 + 28 + + + + + + + 200 + 50 + 113 + 28 + + + + + + + + 0 + 290 + 319 + 20 + + + + Radial gradient describes the color change from + + + + + + 0 + 310 + 335 + 20 + + + + the center to the edges, it is defined by two circles, + + + + + + 0 + 330 + 281 + 20 + + + + which are defined by the center and radius + + + + + + + + 300 + 80 + 117 + 29 + + + + Render Gradient + + + - - - Radial - - - - - Triangle - - - - - CoonsPatch - - - - - TesnorCoonsPatch - - - - - TriangleParametric - - - - - CoonsPatchParametric - - - - - TensorCoonsPatchParametric - - - - - - - 20 - 570 - 101 - 16 - - - - Gradient Type - - - - - - 210 - 400 - 121 - 161 - - - - - Rainbow - - - - - Black and white - - - - - Red Blue - - - - - Pastel - - - - - - - 230 - 570 - 58 - 16 - - - - Colours - - - - - - 340 - 530 - 141 - 41 - - - - Double Click to change - - - - - - 460 - 30 - 160 - 16 - - - - 400 - - - Qt::Horizontal - - - - - - 460 - 60 - 160 - 16 - - - - 400 - - - Qt::Horizontal - - - - - - 460 - 90 - 160 - 16 - - - - 400 - - - 400 - - - Qt::Horizontal - - - - - - 460 - 120 - 160 - 16 - - - - 400 - - - 400 - - - Qt::Horizontal - - - - - - 460 - 10 - 151 - 18 - - - - Points XY Linear - - - - - - 740 - 170 - 58 - 18 - - - - r0 r1 - - - - - - 720 - 200 - 160 - 16 - - - - 200 - - - Qt::Horizontal - - - - - - 720 - 230 - 160 - 16 - - - - 200 - - - 100 - - - Qt::Horizontal - - - - - - 720 - 30 - 160 - 16 - - - - 400 - - - 200 - - - Qt::Horizontal - - - - - - 720 - 60 - 160 - 16 - - - - 400 - - - 200 - - - Qt::Horizontal - - - - - - 720 - 90 - 160 - 16 - - - - 400 - - - 200 - - - Qt::Horizontal - - - - - - 720 - 120 - 160 - 16 - - - - 400 - - - 200 - - - Qt::Horizontal - - - - - - 740 - 10 - 131 - 18 - - - - CenterXY Radial - - - - - - 380 - 420 - 141 - 24 - - - - Continue Forward - - - - - - 380 - 460 - 141 - 24 - - - - Continue Back - - - - - - 440 - 190 - 160 - 16 - - - - 400 - - - 100 - - - Qt::Horizontal - - - - - - 440 - 220 - 160 - 16 - - - - 400 - - - 100 - - - Qt::Horizontal - - - - - - 440 - 290 - 160 - 16 - - - - 400 - - - 200 - - - Qt::Horizontal - - - - - - 440 - 260 - 160 - 16 - - - - 400 - - - 300 - - - Qt::Horizontal - - - - - - 440 - 350 - 160 - 16 - - - - 400 - - - 350 - - - Qt::Horizontal - - - - - - 440 - 320 - 160 - 16 - - - - 400 - - - 200 - - - Qt::Horizontal - - - - - - 420 - 170 - 111 - 16 - - - - XY triangle - - - - - - 770 - 320 - 54 - 17 - - - - PDF - - - - - - 680 - 400 - 80 - 25 - - - - Left - - - - - - 790 - 400 - 80 - 25 - - - - Right - - - - - - 730 - 360 - 113 - 25 - - - - 746 - - + 0 0 - 1025 - 23 + 1098 + 25 @@ -623,7 +592,19 @@ false + + + + + Linear Gradient + + + + + Radial Gradient + + From cd86a8a3c7a30c4715c8f6abd49dd0d157c5a061 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Tue, 2 Apr 2024 00:47:50 +0300 Subject: [PATCH 02/13] fix image size and GenerateImg method --- .../gradient/Gradient/mainwindow.cpp | 139 ++- .../gradient/Gradient/mainwindow.h | 22 +- .../gradient/Gradient/mainwindow.ui | 988 +++++++++--------- 3 files changed, 630 insertions(+), 519 deletions(-) diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index 50178652d0..b3b60008b4 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -7,15 +7,15 @@ #include "../../../../DesktopEditor/common/Directory.h" #include "../../../../PdfFile/PdfFile.h" -std::vector drawCircle1(int n, double cx, double cy, double r) { - std::vector res; - for (int i = 0; i < n; i++) { - double x = cx + r * cos(i * 8 * atan(1) / n); - double y = cy + r * sin(i * 8 * atan(1) / n); - res.push_back({x, y}); - } - return res; -} +// std::vector drawCircle1(int n, double cx, double cy, double r) { +// std::vector res; +// for (int i = 0; i < n; i++) { +// double x = cx + r * cos(i * 8 * atan(1) / n); +// double y = cy + r * sin(i * 8 * atan(1) / n); +// res.push_back({x, y}); +// } +// return res; +// } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -25,7 +25,7 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); ui->lable_test->setStyleSheet("QLabel { background-color : white;}"); - points = {{0, 0}, {105, 0}, {105, 105}, {0, 105}}; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; ui->stackedWidget->setCurrentIndex(0); ui->statusbar->showMessage("Linear"); } @@ -37,14 +37,17 @@ MainWindow::~MainWindow() delete ui; } +void CleanupFunction(void* data) { + delete[] data; +} -void GenerateImg(QImage &img, std::vector &points, Info &info) { +QImage GenerateImg(std::vector &points, Info &info) { NSGraphics::IGraphicsRenderer* pRasterRenderer = NSGraphics::Create(); NSFonts::IFontManager *fmp = NSFonts::NSFontManager::Create(); pRasterRenderer->SetFontManager(fmp); - int nRasterW = img.size().width(); - int nRasterH = img.size().height(); + int nRasterW = 500; + int nRasterH = 500; BYTE* pData = new BYTE[4 * nRasterW * nRasterH]; unsigned int back = 0xffffff; @@ -61,16 +64,15 @@ void GenerateImg(QImage &img, std::vector &points, Info &info) { oFrame.put_Stride(4 * nRasterW); pRasterRenderer->CreateFromBgraFrame(&oFrame); - pRasterRenderer->SetSwapRGB(true); + pRasterRenderer->SetSwapRGB(false); - double dW_MM = nRasterW * 25.4 / 96; - double dH_MM = nRasterH * 25.4 / 96; + double dW_MM = nRasterW /** 25.4 / 96*/; + double dH_MM = nRasterH /** 25.4 / 96*/; pRasterRenderer->put_Width(dW_MM); pRasterRenderer->put_Height(dH_MM); NSStructures::GradientInfo ginfo = info.ginfo; - //ginfo.reflected = true; ginfo.shading.f_type = NSStructures::ShadingInfo::UseNew; pRasterRenderer->put_BrushGradInfo(ginfo); auto a = info.c; @@ -89,15 +91,12 @@ void GenerateImg(QImage &img, std::vector &points, Info &info) { } } pRasterRenderer->Fill(); - //pRasterRenderer->DrawPath(c_nStroke); pRasterRenderer->EndCommand(c_nPathType); pRasterRenderer->PathCommandEnd(); - pData32 = (unsigned int*)pData; - for (long i = 0; i < img.size().height(); i++) { - for (long j = 0; j < img.size().width(); j++) { - img.setPixelColor(j, i, QColor(pData32[j + i * nRasterW])); - } - } + + QImage img = QImage(pData, 500, 500, QImage::Format_RGBA8888, CleanupFunction); + oFrame.put_Data(NULL); + return img; } void MainWindow::on_actionLinear_Gradient_triggered() @@ -219,8 +218,7 @@ void MainWindow::on_pushButton_clicked() info.ginfo.shading.function.set_linear_interpolation({0xfff39189, 0xff046582}, {0.0f, 1.0f}); } - QImage pm(400, 400, QImage::Format_RGB888); - GenerateImg(pm, points, info); + QImage pm = GenerateImg(points, info); ui->lable_test->setPixmap(QPixmap::fromImage(pm)); ui->lable_test->setScaledContents(true); } @@ -249,3 +247,92 @@ void MainWindow::on_Continue_Shading_Backward_2_clicked(bool checked) info.cont_b = checked; } + +void MainWindow::on_First_X_Coordinate_Input_editingFinished() +{ + if (ui->First_X_Coordinate_Input->text().toInt() < 0) + ui->First_X_Coordinate_Input->setText("0"); + if (ui->First_X_Coordinate_Input->text().toInt() > 500) + ui->First_X_Coordinate_Input->setText("500"); +} + + +void MainWindow::on_First_Y_Coordinate_Input_editingFinished() +{ + if (ui->First_Y_Coordinate_Input->text().toInt() < 0) + ui->First_Y_Coordinate_Input->setText("0"); + if (ui->First_Y_Coordinate_Input->text().toInt() > 500) + ui->First_Y_Coordinate_Input->setText("500"); +} + +void MainWindow::on_Second_X_Coordinate_Input_editingFinished() +{ + if (ui->Second_X_Coordinate_Input->text().toInt() < 0) + ui->Second_X_Coordinate_Input->setText("0"); + if (ui->Second_X_Coordinate_Input->text().toInt() > 500) + ui->Second_X_Coordinate_Input->setText("500"); +} + + +void MainWindow::on_Second_Y_Coordinate_Input_editingFinished() +{ + if (ui->Second_Y_Coordinate_Input->text().toInt() < 0) + ui->Second_Y_Coordinate_Input->setText("0"); + if (ui->Second_Y_Coordinate_Input->text().toInt() > 500) + ui->Second_Y_Coordinate_Input->setText("500"); +} + + +void MainWindow::on_First_Center_X_Coordinate_Input_editingFinished() +{ + if (ui->First_Center_X_Coordinate_Input->text().toInt() < 0) + ui->First_Center_X_Coordinate_Input->setText("0"); + if (ui->First_Center_X_Coordinate_Input->text().toInt() > 499) + ui->First_Center_X_Coordinate_Input->setText("500"); +} + + +void MainWindow::on_First_Center_Y_Coordinate_Input_editingFinished() +{ + if (ui->First_Center_Y_Coordinate_Input->text().toInt() < 0) + ui->First_Center_Y_Coordinate_Input->setText("0"); + if (ui->First_Center_Y_Coordinate_Input->text().toInt() > 499) + ui->First_Center_Y_Coordinate_Input->setText("500"); +} + + +void MainWindow::on_Second_Center_X_Coordinate_Input_editingFinished() +{ + if (ui->Second_Center_X_Coordinate_Input->text().toInt() < 0) + ui->Second_Center_X_Coordinate_Input->setText("0"); + if (ui->Second_Center_X_Coordinate_Input->text().toInt() > 500) + ui->Second_Center_X_Coordinate_Input->setText("500"); +} + + +void MainWindow::on_Second_Center_Y_Coordinate_Input_editingFinished() +{ + if (ui->Second_Center_Y_Coordinate_Input->text().toInt() < 0) + ui->Second_Center_Y_Coordinate_Input->setText("0"); + if (ui->Second_Center_Y_Coordinate_Input->text().toInt() > 500) + ui->Second_Center_Y_Coordinate_Input->setText("500"); +} + + +void MainWindow::on_First_Radius_Input_editingFinished() +{ + if (ui->First_Radius_Input->text().toInt() < 0) + ui->First_Radius_Input->setText("0"); + if (ui->First_Radius_Input->text().toInt() > 500) + ui->First_Radius_Input->setText("500"); +} + + +void MainWindow::on_Second_Radius_Input_editingFinished() +{ + if (ui->Second_Radius_Input->text().toInt() < 0) + ui->Second_Radius_Input->setText("0"); + if (ui->Second_Radius_Input->text().toInt() > 500) + ui->Second_Radius_Input->setText("500"); +} + diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index 935902d0eb..c22f60a407 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -72,7 +72,7 @@ struct Info { } }; -void GenerateImg(QImage &img, int grad = 1,double angle = 0,std::vector points = {}); +QImage GenerateImg(int grad = 1,double angle = 0,std::vector points = {}); std::vector drawCircle1(int n, double cx, double cy, double r); class MainWindow : public QMainWindow { @@ -110,6 +110,26 @@ private slots: void on_Continue_Shading_Backward_2_clicked(bool checked); + void on_First_X_Coordinate_Input_editingFinished(); + + void on_First_Y_Coordinate_Input_editingFinished(); + + void on_Second_X_Coordinate_Input_editingFinished(); + + void on_Second_Y_Coordinate_Input_editingFinished(); + + void on_First_Center_X_Coordinate_Input_editingFinished(); + + void on_First_Center_Y_Coordinate_Input_editingFinished(); + + void on_Second_Center_X_Coordinate_Input_editingFinished(); + + void on_Second_Center_Y_Coordinate_Input_editingFinished(); + + void on_First_Radius_Input_editingFinished(); + + void on_Second_Radius_Input_editingFinished(); + private: Ui::MainWindow *ui; }; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index 01316d85be..15e61948c0 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1098 - 706 + 1053 + 602 @@ -17,566 +17,570 @@ true - - - + + + + 0 + 0 + 500 + 500 + + + + + 500 + 500 + + + + + + + + + + 510 + -10 + 535 + 511 + + + + + 535 + 0 + + + + + 535 + 16777215 + + + + + + + + + 10 + 10 + 201 + 150 + + + + Choose gradient colorspace + + + + + 20 + 30 + 112 + 26 + + - + Rainbow - - - - - - 535 - 0 - + + + + 20 + 60 + 161 + 26 + - - - 535 - 16777215 - + + Black and White - - + + + + + 20 + 90 + 131 + 26 + - + + Red and Blue + + + + + + 20 + 120 + 112 + 26 + + + + Pastel + + + + + + + 10 + 160 + 511 + 331 + + + + 1 + + + - 10 - 10 - 201 + 0 + 0 + 371 + 160 + + + + Set Coordinates + + + + + 10 + 30 + 158 + 20 + + + + X Coordinate, First Point + + + + + + 10 + 50 + 113 + 28 + + + + + + + 10 + 80 + 157 + 20 + + + + Y Coordinate, First Point + + + + + + 10 + 100 + 113 + 28 + + + + + + + 180 + 30 + 180 + 20 + + + + X Coordinate, Second Point + + + + + + 180 + 50 + 113 + 28 + + + + + + + 180 + 80 + 179 + 20 + + + + Y Coordinate, Second Point + + + + + + 180 + 100 + 113 + 28 + + + + + + + + 380 + 0 + 131 161 - - - 201 - 161 - + + Continue Shading - - - 201 + + + + 20 + 50 + 93 + 26 + + + + Forward + + + + + + 20 + 100 + 93 + 26 + + + + Backward + + + + + + + 10 + 170 + 415 + 20 + + + + A linear gradient describes a color change along a straight line + + + Qt::AutoText + + + + + + 10 + 190 + 415 + 20 + + + + that is defined by two points. + + + Qt::AutoText + + + + + + + + 380 + 160 + 131 161 - + - Choose gradient colorspace + Continue Shading - + + + + 20 + 50 + 93 + 26 + + + + Forward + + + + + + 20 + 100 + 93 + 26 + + + + Backward + + + + + + + 0 + 10 + 510 + 140 + + + + Set Coordinates Of Circle Centers + + 20 30 - 112 - 26 + 168 + 20 - Rainbow + X Coordinate, First Center - + 20 - 60 - 161 - 26 + 50 + 113 + 28 - - Black and White - - + 20 - 90 - 131 - 26 + 80 + 167 + 20 - Red and Blue + Y Coordinate, First Center - + 20 - 120 - 112 - 26 + 100 + 113 + 28 + + + + + + + 280 + 30 + 187 + 20 - Pastel + Second Center X Coordinate + + + + + + 280 + 50 + 113 + 28 + + + + + + + 280 + 80 + 186 + 20 + + + + Second Center Y Coordinate + + + + + + 280 + 100 + 113 + 28 + - + - 10 - 180 - 511 - 401 + 0 + 160 + 371 + 100 - - 1 + + Set Radius Of Circle - - - - - 0 - 0 - 371 - 160 - - - - Set Coordinates - - - - - 10 - 30 - 158 - 20 - - - - X Coordinate, First Point - - - - - - 10 - 50 - 113 - 28 - - - - - - - 10 - 80 - 157 - 20 - - - - Y Coordinate, First Point - - - - - - 10 - 100 - 113 - 28 - - - - - - - 180 - 30 - 180 - 20 - - - - X Coordinate, Second Point - - - - - - 180 - 50 - 113 - 28 - - - - - - - 180 - 80 - 179 - 20 - - - - Y Coordinate, Second Point - - - - - - 180 - 100 - 113 - 28 - - - - - - - - 380 - 0 - 131 - 161 - - - - Continue Shading - - - - - 20 - 50 - 93 - 26 - - - - Forward - - - - - - 20 - 100 - 93 - 26 - - - - Backward - - - - - - - 10 - 170 - 415 - 20 - - - - A linear gradient describes a color change along a straight line - - - Qt::AutoText - - - - - - 10 - 190 - 415 - 20 - - - - that is defined by two points. - - - Qt::AutoText - - + + + + 20 + 30 + 75 + 20 + + + + First Radius + - - - - - 380 - 180 - 131 - 161 - - - - Continue Shading - - - - - 20 - 50 - 93 - 26 - - - - Forward - - - - - - 20 - 100 - 93 - 26 - - - - Backward - - - - - - - 0 - 10 - 510 - 160 - - - - Set Coordinates Of Circle Centers - - - - - 20 - 30 - 168 - 20 - - - - X Coordinate, First Center - - - - - - 20 - 50 - 113 - 28 - - - - - - - 20 - 80 - 167 - 20 - - - - Y Coordinate, First Center - - - - - - 20 - 100 - 113 - 28 - - - - - - - 280 - 30 - 187 - 20 - - - - Second Center X Coordinate - - - - - - 280 - 50 - 113 - 28 - - - - - - - 280 - 80 - 186 - 20 - - - - Second Center Y Coordinate - - - - - - 280 - 100 - 113 - 28 - - - - - - - - 0 - 180 - 371 - 100 - - - - Set Radius Of Circle - - - - - 20 - 30 - 75 - 20 - - - - First Radius - - - - - - 200 - 30 - 97 - 20 - - - - Second Radius - - - - - - 20 - 50 - 113 - 28 - - - - - - - 200 - 50 - 113 - 28 - - - - - - - - 0 - 290 - 319 - 20 - - - - Radial gradient describes the color change from - - - - - - 0 - 310 - 335 - 20 - - - - the center to the edges, it is defined by two circles, - - - - - - 0 - 330 - 281 - 20 - - - - which are defined by the center and radius - - + + + + 200 + 30 + 97 + 20 + + + + Second Radius + + + + + + 20 + 50 + 113 + 28 + + + + + + + 200 + 50 + 113 + 28 + + - + - 300 - 80 - 117 - 29 + 0 + 260 + 319 + 20 - Render Gradient + Radial gradient describes the color change from + + + + + + 0 + 280 + 335 + 20 + + + + the center to the edges, it is defined by two circles, + + + + + + 0 + 300 + 281 + 20 + + + + which are defined by the center and radius - - + + + + + 300 + 80 + 117 + 29 + + + + Render Gradient + + + 0 0 - 1098 + 1053 25 From 21e3293895055454b75067c2a66c93f3c50f8260 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Wed, 3 Apr 2024 15:31:07 +0300 Subject: [PATCH 03/13] fix image size from pixels to millimeters --- .../gradient/Gradient/mainwindow.cpp | 50 +++++++++--------- .../gradient/Gradient/mainwindow.ui | 52 ++++++++----------- 2 files changed, 48 insertions(+), 54 deletions(-) diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index b3b60008b4..c1989b9c76 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -46,8 +46,8 @@ QImage GenerateImg(std::vector &points, Info &info) { NSGraphics::IGraphicsRenderer* pRasterRenderer = NSGraphics::Create(); NSFonts::IFontManager *fmp = NSFonts::NSFontManager::Create(); pRasterRenderer->SetFontManager(fmp); - int nRasterW = 500; - int nRasterH = 500; + int nRasterW = 567; + int nRasterH = 567; BYTE* pData = new BYTE[4 * nRasterW * nRasterH]; unsigned int back = 0xffffff; @@ -66,8 +66,8 @@ QImage GenerateImg(std::vector &points, Info &info) { pRasterRenderer->CreateFromBgraFrame(&oFrame); pRasterRenderer->SetSwapRGB(false); - double dW_MM = nRasterW /** 25.4 / 96*/; - double dH_MM = nRasterH /** 25.4 / 96*/; + double dW_MM = nRasterW * 25.4 / 96; + double dH_MM = nRasterH * 25.4 / 96; pRasterRenderer->put_Width(dW_MM); pRasterRenderer->put_Height(dH_MM); @@ -94,7 +94,7 @@ QImage GenerateImg(std::vector &points, Info &info) { pRasterRenderer->EndCommand(c_nPathType); pRasterRenderer->PathCommandEnd(); - QImage img = QImage(pData, 500, 500, QImage::Format_RGBA8888, CleanupFunction); + QImage img = QImage(pData, 567, 567, QImage::Format_RGBA8888, CleanupFunction); oFrame.put_Data(NULL); return img; } @@ -252,8 +252,8 @@ void MainWindow::on_First_X_Coordinate_Input_editingFinished() { if (ui->First_X_Coordinate_Input->text().toInt() < 0) ui->First_X_Coordinate_Input->setText("0"); - if (ui->First_X_Coordinate_Input->text().toInt() > 500) - ui->First_X_Coordinate_Input->setText("500"); + if (ui->First_X_Coordinate_Input->text().toInt() > 150) + ui->First_X_Coordinate_Input->setText("150"); } @@ -261,16 +261,16 @@ void MainWindow::on_First_Y_Coordinate_Input_editingFinished() { if (ui->First_Y_Coordinate_Input->text().toInt() < 0) ui->First_Y_Coordinate_Input->setText("0"); - if (ui->First_Y_Coordinate_Input->text().toInt() > 500) - ui->First_Y_Coordinate_Input->setText("500"); + if (ui->First_Y_Coordinate_Input->text().toInt() > 150) + ui->First_Y_Coordinate_Input->setText("150"); } void MainWindow::on_Second_X_Coordinate_Input_editingFinished() { if (ui->Second_X_Coordinate_Input->text().toInt() < 0) ui->Second_X_Coordinate_Input->setText("0"); - if (ui->Second_X_Coordinate_Input->text().toInt() > 500) - ui->Second_X_Coordinate_Input->setText("500"); + if (ui->Second_X_Coordinate_Input->text().toInt() > 150) + ui->Second_X_Coordinate_Input->setText("150"); } @@ -278,8 +278,8 @@ void MainWindow::on_Second_Y_Coordinate_Input_editingFinished() { if (ui->Second_Y_Coordinate_Input->text().toInt() < 0) ui->Second_Y_Coordinate_Input->setText("0"); - if (ui->Second_Y_Coordinate_Input->text().toInt() > 500) - ui->Second_Y_Coordinate_Input->setText("500"); + if (ui->Second_Y_Coordinate_Input->text().toInt() > 150) + ui->Second_Y_Coordinate_Input->setText("150"); } @@ -287,8 +287,8 @@ void MainWindow::on_First_Center_X_Coordinate_Input_editingFinished() { if (ui->First_Center_X_Coordinate_Input->text().toInt() < 0) ui->First_Center_X_Coordinate_Input->setText("0"); - if (ui->First_Center_X_Coordinate_Input->text().toInt() > 499) - ui->First_Center_X_Coordinate_Input->setText("500"); + if (ui->First_Center_X_Coordinate_Input->text().toInt() > 150) + ui->First_Center_X_Coordinate_Input->setText("150"); } @@ -296,8 +296,8 @@ void MainWindow::on_First_Center_Y_Coordinate_Input_editingFinished() { if (ui->First_Center_Y_Coordinate_Input->text().toInt() < 0) ui->First_Center_Y_Coordinate_Input->setText("0"); - if (ui->First_Center_Y_Coordinate_Input->text().toInt() > 499) - ui->First_Center_Y_Coordinate_Input->setText("500"); + if (ui->First_Center_Y_Coordinate_Input->text().toInt() > 150) + ui->First_Center_Y_Coordinate_Input->setText("150"); } @@ -305,8 +305,8 @@ void MainWindow::on_Second_Center_X_Coordinate_Input_editingFinished() { if (ui->Second_Center_X_Coordinate_Input->text().toInt() < 0) ui->Second_Center_X_Coordinate_Input->setText("0"); - if (ui->Second_Center_X_Coordinate_Input->text().toInt() > 500) - ui->Second_Center_X_Coordinate_Input->setText("500"); + if (ui->Second_Center_X_Coordinate_Input->text().toInt() > 150) + ui->Second_Center_X_Coordinate_Input->setText("150"); } @@ -314,8 +314,8 @@ void MainWindow::on_Second_Center_Y_Coordinate_Input_editingFinished() { if (ui->Second_Center_Y_Coordinate_Input->text().toInt() < 0) ui->Second_Center_Y_Coordinate_Input->setText("0"); - if (ui->Second_Center_Y_Coordinate_Input->text().toInt() > 500) - ui->Second_Center_Y_Coordinate_Input->setText("500"); + if (ui->Second_Center_Y_Coordinate_Input->text().toInt() > 150) + ui->Second_Center_Y_Coordinate_Input->setText("150"); } @@ -323,8 +323,8 @@ void MainWindow::on_First_Radius_Input_editingFinished() { if (ui->First_Radius_Input->text().toInt() < 0) ui->First_Radius_Input->setText("0"); - if (ui->First_Radius_Input->text().toInt() > 500) - ui->First_Radius_Input->setText("500"); + if (ui->First_Radius_Input->text().toInt() > 150) + ui->First_Radius_Input->setText("150"); } @@ -332,7 +332,7 @@ void MainWindow::on_Second_Radius_Input_editingFinished() { if (ui->Second_Radius_Input->text().toInt() < 0) ui->Second_Radius_Input->setText("0"); - if (ui->Second_Radius_Input->text().toInt() > 500) - ui->Second_Radius_Input->setText("500"); + if (ui->Second_Radius_Input->text().toInt() > 150) + ui->Second_Radius_Input->setText("150"); } diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index 15e61948c0..a9f777faa7 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1053 - 602 + 1120 + 675 @@ -22,16 +22,10 @@ 0 0 - 500 - 500 + 567 + 567 - - - 500 - 500 - - @@ -39,10 +33,10 @@ - 510 + 580 -10 535 - 511 + 580 @@ -66,7 +60,7 @@ 10 10 201 - 150 + 170 @@ -129,20 +123,20 @@ 10 - 160 + 190 511 - 331 + 370 - 1 + 0 0 - 0 + 10 371 160 @@ -247,7 +241,7 @@ 380 - 0 + 10 131 161 @@ -286,7 +280,7 @@ 10 - 170 + 180 415 20 @@ -302,7 +296,7 @@ 10 - 190 + 200 415 20 @@ -320,7 +314,7 @@ 380 - 160 + 180 131 161 @@ -361,7 +355,7 @@ 0 10 510 - 140 + 150 @@ -464,7 +458,7 @@ 0 - 160 + 180 371 100 @@ -523,7 +517,7 @@ 0 - 260 + 280 319 20 @@ -536,7 +530,7 @@ 0 - 280 + 300 335 20 @@ -549,7 +543,7 @@ 0 - 300 + 320 281 20 @@ -563,8 +557,8 @@ - 300 - 80 + 310 + 90 117 29 @@ -580,7 +574,7 @@ 0 0 - 1053 + 1120 25 From 86b53b7edeb07343f9cfc61039f8ed465919c570 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Thu, 4 Apr 2024 10:22:35 +0300 Subject: [PATCH 04/13] Refactoring --- Test/Applications/gradient/Gradient/main.cpp | 11 +- .../gradient/Gradient/mainwindow.cpp | 424 ++++++++---------- .../gradient/Gradient/mainwindow.h | 183 ++++---- 3 files changed, 298 insertions(+), 320 deletions(-) diff --git a/Test/Applications/gradient/Gradient/main.cpp b/Test/Applications/gradient/Gradient/main.cpp index 7c9d4c93b5..d0857b28b1 100644 --- a/Test/Applications/gradient/Gradient/main.cpp +++ b/Test/Applications/gradient/Gradient/main.cpp @@ -1,11 +1,10 @@ #include "mainwindow.h" -#include #include -#include "../../../../DesktopEditor/graphics/pro/Graphics.h" + int main(int argc, char *argv[]) { - QApplication a(argc, argv ); - MainWindow w; - w.show(); - return a.exec(); + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); } diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index c1989b9c76..8546b00d32 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -2,337 +2,307 @@ #include "ui_mainwindow.h" #include #include + #include "../../../../DesktopEditor/graphics/pro/Graphics.h" -#include "../../../../DesktopEditor/fontengine/ApplicationFontsWorker.h" -#include "../../../../DesktopEditor/common/Directory.h" #include "../../../../PdfFile/PdfFile.h" -// std::vector drawCircle1(int n, double cx, double cy, double r) { -// std::vector res; -// for (int i = 0; i < n; i++) { -// double x = cx + r * cos(i * 8 * atan(1) / n); -// double y = cy + r * sin(i * 8 * atan(1) / n); -// res.push_back({x, y}); -// } -// return res; -// } - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) - , img("test.png") - , lable(new QLabel) +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), img("test.png"), lable(new QLabel) { - ui->setupUi(this); - ui->lable_test->setStyleSheet("QLabel { background-color : white;}"); - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; - ui->stackedWidget->setCurrentIndex(0); - ui->statusbar->showMessage("Linear"); + ui->setupUi(this); + ui->lable_test->setStyleSheet("QLabel { background-color : white;}"); + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; + ui->stackedWidget->setCurrentIndex(0); + ui->statusbar->showMessage("Linear"); } - - MainWindow::~MainWindow() { - delete ui; + delete ui; } -void CleanupFunction(void* data) { - delete[] data; +void CleanupFunction(void *data) +{ + delete[] data; } -QImage GenerateImg(std::vector &points, Info &info) { +const int COORD_SIZE_MM = 100; - NSGraphics::IGraphicsRenderer* pRasterRenderer = NSGraphics::Create(); - NSFonts::IFontManager *fmp = NSFonts::NSFontManager::Create(); - pRasterRenderer->SetFontManager(fmp); - int nRasterW = 567; - int nRasterH = 567; - BYTE* pData = new BYTE[4 * nRasterW * nRasterH]; +QImage GenerateImg(std::vector &points, Info &info, const int& w, const int& h) +{ + NSGraphics::IGraphicsRenderer *pRasterRenderer = NSGraphics::Create(); + NSFonts::IFontManager *fmp = NSFonts::NSFontManager::Create(); + pRasterRenderer->SetFontManager(fmp); + int nRasterW = w; + int nRasterH = h; + BYTE *pData = new BYTE[4 * nRasterW * nRasterH]; - unsigned int back = 0xffffff; - unsigned int* pData32 = (unsigned int*)pData; - unsigned int* pData32End = pData32 + nRasterW * nRasterH ; - //дефолтный тон должен быть прозрачным, а не белым - while (pData32 < pData32End) - *pData32++ = back; + unsigned int back = 0xffffff; + unsigned int *pData32 = (unsigned int *)pData; + unsigned int *pData32End = pData32 + nRasterW * nRasterH; + // дефолтный тон должен быть прозрачным, а не белым + while (pData32 < pData32End) + *pData32++ = back; - CBgraFrame oFrame; - oFrame.put_Data(pData); - oFrame.put_Width(nRasterW); - oFrame.put_Height(nRasterH); - oFrame.put_Stride(4 * nRasterW); + CBgraFrame oFrame; + oFrame.put_Data(pData); + oFrame.put_Width(nRasterW); + oFrame.put_Height(nRasterH); + oFrame.put_Stride(4 * nRasterW); - pRasterRenderer->CreateFromBgraFrame(&oFrame); - pRasterRenderer->SetSwapRGB(false); + pRasterRenderer->CreateFromBgraFrame(&oFrame); + pRasterRenderer->SetSwapRGB(false); - double dW_MM = nRasterW * 25.4 / 96; - double dH_MM = nRasterH * 25.4 / 96; + double dW_MM = COORD_SIZE_MM; + double dH_MM = COORD_SIZE_MM; - pRasterRenderer->put_Width(dW_MM); - pRasterRenderer->put_Height(dH_MM); + pRasterRenderer->put_Width(dW_MM); + pRasterRenderer->put_Height(dH_MM); - NSStructures::GradientInfo ginfo = info.ginfo; - ginfo.shading.f_type = NSStructures::ShadingInfo::UseNew; - pRasterRenderer->put_BrushGradInfo(ginfo); - auto a = info.c; - auto b = info.p; - LONG *c = a.data(); - double *p = b.data(); - pRasterRenderer->CommandDrawText(L"Test", 10, 10, 345, 345); - pRasterRenderer->put_BrushType(info.gradient_type); - pRasterRenderer->put_BrushGradientColors(c, p, info.n_colors); - pRasterRenderer->PathCommandStart(); - pRasterRenderer->BeginCommand(c_nPathType); - if (points.size() > 0) { - pRasterRenderer->PathCommandMoveTo(points[0].x, points[0].y); - for (uint i = 1; i < points.size(); i++) { - pRasterRenderer->PathCommandLineTo(points[i].x, points[i].y) ; - } - } - pRasterRenderer->Fill(); - pRasterRenderer->EndCommand(c_nPathType); - pRasterRenderer->PathCommandEnd(); + NSStructures::GradientInfo ginfo = info.ginfo; + ginfo.shading.f_type = NSStructures::ShadingInfo::UseNew; + pRasterRenderer->put_BrushGradInfo(ginfo); + auto a = info.c; + auto b = info.p; + LONG *c = a.data(); + double *p = b.data(); + pRasterRenderer->put_BrushType(info.gradient_type); + pRasterRenderer->put_BrushGradientColors(c, p, info.n_colors); + pRasterRenderer->PathCommandStart(); + pRasterRenderer->BeginCommand(c_nPathType); + if (points.size() > 0) + { + pRasterRenderer->PathCommandMoveTo(points[0].x, points[0].y); + for (uint i = 1; i < points.size(); i++) + { + pRasterRenderer->PathCommandLineTo(points[i].x, points[i].y); + } + } + pRasterRenderer->Fill(); + pRasterRenderer->EndCommand(c_nPathType); + pRasterRenderer->PathCommandEnd(); - QImage img = QImage(pData, 567, 567, QImage::Format_RGBA8888, CleanupFunction); - oFrame.put_Data(NULL); - return img; + QImage img = QImage(pData, nRasterW, nRasterH, QImage::Format_RGBA8888, CleanupFunction); + oFrame.put_Data(NULL); + return img; } void MainWindow::on_actionLinear_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(0); - ui->statusbar->showMessage("Linear"); - info.gradient_type = c_BrushTypePathNewLinearGradient; + ui->stackedWidget->setCurrentIndex(0); + ui->statusbar->showMessage("Linear"); + info.gradient_type = c_BrushTypePathNewLinearGradient; } - void MainWindow::on_actionRadial_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(1); - ui->statusbar->showMessage("Radial"); - info.gradient_type = c_BrushTypePathRadialGradient; + ui->stackedWidget->setCurrentIndex(1); + ui->statusbar->showMessage("Radial"); + info.gradient_type = c_BrushTypePathRadialGradient; } void MainWindow::on_BAW_Colorspace_Radio_Button_clicked() { - info.colorspace = BlackAndWhite; + info.colorspace = BlackAndWhite; } void MainWindow::on_RAB_Colorspace_Radio_Button_clicked() { - info.colorspace = RedAndBlue; + info.colorspace = RedAndBlue; } void MainWindow::on_Pastel_Colorspace_Radio_Button_clicked() { - info.colorspace = Pastel; + info.colorspace = Pastel; } void MainWindow::on_Rainbow_Colorspace_Radio_Button_clicked() { - info.colorspace = Rainbow; + info.colorspace = Rainbow; } void MainWindow::on_pushButton_clicked() { - if (info.gradient_type == c_BrushTypePathNewLinearGradient) { - if (ui->First_X_Coordinate_Input->text() == "") { - ui->statusbar->showMessage("First X coordinate = NULL"); - return; - } - info.p0.x = ui->First_X_Coordinate_Input->text().toInt(); - if (ui->First_Y_Coordinate_Input->text() == "") { - ui->statusbar->showMessage("First Y coordinate = NULL"); - return; - } - info.p0.y = ui->First_Y_Coordinate_Input->text().toInt(); - if (ui->Second_X_Coordinate_Input->text() == "") { - ui->statusbar->showMessage("First X coordinate = NULL"); - return; - } - info.p1.x = ui->Second_X_Coordinate_Input->text().toInt(); - if (ui->Second_Y_Coordinate_Input->text() == "") { - ui->statusbar->showMessage("First X coordinate = NULL"); - return; - } - info.p1.y = ui->Second_Y_Coordinate_Input->text().toInt(); - info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - } else if (info.gradient_type == c_BrushTypePathRadialGradient) { - if (ui->First_Center_X_Coordinate_Input->text() == "") { - ui->statusbar->showMessage("First Center X coordinate = NULL"); - return; - } - info.c0.x = ui->First_Center_X_Coordinate_Input->text().toInt(); - if (ui->First_Center_Y_Coordinate_Input->text() == "") { - ui->statusbar->showMessage("First Center Y coordinate = NULL"); - return; - } - info.c0.y = ui->First_Center_Y_Coordinate_Input->text().toInt(); - if (ui->Second_Center_X_Coordinate_Input->text() == "") { - ui->statusbar->showMessage("First Center X coordinate = NULL"); - return; - } - info.c1.x = ui->Second_Center_X_Coordinate_Input->text().toInt(); - if (ui->Second_Center_Y_Coordinate_Input->text() == "") { - ui->statusbar->showMessage("First Center X coordinate = NULL"); - return; - } - info.c1.y = ui->Second_Center_Y_Coordinate_Input->text().toInt(); - if (ui->First_Radius_Input->text() == "") { - ui->statusbar->showMessage("First Radius = NUll"); - return; - } - info.r0 = ui->First_Radius_Input->text().toInt(); - if (ui->Second_Radius_Input->text() == "") { - ui->statusbar->showMessage("Second Radius = NULL"); - return; - } - info.r1 = ui->Second_Radius_Input->text().toInt(); - info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, - 0, 1, info.cont_b, info.cont_f); - } + if (info.gradient_type == c_BrushTypePathNewLinearGradient) + { + if (ui->First_X_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First X coordinate = NULL"); + return; + } + info.p0.x = ui->First_X_Coordinate_Input->text().toInt(); + if (ui->First_Y_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First Y coordinate = NULL"); + return; + } + info.p0.y = ui->First_Y_Coordinate_Input->text().toInt(); + if (ui->Second_X_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First X coordinate = NULL"); + return; + } + info.p1.x = ui->Second_X_Coordinate_Input->text().toInt(); + if (ui->Second_Y_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First X coordinate = NULL"); + return; + } + info.p1.y = ui->Second_Y_Coordinate_Input->text().toInt(); + info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); + } + else if (info.gradient_type == c_BrushTypePathRadialGradient) + { + if (ui->First_Center_X_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First Center X coordinate = NULL"); + return; + } + info.c0.x = ui->First_Center_X_Coordinate_Input->text().toInt(); + if (ui->First_Center_Y_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First Center Y coordinate = NULL"); + return; + } + info.c0.y = ui->First_Center_Y_Coordinate_Input->text().toInt(); + if (ui->Second_Center_X_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First Center X coordinate = NULL"); + return; + } + info.c1.x = ui->Second_Center_X_Coordinate_Input->text().toInt(); + if (ui->Second_Center_Y_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First Center X coordinate = NULL"); + return; + } + info.c1.y = ui->Second_Center_Y_Coordinate_Input->text().toInt(); + if (ui->First_Radius_Input->text() == "") + { + ui->statusbar->showMessage("First Radius = NUll"); + return; + } + info.r0 = ui->First_Radius_Input->text().toInt(); + if (ui->Second_Radius_Input->text() == "") + { + ui->statusbar->showMessage("Second Radius = NULL"); + return; + } + info.r1 = ui->Second_Radius_Input->text().toInt(); + info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, 0, 1, info.cont_b, info.cont_f); + } - if (info.colorspace == NoColorspaceType) { - ui->statusbar->showMessage("Colorspace - NULL"); - return; - } else if (info.colorspace == Rainbow) { - info.c = {(LONG)0xFFff0000, (LONG)0xFFffa500, (LONG)0xFFffff00, (LONG)0xFF008000, (LONG)0xFF0000ff, (LONG)0xFFFF00FF}; - info.p = {0.0,0.2,0.4,0.6,0.8,1}; - info.n_colors = 6; - info.ginfo.shading.function.set_linear_interpolation({0xFFff0000, 0xFFffa500, 0xFFffff00, 0xFF008000, 0xFF0000ff, 0xFFFF00FF} - , {0.0f,0.2f,0.4f,0.6f,0.8f,1.0f}); - } else if (info.colorspace == BlackAndWhite) { - info.c = {(LONG)0xFFFFFFFF, (LONG)0xFF000000}; - info.p = {0.0, 1}; - info.n_colors = 2; - info.ginfo.shading.function.set_linear_interpolation({0xFFFFFFFF, 0xFF000000}, {0.0f, 1.0f}); - } else if (info.colorspace == RedAndBlue) { - info.c = {(LONG)0xFFFF0000, (LONG)0xFF0000FF}; - info.p = {0.0, 1}; - info.n_colors = 2; - info.ginfo.shading.function.set_linear_interpolation({0xFFFF0000, 0xFF0000FF}, {0.0f, 1.0f}); - } else if (info.colorspace == Pastel) { - info.c = {(LONG)0xfff39189, (LONG)0xff046582}; - info.p = {0.0, 1}; - info.n_colors = 2; - info.ginfo.shading.function.set_linear_interpolation({0xfff39189, 0xff046582}, {0.0f, 1.0f}); - } + if (info.colorspace == NoColorspaceType) + { + ui->statusbar->showMessage("Colorspace - NULL"); + return; + } + else if (info.colorspace == Rainbow) + { + info.c = {(LONG)0xFFff0000, (LONG)0xFFffa500, (LONG)0xFFffff00, (LONG)0xFF008000, (LONG)0xFF0000ff, (LONG)0xFFFF00FF}; + info.p = {0.0, 0.2, 0.4, 0.6, 0.8, 1}; + info.n_colors = 6; + info.ginfo.shading.function.set_linear_interpolation({0xFFff0000, 0xFFffa500, 0xFFffff00, 0xFF008000, 0xFF0000ff, 0xFFFF00FF}, {0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f}); + } + else if (info.colorspace == BlackAndWhite) + { + info.c = {(LONG)0xFFFFFFFF, (LONG)0xFF000000}; + info.p = {0.0, 1}; + info.n_colors = 2; + info.ginfo.shading.function.set_linear_interpolation({0xFFFFFFFF, 0xFF000000}, {0.0f, 1.0f}); + } + else if (info.colorspace == RedAndBlue) + { + info.c = {(LONG)0xFFFF0000, (LONG)0xFF0000FF}; + info.p = {0.0, 1}; + info.n_colors = 2; + info.ginfo.shading.function.set_linear_interpolation({0xFFFF0000, 0xFF0000FF}, {0.0f, 1.0f}); + } + else if (info.colorspace == Pastel) + { + info.c = {(LONG)0xfff39189, (LONG)0xff046582}; + info.p = {0.0, 1}; + info.n_colors = 2; + info.ginfo.shading.function.set_linear_interpolation({0xfff39189, 0xff046582}, {0.0f, 1.0f}); + } - QImage pm = GenerateImg(points, info); - ui->lable_test->setPixmap(QPixmap::fromImage(pm)); - ui->lable_test->setScaledContents(true); + QImage pm = GenerateImg(points, info, ui->lable_test->width(), ui->lable_test->height()); + ui->lable_test->setPixmap(QPixmap::fromImage(pm)); + ui->lable_test->setScaledContents(true); } - void MainWindow::on_Continue_Shading_Forward_clicked(bool checked) { - info.cont_f = checked; + info.cont_f = checked; } - void MainWindow::on_checkBox_2_clicked(bool checked) { - info.cont_b = checked; + info.cont_b = checked; } - void MainWindow::on_Continue_Shading_Forward_2_clicked(bool checked) { - info.cont_f = checked; + info.cont_f = checked; } - void MainWindow::on_Continue_Shading_Backward_2_clicked(bool checked) { - info.cont_b = checked; + info.cont_b = checked; } +inline void ClampCoords(QLineEdit* edit) +{ + if (edit->text().toInt() < 0) + edit->setText("0"); + if (edit->text().toInt() > COORD_SIZE_MM) + edit->setText(QString::number(COORD_SIZE_MM)); +} void MainWindow::on_First_X_Coordinate_Input_editingFinished() { - if (ui->First_X_Coordinate_Input->text().toInt() < 0) - ui->First_X_Coordinate_Input->setText("0"); - if (ui->First_X_Coordinate_Input->text().toInt() > 150) - ui->First_X_Coordinate_Input->setText("150"); + ClampCoords(ui->First_X_Coordinate_Input); } - void MainWindow::on_First_Y_Coordinate_Input_editingFinished() { - if (ui->First_Y_Coordinate_Input->text().toInt() < 0) - ui->First_Y_Coordinate_Input->setText("0"); - if (ui->First_Y_Coordinate_Input->text().toInt() > 150) - ui->First_Y_Coordinate_Input->setText("150"); + ClampCoords(ui->First_Y_Coordinate_Input); } void MainWindow::on_Second_X_Coordinate_Input_editingFinished() { - if (ui->Second_X_Coordinate_Input->text().toInt() < 0) - ui->Second_X_Coordinate_Input->setText("0"); - if (ui->Second_X_Coordinate_Input->text().toInt() > 150) - ui->Second_X_Coordinate_Input->setText("150"); + ClampCoords(ui->Second_X_Coordinate_Input); } - void MainWindow::on_Second_Y_Coordinate_Input_editingFinished() { - if (ui->Second_Y_Coordinate_Input->text().toInt() < 0) - ui->Second_Y_Coordinate_Input->setText("0"); - if (ui->Second_Y_Coordinate_Input->text().toInt() > 150) - ui->Second_Y_Coordinate_Input->setText("150"); + ClampCoords(ui->Second_Y_Coordinate_Input); } - void MainWindow::on_First_Center_X_Coordinate_Input_editingFinished() { - if (ui->First_Center_X_Coordinate_Input->text().toInt() < 0) - ui->First_Center_X_Coordinate_Input->setText("0"); - if (ui->First_Center_X_Coordinate_Input->text().toInt() > 150) - ui->First_Center_X_Coordinate_Input->setText("150"); + ClampCoords(ui->First_Center_X_Coordinate_Input); } - void MainWindow::on_First_Center_Y_Coordinate_Input_editingFinished() { - if (ui->First_Center_Y_Coordinate_Input->text().toInt() < 0) - ui->First_Center_Y_Coordinate_Input->setText("0"); - if (ui->First_Center_Y_Coordinate_Input->text().toInt() > 150) - ui->First_Center_Y_Coordinate_Input->setText("150"); + ClampCoords(ui->First_Center_Y_Coordinate_Input); } - void MainWindow::on_Second_Center_X_Coordinate_Input_editingFinished() { - if (ui->Second_Center_X_Coordinate_Input->text().toInt() < 0) - ui->Second_Center_X_Coordinate_Input->setText("0"); - if (ui->Second_Center_X_Coordinate_Input->text().toInt() > 150) - ui->Second_Center_X_Coordinate_Input->setText("150"); + ClampCoords(ui->Second_Center_X_Coordinate_Input); } - void MainWindow::on_Second_Center_Y_Coordinate_Input_editingFinished() { - if (ui->Second_Center_Y_Coordinate_Input->text().toInt() < 0) - ui->Second_Center_Y_Coordinate_Input->setText("0"); - if (ui->Second_Center_Y_Coordinate_Input->text().toInt() > 150) - ui->Second_Center_Y_Coordinate_Input->setText("150"); + ClampCoords(ui->Second_Center_Y_Coordinate_Input); } - void MainWindow::on_First_Radius_Input_editingFinished() { - if (ui->First_Radius_Input->text().toInt() < 0) - ui->First_Radius_Input->setText("0"); - if (ui->First_Radius_Input->text().toInt() > 150) - ui->First_Radius_Input->setText("150"); + ClampCoords(ui->First_Radius_Input); } - void MainWindow::on_Second_Radius_Input_editingFinished() { - if (ui->Second_Radius_Input->text().toInt() < 0) - ui->Second_Radius_Input->setText("0"); - if (ui->Second_Radius_Input->text().toInt() > 150) - ui->Second_Radius_Input->setText("150"); + ClampCoords(ui->Second_Radius_Input); } - diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index c22f60a407..d47fe7b145 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -1,136 +1,145 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include #include -#include #include -#include "../../../../DesktopEditor/graphics/pro/Graphics.h" +#include +#include "../../../../DesktopEditor/graphics/structures.h" + QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } +namespace Ui +{ + class MainWindow; +} QT_END_NAMESPACE -typedef enum { - NoColorspaceType, - Rainbow, - BlackAndWhite, - RedAndBlue, - Pastel +typedef enum +{ + NoColorspaceType, + Rainbow, + BlackAndWhite, + RedAndBlue, + Pastel } ColorspaceType; -struct Point { - Point(double _x = 0, double _y = 0) : x(_x), y(_y){} - double x, y; +struct Point +{ + Point(double _x = 0, double _y = 0) : x(_x), y(_y) + { + } + double x, y; }; -struct Color { - uint r,g,b; - Color() { - r = b = g = 0; - } - Color(uint rgb) { - b = rgb % 0x100; - g = (rgb / 0x100) % 0x100; - r = rgb / 0x100 / 0x100; - } - uint get_color() { - return b + g * 0x100 + r * 0x10000; - } +struct Color +{ + uint r, g, b; + Color() + { + r = b = g = 0; + } + Color(uint rgb) + { + b = rgb % 0x100; + g = (rgb / 0x100) % 0x100; + r = rgb / 0x100 / 0x100; + } + uint get_color() + { + return b + g * 0x100 + r * 0x10000; + } }; -struct Info { - ColorspaceType colorspace = NoColorspaceType; +struct Info +{ + ColorspaceType colorspace = NoColorspaceType; - float r0, r1; - NSStructures::Point c0, c1; - NSStructures::Point p0, p1; - bool cont_b, cont_f; - std::vector triangle ={{100, 100}, {300, 200}, {200, 350}}; + float r0, r1; + NSStructures::Point c0, c1; + NSStructures::Point p0, p1; + bool cont_b, cont_f; + std::vector triangle = {{100, 100}, {300, 200}, {200, 350}}; + NSStructures::GradientInfo ginfo; + int gradient_type; + std::vector c; + std::vector p; + int n_colors; + Info() : gradient_type(c_BrushTypePathNewLinearGradient) + { + c = {(LONG)0xFFff0000, (LONG)0xFFffa500, (LONG)0xFFffff00, (LONG)0xFF008000, (LONG)0xFF0000ff, (LONG)0xFFFF00FF}; + p = {0.0, 0.2, 0.4, 0.6, 0.8, 1}; + n_colors = 6; + ginfo.shading.shading_type = NSStructures::ShadingInfo::Parametric; - NSStructures::GradientInfo ginfo; - int gradient_type; - std::vector c; - std::vector p; - int n_colors; - Info() : gradient_type(c_BrushTypePathNewLinearGradient) { - c = {(LONG)0xFFff0000, (LONG)0xFFffa500, (LONG)0xFFffff00, (LONG)0xFF008000, (LONG)0xFF0000ff, (LONG)0xFFFF00FF}; - p = {0.0,0.2,0.4,0.6,0.8,1}; - n_colors = 6; - ginfo.shading.shading_type = NSStructures::ShadingInfo::Parametric; - - - - r0 = 0; - r1 = 100; - c0 = {200, 200}; - c1 = {200, 200}; - p0 = {0, 0}; - p1 = {400, 400}; - cont_b = cont_f = false; - }; - ~Info() { - } + r0 = 0; + r1 = 100; + c0 = {200, 200}; + c1 = {200, 200}; + p0 = {0, 0}; + p1 = {400, 400}; + cont_b = cont_f = false; + }; + ~Info() + { + } }; -QImage GenerateImg(int grad = 1,double angle = 0,std::vector points = {}); -std::vector drawCircle1(int n, double cx, double cy, double r); class MainWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - QImage img; - QLabel *lable; - std::vector points; - Info info; + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + QImage img; + QLabel *lable; + std::vector points; + Info info; private slots: - void on_actionLinear_Gradient_triggered(); + void on_actionLinear_Gradient_triggered(); - void on_actionRadial_Gradient_triggered(); + void on_actionRadial_Gradient_triggered(); - void on_BAW_Colorspace_Radio_Button_clicked(); + void on_BAW_Colorspace_Radio_Button_clicked(); - void on_RAB_Colorspace_Radio_Button_clicked(); + void on_RAB_Colorspace_Radio_Button_clicked(); - void on_Pastel_Colorspace_Radio_Button_clicked(); + void on_Pastel_Colorspace_Radio_Button_clicked(); - void on_Rainbow_Colorspace_Radio_Button_clicked(); + void on_Rainbow_Colorspace_Radio_Button_clicked(); - void on_pushButton_clicked(); + void on_pushButton_clicked(); - void on_Continue_Shading_Forward_clicked(bool checked); + void on_Continue_Shading_Forward_clicked(bool checked); - void on_checkBox_2_clicked(bool checked); + void on_checkBox_2_clicked(bool checked); - void on_Continue_Shading_Forward_2_clicked(bool checked); + void on_Continue_Shading_Forward_2_clicked(bool checked); - void on_Continue_Shading_Backward_2_clicked(bool checked); + void on_Continue_Shading_Backward_2_clicked(bool checked); - void on_First_X_Coordinate_Input_editingFinished(); + void on_First_X_Coordinate_Input_editingFinished(); - void on_First_Y_Coordinate_Input_editingFinished(); + void on_First_Y_Coordinate_Input_editingFinished(); - void on_Second_X_Coordinate_Input_editingFinished(); + void on_Second_X_Coordinate_Input_editingFinished(); - void on_Second_Y_Coordinate_Input_editingFinished(); + void on_Second_Y_Coordinate_Input_editingFinished(); - void on_First_Center_X_Coordinate_Input_editingFinished(); + void on_First_Center_X_Coordinate_Input_editingFinished(); - void on_First_Center_Y_Coordinate_Input_editingFinished(); + void on_First_Center_Y_Coordinate_Input_editingFinished(); - void on_Second_Center_X_Coordinate_Input_editingFinished(); + void on_Second_Center_X_Coordinate_Input_editingFinished(); - void on_Second_Center_Y_Coordinate_Input_editingFinished(); + void on_Second_Center_Y_Coordinate_Input_editingFinished(); - void on_First_Radius_Input_editingFinished(); + void on_First_Radius_Input_editingFinished(); - void on_Second_Radius_Input_editingFinished(); + void on_Second_Radius_Input_editingFinished(); private: - Ui::MainWindow *ui; + Ui::MainWindow *ui; }; #endif // MAINWINDOW_H From 29afb2aed9decd4333e509c1ad6cb6acfd875bab Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Fri, 5 Apr 2024 19:34:20 +0300 Subject: [PATCH 05/13] Add Triangle gradient --- DesktopEditor/graphics/shading_info.h | 6 +- .../gradient/Gradient/mainwindow.cpp | 180 ++++++++ .../gradient/Gradient/mainwindow.h | 28 ++ .../gradient/Gradient/mainwindow.ui | 418 +++++++++++++++++- 4 files changed, 608 insertions(+), 24 deletions(-) diff --git a/DesktopEditor/graphics/shading_info.h b/DesktopEditor/graphics/shading_info.h index 4ea5cc9b23..d89524767b 100644 --- a/DesktopEditor/graphics/shading_info.h +++ b/DesktopEditor/graphics/shading_info.h @@ -468,14 +468,14 @@ namespace NSStructures { GradientInfo ginfo; ginfo.shading.triangle = points; + ginfo.shading.function = ColorFunction(256, t0, t1); + ginfo.continue_shading_f = false; + ginfo.continue_shading_b = false; if (parametric) { ginfo.shading.triangle_parameters = params; ginfo.shading.f_type = ShadingInfo::UseNew; - ginfo.shading.function = ColorFunction(256, t0, t1); ginfo.shading.shading_type = ShadingInfo::Parametric; - ginfo.continue_shading_f = false; - ginfo.continue_shading_b = false; } else { diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index 8546b00d32..eb666ddbc6 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -86,6 +86,8 @@ QImage GenerateImg(std::vector &points, Info &info, const int& w, const i return img; } +bool parametric = false; + void MainWindow::on_actionLinear_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(0); @@ -100,6 +102,21 @@ void MainWindow::on_actionRadial_Gradient_triggered() info.gradient_type = c_BrushTypePathRadialGradient; } +void MainWindow::on_actionTriangle_Gradient_triggered() +{ + ui->stackedWidget->setCurrentIndex(2); + ui->statusbar->showMessage("Triangle"); + info.gradient_type = c_BrushTypeTriagnleMeshGradient; +} + +void MainWindow::on_actionTriangle_Parametric_Gradient_triggered() +{ + ui->stackedWidget->setCurrentIndex(3); + ui->statusbar->showMessage("Triangle Parametric"); + info.gradient_type = c_BrushTypeTriagnleMeshGradient; + parametric = true; +} + void MainWindow::on_BAW_Colorspace_Radio_Button_clicked() { info.colorspace = BlackAndWhite; @@ -189,6 +206,97 @@ void MainWindow::on_pushButton_clicked() info.r1 = ui->Second_Radius_Input->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, 0, 1, info.cont_b, info.cont_f); } + else if (info.gradient_type == c_BrushTypeTriagnleMeshGradient && !parametric) + { + if (ui->First_Vertex_X_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First Vertex X coordinate = NULL"); + return; + } + info.triangle[0].x = ui->First_Vertex_X_Coordinate_Input->text().toInt(); + if (ui->First_Vertex_Y_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("First Vertex Y coordinate = NULL"); + return; + } + info.triangle[0].y = ui->First_Vertex_Y_Coordinate_Input->text().toInt(); + if (ui->Second_Vertex_X_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("Second Vertex X coordinate = NULL"); + return; + } + info.triangle[1].x = ui->Second_Vertex_X_Coordinate_Input->text().toInt(); + if (ui->Second_Vertex_Y_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("Second Vertex Y coordinate = NULL"); + return; + } + info.triangle[1].y = ui->Second_Vertex_Y_Coordinate_Input->text().toInt(); + if (ui->Third_Vertex_X_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("Third Vertex X coordinate = NULL"); + return; + } + info.triangle[2].x = ui->Third_Vertex_X_Coordinate_Input->text().toInt(); + if (ui->Third_Vertex_Y_Coordinate_Input->text() == "") + { + ui->statusbar->showMessage("Third Vertex Y coordinate = NULL"); + return; + } + info.triangle[2].y = ui->Third_Vertex_Y_Coordinate_Input->text().toInt(); + info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, {}, false); + points = {}; + for (auto p : info.triangle) + { + points.push_back({p.x, p.y}); + } + } + else if (info.gradient_type = c_BrushTypeTriagnleMeshGradient && parametric) + { + if (ui->First_Vertex_X_Coordinate_Input_2->text() == "") + { + ui->statusbar->showMessage("First Vertex X coordinate = NULL"); + return; + } + info.triangle[0].x = ui->First_Vertex_X_Coordinate_Input_2->text().toInt(); + if (ui->First_Vertex_Y_Coordinate_Input_2->text() == "") + { + ui->statusbar->showMessage("First Vertex Y coordinate = NULL"); + return; + } + info.triangle[0].y = ui->First_Vertex_Y_Coordinate_Input_2->text().toInt(); + if (ui->Second_Vertex_X_Coordinate_Input_2->text() == "") + { + ui->statusbar->showMessage("Second Vertex X coordinate = NULL"); + return; + } + info.triangle[1].x = ui->Second_Vertex_X_Coordinate_Input_2->text().toInt(); + if (ui->Second_Vertex_Y_Coordinate_Input_2->text() == "") + { + ui->statusbar->showMessage("Second Vertex Y coordinate = NULL"); + return; + } + info.triangle[1].y = ui->Second_Vertex_Y_Coordinate_Input_2->text().toInt(); + if (ui->Third_Vertex_X_Coordinate_Input_2->text() == "") + { + ui->statusbar->showMessage("Third Vertex X coordinate = NULL"); + return; + } + info.triangle[2].x = ui->Third_Vertex_X_Coordinate_Input_2->text().toInt(); + if (ui->Third_Vertex_Y_Coordinate_Input_2->text() == "") + { + ui->statusbar->showMessage("Third Vertex Y coordinate = NULL"); + return; + } + info.triangle[2].y = ui->Third_Vertex_Y_Coordinate_Input_2->text().toInt(); + info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, + {0.f, 0.4f, 1.f}, true); + points = {}; + for (auto p : info.triangle) + { + points.push_back({p.x, p.y}); + } + } if (info.colorspace == NoColorspaceType) { @@ -306,3 +414,75 @@ void MainWindow::on_Second_Radius_Input_editingFinished() { ClampCoords(ui->Second_Radius_Input); } + +void MainWindow::on_First_Vertex_X_Coordinate_Input_editingFinished() +{ + ClampCoords(ui->First_Vertex_X_Coordinate_Input); +} + + +void MainWindow::on_First_Vertex_Y_Coordinate_Input_editingFinished() +{ + ClampCoords(ui->First_Vertex_Y_Coordinate_Input); +} + + +void MainWindow::on_Second_Vertex_X_Coordinate_Input_editingFinished() +{ + ClampCoords(ui->Second_Vertex_X_Coordinate_Input); +} + + +void MainWindow::on_Second_Vertex_Y_Coordinate_Input_editingFinished() +{ + ClampCoords(ui->Second_Vertex_Y_Coordinate_Input); +} + + +void MainWindow::on_Third_Vertex_X_Coordinate_Input_editingFinished() +{ + ClampCoords(ui->Third_Vertex_X_Coordinate_Input); +} + + +void MainWindow::on_Third_Vertex_Y_Coordinate_Input_editingFinished() +{ + ClampCoords(ui->Third_Vertex_Y_Coordinate_Input); +} + + +void MainWindow::on_First_Vertex_X_Coordinate_Input_2_editingFinished() +{ + ClampCoords(ui->First_Vertex_X_Coordinate_Input_2); +} + + +void MainWindow::on_First_Vertex_Y_Coordinate_Input_2_editingFinished() +{ + ClampCoords(ui->First_Vertex_Y_Coordinate_Input_2); +} + + +void MainWindow::on_Second_Vertex_X_Coordinate_Input_2_editingFinished() +{ + ClampCoords(ui->Second_Vertex_X_Coordinate_Input_2); +} + + +void MainWindow::on_Second_Vertex_Y_Coordinate_Input_2_editingFinished() +{ + ClampCoords(ui->Second_Vertex_Y_Coordinate_Input_2); +} + + +void MainWindow::on_Third_Vertex_X_Coordinate_Input_2_editingFinished() +{ + ClampCoords(ui->Third_Vertex_X_Coordinate_Input_2); +} + + +void MainWindow::on_Third_Vertex_Y_Coordinate_Input_2_editingFinished() +{ + ClampCoords(ui->Third_Vertex_Y_Coordinate_Input_2); +} + diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index d47fe7b145..d9f5e08269 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -139,6 +139,34 @@ private slots: void on_Second_Radius_Input_editingFinished(); + void on_actionTriangle_Gradient_triggered(); + + void on_First_Vertex_X_Coordinate_Input_editingFinished(); + + void on_First_Vertex_Y_Coordinate_Input_editingFinished(); + + void on_Second_Vertex_X_Coordinate_Input_editingFinished(); + + void on_Second_Vertex_Y_Coordinate_Input_editingFinished(); + + void on_Third_Vertex_X_Coordinate_Input_editingFinished(); + + void on_Third_Vertex_Y_Coordinate_Input_editingFinished(); + + void on_actionTriangle_Parametric_Gradient_triggered(); + + void on_First_Vertex_X_Coordinate_Input_2_editingFinished(); + + void on_First_Vertex_Y_Coordinate_Input_2_editingFinished(); + + void on_Second_Vertex_X_Coordinate_Input_2_editingFinished(); + + void on_Second_Vertex_Y_Coordinate_Input_2_editingFinished(); + + void on_Third_Vertex_X_Coordinate_Input_2_editingFinished(); + + void on_Third_Vertex_Y_Coordinate_Input_2_editingFinished(); + private: Ui::MainWindow *ui; }; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index a9f777faa7..3f6d8e099e 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1120 - 675 + 1060 + 592 @@ -22,8 +22,8 @@ 0 0 - 567 - 567 + 500 + 500 @@ -33,10 +33,10 @@ - 580 - -10 + 520 + 0 535 - 580 + 500 @@ -60,7 +60,7 @@ 10 10 201 - 170 + 150 @@ -123,13 +123,13 @@ 10 - 190 + 160 511 - 370 + 330 - 0 + 3 @@ -314,7 +314,7 @@ 380 - 180 + 160 131 161 @@ -412,12 +412,12 @@ 280 30 - 187 + 190 20 - Second Center X Coordinate + X Coordinate, Second Center @@ -435,12 +435,12 @@ 280 80 - 186 + 189 20 - Second Center Y Coordinate + Y Coordinate, Second Center @@ -458,7 +458,7 @@ 0 - 180 + 160 371 100 @@ -517,7 +517,7 @@ 0 - 280 + 260 319 20 @@ -530,7 +530,7 @@ 0 - 300 + 280 335 20 @@ -543,7 +543,7 @@ 0 - 320 + 300 281 20 @@ -553,6 +553,364 @@ + + + + + 0 + 10 + 510 + 240 + + + + Set Coordinates Of Triangle Vertices + + + + + 20 + 30 + 168 + 20 + + + + X Coordinate, First Vertex + + + + + + 20 + 50 + 113 + 28 + + + + + + + 20 + 80 + 167 + 20 + + + + Y Coordinate, First Vertex + + + + + + 20 + 100 + 113 + 28 + + + + + + + 280 + 30 + 188 + 20 + + + + X Coordinate, Second Vertex + + + + + + 280 + 50 + 113 + 28 + + + + + + + 280 + 80 + 187 + 20 + + + + Y Coordinate, Second Vertex + + + + + + 280 + 100 + 113 + 28 + + + + + + + 20 + 140 + 173 + 20 + + + + X Coordinate, Third Vertex + + + + + + 20 + 160 + 113 + 28 + + + + + + + 20 + 190 + 173 + 20 + + + + Y Coordinate, Third Vertex + + + + + + 20 + 210 + 113 + 28 + + + + + + + + 0 + 250 + 502 + 20 + + + + Triangle gradient describes the color change between the three vertices of a + + + + + + 0 + 270 + 512 + 20 + + + + triangle. The color change occurs according to the principle of linear gradient + + + + + + 0 + 290 + 476 + 20 + + + + along the perpendiculars from the triangle vertex to the point where the + + + + + + 0 + 310 + 161 + 20 + + + + perpendiculars intersect. + + + + + + + + 0 + 10 + 510 + 260 + + + + Set Coordinates Of Triangle Vertices + + + + + 20 + 30 + 168 + 20 + + + + X Coordinate, First Vertex + + + + + + 20 + 50 + 113 + 28 + + + + + + + 20 + 80 + 167 + 20 + + + + Y Coordinate, First Vertex + + + + + + 20 + 100 + 113 + 28 + + + + + + + 280 + 30 + 188 + 20 + + + + X Coordinate, Second Vertex + + + + + + 280 + 50 + 113 + 28 + + + + + + + 280 + 80 + 187 + 20 + + + + Y Coordinate, Second Vertex + + + + + + 280 + 100 + 113 + 28 + + + + + + + 20 + 140 + 173 + 20 + + + + X Coordinate, Third Vertex + + + + + + 20 + 160 + 113 + 28 + + + + + + + 20 + 190 + 173 + 20 + + + + Y Coordinate, Third Vertex + + + + + + 20 + 210 + 113 + 28 + + + + + @@ -574,7 +932,7 @@ 0 0 - 1120 + 1060 25 @@ -592,6 +950,8 @@ + + @@ -603,6 +963,22 @@ Radial Gradient + + + Triangle Gradient + + + QAction::TextHeuristicRole + + + + + Triangle Parametric Gradient + + + QAction::TextHeuristicRole + + From 3e4c53153801e63b480227da1463b58b164d288e Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Wed, 10 Apr 2024 01:18:40 +0300 Subject: [PATCH 06/13] Add default parametrs and new gradient types --- DesktopEditor/graphics/shading_info.h | 20 +- .../gradient/Gradient/mainwindow.cpp | 753 +++++- .../gradient/Gradient/mainwindow.h | 141 +- .../gradient/Gradient/mainwindow.ui | 2153 +++++++++++++++-- 4 files changed, 2775 insertions(+), 292 deletions(-) diff --git a/DesktopEditor/graphics/shading_info.h b/DesktopEditor/graphics/shading_info.h index d89524767b..9e0323a0ab 100644 --- a/DesktopEditor/graphics/shading_info.h +++ b/DesktopEditor/graphics/shading_info.h @@ -468,13 +468,13 @@ namespace NSStructures { GradientInfo ginfo; ginfo.shading.triangle = points; + ginfo.shading.f_type = ShadingInfo::UseNew; ginfo.shading.function = ColorFunction(256, t0, t1); ginfo.continue_shading_f = false; ginfo.continue_shading_b = false; if (parametric) { ginfo.shading.triangle_parameters = params; - ginfo.shading.f_type = ShadingInfo::UseNew; ginfo.shading.shading_type = ShadingInfo::Parametric; } else @@ -513,7 +513,10 @@ namespace NSStructures ginfo.shading.patch[2][0] = curve_points[10]; ginfo.shading.patch[1][0] = curve_points[11]; - + ginfo.shading.f_type = ShadingInfo::UseNew; + ginfo.shading.function = ColorFunction(256, t0, t1); + ginfo.continue_shading_f = false; + ginfo.continue_shading_b = false; if (parametric) { @@ -522,11 +525,7 @@ namespace NSStructures ginfo.shading.patch_parameters[0][1] = curve_parametrs[1]; ginfo.shading.patch_parameters[1][0] = curve_parametrs[3]; ginfo.shading.patch_parameters[1][1] = curve_parametrs[2]; - ginfo.shading.f_type = ShadingInfo::UseNew; - ginfo.shading.function = ColorFunction(256, t0, t1); ginfo.shading.shading_type = ShadingInfo::Parametric; - ginfo.continue_shading_f = false; - ginfo.continue_shading_b = false; } else { @@ -549,14 +548,15 @@ namespace NSStructures ginfo.shading.patch = curve_poits; + ginfo.shading.f_type = ShadingInfo::UseNew; + ginfo.shading.function = ColorFunction(256, t0, t1); + ginfo.continue_shading_f = false; + ginfo.continue_shading_b = false; + if (parametric) { ginfo.shading.patch_parameters = curve_parametrs; - ginfo.shading.f_type = ShadingInfo::UseNew; - ginfo.shading.function = ColorFunction(256, t0, t1); ginfo.shading.shading_type = ShadingInfo::Parametric; - ginfo.continue_shading_f = false; - ginfo.continue_shading_b = false; } else { diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index eb666ddbc6..88fcd0c783 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -10,9 +10,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi { ui->setupUi(this); ui->lable_test->setStyleSheet("QLabel { background-color : white;}"); - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; ui->stackedWidget->setCurrentIndex(0); + ui->stackedWidget_2->setCurrentIndex(0); ui->statusbar->showMessage("Linear"); + ui->Rainbow_Colorspace_Radio_Button->setChecked(true); + info.colorspace = Rainbow; } MainWindow::~MainWindow() @@ -86,35 +88,84 @@ QImage GenerateImg(std::vector &points, Info &info, const int& w, const i return img; } -bool parametric = false; - void MainWindow::on_actionLinear_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(0); + ui->stackedWidget_2->setCurrentIndex(0); ui->statusbar->showMessage("Linear"); + info.gradient = Linear; info.gradient_type = c_BrushTypePathNewLinearGradient; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionRadial_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(1); + ui->stackedWidget_2->setCurrentIndex(1); ui->statusbar->showMessage("Radial"); + info.gradient = Radial; info.gradient_type = c_BrushTypePathRadialGradient; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionTriangle_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(2); + ui->stackedWidget_2->setCurrentIndex(2); ui->statusbar->showMessage("Triangle"); + info.gradient = Triangle; info.gradient_type = c_BrushTypeTriagnleMeshGradient; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionTriangle_Parametric_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(3); + ui->stackedWidget->setCurrentIndex(2); + ui->stackedWidget_2->setCurrentIndex(3); ui->statusbar->showMessage("Triangle Parametric"); + info.gradient = TriangleParametric; info.gradient_type = c_BrushTypeTriagnleMeshGradient; - parametric = true; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; +} + +void MainWindow::on_actionCoons_Patch_Gradient_triggered() +{ + ui->stackedWidget->setCurrentIndex(3); + ui->stackedWidget_2->setCurrentIndex(4); + ui->statusbar->showMessage("Coons Patch"); + info.gradient = CoonsPatch; + info.gradient_type = c_BrushTypePathNewLinearGradient; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; +} + +void MainWindow::on_actionCoons_Patch_Parametric_triggered() +{ + ui->stackedWidget->setCurrentIndex(3); + ui->stackedWidget_2->setCurrentIndex(5); + ui->statusbar->showMessage("Coons Patch Parametric"); + info.gradient = CoonsPatchParametric; + info.gradient_type = c_BrushTypeCurveGradient; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; +} + +void MainWindow::on_actionTensor_Coons_Patch_Gradient_triggered() +{ + ui->stackedWidget->setCurrentIndex(4); + ui->stackedWidget_2->setCurrentIndex(6); + ui->statusbar->showMessage("Tensor Coons Patch"); + info.gradient = TensorCoonsPatch; + info.gradient_type = c_BrushTypePathNewLinearGradient; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; +} + +void MainWindow::on_actionTensor_Coons_Patch_Parametric_triggered() +{ + ui->stackedWidget->setCurrentIndex(4); + ui->stackedWidget_2->setCurrentIndex(7); + ui->statusbar->showMessage("Tensor Coons Patch Parametric"); + info.gradient = TensorCoonsPatchParametric; + info.gradient_type = c_BrushTypeTensorCurveGradient; + points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_BAW_Colorspace_Radio_Button_clicked() @@ -138,7 +189,7 @@ void MainWindow::on_Rainbow_Colorspace_Radio_Button_clicked() void MainWindow::on_pushButton_clicked() { - if (info.gradient_type == c_BrushTypePathNewLinearGradient) + if (info.gradient == Linear) { if (ui->First_X_Coordinate_Input->text() == "") { @@ -166,7 +217,7 @@ void MainWindow::on_pushButton_clicked() info.p1.y = ui->Second_Y_Coordinate_Input->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); } - else if (info.gradient_type == c_BrushTypePathRadialGradient) + else if (info.gradient == Radial) { if (ui->First_Center_X_Coordinate_Input->text() == "") { @@ -206,7 +257,7 @@ void MainWindow::on_pushButton_clicked() info.r1 = ui->Second_Radius_Input->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, 0, 1, info.cont_b, info.cont_f); } - else if (info.gradient_type == c_BrushTypeTriagnleMeshGradient && !parametric) + else if (info.gradient == Triangle || info.gradient == TriangleParametric) { if (ui->First_Vertex_X_Coordinate_Input->text() == "") { @@ -244,58 +295,370 @@ void MainWindow::on_pushButton_clicked() return; } info.triangle[2].y = ui->Third_Vertex_Y_Coordinate_Input->text().toInt(); - info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, {}, false); + info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, + {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, + {}, + info.gradient == TriangleParametric); points = {}; for (auto p : info.triangle) { points.push_back({p.x, p.y}); } } - else if (info.gradient_type = c_BrushTypeTriagnleMeshGradient && parametric) + else if (info.gradient == CoonsPatch || info.gradient == CoonsPatchParametric) { - if (ui->First_Vertex_X_Coordinate_Input_2->text() == "") + if (ui->First_Vertex_X_Coordinate_Input_3->text() == "") { - ui->statusbar->showMessage("First Vertex X coordinate = NULL"); + ui->statusbar->showMessage("First Vertex X Coordinate = NULL"); return; } - info.triangle[0].x = ui->First_Vertex_X_Coordinate_Input_2->text().toInt(); - if (ui->First_Vertex_Y_Coordinate_Input_2->text() == "") + info.curve[0].x = 5 * ui->First_Vertex_X_Coordinate_Input_3->text().toInt(); + if (ui->First_Vertex_Y_Coordinate_Input_3->text() == "") { - ui->statusbar->showMessage("First Vertex Y coordinate = NULL"); + ui->statusbar->showMessage("First Vertex Y Coordinate = NULL"); return; } - info.triangle[0].y = ui->First_Vertex_Y_Coordinate_Input_2->text().toInt(); - if (ui->Second_Vertex_X_Coordinate_Input_2->text() == "") + info.curve[0].y = 5 * ui->First_Vertex_Y_Coordinate_Input_3->text().toInt(); + if (ui->First_X_Coordinate_First_Edge->text() == "") { - ui->statusbar->showMessage("Second Vertex X coordinate = NULL"); + ui->statusbar->showMessage("First X Coordinate First Edge = NULL"); return; } - info.triangle[1].x = ui->Second_Vertex_X_Coordinate_Input_2->text().toInt(); - if (ui->Second_Vertex_Y_Coordinate_Input_2->text() == "") + info.curve[1].x = 5 * ui->First_X_Coordinate_First_Edge->text().toInt(); + if (ui->First_Y_Coordinate_First_Edge->text() == "") { - ui->statusbar->showMessage("Second Vertex Y coordinate = NULL"); + ui->statusbar->showMessage("First Y Coordinate First Edge = NULL"); return; } - info.triangle[1].y = ui->Second_Vertex_Y_Coordinate_Input_2->text().toInt(); - if (ui->Third_Vertex_X_Coordinate_Input_2->text() == "") + info.curve[1].y = 5 * ui->First_Y_Coordinate_First_Edge->text().toInt(); + if (ui->Second_X_Coordinate_First_Edge->text() == "") { - ui->statusbar->showMessage("Third Vertex X coordinate = NULL"); + ui->statusbar->showMessage("Second X Coordinate First Edge = NULL"); return; } - info.triangle[2].x = ui->Third_Vertex_X_Coordinate_Input_2->text().toInt(); - if (ui->Third_Vertex_Y_Coordinate_Input_2->text() == "") + info.curve[2].x = 5 * ui->Second_X_Coordinate_First_Edge->text().toInt(); + if (ui->Second_Y_Coordinate_First_Edge->text() == "") { - ui->statusbar->showMessage("Third Vertex Y coordinate = NULL"); + ui->statusbar->showMessage("Second Y Coordinate First Edge = NULL"); return; } - info.triangle[2].y = ui->Third_Vertex_Y_Coordinate_Input_2->text().toInt(); - info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.4f, 1.f}, true); - points = {}; - for (auto p : info.triangle) + info.curve[2].y = 5 * ui->Second_Y_Coordinate_First_Edge->text().toInt(); + if (ui->Second_Vertex_X_Coordinate_Input_3->text() == "") { - points.push_back({p.x, p.y}); + ui->statusbar->showMessage("Second Vertex X Coordinate = NULL"); + return; } + info.curve[3].x = 5 * ui->Second_Vertex_X_Coordinate_Input_3->text().toInt(); + if (ui->Second_Vertex_Y_Coordinate_Input_3->text() == "") + { + ui->statusbar->showMessage("Second Vertex Y Coordinate = NULL"); + return; + } + info.curve[3].y = 5 * ui->Second_Vertex_Y_Coordinate_Input_3->text().toInt(); + if (ui->First_X_Coordinate_Second_Edge->text() == "") + { + ui->statusbar->showMessage("First X Coordinate Second Edge = NULL"); + return; + } + info.curve[4].x = 5 * ui->First_X_Coordinate_Second_Edge->text().toInt(); + if (ui->First_Y_Coordinate_Second_Edge->text() == "") + { + ui->statusbar->showMessage("First Y Coordinate Second Edge = NULL"); + return; + } + info.curve[4].y = 5 * ui->First_Y_Coordinate_Second_Edge->text().toInt(); + if (ui->Second_X_Coordinate_Second_Edge->text() == "") + { + ui->statusbar->showMessage("Second X Coordinate Second Edge = NULL"); + return; + } + info.curve[5].x = 5 * ui->Second_X_Coordinate_Second_Edge->text().toInt(); + if (ui->Second_Y_Coordinate_Second_Edge->text() == "") + { + ui->statusbar->showMessage("Second Y Coordinate Second Edge = NULL"); + return; + } + info.curve[5].y = 5 * ui->Second_Y_Coordinate_Second_Edge->text().toInt(); + if (ui->Third_Vertex_X_Coordinate_Input_3->text() == "") + { + ui->statusbar->showMessage("Third Vertex X Coordinate = NULL"); + return; + } + info.curve[6].x = 5 * ui->Third_Vertex_X_Coordinate_Input_3->text().toInt(); + if (ui->Third_Vertex_Y_Coordinate_Input_3->text() == "") + { + ui->statusbar->showMessage("Third Vertex Y Coordinate = NULL"); + return; + } + info.curve[6].y = 5 * ui->Third_Vertex_Y_Coordinate_Input_3->text().toInt(); + if (ui->First_X_Coordinate_Third_Edge->text() == "") + { + ui->statusbar->showMessage("First X Coordinate Third Edge = NULL"); + return; + } + info.curve[7].x = 5 * ui->First_X_Coordinate_Third_Edge->text().toInt(); + if (ui->First_Y_Coordinate_Third_Edge->text() == "") + { + ui->statusbar->showMessage("First Y Coordinate Third Edge = NULL"); + return; + } + info.curve[7].y = 5 * ui->First_Y_Coordinate_Third_Edge->text().toInt(); + if (ui->Second_X_Coordinate_Third_Edge->text() == "") + { + ui->statusbar->showMessage("Second X Coordinate Third Edge = NULL"); + return; + } + info.curve[8].x = 5 * ui->Second_X_Coordinate_Third_Edge->text().toInt(); + if (ui->Second_Y_Coordinate_Third_Edge->text() == "") + { + ui->statusbar->showMessage("Second Y Coordinate Third Edge = NULL"); + return; + } + info.curve[8].y = 5 * ui->Second_Y_Coordinate_Third_Edge->text().toInt(); + if (ui->Fourth_Vertex_X_Coordinate_Input_3->text() == "") + { + ui->statusbar->showMessage("Fourth Vertex X Coordinate = NULL"); + return; + } + info.curve[9].x = 5 * ui->Fourth_Vertex_X_Coordinate_Input_3->text().toInt(); + if (ui->Fourth_Vertex_Y_Coordinate_Input_3->text() == "") + { + ui->statusbar->showMessage("Fourth Vertex Y Coordinate = NULL"); + return; + } + info.curve[9].y = 5 * ui->Fourth_Vertex_Y_Coordinate_Input_3->text().toInt(); + if (ui->First_X_Coordinate_Fourth_Edge->text() == "") + { + ui->statusbar->showMessage("First X Coordinate Fourth Edge = NULL"); + return; + } + info.curve[10].x = 5 * ui->First_X_Coordinate_Fourth_Edge->text().toInt(); + if (ui->First_Y_Coordinate_Fourth_Edge->text() == "") + { + ui->statusbar->showMessage("First Y Coordinate Fourth Edge = NULL"); + return; + } + info.curve[10].y = 5 * ui->First_Y_Coordinate_Fourth_Edge->text().toInt(); + if (ui->Second_X_Coordinate_Fourth_Edge->text() == "") + { + ui->statusbar->showMessage("Second X Coordinate Fourth Edge = NULL"); + return; + } + info.curve[11].x = 5 * ui->Second_X_Coordinate_Fourth_Edge->text().toInt(); + if (ui->Second_Y_Coordinate_Fourth_Edge->text() == "") + { + ui->statusbar->showMessage("Second Y Coordinate Fourth Edge = NULL"); + return; + } + info.curve[11].y = 5 * ui->Second_Y_Coordinate_Fourth_Edge->text().toInt(); + info.ginfo = NSStructures::GInfoConstructor::get_curve( + info.curve, + {0, 0.5, 1, 0.5}, + {{0, 0, 255}, {255, 0, 255}, + {255, 0, 0}, {0, 255, 0}}, + info.gradient == CoonsPatchParametric + ); + } + else if (info.gradient == TensorCoonsPatch || info.gradient == TensorCoonsPatchParametric) + { + if (ui->First_X_Coordinate_First_Edge_3->text() == "") + { + ui->statusbar->showMessage("First X Coordinate First Edge = NULL"); + return; + } + info.tensorcurve[0][0].x = 5 * ui->First_X_Coordinate_First_Edge_3->text().toInt(); + if (ui->First_Y_Coordinate_First_Edge_3->text() == "") + { + ui->statusbar->showMessage("First Y Coordinate First Edge = NULL"); + return; + } + info.tensorcurve[0][0].y = 5 * ui->First_Y_Coordinate_First_Edge_3->text().toInt(); + if (ui->Second_X_Coordinate_First_Edge_3->text() == "") + { + ui->statusbar->showMessage("Second X Coordinate First Edge = NULL"); + return; + } + info.tensorcurve[0][1].x = 5 * ui->Second_X_Coordinate_First_Edge_3->text().toInt(); + if (ui->Second_Y_Coordinate_First_Edge_3->text() == "") + { + ui->statusbar->showMessage("Second Y Coordinate First Edge = NULL"); + return; + } + info.tensorcurve[0][1].y = 5 * ui->Second_Y_Coordinate_First_Edge_3->text().toInt(); + if (ui->Third_X_Coordinate_First_Edge_3->text() == "") + { + ui->statusbar->showMessage("Third X Coordinate First Edge = NULL"); + return; + } + info.tensorcurve[0][2].x = 5 * ui->Third_X_Coordinate_First_Edge_3->text().toInt(); + if (ui->Third_Y_Coordinate_First_Edge_3->text() == "") + { + ui->statusbar->showMessage("Third Y Coordinate First Edge = NULL"); + return; + } + info.tensorcurve[0][2].y = 5 * ui->Third_Y_Coordinate_First_Edge_3->text().toInt(); + if (ui->Fourth_X_Coordinate_First_Edge_3->text() == "") + { + ui->statusbar->showMessage("Fourth X Coordinate First Edge = NULL"); + return; + } + info.tensorcurve[0][3].x = 5 * ui->Fourth_X_Coordinate_First_Edge_3->text().toInt(); + if (ui->Fourth_Y_Coordinate_First_Edge_3->text() == "") + { + ui->statusbar->showMessage("Fourth Y Coordinate First Edge = NULL"); + return; + } + info.tensorcurve[0][3].y = 5 * ui->Fourth_Y_Coordinate_First_Edge_3->text().toInt(); + if (ui->First_X_Coordinate_Second_Edge_3->text() == "") + { + ui->statusbar->showMessage("First X Coordinate Second Edge = NULL"); + return; + } + info.tensorcurve[1][0].x = 5 * ui->First_X_Coordinate_Second_Edge_3->text().toInt(); + if (ui->First_Vertex_Y_Coordinate_Input_3->text() == "") + { + ui->statusbar->showMessage("First Y Coordinate Second Edge = NULL"); + return; + } + info.tensorcurve[1][0].y = 5 * ui->First_Y_Coordinate_Second_Edge_3->text().toInt(); + if (ui->Second_X_Coordinate_Second_Edge_3->text() == "") + { + ui->statusbar->showMessage("Second X Coordinate Second Edge = NULL"); + return; + } + info.tensorcurve[1][1].x = 5 * ui->Second_X_Coordinate_Second_Edge_3->text().toInt(); + if (ui->Second_Y_Coordinate_Second_Edge_3->text() == "") + { + ui->statusbar->showMessage("Second Y Coordinate Second Edge = NULL"); + return; + } + info.tensorcurve[1][1].y = 5 * ui->Second_Y_Coordinate_Second_Edge_3->text().toInt(); + if (ui->Third_X_Coordinate_Second_Edge_3->text() == "") + { + ui->statusbar->showMessage("Third X Coordinate Second Edge = NULL"); + return; + } + info.tensorcurve[1][2].x = 5 * ui->Third_X_Coordinate_Second_Edge_3->text().toInt(); + if (ui->Third_Y_Coordinate_Second_Edge_3->text() == "") + { + ui->statusbar->showMessage("Third Y Coordinate Second Edge = NULL"); + return; + } + info.tensorcurve[1][2].y = 5 * ui->Third_Y_Coordinate_Second_Edge_3->text().toInt(); + if (ui->Fourth_X_Coordinate_Second_Edge_3->text() == "") + { + ui->statusbar->showMessage("Fourth X Coordinate Second Edge = NULL"); + return; + } + info.tensorcurve[1][3].x = 5 * ui->Fourth_X_Coordinate_Second_Edge_3->text().toInt(); + if (ui->Fourth_Y_Coordinate_Second_Edge_3->text() == "") + { + ui->statusbar->showMessage("Fourth Y Coordinate Second Edge = NULL"); + return; + } + info.tensorcurve[1][3].y = 5 * ui->Fourth_Y_Coordinate_Second_Edge_3->text().toInt(); + if (ui->First_X_Coordinate_Third_Edge_3->text() == "") + { + ui->statusbar->showMessage("First X Coordinate Third Edge = NULL"); + return; + } + info.tensorcurve[2][0].x = 5 * ui->First_X_Coordinate_Third_Edge_3->text().toInt(); + if (ui->First_Y_Coordinate_Third_Edge_3->text() == "") + { + ui->statusbar->showMessage("First Y Coordinate Third Edge = NULL"); + return; + } + info.tensorcurve[2][0].y = 5 * ui->First_Y_Coordinate_Third_Edge_3->text().toInt(); + if (ui->Second_X_Coordinate_Third_Edge_3->text() == "") + { + ui->statusbar->showMessage("Second X Coordinate Third Edge = NULL"); + return; + } + info.tensorcurve[2][1].x = 5 * ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); + if (ui->Second_Y_Coordinate_Third_Edge_3->text() == "") + { + ui->statusbar->showMessage("Second Y Coordinate Third Edge = NULL"); + return; + } + info.tensorcurve[2][1].y = 5 * ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); + if (ui->Third_X_Coordinate_Third_Edge_3->text() == "") + { + ui->statusbar->showMessage("Third X Coordinate Third Edge = NULL"); + return; + } + info.tensorcurve[2][2].x = 5 * ui->Third_X_Coordinate_Third_Edge_3->text().toInt(); + if (ui->Third_Y_Coordinate_Third_Edge_3->text() == "") + { + ui->statusbar->showMessage("Third Y Coordinate Third Edge = NULL"); + return; + } + info.tensorcurve[2][2].y = 5 * ui->Third_Y_Coordinate_Third_Edge_3->text().toInt(); + if (ui->Fourth_X_Coordinate_Third_Edge_3->text() == "") + { + ui->statusbar->showMessage("Fourth X Coordinate Third Edge = NULL"); + return; + } + info.tensorcurve[2][3].x = 5 * ui->Fourth_X_Coordinate_Third_Edge_3->text().toInt(); + if (ui->Fourth_Y_Coordinate_Third_Edge_3->text() == "") + { + ui->statusbar->showMessage("Fourth Y Coordinate Third Edge = NULL"); + return; + } + info.tensorcurve[2][3].y = 5 * ui->Fourth_Y_Coordinate_Third_Edge_3->text().toInt(); + if (ui->First_X_Coordinate_Fourth_Edge_3->text() == "") + { + ui->statusbar->showMessage("First X Coordinate Fourth Edge = NULL"); + return; + } + info.tensorcurve[3][0].x = 5 * ui->First_X_Coordinate_Fourth_Edge_3->text().toInt(); + if (ui->First_Y_Coordinate_Fourth_Edge_3->text() == "") + { + ui->statusbar->showMessage("First Y Coordinate Fourth Edge = NULL"); + return; + } + info.tensorcurve[3][0].y = 5 * ui->First_Y_Coordinate_Fourth_Edge_3->text().toInt(); + if (ui->Second_X_Coordinate_Fourth_Edge_3->text() == "") + { + ui->statusbar->showMessage("Second X Coordinate Fourth Edge = NULL"); + return; + } + info.tensorcurve[3][1].x = 5 * ui->Second_X_Coordinate_Fourth_Edge_3->text().toInt(); + if (ui->Second_Y_Coordinate_Fourth_Edge_3->text() == "") + { + ui->statusbar->showMessage("Second Y Coordinate Fourth Edge = NULL"); + return; + } + info.tensorcurve[3][1].y = 5 * ui->Second_Y_Coordinate_Fourth_Edge_3->text().toInt(); + if (ui->Third_X_Coordinate_Fourth_Edge_3->text() == "") + { + ui->statusbar->showMessage("Third X Coordinate Fourth Edge = NULL"); + return; + } + info.tensorcurve[3][2].x = 5 * ui->Third_X_Coordinate_Fourth_Edge_3->text().toInt(); + if (ui->Third_Y_Coordinate_Fourth_Edge_3->text() == "") + { + ui->statusbar->showMessage("Third X Coordinate Fourth Edge = NULL"); + return; + } + info.tensorcurve[3][2].y = 5 * ui->Third_Y_Coordinate_Fourth_Edge_3->text().toInt(); + if (ui->Fourth_X_Coordinate_Fourth_Edge_3->text() == "") + { + ui->statusbar->showMessage("Fourth X Coordinate Fourth Edge = NULL"); + return; + } + info.tensorcurve[3][3].x = 5 * ui->Fourth_X_Coordinate_Fourth_Edge_3->text().toInt(); + if (ui->Fourth_Y_Coordinate_Fourth_Edge_3->text() == "") + { + ui->statusbar->showMessage("Fourth Y Coordinate Fourth Edge = NULL"); + return; + } + info.tensorcurve[3][3].y = 5 * ui->Fourth_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve( + info.tensorcurve, + {{0, 0.5}, {1, 0.5}}, + {{{0, 0, 255}, {255, 0, 255}}, {{255, 0, 0}, {0, 255, 0}}}, + info.gradient == TensorCoonsPatchParametric + ); } if (info.colorspace == NoColorspaceType) @@ -451,38 +814,338 @@ void MainWindow::on_Third_Vertex_Y_Coordinate_Input_editingFinished() } -void MainWindow::on_First_Vertex_X_Coordinate_Input_2_editingFinished() +void MainWindow::on_First_Vertex_X_Coordinate_Input_3_editingFinished() { - ClampCoords(ui->First_Vertex_X_Coordinate_Input_2); + ClampCoords(ui->First_Vertex_X_Coordinate_Input_3); } -void MainWindow::on_First_Vertex_Y_Coordinate_Input_2_editingFinished() +void MainWindow::on_First_Vertex_Y_Coordinate_Input_3_editingFinished() { - ClampCoords(ui->First_Vertex_Y_Coordinate_Input_2); + ClampCoords(ui->First_Vertex_Y_Coordinate_Input_3); } -void MainWindow::on_Second_Vertex_X_Coordinate_Input_2_editingFinished() +void MainWindow::on_Second_Vertex_X_Coordinate_Input_3_editingFinished() { - ClampCoords(ui->Second_Vertex_X_Coordinate_Input_2); + ClampCoords(ui->Second_Vertex_X_Coordinate_Input_3); } -void MainWindow::on_Second_Vertex_Y_Coordinate_Input_2_editingFinished() +void MainWindow::on_Second_Vertex_Y_Coordinate_Input_3_editingFinished() { - ClampCoords(ui->Second_Vertex_Y_Coordinate_Input_2); + ClampCoords(ui->Second_Vertex_Y_Coordinate_Input_3); } -void MainWindow::on_Third_Vertex_X_Coordinate_Input_2_editingFinished() +void MainWindow::on_Third_Vertex_X_Coordinate_Input_3_editingFinished() { - ClampCoords(ui->Third_Vertex_X_Coordinate_Input_2); + ClampCoords(ui->Third_Vertex_X_Coordinate_Input_3); } -void MainWindow::on_Third_Vertex_Y_Coordinate_Input_2_editingFinished() +void MainWindow::on_Third_Vertex_Y_Coordinate_Input_3_editingFinished() { - ClampCoords(ui->Third_Vertex_Y_Coordinate_Input_2); + ClampCoords(ui->Third_Vertex_Y_Coordinate_Input_3); +} + + +void MainWindow::on_Fourth_Vertex_X_Coordinate_Input_3_editingFinished() +{ + ClampCoords(ui->Fourth_Vertex_X_Coordinate_Input_3); +} + + +void MainWindow::on_Fourth_Vertex_Y_Coordinate_Input_3_editingFinished() +{ + ClampCoords(ui->Fourth_Vertex_Y_Coordinate_Input_3); +} + + +void MainWindow::on_First_X_Coordinate_First_Edge_editingFinished() +{ + ClampCoords(ui->First_X_Coordinate_First_Edge); +} + + +void MainWindow::on_First_Y_Coordinate_First_Edge_editingFinished() +{ + ClampCoords(ui->First_Y_Coordinate_First_Edge); +} + + +void MainWindow::on_Second_X_Coordinate_First_Edge_editingFinished() +{ + ClampCoords(ui->Second_X_Coordinate_First_Edge); +} + + +void MainWindow::on_Second_Y_Coordinate_First_Edge_editingFinished() +{ + ClampCoords(ui->Second_Y_Coordinate_First_Edge); +} + + +void MainWindow::on_First_X_Coordinate_Second_Edge_editingFinished() +{ + ClampCoords(ui->First_X_Coordinate_Second_Edge); +} + + +void MainWindow::on_First_Y_Coordinate_Second_Edge_editingFinished() +{ + ClampCoords(ui->First_Y_Coordinate_Second_Edge); +} + + +void MainWindow::on_Second_X_Coordinate_Second_Edge_editingFinished() +{ + ClampCoords(ui->Second_X_Coordinate_Second_Edge); +} + + +void MainWindow::on_Second_Y_Coordinate_Second_Edge_editingFinished() +{ + ClampCoords(ui->Second_Y_Coordinate_Second_Edge); +} + + +void MainWindow::on_First_X_Coordinate_Third_Edge_editingFinished() +{ + ClampCoords(ui->First_X_Coordinate_Third_Edge); +} + + +void MainWindow::on_First_Y_Coordinate_Third_Edge_editingFinished() +{ + ClampCoords(ui->First_Y_Coordinate_Third_Edge); +} + + +void MainWindow::on_Second_X_Coordinate_Third_Edge_editingFinished() +{ + ClampCoords(ui->Second_X_Coordinate_Third_Edge); +} + + +void MainWindow::on_Second_Y_Coordinate_Third_Edge_editingFinished() +{ + ClampCoords(ui->Second_Y_Coordinate_Third_Edge); +} + + +void MainWindow::on_First_X_Coordinate_Fourth_Edge_editingFinished() +{ + ClampCoords(ui->First_X_Coordinate_Fourth_Edge); +} + + +void MainWindow::on_First_Y_Coordinate_Fourth_Edge_editingFinished() +{ + ClampCoords(ui->First_Y_Coordinate_Fourth_Edge); +} + + +void MainWindow::on_Second_X_Coordinate_Fourth_Edge_editingFinished() +{ + ClampCoords(ui->Second_X_Coordinate_Fourth_Edge); +} + + +void MainWindow::on_Second_Y_Coordinate_Fourth_Edge_editingFinished() +{ + ClampCoords(ui->Second_Y_Coordinate_Fourth_Edge); +} + + +void MainWindow::on_First_X_Coordinate_First_Edge_3_editingFinished() +{ + ClampCoords(ui->First_X_Coordinate_First_Edge_3); +} + + +void MainWindow::on_First_Y_Coordinate_First_Edge_3_editingFinished() +{ + ClampCoords(ui->First_Y_Coordinate_First_Edge_3); +} + + +void MainWindow::on_Second_X_Coordinate_First_Edge_3_editingFinished() +{ + ClampCoords(ui->Second_X_Coordinate_First_Edge_3); +} + + +void MainWindow::on_Second_Y_Coordinate_First_Edge_3_editingFinished() +{ + ClampCoords(ui->Second_Y_Coordinate_First_Edge_3); +} + + +void MainWindow::on_Third_X_Coordinate_First_Edge_3_editingFinished() +{ + ClampCoords(ui->Third_X_Coordinate_First_Edge_3); +} + + +void MainWindow::on_Third_Y_Coordinate_First_Edge_3_editingFinished() +{ + ClampCoords(ui->Third_Y_Coordinate_First_Edge_3); +} + + +void MainWindow::on_Fourth_X_Coordinate_First_Edge_3_editingFinished() +{ + ClampCoords(ui->Fourth_X_Coordinate_First_Edge_3); +} + + +void MainWindow::on_Fourth_Y_Coordinate_First_Edge_3_editingFinished() +{ + ClampCoords(ui->Fourth_Y_Coordinate_First_Edge_3); +} + + +void MainWindow::on_First_X_Coordinate_Second_Edge_3_editingFinished() +{ + ClampCoords(ui->First_X_Coordinate_Second_Edge_3); +} + + +void MainWindow::on_First_Y_Coordinate_Second_Edge_3_editingFinished() +{ + ClampCoords(ui->First_Y_Coordinate_Second_Edge_3); +} + + +void MainWindow::on_Second_X_Coordinate_Second_Edge_3_editingFinished() +{ + ClampCoords(ui->Second_X_Coordinate_Second_Edge_3); +} + + +void MainWindow::on_Second_Y_Coordinate_Second_Edge_3_editingFinished() +{ + ClampCoords(ui->Second_Y_Coordinate_Second_Edge_3); +} + + +void MainWindow::on_Third_X_Coordinate_Second_Edge_3_editingFinished() +{ + ClampCoords(ui->Third_X_Coordinate_Second_Edge_3); +} + + +void MainWindow::on_Third_Y_Coordinate_Second_Edge_3_editingFinished() +{ + ClampCoords(ui->Third_Y_Coordinate_Second_Edge_3); +} + + +void MainWindow::on_Fourth_X_Coordinate_Second_Edge_3_editingFinished() +{ + ClampCoords(ui->Fourth_X_Coordinate_Second_Edge_3); +} + + +void MainWindow::on_Fourth_Y_Coordinate_Second_Edge_3_editingFinished() +{ + ClampCoords(ui->Fourth_Y_Coordinate_Second_Edge_3); +} + + +void MainWindow::on_First_X_Coordinate_Third_Edge_3_editingFinished() +{ + ClampCoords(ui->First_X_Coordinate_Third_Edge_3); +} + + +void MainWindow::on_First_Y_Coordinate_Third_Edge_3_editingFinished() +{ + ClampCoords(ui->First_Y_Coordinate_Third_Edge_3); +} + + +void MainWindow::on_Second_X_Coordinate_Third_Edge_3_editingFinished() +{ + ClampCoords(ui->Second_X_Coordinate_Third_Edge_3); +} + + +void MainWindow::on_Second_Y_Coordinate_Third_Edge_3_editingFinished() +{ + ClampCoords(ui->Second_Y_Coordinate_Third_Edge_3); +} + + +void MainWindow::on_Third_X_Coordinate_Third_Edge_3_editingFinished() +{ + ClampCoords(ui->Third_X_Coordinate_Third_Edge_3); +} + + +void MainWindow::on_Third_Y_Coordinate_Third_Edge_3_editingFinished() +{ + ClampCoords(ui->Third_Y_Coordinate_Third_Edge_3); +} + + +void MainWindow::on_Fourth_X_Coordinate_Third_Edge_3_editingFinished() +{ + ClampCoords(ui->Fourth_X_Coordinate_Third_Edge_3); +} + + +void MainWindow::on_Fourth_Y_Coordinate_Third_Edge_3_editingFinished() +{ + ClampCoords(ui->Fourth_Y_Coordinate_Third_Edge_3); +} + + +void MainWindow::on_First_X_Coordinate_Fourth_Edge_3_editingFinished() +{ + ClampCoords(ui->First_X_Coordinate_Fourth_Edge_3); +} + + +void MainWindow::on_First_Y_Coordinate_Fourth_Edge_3_editingFinished() +{ + ClampCoords(ui->First_Y_Coordinate_Fourth_Edge_3); +} + + +void MainWindow::on_Second_X_Coordinate_Fourth_Edge_3_editingFinished() +{ + ClampCoords(ui->Second_X_Coordinate_Fourth_Edge_3); +} + + +void MainWindow::on_Second_Y_Coordinate_Fourth_Edge_3_editingFinished() +{ + ClampCoords(ui->Second_Y_Coordinate_Fourth_Edge_3); +} + + +void MainWindow::on_Third_X_Coordinate_Fourth_Edge_3_editingFinished() +{ + ClampCoords(ui->Third_X_Coordinate_Fourth_Edge_3); +} + + +void MainWindow::on_Third_Y_Coordinate_Fourth_Edge_3_editingFinished() +{ + ClampCoords(ui->Third_Y_Coordinate_Fourth_Edge_3); +} + + +void MainWindow::on_Fourth_X_Coordinate_Fourth_Edge_3_editingFinished() +{ + ClampCoords(ui->Fourth_X_Coordinate_Fourth_Edge_3); +} + + +void MainWindow::on_Fourth_Y_Coordinate_Fourth_Edge_3_editingFinished() +{ + ClampCoords(ui->Fourth_Y_Coordinate_Fourth_Edge_3); } diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index d9f5e08269..99c51b16d7 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -13,6 +13,19 @@ namespace Ui } QT_END_NAMESPACE +typedef enum +{ + Linear, + Radial, + Triangle, + TriangleParametric, + CoonsPatch, + CoonsPatchParametric, + TensorCoonsPatch, + TensorCoonsPatchParametric, + Functional +} GradientType; + typedef enum { NoColorspaceType, @@ -51,12 +64,20 @@ struct Color struct Info { ColorspaceType colorspace = NoColorspaceType; + GradientType gradient = Linear; float r0, r1; NSStructures::Point c0, c1; NSStructures::Point p0, p1; bool cont_b, cont_f; std::vector triangle = {{100, 100}, {300, 200}, {200, 350}}; + std::vector curve = {{100, 300}, {50, 250}, {150, 150}, {100, 100}, + {150, 50}, {250, 150}, {300, 100}, {250, 150}, + {350, 250}, {300, 300}, {250, 350}, {150,250}}; + std::vector> tensorcurve = {{{100, 300}, {150, 250}, {50, 150}, {100,100}}, + {{150, 250}, {170, 230}, {170, 170}, {50, 150}}, + {{350, 250}, {230, 230}, {230, 170}, {150, 250}}, + {{300, 300}, {250, 250}, {350, 150}, {300, 100}}}; NSStructures::GradientInfo ginfo; int gradient_type; @@ -155,17 +176,125 @@ private slots: void on_actionTriangle_Parametric_Gradient_triggered(); - void on_First_Vertex_X_Coordinate_Input_2_editingFinished(); + void on_actionCoons_Patch_Gradient_triggered(); - void on_First_Vertex_Y_Coordinate_Input_2_editingFinished(); + void on_actionCoons_Patch_Parametric_triggered(); - void on_Second_Vertex_X_Coordinate_Input_2_editingFinished(); + void on_actionTensor_Coons_Patch_Gradient_triggered(); - void on_Second_Vertex_Y_Coordinate_Input_2_editingFinished(); + void on_actionTensor_Coons_Patch_Parametric_triggered(); - void on_Third_Vertex_X_Coordinate_Input_2_editingFinished(); + void on_First_Vertex_X_Coordinate_Input_3_editingFinished(); - void on_Third_Vertex_Y_Coordinate_Input_2_editingFinished(); + void on_First_Vertex_Y_Coordinate_Input_3_editingFinished(); + + void on_Second_Vertex_X_Coordinate_Input_3_editingFinished(); + + void on_Second_Vertex_Y_Coordinate_Input_3_editingFinished(); + + void on_Third_Vertex_X_Coordinate_Input_3_editingFinished(); + + void on_Third_Vertex_Y_Coordinate_Input_3_editingFinished(); + + void on_Fourth_Vertex_X_Coordinate_Input_3_editingFinished(); + + void on_Fourth_Vertex_Y_Coordinate_Input_3_editingFinished(); + + void on_First_X_Coordinate_First_Edge_editingFinished(); + + void on_First_Y_Coordinate_First_Edge_editingFinished(); + + void on_Second_X_Coordinate_First_Edge_editingFinished(); + + void on_Second_Y_Coordinate_First_Edge_editingFinished(); + + void on_First_X_Coordinate_Second_Edge_editingFinished(); + + void on_First_Y_Coordinate_Second_Edge_editingFinished(); + + void on_Second_X_Coordinate_Second_Edge_editingFinished(); + + void on_Second_Y_Coordinate_Second_Edge_editingFinished(); + + void on_First_X_Coordinate_Third_Edge_editingFinished(); + + void on_First_Y_Coordinate_Third_Edge_editingFinished(); + + void on_Second_X_Coordinate_Third_Edge_editingFinished(); + + void on_Second_Y_Coordinate_Third_Edge_editingFinished(); + + void on_First_X_Coordinate_Fourth_Edge_editingFinished(); + + void on_First_Y_Coordinate_Fourth_Edge_editingFinished(); + + void on_Second_X_Coordinate_Fourth_Edge_editingFinished(); + + void on_Second_Y_Coordinate_Fourth_Edge_editingFinished(); + + void on_First_X_Coordinate_First_Edge_3_editingFinished(); + + void on_First_Y_Coordinate_First_Edge_3_editingFinished(); + + void on_Second_X_Coordinate_First_Edge_3_editingFinished(); + + void on_Second_Y_Coordinate_First_Edge_3_editingFinished(); + + void on_Third_X_Coordinate_First_Edge_3_editingFinished(); + + void on_Third_Y_Coordinate_First_Edge_3_editingFinished(); + + void on_Fourth_X_Coordinate_First_Edge_3_editingFinished(); + + void on_Fourth_Y_Coordinate_First_Edge_3_editingFinished(); + + void on_First_X_Coordinate_Second_Edge_3_editingFinished(); + + void on_First_Y_Coordinate_Second_Edge_3_editingFinished(); + + void on_Second_X_Coordinate_Second_Edge_3_editingFinished(); + + void on_Second_Y_Coordinate_Second_Edge_3_editingFinished(); + + void on_Third_X_Coordinate_Second_Edge_3_editingFinished(); + + void on_Third_Y_Coordinate_Second_Edge_3_editingFinished(); + + void on_Fourth_X_Coordinate_Second_Edge_3_editingFinished(); + + void on_Fourth_Y_Coordinate_Second_Edge_3_editingFinished(); + + void on_First_X_Coordinate_Third_Edge_3_editingFinished(); + + void on_First_Y_Coordinate_Third_Edge_3_editingFinished(); + + void on_Second_X_Coordinate_Third_Edge_3_editingFinished(); + + void on_Second_Y_Coordinate_Third_Edge_3_editingFinished(); + + void on_Third_X_Coordinate_Third_Edge_3_editingFinished(); + + void on_Third_Y_Coordinate_Third_Edge_3_editingFinished(); + + void on_Fourth_X_Coordinate_Third_Edge_3_editingFinished(); + + void on_Fourth_Y_Coordinate_Third_Edge_3_editingFinished(); + + void on_First_X_Coordinate_Fourth_Edge_3_editingFinished(); + + void on_First_Y_Coordinate_Fourth_Edge_3_editingFinished(); + + void on_Second_X_Coordinate_Fourth_Edge_3_editingFinished(); + + void on_Second_Y_Coordinate_Fourth_Edge_3_editingFinished(); + + void on_Third_X_Coordinate_Fourth_Edge_3_editingFinished(); + + void on_Third_Y_Coordinate_Fourth_Edge_3_editingFinished(); + + void on_Fourth_X_Coordinate_Fourth_Edge_3_editingFinished(); + + void on_Fourth_Y_Coordinate_Fourth_Edge_3_editingFinished(); private: Ui::MainWindow *ui; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index 3f6d8e099e..713a17ab4b 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1060 - 592 + 1126 + 827 @@ -33,24 +33,12 @@ - 520 + 510 0 - 535 - 500 + 610 + 740 - - - 535 - 0 - - - - - 535 - 16777215 - - @@ -124,12 +112,12 @@ 10 160 - 511 - 330 + 590 + 570 - 3 + 0 @@ -137,8 +125,8 @@ 0 10 - 371 - 160 + 440 + 150 @@ -166,6 +154,9 @@ 28 + + 10 + @@ -189,11 +180,14 @@ 28 + + 10 + - 180 + 240 30 180 20 @@ -206,17 +200,20 @@ - 180 + 240 50 113 28 + + 90 + - 180 + 240 80 179 20 @@ -229,21 +226,24 @@ - 180 + 240 100 113 28 + + 90 + - 380 + 450 10 131 - 161 + 150 @@ -276,47 +276,15 @@ - - - - 10 - 180 - 415 - 20 - - - - A linear gradient describes a color change along a straight line - - - Qt::AutoText - - - - - - 10 - 200 - 415 - 20 - - - - that is defined by two points. - - - Qt::AutoText - - - 380 - 160 + 450 + 10 131 - 161 + 150 @@ -354,7 +322,7 @@ 0 10 - 510 + 440 150 @@ -383,6 +351,9 @@ 28 + + 50 + @@ -406,11 +377,14 @@ 28 + + 50 + - 280 + 230 30 190 20 @@ -423,17 +397,20 @@ - 280 + 230 50 113 28 + + 50 + - 280 + 230 80 189 20 @@ -446,12 +423,15 @@ - 280 + 230 100 113 28 + + 50 + @@ -459,7 +439,7 @@ 0 160 - 371 + 440 100 @@ -482,7 +462,7 @@ - 200 + 230 30 97 20 @@ -501,66 +481,33 @@ 28 + + 10 + - 200 + 230 50 113 28 + + 30 + - - - - 0 - 260 - 319 - 20 - - - - Radial gradient describes the color change from - - - - - - 0 - 280 - 335 - 20 - - - - the center to the edges, it is defined by two circles, - - - - - - 0 - 300 - 281 - 20 - - - - which are defined by the center and radius - - - + 0 10 - 510 - 240 + 590 + 140 @@ -569,7 +516,7 @@ - 20 + 10 30 168 20 @@ -582,17 +529,20 @@ - 20 + 10 50 113 28 + + 50 + - 20 + 10 80 167 20 @@ -605,17 +555,20 @@ - 20 + 10 100 113 28 + + 20 + - 280 + 200 30 188 20 @@ -628,17 +581,20 @@ - 280 + 200 50 113 28 + + 20 + - 280 + 200 80 187 20 @@ -651,18 +607,21 @@ - 280 + 200 100 113 28 + + 70 + - 20 - 140 + 410 + 30 173 20 @@ -674,18 +633,21 @@ - 20 - 160 + 410 + 50 113 28 + + 80 + - 20 - 190 + 410 + 80 173 20 @@ -697,217 +659,1605 @@ - 20 - 210 + 410 + 100 113 28 + + 70 + - - - - 0 - 250 - 502 - 20 - - - - Triangle gradient describes the color change between the three vertices of a - - - - - - 0 - 270 - 512 - 20 - - - - triangle. The color change occurs according to the principle of linear gradient - - - - - - 0 - 290 - 476 - 20 - - - - along the perpendiculars from the triangle vertex to the point where the - - - - - - 0 - 310 - 161 - 20 - - - - perpendiculars intersect. - - - - + + 0 10 - 510 - 260 + 590 + 140 - Set Coordinates Of Triangle Vertices + Set Coordinates Of Square Vertices - + - 20 + 10 30 - 168 + 118 20 - X Coordinate, First Vertex + First X Coordinate - + - 20 + 10 50 113 28 + + 20 + - + - 20 + 10 80 - 167 + 117 20 - Y Coordinate, First Vertex + First Y Coordinate - + - 20 + 10 100 113 28 + + 60 + - + - 280 + 140 30 - 188 + 140 20 - X Coordinate, Second Vertex + Second X Coordinate - + - 280 + 140 50 113 28 + + 20 + - + - 280 + 140 80 - 187 + 139 20 - Y Coordinate, Second Vertex + Second Y Coordinate - + - 280 + 140 100 113 28 + + 20 + - + - 20 - 140 - 173 + 300 + 30 + 125 20 - X Coordinate, Third Vertex + Third X Coordinate - + - 20 - 160 + 300 + 50 113 28 + + 60 + - + - 20 - 190 - 173 + 300 + 80 + 124 20 - Y Coordinate, Third Vertex + Third Y Coordinate - + - 20 - 210 + 300 + 100 113 28 + + 20 + + + + + + 450 + 30 + 133 + 20 + + + + Fourth X Coordinate + + + + + + 450 + 50 + 113 + 28 + + + + 60 + + + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 450 + 100 + 113 + 28 + + + + 60 + + + + + + + 0 + 150 + 590 + 320 + + + + Set Curvature Coordinates Of Square Edges + + + + + 10 + 30 + 280 + 140 + + + + First Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 10 + + + + + + 140 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 140 + 50 + 113 + 28 + + + + 30 + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 10 + 100 + 113 + 28 + + + + 50 + + + + + + 140 + 80 + 139 + 20 + + + + Second Y Coordinate + + + + + + 140 + 100 + 113 + 28 + + + + 30 + + + + + + + 300 + 30 + 280 + 140 + + + + Second Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 30 + + + + + + 140 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 140 + 50 + 113 + 28 + + + + 50 + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 10 + 100 + 113 + 28 + + + + 10 + + + + + + 140 + 80 + 140 + 20 + + + + Second Y Coordinate + + + + + + 140 + 100 + 113 + 28 + + + + 30 + + + + + + + 10 + 170 + 280 + 140 + + + + Third Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 50 + + + + + + 140 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 140 + 50 + 113 + 28 + + + + 70 + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 10 + 100 + 113 + 28 + + + + 30 + + + + + + 140 + 80 + 140 + 20 + + + + Second Y Coordinate + + + + + + 140 + 100 + 113 + 28 + + + + 50 + + + + + + + 300 + 170 + 280 + 140 + + + + Fourth Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 50 + + + + + + 140 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 140 + 50 + 113 + 28 + + + + 30 + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 10 + 100 + 113 + 28 + + + + 70 + + + + + + 140 + 80 + 140 + 20 + + + + Second Y Coordinate + + + + + + 140 + 100 + 113 + 28 + + + + 50 + + + + + + + + + + 0 + 10 + 590 + 140 + + + + Set Coordinates Of First Curved Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 20 + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 10 + 100 + 113 + 28 + + + + 60 + + + + + + 140 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 140 + 50 + 113 + 28 + + + + 30 + + + + + + 140 + 80 + 139 + 20 + + + + Second Y Coordinate + + + + + + 140 + 100 + 113 + 28 + + + + 50 + + + + + + 300 + 30 + 125 + 20 + + + + Third X Coordinate + + + + + + 300 + 50 + 113 + 28 + + + + 10 + + + + + + 300 + 80 + 124 + 20 + + + + Third Y Coordinate + + + + + + 300 + 100 + 113 + 28 + + + + 30 + + + + + + 450 + 30 + 133 + 20 + + + + Fourth X Coordinate + + + + + + 450 + 50 + 113 + 28 + + + + 20 + + + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 450 + 100 + 113 + 28 + + + + 20 + + + + + + + 0 + 150 + 590 + 140 + + + + Set Coordinates Of Second Curved Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 30 + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 10 + 100 + 113 + 28 + + + + 50 + + + + + + 140 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 140 + 50 + 113 + 28 + + + + 34 + + + + + + 140 + 80 + 139 + 20 + + + + Second Y Coordinate + + + + + + 140 + 100 + 113 + 28 + + + + 46 + + + + + + 300 + 30 + 125 + 20 + + + + Third X Coordinate + + + + + + 300 + 50 + 113 + 28 + + + + 34 + + + + + + 300 + 80 + 124 + 20 + + + + Third Y Coordinate + + + + + + 300 + 100 + 113 + 28 + + + + 34 + + + + + + 450 + 30 + 133 + 20 + + + + Fourth X Coordinate + + + + + + 450 + 50 + 113 + 28 + + + + 10 + + + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 450 + 100 + 113 + 28 + + + + 30 + + + + + + + 0 + 290 + 590 + 140 + + + + Set Coordinates Of Third Curved Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 70 + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 10 + 100 + 113 + 28 + + + + 50 + + + + + + 140 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 140 + 50 + 113 + 28 + + + + 46 + + + + + + 140 + 80 + 139 + 20 + + + + Second Y Coordinate + + + + + + 140 + 100 + 113 + 28 + + + + 46 + + + + + + 300 + 30 + 125 + 20 + + + + Third X Coordinate + + + + + + 300 + 50 + 113 + 28 + + + + 46 + + + + + + 300 + 80 + 124 + 20 + + + + Third Y Coordinate + + + + + + 300 + 100 + 113 + 28 + + + + 34 + + + + + + 450 + 30 + 133 + 20 + + + + Fourth X Coordinate + + + + + + 450 + 50 + 113 + 28 + + + + 30 + + + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 450 + 100 + 113 + 28 + + + + 50 + + + + + + + 0 + 430 + 590 + 140 + + + + Set Coordinates Of Fourth Curved Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 60 + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 10 + 100 + 113 + 28 + + + + 60 + + + + + + 140 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 140 + 50 + 113 + 28 + + + + 50 + + + + + + 140 + 80 + 139 + 20 + + + + Second Y Coordinate + + + + + + 140 + 100 + 113 + 28 + + + + 50 + + + + + + 300 + 30 + 125 + 20 + + + + Third X Coordinate + + + + + + 300 + 50 + 113 + 28 + + + + 70 + + + + + + 300 + 80 + 124 + 20 + + + + Third Y Coordinate + + + + + + 300 + 100 + 113 + 28 + + + + 30 + + + + + + 450 + 30 + 133 + 20 + + + + Fourth X Coordinate + + + + + + 450 + 50 + 113 + 28 + + + + 60 + + + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 450 + 100 + 113 + 28 + + + + 20 + @@ -926,13 +2276,318 @@ + + + + 10 + 510 + 490 + 220 + + + + 6 + + + + + + 20 + 10 + 415 + 20 + + + + A linear gradient describes a color change along a straight line + + + Qt::AutoText + + + + + + 20 + 30 + 415 + 20 + + + + that is defined by two points. + + + Qt::AutoText + + + + + + + + 10 + 10 + 319 + 20 + + + + Radial gradient describes the color change from + + + + + + 10 + 30 + 335 + 20 + + + + the center to the edges, it is defined by two circles, + + + + + + 10 + 50 + 281 + 20 + + + + which are defined by the center and radius + + + + + + + + 0 + 10 + 472 + 20 + + + + Triangle gradient describes the color change between the three vertices + + + + + + 0 + 30 + 482 + 20 + + + + of a triangle. The color change occurs according to the principle of linear + + + + + + 0 + 50 + 467 + 20 + + + + gradient along the perpendiculars from the triangle vertex to the point + + + + + + 0 + 70 + 230 + 20 + + + + where the perpendiculars intersect. + + + + + + + + + 10 + 10 + 461 + 20 + + + + Coons Patch gradient describes the color change on the surface of the + + + + + + 10 + 30 + 456 + 20 + + + + Coons Patch on the plane. In mathematics, a Coons patch, is a type of + + + + + + 10 + 50 + 418 + 20 + + + + surface patch used in computer graphics to smoothly join other + + + + + + 10 + 70 + 117 + 20 + + + + surfaces together. + + + + + + 10 + 130 + 162 + 20 + + + + Note on set coordinates: + + + + + + 10 + 150 + 459 + 20 + + + + The vertices are counted clockwise. + + + + + + 10 + 170 + 457 + 20 + + + + The edges are counted clockwise starting from the edge between the + + + + + + 10 + 190 + 152 + 20 + + + + first and second vertex. + + + + + + + + + 10 + 10 + 435 + 20 + + + + Tensor Coons Patch gradient describes the color change as well as + + + + + + 10 + 30 + 279 + 20 + + + + Coons Patch gradient, but in tensor space. + + + + + + 10 + 130 + 162 + 20 + + + + Note on set coordinates: + + + + + + 10 + 150 + 222 + 20 + + + + The curves are counted clockwise. + + + + + 0 0 - 1060 + 1126 25 @@ -952,20 +2607,24 @@ + + + + - Linear Gradient + Linear - Radial Gradient + Radial - Triangle Gradient + Triangle QAction::TextHeuristicRole @@ -973,7 +2632,39 @@ - Triangle Parametric Gradient + Triangle Parametric + + + QAction::TextHeuristicRole + + + + + Coons Patch + + + QAction::TextHeuristicRole + + + + + Coons Patch Parametric + + + QAction::TextHeuristicRole + + + + + Tensor Coons Patch + + + QAction::TextHeuristicRole + + + + + Tensor Coons Patch Parametric QAction::TextHeuristicRole From 0700038802a0ba8c9862ea04c6f234c53aa6f419 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Wed, 10 Apr 2024 19:12:01 +0300 Subject: [PATCH 07/13] Refactoring --- .../gradient/Gradient/mainwindow.cpp | 978 ++---------------- .../gradient/Gradient/mainwindow.h | 199 +--- .../gradient/Gradient/mainwindow.ui | 423 ++++++-- 3 files changed, 422 insertions(+), 1178 deletions(-) diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index 88fcd0c783..6d1a853ae3 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -10,11 +10,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi { ui->setupUi(this); ui->lable_test->setStyleSheet("QLabel { background-color : white;}"); - ui->stackedWidget->setCurrentIndex(0); - ui->stackedWidget_2->setCurrentIndex(0); - ui->statusbar->showMessage("Linear"); + on_actionLinear_Gradient_triggered(); ui->Rainbow_Colorspace_Radio_Button->setChecked(true); - info.colorspace = Rainbow; } MainWindow::~MainWindow() @@ -27,8 +24,6 @@ void CleanupFunction(void *data) delete[] data; } -const int COORD_SIZE_MM = 100; - QImage GenerateImg(std::vector &points, Info &info, const int& w, const int& h) { NSGraphics::IGraphicsRenderer *pRasterRenderer = NSGraphics::Create(); @@ -95,7 +90,6 @@ void MainWindow::on_actionLinear_Gradient_triggered() ui->statusbar->showMessage("Linear"); info.gradient = Linear; info.gradient_type = c_BrushTypePathNewLinearGradient; - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionRadial_Gradient_triggered() @@ -105,7 +99,6 @@ void MainWindow::on_actionRadial_Gradient_triggered() ui->statusbar->showMessage("Radial"); info.gradient = Radial; info.gradient_type = c_BrushTypePathRadialGradient; - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionTriangle_Gradient_triggered() @@ -115,7 +108,6 @@ void MainWindow::on_actionTriangle_Gradient_triggered() ui->statusbar->showMessage("Triangle"); info.gradient = Triangle; info.gradient_type = c_BrushTypeTriagnleMeshGradient; - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionTriangle_Parametric_Gradient_triggered() @@ -125,7 +117,6 @@ void MainWindow::on_actionTriangle_Parametric_Gradient_triggered() ui->statusbar->showMessage("Triangle Parametric"); info.gradient = TriangleParametric; info.gradient_type = c_BrushTypeTriagnleMeshGradient; - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionCoons_Patch_Gradient_triggered() @@ -135,7 +126,6 @@ void MainWindow::on_actionCoons_Patch_Gradient_triggered() ui->statusbar->showMessage("Coons Patch"); info.gradient = CoonsPatch; info.gradient_type = c_BrushTypePathNewLinearGradient; - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionCoons_Patch_Parametric_triggered() @@ -145,7 +135,6 @@ void MainWindow::on_actionCoons_Patch_Parametric_triggered() ui->statusbar->showMessage("Coons Patch Parametric"); info.gradient = CoonsPatchParametric; info.gradient_type = c_BrushTypeCurveGradient; - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionTensor_Coons_Patch_Gradient_triggered() @@ -155,7 +144,6 @@ void MainWindow::on_actionTensor_Coons_Patch_Gradient_triggered() ui->statusbar->showMessage("Tensor Coons Patch"); info.gradient = TensorCoonsPatch; info.gradient_type = c_BrushTypePathNewLinearGradient; - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; } void MainWindow::on_actionTensor_Coons_Patch_Parametric_triggered() @@ -165,135 +153,44 @@ void MainWindow::on_actionTensor_Coons_Patch_Parametric_triggered() ui->statusbar->showMessage("Tensor Coons Patch Parametric"); info.gradient = TensorCoonsPatchParametric; info.gradient_type = c_BrushTypeTensorCurveGradient; - points = {{0, 0}, {500, 0}, {500, 500}, {0, 500}}; -} - -void MainWindow::on_BAW_Colorspace_Radio_Button_clicked() -{ - info.colorspace = BlackAndWhite; -} - -void MainWindow::on_RAB_Colorspace_Radio_Button_clicked() -{ - info.colorspace = RedAndBlue; -} - -void MainWindow::on_Pastel_Colorspace_Radio_Button_clicked() -{ - info.colorspace = Pastel; -} -void MainWindow::on_Rainbow_Colorspace_Radio_Button_clicked() -{ - info.colorspace = Rainbow; } void MainWindow::on_pushButton_clicked() { + points = {{0, 0}, + {static_cast(ui->lable_test->width()), 0}, + {static_cast(ui->lable_test->width()), static_cast(ui->lable_test->height())}, + {0, static_cast(ui->lable_test->height())}}; + if (info.gradient == Linear) { - if (ui->First_X_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First X coordinate = NULL"); - return; - } info.p0.x = ui->First_X_Coordinate_Input->text().toInt(); - if (ui->First_Y_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First Y coordinate = NULL"); - return; - } info.p0.y = ui->First_Y_Coordinate_Input->text().toInt(); - if (ui->Second_X_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First X coordinate = NULL"); - return; - } info.p1.x = ui->Second_X_Coordinate_Input->text().toInt(); - if (ui->Second_Y_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First X coordinate = NULL"); - return; - } info.p1.y = ui->Second_Y_Coordinate_Input->text().toInt(); + info.cont_b = ui->Continue_Shading_Backward->isChecked(); + info.cont_f = ui->Continue_Shading_Forward->isChecked(); info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); } else if (info.gradient == Radial) { - if (ui->First_Center_X_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First Center X coordinate = NULL"); - return; - } info.c0.x = ui->First_Center_X_Coordinate_Input->text().toInt(); - if (ui->First_Center_Y_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First Center Y coordinate = NULL"); - return; - } info.c0.y = ui->First_Center_Y_Coordinate_Input->text().toInt(); - if (ui->Second_Center_X_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First Center X coordinate = NULL"); - return; - } info.c1.x = ui->Second_Center_X_Coordinate_Input->text().toInt(); - if (ui->Second_Center_Y_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First Center X coordinate = NULL"); - return; - } info.c1.y = ui->Second_Center_Y_Coordinate_Input->text().toInt(); - if (ui->First_Radius_Input->text() == "") - { - ui->statusbar->showMessage("First Radius = NUll"); - return; - } info.r0 = ui->First_Radius_Input->text().toInt(); - if (ui->Second_Radius_Input->text() == "") - { - ui->statusbar->showMessage("Second Radius = NULL"); - return; - } info.r1 = ui->Second_Radius_Input->text().toInt(); + info.cont_b = ui->Continue_Shading_Backward_2->isChecked(); + info.cont_f = ui->Continue_Shading_Forward_2->isChecked(); info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, 0, 1, info.cont_b, info.cont_f); } else if (info.gradient == Triangle || info.gradient == TriangleParametric) { - if (ui->First_Vertex_X_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First Vertex X coordinate = NULL"); - return; - } info.triangle[0].x = ui->First_Vertex_X_Coordinate_Input->text().toInt(); - if (ui->First_Vertex_Y_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("First Vertex Y coordinate = NULL"); - return; - } info.triangle[0].y = ui->First_Vertex_Y_Coordinate_Input->text().toInt(); - if (ui->Second_Vertex_X_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("Second Vertex X coordinate = NULL"); - return; - } info.triangle[1].x = ui->Second_Vertex_X_Coordinate_Input->text().toInt(); - if (ui->Second_Vertex_Y_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("Second Vertex Y coordinate = NULL"); - return; - } info.triangle[1].y = ui->Second_Vertex_Y_Coordinate_Input->text().toInt(); - if (ui->Third_Vertex_X_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("Third Vertex X coordinate = NULL"); - return; - } info.triangle[2].x = ui->Third_Vertex_X_Coordinate_Input->text().toInt(); - if (ui->Third_Vertex_Y_Coordinate_Input->text() == "") - { - ui->statusbar->showMessage("Third Vertex Y coordinate = NULL"); - return; - } info.triangle[2].y = ui->Third_Vertex_Y_Coordinate_Input->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, @@ -307,150 +204,30 @@ void MainWindow::on_pushButton_clicked() } else if (info.gradient == CoonsPatch || info.gradient == CoonsPatchParametric) { - if (ui->First_Vertex_X_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("First Vertex X Coordinate = NULL"); - return; - } - info.curve[0].x = 5 * ui->First_Vertex_X_Coordinate_Input_3->text().toInt(); - if (ui->First_Vertex_Y_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("First Vertex Y Coordinate = NULL"); - return; - } - info.curve[0].y = 5 * ui->First_Vertex_Y_Coordinate_Input_3->text().toInt(); - if (ui->First_X_Coordinate_First_Edge->text() == "") - { - ui->statusbar->showMessage("First X Coordinate First Edge = NULL"); - return; - } - info.curve[1].x = 5 * ui->First_X_Coordinate_First_Edge->text().toInt(); - if (ui->First_Y_Coordinate_First_Edge->text() == "") - { - ui->statusbar->showMessage("First Y Coordinate First Edge = NULL"); - return; - } - info.curve[1].y = 5 * ui->First_Y_Coordinate_First_Edge->text().toInt(); - if (ui->Second_X_Coordinate_First_Edge->text() == "") - { - ui->statusbar->showMessage("Second X Coordinate First Edge = NULL"); - return; - } - info.curve[2].x = 5 * ui->Second_X_Coordinate_First_Edge->text().toInt(); - if (ui->Second_Y_Coordinate_First_Edge->text() == "") - { - ui->statusbar->showMessage("Second Y Coordinate First Edge = NULL"); - return; - } - info.curve[2].y = 5 * ui->Second_Y_Coordinate_First_Edge->text().toInt(); - if (ui->Second_Vertex_X_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("Second Vertex X Coordinate = NULL"); - return; - } - info.curve[3].x = 5 * ui->Second_Vertex_X_Coordinate_Input_3->text().toInt(); - if (ui->Second_Vertex_Y_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("Second Vertex Y Coordinate = NULL"); - return; - } - info.curve[3].y = 5 * ui->Second_Vertex_Y_Coordinate_Input_3->text().toInt(); - if (ui->First_X_Coordinate_Second_Edge->text() == "") - { - ui->statusbar->showMessage("First X Coordinate Second Edge = NULL"); - return; - } - info.curve[4].x = 5 * ui->First_X_Coordinate_Second_Edge->text().toInt(); - if (ui->First_Y_Coordinate_Second_Edge->text() == "") - { - ui->statusbar->showMessage("First Y Coordinate Second Edge = NULL"); - return; - } - info.curve[4].y = 5 * ui->First_Y_Coordinate_Second_Edge->text().toInt(); - if (ui->Second_X_Coordinate_Second_Edge->text() == "") - { - ui->statusbar->showMessage("Second X Coordinate Second Edge = NULL"); - return; - } - info.curve[5].x = 5 * ui->Second_X_Coordinate_Second_Edge->text().toInt(); - if (ui->Second_Y_Coordinate_Second_Edge->text() == "") - { - ui->statusbar->showMessage("Second Y Coordinate Second Edge = NULL"); - return; - } - info.curve[5].y = 5 * ui->Second_Y_Coordinate_Second_Edge->text().toInt(); - if (ui->Third_Vertex_X_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("Third Vertex X Coordinate = NULL"); - return; - } - info.curve[6].x = 5 * ui->Third_Vertex_X_Coordinate_Input_3->text().toInt(); - if (ui->Third_Vertex_Y_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("Third Vertex Y Coordinate = NULL"); - return; - } - info.curve[6].y = 5 * ui->Third_Vertex_Y_Coordinate_Input_3->text().toInt(); - if (ui->First_X_Coordinate_Third_Edge->text() == "") - { - ui->statusbar->showMessage("First X Coordinate Third Edge = NULL"); - return; - } - info.curve[7].x = 5 * ui->First_X_Coordinate_Third_Edge->text().toInt(); - if (ui->First_Y_Coordinate_Third_Edge->text() == "") - { - ui->statusbar->showMessage("First Y Coordinate Third Edge = NULL"); - return; - } - info.curve[7].y = 5 * ui->First_Y_Coordinate_Third_Edge->text().toInt(); - if (ui->Second_X_Coordinate_Third_Edge->text() == "") - { - ui->statusbar->showMessage("Second X Coordinate Third Edge = NULL"); - return; - } - info.curve[8].x = 5 * ui->Second_X_Coordinate_Third_Edge->text().toInt(); - if (ui->Second_Y_Coordinate_Third_Edge->text() == "") - { - ui->statusbar->showMessage("Second Y Coordinate Third Edge = NULL"); - return; - } - info.curve[8].y = 5 * ui->Second_Y_Coordinate_Third_Edge->text().toInt(); - if (ui->Fourth_Vertex_X_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("Fourth Vertex X Coordinate = NULL"); - return; - } - info.curve[9].x = 5 * ui->Fourth_Vertex_X_Coordinate_Input_3->text().toInt(); - if (ui->Fourth_Vertex_Y_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("Fourth Vertex Y Coordinate = NULL"); - return; - } - info.curve[9].y = 5 * ui->Fourth_Vertex_Y_Coordinate_Input_3->text().toInt(); - if (ui->First_X_Coordinate_Fourth_Edge->text() == "") - { - ui->statusbar->showMessage("First X Coordinate Fourth Edge = NULL"); - return; - } - info.curve[10].x = 5 * ui->First_X_Coordinate_Fourth_Edge->text().toInt(); - if (ui->First_Y_Coordinate_Fourth_Edge->text() == "") - { - ui->statusbar->showMessage("First Y Coordinate Fourth Edge = NULL"); - return; - } - info.curve[10].y = 5 * ui->First_Y_Coordinate_Fourth_Edge->text().toInt(); - if (ui->Second_X_Coordinate_Fourth_Edge->text() == "") - { - ui->statusbar->showMessage("Second X Coordinate Fourth Edge = NULL"); - return; - } - info.curve[11].x = 5 * ui->Second_X_Coordinate_Fourth_Edge->text().toInt(); - if (ui->Second_Y_Coordinate_Fourth_Edge->text() == "") - { - ui->statusbar->showMessage("Second Y Coordinate Fourth Edge = NULL"); - return; - } - info.curve[11].y = 5 * ui->Second_Y_Coordinate_Fourth_Edge->text().toInt(); + info.curve[0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_Vertex_X_Coordinate_Input_3->text().toInt(); + info.curve[0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Vertex_Y_Coordinate_Input_3->text().toInt(); + info.curve[1].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_First_Edge->text().toInt(); + info.curve[1].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_First_Edge->text().toInt(); + info.curve[2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_First_Edge->text().toInt(); + info.curve[2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_First_Edge->text().toInt(); + info.curve[3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_Vertex_X_Coordinate_Input_3->text().toInt(); + info.curve[3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Vertex_Y_Coordinate_Input_3->text().toInt(); + info.curve[4].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Second_Edge->text().toInt(); + info.curve[4].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Second_Edge->text().toInt(); + info.curve[5].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Second_Edge->text().toInt(); + info.curve[5].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Second_Edge->text().toInt(); + info.curve[6].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_Vertex_X_Coordinate_Input_3->text().toInt(); + info.curve[6].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Vertex_Y_Coordinate_Input_3->text().toInt(); + info.curve[7].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Third_Edge->text().toInt(); + info.curve[7].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Third_Edge->text().toInt(); + info.curve[8].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Third_Edge->text().toInt(); + info.curve[8].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Third_Edge->text().toInt(); + info.curve[9].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_Vertex_X_Coordinate_Input_3->text().toInt(); + info.curve[9].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Vertex_Y_Coordinate_Input_3->text().toInt(); + info.curve[10].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Fourth_Edge->text().toInt(); + info.curve[10].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Fourth_Edge->text().toInt(); + info.curve[11].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Fourth_Edge->text().toInt(); + info.curve[11].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Fourth_Edge->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_curve( info.curve, {0, 0.5, 1, 0.5}, @@ -461,198 +238,38 @@ void MainWindow::on_pushButton_clicked() } else if (info.gradient == TensorCoonsPatch || info.gradient == TensorCoonsPatchParametric) { - if (ui->First_X_Coordinate_First_Edge_3->text() == "") - { - ui->statusbar->showMessage("First X Coordinate First Edge = NULL"); - return; - } - info.tensorcurve[0][0].x = 5 * ui->First_X_Coordinate_First_Edge_3->text().toInt(); - if (ui->First_Y_Coordinate_First_Edge_3->text() == "") - { - ui->statusbar->showMessage("First Y Coordinate First Edge = NULL"); - return; - } - info.tensorcurve[0][0].y = 5 * ui->First_Y_Coordinate_First_Edge_3->text().toInt(); - if (ui->Second_X_Coordinate_First_Edge_3->text() == "") - { - ui->statusbar->showMessage("Second X Coordinate First Edge = NULL"); - return; - } - info.tensorcurve[0][1].x = 5 * ui->Second_X_Coordinate_First_Edge_3->text().toInt(); - if (ui->Second_Y_Coordinate_First_Edge_3->text() == "") - { - ui->statusbar->showMessage("Second Y Coordinate First Edge = NULL"); - return; - } - info.tensorcurve[0][1].y = 5 * ui->Second_Y_Coordinate_First_Edge_3->text().toInt(); - if (ui->Third_X_Coordinate_First_Edge_3->text() == "") - { - ui->statusbar->showMessage("Third X Coordinate First Edge = NULL"); - return; - } - info.tensorcurve[0][2].x = 5 * ui->Third_X_Coordinate_First_Edge_3->text().toInt(); - if (ui->Third_Y_Coordinate_First_Edge_3->text() == "") - { - ui->statusbar->showMessage("Third Y Coordinate First Edge = NULL"); - return; - } - info.tensorcurve[0][2].y = 5 * ui->Third_Y_Coordinate_First_Edge_3->text().toInt(); - if (ui->Fourth_X_Coordinate_First_Edge_3->text() == "") - { - ui->statusbar->showMessage("Fourth X Coordinate First Edge = NULL"); - return; - } - info.tensorcurve[0][3].x = 5 * ui->Fourth_X_Coordinate_First_Edge_3->text().toInt(); - if (ui->Fourth_Y_Coordinate_First_Edge_3->text() == "") - { - ui->statusbar->showMessage("Fourth Y Coordinate First Edge = NULL"); - return; - } - info.tensorcurve[0][3].y = 5 * ui->Fourth_Y_Coordinate_First_Edge_3->text().toInt(); - if (ui->First_X_Coordinate_Second_Edge_3->text() == "") - { - ui->statusbar->showMessage("First X Coordinate Second Edge = NULL"); - return; - } - info.tensorcurve[1][0].x = 5 * ui->First_X_Coordinate_Second_Edge_3->text().toInt(); - if (ui->First_Vertex_Y_Coordinate_Input_3->text() == "") - { - ui->statusbar->showMessage("First Y Coordinate Second Edge = NULL"); - return; - } - info.tensorcurve[1][0].y = 5 * ui->First_Y_Coordinate_Second_Edge_3->text().toInt(); - if (ui->Second_X_Coordinate_Second_Edge_3->text() == "") - { - ui->statusbar->showMessage("Second X Coordinate Second Edge = NULL"); - return; - } - info.tensorcurve[1][1].x = 5 * ui->Second_X_Coordinate_Second_Edge_3->text().toInt(); - if (ui->Second_Y_Coordinate_Second_Edge_3->text() == "") - { - ui->statusbar->showMessage("Second Y Coordinate Second Edge = NULL"); - return; - } - info.tensorcurve[1][1].y = 5 * ui->Second_Y_Coordinate_Second_Edge_3->text().toInt(); - if (ui->Third_X_Coordinate_Second_Edge_3->text() == "") - { - ui->statusbar->showMessage("Third X Coordinate Second Edge = NULL"); - return; - } - info.tensorcurve[1][2].x = 5 * ui->Third_X_Coordinate_Second_Edge_3->text().toInt(); - if (ui->Third_Y_Coordinate_Second_Edge_3->text() == "") - { - ui->statusbar->showMessage("Third Y Coordinate Second Edge = NULL"); - return; - } - info.tensorcurve[1][2].y = 5 * ui->Third_Y_Coordinate_Second_Edge_3->text().toInt(); - if (ui->Fourth_X_Coordinate_Second_Edge_3->text() == "") - { - ui->statusbar->showMessage("Fourth X Coordinate Second Edge = NULL"); - return; - } - info.tensorcurve[1][3].x = 5 * ui->Fourth_X_Coordinate_Second_Edge_3->text().toInt(); - if (ui->Fourth_Y_Coordinate_Second_Edge_3->text() == "") - { - ui->statusbar->showMessage("Fourth Y Coordinate Second Edge = NULL"); - return; - } - info.tensorcurve[1][3].y = 5 * ui->Fourth_Y_Coordinate_Second_Edge_3->text().toInt(); - if (ui->First_X_Coordinate_Third_Edge_3->text() == "") - { - ui->statusbar->showMessage("First X Coordinate Third Edge = NULL"); - return; - } - info.tensorcurve[2][0].x = 5 * ui->First_X_Coordinate_Third_Edge_3->text().toInt(); - if (ui->First_Y_Coordinate_Third_Edge_3->text() == "") - { - ui->statusbar->showMessage("First Y Coordinate Third Edge = NULL"); - return; - } - info.tensorcurve[2][0].y = 5 * ui->First_Y_Coordinate_Third_Edge_3->text().toInt(); - if (ui->Second_X_Coordinate_Third_Edge_3->text() == "") - { - ui->statusbar->showMessage("Second X Coordinate Third Edge = NULL"); - return; - } - info.tensorcurve[2][1].x = 5 * ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); - if (ui->Second_Y_Coordinate_Third_Edge_3->text() == "") - { - ui->statusbar->showMessage("Second Y Coordinate Third Edge = NULL"); - return; - } - info.tensorcurve[2][1].y = 5 * ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); - if (ui->Third_X_Coordinate_Third_Edge_3->text() == "") - { - ui->statusbar->showMessage("Third X Coordinate Third Edge = NULL"); - return; - } - info.tensorcurve[2][2].x = 5 * ui->Third_X_Coordinate_Third_Edge_3->text().toInt(); - if (ui->Third_Y_Coordinate_Third_Edge_3->text() == "") - { - ui->statusbar->showMessage("Third Y Coordinate Third Edge = NULL"); - return; - } - info.tensorcurve[2][2].y = 5 * ui->Third_Y_Coordinate_Third_Edge_3->text().toInt(); - if (ui->Fourth_X_Coordinate_Third_Edge_3->text() == "") - { - ui->statusbar->showMessage("Fourth X Coordinate Third Edge = NULL"); - return; - } - info.tensorcurve[2][3].x = 5 * ui->Fourth_X_Coordinate_Third_Edge_3->text().toInt(); - if (ui->Fourth_Y_Coordinate_Third_Edge_3->text() == "") - { - ui->statusbar->showMessage("Fourth Y Coordinate Third Edge = NULL"); - return; - } - info.tensorcurve[2][3].y = 5 * ui->Fourth_Y_Coordinate_Third_Edge_3->text().toInt(); - if (ui->First_X_Coordinate_Fourth_Edge_3->text() == "") - { - ui->statusbar->showMessage("First X Coordinate Fourth Edge = NULL"); - return; - } - info.tensorcurve[3][0].x = 5 * ui->First_X_Coordinate_Fourth_Edge_3->text().toInt(); - if (ui->First_Y_Coordinate_Fourth_Edge_3->text() == "") - { - ui->statusbar->showMessage("First Y Coordinate Fourth Edge = NULL"); - return; - } - info.tensorcurve[3][0].y = 5 * ui->First_Y_Coordinate_Fourth_Edge_3->text().toInt(); - if (ui->Second_X_Coordinate_Fourth_Edge_3->text() == "") - { - ui->statusbar->showMessage("Second X Coordinate Fourth Edge = NULL"); - return; - } - info.tensorcurve[3][1].x = 5 * ui->Second_X_Coordinate_Fourth_Edge_3->text().toInt(); - if (ui->Second_Y_Coordinate_Fourth_Edge_3->text() == "") - { - ui->statusbar->showMessage("Second Y Coordinate Fourth Edge = NULL"); - return; - } - info.tensorcurve[3][1].y = 5 * ui->Second_Y_Coordinate_Fourth_Edge_3->text().toInt(); - if (ui->Third_X_Coordinate_Fourth_Edge_3->text() == "") - { - ui->statusbar->showMessage("Third X Coordinate Fourth Edge = NULL"); - return; - } - info.tensorcurve[3][2].x = 5 * ui->Third_X_Coordinate_Fourth_Edge_3->text().toInt(); - if (ui->Third_Y_Coordinate_Fourth_Edge_3->text() == "") - { - ui->statusbar->showMessage("Third X Coordinate Fourth Edge = NULL"); - return; - } - info.tensorcurve[3][2].y = 5 * ui->Third_Y_Coordinate_Fourth_Edge_3->text().toInt(); - if (ui->Fourth_X_Coordinate_Fourth_Edge_3->text() == "") - { - ui->statusbar->showMessage("Fourth X Coordinate Fourth Edge = NULL"); - return; - } - info.tensorcurve[3][3].x = 5 * ui->Fourth_X_Coordinate_Fourth_Edge_3->text().toInt(); - if (ui->Fourth_Y_Coordinate_Fourth_Edge_3->text() == "") - { - ui->statusbar->showMessage("Fourth Y Coordinate Fourth Edge = NULL"); - return; - } - info.tensorcurve[3][3].y = 5 * ui->Fourth_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[0][0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][1].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][1].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_X_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Y_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_X_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Y_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[1][0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][1].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][1].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_X_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Y_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_X_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Y_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[2][0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][1].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][1].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_X_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_X_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[3][0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][1].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][1].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_X_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_X_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Y_Coordinate_Fourth_Edge_3->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve( info.tensorcurve, {{0, 0.5}, {1, 0.5}}, @@ -661,33 +278,28 @@ void MainWindow::on_pushButton_clicked() ); } - if (info.colorspace == NoColorspaceType) - { - ui->statusbar->showMessage("Colorspace - NULL"); - return; - } - else if (info.colorspace == Rainbow) + if (ui->Rainbow_Colorspace_Radio_Button->isChecked()) { info.c = {(LONG)0xFFff0000, (LONG)0xFFffa500, (LONG)0xFFffff00, (LONG)0xFF008000, (LONG)0xFF0000ff, (LONG)0xFFFF00FF}; info.p = {0.0, 0.2, 0.4, 0.6, 0.8, 1}; info.n_colors = 6; info.ginfo.shading.function.set_linear_interpolation({0xFFff0000, 0xFFffa500, 0xFFffff00, 0xFF008000, 0xFF0000ff, 0xFFFF00FF}, {0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f}); } - else if (info.colorspace == BlackAndWhite) + else if (ui->BAW_Colorspace_Radio_Button->isChecked()) { info.c = {(LONG)0xFFFFFFFF, (LONG)0xFF000000}; info.p = {0.0, 1}; info.n_colors = 2; info.ginfo.shading.function.set_linear_interpolation({0xFFFFFFFF, 0xFF000000}, {0.0f, 1.0f}); } - else if (info.colorspace == RedAndBlue) + else if (ui->RAB_Colorspace_Radio_Button->isChecked()) { info.c = {(LONG)0xFFFF0000, (LONG)0xFF0000FF}; info.p = {0.0, 1}; info.n_colors = 2; info.ginfo.shading.function.set_linear_interpolation({0xFFFF0000, 0xFF0000FF}, {0.0f, 1.0f}); } - else if (info.colorspace == Pastel) + else if (ui->Pastel_Colorspace_Radio_Button->isChecked()) { info.c = {(LONG)0xfff39189, (LONG)0xff046582}; info.p = {0.0, 1}; @@ -699,453 +311,3 @@ void MainWindow::on_pushButton_clicked() ui->lable_test->setPixmap(QPixmap::fromImage(pm)); ui->lable_test->setScaledContents(true); } - -void MainWindow::on_Continue_Shading_Forward_clicked(bool checked) -{ - info.cont_f = checked; -} - -void MainWindow::on_checkBox_2_clicked(bool checked) -{ - info.cont_b = checked; -} - -void MainWindow::on_Continue_Shading_Forward_2_clicked(bool checked) -{ - info.cont_f = checked; -} - -void MainWindow::on_Continue_Shading_Backward_2_clicked(bool checked) -{ - info.cont_b = checked; -} - -inline void ClampCoords(QLineEdit* edit) -{ - if (edit->text().toInt() < 0) - edit->setText("0"); - if (edit->text().toInt() > COORD_SIZE_MM) - edit->setText(QString::number(COORD_SIZE_MM)); -} - -void MainWindow::on_First_X_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_Input); -} - -void MainWindow::on_First_Y_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_Input); -} - -void MainWindow::on_Second_X_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_Input); -} - -void MainWindow::on_Second_Y_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_Input); -} - -void MainWindow::on_First_Center_X_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->First_Center_X_Coordinate_Input); -} - -void MainWindow::on_First_Center_Y_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->First_Center_Y_Coordinate_Input); -} - -void MainWindow::on_Second_Center_X_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->Second_Center_X_Coordinate_Input); -} - -void MainWindow::on_Second_Center_Y_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->Second_Center_Y_Coordinate_Input); -} - -void MainWindow::on_First_Radius_Input_editingFinished() -{ - ClampCoords(ui->First_Radius_Input); -} - -void MainWindow::on_Second_Radius_Input_editingFinished() -{ - ClampCoords(ui->Second_Radius_Input); -} - -void MainWindow::on_First_Vertex_X_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->First_Vertex_X_Coordinate_Input); -} - - -void MainWindow::on_First_Vertex_Y_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->First_Vertex_Y_Coordinate_Input); -} - - -void MainWindow::on_Second_Vertex_X_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->Second_Vertex_X_Coordinate_Input); -} - - -void MainWindow::on_Second_Vertex_Y_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->Second_Vertex_Y_Coordinate_Input); -} - - -void MainWindow::on_Third_Vertex_X_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->Third_Vertex_X_Coordinate_Input); -} - - -void MainWindow::on_Third_Vertex_Y_Coordinate_Input_editingFinished() -{ - ClampCoords(ui->Third_Vertex_Y_Coordinate_Input); -} - - -void MainWindow::on_First_Vertex_X_Coordinate_Input_3_editingFinished() -{ - ClampCoords(ui->First_Vertex_X_Coordinate_Input_3); -} - - -void MainWindow::on_First_Vertex_Y_Coordinate_Input_3_editingFinished() -{ - ClampCoords(ui->First_Vertex_Y_Coordinate_Input_3); -} - - -void MainWindow::on_Second_Vertex_X_Coordinate_Input_3_editingFinished() -{ - ClampCoords(ui->Second_Vertex_X_Coordinate_Input_3); -} - - -void MainWindow::on_Second_Vertex_Y_Coordinate_Input_3_editingFinished() -{ - ClampCoords(ui->Second_Vertex_Y_Coordinate_Input_3); -} - - -void MainWindow::on_Third_Vertex_X_Coordinate_Input_3_editingFinished() -{ - ClampCoords(ui->Third_Vertex_X_Coordinate_Input_3); -} - - -void MainWindow::on_Third_Vertex_Y_Coordinate_Input_3_editingFinished() -{ - ClampCoords(ui->Third_Vertex_Y_Coordinate_Input_3); -} - - -void MainWindow::on_Fourth_Vertex_X_Coordinate_Input_3_editingFinished() -{ - ClampCoords(ui->Fourth_Vertex_X_Coordinate_Input_3); -} - - -void MainWindow::on_Fourth_Vertex_Y_Coordinate_Input_3_editingFinished() -{ - ClampCoords(ui->Fourth_Vertex_Y_Coordinate_Input_3); -} - - -void MainWindow::on_First_X_Coordinate_First_Edge_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_First_Edge); -} - - -void MainWindow::on_First_Y_Coordinate_First_Edge_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_First_Edge); -} - - -void MainWindow::on_Second_X_Coordinate_First_Edge_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_First_Edge); -} - - -void MainWindow::on_Second_Y_Coordinate_First_Edge_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_First_Edge); -} - - -void MainWindow::on_First_X_Coordinate_Second_Edge_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_Second_Edge); -} - - -void MainWindow::on_First_Y_Coordinate_Second_Edge_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_Second_Edge); -} - - -void MainWindow::on_Second_X_Coordinate_Second_Edge_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_Second_Edge); -} - - -void MainWindow::on_Second_Y_Coordinate_Second_Edge_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_Second_Edge); -} - - -void MainWindow::on_First_X_Coordinate_Third_Edge_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_Third_Edge); -} - - -void MainWindow::on_First_Y_Coordinate_Third_Edge_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_Third_Edge); -} - - -void MainWindow::on_Second_X_Coordinate_Third_Edge_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_Third_Edge); -} - - -void MainWindow::on_Second_Y_Coordinate_Third_Edge_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_Third_Edge); -} - - -void MainWindow::on_First_X_Coordinate_Fourth_Edge_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_Fourth_Edge); -} - - -void MainWindow::on_First_Y_Coordinate_Fourth_Edge_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_Fourth_Edge); -} - - -void MainWindow::on_Second_X_Coordinate_Fourth_Edge_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_Fourth_Edge); -} - - -void MainWindow::on_Second_Y_Coordinate_Fourth_Edge_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_Fourth_Edge); -} - - -void MainWindow::on_First_X_Coordinate_First_Edge_3_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_First_Edge_3); -} - - -void MainWindow::on_First_Y_Coordinate_First_Edge_3_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_First_Edge_3); -} - - -void MainWindow::on_Second_X_Coordinate_First_Edge_3_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_First_Edge_3); -} - - -void MainWindow::on_Second_Y_Coordinate_First_Edge_3_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_First_Edge_3); -} - - -void MainWindow::on_Third_X_Coordinate_First_Edge_3_editingFinished() -{ - ClampCoords(ui->Third_X_Coordinate_First_Edge_3); -} - - -void MainWindow::on_Third_Y_Coordinate_First_Edge_3_editingFinished() -{ - ClampCoords(ui->Third_Y_Coordinate_First_Edge_3); -} - - -void MainWindow::on_Fourth_X_Coordinate_First_Edge_3_editingFinished() -{ - ClampCoords(ui->Fourth_X_Coordinate_First_Edge_3); -} - - -void MainWindow::on_Fourth_Y_Coordinate_First_Edge_3_editingFinished() -{ - ClampCoords(ui->Fourth_Y_Coordinate_First_Edge_3); -} - - -void MainWindow::on_First_X_Coordinate_Second_Edge_3_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_Second_Edge_3); -} - - -void MainWindow::on_First_Y_Coordinate_Second_Edge_3_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_Second_Edge_3); -} - - -void MainWindow::on_Second_X_Coordinate_Second_Edge_3_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_Second_Edge_3); -} - - -void MainWindow::on_Second_Y_Coordinate_Second_Edge_3_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_Second_Edge_3); -} - - -void MainWindow::on_Third_X_Coordinate_Second_Edge_3_editingFinished() -{ - ClampCoords(ui->Third_X_Coordinate_Second_Edge_3); -} - - -void MainWindow::on_Third_Y_Coordinate_Second_Edge_3_editingFinished() -{ - ClampCoords(ui->Third_Y_Coordinate_Second_Edge_3); -} - - -void MainWindow::on_Fourth_X_Coordinate_Second_Edge_3_editingFinished() -{ - ClampCoords(ui->Fourth_X_Coordinate_Second_Edge_3); -} - - -void MainWindow::on_Fourth_Y_Coordinate_Second_Edge_3_editingFinished() -{ - ClampCoords(ui->Fourth_Y_Coordinate_Second_Edge_3); -} - - -void MainWindow::on_First_X_Coordinate_Third_Edge_3_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_Third_Edge_3); -} - - -void MainWindow::on_First_Y_Coordinate_Third_Edge_3_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_Third_Edge_3); -} - - -void MainWindow::on_Second_X_Coordinate_Third_Edge_3_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_Third_Edge_3); -} - - -void MainWindow::on_Second_Y_Coordinate_Third_Edge_3_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_Third_Edge_3); -} - - -void MainWindow::on_Third_X_Coordinate_Third_Edge_3_editingFinished() -{ - ClampCoords(ui->Third_X_Coordinate_Third_Edge_3); -} - - -void MainWindow::on_Third_Y_Coordinate_Third_Edge_3_editingFinished() -{ - ClampCoords(ui->Third_Y_Coordinate_Third_Edge_3); -} - - -void MainWindow::on_Fourth_X_Coordinate_Third_Edge_3_editingFinished() -{ - ClampCoords(ui->Fourth_X_Coordinate_Third_Edge_3); -} - - -void MainWindow::on_Fourth_Y_Coordinate_Third_Edge_3_editingFinished() -{ - ClampCoords(ui->Fourth_Y_Coordinate_Third_Edge_3); -} - - -void MainWindow::on_First_X_Coordinate_Fourth_Edge_3_editingFinished() -{ - ClampCoords(ui->First_X_Coordinate_Fourth_Edge_3); -} - - -void MainWindow::on_First_Y_Coordinate_Fourth_Edge_3_editingFinished() -{ - ClampCoords(ui->First_Y_Coordinate_Fourth_Edge_3); -} - - -void MainWindow::on_Second_X_Coordinate_Fourth_Edge_3_editingFinished() -{ - ClampCoords(ui->Second_X_Coordinate_Fourth_Edge_3); -} - - -void MainWindow::on_Second_Y_Coordinate_Fourth_Edge_3_editingFinished() -{ - ClampCoords(ui->Second_Y_Coordinate_Fourth_Edge_3); -} - - -void MainWindow::on_Third_X_Coordinate_Fourth_Edge_3_editingFinished() -{ - ClampCoords(ui->Third_X_Coordinate_Fourth_Edge_3); -} - - -void MainWindow::on_Third_Y_Coordinate_Fourth_Edge_3_editingFinished() -{ - ClampCoords(ui->Third_Y_Coordinate_Fourth_Edge_3); -} - - -void MainWindow::on_Fourth_X_Coordinate_Fourth_Edge_3_editingFinished() -{ - ClampCoords(ui->Fourth_X_Coordinate_Fourth_Edge_3); -} - - -void MainWindow::on_Fourth_Y_Coordinate_Fourth_Edge_3_editingFinished() -{ - ClampCoords(ui->Fourth_Y_Coordinate_Fourth_Edge_3); -} - diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index 99c51b16d7..eece8a5562 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -4,8 +4,12 @@ #include #include #include +#include #include "../../../../DesktopEditor/graphics/structures.h" +#define COORD_SIZE_MM 100 +#define MM_TO_COORD(size) (size / COORD_SIZE_MM) + QT_BEGIN_NAMESPACE namespace Ui { @@ -13,6 +17,30 @@ namespace Ui } QT_END_NAMESPACE +class CustomLineEdit : public QLineEdit +{ + Q_OBJECT +public: + CustomLineEdit(QWidget *parent = nullptr) : QLineEdit(parent) + { + connect(this, &QLineEdit::editingFinished, this, &CustomLineEdit::onEditingFinished); + } + ~CustomLineEdit() + { + + } +public slots: + void onEditingFinished() + { + if (this->text() == "") + this->setText(this->placeholderText()); + if (this->text().toInt() < 0) + this->setText("0"); + if (this->text().toInt() > COORD_SIZE_MM) + this->setText(QString::number(COORD_SIZE_MM)); + } +}; + typedef enum { Linear, @@ -26,15 +54,6 @@ typedef enum Functional } GradientType; -typedef enum -{ - NoColorspaceType, - Rainbow, - BlackAndWhite, - RedAndBlue, - Pastel -} ColorspaceType; - struct Point { Point(double _x = 0, double _y = 0) : x(_x), y(_y) @@ -42,6 +61,7 @@ struct Point } double x, y; }; + struct Color { uint r, g, b; @@ -63,7 +83,6 @@ struct Color struct Info { - ColorspaceType colorspace = NoColorspaceType; GradientType gradient = Linear; float r0, r1; @@ -122,58 +141,10 @@ private slots: void on_actionRadial_Gradient_triggered(); - void on_BAW_Colorspace_Radio_Button_clicked(); - - void on_RAB_Colorspace_Radio_Button_clicked(); - - void on_Pastel_Colorspace_Radio_Button_clicked(); - - void on_Rainbow_Colorspace_Radio_Button_clicked(); - void on_pushButton_clicked(); - void on_Continue_Shading_Forward_clicked(bool checked); - - void on_checkBox_2_clicked(bool checked); - - void on_Continue_Shading_Forward_2_clicked(bool checked); - - void on_Continue_Shading_Backward_2_clicked(bool checked); - - void on_First_X_Coordinate_Input_editingFinished(); - - void on_First_Y_Coordinate_Input_editingFinished(); - - void on_Second_X_Coordinate_Input_editingFinished(); - - void on_Second_Y_Coordinate_Input_editingFinished(); - - void on_First_Center_X_Coordinate_Input_editingFinished(); - - void on_First_Center_Y_Coordinate_Input_editingFinished(); - - void on_Second_Center_X_Coordinate_Input_editingFinished(); - - void on_Second_Center_Y_Coordinate_Input_editingFinished(); - - void on_First_Radius_Input_editingFinished(); - - void on_Second_Radius_Input_editingFinished(); - void on_actionTriangle_Gradient_triggered(); - void on_First_Vertex_X_Coordinate_Input_editingFinished(); - - void on_First_Vertex_Y_Coordinate_Input_editingFinished(); - - void on_Second_Vertex_X_Coordinate_Input_editingFinished(); - - void on_Second_Vertex_Y_Coordinate_Input_editingFinished(); - - void on_Third_Vertex_X_Coordinate_Input_editingFinished(); - - void on_Third_Vertex_Y_Coordinate_Input_editingFinished(); - void on_actionTriangle_Parametric_Gradient_triggered(); void on_actionCoons_Patch_Gradient_triggered(); @@ -184,118 +155,6 @@ private slots: void on_actionTensor_Coons_Patch_Parametric_triggered(); - void on_First_Vertex_X_Coordinate_Input_3_editingFinished(); - - void on_First_Vertex_Y_Coordinate_Input_3_editingFinished(); - - void on_Second_Vertex_X_Coordinate_Input_3_editingFinished(); - - void on_Second_Vertex_Y_Coordinate_Input_3_editingFinished(); - - void on_Third_Vertex_X_Coordinate_Input_3_editingFinished(); - - void on_Third_Vertex_Y_Coordinate_Input_3_editingFinished(); - - void on_Fourth_Vertex_X_Coordinate_Input_3_editingFinished(); - - void on_Fourth_Vertex_Y_Coordinate_Input_3_editingFinished(); - - void on_First_X_Coordinate_First_Edge_editingFinished(); - - void on_First_Y_Coordinate_First_Edge_editingFinished(); - - void on_Second_X_Coordinate_First_Edge_editingFinished(); - - void on_Second_Y_Coordinate_First_Edge_editingFinished(); - - void on_First_X_Coordinate_Second_Edge_editingFinished(); - - void on_First_Y_Coordinate_Second_Edge_editingFinished(); - - void on_Second_X_Coordinate_Second_Edge_editingFinished(); - - void on_Second_Y_Coordinate_Second_Edge_editingFinished(); - - void on_First_X_Coordinate_Third_Edge_editingFinished(); - - void on_First_Y_Coordinate_Third_Edge_editingFinished(); - - void on_Second_X_Coordinate_Third_Edge_editingFinished(); - - void on_Second_Y_Coordinate_Third_Edge_editingFinished(); - - void on_First_X_Coordinate_Fourth_Edge_editingFinished(); - - void on_First_Y_Coordinate_Fourth_Edge_editingFinished(); - - void on_Second_X_Coordinate_Fourth_Edge_editingFinished(); - - void on_Second_Y_Coordinate_Fourth_Edge_editingFinished(); - - void on_First_X_Coordinate_First_Edge_3_editingFinished(); - - void on_First_Y_Coordinate_First_Edge_3_editingFinished(); - - void on_Second_X_Coordinate_First_Edge_3_editingFinished(); - - void on_Second_Y_Coordinate_First_Edge_3_editingFinished(); - - void on_Third_X_Coordinate_First_Edge_3_editingFinished(); - - void on_Third_Y_Coordinate_First_Edge_3_editingFinished(); - - void on_Fourth_X_Coordinate_First_Edge_3_editingFinished(); - - void on_Fourth_Y_Coordinate_First_Edge_3_editingFinished(); - - void on_First_X_Coordinate_Second_Edge_3_editingFinished(); - - void on_First_Y_Coordinate_Second_Edge_3_editingFinished(); - - void on_Second_X_Coordinate_Second_Edge_3_editingFinished(); - - void on_Second_Y_Coordinate_Second_Edge_3_editingFinished(); - - void on_Third_X_Coordinate_Second_Edge_3_editingFinished(); - - void on_Third_Y_Coordinate_Second_Edge_3_editingFinished(); - - void on_Fourth_X_Coordinate_Second_Edge_3_editingFinished(); - - void on_Fourth_Y_Coordinate_Second_Edge_3_editingFinished(); - - void on_First_X_Coordinate_Third_Edge_3_editingFinished(); - - void on_First_Y_Coordinate_Third_Edge_3_editingFinished(); - - void on_Second_X_Coordinate_Third_Edge_3_editingFinished(); - - void on_Second_Y_Coordinate_Third_Edge_3_editingFinished(); - - void on_Third_X_Coordinate_Third_Edge_3_editingFinished(); - - void on_Third_Y_Coordinate_Third_Edge_3_editingFinished(); - - void on_Fourth_X_Coordinate_Third_Edge_3_editingFinished(); - - void on_Fourth_Y_Coordinate_Third_Edge_3_editingFinished(); - - void on_First_X_Coordinate_Fourth_Edge_3_editingFinished(); - - void on_First_Y_Coordinate_Fourth_Edge_3_editingFinished(); - - void on_Second_X_Coordinate_Fourth_Edge_3_editingFinished(); - - void on_Second_Y_Coordinate_Fourth_Edge_3_editingFinished(); - - void on_Third_X_Coordinate_Fourth_Edge_3_editingFinished(); - - void on_Third_Y_Coordinate_Fourth_Edge_3_editingFinished(); - - void on_Fourth_X_Coordinate_Fourth_Edge_3_editingFinished(); - - void on_Fourth_Y_Coordinate_Fourth_Edge_3_editingFinished(); - private: Ui::MainWindow *ui; }; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index 713a17ab4b..01e5f01b4d 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1126 - 827 + 795 @@ -36,7 +36,7 @@ 510 0 610 - 740 + 710 @@ -46,9 +46,9 @@ 10 - 10 + 0 201 - 150 + 140 @@ -58,7 +58,7 @@ 20 - 30 + 20 112 26 @@ -71,7 +71,7 @@ 20 - 60 + 50 161 26 @@ -84,7 +84,7 @@ 20 - 90 + 80 131 26 @@ -97,7 +97,7 @@ 20 - 120 + 110 112 26 @@ -111,9 +111,9 @@ 10 - 160 + 140 590 - 570 + 560 @@ -124,7 +124,7 @@ 0 - 10 + 0 440 150 @@ -145,7 +145,7 @@ X Coordinate, First Point - + 10 @@ -157,6 +157,9 @@ 10 + + 10 + @@ -171,7 +174,7 @@ Y Coordinate, First Point - + 10 @@ -183,6 +186,9 @@ 10 + + 10 + @@ -197,7 +203,7 @@ X Coordinate, Second Point - + 240 @@ -209,6 +215,9 @@ 90 + + 90 + @@ -223,7 +232,7 @@ Y Coordinate, Second Point - + 240 @@ -235,14 +244,17 @@ 90 + + 90 + 450 - 10 - 131 + 0 + 130 150 @@ -262,7 +274,7 @@ Forward - + 20 @@ -282,8 +294,8 @@ 450 - 10 - 131 + 0 + 130 150 @@ -321,7 +333,7 @@ 0 - 10 + 0 440 150 @@ -342,7 +354,7 @@ X Coordinate, First Center - + 20 @@ -354,6 +366,9 @@ 50 + + 50 + @@ -368,7 +383,7 @@ Y Coordinate, First Center - + 20 @@ -380,6 +395,9 @@ 50 + + 50 + @@ -394,7 +412,7 @@ X Coordinate, Second Center - + 230 @@ -406,6 +424,9 @@ 50 + + 50 + @@ -420,7 +441,7 @@ Y Coordinate, Second Center - + 230 @@ -432,13 +453,16 @@ 50 + + 50 + 0 - 160 + 150 440 100 @@ -472,7 +496,7 @@ Second Radius - + 20 @@ -484,8 +508,11 @@ 10 + + 10 + - + 230 @@ -497,6 +524,9 @@ 30 + + 30 + @@ -505,7 +535,7 @@ 0 - 10 + 0 590 140 @@ -526,7 +556,7 @@ X Coordinate, First Vertex - + 10 @@ -538,6 +568,9 @@ 50 + + 50 + @@ -552,7 +585,7 @@ Y Coordinate, First Vertex - + 10 @@ -564,6 +597,9 @@ 20 + + 20 + @@ -578,7 +614,7 @@ X Coordinate, Second Vertex - + 200 @@ -590,6 +626,9 @@ 20 + + 20 + @@ -604,7 +643,7 @@ Y Coordinate, Second Vertex - + 200 @@ -616,6 +655,9 @@ 70 + + 70 + @@ -630,7 +672,7 @@ X Coordinate, Third Vertex - + 410 @@ -642,6 +684,9 @@ 80 + + 80 + @@ -656,7 +701,7 @@ Y Coordinate, Third Vertex - + 410 @@ -668,6 +713,9 @@ 70 + + 70 + @@ -676,7 +724,7 @@ 0 - 10 + 0 590 140 @@ -697,7 +745,7 @@ First X Coordinate - + 10 @@ -709,6 +757,9 @@ 20 + + 20 + @@ -723,7 +774,7 @@ First Y Coordinate - + 10 @@ -735,6 +786,9 @@ 60 + + 60 + @@ -749,7 +803,7 @@ Second X Coordinate - + 140 @@ -761,6 +815,9 @@ 20 + + 20 + @@ -775,7 +832,7 @@ Second Y Coordinate - + 140 @@ -787,6 +844,9 @@ 20 + + 20 + @@ -801,7 +861,7 @@ Third X Coordinate - + 300 @@ -813,6 +873,9 @@ 60 + + 60 + @@ -827,7 +890,7 @@ Third Y Coordinate - + 300 @@ -839,6 +902,9 @@ 20 + + 20 + @@ -853,7 +919,7 @@ Fourth X Coordinate - + 450 @@ -865,6 +931,9 @@ 60 + + 60 + @@ -879,7 +948,7 @@ Fourth Y Coorfinate - + 450 @@ -891,13 +960,16 @@ 60 + + 60 + 0 - 150 + 140 590 320 @@ -930,7 +1002,7 @@ First X Coordinate - + 10 @@ -942,6 +1014,9 @@ 10 + + 10 + @@ -956,7 +1031,7 @@ Second X Coordinate - + 140 @@ -968,6 +1043,9 @@ 30 + + 30 + @@ -982,7 +1060,7 @@ First Y Coordinate - + 10 @@ -994,6 +1072,9 @@ 50 + + 50 + @@ -1008,7 +1089,7 @@ Second Y Coordinate - + 140 @@ -1020,6 +1101,9 @@ 30 + + 30 + @@ -1047,7 +1131,7 @@ First X Coordinate - + 10 @@ -1059,6 +1143,9 @@ 30 + + 30 + @@ -1073,7 +1160,7 @@ Second X Coordinate - + 140 @@ -1085,6 +1172,9 @@ 50 + + 50 + @@ -1099,7 +1189,7 @@ First Y Coordinate - + 10 @@ -1111,6 +1201,9 @@ 10 + + 10 + @@ -1125,7 +1218,7 @@ Second Y Coordinate - + 140 @@ -1137,6 +1230,9 @@ 30 + + 30 + @@ -1164,7 +1260,7 @@ First X Coordinate - + 10 @@ -1176,6 +1272,9 @@ 50 + + 50 + @@ -1190,7 +1289,7 @@ Second X Coordinate - + 140 @@ -1202,6 +1301,9 @@ 70 + + 70 + @@ -1216,7 +1318,7 @@ First Y Coordinate - + 10 @@ -1228,6 +1330,9 @@ 30 + + 30 + @@ -1242,7 +1347,7 @@ Second Y Coordinate - + 140 @@ -1254,6 +1359,9 @@ 50 + + 50 + @@ -1281,7 +1389,7 @@ First X Coordinate - + 10 @@ -1293,6 +1401,9 @@ 50 + + 50 + @@ -1307,7 +1418,7 @@ Second X Coordinate - + 140 @@ -1319,6 +1430,9 @@ 30 + + 30 + @@ -1333,7 +1447,7 @@ First Y Coordinate - + 10 @@ -1345,6 +1459,9 @@ 70 + + 70 + @@ -1359,7 +1476,7 @@ Second Y Coordinate - + 140 @@ -1371,6 +1488,9 @@ 50 + + 50 + @@ -1380,7 +1500,7 @@ 0 - 10 + 0 590 140 @@ -1401,7 +1521,7 @@ First X Coordinate - + 10 @@ -1413,6 +1533,9 @@ 20 + + 20 + @@ -1427,7 +1550,7 @@ First Y Coordinate - + 10 @@ -1439,6 +1562,9 @@ 60 + + 60 + @@ -1453,7 +1579,7 @@ Second X Coordinate - + 140 @@ -1465,6 +1591,9 @@ 30 + + 30 + @@ -1479,7 +1608,7 @@ Second Y Coordinate - + 140 @@ -1491,6 +1620,9 @@ 50 + + 50 + @@ -1505,7 +1637,7 @@ Third X Coordinate - + 300 @@ -1517,6 +1649,9 @@ 10 + + 10 + @@ -1531,7 +1666,7 @@ Third Y Coordinate - + 300 @@ -1543,6 +1678,9 @@ 30 + + 30 + @@ -1557,7 +1695,7 @@ Fourth X Coordinate - + 450 @@ -1569,6 +1707,9 @@ 20 + + 20 + @@ -1583,7 +1724,7 @@ Fourth Y Coorfinate - + 450 @@ -1595,13 +1736,16 @@ 20 + + 20 + 0 - 150 + 140 590 140 @@ -1622,7 +1766,7 @@ First X Coordinate - + 10 @@ -1634,6 +1778,9 @@ 30 + + 30 + @@ -1648,7 +1795,7 @@ First Y Coordinate - + 10 @@ -1660,6 +1807,9 @@ 50 + + 50 + @@ -1674,7 +1824,7 @@ Second X Coordinate - + 140 @@ -1686,6 +1836,9 @@ 34 + + 34 + @@ -1700,7 +1853,7 @@ Second Y Coordinate - + 140 @@ -1712,6 +1865,9 @@ 46 + + 46 + @@ -1726,7 +1882,7 @@ Third X Coordinate - + 300 @@ -1738,6 +1894,9 @@ 34 + + 34 + @@ -1752,7 +1911,7 @@ Third Y Coordinate - + 300 @@ -1764,6 +1923,9 @@ 34 + + 34 + @@ -1778,7 +1940,7 @@ Fourth X Coordinate - + 450 @@ -1790,6 +1952,9 @@ 10 + + 10 + @@ -1804,7 +1969,7 @@ Fourth Y Coorfinate - + 450 @@ -1816,13 +1981,16 @@ 30 + + 30 + 0 - 290 + 280 590 140 @@ -1843,7 +2011,7 @@ First X Coordinate - + 10 @@ -1855,6 +2023,9 @@ 70 + + 70 + @@ -1869,7 +2040,7 @@ First Y Coordinate - + 10 @@ -1881,6 +2052,9 @@ 50 + + 50 + @@ -1895,7 +2069,7 @@ Second X Coordinate - + 140 @@ -1907,6 +2081,9 @@ 46 + + 46 + @@ -1921,7 +2098,7 @@ Second Y Coordinate - + 140 @@ -1933,6 +2110,9 @@ 46 + + 46 + @@ -1947,7 +2127,7 @@ Third X Coordinate - + 300 @@ -1959,6 +2139,9 @@ 46 + + 46 + @@ -1973,7 +2156,7 @@ Third Y Coordinate - + 300 @@ -1985,6 +2168,9 @@ 34 + + 34 + @@ -1999,7 +2185,7 @@ Fourth X Coordinate - + 450 @@ -2011,6 +2197,9 @@ 30 + + 30 + @@ -2025,7 +2214,7 @@ Fourth Y Coorfinate - + 450 @@ -2037,13 +2226,16 @@ 50 + + 50 + 0 - 430 + 420 590 140 @@ -2064,7 +2256,7 @@ First X Coordinate - + 10 @@ -2076,6 +2268,9 @@ 60 + + 60 + @@ -2090,7 +2285,7 @@ First Y Coordinate - + 10 @@ -2102,6 +2297,9 @@ 60 + + 60 + @@ -2116,7 +2314,7 @@ Second X Coordinate - + 140 @@ -2128,6 +2326,9 @@ 50 + + 50 + @@ -2142,7 +2343,7 @@ Second Y Coordinate - + 140 @@ -2154,6 +2355,9 @@ 50 + + 50 + @@ -2168,7 +2372,7 @@ Third X Coordinate - + 300 @@ -2180,6 +2384,9 @@ 70 + + 70 + @@ -2194,7 +2401,7 @@ Third Y Coordinate - + 300 @@ -2206,6 +2413,9 @@ 30 + + 30 + @@ -2220,7 +2430,7 @@ Fourth X Coordinate - + 450 @@ -2232,6 +2442,9 @@ 60 + + 60 + @@ -2246,7 +2459,7 @@ Fourth Y Coorfinate - + 450 @@ -2258,6 +2471,9 @@ 20 + + 20 + @@ -2265,8 +2481,8 @@ - 310 - 90 + 360 + 60 117 29 @@ -2282,7 +2498,7 @@ 10 510 490 - 220 + 190 @@ -2671,6 +2887,13 @@ + + + CustomLineEdit + QLineEdit +
mainwindow.h
+
+
From 283f21de86a39c7c856dcbcab756523bb3437ab5 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Fri, 19 Apr 2024 20:13:30 +0300 Subject: [PATCH 08/13] Add class Custom label for handle click --- DesktopEditor/graphics/shading_info.h | 2 +- .../gradient/Gradient/mainwindow.cpp | 102 +++++++++++++++++- .../gradient/Gradient/mainwindow.h | 47 +++++++- .../gradient/Gradient/mainwindow.ui | 22 +++- 4 files changed, 163 insertions(+), 10 deletions(-) diff --git a/DesktopEditor/graphics/shading_info.h b/DesktopEditor/graphics/shading_info.h index 9e0323a0ab..c97c08f806 100644 --- a/DesktopEditor/graphics/shading_info.h +++ b/DesktopEditor/graphics/shading_info.h @@ -468,7 +468,7 @@ namespace NSStructures { GradientInfo ginfo; ginfo.shading.triangle = points; - ginfo.shading.f_type = ShadingInfo::UseNew; + ginfo.shading.shading_type = ShadingInfo::Parametric; ginfo.shading.function = ColorFunction(256, t0, t1); ginfo.continue_shading_f = false; ginfo.continue_shading_b = false; diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index 6d1a853ae3..cc8336598b 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -134,7 +134,7 @@ void MainWindow::on_actionCoons_Patch_Parametric_triggered() ui->stackedWidget_2->setCurrentIndex(5); ui->statusbar->showMessage("Coons Patch Parametric"); info.gradient = CoonsPatchParametric; - info.gradient_type = c_BrushTypeCurveGradient; + info.gradient_type = c_BrushTypePathNewLinearGradient; } void MainWindow::on_actionTensor_Coons_Patch_Gradient_triggered() @@ -194,7 +194,7 @@ void MainWindow::on_pushButton_clicked() info.triangle[2].y = ui->Third_Vertex_Y_Coordinate_Input->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {}, + {0.f, 0.9f, 1.f}, info.gradient == TriangleParametric); points = {}; for (auto p : info.triangle) @@ -230,7 +230,7 @@ void MainWindow::on_pushButton_clicked() info.curve[11].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Fourth_Edge->text().toInt(); info.ginfo = NSStructures::GInfoConstructor::get_curve( info.curve, - {0, 0.5, 1, 0.5}, + {0.1f, 0.5f, 0.9f, 0.2f}, {{0, 0, 255}, {255, 0, 255}, {255, 0, 0}, {0, 255, 0}}, info.gradient == CoonsPatchParametric @@ -311,3 +311,99 @@ void MainWindow::on_pushButton_clicked() ui->lable_test->setPixmap(QPixmap::fromImage(pm)); ui->lable_test->setScaledContents(true); } + +void MainWindow::on_pushButton_2_clicked() +{ + std::vector p = ui->lable_test->GetPoints(); + if (info.gradient == Linear) + { + ui->First_X_Coordinate_Input->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Input->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_Input->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Input->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->lable_test->Clear(); + } + else if (info.gradient == Radial) + { + ui->First_Center_X_Coordinate_Input->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Center_Y_Coordinate_Input->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_Center_X_Coordinate_Input->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Center_Y_Coordinate_Input->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->lable_test->Clear(); + } + else if (info.gradient == Triangle || info.gradient == TriangleParametric) + { + ui->First_Vertex_X_Coordinate_Input->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Vertex_Y_Coordinate_Input->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_Vertex_X_Coordinate_Input->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Vertex_Y_Coordinate_Input->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Third_Vertex_X_Coordinate_Input->setText(QString::number(p[2].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Vertex_Y_Coordinate_Input->setText(QString::number(p[2].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->lable_test->Clear(); + } + else if (info.gradient == CoonsPatch || info.gradient == CoonsPatchParametric) + { + ui->First_Vertex_X_Coordinate_Input_3->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Vertex_Y_Coordinate_Input_3->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->First_X_Coordinate_First_Edge->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_First_Edge->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_First_Edge->setText(QString::number(p[2].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_First_Edge->setText(QString::number(p[2].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_Vertex_X_Coordinate_Input_3->setText(QString::number(p[3].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Vertex_Y_Coordinate_Input_3->setText(QString::number(p[3].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->First_X_Coordinate_Second_Edge->setText(QString::number(p[4].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Second_Edge->setText(QString::number(p[4].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_Second_Edge->setText(QString::number(p[5].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Second_Edge->setText(QString::number(p[5].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Third_Vertex_X_Coordinate_Input_3->setText(QString::number(p[6].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Vertex_Y_Coordinate_Input_3->setText(QString::number(p[6].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->First_X_Coordinate_Third_Edge->setText(QString::number(p[7].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Third_Edge->setText(QString::number(p[7].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_Third_Edge->setText(QString::number(p[8].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Third_Edge->setText(QString::number(p[8].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Fourth_Vertex_X_Coordinate_Input_3->setText(QString::number(p[9].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Vertex_Y_Coordinate_Input_3->setText(QString::number(p[9].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->First_X_Coordinate_Fourth_Edge->setText(QString::number(p[10].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Fourth_Edge->setText(QString::number(p[10].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_Fourth_Edge->setText(QString::number(p[11].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Fourth_Edge->setText(QString::number(p[11].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->lable_test->Clear(); + } + else if (info.gradient == TensorCoonsPatch || info.gradient == TensorCoonsPatchParametric) + { + ui->First_X_Coordinate_First_Edge_3->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_First_Edge_3->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_First_Edge_3->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_First_Edge_3->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Third_X_Coordinate_First_Edge_3->setText(QString::number(p[2].x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Y_Coordinate_First_Edge_3->setText(QString::number(p[2].x()/ MM_TO_COORD(ui->lable_test->height()))); + ui->Fourth_X_Coordinate_First_Edge_3->setText(QString::number(p[3].x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Y_Coordinate_First_Edge_3->setText(QString::number(p[3].x()/ MM_TO_COORD(ui->lable_test->height()))); + ui->First_X_Coordinate_Second_Edge_3->setText(QString::number(p[4].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Second_Edge_3->setText(QString::number(p[4].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_Second_Edge_3->setText(QString::number(p[5].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Second_Edge_3->setText(QString::number(p[5].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Third_X_Coordinate_Second_Edge_3->setText(QString::number(p[6].x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Y_Coordinate_Second_Edge_3->setText(QString::number(p[6].x()/ MM_TO_COORD(ui->lable_test->height()))); + ui->Fourth_X_Coordinate_Second_Edge_3->setText(QString::number(p[7].x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Y_Coordinate_Second_Edge_3->setText(QString::number(p[7].x()/ MM_TO_COORD(ui->lable_test->height()))); + ui->First_X_Coordinate_Third_Edge_3->setText(QString::number(p[8].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Third_Edge_3->setText(QString::number(p[8].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_Third_Edge_3->setText(QString::number(p[9].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Third_Edge_3->setText(QString::number(p[9].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Third_X_Coordinate_Third_Edge_3->setText(QString::number(p[10].x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Y_Coordinate_Third_Edge_3->setText(QString::number(p[10].x()/ MM_TO_COORD(ui->lable_test->height()))); + ui->Fourth_X_Coordinate_Third_Edge_3->setText(QString::number(p[11].x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Y_Coordinate_Third_Edge_3->setText(QString::number(p[11].x()/ MM_TO_COORD(ui->lable_test->height()))); + ui->First_X_Coordinate_Fourth_Edge_3->setText(QString::number(p[12].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Fourth_Edge_3->setText(QString::number(p[12].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Second_X_Coordinate_Fourth_Edge_3->setText(QString::number(p[13].x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Fourth_Edge_3->setText(QString::number(p[13].y() / MM_TO_COORD(ui->lable_test->height()))); + ui->Third_X_Coordinate_Fourth_Edge_3->setText(QString::number(p[14].x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Y_Coordinate_Fourth_Edge_3->setText(QString::number(p[14].x()/ MM_TO_COORD(ui->lable_test->height()))); + ui->Fourth_X_Coordinate_Fourth_Edge_3->setText(QString::number(p[15].x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Y_Coordinate_Fourth_Edge_3->setText(QString::number(p[15].x()/ MM_TO_COORD(ui->lable_test->height()))); + ui->lable_test->Clear(); + } +} + diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index eece8a5562..c49b016d88 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -5,6 +5,9 @@ #include #include #include +#include +#include +#include #include "../../../../DesktopEditor/graphics/structures.h" #define COORD_SIZE_MM 100 @@ -25,10 +28,7 @@ public: { connect(this, &QLineEdit::editingFinished, this, &CustomLineEdit::onEditingFinished); } - ~CustomLineEdit() - { - - } + ~CustomLineEdit() {} public slots: void onEditingFinished() { @@ -41,6 +41,43 @@ public slots: } }; +class CustomLabel : public QLabel +{ + Q_OBJECT +public: + CustomLabel(QWidget *parent = nullptr) : QLabel(parent) + { + connect(this, &CustomLabel::mousePressed, this, &CustomLabel::onCheckPosition); + } + + ~CustomLabel() {} + + std::vector GetPoints() const + { + return m_points; + } + + void Clear() + { + m_points.clear(); + } +signals: + void mousePressed(QPoint point); +protected: + void mousePressEvent(QMouseEvent *event) override + { + QPoint point = event->pos(); + emit mousePressed(point); + } +public slots: + void onCheckPosition(QPoint point) + { + m_points.push_back(point); + } +private: + std::vector m_points; +}; + typedef enum { Linear, @@ -155,6 +192,8 @@ private slots: void on_actionTensor_Coons_Patch_Parametric_triggered(); + void on_pushButton_2_clicked(); + private: Ui::MainWindow *ui; }; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index 01e5f01b4d..509912eddb 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -17,7 +17,7 @@ true - + 0 @@ -117,7 +117,7 @@ - 0 + 4 @@ -2491,6 +2491,19 @@ Render Gradient + + + + 380 + 110 + 80 + 29 + + + + set from + + @@ -2893,6 +2906,11 @@ QLineEdit
mainwindow.h
+ + CustomLabel + QLabel +
mainwindow.h
+
From 51c6fe496b2a81e795171d20da3d16f251bb0f50 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Fri, 26 Apr 2024 19:40:08 +0300 Subject: [PATCH 09/13] Add parametrs input --- .../gradient/Gradient/mainwindow.cpp | 167 +++--- .../gradient/Gradient/mainwindow.h | 24 + .../gradient/Gradient/mainwindow.ui | 475 +++++++++++++++++- 3 files changed, 597 insertions(+), 69 deletions(-) diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index cc8336598b..2368436fef 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -134,7 +134,7 @@ void MainWindow::on_actionCoons_Patch_Parametric_triggered() ui->stackedWidget_2->setCurrentIndex(5); ui->statusbar->showMessage("Coons Patch Parametric"); info.gradient = CoonsPatchParametric; - info.gradient_type = c_BrushTypePathNewLinearGradient; + info.gradient_type = c_BrushTypeCurveGradient; } void MainWindow::on_actionTensor_Coons_Patch_Gradient_triggered() @@ -192,9 +192,17 @@ void MainWindow::on_pushButton_clicked() info.triangle[1].y = ui->Second_Vertex_Y_Coordinate_Input->text().toInt(); info.triangle[2].x = ui->Third_Vertex_X_Coordinate_Input->text().toInt(); info.triangle[2].y = ui->Third_Vertex_Y_Coordinate_Input->text().toInt(); + + if (info.gradient == TriangleParametric) + { + info.triangle_parametrs[0] = ui->First_Vertex_Parametr_Input_4->text().toFloat(); + info.triangle_parametrs[1] = ui->Second_Vertex_Parametr_Input_4->text().toFloat(); + info.triangle_parametrs[2] = ui->Third_Vertex_Parametr_Input_4->text().toFloat(); + } + info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, - {0.f, 0.9f, 1.f}, + info.triangle_parametrs, info.gradient == TriangleParametric); points = {}; for (auto p : info.triangle) @@ -204,33 +212,51 @@ void MainWindow::on_pushButton_clicked() } else if (info.gradient == CoonsPatch || info.gradient == CoonsPatchParametric) { - info.curve[0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_Vertex_X_Coordinate_Input_3->text().toInt(); - info.curve[0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Vertex_Y_Coordinate_Input_3->text().toInt(); - info.curve[1].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_First_Edge->text().toInt(); - info.curve[1].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_First_Edge->text().toInt(); - info.curve[2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_First_Edge->text().toInt(); - info.curve[2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_First_Edge->text().toInt(); - info.curve[3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_Vertex_X_Coordinate_Input_3->text().toInt(); - info.curve[3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Vertex_Y_Coordinate_Input_3->text().toInt(); - info.curve[4].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Second_Edge->text().toInt(); - info.curve[4].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Second_Edge->text().toInt(); - info.curve[5].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Second_Edge->text().toInt(); - info.curve[5].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Second_Edge->text().toInt(); - info.curve[6].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_Vertex_X_Coordinate_Input_3->text().toInt(); - info.curve[6].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Vertex_Y_Coordinate_Input_3->text().toInt(); - info.curve[7].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Third_Edge->text().toInt(); - info.curve[7].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Third_Edge->text().toInt(); - info.curve[8].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Third_Edge->text().toInt(); - info.curve[8].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Third_Edge->text().toInt(); - info.curve[9].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_Vertex_X_Coordinate_Input_3->text().toInt(); - info.curve[9].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Vertex_Y_Coordinate_Input_3->text().toInt(); - info.curve[10].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Fourth_Edge->text().toInt(); - info.curve[10].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Fourth_Edge->text().toInt(); - info.curve[11].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Fourth_Edge->text().toInt(); - info.curve[11].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Fourth_Edge->text().toInt(); + info.curve[0].x = ui->First_Vertex_X_Coordinate_Input_3->text().toInt(); + info.curve[0].y = ui->First_Vertex_Y_Coordinate_Input_3->text().toInt(); + info.curve[1].x = ui->First_X_Coordinate_First_Edge->text().toInt(); + info.curve[1].y = ui->First_Y_Coordinate_First_Edge->text().toInt(); + info.curve[2].x = ui->Second_X_Coordinate_First_Edge->text().toInt(); + info.curve[2].y = ui->Second_Y_Coordinate_First_Edge->text().toInt(); + info.curve[3].x = ui->Second_Vertex_X_Coordinate_Input_3->text().toInt(); + info.curve[3].y = ui->Second_Vertex_Y_Coordinate_Input_3->text().toInt(); + info.curve[4].x = ui->First_X_Coordinate_Second_Edge->text().toInt(); + info.curve[4].y = ui->First_Y_Coordinate_Second_Edge->text().toInt(); + info.curve[5].x = ui->Second_X_Coordinate_Second_Edge->text().toInt(); + info.curve[5].y = ui->Second_Y_Coordinate_Second_Edge->text().toInt(); + info.curve[6].x = ui->Third_Vertex_X_Coordinate_Input_3->text().toInt(); + info.curve[6].y = ui->Third_Vertex_Y_Coordinate_Input_3->text().toInt(); + info.curve[7].x = ui->First_X_Coordinate_Third_Edge->text().toInt(); + info.curve[7].y = ui->First_Y_Coordinate_Third_Edge->text().toInt(); + info.curve[8].x = ui->Second_X_Coordinate_Third_Edge->text().toInt(); + info.curve[8].y = ui->Second_Y_Coordinate_Third_Edge->text().toInt(); + info.curve[9].x = ui->Fourth_Vertex_X_Coordinate_Input_3->text().toInt(); + info.curve[9].y = ui->Fourth_Vertex_Y_Coordinate_Input_3->text().toInt(); + info.curve[10].x = ui->First_X_Coordinate_Fourth_Edge->text().toInt(); + info.curve[10].y = ui->First_Y_Coordinate_Fourth_Edge->text().toInt(); + info.curve[11].x = ui->Second_X_Coordinate_Fourth_Edge->text().toInt(); + info.curve[11].y = ui->Second_Y_Coordinate_Fourth_Edge->text().toInt(); + + if (info.gradient == CoonsPatchParametric) + { + info.curve_parametrs[0] = ui->First_Vertex_Parametr_Input_2->text().toFloat(); + info.curve_parametrs[1] = ui->Second_Vertex_Parametr_Input_2->text().toFloat(); + info.curve_parametrs[2] = ui->Third_Vertex_Parametr_Input_2->text().toFloat(); + info.curve_parametrs[3] = ui->Fourth_Vertex_Parametr_Input_2->text().toFloat(); + } + + if (info.gradient == CoonsPatch) + { + for(int j = 0; j < 12; j++) + { + info.curve[j].x *= MM_TO_COORD(ui->lable_test->width()); + info.curve[j].y *= MM_TO_COORD(ui->lable_test->height()); + } + } + info.ginfo = NSStructures::GInfoConstructor::get_curve( info.curve, - {0.1f, 0.5f, 0.9f, 0.2f}, + info.curve_parametrs, {{0, 0, 255}, {255, 0, 255}, {255, 0, 0}, {0, 255, 0}}, info.gradient == CoonsPatchParametric @@ -238,41 +264,62 @@ void MainWindow::on_pushButton_clicked() } else if (info.gradient == TensorCoonsPatch || info.gradient == TensorCoonsPatchParametric) { - info.tensorcurve[0][0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][1].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][1].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_X_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Y_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_X_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Y_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[1][0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][1].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][1].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_X_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Y_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_X_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Y_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[2][0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][1].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][1].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_X_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_X_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[3][0].x = MM_TO_COORD(ui->lable_test->width()) * ui->First_X_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][0].y = MM_TO_COORD(ui->lable_test->height()) * ui->First_Y_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][1].x = MM_TO_COORD(ui->lable_test->width()) * ui->Second_X_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][1].y = MM_TO_COORD(ui->lable_test->height()) * ui->Second_Y_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][2].x = MM_TO_COORD(ui->lable_test->width()) * ui->Third_X_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][2].y = MM_TO_COORD(ui->lable_test->height()) * ui->Third_Y_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][3].x = MM_TO_COORD(ui->lable_test->width()) * ui->Fourth_X_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][3].y = MM_TO_COORD(ui->lable_test->height()) * ui->Fourth_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[0][0].x = ui->First_X_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][0].y = ui->First_Y_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][1].x = ui->Second_X_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][1].y = ui->Second_Y_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][2].x = ui->Third_X_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][2].y = ui->Third_Y_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][3].x = ui->Fourth_X_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[0][3].y = ui->Fourth_Y_Coordinate_First_Edge_3->text().toInt(); + info.tensorcurve[1][0].x = ui->First_X_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][0].y = ui->First_Y_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][1].x = ui->Second_X_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][1].y = ui->Second_Y_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][2].x = ui->Third_X_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][2].y = ui->Third_Y_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][3].x = ui->Fourth_X_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[1][3].y = ui->Fourth_Y_Coordinate_Second_Edge_3->text().toInt(); + info.tensorcurve[2][0].x = ui->First_X_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][0].y = ui->First_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][1].x = ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][1].y = ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][2].x = ui->Third_X_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][2].y = ui->Third_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][3].x = ui->Fourth_X_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[2][3].y = ui->Fourth_Y_Coordinate_Third_Edge_3->text().toInt(); + info.tensorcurve[3][0].x = ui->First_X_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][0].y = ui->First_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][1].x = ui->Second_X_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][1].y = ui->Second_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][2].x = ui->Third_X_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][2].y = ui->Third_Y_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][3].x = ui->Fourth_X_Coordinate_Fourth_Edge_3->text().toInt(); + info.tensorcurve[3][3].y = ui->Fourth_Y_Coordinate_Fourth_Edge_3->text().toInt(); + + if (info.gradient == TensorCoonsPatchParametric) + { + info.tensor_curve_parametrs[0][0] = ui->First_Vertex_Parametr_Input_3->text().toFloat(); + info.tensor_curve_parametrs[0][1] = ui->Second_Vertex_Parametr_Input_3->text().toFloat(); + info.tensor_curve_parametrs[1][0] = ui->Third_Vertex_Parametr_Input_3->text().toFloat(); + info.tensor_curve_parametrs[1][1] = ui->Fourth_Vertex_Parametr_Input_3->text().toFloat(); + } + + if (info.gradient == TensorCoonsPatch) + { + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { + info.tensorcurve[i][j].x *= MM_TO_COORD(ui->lable_test->width()); + info.tensorcurve[i][j].y *= MM_TO_COORD(ui->lable_test->height()); + } + } + } + info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve( info.tensorcurve, - {{0, 0.5}, {1, 0.5}}, + info.tensor_curve_parametrs, {{{0, 0, 255}, {255, 0, 255}}, {{255, 0, 0}, {0, 255, 0}}}, info.gradient == TensorCoonsPatchParametric ); diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index c49b016d88..7d39bd6d71 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -41,6 +41,27 @@ public slots: } }; +class CustomParametrLineEdit : public QLineEdit +{ + Q_OBJECT +public: + CustomParametrLineEdit(QWidget *parent = nullptr) : QLineEdit(parent) + { + connect(this, &QLineEdit::editingFinished, this, &CustomParametrLineEdit::onEditingFinished); + } + ~CustomParametrLineEdit() {} +public slots: + void onEditingFinished() + { + if (this->text() == "") + this->setText(this->placeholderText()); + if (this->text().toDouble() < 0) + this->setText("0"); + if (this->text().toDouble() > 1) + this->setText("1"); + } +}; + class CustomLabel : public QLabel { Q_OBJECT @@ -134,6 +155,9 @@ struct Info {{150, 250}, {170, 230}, {170, 170}, {50, 150}}, {{350, 250}, {230, 230}, {230, 170}, {150, 250}}, {{300, 300}, {250, 250}, {350, 150}, {300, 100}}}; + std::vector triangle_parametrs = {0.f, 0.5f, 1.f}; + std::vector curve_parametrs = {0.f, 0.3f, 1.f, 0.6f}; + std::vector> tensor_curve_parametrs = {{0.f, 0.3f}, {1.f, 0.6f}}; NSStructures::GradientInfo ginfo; int gradient_type; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index 509912eddb..923f7d111a 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -117,7 +117,7 @@
- 4 + 3 @@ -2481,8 +2481,8 @@ - 360 - 60 + 370 + 40 117 29 @@ -2494,8 +2494,8 @@ - 380 - 110 + 390 + 100 80 29 @@ -2504,6 +2504,19 @@ set from + + + + 300 + 80 + 288 + 20 + + + + Set the coordinates from the label and click + + @@ -2515,7 +2528,7 @@ - 6 + 3 @@ -2646,7 +2659,134 @@ - + + + + + 10 + 10 + 469 + 20 + + + + A parametric gradient differs in that the colors at the corners are set by + + + + + + 10 + 30 + 271 + 20 + + + + the initial parameters (value from 0 to 1). + + + + + + 10 + 50 + 470 + 130 + + + + Set Parametrs + + + + + 10 + 30 + 135 + 20 + + + + First Vertex Parametr + + + + + + 10 + 50 + 113 + 28 + + + + 0 + + + 0 + + + + + + 270 + 30 + 157 + 20 + + + + Second Vertex Parametr + + + + + + 270 + 50 + 113 + 28 + + + + 0.5 + + + 0.5 + + + + + + 10 + 80 + 157 + 20 + + + + Third Vertex Parametr + + + + + + 10 + 100 + 113 + 28 + + + + 1 + + + 1 + + + + @@ -2753,7 +2893,163 @@ - + + + + + 10 + 10 + 469 + 20 + + + + A parametric gradient differs in that the colors at the corners are set by + + + + + + 10 + 30 + 271 + 20 + + + + the initial parameters (value from 0 to 1). + + + + + + 10 + 50 + 470 + 130 + + + + Set Parametrs + + + + + 10 + 30 + 135 + 20 + + + + First Vertex Parametr + + + + + + 10 + 50 + 113 + 28 + + + + 0 + + + 0 + + + + + + 270 + 30 + 157 + 20 + + + + Second Vertex Parametr + + + + + + 270 + 50 + 113 + 28 + + + + 0.3 + + + 0.3 + + + + + + 10 + 80 + 157 + 20 + + + + Third Vertex Parametr + + + + + + 10 + 100 + 113 + 28 + + + + 0.6 + + + 0.6 + + + + + + 270 + 80 + 157 + 20 + + + + Fourth Vertex Parametr + + + + + + 270 + 100 + 113 + 28 + + + + 1 + + + 1 + + + + @@ -2808,7 +3104,163 @@ - + + + + + 10 + 10 + 469 + 20 + + + + A parametric gradient differs in that the colors at the corners are set by + + + + + + 10 + 30 + 271 + 20 + + + + the initial parameters (value from 0 to 1). + + + + + + 10 + 50 + 470 + 130 + + + + Set Parametrs + + + + + 10 + 30 + 135 + 20 + + + + First Vertex Parametr + + + + + + 10 + 50 + 113 + 28 + + + + 0 + + + 0 + + + + + + 270 + 30 + 157 + 20 + + + + Second Vertex Parametr + + + + + + 270 + 50 + 113 + 28 + + + + 0.3 + + + 0.3 + + + + + + 10 + 80 + 157 + 20 + + + + Third Vertex Parametr + + + + + + 10 + 100 + 113 + 28 + + + + 0.6 + + + 0.6 + + + + + + 270 + 80 + 157 + 20 + + + + Fourth Vertex Parametr + + + + + + 270 + 100 + 113 + 28 + + + + 1 + + + 1 + + + + @@ -2911,6 +3363,11 @@ QLabel
mainwindow.h
+ + CustomParametrLineEdit + QLineEdit +
mainwindow.h
+
From 63c9185fd2c515b0c2aded0a88c0a3ff87d606c6 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Mon, 29 Apr 2024 22:08:28 +0300 Subject: [PATCH 10/13] Add choice of colors for non parametric gradients --- .../gradient/Gradient/mainwindow.cpp | 78 ++++++- .../gradient/Gradient/mainwindow.h | 47 ++++ .../gradient/Gradient/mainwindow.ui | 220 ++++++++++++------ 3 files changed, 273 insertions(+), 72 deletions(-) diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index 2368436fef..b146861aea 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -83,10 +83,22 @@ QImage GenerateImg(std::vector &points, Info &info, const int& w, const i return img; } +void MainWindow::InitializeColors(bool Triangle) +{ + ui->label_80->SetColor(QColor(Qt::red)); + ui->label_81->SetColor(QColor(Qt::green)); + ui->label_114->SetColor(QColor(Qt::blue)); + if (!Triangle) + { + ui->label_115->SetColor(QColor(Qt::yellow)); + } +} + void MainWindow::on_actionLinear_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(0); ui->stackedWidget_2->setCurrentIndex(0); + ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Linear"); info.gradient = Linear; info.gradient_type = c_BrushTypePathNewLinearGradient; @@ -96,6 +108,7 @@ void MainWindow::on_actionRadial_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(1); ui->stackedWidget_2->setCurrentIndex(1); + ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Radial"); info.gradient = Radial; info.gradient_type = c_BrushTypePathRadialGradient; @@ -105,6 +118,8 @@ void MainWindow::on_actionTriangle_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(2); ui->stackedWidget_2->setCurrentIndex(2); + ui->stackedWidget_3->setCurrentIndex(1); + InitializeColors(true); ui->statusbar->showMessage("Triangle"); info.gradient = Triangle; info.gradient_type = c_BrushTypeTriagnleMeshGradient; @@ -114,6 +129,7 @@ void MainWindow::on_actionTriangle_Parametric_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(2); ui->stackedWidget_2->setCurrentIndex(3); + ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Triangle Parametric"); info.gradient = TriangleParametric; info.gradient_type = c_BrushTypeTriagnleMeshGradient; @@ -123,6 +139,8 @@ void MainWindow::on_actionCoons_Patch_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(3); ui->stackedWidget_2->setCurrentIndex(4); + ui->stackedWidget_3->setCurrentIndex(1); + InitializeColors(false); ui->statusbar->showMessage("Coons Patch"); info.gradient = CoonsPatch; info.gradient_type = c_BrushTypePathNewLinearGradient; @@ -132,6 +150,7 @@ void MainWindow::on_actionCoons_Patch_Parametric_triggered() { ui->stackedWidget->setCurrentIndex(3); ui->stackedWidget_2->setCurrentIndex(5); + ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Coons Patch Parametric"); info.gradient = CoonsPatchParametric; info.gradient_type = c_BrushTypeCurveGradient; @@ -141,6 +160,8 @@ void MainWindow::on_actionTensor_Coons_Patch_Gradient_triggered() { ui->stackedWidget->setCurrentIndex(4); ui->stackedWidget_2->setCurrentIndex(6); + ui->stackedWidget_3->setCurrentIndex(1); + InitializeColors(false); ui->statusbar->showMessage("Tensor Coons Patch"); info.gradient = TensorCoonsPatch; info.gradient_type = c_BrushTypePathNewLinearGradient; @@ -150,11 +171,58 @@ void MainWindow::on_actionTensor_Coons_Patch_Parametric_triggered() { ui->stackedWidget->setCurrentIndex(4); ui->stackedWidget_2->setCurrentIndex(7); + ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Tensor Coons Patch Parametric"); info.gradient = TensorCoonsPatchParametric; info.gradient_type = c_BrushTypeTensorCurveGradient; } +std::vector MainWindow::QColor2rgba(bool triangle) +{ + std::vector colors; + colors.push_back({static_cast(ui->label_80->GetColor().red()), + static_cast(ui->label_80->GetColor().green()), + static_cast(ui->label_80->GetColor().blue())}); + colors.push_back({static_cast(ui->label_81->GetColor().red()), + static_cast(ui->label_81->GetColor().green()), + static_cast(ui->label_81->GetColor().blue())}); + colors.push_back({static_cast(ui->label_114->GetColor().red()), + static_cast(ui->label_114->GetColor().green()), + static_cast(ui->label_114->GetColor().blue())}); + if (!triangle) + { + colors.push_back({static_cast(ui->label_115->GetColor().red()), + static_cast(ui->label_115->GetColor().green()), + static_cast(ui->label_115->GetColor().blue())}); + } + + return colors; +} + +std::vector> MainWindow::QColor2rgbaMatrix() +{ + std::vector> colors; + std::vector sub_colors; + sub_colors.push_back({static_cast(ui->label_80->GetColor().red()), + static_cast(ui->label_80->GetColor().green()), + static_cast(ui->label_80->GetColor().blue())}); + sub_colors.push_back({static_cast(ui->label_81->GetColor().red()), + static_cast(ui->label_81->GetColor().green()), + static_cast(ui->label_81->GetColor().blue())}); + colors.push_back(sub_colors); + sub_colors.clear(); + sub_colors.push_back({static_cast(ui->label_114->GetColor().red()), + static_cast(ui->label_114->GetColor().green()), + static_cast(ui->label_114->GetColor().blue())}); + sub_colors.push_back({static_cast(ui->label_115->GetColor().red()), + static_cast(ui->label_115->GetColor().green()), + static_cast(ui->label_115->GetColor().blue())}); + colors.push_back(sub_colors); + sub_colors.clear(); + + return colors; +} + void MainWindow::on_pushButton_clicked() { points = {{0, 0}, @@ -199,9 +267,8 @@ void MainWindow::on_pushButton_clicked() info.triangle_parametrs[1] = ui->Second_Vertex_Parametr_Input_4->text().toFloat(); info.triangle_parametrs[2] = ui->Third_Vertex_Parametr_Input_4->text().toFloat(); } - info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, - {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}}, + QColor2rgba(true), info.triangle_parametrs, info.gradient == TriangleParametric); points = {}; @@ -253,12 +320,10 @@ void MainWindow::on_pushButton_clicked() info.curve[j].y *= MM_TO_COORD(ui->lable_test->height()); } } - info.ginfo = NSStructures::GInfoConstructor::get_curve( info.curve, info.curve_parametrs, - {{0, 0, 255}, {255, 0, 255}, - {255, 0, 0}, {0, 255, 0}}, + QColor2rgba(false), info.gradient == CoonsPatchParametric ); } @@ -320,7 +385,7 @@ void MainWindow::on_pushButton_clicked() info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve( info.tensorcurve, info.tensor_curve_parametrs, - {{{0, 0, 255}, {255, 0, 255}}, {{255, 0, 0}, {0, 255, 0}}}, + QColor2rgbaMatrix(), info.gradient == TensorCoonsPatchParametric ); } @@ -453,4 +518,3 @@ void MainWindow::on_pushButton_2_clicked() ui->lable_test->Clear(); } } - diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index 7d39bd6d71..d7edfce592 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "../../../../DesktopEditor/graphics/structures.h" @@ -99,6 +100,49 @@ private: std::vector m_points; }; +class CustomColorLabel : public QLabel +{ + Q_OBJECT +public: + CustomColorLabel(QWidget *parent = nullptr) : QLabel(parent) + { + connect(this, &CustomColorLabel::mousePressed, this, &CustomColorLabel::onMousePressed); + } + + ~CustomColorLabel() {} + + void SetColor(QColor color) + { + m_color = color; + this->setStyleSheet("QLabel { background-color : " + m_color.name() + "; border: 1px solid black; padding 10px;}"); + } + + QColor GetColor() const + { + return m_color; + } +signals: + void mousePressed(); +protected: + void mousePressEvent(QMouseEvent *event) override + { + emit mousePressed(); + } +public slots: + void onMousePressed() + { + QColorDialog colorDialog; + QColor color = colorDialog.getColor(); + + if (color.isValid()) + { + SetColor(color); + } + } +private: + QColor m_color; +}; + typedef enum { Linear, @@ -191,6 +235,9 @@ class MainWindow : public QMainWindow public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); + void InitializeColors(bool triangle); + std::vector QColor2rgba(bool triangle); + std::vector> QColor2rgbaMatrix(); QImage img; QLabel *lable; std::vector points; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index 923f7d111a..a6ff2122c6 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -42,71 +42,6 @@ - - - - 10 - 0 - 201 - 140 - - - - Choose gradient colorspace - - - - - 20 - 20 - 112 - 26 - - - - Rainbow - - - - - - 20 - 50 - 161 - 26 - - - - Black and White - - - - - - 20 - 80 - 131 - 26 - - - - Red and Blue - - - - - - 20 - 110 - 112 - 26 - - - - Pastel - - - @@ -2517,6 +2452,153 @@ Set the coordinates from the label and click + + + + 10 + 10 + 221 + 130 + + + + 1 + + + + + + 10 + 10 + 201 + 120 + + + + Choose gradient colorspace + + + + + 20 + 30 + 112 + 26 + + + + Rainbow + + + + + + 20 + 50 + 161 + 26 + + + + Black and White + + + + + + 20 + 70 + 131 + 26 + + + + Red and Blue + + + + + + 20 + 90 + 112 + 26 + + + + Pastel + + + + + + + + + 20 + 20 + 171 + 81 + + + + Set colors in angles + + + + + 10 + 40 + 30 + 20 + + + + + + + + + + 50 + 40 + 30 + 20 + + + + + + + + + + 90 + 40 + 30 + 20 + + + + + + + + + + 130 + 40 + 30 + 20 + + + + + + + + +
@@ -3368,6 +3450,14 @@ QLineEdit
mainwindow.h
+ + CustomColorLabel + QLabel +
mainwindow.h
+ + onMouseClicked() + +
From fb12bfa57f622618a14ce67712226013a87d0b49 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Mon, 13 May 2024 11:17:30 +0300 Subject: [PATCH 11/13] Add MovablePoints on Label --- .../gradient/Gradient/mainwindow.cpp | 397 +++++++++++++----- .../gradient/Gradient/mainwindow.h | 86 +++- .../gradient/Gradient/mainwindow.ui | 28 +- 3 files changed, 378 insertions(+), 133 deletions(-) diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index b146861aea..dba76eaa80 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -12,6 +12,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi ui->lable_test->setStyleSheet("QLabel { background-color : white;}"); on_actionLinear_Gradient_triggered(); ui->Rainbow_Colorspace_Radio_Button->setChecked(true); + connect(ui->lable_test, SIGNAL(mousePressed()), this, SLOT(on_label_test_clicked())); } MainWindow::~MainWindow() @@ -223,6 +224,306 @@ std::vector> MainWindow::QColor2rgbaMatrix() return colors; } +inline void setPoint(QImage *image, int x, int y, QRgb color) +{ + image->setPixel(x, y, color); + image->setPixel(x - 1, y, color); + image->setPixel(x, y - 1, color); + image->setPixel(x + 1, y, color); + image->setPixel(x, y + 1, color); +} + +void MainWindow::setPoints(QImage *image) +{ + std::vector points; + if (info.gradient == Linear) + { + setPoint(image, + info.p0.x * MM_TO_COORD(ui->lable_test->width()), + info.p0.y * MM_TO_COORD(ui->lable_test->height()), + qRgb(0, 0, 0)); + setPoint(image, + info.p1.x * MM_TO_COORD(ui->lable_test->width()), + info.p1.y * MM_TO_COORD(ui->lable_test->height()), + qRgb(0, 0, 0)); + points.push_back(QPoint(info.p0.x * MM_TO_COORD(ui->lable_test->width()), info.p0.y * MM_TO_COORD(ui->lable_test->height()))); + points.push_back(QPoint(info.p1.x * MM_TO_COORD(ui->lable_test->width()), info.p1.y * MM_TO_COORD(ui->lable_test->height()))); + } + else if (info.gradient == Radial) + { + setPoint(image, + info.c0.x * MM_TO_COORD(ui->lable_test->width()), + info.c0.y * MM_TO_COORD(ui->lable_test->height()), + qRgb(0, 0, 0)); + setPoint(image, + info.c1.x * MM_TO_COORD(ui->lable_test->width()), + info.c1.y * MM_TO_COORD(ui->lable_test->height()), + qRgb(0, 0, 0)); + points.push_back(QPoint(info.c0.x * MM_TO_COORD(ui->lable_test->width()), info.c0.y * MM_TO_COORD(ui->lable_test->height()))); + points.push_back(QPoint(info.c1.x * MM_TO_COORD(ui->lable_test->width()), info.c1.y * MM_TO_COORD(ui->lable_test->height()))); + } + else if (info.gradient == Triangle || info.gradient == TriangleParametric) + { + for (NSStructures::Point p : info.triangle) + { + setPoint(image, + p.x * MM_TO_COORD(ui->lable_test->width()), + p.y * MM_TO_COORD(ui->lable_test->height()), + qRgb(0,0,0)); + points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()))); + } + } + else if (info.gradient == CoonsPatch) + { + for (NSStructures::Point p : info.curve) + { + setPoint(image, + p.x, + p.y, + qRgb(0,0,0)); + points.push_back(QPoint(p.x, p.y)); + } + } + else if (info.gradient == CoonsPatchParametric) + { + for (NSStructures::Point p : info.curve) + { + setPoint(image, + p.x * MM_TO_COORD(ui->lable_test->width()), + p.y * MM_TO_COORD(ui->lable_test->height()), + qRgb(0,0,0)); + points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->width()))); + } + } + else if (info.gradient == TensorCoonsPatch) + { + for (std::vector v : info.tensorcurve) + { + for (NSStructures::Point p : v) + { + setPoint(image, + p.x, + p.y, + qRgb(0,0,0)); + points.push_back(QPoint(p.x, p.y)); + } + } + } + else if (info.gradient == TensorCoonsPatchParametric) + { + for (std::vector v : info.tensorcurve) + { + for (NSStructures::Point p : v) + { + setPoint(image, + p.x * MM_TO_COORD(ui->lable_test->width()), + p.y * MM_TO_COORD(ui->lable_test->height()), + qRgb(0,0,0)); + points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->width()))); + } + } + } + ui->lable_test->SetPoints(points); +} + +void MainWindow::on_label_test_clicked() +{ + if (ui->lable_test->Movable()) + { + ui->lable_test->ResetMovable(); + disconnect(ui->lable_test, SIGNAL(mouseMoved()), this, SLOT(on_label_test_mouse_move())); + } + else if (ui->lable_test->CheckPointArea()) + { + ui->lable_test->ResetMovable(); + connect(ui->lable_test, SIGNAL(mouseMoved()), this, SLOT(on_label_test_mouse_move())); + } +} + +void MainWindow::on_label_test_mouse_move() +{ + if (info.gradient == Linear) + { + switch (ui->lable_test->GetIndex()) + { + case 0: + ui->First_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 1: + ui->Second_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + default: + break; + } + } + else if (info.gradient == Radial) + { + switch (ui->lable_test->GetIndex()) + { + case 0: + ui->First_Center_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Center_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 1: + ui->Second_Center_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Center_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + default: + break; + } + } + else if (info.gradient == Triangle || info.gradient == TriangleParametric) + { + switch (ui->lable_test->GetIndex()) + { + case 0: + ui->First_Vertex_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Vertex_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 1: + ui->Second_Vertex_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Vertex_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 2: + ui->Third_Vertex_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Vertex_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + default: + break; + } + } + else if (info.gradient == CoonsPatch || info.gradient == CoonsPatchParametric) + { + switch (ui->lable_test->GetIndex()) + { + case 0: + ui->First_Vertex_X_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Vertex_Y_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 1: + ui->First_X_Coordinate_First_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_First_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 2: + ui->Second_X_Coordinate_First_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_First_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 3: + ui->Second_Vertex_X_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Vertex_Y_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 4: + ui->First_X_Coordinate_Second_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Second_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 5: + ui->Second_X_Coordinate_Second_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Second_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 6: + ui->Third_Vertex_X_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Vertex_Y_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 7: + ui->First_X_Coordinate_Third_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Third_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 8: + ui->Second_X_Coordinate_Third_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Third_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 9: + ui->Fourth_Vertex_X_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Vertex_Y_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 10: + ui->First_X_Coordinate_Fourth_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Fourth_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 11: + ui->Second_X_Coordinate_Fourth_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Fourth_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + default: + break; + } + } + else if (info.gradient == TensorCoonsPatch || info.gradient == TensorCoonsPatchParametric) + { + switch (ui->lable_test->GetIndex()) + { + case 0: + ui->First_X_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 1: + ui->Second_X_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 2: + ui->Third_X_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Y_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); + break; + case 3: + ui->Fourth_X_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Y_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); + break; + case 4: + ui->First_X_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 5: + ui->Second_X_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 6: + ui->Third_X_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Y_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); + break; + case 7: + ui->Fourth_X_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Y_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); + break; + case 8: + ui->First_X_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 9: + ui->Second_X_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 10: + ui->Third_X_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Y_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); + break; + case 11: + ui->Fourth_X_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Y_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); + break; + case 12: + ui->First_X_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->First_Y_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 13: + ui->Second_X_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + ui->Second_Y_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + break; + case 14: + ui->Third_X_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Third_Y_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); + case 15: + ui->Fourth_X_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); + ui->Fourth_Y_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); + default: + break; + } + } + + on_pushButton_clicked(); +} + void MainWindow::on_pushButton_clicked() { points = {{0, 0}, @@ -420,101 +721,7 @@ void MainWindow::on_pushButton_clicked() } QImage pm = GenerateImg(points, info, ui->lable_test->width(), ui->lable_test->height()); + setPoints(&pm); ui->lable_test->setPixmap(QPixmap::fromImage(pm)); ui->lable_test->setScaledContents(true); } - -void MainWindow::on_pushButton_2_clicked() -{ - std::vector p = ui->lable_test->GetPoints(); - if (info.gradient == Linear) - { - ui->First_X_Coordinate_Input->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Input->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_Input->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Input->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->lable_test->Clear(); - } - else if (info.gradient == Radial) - { - ui->First_Center_X_Coordinate_Input->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Center_Y_Coordinate_Input->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_Center_X_Coordinate_Input->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Center_Y_Coordinate_Input->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->lable_test->Clear(); - } - else if (info.gradient == Triangle || info.gradient == TriangleParametric) - { - ui->First_Vertex_X_Coordinate_Input->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Vertex_Y_Coordinate_Input->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_Vertex_X_Coordinate_Input->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Vertex_Y_Coordinate_Input->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Third_Vertex_X_Coordinate_Input->setText(QString::number(p[2].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Vertex_Y_Coordinate_Input->setText(QString::number(p[2].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->lable_test->Clear(); - } - else if (info.gradient == CoonsPatch || info.gradient == CoonsPatchParametric) - { - ui->First_Vertex_X_Coordinate_Input_3->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Vertex_Y_Coordinate_Input_3->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->First_X_Coordinate_First_Edge->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_First_Edge->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_First_Edge->setText(QString::number(p[2].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_First_Edge->setText(QString::number(p[2].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_Vertex_X_Coordinate_Input_3->setText(QString::number(p[3].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Vertex_Y_Coordinate_Input_3->setText(QString::number(p[3].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->First_X_Coordinate_Second_Edge->setText(QString::number(p[4].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Second_Edge->setText(QString::number(p[4].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_Second_Edge->setText(QString::number(p[5].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Second_Edge->setText(QString::number(p[5].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Third_Vertex_X_Coordinate_Input_3->setText(QString::number(p[6].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Vertex_Y_Coordinate_Input_3->setText(QString::number(p[6].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->First_X_Coordinate_Third_Edge->setText(QString::number(p[7].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Third_Edge->setText(QString::number(p[7].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_Third_Edge->setText(QString::number(p[8].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Third_Edge->setText(QString::number(p[8].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Fourth_Vertex_X_Coordinate_Input_3->setText(QString::number(p[9].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Vertex_Y_Coordinate_Input_3->setText(QString::number(p[9].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->First_X_Coordinate_Fourth_Edge->setText(QString::number(p[10].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Fourth_Edge->setText(QString::number(p[10].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_Fourth_Edge->setText(QString::number(p[11].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Fourth_Edge->setText(QString::number(p[11].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->lable_test->Clear(); - } - else if (info.gradient == TensorCoonsPatch || info.gradient == TensorCoonsPatchParametric) - { - ui->First_X_Coordinate_First_Edge_3->setText(QString::number(p[0].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_First_Edge_3->setText(QString::number(p[0].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_First_Edge_3->setText(QString::number(p[1].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_First_Edge_3->setText(QString::number(p[1].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Third_X_Coordinate_First_Edge_3->setText(QString::number(p[2].x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Y_Coordinate_First_Edge_3->setText(QString::number(p[2].x()/ MM_TO_COORD(ui->lable_test->height()))); - ui->Fourth_X_Coordinate_First_Edge_3->setText(QString::number(p[3].x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Y_Coordinate_First_Edge_3->setText(QString::number(p[3].x()/ MM_TO_COORD(ui->lable_test->height()))); - ui->First_X_Coordinate_Second_Edge_3->setText(QString::number(p[4].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Second_Edge_3->setText(QString::number(p[4].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_Second_Edge_3->setText(QString::number(p[5].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Second_Edge_3->setText(QString::number(p[5].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Third_X_Coordinate_Second_Edge_3->setText(QString::number(p[6].x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Y_Coordinate_Second_Edge_3->setText(QString::number(p[6].x()/ MM_TO_COORD(ui->lable_test->height()))); - ui->Fourth_X_Coordinate_Second_Edge_3->setText(QString::number(p[7].x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Y_Coordinate_Second_Edge_3->setText(QString::number(p[7].x()/ MM_TO_COORD(ui->lable_test->height()))); - ui->First_X_Coordinate_Third_Edge_3->setText(QString::number(p[8].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Third_Edge_3->setText(QString::number(p[8].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_Third_Edge_3->setText(QString::number(p[9].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Third_Edge_3->setText(QString::number(p[9].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Third_X_Coordinate_Third_Edge_3->setText(QString::number(p[10].x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Y_Coordinate_Third_Edge_3->setText(QString::number(p[10].x()/ MM_TO_COORD(ui->lable_test->height()))); - ui->Fourth_X_Coordinate_Third_Edge_3->setText(QString::number(p[11].x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Y_Coordinate_Third_Edge_3->setText(QString::number(p[11].x()/ MM_TO_COORD(ui->lable_test->height()))); - ui->First_X_Coordinate_Fourth_Edge_3->setText(QString::number(p[12].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Fourth_Edge_3->setText(QString::number(p[12].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Second_X_Coordinate_Fourth_Edge_3->setText(QString::number(p[13].x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Fourth_Edge_3->setText(QString::number(p[13].y() / MM_TO_COORD(ui->lable_test->height()))); - ui->Third_X_Coordinate_Fourth_Edge_3->setText(QString::number(p[14].x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Y_Coordinate_Fourth_Edge_3->setText(QString::number(p[14].x()/ MM_TO_COORD(ui->lable_test->height()))); - ui->Fourth_X_Coordinate_Fourth_Edge_3->setText(QString::number(p[15].x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Y_Coordinate_Fourth_Edge_3->setText(QString::number(p[15].x()/ MM_TO_COORD(ui->lable_test->height()))); - ui->lable_test->Clear(); - } -} diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index d7edfce592..ca548e2ae1 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -69,34 +69,95 @@ class CustomLabel : public QLabel public: CustomLabel(QWidget *parent = nullptr) : QLabel(parent) { - connect(this, &CustomLabel::mousePressed, this, &CustomLabel::onCheckPosition); + movable = false; + setMouseTracking(true); } ~CustomLabel() {} - std::vector GetPoints() const + void SetPoints(const std::vector& points) { - return m_points; + m_points = points; + } + + QPoint GetCheckPoint() const + { + return checkPoint; + } + + QPoint GetMovePoint() const + { + return movePoint; + } + + size_t GetIndex() const + { + return index; + } + + bool Movable() const + { + return movable; + } + + void ResetMovable() + { + if (movable) + { + movable = false; + } + else + { + movable = true; + } + } + + void setIndex(size_t _index) + { + index = _index; } void Clear() { m_points.clear(); } + + bool CheckPointArea() + { + for (int i = 0; i < m_points.size(); i++) + { + QRect rect(m_points[i].x() - 5, m_points[i].y() - 5, m_points[i].x() + 5, m_points[i].y() + 5); + if (rect.contains(checkPoint)) + { + index = i; + return true; + } + } + return false; + } + signals: - void mousePressed(QPoint point); + void mousePressed(); + void mouseMoved(); + protected: void mousePressEvent(QMouseEvent *event) override { - QPoint point = event->pos(); - emit mousePressed(point); + checkPoint = event->pos(); + emit mousePressed(); } -public slots: - void onCheckPosition(QPoint point) + + void mouseMoveEvent(QMouseEvent *event) override { - m_points.push_back(point); + movePoint = event->pos(); + emit mouseMoved(); } + private: + bool movable; + size_t index; + QPoint movePoint; + QPoint checkPoint; std::vector m_points; }; @@ -238,6 +299,7 @@ public: void InitializeColors(bool triangle); std::vector QColor2rgba(bool triangle); std::vector> QColor2rgbaMatrix(); + void setPoints(QImage *image); QImage img; QLabel *lable; std::vector points; @@ -245,6 +307,10 @@ public: private slots: + void on_label_test_clicked(); + + void on_label_test_mouse_move(); + void on_actionLinear_Gradient_triggered(); void on_actionRadial_Gradient_triggered(); @@ -263,8 +329,6 @@ private slots: void on_actionTensor_Coons_Patch_Parametric_triggered(); - void on_pushButton_2_clicked(); - private: Ui::MainWindow *ui; }; diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index a6ff2122c6..ae202b3f9d 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -52,7 +52,7 @@
- 3 + 4 @@ -2426,32 +2426,6 @@ Render Gradient - - - - 390 - 100 - 80 - 29 - - - - set from - - - - - - 300 - 80 - 288 - 20 - - - - Set the coordinates from the label and click - - From f86548c8733fa12f35eadb73fed768be327d8269 Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Thu, 30 May 2024 16:27:00 +0300 Subject: [PATCH 12/13] Refactoring --- .../gradient/Gradient/mainwindow.cpp | 625 ++-- .../gradient/Gradient/mainwindow.h | 92 +- .../gradient/Gradient/mainwindow.ui | 2907 +++++++++-------- 3 files changed, 1717 insertions(+), 1907 deletions(-) diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index dba76eaa80..1a3473a151 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -1,7 +1,5 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include -#include #include "../../../../DesktopEditor/graphics/pro/Graphics.h" #include "../../../../PdfFile/PdfFile.h" @@ -9,10 +7,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), img("test.png"), lable(new QLabel) { ui->setupUi(this); - ui->lable_test->setStyleSheet("QLabel { background-color : white;}"); - on_actionLinear_Gradient_triggered(); - ui->Rainbow_Colorspace_Radio_Button->setChecked(true); + + listOfLines = ui->centralwidget->findChildren(); + listOfParametricLines = ui->centralwidget->findChildren(); + listOfCheckBox = ui->centralwidget->findChildren(); + listOfColorLabels = ui->centralwidget->findChildren(); + connect(ui->lable_test, SIGNAL(mousePressed()), this, SLOT(on_label_test_clicked())); + + on_actionLinear_Gradient_triggered(); } MainWindow::~MainWindow() @@ -25,7 +28,7 @@ void CleanupFunction(void *data) delete[] data; } -QImage GenerateImg(std::vector &points, Info &info, const int& w, const int& h) +QImage GenerateImg(std::vector &points, Info &info, const int& w, const int& h) { NSGraphics::IGraphicsRenderer *pRasterRenderer = NSGraphics::Create(); NSFonts::IFontManager *fmp = NSFonts::NSFontManager::Create(); @@ -101,7 +104,8 @@ void MainWindow::on_actionLinear_Gradient_triggered() ui->stackedWidget_2->setCurrentIndex(0); ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Linear"); - info.gradient = Linear; + info.gradient = Linear; + info.offset = LinearOffset; info.gradient_type = c_BrushTypePathNewLinearGradient; } @@ -111,7 +115,8 @@ void MainWindow::on_actionRadial_Gradient_triggered() ui->stackedWidget_2->setCurrentIndex(1); ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Radial"); - info.gradient = Radial; + info.gradient = Radial; + info.offset = RadialOffset; info.gradient_type = c_BrushTypePathRadialGradient; } @@ -122,7 +127,8 @@ void MainWindow::on_actionTriangle_Gradient_triggered() ui->stackedWidget_3->setCurrentIndex(1); InitializeColors(true); ui->statusbar->showMessage("Triangle"); - info.gradient = Triangle; + info.gradient = Triangle; + info.offset = TriangleOffset; info.gradient_type = c_BrushTypeTriagnleMeshGradient; } @@ -132,7 +138,8 @@ void MainWindow::on_actionTriangle_Parametric_Gradient_triggered() ui->stackedWidget_2->setCurrentIndex(3); ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Triangle Parametric"); - info.gradient = TriangleParametric; + info.gradient = TriangleParametric; + info.offset = TriangleOffset; info.gradient_type = c_BrushTypeTriagnleMeshGradient; } @@ -143,7 +150,8 @@ void MainWindow::on_actionCoons_Patch_Gradient_triggered() ui->stackedWidget_3->setCurrentIndex(1); InitializeColors(false); ui->statusbar->showMessage("Coons Patch"); - info.gradient = CoonsPatch; + info.gradient = CoonsPatch; + info.offset = CoonsPatchOffset; info.gradient_type = c_BrushTypePathNewLinearGradient; } @@ -153,7 +161,8 @@ void MainWindow::on_actionCoons_Patch_Parametric_triggered() ui->stackedWidget_2->setCurrentIndex(5); ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Coons Patch Parametric"); - info.gradient = CoonsPatchParametric; + info.gradient = CoonsPatchParametric; + info.offset = CoonsPatchOffset; info.gradient_type = c_BrushTypeCurveGradient; } @@ -164,7 +173,8 @@ void MainWindow::on_actionTensor_Coons_Patch_Gradient_triggered() ui->stackedWidget_3->setCurrentIndex(1); InitializeColors(false); ui->statusbar->showMessage("Tensor Coons Patch"); - info.gradient = TensorCoonsPatch; + info.gradient = TensorCoonsPatch; + info.offset = TensorCoonsPatchOffset; info.gradient_type = c_BrushTypePathNewLinearGradient; } @@ -174,27 +184,29 @@ void MainWindow::on_actionTensor_Coons_Patch_Parametric_triggered() ui->stackedWidget_2->setCurrentIndex(7); ui->stackedWidget_3->setCurrentIndex(0); ui->statusbar->showMessage("Tensor Coons Patch Parametric"); - info.gradient = TensorCoonsPatchParametric; + info.gradient = TensorCoonsPatchParametric; + info.offset = TensorCoonsPatchOffset; info.gradient_type = c_BrushTypeTensorCurveGradient; } +inline agg::rgba8 getRGB(CustomColorLabel *label) +{ + return {static_cast(label->GetColor().red()), + static_cast(label->GetColor().green()), + static_cast(label->GetColor().blue())}; +} + std::vector MainWindow::QColor2rgba(bool triangle) { std::vector colors; - colors.push_back({static_cast(ui->label_80->GetColor().red()), - static_cast(ui->label_80->GetColor().green()), - static_cast(ui->label_80->GetColor().blue())}); - colors.push_back({static_cast(ui->label_81->GetColor().red()), - static_cast(ui->label_81->GetColor().green()), - static_cast(ui->label_81->GetColor().blue())}); - colors.push_back({static_cast(ui->label_114->GetColor().red()), - static_cast(ui->label_114->GetColor().green()), - static_cast(ui->label_114->GetColor().blue())}); - if (!triangle) + + size_t size = listOfColorLabels.size(); + if (triangle) + size--; + + for (int i = 0; i < size; i++) { - colors.push_back({static_cast(ui->label_115->GetColor().red()), - static_cast(ui->label_115->GetColor().green()), - static_cast(ui->label_115->GetColor().blue())}); + colors.push_back(getRGB(listOfColorLabels[i])); } return colors; @@ -203,23 +215,17 @@ std::vector MainWindow::QColor2rgba(bool triangle) std::vector> MainWindow::QColor2rgbaMatrix() { std::vector> colors; - std::vector sub_colors; - sub_colors.push_back({static_cast(ui->label_80->GetColor().red()), - static_cast(ui->label_80->GetColor().green()), - static_cast(ui->label_80->GetColor().blue())}); - sub_colors.push_back({static_cast(ui->label_81->GetColor().red()), - static_cast(ui->label_81->GetColor().green()), - static_cast(ui->label_81->GetColor().blue())}); - colors.push_back(sub_colors); - sub_colors.clear(); - sub_colors.push_back({static_cast(ui->label_114->GetColor().red()), - static_cast(ui->label_114->GetColor().green()), - static_cast(ui->label_114->GetColor().blue())}); - sub_colors.push_back({static_cast(ui->label_115->GetColor().red()), - static_cast(ui->label_115->GetColor().green()), - static_cast(ui->label_115->GetColor().blue())}); - colors.push_back(sub_colors); - sub_colors.clear(); + size_t size = listOfColorLabels.size() / 2; + + for (int i = 0; i < size; i++) + { + std::vector sub_colors; + for (int j = 0; j < size; j++) + { + sub_colors.push_back(getRGB(listOfColorLabels[2 * i + j])); + } + colors.push_back(sub_colors); + } return colors; } @@ -236,92 +242,64 @@ inline void setPoint(QImage *image, int x, int y, QRgb color) void MainWindow::setPoints(QImage *image) { std::vector points; - if (info.gradient == Linear) + switch (info.gradient) { - setPoint(image, - info.p0.x * MM_TO_COORD(ui->lable_test->width()), - info.p0.y * MM_TO_COORD(ui->lable_test->height()), - qRgb(0, 0, 0)); - setPoint(image, - info.p1.x * MM_TO_COORD(ui->lable_test->width()), - info.p1.y * MM_TO_COORD(ui->lable_test->height()), - qRgb(0, 0, 0)); + case Linear: + setPoint(image, info.p0.x * MM_TO_COORD(ui->lable_test->width()), info.p0.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0, 0, 0)); + setPoint(image, info.p1.x * MM_TO_COORD(ui->lable_test->width()), info.p1.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0, 0, 0)); points.push_back(QPoint(info.p0.x * MM_TO_COORD(ui->lable_test->width()), info.p0.y * MM_TO_COORD(ui->lable_test->height()))); points.push_back(QPoint(info.p1.x * MM_TO_COORD(ui->lable_test->width()), info.p1.y * MM_TO_COORD(ui->lable_test->height()))); - } - else if (info.gradient == Radial) - { - setPoint(image, - info.c0.x * MM_TO_COORD(ui->lable_test->width()), - info.c0.y * MM_TO_COORD(ui->lable_test->height()), - qRgb(0, 0, 0)); - setPoint(image, - info.c1.x * MM_TO_COORD(ui->lable_test->width()), - info.c1.y * MM_TO_COORD(ui->lable_test->height()), - qRgb(0, 0, 0)); + break; + case Radial: + setPoint(image, info.c0.x * MM_TO_COORD(ui->lable_test->width()), info.c0.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0, 0, 0)); + setPoint(image, info.c1.x * MM_TO_COORD(ui->lable_test->width()), info.c1.y * MM_TO_COORD(ui->lable_test->height()),qRgb(0, 0, 0)); points.push_back(QPoint(info.c0.x * MM_TO_COORD(ui->lable_test->width()), info.c0.y * MM_TO_COORD(ui->lable_test->height()))); points.push_back(QPoint(info.c1.x * MM_TO_COORD(ui->lable_test->width()), info.c1.y * MM_TO_COORD(ui->lable_test->height()))); - } - else if (info.gradient == Triangle || info.gradient == TriangleParametric) - { + break; + case Triangle: + case TriangleParametric: for (NSStructures::Point p : info.triangle) { - setPoint(image, - p.x * MM_TO_COORD(ui->lable_test->width()), - p.y * MM_TO_COORD(ui->lable_test->height()), - qRgb(0,0,0)); + setPoint(image, p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0,0,0)); points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()))); } - } - else if (info.gradient == CoonsPatch) - { + break; + case CoonsPatch: for (NSStructures::Point p : info.curve) { - setPoint(image, - p.x, - p.y, - qRgb(0,0,0)); + setPoint(image, p.x, p.y, qRgb(0,0,0)); points.push_back(QPoint(p.x, p.y)); } - } - else if (info.gradient == CoonsPatchParametric) - { + break; + case CoonsPatchParametric: for (NSStructures::Point p : info.curve) { - setPoint(image, - p.x * MM_TO_COORD(ui->lable_test->width()), - p.y * MM_TO_COORD(ui->lable_test->height()), - qRgb(0,0,0)); + setPoint(image, p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0,0,0)); points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->width()))); } - } - else if (info.gradient == TensorCoonsPatch) - { + break; + case TensorCoonsPatch: for (std::vector v : info.tensorcurve) { for (NSStructures::Point p : v) { - setPoint(image, - p.x, - p.y, - qRgb(0,0,0)); + setPoint(image, p.x, p.y, qRgb(0,0,0)); points.push_back(QPoint(p.x, p.y)); } } - } - else if (info.gradient == TensorCoonsPatchParametric) - { + break; + case TensorCoonsPatchParametric: for (std::vector v : info.tensorcurve) { for (NSStructures::Point p : v) { - setPoint(image, - p.x * MM_TO_COORD(ui->lable_test->width()), - p.y * MM_TO_COORD(ui->lable_test->height()), - qRgb(0,0,0)); + setPoint(image, p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0,0,0)); points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->width()))); } } + break; + default: + break; } ui->lable_test->SetPoints(points); } @@ -342,353 +320,152 @@ void MainWindow::on_label_test_clicked() void MainWindow::on_label_test_mouse_move() { - if (info.gradient == Linear) + listOfLines[info.offset + 2 * ui->lable_test->GetIndex() + 0]->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); + listOfLines[info.offset + 2 * ui->lable_test->GetIndex() + 1]->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + on_pushButton_clicked(); +} + +void MainWindow::on_point_set() +{ + //Linear + info.p0.x = listOfLines[LinearOffset + 0]->text().toInt(); + info.p0.y = listOfLines[LinearOffset + 1]->text().toInt(); + info.p1.x = listOfLines[LinearOffset + 2]->text().toInt(); + info.p1.y = listOfLines[LinearOffset + 3]->text().toInt(); + + //Radial + info.c0.x = listOfLines[RadialOffset + 0]->text().toInt(); + info.c0.y = listOfLines[RadialOffset + 1]->text().toInt(); + info.c1.x = listOfLines[RadialOffset + 2]->text().toInt(); + info.c1.y = listOfLines[RadialOffset + 3]->text().toInt(); + info.r0 = listOfLines[RadialOffset + 4]->text().toInt(); + info.r1 = listOfLines[RadialOffset + 5]->text().toInt(); + + //Triangle and TriangleParametric + for (size_t i = 0; i < info.triangle.size(); i++) { - switch (ui->lable_test->GetIndex()) - { - case 0: - ui->First_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 1: - ui->Second_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - default: - break; - } - } - else if (info.gradient == Radial) - { - switch (ui->lable_test->GetIndex()) - { - case 0: - ui->First_Center_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Center_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 1: - ui->Second_Center_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Center_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - default: - break; - } - } - else if (info.gradient == Triangle || info.gradient == TriangleParametric) - { - switch (ui->lable_test->GetIndex()) - { - case 0: - ui->First_Vertex_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Vertex_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 1: - ui->Second_Vertex_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Vertex_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 2: - ui->Third_Vertex_X_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Vertex_Y_Coordinate_Input->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - default: - break; - } - } - else if (info.gradient == CoonsPatch || info.gradient == CoonsPatchParametric) - { - switch (ui->lable_test->GetIndex()) - { - case 0: - ui->First_Vertex_X_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Vertex_Y_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 1: - ui->First_X_Coordinate_First_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_First_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 2: - ui->Second_X_Coordinate_First_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_First_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 3: - ui->Second_Vertex_X_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Vertex_Y_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 4: - ui->First_X_Coordinate_Second_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Second_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 5: - ui->Second_X_Coordinate_Second_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Second_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 6: - ui->Third_Vertex_X_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Vertex_Y_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 7: - ui->First_X_Coordinate_Third_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Third_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 8: - ui->Second_X_Coordinate_Third_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Third_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 9: - ui->Fourth_Vertex_X_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Vertex_Y_Coordinate_Input_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 10: - ui->First_X_Coordinate_Fourth_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Fourth_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 11: - ui->Second_X_Coordinate_Fourth_Edge->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Fourth_Edge->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - default: - break; - } - } - else if (info.gradient == TensorCoonsPatch || info.gradient == TensorCoonsPatchParametric) - { - switch (ui->lable_test->GetIndex()) - { - case 0: - ui->First_X_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 1: - ui->Second_X_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 2: - ui->Third_X_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Y_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); - break; - case 3: - ui->Fourth_X_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Y_Coordinate_First_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); - break; - case 4: - ui->First_X_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 5: - ui->Second_X_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 6: - ui->Third_X_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Y_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); - break; - case 7: - ui->Fourth_X_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Y_Coordinate_Second_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); - break; - case 8: - ui->First_X_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 9: - ui->Second_X_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 10: - ui->Third_X_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Y_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); - break; - case 11: - ui->Fourth_X_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Y_Coordinate_Third_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); - break; - case 12: - ui->First_X_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->First_Y_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 13: - ui->Second_X_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - ui->Second_Y_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); - break; - case 14: - ui->Third_X_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Third_Y_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); - case 15: - ui->Fourth_X_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->width()))); - ui->Fourth_Y_Coordinate_Fourth_Edge_3->setText(QString::number(ui->lable_test->GetMovePoint().x()/ MM_TO_COORD(ui->lable_test->height()))); - default: - break; - } + info.triangle[i].x = listOfLines[TriangleOffset + 2 * i + 0]->text().toInt(); + info.triangle[i].y = listOfLines[TriangleOffset + 2 * i + 1]->text().toInt(); } - on_pushButton_clicked(); + //CoonsPatch and CoonsPatchParametric + for (size_t i = 0; i < info.curve.size(); i++) + { + info.curve[i].x = listOfLines[CoonsPatchOffset + 2 * i + 0]->text().toInt(); + info.curve[i].y = listOfLines[CoonsPatchOffset + 2 * i + 1]->text().toInt(); + } + + //TensorCoonsPatch and TensorCoonsPatchParametric + for (size_t i = 0; i < info.tensorcurve.size(); i++) + { + for (size_t j = 0; j < info.tensorcurve[i].size(); j++) + { + info.tensorcurve[i][j].x = listOfLines[TensorCoonsPatchOffset + 2 * (i * info.tensorcurve[i].size() + j) + 0]->text().toInt(); + info.tensorcurve[i][j].y = listOfLines[TensorCoonsPatchOffset + 2 * (i * info.tensorcurve[i].size() + j) + 1]->text().toInt(); + } + } +} + +void MainWindow::on_parametrs_set() +{ + size_t offset = 0; + + //CoonsPatchParametric + for (size_t i = 0; i < info.curve_parametrs.size(); i++) + { + info.curve_parametrs[i] = listOfParametricLines[offset + i]->text().toFloat(); + } + offset += info.curve_parametrs.size(); + + //TriangleParametric + for (size_t i = 0; i < info.triangle_parametrs.size(); i++) + { + info.triangle_parametrs[i] = listOfParametricLines[offset + i]->text().toFloat(); + } + offset += info.triangle_parametrs.size(); + + //TensorCoonsPatchParametric + for (size_t i = 0; i < info.tensor_curve_parametrs.size(); i++) + { + offset += i; + for (size_t j = 0; j < info.tensor_curve_parametrs[i].size(); j++) + { + info.tensor_curve_parametrs[i][j] = listOfParametricLines[offset + i]->text().toFloat(); + } + } +} + +void MainWindow::on_continue_set() +{ + switch (info.gradient) + { + case Linear: + info.cont_f = listOfCheckBox[0]->isChecked(); + info.cont_b = listOfCheckBox[1]->isChecked(); + break; + case Radial: + info.cont_f = listOfCheckBox[2]->isChecked(); + info.cont_b = listOfCheckBox[3]->isChecked(); + break; + default: + break; + } } void MainWindow::on_pushButton_clicked() { - points = {{0, 0}, - {static_cast(ui->lable_test->width()), 0}, - {static_cast(ui->lable_test->width()), static_cast(ui->lable_test->height())}, - {0, static_cast(ui->lable_test->height())}}; + points = {NSStructures::Point(), + NSStructures::Point(ui->lable_test->width(), 0), + NSStructures::Point(ui->lable_test->width(), ui->lable_test->height()), + NSStructures::Point(0, ui->lable_test->height())}; + on_point_set(); + on_parametrs_set(); + on_continue_set(); - if (info.gradient == Linear) + switch (info.gradient) { - info.p0.x = ui->First_X_Coordinate_Input->text().toInt(); - info.p0.y = ui->First_Y_Coordinate_Input->text().toInt(); - info.p1.x = ui->Second_X_Coordinate_Input->text().toInt(); - info.p1.y = ui->Second_Y_Coordinate_Input->text().toInt(); - info.cont_b = ui->Continue_Shading_Backward->isChecked(); - info.cont_f = ui->Continue_Shading_Forward->isChecked(); + case Linear: info.ginfo = NSStructures::GInfoConstructor::get_linear(info.p0, info.p1, 0, 1, info.cont_b, info.cont_f); - } - else if (info.gradient == Radial) - { - info.c0.x = ui->First_Center_X_Coordinate_Input->text().toInt(); - info.c0.y = ui->First_Center_Y_Coordinate_Input->text().toInt(); - info.c1.x = ui->Second_Center_X_Coordinate_Input->text().toInt(); - info.c1.y = ui->Second_Center_Y_Coordinate_Input->text().toInt(); - info.r0 = ui->First_Radius_Input->text().toInt(); - info.r1 = ui->Second_Radius_Input->text().toInt(); - info.cont_b = ui->Continue_Shading_Backward_2->isChecked(); - info.cont_f = ui->Continue_Shading_Forward_2->isChecked(); + break; + case Radial: info.ginfo = NSStructures::GInfoConstructor::get_radial(info.c0, info.c1, info.r0, info.r1, 0, 1, info.cont_b, info.cont_f); - } - else if (info.gradient == Triangle || info.gradient == TriangleParametric) - { - info.triangle[0].x = ui->First_Vertex_X_Coordinate_Input->text().toInt(); - info.triangle[0].y = ui->First_Vertex_Y_Coordinate_Input->text().toInt(); - info.triangle[1].x = ui->Second_Vertex_X_Coordinate_Input->text().toInt(); - info.triangle[1].y = ui->Second_Vertex_Y_Coordinate_Input->text().toInt(); - info.triangle[2].x = ui->Third_Vertex_X_Coordinate_Input->text().toInt(); - info.triangle[2].y = ui->Third_Vertex_Y_Coordinate_Input->text().toInt(); - - if (info.gradient == TriangleParametric) - { - info.triangle_parametrs[0] = ui->First_Vertex_Parametr_Input_4->text().toFloat(); - info.triangle_parametrs[1] = ui->Second_Vertex_Parametr_Input_4->text().toFloat(); - info.triangle_parametrs[2] = ui->Third_Vertex_Parametr_Input_4->text().toFloat(); - } - info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, - QColor2rgba(true), - info.triangle_parametrs, - info.gradient == TriangleParametric); + break; + case Triangle: + case TriangleParametric: + info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, QColor2rgba(true), info.triangle_parametrs, info.gradient == TriangleParametric); points = {}; for (auto p : info.triangle) { points.push_back({p.x, p.y}); } - } - else if (info.gradient == CoonsPatch || info.gradient == CoonsPatchParametric) - { - info.curve[0].x = ui->First_Vertex_X_Coordinate_Input_3->text().toInt(); - info.curve[0].y = ui->First_Vertex_Y_Coordinate_Input_3->text().toInt(); - info.curve[1].x = ui->First_X_Coordinate_First_Edge->text().toInt(); - info.curve[1].y = ui->First_Y_Coordinate_First_Edge->text().toInt(); - info.curve[2].x = ui->Second_X_Coordinate_First_Edge->text().toInt(); - info.curve[2].y = ui->Second_Y_Coordinate_First_Edge->text().toInt(); - info.curve[3].x = ui->Second_Vertex_X_Coordinate_Input_3->text().toInt(); - info.curve[3].y = ui->Second_Vertex_Y_Coordinate_Input_3->text().toInt(); - info.curve[4].x = ui->First_X_Coordinate_Second_Edge->text().toInt(); - info.curve[4].y = ui->First_Y_Coordinate_Second_Edge->text().toInt(); - info.curve[5].x = ui->Second_X_Coordinate_Second_Edge->text().toInt(); - info.curve[5].y = ui->Second_Y_Coordinate_Second_Edge->text().toInt(); - info.curve[6].x = ui->Third_Vertex_X_Coordinate_Input_3->text().toInt(); - info.curve[6].y = ui->Third_Vertex_Y_Coordinate_Input_3->text().toInt(); - info.curve[7].x = ui->First_X_Coordinate_Third_Edge->text().toInt(); - info.curve[7].y = ui->First_Y_Coordinate_Third_Edge->text().toInt(); - info.curve[8].x = ui->Second_X_Coordinate_Third_Edge->text().toInt(); - info.curve[8].y = ui->Second_Y_Coordinate_Third_Edge->text().toInt(); - info.curve[9].x = ui->Fourth_Vertex_X_Coordinate_Input_3->text().toInt(); - info.curve[9].y = ui->Fourth_Vertex_Y_Coordinate_Input_3->text().toInt(); - info.curve[10].x = ui->First_X_Coordinate_Fourth_Edge->text().toInt(); - info.curve[10].y = ui->First_Y_Coordinate_Fourth_Edge->text().toInt(); - info.curve[11].x = ui->Second_X_Coordinate_Fourth_Edge->text().toInt(); - info.curve[11].y = ui->Second_Y_Coordinate_Fourth_Edge->text().toInt(); - - if (info.gradient == CoonsPatchParametric) + break; + case CoonsPatch: + for(int i = 0; i < info.curve.size(); i++) { - info.curve_parametrs[0] = ui->First_Vertex_Parametr_Input_2->text().toFloat(); - info.curve_parametrs[1] = ui->Second_Vertex_Parametr_Input_2->text().toFloat(); - info.curve_parametrs[2] = ui->Third_Vertex_Parametr_Input_2->text().toFloat(); - info.curve_parametrs[3] = ui->Fourth_Vertex_Parametr_Input_2->text().toFloat(); + info.curve[i].x *= MM_TO_COORD(ui->lable_test->width()); + info.curve[i].y *= MM_TO_COORD(ui->lable_test->height()); } - - if (info.gradient == CoonsPatch) + info.ginfo = NSStructures::GInfoConstructor::get_curve(info.curve, info.curve_parametrs, QColor2rgba(false), false); + break; + case CoonsPatchParametric: + info.ginfo = NSStructures::GInfoConstructor::get_curve(info.curve, info.curve_parametrs, QColor2rgba(false),true); + break; + case TensorCoonsPatch: + for (int i = 0; i < info.tensorcurve.size(); i++) { - for(int j = 0; j < 12; j++) + for (int j = 0; j < info.tensorcurve[i].size(); j++) { - info.curve[j].x *= MM_TO_COORD(ui->lable_test->width()); - info.curve[j].y *= MM_TO_COORD(ui->lable_test->height()); + info.tensorcurve[i][j].x *= MM_TO_COORD(ui->lable_test->width()); + info.tensorcurve[i][j].y *= MM_TO_COORD(ui->lable_test->height()); } } - info.ginfo = NSStructures::GInfoConstructor::get_curve( - info.curve, - info.curve_parametrs, - QColor2rgba(false), - info.gradient == CoonsPatchParametric - ); - } - else if (info.gradient == TensorCoonsPatch || info.gradient == TensorCoonsPatchParametric) - { - info.tensorcurve[0][0].x = ui->First_X_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][0].y = ui->First_Y_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][1].x = ui->Second_X_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][1].y = ui->Second_Y_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][2].x = ui->Third_X_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][2].y = ui->Third_Y_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][3].x = ui->Fourth_X_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[0][3].y = ui->Fourth_Y_Coordinate_First_Edge_3->text().toInt(); - info.tensorcurve[1][0].x = ui->First_X_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][0].y = ui->First_Y_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][1].x = ui->Second_X_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][1].y = ui->Second_Y_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][2].x = ui->Third_X_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][2].y = ui->Third_Y_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][3].x = ui->Fourth_X_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[1][3].y = ui->Fourth_Y_Coordinate_Second_Edge_3->text().toInt(); - info.tensorcurve[2][0].x = ui->First_X_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][0].y = ui->First_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][1].x = ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][1].y = ui->Second_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][2].x = ui->Third_X_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][2].y = ui->Third_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][3].x = ui->Fourth_X_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[2][3].y = ui->Fourth_Y_Coordinate_Third_Edge_3->text().toInt(); - info.tensorcurve[3][0].x = ui->First_X_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][0].y = ui->First_Y_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][1].x = ui->Second_X_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][1].y = ui->Second_Y_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][2].x = ui->Third_X_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][2].y = ui->Third_Y_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][3].x = ui->Fourth_X_Coordinate_Fourth_Edge_3->text().toInt(); - info.tensorcurve[3][3].y = ui->Fourth_Y_Coordinate_Fourth_Edge_3->text().toInt(); - - if (info.gradient == TensorCoonsPatchParametric) - { - info.tensor_curve_parametrs[0][0] = ui->First_Vertex_Parametr_Input_3->text().toFloat(); - info.tensor_curve_parametrs[0][1] = ui->Second_Vertex_Parametr_Input_3->text().toFloat(); - info.tensor_curve_parametrs[1][0] = ui->Third_Vertex_Parametr_Input_3->text().toFloat(); - info.tensor_curve_parametrs[1][1] = ui->Fourth_Vertex_Parametr_Input_3->text().toFloat(); - } - - if (info.gradient == TensorCoonsPatch) - { - for (int i = 0; i < 4; i++) - { - for (int j = 0; j < 4; j++) - { - info.tensorcurve[i][j].x *= MM_TO_COORD(ui->lable_test->width()); - info.tensorcurve[i][j].y *= MM_TO_COORD(ui->lable_test->height()); - } - } - } - - info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve( - info.tensorcurve, - info.tensor_curve_parametrs, - QColor2rgbaMatrix(), - info.gradient == TensorCoonsPatchParametric - ); + info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve(info.tensorcurve, info.tensor_curve_parametrs, QColor2rgbaMatrix(), false); + break; + case TensorCoonsPatchParametric: + info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve(info.tensorcurve, info.tensor_curve_parametrs, QColor2rgbaMatrix(), true); + break; + default: + break; } if (ui->Rainbow_Colorspace_Radio_Button->isChecked()) diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index ca548e2ae1..5edf24dbea 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -2,10 +2,13 @@ #define MAINWINDOW_H #include +#include #include #include #include +#include #include +#include #include #include #include @@ -213,56 +216,33 @@ typedef enum CoonsPatch, CoonsPatchParametric, TensorCoonsPatch, - TensorCoonsPatchParametric, - Functional + TensorCoonsPatchParametric } GradientType; -struct Point +typedef enum { - Point(double _x = 0, double _y = 0) : x(_x), y(_y) - { - } - double x, y; -}; - -struct Color -{ - uint r, g, b; - Color() - { - r = b = g = 0; - } - Color(uint rgb) - { - b = rgb % 0x100; - g = (rgb / 0x100) % 0x100; - r = rgb / 0x100 / 0x100; - } - uint get_color() - { - return b + g * 0x100 + r * 0x10000; - } -}; + LinearOffset = 68, + RadialOffset = 62, + TriangleOffset = 56, + CoonsPatchOffset = 32, + TensorCoonsPatchOffset = 0 +} GradientOffse; struct Info { - GradientType gradient = Linear; + GradientType gradient; + GradientOffse offset; float r0, r1; NSStructures::Point c0, c1; NSStructures::Point p0, p1; bool cont_b, cont_f; - std::vector triangle = {{100, 100}, {300, 200}, {200, 350}}; - std::vector curve = {{100, 300}, {50, 250}, {150, 150}, {100, 100}, - {150, 50}, {250, 150}, {300, 100}, {250, 150}, - {350, 250}, {300, 300}, {250, 350}, {150,250}}; - std::vector> tensorcurve = {{{100, 300}, {150, 250}, {50, 150}, {100,100}}, - {{150, 250}, {170, 230}, {170, 170}, {50, 150}}, - {{350, 250}, {230, 230}, {230, 170}, {150, 250}}, - {{300, 300}, {250, 250}, {350, 150}, {300, 100}}}; - std::vector triangle_parametrs = {0.f, 0.5f, 1.f}; - std::vector curve_parametrs = {0.f, 0.3f, 1.f, 0.6f}; - std::vector> tensor_curve_parametrs = {{0.f, 0.3f}, {1.f, 0.6f}}; + std::vector triangle; + std::vector curve; + std::vector> tensorcurve; + std::vector triangle_parametrs; + std::vector curve_parametrs; + std::vector> tensor_curve_parametrs; NSStructures::GradientInfo ginfo; int gradient_type; @@ -275,15 +255,23 @@ struct Info p = {0.0, 0.2, 0.4, 0.6, 0.8, 1}; n_colors = 6; ginfo.shading.shading_type = NSStructures::ShadingInfo::Parametric; + triangle.resize(3); + curve.resize(12); + tensorcurve.resize(4); + for (int i = 0; i < tensorcurve.size(); i++) + { + tensorcurve[i].resize(4); + } + triangle_parametrs.resize(3); + curve_parametrs.resize(4); + tensor_curve_parametrs.resize(2); + for (int i = 0; i < tensor_curve_parametrs.size(); i++) + { + tensor_curve_parametrs[i].resize(2); + } - r0 = 0; - r1 = 100; - c0 = {200, 200}; - c1 = {200, 200}; - p0 = {0, 0}; - p1 = {400, 400}; cont_b = cont_f = false; - }; + } ~Info() { } @@ -302,7 +290,7 @@ public: void setPoints(QImage *image); QImage img; QLabel *lable; - std::vector points; + std::vector points; Info info; private slots: @@ -311,6 +299,12 @@ private slots: void on_label_test_mouse_move(); + void on_point_set(); + + void on_parametrs_set(); + + void on_continue_set(); + void on_actionLinear_Gradient_triggered(); void on_actionRadial_Gradient_triggered(); @@ -330,6 +324,10 @@ private slots: void on_actionTensor_Coons_Patch_Parametric_triggered(); private: + QList listOfLines; + QList listOfParametricLines; + QList listOfCheckBox; + QListlistOfColorLabels; Ui::MainWindow *ui; }; #endif // MAINWINDOW_H diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index ae202b3f9d..37680dfdf7 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -26,6 +26,9 @@ 500 + + background-color : white; + @@ -52,7 +55,7 @@ - 4 + 0 @@ -80,22 +83,6 @@ X Coordinate, First Point - - - - 10 - 50 - 113 - 28 - - - - 10 - - - 10 - - @@ -109,22 +96,6 @@ Y Coordinate, First Point - - - - 10 - 100 - 113 - 28 - - - - 10 - - - 10 - - @@ -138,7 +109,52 @@ X Coordinate, Second Point - + + + + 240 + 80 + 179 + 20 + + + + Y Coordinate, Second Point + + + + + + 10 + 50 + 113 + 28 + + + + 10 + + + 10 + + + + + + 10 + 100 + 113 + 28 + + + + 10 + + + 10 + + + 240 @@ -154,20 +170,7 @@ 90 - - - - 240 - 80 - 179 - 20 - - - - Y Coordinate, Second Point - - - + 240 @@ -196,7 +199,7 @@ Continue Shading - + 20 @@ -208,8 +211,11 @@ Forward + + false + - + 20 @@ -237,7 +243,7 @@ Continue Shading - + 20 @@ -250,7 +256,7 @@ Forward - + 20 @@ -289,22 +295,6 @@ X Coordinate, First Center - - - - 20 - 50 - 113 - 28 - - - - 50 - - - 50 - - @@ -318,22 +308,6 @@ Y Coordinate, First Center - - - - 20 - 100 - 113 - 28 - - - - 50 - - - 50 - - @@ -347,7 +321,52 @@ X Coordinate, Second Center - + + + + 230 + 80 + 189 + 20 + + + + Y Coordinate, Second Center + + + + + + 20 + 50 + 113 + 28 + + + + 50 + + + 50 + + + + + + 20 + 100 + 113 + 28 + + + + 50 + + + 50 + + + 230 @@ -363,20 +382,7 @@ 50 - - - - 230 - 80 - 189 - 20 - - - - Y Coordinate, Second Center - - - + 230 @@ -431,7 +437,7 @@ Second Radius - + 20 @@ -447,7 +453,7 @@ 10 - + 230 @@ -491,22 +497,6 @@ X Coordinate, First Vertex - - - - 10 - 50 - 113 - 28 - - - - 50 - - - 50 - - @@ -520,22 +510,6 @@ Y Coordinate, First Vertex - - - - 10 - 100 - 113 - 28 - - - - 20 - - - 20 - - @@ -549,22 +523,6 @@ X Coordinate, Second Vertex - - - - 200 - 50 - 113 - 28 - - - - 20 - - - 20 - - @@ -578,22 +536,6 @@ Y Coordinate, Second Vertex - - - - 200 - 100 - 113 - 28 - - - - 70 - - - 70 - - @@ -607,7 +549,84 @@ X Coordinate, Third Vertex - + + + + 410 + 80 + 173 + 20 + + + + Y Coordinate, Third Vertex + + + + + + 10 + 50 + 113 + 28 + + + + 50 + + + 50 + + + + + + 10 + 100 + 113 + 28 + + + + 20 + + + 20 + + + + + + 200 + 50 + 113 + 28 + + + + 20 + + + 20 + + + + + + 200 + 100 + 113 + 28 + + + + 70 + + + 70 + + + 410 @@ -623,20 +642,7 @@ 80 - - - - 410 - 80 - 173 - 20 - - - - Y Coordinate, Third Vertex - - - + 410 @@ -655,32 +661,32 @@ - + - 0 + 20 0 - 590 + 130 140 - Set Coordinates Of Square Vertices + First Vertex 10 30 - 118 + 87 20 - First X Coordinate + X Coordinate - + 10 @@ -701,15 +707,15 @@ 10 80 - 117 + 86 20 - First Y Coordinate + Y Coordinate - + 10 @@ -725,708 +731,734 @@ 60 - - - - 140 - 30 - 140 - 20 - - - - Second X Coordinate - - - - - - 140 - 50 - 113 - 28 - - - - 20 - - - 20 - - - - - - 140 - 80 - 139 - 20 - - - - Second Y Coordinate - - - - - - 140 - 100 - 113 - 28 - - - - 20 - - - 20 - - - - - - 300 - 30 - 125 - 20 - - - - Third X Coordinate - - - - - - 300 - 50 - 113 - 28 - - - - 60 - - - 60 - - - - - - 300 - 80 - 124 - 20 - - - - Third Y Coordinate - - - - - - 300 - 100 - 113 - 28 - - - - 20 - - - 20 - - - - - - 450 - 30 - 133 - 20 - - - - Fourth X Coordinate - - - - - - 450 - 50 - 113 - 28 - - - - 60 - - - 60 - - - - - - 450 - 80 - 128 - 20 - - - - Fourth Y Coorfinate - - - - - - 450 - 100 - 113 - 28 - - - - 60 - - - 60 - - - + - 0 - 140 - 590 - 320 + 200 + 0 + 370 + 140 - Set Curvature Coordinates Of Square Edges + First Edge - + 10 30 - 280 - 140 + 118 + 20 - - First Edge + + First X Coordinate - - - - 10 - 30 - 118 - 20 - - - - First X Coordinate - - - - - - 10 - 50 - 113 - 28 - - - - 10 - - - 10 - - - - - - 140 - 30 - 140 - 20 - - - - Second X Coordinate - - - - - - 140 - 50 - 113 - 28 - - - - 30 - - - 30 - - - - - - 10 - 80 - 117 - 20 - - - - First Y Coordinate - - - - - - 10 - 100 - 113 - 28 - - - - 50 - - - 50 - - - - - - 140 - 80 - 139 - 20 - - - - Second Y Coordinate - - - - - - 140 - 100 - 113 - 28 - - - - 30 - - - 30 - - - + - 300 + 210 30 - 280 - 140 + 140 + 20 - - Second Edge + + Second X Coordinate - - - - 10 - 30 - 118 - 20 - - - - First X Coordinate - - - - - - 10 - 50 - 113 - 28 - - - - 30 - - - 30 - - - - - - 140 - 30 - 140 - 20 - - - - Second X Coordinate - - - - - - 140 - 50 - 113 - 28 - - - - 50 - - - 50 - - - - - - 10 - 80 - 117 - 20 - - - - First Y Coordinate - - - - - - 10 - 100 - 113 - 28 - - - - 10 - - - 10 - - - - - - 140 - 80 - 140 - 20 - - - - Second Y Coordinate - - - - - - 140 - 100 - 113 - 28 - - - - 30 - - - 30 - - - + 10 - 170 - 280 - 140 + 80 + 117 + 20 - - Third Edge + + First Y Coordinate - - - - 10 - 30 - 118 - 20 - - - - First X Coordinate - - - - - - 10 - 50 - 113 - 28 - - - - 50 - - - 50 - - - - - - 140 - 30 - 140 - 20 - - - - Second X Coordinate - - - - - - 140 - 50 - 113 - 28 - - - - 70 - - - 70 - - - - - - 10 - 80 - 117 - 20 - - - - First Y Coordinate - - - - - - 10 - 100 - 113 - 28 - - - - 30 - - - 30 - - - - - - 140 - 80 - 140 - 20 - - - - Second Y Coordinate - - - - - - 140 - 100 - 113 - 28 - - - - 50 - - - 50 - - - + - 300 - 170 - 280 - 140 + 210 + 80 + 139 + 20 - - Fourth Edge + + Second Y Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 10 + + + 10 + + + + + + 10 + 100 + 113 + 28 + + + + 50 + + + 50 + + + + + + 210 + 50 + 113 + 28 + + + + 30 + + + 30 + + + + + + 210 + 100 + 113 + 28 + + + + 30 + + + 30 + + + + + + + 20 + 140 + 130 + 140 + + + + Second Vertex + + + + + 10 + 30 + 87 + 20 + + + + X Coordinate + + + + + + 10 + 80 + 86 + 20 + + + + Y Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 20 + + + 20 + + + + + + 10 + 100 + 113 + 28 + + + + 20 + + + 20 + + + + + + + 200 + 140 + 370 + 140 + + + + Second Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 210 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 210 + 80 + 140 + 20 + + + + Second Y Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 30 + + + 30 + + + + + + 10 + 100 + 113 + 28 + + + + 10 + + + 10 + + + + + + 210 + 50 + 113 + 28 + + + + 50 + + + 50 + + + + + + 210 + 100 + 113 + 28 + + + + 30 + + + 30 + + + + + + + 20 + 280 + 130 + 140 + + + + Third Vertex + + + + + 10 + 30 + 87 + 20 + + + + X Coordinate + + + + + + 10 + 80 + 86 + 20 + + + + Y Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 60 + + + 60 + + + + + + 10 + 100 + 113 + 28 + + + + 20 + + + 20 + + + + + + + 200 + 280 + 370 + 140 + + + + Third Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 220 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 220 + 80 + 140 + 20 + + + + Second Y Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 50 + + + 50 + + + + + + 10 + 100 + 113 + 28 + + + + 30 + + + 30 + + + + + + 220 + 50 + 113 + 28 + + + + 70 + + + 70 + + + + + + 220 + 100 + 113 + 28 + + + + 50 + + + 50 + + + + + + + 20 + 420 + 130 + 140 + + + + Fourth Vertex + + + + + 10 + 30 + 87 + 20 + + + + X Coordinate + + + + + + 10 + 80 + 86 + 20 + + + + Y Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 60 + + + 60 + + + + + + 10 + 100 + 113 + 28 + + + + 60 + + + 60 + + + + + + + 200 + 420 + 370 + 140 + + + + Fourth Edge + + + + + 10 + 30 + 118 + 20 + + + + First X Coordinate + + + + + + 220 + 30 + 140 + 20 + + + + Second X Coordinate + + + + + + 10 + 80 + 117 + 20 + + + + First Y Coordinate + + + + + + 220 + 80 + 140 + 20 + + + + Second Y Coordinate + + + + + + 10 + 50 + 113 + 28 + + + + 50 + + + 50 + + + + + + 10 + 100 + 113 + 28 + + + + 70 + + + 70 + + + + + + 220 + 50 + 113 + 28 + + + + 30 + + + 30 + + + + + + 220 + 100 + 113 + 28 + + + + 50 + + + 50 - - - - 10 - 30 - 118 - 20 - - - - First X Coordinate - - - - - - 10 - 50 - 113 - 28 - - - - 50 - - - 50 - - - - - - 140 - 30 - 140 - 20 - - - - Second X Coordinate - - - - - - 140 - 50 - 113 - 28 - - - - 30 - - - 30 - - - - - - 10 - 80 - 117 - 20 - - - - First Y Coordinate - - - - - - 10 - 100 - 113 - 28 - - - - 70 - - - 70 - - - - - - 140 - 80 - 140 - 20 - - - - Second Y Coordinate - - - - - - 140 - 100 - 113 - 28 - - - - 50 - - - 50 - - @@ -1456,22 +1488,6 @@ First X Coordinate - - - - 10 - 50 - 113 - 28 - - - - 20 - - - 20 - - @@ -1485,22 +1501,6 @@ First Y Coordinate - - - - 10 - 100 - 113 - 28 - - - - 60 - - - 60 - - @@ -1514,22 +1514,6 @@ Second X Coordinate - - - - 140 - 50 - 113 - 28 - - - - 30 - - - 30 - - @@ -1543,22 +1527,6 @@ Second Y Coordinate - - - - 140 - 100 - 113 - 28 - - - - 50 - - - 50 - - @@ -1572,22 +1540,6 @@ Third X Coordinate - - - - 300 - 50 - 113 - 28 - - - - 10 - - - 10 - - @@ -1601,22 +1553,6 @@ Third Y Coordinate - - - - 300 - 100 - 113 - 28 - - - - 30 - - - 30 - - @@ -1630,7 +1566,116 @@ Fourth X Coordinate - + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 10 + 50 + 113 + 28 + + + + 20 + + + 20 + + + + + + 10 + 100 + 113 + 28 + + + + 60 + + + 60 + + + + + + 140 + 50 + 113 + 28 + + + + 30 + + + 30 + + + + + + 140 + 100 + 113 + 28 + + + + 50 + + + 50 + + + + + + 300 + 50 + 113 + 28 + + + + 10 + + + 10 + + + + + + 300 + 100 + 113 + 28 + + + + 30 + + + 30 + + + 450 @@ -1646,20 +1691,7 @@ 20 - - - - 450 - 80 - 128 - 20 - - - - Fourth Y Coorfinate - - - + 450 @@ -1701,22 +1733,6 @@ First X Coordinate - - - - 10 - 50 - 113 - 28 - - - - 30 - - - 30 - - @@ -1730,22 +1746,6 @@ First Y Coordinate - - - - 10 - 100 - 113 - 28 - - - - 50 - - - 50 - - @@ -1759,22 +1759,6 @@ Second X Coordinate - - - - 140 - 50 - 113 - 28 - - - - 34 - - - 34 - - @@ -1788,22 +1772,6 @@ Second Y Coordinate - - - - 140 - 100 - 113 - 28 - - - - 46 - - - 46 - - @@ -1817,22 +1785,6 @@ Third X Coordinate - - - - 300 - 50 - 113 - 28 - - - - 34 - - - 34 - - @@ -1846,22 +1798,6 @@ Third Y Coordinate - - - - 300 - 100 - 113 - 28 - - - - 34 - - - 34 - - @@ -1875,7 +1811,116 @@ Fourth X Coordinate - + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 10 + 50 + 113 + 28 + + + + 30 + + + 30 + + + + + + 10 + 100 + 113 + 28 + + + + 50 + + + 50 + + + + + + 140 + 50 + 113 + 28 + + + + 34 + + + 34 + + + + + + 140 + 100 + 113 + 28 + + + + 46 + + + 46 + + + + + + 300 + 50 + 113 + 28 + + + + 34 + + + 34 + + + + + + 300 + 100 + 113 + 28 + + + + 34 + + + 34 + + + 450 @@ -1891,20 +1936,7 @@ 10 - - - - 450 - 80 - 128 - 20 - - - - Fourth Y Coorfinate - - - + 450 @@ -1946,22 +1978,6 @@ First X Coordinate - - - - 10 - 50 - 113 - 28 - - - - 70 - - - 70 - - @@ -1975,22 +1991,6 @@ First Y Coordinate - - - - 10 - 100 - 113 - 28 - - - - 50 - - - 50 - - @@ -2004,22 +2004,6 @@ Second X Coordinate - - - - 140 - 50 - 113 - 28 - - - - 46 - - - 46 - - @@ -2033,22 +2017,6 @@ Second Y Coordinate - - - - 140 - 100 - 113 - 28 - - - - 46 - - - 46 - - @@ -2062,22 +2030,6 @@ Third X Coordinate - - - - 300 - 50 - 113 - 28 - - - - 46 - - - 46 - - @@ -2091,22 +2043,6 @@ Third Y Coordinate - - - - 300 - 100 - 113 - 28 - - - - 34 - - - 34 - - @@ -2120,7 +2056,116 @@ Fourth X Coordinate - + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 10 + 50 + 113 + 28 + + + + 70 + + + 70 + + + + + + 10 + 100 + 113 + 28 + + + + 50 + + + 50 + + + + + + 140 + 50 + 113 + 28 + + + + 46 + + + 46 + + + + + + 140 + 100 + 113 + 28 + + + + 46 + + + 46 + + + + + + 300 + 50 + 113 + 28 + + + + 46 + + + 46 + + + + + + 300 + 100 + 113 + 28 + + + + 34 + + + 34 + + + 450 @@ -2136,20 +2181,7 @@ 30 - - - - 450 - 80 - 128 - 20 - - - - Fourth Y Coorfinate - - - + 450 @@ -2191,22 +2223,6 @@ First X Coordinate - - - - 10 - 50 - 113 - 28 - - - - 60 - - - 60 - - @@ -2220,22 +2236,6 @@ First Y Coordinate - - - - 10 - 100 - 113 - 28 - - - - 60 - - - 60 - - @@ -2249,22 +2249,6 @@ Second X Coordinate - - - - 140 - 50 - 113 - 28 - - - - 50 - - - 50 - - @@ -2278,22 +2262,6 @@ Second Y Coordinate - - - - 140 - 100 - 113 - 28 - - - - 50 - - - 50 - - @@ -2307,22 +2275,6 @@ Third X Coordinate - - - - 300 - 50 - 113 - 28 - - - - 70 - - - 70 - - @@ -2336,22 +2288,6 @@ Third Y Coordinate - - - - 300 - 100 - 113 - 28 - - - - 30 - - - 30 - - @@ -2365,7 +2301,116 @@ Fourth X Coordinate - + + + + 450 + 80 + 128 + 20 + + + + Fourth Y Coorfinate + + + + + + 10 + 50 + 113 + 28 + + + + 60 + + + 60 + + + + + + 10 + 100 + 113 + 28 + + + + 60 + + + 60 + + + + + + 140 + 50 + 113 + 28 + + + + 50 + + + 50 + + + + + + 140 + 100 + 113 + 28 + + + + 50 + + + 50 + + + + + + 300 + 50 + 113 + 28 + + + + 70 + + + 70 + + + + + + 300 + 100 + 113 + 28 + + + + 30 + + + 30 + + + 450 @@ -2381,20 +2426,7 @@ 60 - - - - 450 - 80 - 128 - 20 - - - - Fourth Y Coorfinate - - - + 450 @@ -2436,7 +2468,7 @@ - 1 + 0 @@ -2463,6 +2495,9 @@ Rainbow + + true + @@ -2584,7 +2619,7 @@ - 3 + 5 @@ -2767,22 +2802,6 @@ First Vertex Parametr - - - - 10 - 50 - 113 - 28 - - - - 0 - - - 0 - - @@ -2796,22 +2815,6 @@ Second Vertex Parametr - - - - 270 - 50 - 113 - 28 - - - - 0.5 - - - 0.5 - - @@ -2825,7 +2828,39 @@ Third Vertex Parametr - + + + + 10 + 50 + 113 + 28 + + + + 0 + + + 0 + + + + + + 270 + 50 + 113 + 28 + + + + 0.5 + + + 0.5 + + + 10 @@ -3001,22 +3036,6 @@ First Vertex Parametr - - - - 10 - 50 - 113 - 28 - - - - 0 - - - 0 - - @@ -3030,22 +3049,6 @@ Second Vertex Parametr - - - - 270 - 50 - 113 - 28 - - - - 0.3 - - - 0.3 - - @@ -3059,22 +3062,6 @@ Third Vertex Parametr - - - - 10 - 100 - 113 - 28 - - - - 0.6 - - - 0.6 - - @@ -3088,7 +3075,55 @@ Fourth Vertex Parametr - + + + + 10 + 50 + 113 + 28 + + + + 0 + + + 0 + + + + + + 270 + 50 + 113 + 28 + + + + 0.3 + + + 0.3 + + + + + + 10 + 100 + 113 + 28 + + + + 1 + + + 1 + + + 270 @@ -3098,7 +3133,7 @@ - 1 + 0.6 1 @@ -3212,22 +3247,6 @@ First Vertex Parametr - - - - 10 - 50 - 113 - 28 - - - - 0 - - - 0 - - @@ -3241,22 +3260,6 @@ Second Vertex Parametr - - - - 270 - 50 - 113 - 28 - - - - 0.3 - - - 0.3 - - @@ -3270,22 +3273,6 @@ Third Vertex Parametr - - - - 10 - 100 - 113 - 28 - - - - 0.6 - - - 0.6 - - @@ -3299,10 +3286,42 @@ Fourth Vertex Parametr - + + + + 10 + 50 + 113 + 28 + + + + 0 + + + 0 + + + 270 + 50 + 113 + 28 + + + + 0.3 + + + 0.3 + + + + + + 10 100 113 28 @@ -3315,6 +3334,22 @@ 1 + + + + 270 + 100 + 113 + 28 + + + + 0.6 + + + 0.6 + + From 56a08867db5eb723796111157cbe1f149ac0942d Mon Sep 17 00:00:00 2001 From: K1rillProkhorov Date: Fri, 31 May 2024 21:45:44 +0300 Subject: [PATCH 13/13] refactoring --- .../gradient/Gradient/mainwindow.cpp | 247 ++++++++---------- .../gradient/Gradient/mainwindow.h | 154 ++++------- .../gradient/Gradient/mainwindow.ui | 4 +- 3 files changed, 171 insertions(+), 234 deletions(-) diff --git a/Test/Applications/gradient/Gradient/mainwindow.cpp b/Test/Applications/gradient/Gradient/mainwindow.cpp index 1a3473a151..3410e7aea9 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.cpp +++ b/Test/Applications/gradient/Gradient/mainwindow.cpp @@ -4,16 +4,16 @@ #include "../../../../DesktopEditor/graphics/pro/Graphics.h" #include "../../../../PdfFile/PdfFile.h" -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), img("test.png"), lable(new QLabel) +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), img("test.png") { ui->setupUi(this); - listOfLines = ui->centralwidget->findChildren(); - listOfParametricLines = ui->centralwidget->findChildren(); - listOfCheckBox = ui->centralwidget->findChildren(); - listOfColorLabels = ui->centralwidget->findChildren(); + listOfLines = ui->centralwidget->findChildren(); + listOfCheckBox = ui->centralwidget->findChildren(); + listOfColorLabels = ui->centralwidget->findChildren(); + listOfParametricLines = ui->centralwidget->findChildren(); - connect(ui->lable_test, SIGNAL(mousePressed()), this, SLOT(on_label_test_clicked())); + connect(ui->label_test, SIGNAL(mousePressed()), this, SLOT(on_label_test_clicked())); on_actionLinear_Gradient_triggered(); } @@ -62,10 +62,10 @@ QImage GenerateImg(std::vector &points, Info &info, const i NSStructures::GradientInfo ginfo = info.ginfo; ginfo.shading.f_type = NSStructures::ShadingInfo::UseNew; pRasterRenderer->put_BrushGradInfo(ginfo); - auto a = info.c; - auto b = info.p; - LONG *c = a.data(); - double *p = b.data(); + auto a = info.c; + auto b = info.p; + LONG *c = a.data(); + double *p = b.data(); pRasterRenderer->put_BrushType(info.gradient_type); pRasterRenderer->put_BrushGradientColors(c, p, info.n_colors); pRasterRenderer->PathCommandStart(); @@ -87,116 +87,116 @@ QImage GenerateImg(std::vector &points, Info &info, const i return img; } -void MainWindow::InitializeColors(bool Triangle) +void MainWindow::initializeColors(bool Triangle) { - ui->label_80->SetColor(QColor(Qt::red)); - ui->label_81->SetColor(QColor(Qt::green)); - ui->label_114->SetColor(QColor(Qt::blue)); + listOfColorLabels[0]->setColor(QColor(Qt::red)); + listOfColorLabels[1]->setColor(QColor(Qt::green)); + listOfColorLabels[2]->setColor(QColor(Qt::blue)); if (!Triangle) { - ui->label_115->SetColor(QColor(Qt::yellow)); + listOfColorLabels[3]->setColor(QColor(Qt::yellow)); } } void MainWindow::on_actionLinear_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(0); + ui->stackedWidget_1->setCurrentIndex(0); ui->stackedWidget_2->setCurrentIndex(0); ui->stackedWidget_3->setCurrentIndex(0); + info.gradient = Linear; + info.offset = LinearOffset; + info.gradient_type = c_BrushTypePathNewLinearGradient; ui->statusbar->showMessage("Linear"); - info.gradient = Linear; - info.offset = LinearOffset; - info.gradient_type = c_BrushTypePathNewLinearGradient; } void MainWindow::on_actionRadial_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(1); + ui->stackedWidget_1->setCurrentIndex(1); ui->stackedWidget_2->setCurrentIndex(1); ui->stackedWidget_3->setCurrentIndex(0); + info.gradient = Radial; + info.offset = RadialOffset; + info.gradient_type = c_BrushTypePathRadialGradient; ui->statusbar->showMessage("Radial"); - info.gradient = Radial; - info.offset = RadialOffset; - info.gradient_type = c_BrushTypePathRadialGradient; } void MainWindow::on_actionTriangle_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(2); + ui->stackedWidget_1->setCurrentIndex(2); ui->stackedWidget_2->setCurrentIndex(2); ui->stackedWidget_3->setCurrentIndex(1); - InitializeColors(true); + info.gradient = Triangle; + info.offset = TriangleOffset; + info.gradient_type = c_BrushTypeTriagnleMeshGradient; + initializeColors(true); ui->statusbar->showMessage("Triangle"); - info.gradient = Triangle; - info.offset = TriangleOffset; - info.gradient_type = c_BrushTypeTriagnleMeshGradient; } void MainWindow::on_actionTriangle_Parametric_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(2); + ui->stackedWidget_1->setCurrentIndex(2); ui->stackedWidget_2->setCurrentIndex(3); ui->stackedWidget_3->setCurrentIndex(0); + info.gradient = TriangleParametric; + info.offset = TriangleOffset; + info.gradient_type = c_BrushTypeTriagnleMeshGradient; ui->statusbar->showMessage("Triangle Parametric"); - info.gradient = TriangleParametric; - info.offset = TriangleOffset; - info.gradient_type = c_BrushTypeTriagnleMeshGradient; } void MainWindow::on_actionCoons_Patch_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(3); + ui->stackedWidget_1->setCurrentIndex(3); ui->stackedWidget_2->setCurrentIndex(4); ui->stackedWidget_3->setCurrentIndex(1); - InitializeColors(false); + info.gradient = CoonsPatch; + info.offset = CoonsPatchOffset; + info.gradient_type = c_BrushTypeCurveGradient; + initializeColors(false); ui->statusbar->showMessage("Coons Patch"); - info.gradient = CoonsPatch; - info.offset = CoonsPatchOffset; - info.gradient_type = c_BrushTypePathNewLinearGradient; } void MainWindow::on_actionCoons_Patch_Parametric_triggered() { - ui->stackedWidget->setCurrentIndex(3); + ui->stackedWidget_1->setCurrentIndex(3); ui->stackedWidget_2->setCurrentIndex(5); ui->stackedWidget_3->setCurrentIndex(0); + info.gradient = CoonsPatchParametric; + info.offset = CoonsPatchOffset; + info.gradient_type = c_BrushTypeCurveGradient; ui->statusbar->showMessage("Coons Patch Parametric"); - info.gradient = CoonsPatchParametric; - info.offset = CoonsPatchOffset; - info.gradient_type = c_BrushTypeCurveGradient; } void MainWindow::on_actionTensor_Coons_Patch_Gradient_triggered() { - ui->stackedWidget->setCurrentIndex(4); + ui->stackedWidget_1->setCurrentIndex(4); ui->stackedWidget_2->setCurrentIndex(6); ui->stackedWidget_3->setCurrentIndex(1); - InitializeColors(false); + info.gradient = TensorCoonsPatch; + info.offset = TensorCoonsPatchOffset; + info.gradient_type = c_BrushTypeTensorCurveGradient; + initializeColors(false); ui->statusbar->showMessage("Tensor Coons Patch"); - info.gradient = TensorCoonsPatch; - info.offset = TensorCoonsPatchOffset; - info.gradient_type = c_BrushTypePathNewLinearGradient; } void MainWindow::on_actionTensor_Coons_Patch_Parametric_triggered() { - ui->stackedWidget->setCurrentIndex(4); + ui->stackedWidget_1->setCurrentIndex(4); ui->stackedWidget_2->setCurrentIndex(7); ui->stackedWidget_3->setCurrentIndex(0); + info.gradient = TensorCoonsPatchParametric; + info.offset = TensorCoonsPatchOffset; + info.gradient_type = c_BrushTypeTensorCurveGradient; ui->statusbar->showMessage("Tensor Coons Patch Parametric"); - info.gradient = TensorCoonsPatchParametric; - info.offset = TensorCoonsPatchOffset; - info.gradient_type = c_BrushTypeTensorCurveGradient; } inline agg::rgba8 getRGB(CustomColorLabel *label) { - return {static_cast(label->GetColor().red()), - static_cast(label->GetColor().green()), - static_cast(label->GetColor().blue())}; + return {static_cast(label->getColor().red()), + static_cast(label->getColor().green()), + static_cast(label->getColor().blue())}; } -std::vector MainWindow::QColor2rgba(bool triangle) +std::vector MainWindow::qColor2rgba(bool triangle) { std::vector colors; @@ -212,7 +212,7 @@ std::vector MainWindow::QColor2rgba(bool triangle) return colors; } -std::vector> MainWindow::QColor2rgbaMatrix() +std::vector> MainWindow::qColor2rgbaMatrix() { std::vector> colors; size_t size = listOfColorLabels.size() / 2; @@ -230,102 +230,92 @@ std::vector> MainWindow::QColor2rgbaMatrix() return colors; } -inline void setPoint(QImage *image, int x, int y, QRgb color) +NSStructures::Point MainWindow::scaleCoord(NSStructures::Point p) { - image->setPixel(x, y, color); - image->setPixel(x - 1, y, color); - image->setPixel(x, y - 1, color); - image->setPixel(x + 1, y, color); - image->setPixel(x, y + 1, color); + return {p.x * MM_TO_COORD(ui->label_test->width()), p.y * MM_TO_COORD(ui->label_test->height())}; +} + +inline void setPoint(QImage *image, NSStructures::Point p) +{ + image->setPixel(p.x, p.y, qRgb(0, 0, 0)); + image->setPixel(p.x - 1, p.y, qRgb(0, 0, 0)); + image->setPixel(p.x, p.y - 1, qRgb(0, 0, 0)); + image->setPixel(p.x + 1, p.y, qRgb(0, 0, 0)); + image->setPixel(p.x, p.y + 1, qRgb(0, 0, 0)); } void MainWindow::setPoints(QImage *image) { - std::vector points; + std::vector points; switch (info.gradient) { case Linear: - setPoint(image, info.p0.x * MM_TO_COORD(ui->lable_test->width()), info.p0.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0, 0, 0)); - setPoint(image, info.p1.x * MM_TO_COORD(ui->lable_test->width()), info.p1.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0, 0, 0)); - points.push_back(QPoint(info.p0.x * MM_TO_COORD(ui->lable_test->width()), info.p0.y * MM_TO_COORD(ui->lable_test->height()))); - points.push_back(QPoint(info.p1.x * MM_TO_COORD(ui->lable_test->width()), info.p1.y * MM_TO_COORD(ui->lable_test->height()))); + setPoint(image, scaleCoord(info.p0)); + setPoint(image, scaleCoord(info.p1)); + points.push_back(scaleCoord(info.p0)); + points.push_back(scaleCoord(info.p1)); break; case Radial: - setPoint(image, info.c0.x * MM_TO_COORD(ui->lable_test->width()), info.c0.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0, 0, 0)); - setPoint(image, info.c1.x * MM_TO_COORD(ui->lable_test->width()), info.c1.y * MM_TO_COORD(ui->lable_test->height()),qRgb(0, 0, 0)); - points.push_back(QPoint(info.c0.x * MM_TO_COORD(ui->lable_test->width()), info.c0.y * MM_TO_COORD(ui->lable_test->height()))); - points.push_back(QPoint(info.c1.x * MM_TO_COORD(ui->lable_test->width()), info.c1.y * MM_TO_COORD(ui->lable_test->height()))); + setPoint(image, scaleCoord(info.c0)); + setPoint(image, scaleCoord(info.c1)); + points.push_back(scaleCoord(info.c0)); + points.push_back(scaleCoord(info.c1)); break; case Triangle: case TriangleParametric: for (NSStructures::Point p : info.triangle) { - setPoint(image, p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0,0,0)); - points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()))); + setPoint(image, scaleCoord(p)); + points.push_back(scaleCoord(p)); } break; case CoonsPatch: - for (NSStructures::Point p : info.curve) - { - setPoint(image, p.x, p.y, qRgb(0,0,0)); - points.push_back(QPoint(p.x, p.y)); - } - break; case CoonsPatchParametric: - for (NSStructures::Point p : info.curve) + for (int i = 0; i < info.curve.size(); i++) { - setPoint(image, p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0,0,0)); - points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->width()))); + setPoint(image, scaleCoord(info.curve[i])); + points.push_back(scaleCoord(info.curve[i])); } break; case TensorCoonsPatch: - for (std::vector v : info.tensorcurve) - { - for (NSStructures::Point p : v) - { - setPoint(image, p.x, p.y, qRgb(0,0,0)); - points.push_back(QPoint(p.x, p.y)); - } - } - break; case TensorCoonsPatchParametric: for (std::vector v : info.tensorcurve) { for (NSStructures::Point p : v) { - setPoint(image, p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->height()), qRgb(0,0,0)); - points.push_back(QPoint(p.x * MM_TO_COORD(ui->lable_test->width()), p.y * MM_TO_COORD(ui->lable_test->width()))); + setPoint(image, scaleCoord(p)); + points.push_back(scaleCoord(p)); } } break; default: break; } - ui->lable_test->SetPoints(points); + ui->label_test->setPoints(points); } void MainWindow::on_label_test_clicked() { - if (ui->lable_test->Movable()) + if (ui->label_test->getMovable()) { - ui->lable_test->ResetMovable(); - disconnect(ui->lable_test, SIGNAL(mouseMoved()), this, SLOT(on_label_test_mouse_move())); + ui->label_test->resetMovable(); + disconnect(ui->label_test, SIGNAL(mouseMoved()), this, SLOT(on_label_test_mouse_move())); } - else if (ui->lable_test->CheckPointArea()) + else if (ui->label_test->checkPointArea()) { - ui->lable_test->ResetMovable(); - connect(ui->lable_test, SIGNAL(mouseMoved()), this, SLOT(on_label_test_mouse_move())); + ui->label_test->resetMovable(); + connect(ui->label_test, SIGNAL(mouseMoved()), this, SLOT(on_label_test_mouse_move())); } } void MainWindow::on_label_test_mouse_move() { - listOfLines[info.offset + 2 * ui->lable_test->GetIndex() + 0]->setText(QString::number(ui->lable_test->GetMovePoint().x() / MM_TO_COORD(ui->lable_test->width()))); - listOfLines[info.offset + 2 * ui->lable_test->GetIndex() + 1]->setText(QString::number(ui->lable_test->GetMovePoint().y() / MM_TO_COORD(ui->lable_test->height()))); + listOfLines[info.offset + 2 * ui->label_test->getIndex() + 0]->setText(QString::number(static_cast(ui->label_test->getMovePoint().x) / MM_TO_COORD(ui->label_test->width()))); + listOfLines[info.offset + 2 * ui->label_test->getIndex() + 1]->setText(QString::number(static_cast(ui->label_test->getMovePoint().y) / MM_TO_COORD(ui->label_test->height()))); on_pushButton_clicked(); } -void MainWindow::on_point_set() +void MainWindow::lineEdits2Points() { //Linear info.p0.x = listOfLines[LinearOffset + 0]->text().toInt(); @@ -366,7 +356,7 @@ void MainWindow::on_point_set() } } -void MainWindow::on_parametrs_set() +void MainWindow::lineEdits2Parametrs() { size_t offset = 0; @@ -395,7 +385,7 @@ void MainWindow::on_parametrs_set() } } -void MainWindow::on_continue_set() +void MainWindow::checkBox2Continue() { switch (info.gradient) { @@ -414,13 +404,13 @@ void MainWindow::on_continue_set() void MainWindow::on_pushButton_clicked() { - points = {NSStructures::Point(), - NSStructures::Point(ui->lable_test->width(), 0), - NSStructures::Point(ui->lable_test->width(), ui->lable_test->height()), - NSStructures::Point(0, ui->lable_test->height())}; - on_point_set(); - on_parametrs_set(); - on_continue_set(); + lineEdits2Points(); + lineEdits2Parametrs(); + checkBox2Continue(); + points = {{0, 0}, + {ui->label_test->width(), 0}, + {ui->label_test->width(), ui->label_test->height()}, + {0, ui->label_test->height()}}; switch (info.gradient) { @@ -432,7 +422,8 @@ void MainWindow::on_pushButton_clicked() break; case Triangle: case TriangleParametric: - info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, QColor2rgba(true), info.triangle_parametrs, info.gradient == TriangleParametric); + info.ginfo = NSStructures::GInfoConstructor::get_triangle(info.triangle, qColor2rgba(true), + info.triangle_parametrs, info.gradient == TriangleParametric); points = {}; for (auto p : info.triangle) { @@ -440,29 +431,14 @@ void MainWindow::on_pushButton_clicked() } break; case CoonsPatch: - for(int i = 0; i < info.curve.size(); i++) - { - info.curve[i].x *= MM_TO_COORD(ui->lable_test->width()); - info.curve[i].y *= MM_TO_COORD(ui->lable_test->height()); - } - info.ginfo = NSStructures::GInfoConstructor::get_curve(info.curve, info.curve_parametrs, QColor2rgba(false), false); - break; case CoonsPatchParametric: - info.ginfo = NSStructures::GInfoConstructor::get_curve(info.curve, info.curve_parametrs, QColor2rgba(false),true); + info.ginfo = NSStructures::GInfoConstructor::get_curve(info.curve, info.curve_parametrs, + qColor2rgba(false), info.gradient == CoonsPatchParametric); break; case TensorCoonsPatch: - for (int i = 0; i < info.tensorcurve.size(); i++) - { - for (int j = 0; j < info.tensorcurve[i].size(); j++) - { - info.tensorcurve[i][j].x *= MM_TO_COORD(ui->lable_test->width()); - info.tensorcurve[i][j].y *= MM_TO_COORD(ui->lable_test->height()); - } - } - info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve(info.tensorcurve, info.tensor_curve_parametrs, QColor2rgbaMatrix(), false); - break; case TensorCoonsPatchParametric: - info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve(info.tensorcurve, info.tensor_curve_parametrs, QColor2rgbaMatrix(), true); + info.ginfo = NSStructures::GInfoConstructor::get_tensor_curve(info.tensorcurve, info.tensor_curve_parametrs, + qColor2rgbaMatrix(), info.gradient == TensorCoonsPatchParametric); break; default: break; @@ -473,7 +449,8 @@ void MainWindow::on_pushButton_clicked() info.c = {(LONG)0xFFff0000, (LONG)0xFFffa500, (LONG)0xFFffff00, (LONG)0xFF008000, (LONG)0xFF0000ff, (LONG)0xFFFF00FF}; info.p = {0.0, 0.2, 0.4, 0.6, 0.8, 1}; info.n_colors = 6; - info.ginfo.shading.function.set_linear_interpolation({0xFFff0000, 0xFFffa500, 0xFFffff00, 0xFF008000, 0xFF0000ff, 0xFFFF00FF}, {0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f}); + info.ginfo.shading.function.set_linear_interpolation({0xFFff0000, 0xFFffa500, 0xFFffff00, 0xFF008000, 0xFF0000ff, 0xFFFF00FF}, + {0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f}); } else if (ui->BAW_Colorspace_Radio_Button->isChecked()) { @@ -497,8 +474,8 @@ void MainWindow::on_pushButton_clicked() info.ginfo.shading.function.set_linear_interpolation({0xfff39189, 0xff046582}, {0.0f, 1.0f}); } - QImage pm = GenerateImg(points, info, ui->lable_test->width(), ui->lable_test->height()); + QImage pm = GenerateImg(points, info, ui->label_test->width(), ui->label_test->height()); setPoints(&pm); - ui->lable_test->setPixmap(QPixmap::fromImage(pm)); - ui->lable_test->setScaledContents(true); + ui->label_test->setPixmap(QPixmap::fromImage(pm)); + ui->label_test->setScaledContents(true); } diff --git a/Test/Applications/gradient/Gradient/mainwindow.h b/Test/Applications/gradient/Gradient/mainwindow.h index 5edf24dbea..2a78c1a472 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.h +++ b/Test/Applications/gradient/Gradient/mainwindow.h @@ -3,11 +3,9 @@ #include #include -#include #include #include #include -#include #include #include #include @@ -78,41 +76,29 @@ public: ~CustomLabel() {} - void SetPoints(const std::vector& points) + void setPoints(const std::vector& points) { m_points = points; } - QPoint GetCheckPoint() const - { - return checkPoint; - } - - QPoint GetMovePoint() const + NSStructures::Point getMovePoint() const { return movePoint; } - size_t GetIndex() const + size_t getIndex() const { return index; } - bool Movable() const + bool getMovable() const { return movable; } - void ResetMovable() + void resetMovable() { - if (movable) - { - movable = false; - } - else - { - movable = true; - } + movable = !movable; } void setIndex(size_t _index) @@ -120,17 +106,12 @@ public: index = _index; } - void Clear() - { - m_points.clear(); - } - - bool CheckPointArea() + bool checkPointArea() { for (int i = 0; i < m_points.size(); i++) { - QRect rect(m_points[i].x() - 5, m_points[i].y() - 5, m_points[i].x() + 5, m_points[i].y() + 5); - if (rect.contains(checkPoint)) + QRect rect(m_points[i].x - 5, m_points[i].y - 5, 10, 10); + if (rect.contains(checkPoint.x, checkPoint.y)) { index = i; return true; @@ -146,22 +127,23 @@ signals: protected: void mousePressEvent(QMouseEvent *event) override { - checkPoint = event->pos(); + checkPoint = {event->pos().x(), event->pos().y()}; emit mousePressed(); } void mouseMoveEvent(QMouseEvent *event) override { - movePoint = event->pos(); + movePoint = {event->pos().x(), event->pos().y()}; emit mouseMoved(); } private: - bool movable; - size_t index; - QPoint movePoint; - QPoint checkPoint; - std::vector m_points; + bool movable; + size_t index; + + NSStructures::Point movePoint; + NSStructures::Point checkPoint; + std::vector m_points; }; class CustomColorLabel : public QLabel @@ -175,13 +157,13 @@ public: ~CustomColorLabel() {} - void SetColor(QColor color) + void setColor(QColor color) { m_color = color; this->setStyleSheet("QLabel { background-color : " + m_color.name() + "; border: 1px solid black; padding 10px;}"); } - QColor GetColor() const + QColor getColor() const { return m_color; } @@ -200,7 +182,7 @@ public slots: if (color.isValid()) { - SetColor(color); + setColor(color); } } private: @@ -221,60 +203,36 @@ typedef enum typedef enum { - LinearOffset = 68, - RadialOffset = 62, - TriangleOffset = 56, - CoonsPatchOffset = 32, - TensorCoonsPatchOffset = 0 + LinearOffset = 68, + RadialOffset = 62, + TriangleOffset = 56, + CoonsPatchOffset = 32, + TensorCoonsPatchOffset = 0 } GradientOffse; struct Info { - GradientType gradient; - GradientOffse offset; + GradientType gradient; + GradientOffse offset; - float r0, r1; - NSStructures::Point c0, c1; NSStructures::Point p0, p1; + NSStructures::Point c0, c1; + float r0, r1; + std::vector triangle = std::vector(3); + std::vector curve = std::vector(12); + std::vector> tensorcurve = std::vector>(4, std::vector(4)); + + std::vector triangle_parametrs = std::vector(3); + std::vector curve_parametrs = std::vector(4); + std::vector> tensor_curve_parametrs = std::vector>(2, std::vector(2)); + bool cont_b, cont_f; - std::vector triangle; - std::vector curve; - std::vector> tensorcurve; - std::vector triangle_parametrs; - std::vector curve_parametrs; - std::vector> tensor_curve_parametrs; NSStructures::GradientInfo ginfo; + std::vector c; + std::vector p; int gradient_type; - std::vector c; - std::vector p; int n_colors; - Info() : gradient_type(c_BrushTypePathNewLinearGradient) - { - c = {(LONG)0xFFff0000, (LONG)0xFFffa500, (LONG)0xFFffff00, (LONG)0xFF008000, (LONG)0xFF0000ff, (LONG)0xFFFF00FF}; - p = {0.0, 0.2, 0.4, 0.6, 0.8, 1}; - n_colors = 6; - ginfo.shading.shading_type = NSStructures::ShadingInfo::Parametric; - triangle.resize(3); - curve.resize(12); - tensorcurve.resize(4); - for (int i = 0; i < tensorcurve.size(); i++) - { - tensorcurve[i].resize(4); - } - triangle_parametrs.resize(3); - curve_parametrs.resize(4); - tensor_curve_parametrs.resize(2); - for (int i = 0; i < tensor_curve_parametrs.size(); i++) - { - tensor_curve_parametrs[i].resize(2); - } - - cont_b = cont_f = false; - } - ~Info() - { - } }; class MainWindow : public QMainWindow @@ -284,14 +242,17 @@ class MainWindow : public QMainWindow public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); - void InitializeColors(bool triangle); - std::vector QColor2rgba(bool triangle); - std::vector> QColor2rgbaMatrix(); + + void initializeColors(bool triangle); + std::vector qColor2rgba(bool triangle); + std::vector> qColor2rgbaMatrix(); + void setPoints(QImage *image); - QImage img; - QLabel *lable; - std::vector points; - Info info; + NSStructures::Point scaleCoord(NSStructures::Point p); + + void lineEdits2Points(); + void lineEdits2Parametrs(); + void checkBox2Continue(); private slots: @@ -299,12 +260,6 @@ private slots: void on_label_test_mouse_move(); - void on_point_set(); - - void on_parametrs_set(); - - void on_continue_set(); - void on_actionLinear_Gradient_triggered(); void on_actionRadial_Gradient_triggered(); @@ -324,10 +279,15 @@ private slots: void on_actionTensor_Coons_Patch_Parametric_triggered(); private: - QList listOfLines; + QImage img; + Info info; + std::vector points; + + QList listOfCheckBox; + QList listOfLines; + QList listOfColorLabels; QList listOfParametricLines; - QList listOfCheckBox; - QListlistOfColorLabels; + Ui::MainWindow *ui; }; #endif // MAINWINDOW_H diff --git a/Test/Applications/gradient/Gradient/mainwindow.ui b/Test/Applications/gradient/Gradient/mainwindow.ui index 37680dfdf7..f64b558c70 100644 --- a/Test/Applications/gradient/Gradient/mainwindow.ui +++ b/Test/Applications/gradient/Gradient/mainwindow.ui @@ -17,7 +17,7 @@ true - + 0 @@ -45,7 +45,7 @@ - + 10