From: vsv Date: Mon, 8 Jul 2019 14:45:51 +0000 (+0300) Subject: Provide pop-up menu for steps X-Git-Tag: VEDF2019Lot4~103^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FDISPLAY_FIELD_STEP;p=modules%2Fshaper.git Provide pop-up menu for steps --- diff --git a/src/ModelAPI/ModelAPI_ResultField.cpp b/src/ModelAPI/ModelAPI_ResultField.cpp index 0b44d8c95..8a997866e 100644 --- a/src/ModelAPI/ModelAPI_ResultField.cpp +++ b/src/ModelAPI/ModelAPI_ResultField.cpp @@ -38,8 +38,25 @@ void ModelAPI_ResultField::ModelAPI_FieldStep::setDisplayed(const bool theDispla static Events_Loop* aLoop = Events_Loop::loop(); static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - if (field()) { - aECreator->sendUpdated(field()->step(id()), EVENT_DISP); // updated pointer to this + ModelAPI_ResultField* aField = field(); + if (aField) { + aECreator->sendUpdated(aField->step(id()), EVENT_DISP); // updated pointer to this + if (myIsDisplayed) { + for (int i = 0; i < aField->stepsSize(); i++) + if (i != id()) + aField->step(i)->setDisplayed(false); + aField->setDisplayed(false); + } } } } + + +void ModelAPI_ResultField::setDisplayed(const bool theDisplay) +{ + ModelAPI_Result::setDisplayed(theDisplay); + if (isDisplayed()) { + for (int i = 0; i < stepsSize(); i++) + step(i)->setDisplayed(false); + } +} diff --git a/src/ModelAPI/ModelAPI_ResultField.h b/src/ModelAPI/ModelAPI_ResultField.h index 09698048d..4e2be6a40 100644 --- a/src/ModelAPI/ModelAPI_ResultField.h +++ b/src/ModelAPI/ModelAPI_ResultField.h @@ -108,6 +108,10 @@ public: /// \param theId an id of the object virtual std::shared_ptr step(int theId) const = 0; + /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay" + /// signal. + MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay); + /// To refresh the steps of a field MODELAPI_EXPORT virtual void updateSteps() = 0; }; diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index e49a994ff..3d47d3cde 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -397,8 +398,9 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe ResultPtr aResult = 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); - hasResult |= (aResult.get() != NULL); + hasResult |= ((aResult.get() != NULL) || (aStep.get() != NULL)); hasFeature |= (aFeature.get() != NULL); hasFolder |= (aFolder.get() != NULL); hasParameter |= (aConstruction.get() != NULL); diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 55006b428..83db1b815 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include @@ -506,8 +507,7 @@ void XGUI_ContextMenuMgr::updateViewerMenu() foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) { aObject = aPrs->object(); GeomShapePtr aShape = aPrs->shape(); - ResultPtr aRes = std::dynamic_pointer_cast(aObject); - if (aRes && aRes->isDisplayed()) { + if (aObject->isDisplayed()) { isVisible = true; canBeShaded = myWorkshop->displayer()->canBeShaded(aObject); isShading = @@ -683,6 +683,13 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("DELETE_CMD")); myObjBrowserMenus[ModelAPI_Folder::group()] = aList; + //--------------------------------------- + // Step objects menu + aList.clear(); + aList.append(action("SHOW_CMD")); + aList.append(action("HIDE_CMD")); + aList.append(action("SHOW_ONLY_CMD")); + myObjBrowserMenus[ModelAPI_ResultField::ModelAPI_FieldStep::group()] = aList; } void XGUI_ContextMenuMgr::buildViewerMenu() @@ -721,6 +728,10 @@ void XGUI_ContextMenuMgr::buildViewerMenu() myViewerMenu[ModelAPI_ResultGroup::group()] = aList; myViewerMenu[ModelAPI_ResultField::group()] = aList; //------------------------------------- + // Step objects menu + aList.clear(); + aList.append(action("HIDE_CMD")); + myViewerMenu[ModelAPI_ResultField::ModelAPI_FieldStep::group()] = aList; } diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 2781c51f6..a83a67251 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -231,70 +231,30 @@ void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex) void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex) { - static Events_Loop* aLoop = Events_Loop::loop(); - static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); - static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - + XGUI_ObjectsBrowser* aObjBrowser = qobject_cast(parent()); XGUI_DataModel* aModel = dataModel(); ObjectPtr aObj = aModel->object(theIndex); if (aObj.get()) { - XGUI_ObjectsBrowser* aObjBrowser = qobject_cast(parent()); - ResultFieldPtr aField = std::dynamic_pointer_cast(aObj); - if (aField.get()) { - bool toDisplay = !aField->isDisplayed(); - aField->setDisplayed(toDisplay); - if (toDisplay) { - for (int i = 0; i < aField->stepsSize(); i++) { - aField->step(i)->setDisplayed(false); - } - } - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - } - else { - FieldStepPtr aStep = - std::dynamic_pointer_cast(aObj); - if (aStep.get()) { - // Only one step from a field can be visible at once - bool toDisplay = !aStep->isDisplayed(); - if (toDisplay) { - int aId = aStep->id(); - ModelAPI_ResultField* aField = aStep->field(); - aField->setDisplayed(false); - for (int i = 0; i < aField->stepsSize(); i++) { - aField->step(i)->setDisplayed(i == aId); - } - } - else { - aStep->setDisplayed(false); - aECreator->sendUpdated(aStep, EVENT_DISP); - } - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - } - else { - ResultPtr aResObj = std::dynamic_pointer_cast(aObj); - if (aResObj.get()) { - std::set anObjects; - anObjects.insert(aResObj); - - bool hasHiddenState = aModel->hasHiddenState(theIndex); - if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects)) - return; - if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem) - if (aResObj->isDisplayed()) - aResObj->setDisplayed(false); - aResObj->setDisplayed(true); - } - else - aResObj->setDisplayed(!aResObj->isDisplayed()); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - } - } + std::set anObjects; + anObjects.insert(aObj); + + bool hasHiddenState = aModel->hasHiddenState(theIndex); + if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects)) + return; + if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem) + if (aObj->isDisplayed()) + aObj->setDisplayed(false); + aObj->setDisplayed(true); } + else + aObj->setDisplayed(!aObj->isDisplayed()); + // Update list of selected objects because this event happens after // selection event in object browser if (aObjBrowser) { aObjBrowser->onSelectionChanged(); } + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); update(theIndex); } } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 1f5794a97..7544b455f 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -2475,11 +2475,6 @@ void XGUI_Workshop::onTransparencyValueChanged() Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } -//************************************************************** -#define SET_DISPLAY_GROUP(aGroupName, aDisplay) \ -for (int i = 0; i < aDoc->size(aGroupName); i++) { \ - aDoc->object(aGroupName, i)->setDisplayed(aDisplay); \ -} //****************************************************** void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)