From 64bd95cebe79a5639800635efb7b0d21f13c079c Mon Sep 17 00:00:00 2001 From: mbs Date: Wed, 4 Jan 2023 20:11:22 +0000 Subject: [PATCH] added the "Bring To Front" command for Groups --- src/Model/Model_Data.cpp | 2 +- src/ModelAPI/ModelAPI_Result.cpp | 9 ++-- src/ModelAPI/ModelAPI_Result.h | 8 +++ src/ModelAPI/ModelAPI_Tools.cpp | 25 ++++++++++ src/ModelAPI/ModelAPI_Tools.h | 8 +++ src/ModuleBase/ModuleBase_Tools.cpp | 8 ++- src/ModuleBase/ModuleBase_Tools.h | 2 +- src/PartSet/PartSet_Module.cpp | 3 +- src/XGUI/XGUI_ContextMenuMgr.cpp | 76 +++++++++++++++++++++++------ src/XGUI/XGUI_ContextMenuMgr.h | 1 + src/XGUI/XGUI_Displayer.cpp | 21 ++++++++ src/XGUI/XGUI_Workshop.cpp | 22 ++++++++- src/XGUI/XGUI_Workshop.h | 3 ++ src/XGUI/XGUI_msg_fr.ts | 4 ++ 14 files changed, 168 insertions(+), 24 deletions(-) diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 00e6defd2..096f015f1 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -466,7 +466,7 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color" || theAttr->id() == "Transparency" || theAttr->id() == "Deflection" || theAttr->id() == "Iso_lines" || theAttr->id() == "Show_Iso_lines" || - theAttr->id() == "Show_Edges_direction")) { + theAttr->id() == "Show_Edges_direction" || theAttr->id() == "Bring_To_Front")) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); } diff --git a/src/ModelAPI/ModelAPI_Result.cpp b/src/ModelAPI/ModelAPI_Result.cpp index a225fe950..04632b4ea 100644 --- a/src/ModelAPI/ModelAPI_Result.cpp +++ b/src/ModelAPI/ModelAPI_Result.cpp @@ -39,10 +39,11 @@ void ModelAPI_Result::initAttributes() aData->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false); aData->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false); aData->addAttribute(ISO_LINES_ID(), ModelAPI_AttributeIntArray::typeId())->setIsArgument(false); - aData->addAttribute(SHOW_ISO_LINES_ID(), ModelAPI_AttributeBoolean::typeId())-> - setIsArgument(false); - aData->addAttribute(SHOW_EDGES_DIRECTION_ID(), ModelAPI_AttributeBoolean::typeId())-> - setIsArgument(false); + aData->addAttribute(SHOW_ISO_LINES_ID(), ModelAPI_AttributeBoolean::typeId())->setIsArgument(false); + aData->addAttribute(SHOW_EDGES_DIRECTION_ID(), ModelAPI_AttributeBoolean::typeId())->setIsArgument(false); + // Add the "Bring To Front" attribute to the Result base class, as we may support it in the future + // for all type of results. Actually, only ResultGroups are supported. + aData->addAttribute(BRING_TO_FRONT_ID(), ModelAPI_AttributeBoolean::typeId())->setIsArgument(false); } bool ModelAPI_Result::setDisabled(std::shared_ptr theThis, const bool theFlag) diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h index 778529c22..88caeb55c 100644 --- a/src/ModelAPI/ModelAPI_Result.h +++ b/src/ModelAPI/ModelAPI_Result.h @@ -87,6 +87,14 @@ class ModelAPI_Result : public ModelAPI_Object return MY_SHOW_EDGES_DIRECTION_ID; } + /// Reference to the BringToFront flag of the result. + /// The bool value is used. + inline static const std::string& BRING_TO_FRONT_ID() + { + static const std::string MY_BRING_TO_FRONT_ID("Bring_To_Front"); + return MY_BRING_TO_FRONT_ID; + } + /// Returns true if the result is concealed from the data tree (referenced by other objects) MODELAPI_EXPORT virtual bool isConcealed(); diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 84c5de685..2c2a9b654 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -1194,6 +1194,31 @@ bool isShowEdgesDirection(std::shared_ptr theResult) return false; } +//****************************************************** +void bringToFront(std::shared_ptr theResult, bool theFlag) +{ + if (!theResult.get()) + return; + + AttributeBooleanPtr aAttr = theResult->data()->boolean(ModelAPI_Result::BRING_TO_FRONT_ID()); + if (aAttr.get() != NULL) { + aAttr->setValue(theFlag); + } +} + +//****************************************************** +bool isBringToFront(std::shared_ptr theResult) +{ + if (!theResult.get()) + return false; + + AttributeBooleanPtr aAttr = theResult->data()->boolean(ModelAPI_Result::BRING_TO_FRONT_ID()); + if (aAttr.get() != NULL) { + return aAttr->value(); + } + return false; +} + //************************************************************** void setTransparency(ResultPtr theResult, double theTransparency) { diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index 83a1e010e..8a2e7eec1 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -312,6 +312,14 @@ MODELAPI_EXPORT void showEdgesDirection(std::shared_ptr theResu MODELAPI_EXPORT bool isShowEdgesDirection(std::shared_ptr theResult); +/*! Set flag to bring result in front of other results +* \param[in] theResult a result object +* \param[in] theFlag is a flag +*/ +MODELAPI_EXPORT void bringToFront(std::shared_ptr theResult, bool theFlag); + +MODELAPI_EXPORT bool isBringToFront(std::shared_ptr theResult); + /*! Returns current transparency in the given result * \param theResult a result object * \return a transparency value or -1 if it was not defined diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 2245d51e0..60c1bb579 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -446,7 +446,7 @@ int shapeType(const QString& theType) void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory, - bool& hasFolder) + bool& hasFolder, bool &hasGroupsOnly) { hasResult = false; hasFeature = false; @@ -454,9 +454,11 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe hasCompositeOwner = false; hasResultInHistory = false; hasFolder = false; + bool hasNonGroup = false; foreach(ObjectPtr aObj, theObjects) { FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); ResultPtr aResult = std::dynamic_pointer_cast(aObj); + ResultGroupPtr aGroup = std::dynamic_pointer_cast(aObj); FolderPtr aFolder = std::dynamic_pointer_cast(aObj); ResultParameterPtr aConstruction = std::dynamic_pointer_cast(aResult); FieldStepPtr aStep = std::dynamic_pointer_cast(aObj); @@ -465,6 +467,7 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe hasFeature |= (aFeature.get() != NULL); hasFolder |= (aFolder.get() != NULL); hasParameter |= (aConstruction.get() != NULL); + hasNonGroup |= (aGroup.get() == NULL); if (hasFeature) hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL); else if (aResult.get()) @@ -475,9 +478,10 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe hasResultInHistory = aFeature.get() && aFeature->isInHistory(); } - if (hasFeature && hasResult && hasParameter && hasCompositeOwner) + if (hasFeature && hasResult && hasParameter && hasCompositeOwner && hasNonGroup) break; } + hasGroupsOnly = !hasNonGroup; } void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape, diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index d3f1914fe..d5be417ec 100644 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -189,7 +189,7 @@ MODULEBASE_EXPORT bool isSubResult(ObjectPtr theObject); /// \param hasFolder will be set to true if one of folder is in the list MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasCompositeOwner, - bool& hasResultInHistory, bool& hasFolder); + bool& hasResultInHistory, bool& hasFolder, bool &hasGroupsOnly); /// Sets the default coeffient into the driver calculated accordingly the shape type. /// It provides 1.e-4 for results of construction type diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index eb8cf5589..76bafe5f6 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1598,8 +1598,9 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const bool hasCompositeOwner = false; bool hasResultInHistory = false; bool hasFolder = false; + bool hasGroupsOnly = false; ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, - hasCompositeOwner, hasResultInHistory, hasFolder); + hasCompositeOwner, hasResultInHistory, hasFolder, hasGroupsOnly); ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation(); if (aSelected == 1) { diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index e42131d55..49c2a4d0d 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -170,6 +170,10 @@ void XGUI_ContextMenuMgr::createActions() anAction->setCheckable(true); addAction("SHOW_ISOLINES_CMD", anAction); + anAction = ModuleBase_Tools::createAction(QIcon(), tr("Bring To Front"), aDesktop); + anAction->setCheckable(true); + addAction("BRING_TO_FRONT_CMD", anAction); + mySeparator1 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop); mySeparator1->setSeparator(true); @@ -179,6 +183,9 @@ void XGUI_ContextMenuMgr::createActions() mySeparator3 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop); mySeparator3->setSeparator(true); + mySeparator4 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop); + mySeparator4->setSeparator(true); + anAction = ModuleBase_Tools::createAction(QIcon(":pictures/vertex.png"), tr("Vertices"), aDesktop, this, SLOT(onShapeSelection(bool))); anAction->setCheckable(true); @@ -327,8 +334,9 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() bool hasCompositeOwner = false; bool hasResultInHistory = false; bool hasFolder = false; + bool hasGroupsOnly = false; ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, - hasCompositeOwner, hasResultInHistory, hasFolder); + hasCompositeOwner, hasResultInHistory, hasFolder, hasGroupsOnly); //Process Feature if (aSelected == 1) { // single selection ObjectPtr aObject = aObjects.first(); @@ -348,6 +356,9 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true); action("SHOW_EDGES_DIRECTION_CMD")->setChecked(ModelAPI_Tools::isShowEdgesDirection(aResult)); + action("BRING_TO_FRONT_CMD")->setEnabled(hasGroupsOnly); + action("BRING_TO_FRONT_CMD")->setChecked(ModelAPI_Tools::isBringToFront(aResult)); + action("SHOW_ISOLINES_CMD")->setEnabled(true); action("SHOW_ISOLINES_CMD")->setChecked(ModelAPI_Tools::isShownIsoLines(aResult)); action("ISOLINES_CMD")->setEnabled(true); @@ -405,6 +416,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("SHADING_CMD")->setEnabled(true); action("WIREFRAME_CMD")->setEnabled(true); action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true); + action("BRING_TO_FRONT_CMD")->setEnabled(hasGroupsOnly); action("SHOW_ISOLINES_CMD")->setEnabled(true); action("ISOLINES_CMD")->setEnabled(true); } @@ -603,6 +615,11 @@ void XGUI_ContextMenuMgr::updateViewerMenu() action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true); action("SHOW_EDGES_DIRECTION_CMD")->setChecked( ModelAPI_Tools::isShowEdgesDirection(aResult)); + + // Only enable the "Bring To Front" command for Groups + ResultGroupPtr aGroup = std::dynamic_pointer_cast(aResult); + action("BRING_TO_FRONT_CMD")->setEnabled(aGroup.get() != NULL); + action("BRING_TO_FRONT_CMD")->setChecked(ModelAPI_Tools::isBringToFront(aResult)); } } } @@ -690,6 +707,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() QActionsList aList; + //------------------------------------- // Result construction menu aList.append(action("SHOW_CMD")); aList.append(action("HIDE_CMD")); @@ -705,7 +723,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList; //------------------------------------- - // Result body menu + // Result body/field/part menu aList.clear(); aList.append(action("WIREFRAME_CMD")); aList.append(action("SHADING_CMD")); @@ -725,22 +743,26 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("SHOW_FEATURE_CMD")); aList.append(mySeparator3); aList.append(action("DELETE_CMD")); + // Result body menu myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList; - // Group menu + // Field menu myObjBrowserMenus[ModelAPI_ResultField::group()] = aList; // Result part menu myObjBrowserMenus[ModelAPI_ResultPart::group()] = aList; + //------------------------------------- + // Group menu aList.clear(); aList.append(action("WIREFRAME_CMD")); aList.append(action("SHADING_CMD")); aList.append(action("SHOW_EDGES_DIRECTION_CMD")); - aList.append(mySeparator1); // this separator is not shown as this action is added after show only - // qt list container contains only one instance of the same action + aList.append(mySeparator1); + aList.append(action("BRING_TO_FRONT_CMD")); + aList.append(mySeparator2); aList.append(action("SHOW_CMD")); aList.append(action("HIDE_CMD")); aList.append(action("SHOW_ONLY_CMD")); - aList.append(mySeparator2); + aList.append(mySeparator3); aList.append(action("AUTOCOLOR_CMD")); aList.append(action("RENAME_CMD")); aList.append(action("COLOR_CMD")); @@ -749,10 +771,10 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("SHOW_ISOLINES_CMD")); aList.append(action("ISOLINES_CMD")); aList.append(action("SHOW_FEATURE_CMD")); - aList.append(mySeparator3); + aList.append(mySeparator4); aList.append(action("DELETE_CMD")); - // Group menu myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList; + //------------------------------------- // Feature menu aList.clear(); @@ -773,14 +795,17 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("DELETE_CMD")); myObjBrowserMenus[ModelAPI_Feature::group()] = aList; + //------------------------------------- + // Parameter menu aList.clear(); aList.append(action("RENAME_CMD")); aList.append(mySeparator1); aList.append(action("CLEAN_HISTORY_CMD")); aList.append(action("DELETE_CMD")); myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList; - //------------------------------------- + //------------------------------------- + // Folder menu aList.clear(); aList.append(action("RENAME_CMD")); aList.append(action("DELETE_CMD")); @@ -798,7 +823,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() void XGUI_ContextMenuMgr::buildViewerMenu() { QActionsList aList; - // Result construction menu + // Result construction/part menu aList.append(action("COLOR_CMD")); aList.append(action("DEFLECTION_CMD")); aList.append(action("TRANSPARENCY_CMD")); @@ -809,8 +834,8 @@ void XGUI_ContextMenuMgr::buildViewerMenu() aList.append(action("SHOW_ONLY_CMD")); aList.append(action("HIDE_CMD")); myViewerMenu[ModelAPI_ResultConstruction::group()] = aList; - // Result part menu myViewerMenu[ModelAPI_ResultPart::group()] = aList; + //------------------------------------- // Result body menu aList.clear(); @@ -830,9 +855,30 @@ void XGUI_ContextMenuMgr::buildViewerMenu() aList.append(action("SHOW_ONLY_CMD")); aList.append(action("HIDE_CMD")); myViewerMenu[ModelAPI_ResultBody::group()] = aList; + myViewerMenu[ModelAPI_ResultField::group()] = aList; + + //------------------------------------- // Group menu + aList.clear(); + aList.append(action("WIREFRAME_CMD")); + aList.append(action("SHADING_CMD")); + aList.append(action("SHOW_EDGES_DIRECTION_CMD")); + aList.append(mySeparator1); + aList.append(action("BRING_TO_FRONT_CMD")); + aList.append(mySeparator2); + aList.append(action("COLOR_CMD")); + aList.append(action("DEFLECTION_CMD")); + aList.append(action("TRANSPARENCY_CMD")); + aList.append(action("SHOW_ISOLINES_CMD")); + aList.append(action("ISOLINES_CMD")); + aList.append(mySeparator3); + aList.append(action("SET_VIEW_NORMAL_CMD")); + aList.append(action("SET_VIEW_INVERTEDNORMAL_CMD")); + aList.append(mySeparator4); + aList.append(action("SHOW_ONLY_CMD")); + aList.append(action("HIDE_CMD")); myViewerMenu[ModelAPI_ResultGroup::group()] = aList; - myViewerMenu[ModelAPI_ResultField::group()] = aList; + //------------------------------------- // Step objects menu aList.clear(); @@ -863,15 +909,17 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const anActions.append(action("SHADING_CMD")); anActions.append(action("SHOW_EDGES_DIRECTION_CMD")); anActions.append(mySeparator1); + anActions.append(action("BRING_TO_FRONT_CMD")); + anActions.append(mySeparator2); anActions.append(action("SHOW_CMD")); anActions.append(action("HIDE_CMD")); anActions.append(action("SHOW_ONLY_CMD")); - anActions.append(mySeparator2); + anActions.append(mySeparator3); anActions.append(action("ADD_TO_FOLDER_BEFORE_CMD")); anActions.append(action("ADD_TO_FOLDER_AFTER_CMD")); anActions.append(action("ADD_OUT_FOLDER_BEFORE_CMD")); anActions.append(action("ADD_OUT_FOLDER_AFTER_CMD")); - anActions.append(mySeparator3); + anActions.append(mySeparator4); anActions.append(action("MOVE_CMD")); anActions.append(action("MOVE_SPLIT_CMD")); anActions.append(action("COLOR_CMD")); diff --git a/src/XGUI/XGUI_ContextMenuMgr.h b/src/XGUI/XGUI_ContextMenuMgr.h index 686f44ccc..cb448b12d 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.h +++ b/src/XGUI/XGUI_ContextMenuMgr.h @@ -144,6 +144,7 @@ signals: QAction* mySeparator1; QAction* mySeparator2; QAction* mySeparator3; + QAction* mySeparator4; }; #endif diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 8fda4fb34..2a7b07c1d 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -95,6 +96,12 @@ /// defines the local context mouse selection sensitivity const int MOUSE_SENSITIVITY_IN_PIXEL = 10; +/// defines the display priority for results brought to front +constexpr int FRONT_DISPLAY_PRIORITY = 8; /* = Graphic3d_DisplayPriority_Highlight-1 */ + +/// defines the default (normal) display priority for all results +constexpr int DEFAULT_DISPLAY_PRIORITY = 5; /* = Graphic3d_DisplayPriority_Normal */ + //#define DEBUG_DISPLAY //#define DEBUG_FEATURE_REDISPLAY //#define DEBUG_SELECTION_FILTERS @@ -215,6 +222,13 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, int aDispMode = isShading? Shading : Wireframe; anAISIO->SetDisplayMode(aDispMode); aContext->Display(anAISIO, aDispMode, 0, false, AIS_DS_Displayed); + ResultPtr aResult = std::dynamic_pointer_cast(theObject); + if (ModelAPI_Tools::isBringToFront(aResult)) { + // NOTE: do not use a priority higher than 8 as highlight uses priority 9! + // Any higher level prevents the highlight from being visible as it would + // appear "behind" the Groups. + aContext->SetDisplayPriority(anAISIO, FRONT_DISPLAY_PRIORITY); + } #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(anAISIO); #endif @@ -329,6 +343,13 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO); if (!aResPrs.IsNull()) aResPrs->updateIsoLines(); + + // Only support the "Bring To Front" command for Groups (for now) + ResultGroupPtr aGroup = std::dynamic_pointer_cast(aResult); + if (aGroup.get()) { + bool isInFront = ModelAPI_Tools::isBringToFront(aResult); + aContext->SetDisplayPriority(aAISIO, (isInFront ? FRONT_DISPLAY_PRIORITY : DEFAULT_DISPLAY_PRIORITY)); + } } //myWorkshop->module()->storeSelection(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 124ac7bc1..4d6efbfc9 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1827,6 +1827,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) 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) { @@ -2034,8 +2036,9 @@ void XGUI_Workshop::deleteObjects() 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; @@ -3086,6 +3089,23 @@ void XGUI_Workshop::toggleEdgesDirection(const QObjectPtrList& theList) 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(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() { diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 81145343e..aa12b955a 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -239,6 +239,9 @@ Q_OBJECT /// Toggle visualisation of edges direction void toggleEdgesDirection(const QObjectPtrList& theList); + /// Toggle state of display priority (normal/in front) + void toggleBringToFront(const QObjectPtrList& theList); + /// Set selection mode in viewer. If theMode=-1 then activate default mode /// \param theMode the selection mode (according to TopAbs_ShapeEnum) void setViewerSelectionMode(int theMode); diff --git a/src/XGUI/XGUI_msg_fr.ts b/src/XGUI/XGUI_msg_fr.ts index 16f7ea842..9d89050d2 100644 --- a/src/XGUI/XGUI_msg_fr.ts +++ b/src/XGUI/XGUI_msg_fr.ts @@ -232,6 +232,10 @@ Show edges direction Afficher la direction des bords + + Bring To Front + Afficher au premier plan + XGUI_DataTree -- 2.39.2