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) {
|
||||
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 <QMouseEvent>
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <QDebug>
|
||||
#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<Line*, Line*>;
|
||||
|
||||
// ===================================================================
|
||||
// Îñíîâíîé êëàññ õîëñòà
|
||||
// Основной класс холста
|
||||
// ===================================================================
|
||||
|
||||
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<Line*> lines; // çàâåðø¸ííûå ëèíèè
|
||||
QVector<Point> points; // âñå òî÷êè (äëÿ óäîáíîãî äîñòóïà)
|
||||
std::vector<double*> params; // âñå ïàðàìåòðû, ïåðåäàâàåìûå â ñîëâåð
|
||||
// ====================== Данные сцены ======================
|
||||
System sys; // геометрический солвер
|
||||
QVector<Line*> lines; // завершённые линии
|
||||
QVector<Point> points; // все точки (для удобного доступа)
|
||||
std::vector<double*> params; // все параметры, передаваемые в солвер
|
||||
|
||||
std::set<LinePair> parallelPairs; // óæå çàïàðàëëåëåííûå ïàðû (çàùèòà îò äóáëåé)
|
||||
std::set<LinePair> 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 }; // тег для новых ограничений
|
||||
};
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
10
DRAWer_2_0.h
10
DRAWer_2_0.h
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#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;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<number>23</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="Line_Button">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
@@ -40,7 +40,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="Parallel_Button">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
@@ -53,7 +53,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<widget class="QPushButton" name="P2P_Button">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
@@ -65,6 +65,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="FIX_Button">
|
||||
<property name="text">
|
||||
<string>Fix Point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -110,7 +117,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>21</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user