mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Refactoring
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QPixmap>
|
||||
#include <iostream>
|
||||
|
||||
#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<CustomLineEdit*>();
|
||||
listOfParametricLines = ui->centralwidget->findChildren<CustomParametrLineEdit*>();
|
||||
listOfCheckBox = ui->centralwidget->findChildren<QCheckBox*>();
|
||||
listOfColorLabels = ui->centralwidget->findChildren<CustomColorLabel*>();
|
||||
|
||||
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<Point> &points, Info &info, const int& w, const int& h)
|
||||
QImage GenerateImg(std::vector<NSStructures::Point> &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<unsigned int>(label->GetColor().red()),
|
||||
static_cast<unsigned int>(label->GetColor().green()),
|
||||
static_cast<unsigned int>(label->GetColor().blue())};
|
||||
}
|
||||
|
||||
std::vector<agg::rgba8> MainWindow::QColor2rgba(bool triangle)
|
||||
{
|
||||
std::vector<agg::rgba8> colors;
|
||||
colors.push_back({static_cast<unsigned int>(ui->label_80->GetColor().red()),
|
||||
static_cast<unsigned int>(ui->label_80->GetColor().green()),
|
||||
static_cast<unsigned int>(ui->label_80->GetColor().blue())});
|
||||
colors.push_back({static_cast<unsigned int>(ui->label_81->GetColor().red()),
|
||||
static_cast<unsigned int>(ui->label_81->GetColor().green()),
|
||||
static_cast<unsigned int>(ui->label_81->GetColor().blue())});
|
||||
colors.push_back({static_cast<unsigned int>(ui->label_114->GetColor().red()),
|
||||
static_cast<unsigned int>(ui->label_114->GetColor().green()),
|
||||
static_cast<unsigned int>(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<unsigned int>(ui->label_115->GetColor().red()),
|
||||
static_cast<unsigned int>(ui->label_115->GetColor().green()),
|
||||
static_cast<unsigned int>(ui->label_115->GetColor().blue())});
|
||||
colors.push_back(getRGB(listOfColorLabels[i]));
|
||||
}
|
||||
|
||||
return colors;
|
||||
@ -203,23 +215,17 @@ std::vector<agg::rgba8> MainWindow::QColor2rgba(bool triangle)
|
||||
std::vector<std::vector<agg::rgba8>> MainWindow::QColor2rgbaMatrix()
|
||||
{
|
||||
std::vector<std::vector<agg::rgba8>> colors;
|
||||
std::vector<agg::rgba8> sub_colors;
|
||||
sub_colors.push_back({static_cast<unsigned int>(ui->label_80->GetColor().red()),
|
||||
static_cast<unsigned int>(ui->label_80->GetColor().green()),
|
||||
static_cast<unsigned int>(ui->label_80->GetColor().blue())});
|
||||
sub_colors.push_back({static_cast<unsigned int>(ui->label_81->GetColor().red()),
|
||||
static_cast<unsigned int>(ui->label_81->GetColor().green()),
|
||||
static_cast<unsigned int>(ui->label_81->GetColor().blue())});
|
||||
colors.push_back(sub_colors);
|
||||
sub_colors.clear();
|
||||
sub_colors.push_back({static_cast<unsigned int>(ui->label_114->GetColor().red()),
|
||||
static_cast<unsigned int>(ui->label_114->GetColor().green()),
|
||||
static_cast<unsigned int>(ui->label_114->GetColor().blue())});
|
||||
sub_colors.push_back({static_cast<unsigned int>(ui->label_115->GetColor().red()),
|
||||
static_cast<unsigned int>(ui->label_115->GetColor().green()),
|
||||
static_cast<unsigned int>(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<agg::rgba8> 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<QPoint> 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<NSStructures::Point> 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<NSStructures::Point> 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<double>(ui->lable_test->width()), 0},
|
||||
{static_cast<double>(ui->lable_test->width()), static_cast<double>(ui->lable_test->height())},
|
||||
{0, static_cast<double>(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())
|
||||
|
||||
@ -2,10 +2,13 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QList>
|
||||
#include <QListWidgetItem>
|
||||
#include <QMainWindow>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QPoint>
|
||||
#include <QPixmap>
|
||||
#include <QMouseEvent>
|
||||
#include <QColorDialog>
|
||||
#include <QPainter>
|
||||
@ -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<NSStructures::Point> triangle = {{100, 100}, {300, 200}, {200, 350}};
|
||||
std::vector<NSStructures::Point> 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<std::vector<NSStructures::Point>> 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<float> triangle_parametrs = {0.f, 0.5f, 1.f};
|
||||
std::vector<float> curve_parametrs = {0.f, 0.3f, 1.f, 0.6f};
|
||||
std::vector<std::vector<float>> tensor_curve_parametrs = {{0.f, 0.3f}, {1.f, 0.6f}};
|
||||
std::vector<NSStructures::Point> triangle;
|
||||
std::vector<NSStructures::Point> curve;
|
||||
std::vector<std::vector<NSStructures::Point>> tensorcurve;
|
||||
std::vector<float> triangle_parametrs;
|
||||
std::vector<float> curve_parametrs;
|
||||
std::vector<std::vector<float>> 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<Point> points;
|
||||
std::vector<NSStructures::Point> 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<CustomLineEdit *> listOfLines;
|
||||
QList<CustomParametrLineEdit *> listOfParametricLines;
|
||||
QList<QCheckBox *> listOfCheckBox;
|
||||
QList<CustomColorLabel *>listOfColorLabels;
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user