From c2aa597022b6ec45a26a7ae2dfbec0b66f88ac11 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 13 Jan 2026 16:21:59 +0100 Subject: [PATCH] WIP --- src/ant/ant/antService.cc | 7 ++++++ src/ant/ant/antService.h | 5 +++++ src/edt/edt/edtMoveTrackerService.cc | 7 ++++++ src/edt/edt/edtMoveTrackerService.h | 5 +++++ src/edt/edt/edtPartialService.cc | 11 +++++++--- src/edt/edt/edtPartialService.h | 5 +++++ src/edt/edt/edtService.cc | 19 +++++++++++++--- src/edt/edt/edtService.h | 5 +++++ src/img/img/imgService.cc | 9 +++++++- src/img/img/imgService.h | 5 +++++ src/laybasic/laybasic/layEditable.cc | 33 +++++++++++++++++++++++++++- src/laybasic/laybasic/layEditable.h | 20 +++++++++++++++++ src/laybasic/laybasic/layMove.cc | 29 +++++++++++++++--------- 13 files changed, 142 insertions(+), 18 deletions(-) diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index b7ead8384..2a66becba 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -1681,6 +1681,13 @@ Service::show_message () view ()->message (pos); } +void +Service::end_move (const db::DVector &v) +{ + m_trans = db::DTrans (v) * db::DTrans (m_trans.fp_trans ()); + end_move (db::DPoint (), lay::AC_Any); +} + void Service::end_move (const db::DPoint &, lay::angle_constraint_type) { diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index 13086eeb4..f270ff914 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -347,6 +347,11 @@ public: */ virtual void end_move (const db::DPoint &p, lay::angle_constraint_type ac); + /** + * @brief Terminate a "move" operation with compulsory move vector + */ + virtual void end_move (const db::DVector &v); + /** * @brief Return the bbox of the selection (reimplementation of lay::Editable interface) */ diff --git a/src/edt/edt/edtMoveTrackerService.cc b/src/edt/edt/edtMoveTrackerService.cc index 32a7e2cfa..c1b8abc34 100644 --- a/src/edt/edt/edtMoveTrackerService.cc +++ b/src/edt/edt/edtMoveTrackerService.cc @@ -133,6 +133,13 @@ MoveTrackerService::end_move (const db::DPoint & /*p*/, lay::angle_constraint_ty move_cancel (); // formally this functionality fits here } +void +MoveTrackerService::end_move (const db::DVector & /*v*/) +{ + call_editor_hooks (m_editor_hooks, &edt::EditorHooks::commit_edit); + move_cancel (); // formally this functionality fits here +} + void MoveTrackerService::edit_cancel () { diff --git a/src/edt/edt/edtMoveTrackerService.h b/src/edt/edt/edtMoveTrackerService.h index d92d9f3aa..48c18bc08 100644 --- a/src/edt/edt/edtMoveTrackerService.h +++ b/src/edt/edt/edtMoveTrackerService.h @@ -68,6 +68,11 @@ public: */ virtual void end_move (const db::DPoint &p, lay::angle_constraint_type ac); + /** + * @brief Terminate a "move" operation with compulsory move vector + */ + virtual void end_move (const db::DVector &v); + /** * @brief Access to the view object */ diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index d80a08bcd..0e4210ff7 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -2489,14 +2489,19 @@ PartialService::move (const db::DPoint &p, lay::angle_constraint_type ac) } void -PartialService::end_move (const db::DPoint & /*p*/, lay::angle_constraint_type ac) +PartialService::end_move (const db::DVector &v) +{ + m_current = m_start + v; + end_move (db::DPoint (), lay::AC_Any); +} + +void +PartialService::end_move (const db::DPoint & /*p*/, lay::angle_constraint_type /*ac*/) { if (! m_dragging) { return; } - m_alt_ac = ac; - if (m_current != m_start) { // stop dragging diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index 594c73108..e124c2dda 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -287,6 +287,11 @@ public: */ virtual void end_move (const db::DPoint &p, lay::angle_constraint_type ac); + /** + * @brief Terminate a "move" operation with compulsory move vector + */ + virtual void end_move (const db::DVector &v); + /** * @brief Implement the "select" method at least to clear the selection */ diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index a044dd441..7c546c220 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -601,16 +601,29 @@ Service::move_transform (const db::DPoint &pu, db::DFTrans tr, lay::angle_constr m_alt_ac = lay::AC_Global; } -void -Service::end_move (const db::DPoint & /*p*/, lay::angle_constraint_type ac) +void +Service::end_move (const db::DVector &v) +{ + if (view ()->is_editable () && m_moving) { + transform (db::DCplxTrans (db::DTrans (v) * db::DTrans (m_move_trans.fp_trans ()))); + move_cancel (); // formally this functionality fits here + // accept changes to guiding shapes + handle_guiding_shape_changes (true); + } + + m_alt_ac = lay::AC_Global; +} + +void +Service::end_move (const db::DPoint & /*p*/, lay::angle_constraint_type /*ac*/) { - m_alt_ac = ac; if (view ()->is_editable () && m_moving) { transform (db::DCplxTrans (m_move_trans)); move_cancel (); // formally this functionality fits here // accept changes to guiding shapes handle_guiding_shape_changes (true); } + m_alt_ac = lay::AC_Global; } diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index 09bb56e96..814e4db93 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -190,6 +190,11 @@ public: */ virtual void end_move (const db::DPoint &p, lay::angle_constraint_type ac); + /** + * @brief Terminate a "move" operation with compulsory move vector + */ + virtual void end_move (const db::DVector &v); + /** * @brief Indicates whether objects are selected */ diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index ce0b06961..7d84f281b 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -872,7 +872,14 @@ Service::show_message () */ } -void +void +Service::end_move (const db::DVector &v) +{ + m_trans = db::DTrans (v) * db::DTrans (m_trans.fp_trans ()); + end_move (db::DPoint (), lay::AC_Any); +} + +void Service::end_move (const db::DPoint &, lay::angle_constraint_type) { if (! m_selected_image_views.empty () && ! m_selected.empty ()) { diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index 9e5d1cc14..0d3d27092 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -359,6 +359,11 @@ public: */ virtual void end_move (const db::DPoint &p, lay::angle_constraint_type ac); + /** + * @brief Terminate a "move" operation with compulsory move vector + */ + virtual void end_move (const db::DVector &v); + /** * @brief Return the bbox of the selection (reimplementation of lay::Editable interface) */ diff --git a/src/laybasic/laybasic/layEditable.cc b/src/laybasic/laybasic/layEditable.cc index 49060757a..1e532f800 100644 --- a/src/laybasic/laybasic/layEditable.cc +++ b/src/laybasic/laybasic/layEditable.cc @@ -621,7 +621,38 @@ Editables::move_transform (const db::DPoint &p, db::DFTrans t, lay::angle_constr } } -void +void +Editables::end_move (const db::DVector &v, db::Transaction *transaction) +{ + std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Move")))); + + if (m_any_move_operation) { + + trans_holder->open (); + + // this dummy operation will update the screen: + if (manager ()) { + manager ()->queue (this, new db::Op ()); + } + + for (iterator e = begin (); e != end (); ++e) { + e->end_move (v); + } + + // clear the selection that was set previously + if (m_move_selection) { + clear_selection (); + } + + } else { + + trans_holder->cancel (); + edit_cancel (); + + } +} + +void Editables::end_move (const db::DPoint &p, lay::angle_constraint_type ac, db::Transaction *transaction) { std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Move")))); diff --git a/src/laybasic/laybasic/layEditable.h b/src/laybasic/laybasic/layEditable.h index 9722e2ff3..f57c1f141 100644 --- a/src/laybasic/laybasic/layEditable.h +++ b/src/laybasic/laybasic/layEditable.h @@ -326,6 +326,16 @@ public: // .. by default, nothing is implemented .. } + /** + * @brief Terminate a "move" operation with compulsory shift vector + * + * @param v The move distance to be applied + */ + virtual void end_move (const db::DVector & /*v*/) + { + // .. by default, nothing is implemented .. + } + /** * @brief Cancel any pending operations * @@ -610,6 +620,16 @@ public: */ void end_move (const db::DPoint &p, lay::angle_constraint_type ac, db::Transaction *transaction = 0); + /** + * @brief End "move" operation with given vector + * + * If a transaction is given, the operation will be appended to this pending transaction + * The Editables object takes ownership over the Transaction object. + * + * The vector is supposed to be taken "as is" and no snapping shall be applied. + */ + void end_move (const db::DVector &v, db::Transaction *transaction = 0); + /** * @brief Indicates how many objects are selected. * diff --git a/src/laybasic/laybasic/layMove.cc b/src/laybasic/laybasic/layMove.cc index 08310c798..0adad09d3 100644 --- a/src/laybasic/laybasic/layMove.cc +++ b/src/laybasic/laybasic/layMove.cc @@ -91,12 +91,28 @@ void MoveService::function (const std::string &name, const std::string &value) { if (name == move_function_name) { + try { + db::DVector s; tl::from_string (value, s); - tl::info << "@@@ move " << s.to_string (); + + m_dragging = false; + + show_toolbox (false); + ui ()->ungrab_mouse (this); + + mp_editables->end_move (s, mp_transaction.release ()); + + if (m_dragging_transient) { + mp_editables->clear_selection (); + } + + drag_cancel (); + } catch (...) { } + } } @@ -481,8 +497,6 @@ public: virtual void commit (lay::Dispatcher *dispatcher) { - tl::info << "@@@ Commit!"; - try { double dx = 0.0, dy = 0.0; @@ -505,19 +519,14 @@ public: db::DVector mv; tl::from_string (value, mv); - mp_x_le->setText (tl::to_qstring (tl::to_string (mv.x ()))); - mp_y_le->setText (tl::to_qstring (tl::to_string (mv.y ()))); + mp_x_le->setText (tl::to_qstring (tl::micron_to_string (mv.x ()))); + mp_y_le->setText (tl::to_qstring (tl::micron_to_string (mv.y ()))); } catch (...) { } } } - virtual void cancel () - { - tl::info << "@@@ Escape!"; - } - private: QHBoxLayout *mp_layout; QLineEdit *mp_x_le, *mp_y_le;