This commit is contained in:
Matthias Koefferlein 2026-01-13 16:21:59 +01:00
parent ee622fc104
commit c2aa597022
13 changed files with 142 additions and 18 deletions

View File

@ -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)
{

View File

@ -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)
*/

View File

@ -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 ()
{

View File

@ -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
*/

View File

@ -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

View File

@ -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
*/

View File

@ -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;
}

View File

@ -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
*/

View File

@ -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 ()) {

View File

@ -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)
*/

View File

@ -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<db::Transaction> 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<db::Transaction> trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Move"))));

View File

@ -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.
*

View File

@ -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;