From e3d63493c79245a232066757f3d48cc15bc809cc Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 24 Feb 2019 14:04:42 +0100 Subject: [PATCH] fixes 0003061: 'Move object after other object' function causes chaos --- src/Mod/PartDesign/Gui/CommandBody.cpp | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index d6eabf7ef7..9351f59877 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -913,6 +913,7 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg) openCommand("Move an object inside tree"); + App::DocumentObject* lastObject = nullptr; for ( auto feat: features ) { if ( feat == target ) continue; @@ -930,9 +931,37 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg) body->getNameInDocument(), feat->getNameInDocument() ); doCommand ( Doc, "App.activeDocument().%s.insertObject(App.activeDocument().%s, %s, True)", body->getNameInDocument(), feat->getNameInDocument(), targetStr.c_str () ); + + if (!lastObject) + lastObject = feat; } updateActive(); + + // If the selected objects have been moved after the current tip then ask the + // user if he wants the last object to be the new tip. + if (lastObject && body->Tip.getValue() == target) { + QMessageBox msgBox(Gui::getMainWindow()); + msgBox.setIcon(QMessageBox::Question); + msgBox.setWindowTitle(qApp->translate("PartDesign_MoveFeatureInTree","Move tip")); + msgBox.setText(qApp->translate("PartDesign_MoveFeatureInTree","The moved feature appears after the currently set tip.")); + msgBox.setInformativeText(qApp->translate("PartDesign_MoveFeatureInTree","Do you want the last feature to be the new tip?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + int ret = msgBox.exec(); + if (ret == QMessageBox::Yes) { + openCommand("Move tip to selected feature"); + + doCommand(Doc,"App.activeDocument().%s.Tip = App.activeDocument().%s", + body->getNameInDocument(), + lastObject->getNameInDocument()); + + // Adjust visibility to show only the Tip feature + doCommand(Gui,"Gui.activeDocument().show(\"%s\")", lastObject->getNameInDocument()); + + updateActive(); + } + } } bool CmdPartDesignMoveFeatureInTree::isActive(void)