diff --git a/Canvas.cpp b/Canvas.cpp index 8978b10..46d09cb 100644 --- a/Canvas.cpp +++ b/Canvas.cpp @@ -75,15 +75,29 @@ void Canvas::mousePressEvent(QMouseEvent* event) #ifdef _DEBUG qDebug() << "Scene point in" << scene.x() << scene.y(); #endif - + if (mode == Mode::None){ Point* p = findPointAt(scene); if (p) { draggedPoint = p; dragOffset = scene - QPointF(*p->x, *p->y); - return; } } + + else if (mode == Mode::Horizontal || mode == Mode::Vertical) { + Line* found = findAt(scene); + + if (found) { + if (mode == Mode::Horizontal) + sys.addConstraintHorizontal(*found, constraints_count++); + else + sys.addConstraintVertical(*found, constraints_count++); + update(); + } + mode = Mode::None; + after_constraint = true; + } + else if (mode == Mode::DrawingLine) { if (!current_line) { current_line = new Line(); diff --git a/Canvas.h b/Canvas.h index 567652c..0f498ac 100644 --- a/Canvas.h +++ b/Canvas.h @@ -19,7 +19,9 @@ enum class Mode : int None = 0, DrawingLine = 1, Parallel = 2, - Coincedent = 3 + Coincedent = 3, + Horizontal = 4, + Vertical = 5 }; // Удобный тип для хранения пары параллельных линий (порядок не важен) diff --git a/DRAWer_2_0.cpp b/DRAWer_2_0.cpp index 7c2f683..4458cb3 100644 --- a/DRAWer_2_0.cpp +++ b/DRAWer_2_0.cpp @@ -30,8 +30,13 @@ void DRAWer_2_0::on_P2P_Button_clicked() } -void DRAWer_2_0::on_FIX_Button_clicked() +void DRAWer_2_0::on_Horizontal_Button_clicked() { - + ui.widget->changeMode(Mode::Horizontal); +} + +void DRAWer_2_0::on_Vertical_Button_clicked() +{ + ui.widget->changeMode(Mode::Vertical); } diff --git a/DRAWer_2_0.h b/DRAWer_2_0.h index 3adf8ef..9d40eca 100644 --- a/DRAWer_2_0.h +++ b/DRAWer_2_0.h @@ -18,7 +18,9 @@ private slots: void on_P2P_Button_clicked(); - void on_FIX_Button_clicked(); + void on_Horizontal_Button_clicked(); + + void on_Vertical_Button_clicked(); private: Ui::DRAWer_2_0Class ui; diff --git a/DRAWer_2_0.ui b/DRAWer_2_0.ui index 5221b23..fe011c0 100644 --- a/DRAWer_2_0.ui +++ b/DRAWer_2_0.ui @@ -66,9 +66,16 @@ - + - Fix Point + Vertical + + + + + + + Horizontal @@ -117,7 +124,7 @@ 0 0 700 - 22 + 21 diff --git a/GCS/Geo.h b/GCS/Geo.h index cf94c87..7c513b0 100644 --- a/GCS/Geo.h +++ b/GCS/Geo.h @@ -239,7 +239,7 @@ public: void set_tag(int); int get_tag(); - bool contains(QPointF, qreal tol = 10.0) const; + bool contains(QPointF, qreal tol = 5.0) const; };