Preserve object order when moving them
Remove and re-insert the selected objects at the specified point in the tree while preserving their relative order. The code used to insert them in reverse order. Closes #12287
This commit is contained in:
@@ -897,18 +897,17 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg)
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Move an object inside tree"));
|
||||
|
||||
App::DocumentObject* lastObject = nullptr;
|
||||
App::DocumentObject* lastObject = target;
|
||||
for ( auto feat: features ) {
|
||||
if ( feat == target ) continue;
|
||||
|
||||
// Remove and re-insert the feature to/from the Body
|
||||
// Remove and re-insert the feature to/from the Body, preserving their order.
|
||||
// TODO: if tip was moved the new position of tip is quite undetermined (2015-08-07, Fat-Zer)
|
||||
// TODO: warn the user if we are moving an object to some place before the object's link (2015-08-07, Fat-Zer)
|
||||
FCMD_OBJ_CMD(body,"removeObject(" << getObjectCmd(feat) << ")");
|
||||
FCMD_OBJ_CMD(body,"insertObject(" << getObjectCmd(feat) << ","<< getObjectCmd(target) << ", True)");
|
||||
FCMD_OBJ_CMD(body,"insertObject(" << getObjectCmd(feat) << ","<< getObjectCmd(lastObject) << ", True)");
|
||||
|
||||
if (!lastObject)
|
||||
lastObject = feat;
|
||||
lastObject = feat;
|
||||
}
|
||||
|
||||
// Dependency order check.
|
||||
@@ -954,7 +953,7 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg)
|
||||
// If the selected objects have been moved after the current tip then ask the
|
||||
// user if they want the last object to be the new tip.
|
||||
// Only do this for features that can hold a tip (not for e.g. datums)
|
||||
if ( lastObject && body->Tip.getValue() == target
|
||||
if ( lastObject != target && body->Tip.getValue() == target
|
||||
&& lastObject->isDerivedFrom(PartDesign::Feature::getClassTypeId()) ) {
|
||||
QMessageBox msgBox(Gui::getMainWindow());
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
|
||||
Reference in New Issue
Block a user