Change encoding
And add fix button
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#include "Canvas.h"
|
#include "Canvas.h"
|
||||||
|
|
||||||
static double dist_P2P(QPointF p1, QPointF p2) {
|
static double dist_P2P(QPointF p1, QPointF p2) {
|
||||||
return sqrt(pow(p2.x() - p1.x(), 2) + pow(p2.y() - p1.y(), 2));
|
return sqrt(pow(p2.x() - p1.x(), 2) + pow(p2.y() - p1.y(), 2));
|
||||||
|
|||||||
32
Canvas.h
32
Canvas.h
@@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GCS — ãåîìåòðè÷åñêèé ñîëâåð èç FreeCAD
|
// GCS — геометрический солвер из FreeCAD
|
||||||
#include "GCS/Geo.h"
|
#include "GCS/Geo.h"
|
||||||
#include "GCS/GCS.h"
|
#include "GCS/GCS.h"
|
||||||
using namespace GCS;
|
using namespace GCS;
|
||||||
@@ -22,11 +22,11 @@ enum class Mode : int
|
|||||||
Coincedent = 3
|
Coincedent = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
// Óäîáíûé òèï äëÿ õðàíåíèÿ ïàðû ïàðàëëåëüíûõ ëèíèé (ïîðÿäîê íå âàæåí)
|
// Удобный тип для хранения пары параллельных линий (порядок не важен)
|
||||||
using LinePair = std::pair<Line*, Line*>;
|
using LinePair = std::pair<Line*, Line*>;
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
// Îñíîâíîé êëàññ õîëñòà
|
// Основной класс холста
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
class Canvas : public QWidget
|
class Canvas : public QWidget
|
||||||
@@ -44,26 +44,26 @@ protected:
|
|||||||
void paintEvent(QPaintEvent* event) override;
|
void paintEvent(QPaintEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ====================== Ïîèñê è âûáîð ======================
|
// ====================== Поиск и выбор ======================
|
||||||
Line* findAt(QPointF&); // èùåò ëèíèþ ïîä êóðñîðîì
|
Line* findAt(QPointF&); // ищет линию под курсором
|
||||||
Point* findPointAt(QPointF, qreal tolerance = 10.0);
|
Point* findPointAt(QPointF, qreal tolerance = 10.0);
|
||||||
|
|
||||||
// ====================== Ïàðàëëåëüíîñòü ======================
|
// ====================== Параллельность ======================
|
||||||
LinePair makeOrderedPair(Line* l1, Line* l2);
|
LinePair makeOrderedPair(Line* l1, Line* l2);
|
||||||
bool areAlreadyParallel(Line* l1, Line* l2); // ïðîâåðêà íà äóáëèêàò
|
bool areAlreadyParallel(Line* l1, Line* l2); // проверка на дубликат
|
||||||
|
|
||||||
// ====================== Äàííûå ñöåíû ======================
|
// ====================== Данные сцены ======================
|
||||||
System sys; // ãåîìåòðè÷åñêèé ñîëâåð
|
System sys; // геометрический солвер
|
||||||
QVector<Line*> lines; // çàâåðø¸ííûå ëèíèè
|
QVector<Line*> lines; // завершённые линии
|
||||||
QVector<Point> points; // âñå òî÷êè (äëÿ óäîáíîãî äîñòóïà)
|
QVector<Point> points; // все точки (для удобного доступа)
|
||||||
std::vector<double*> params; // âñå ïàðàìåòðû, ïåðåäàâàåìûå â ñîëâåð
|
std::vector<double*> params; // все параметры, передаваемые в солвер
|
||||||
|
|
||||||
std::set<LinePair> parallelPairs; // óæå çàïàðàëëåëåííûå ïàðû (çàùèòà îò äóáëåé)
|
std::set<LinePair> parallelPairs; // уже запараллеленные пары (защита от дублей)
|
||||||
|
|
||||||
Line* current_line{ nullptr };
|
Line* current_line{ nullptr };
|
||||||
Point* firstPoint{ nullptr };
|
Point* firstPoint{ nullptr };
|
||||||
Mode mode{ Mode::None };
|
Mode mode{ Mode::None };
|
||||||
|
|
||||||
int obj_count{ 0 }; // òåã äëÿ íîâûõ îáúåêòîâ
|
int obj_count{ 0 }; // тег для новых объектов
|
||||||
int constraints_count{ 0 }; // òåã äëÿ íîâûõ îãðàíè÷åíèé
|
int constraints_count{ 0 }; // тег для новых ограничений
|
||||||
};
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "DRAWer_2_0.h"
|
#include "DRAWer_2_0.h"
|
||||||
|
|
||||||
DRAWer_2_0::DRAWer_2_0(QWidget *parent)
|
DRAWer_2_0::DRAWer_2_0(QWidget *parent)
|
||||||
: QMainWindow(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.label->setText(QString::number(counter++));
|
||||||
ui.widget->changeMode(Mode::DrawingLine);
|
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);
|
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);
|
ui.widget->changeMode(Mode::Coincedent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DRAWer_2_0::on_FIX_Button_clicked()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
10
DRAWer_2_0.h
10
DRAWer_2_0.h
@@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QtWidgets/QMainWindow>
|
#include <QtWidgets/QMainWindow>
|
||||||
#include "ui_DRAWer_2_0.h"
|
#include "ui_DRAWer_2_0.h"
|
||||||
@@ -12,11 +12,13 @@ public:
|
|||||||
~DRAWer_2_0();
|
~DRAWer_2_0();
|
||||||
|
|
||||||
private slots:
|
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:
|
private:
|
||||||
Ui::DRAWer_2_0Class ui;
|
Ui::DRAWer_2_0Class ui;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<number>23</number>
|
<number>23</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="Line_Button">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>75</width>
|
<width>75</width>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QPushButton" name="Parallel_Button">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>75</width>
|
<width>75</width>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_3">
|
<widget class="QPushButton" name="P2P_Button">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>75</width>
|
<width>75</width>
|
||||||
@@ -65,6 +65,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="FIX_Button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fix Point</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -110,7 +117,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>700</width>
|
<width>700</width>
|
||||||
<height>21</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user