mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Add class Custom label for handle click
This commit is contained in:
@ -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<QPoint> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,9 @@
|
||||
#include <QListWidgetItem>
|
||||
#include <QMainWindow>
|
||||
#include <QLineEdit>
|
||||
#include <QPoint>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#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<QPoint> 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<QPoint> 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;
|
||||
};
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QLabel" name="lable_test">
|
||||
<widget class="CustomLabel" name="lable_test">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -117,7 +117,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Linear_Page">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
@ -2491,6 +2491,19 @@
|
||||
<string>Render Gradient</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>110</y>
|
||||
<width>80</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>set from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="stackedWidget_2">
|
||||
<property name="geometry">
|
||||
@ -2893,6 +2906,11 @@
|
||||
<extends>QLineEdit</extends>
|
||||
<header>mainwindow.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CustomLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>mainwindow.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user