From 0cb599e0e4edd37924565ef37f579ef2f32ba571 Mon Sep 17 00:00:00 2001 From: ParkSuMin Date: Sun, 7 Dec 2025 17:10:48 +0300 Subject: [PATCH] Change encoding And add fix button --- Canvas.cpp | 2 +- Canvas.h | 32 ++++++++++++++++---------------- DRAWer_2_0.cpp | 14 ++++++++++---- DRAWer_2_0.h | 10 ++++++---- DRAWer_2_0.ui | 15 +++++++++++---- 5 files changed, 44 insertions(+), 29 deletions(-) diff --git a/Canvas.cpp b/Canvas.cpp index b22b45a..ae57dc5 100644 --- a/Canvas.cpp +++ b/Canvas.cpp @@ -1,4 +1,4 @@ -#include "Canvas.h" +#include "Canvas.h" static double dist_P2P(QPointF p1, QPointF p2) { return sqrt(pow(p2.x() - p1.x(), 2) + pow(p2.y() - p1.y(), 2)); diff --git a/Canvas.h b/Canvas.h index 9cc0fdd..87c2f6d 100644 --- a/Canvas.h +++ b/Canvas.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -9,7 +9,7 @@ #include #endif -// GCS FreeCAD +// GCS — геометрический солвер из FreeCAD #include "GCS/Geo.h" #include "GCS/GCS.h" using namespace GCS; @@ -22,11 +22,11 @@ enum class Mode : int Coincedent = 3 }; -// ( ) +// Удобный тип для хранения пары параллельных линий (порядок не важен) using LinePair = std::pair; // =================================================================== -// +// Основной класс холста // =================================================================== class Canvas : public QWidget @@ -44,26 +44,26 @@ protected: void paintEvent(QPaintEvent* event) override; private: - // ====================== ====================== - Line* findAt(QPointF&); // + // ====================== Поиск и выбор ====================== + Line* findAt(QPointF&); // ищет линию под курсором Point* findPointAt(QPointF, qreal tolerance = 10.0); - // ====================== ====================== + // ====================== Параллельность ====================== LinePair makeOrderedPair(Line* l1, Line* l2); - bool areAlreadyParallel(Line* l1, Line* l2); // + bool areAlreadyParallel(Line* l1, Line* l2); // проверка на дубликат - // ====================== ====================== - System sys; // - QVector lines; // - QVector points; // ( ) - std::vector params; // , + // ====================== Данные сцены ====================== + System sys; // геометрический солвер + QVector lines; // завершённые линии + QVector points; // все точки (для удобного доступа) + std::vector params; // все параметры, передаваемые в солвер - std::set parallelPairs; // ( ) + std::set parallelPairs; // уже запараллеленные пары (защита от дублей) Line* current_line{ nullptr }; Point* firstPoint{ nullptr }; Mode mode{ Mode::None }; - int obj_count{ 0 }; // - int constraints_count{ 0 }; // + int obj_count{ 0 }; // тег для новых объектов + int constraints_count{ 0 }; // тег для новых ограничений }; \ No newline at end of file diff --git a/DRAWer_2_0.cpp b/DRAWer_2_0.cpp index 8bcc487..7c2f683 100644 --- a/DRAWer_2_0.cpp +++ b/DRAWer_2_0.cpp @@ -1,4 +1,4 @@ -#include "DRAWer_2_0.h" +#include "DRAWer_2_0.h" DRAWer_2_0::DRAWer_2_0(QWidget *parent) : QMainWindow(parent) @@ -11,21 +11,27 @@ DRAWer_2_0::~DRAWer_2_0() {} -void DRAWer_2_0::on_pushButton_clicked() +void DRAWer_2_0::on_Line_Button_clicked() { ui.label->setText(QString::number(counter++)); ui.widget->changeMode(Mode::DrawingLine); } -void DRAWer_2_0::on_pushButton_2_clicked() +void DRAWer_2_0::on_Parallel_Button_clicked() { ui.widget->changeMode(Mode::Parallel); } -void DRAWer_2_0::on_pushButton_3_clicked() +void DRAWer_2_0::on_P2P_Button_clicked() { ui.widget->changeMode(Mode::Coincedent); } + +void DRAWer_2_0::on_FIX_Button_clicked() +{ + +} + diff --git a/DRAWer_2_0.h b/DRAWer_2_0.h index fa5ae79..3adf8ef 100644 --- a/DRAWer_2_0.h +++ b/DRAWer_2_0.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include "ui_DRAWer_2_0.h" @@ -12,11 +12,13 @@ public: ~DRAWer_2_0(); private slots: - void on_pushButton_clicked(); + void on_Line_Button_clicked(); - void on_pushButton_2_clicked(); + void on_Parallel_Button_clicked(); - void on_pushButton_3_clicked(); + void on_P2P_Button_clicked(); + + void on_FIX_Button_clicked(); private: Ui::DRAWer_2_0Class ui; diff --git a/DRAWer_2_0.ui b/DRAWer_2_0.ui index 3e9eec9..5221b23 100644 --- a/DRAWer_2_0.ui +++ b/DRAWer_2_0.ui @@ -27,7 +27,7 @@ 23 - + 75 @@ -40,7 +40,7 @@ - + 75 @@ -53,7 +53,7 @@ - + 75 @@ -65,6 +65,13 @@ + + + + Fix Point + + + @@ -110,7 +117,7 @@ 0 0 700 - 21 + 22