Refactoring

This commit is contained in:
Oleg Korshul
2024-04-04 10:22:35 +03:00
parent 21e3293895
commit 86b53b7ede
3 changed files with 298 additions and 320 deletions

View File

@ -1,11 +1,10 @@
#include "mainwindow.h"
#include <iostream>
#include <QApplication>
#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();
}

View File

@ -2,337 +2,307 @@
#include "ui_mainwindow.h"
#include <QPixmap>
#include <iostream>
#include "../../../../DesktopEditor/graphics/pro/Graphics.h"
#include "../../../../DesktopEditor/fontengine/ApplicationFontsWorker.h"
#include "../../../../DesktopEditor/common/Directory.h"
#include "../../../../PdfFile/PdfFile.h"
// std::vector<Point> drawCircle1(int n, double cx, double cy, double r) {
// std::vector<Point> 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<Point> &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<Point> &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);
}

View File

@ -1,136 +1,145 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLabel>
#include <cmath>
#include <QListWidgetItem>
#include "../../../../DesktopEditor/graphics/pro/Graphics.h"
#include <QMainWindow>
#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<NSStructures::Point> 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<NSStructures::Point> triangle = {{100, 100}, {300, 200}, {200, 350}};
NSStructures::GradientInfo ginfo;
int gradient_type;
std::vector<LONG> c;
std::vector<double> 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<LONG> c;
std::vector<double> 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<Point> points = {});
std::vector<Point> 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<Point> points;
Info info;
MainWindow(QWidget *parent = nullptr);
~MainWindow();
QImage img;
QLabel *lable;
std::vector<Point> 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