-// Copyright (C) 2014-2022 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
facesPanel()->reset(true);
updateCommandStatus();
+ QObjectPtrList aList = myDisplayer->displayedObjects();
+ foreach(ObjectPtr aObj, aList) {
+ module()->customizePresentation(aObj, myDisplayer->getAISObject(aObj));
+ }
+
// unblock the viewer update functionality and make update on purpose
myDisplayer->enableUpdateViewer(isUpdateEnabled);
myDisplayer->updateViewer();
//******************************************************
void XGUI_Workshop::hidePanel(QDockWidget* theDockWidget)
{
- if (theDockWidget && theDockWidget == myPropertyPanel) {
+ if (!theDockWidget) return;
+
+ if (theDockWidget == myPropertyPanel) {
QAction* aViewAct = theDockWidget->toggleViewAction();
///<! Do not allow to show empty property panel
aViewAct->setEnabled(false);
}
+
theDockWidget->hide();
// the property panel is active window of the desktop, when it is
setDisplayMode(anObjects, XGUI_Displayer::Wireframe);
else if (theId == "SHOW_EDGES_DIRECTION_CMD")
toggleEdgesDirection(anObjects);
+ else if (theId == "BRING_TO_FRONT_CMD")
+ toggleBringToFront(anObjects);
else if (theId == "HIDEALL_CMD") {
QObjectPtrList aList = myDisplayer->displayedObjects();
foreach (ObjectPtr aObj, aList) {
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
bool hasFolder = false;
+ bool hasGroupsOnly = false;
ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner,
- hasResultInHistory, hasFolder);
+ hasResultInHistory, hasFolder, hasGroupsOnly);
if (!(hasResult || hasFeature || hasParameter || hasFolder))
return;
QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
QObjectPtrList aValidatedObjects;
+ std::set<FeaturePtr> aSelectedFeatures;
foreach (ObjectPtr anObject, anObjects) {
if (!myModule->canApplyAction(anObject, anActionId))
continue;
if (anObject->document() != ModelAPI_Session::get()->activeDocument())
continue;
aValidatedObjects.append(anObject);
+ FeaturePtr aFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+ aSelectedFeatures.insert(aFeat);
}
if (aValidatedObjects.size() != anObjects.size())
anObjects = aValidatedObjects;
break;
}
FeaturePtr aFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
- // only groups can be moved to the end for now (#2451)
- if (aFeat.get() && aFeat->getKind() != "Group") {
- aCanMove = false;
- break;
+ // only groups can be moved to the end for now (#2451 old_id, #23105 tuleap id)
+ // and groups created by other groups (#34401)
+ if (aFeat.get()) {
+ std::string aKindOfFeature = aFeat->getKind();
+ if (aKindOfFeature != "Group" &&
+ aKindOfFeature != "GroupSubstraction" &&
+ aKindOfFeature != "GroupAddition" &&
+ aKindOfFeature != "GroupIntersection") {
+ aCanMove = false;
+ break;
+ }
}
+ // Check that the feature can be moved due to its dependencies
+ // i.e. Check that there are no features between the moved one and its destination
+ // with references to it
+ // Details on #21340 (old_id #660)
+ // NOTE: we can ignore dependend features, if they are also moved!
+
// 1. Get features placed between selected and current in the document
std::list<FeaturePtr> aFeaturesBetween = toCurrentFeatures(anObject);
// if aFeaturesBetween is empty it means wrong order or anObject is the current feature
if (aRefFeatures.empty())
continue;
else {
- // 3. Find any placed features in all reference features
+ // 3.1. Check, if any reference feature is going to be moved, too.
+ // If it is, we can ignore its dependency in our subsequent check (3.2)
+ std::set<FeaturePtr> aNoMoveRefFeatures;
+ std::set_difference(aRefFeatures.begin(), aRefFeatures.end(),
+ aSelectedFeatures.begin(), aSelectedFeatures.end(),
+ std::inserter(aNoMoveRefFeatures, aNoMoveRefFeatures.begin()));
+ if (aNoMoveRefFeatures.empty())
+ continue;
+
+ // 3.2. Find any placed features in all remaining (non-moved) reference features
std::set<FeaturePtr> aIntersectionFeatures;
- std::set_intersection(aRefFeatures.begin(), aRefFeatures.end(),
+ std::set_intersection(aNoMoveRefFeatures.begin(), aNoMoveRefFeatures.end(),
aPlacedFeatures.begin(), aPlacedFeatures.end(),
std::inserter(aIntersectionFeatures, aIntersectionFeatures.begin()));
- // 4. Return false if any reference feature is placed before current feature
+ // 4. Return false if any (non-moved) reference feature is placed before current feature
if (!aIntersectionFeatures.empty())
aCanMove = false;
}
myDisplayer->updateViewer();
}
+//**************************************************************
+void XGUI_Workshop::toggleBringToFront(const QObjectPtrList& theList)
+{
+ // Toggle the "BringToFront" state of all objects in the list
+ foreach(ObjectPtr anObj, theList) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+ if (aResult.get() != NULL)
+ {
+ bool aBringToFront = !ModelAPI_Tools::isBringToFront(aResult);
+ ModelAPI_Tools::bringToFront(aResult, aBringToFront);
+ myDisplayer->redisplay(anObj, false);
+ }
+ }
+ if (theList.size() > 0)
+ myDisplayer->updateViewer();
+}
+
//**************************************************************
void XGUI_Workshop::closeDocument()
{