From: vsv Date: Fri, 26 Dec 2014 15:38:09 +0000 (+0300) Subject: Switch Wireframe/Shading with closing of context X-Git-Tag: V_0.7.0_rc1~39 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ecec337d46d54cb79cbca6233fb93449513603af;p=modules%2Fshaper.git Switch Wireframe/Shading with closing of context --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 211380338..420487097 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -260,23 +260,4 @@ void ModuleBase_WidgetMultiSelector::updateSelectionList(AttributeSelectionListP AttributeSelectionPtr aAttr = theList->value(i); myListControl->addItem(aAttr->namingName().c_str()); } - //QString aType; - //if (myTypeCombo->currentText().toLower() == "vertices") - // aType = "vertex"; - //else if (myTypeCombo->currentText().toLower() == "edges") - // aType = "edge"; - //else if (myTypeCombo->currentText().toLower() == "faces") - // aType = "face"; - //else if (myTypeCombo->currentText().toLower() == "solids") - // aType = "solid"; - - //myListControl->clear(); - //int i = 1; - //foreach (GeomSelection aSel, mySelection) { - // QString aName(aSel.first->data()->name().c_str()); - // aName += ":" + aType + QString("_%1").arg(i); - // myListControl->addItem(aName); - // i++; - //} - //myListControl->repaint(); } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 94c577a55..5898c252d 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -228,30 +228,38 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation) void PartSet_Module::onSelectionChanged() { ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); + if (!aOperation) + return; + bool isSketcherOp = false; // An edit operation is enable only if the current opeation is the sketch operation - if (aOperation && mySketchMgr->activeSketch()) { + if (mySketchMgr->activeSketch()) { if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch())) isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID()); } - if (!isSketcherOp) - return; - - // Editing of constraints can be done on selection - ModuleBase_ISelection* aSelect = myWorkshop->selection(); - QList aSelected = aSelect->getSelected(); - if (aSelected.size() == 1) { - ModuleBase_ViewerPrs aPrs = aSelected.first(); - ObjectPtr aObject = aPrs.object(); - FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); - if (aFeature) { - std::string aId = aFeature->getKind(); - if ((aId == SketchPlugin_ConstraintRadius::ID()) || - (aId == SketchPlugin_ConstraintLength::ID()) || - (aId == SketchPlugin_ConstraintDistance::ID())) { - editFeature(aFeature); + if (isSketcherOp) { + // Editing of constraints can be done on selection + ModuleBase_ISelection* aSelect = myWorkshop->selection(); + QList aSelected = aSelect->getSelected(); + if (aSelected.size() == 1) { + ModuleBase_ViewerPrs aPrs = aSelected.first(); + ObjectPtr aObject = aPrs.object(); + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (aFeature) { + std::string aId = aFeature->getKind(); + if ((aId == SketchPlugin_ConstraintRadius::ID()) || + (aId == SketchPlugin_ConstraintLength::ID()) || + (aId == SketchPlugin_ConstraintDistance::ID())) { + editFeature(aFeature); + } } } + } else if (mySketchMgr->sketchOperationIdList().contains(aOperation->id()) && + aOperation->isEditOperation()) { + // if this is sketch operation in edit mode + + ModuleBase_ISelection* aSelect = myWorkshop->selection(); + //aSelect->selectedShapes(); } } diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 8f4a49175..dcde2a6b5 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -149,10 +149,12 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const aMenu->addAction(action("EDIT_CMD")); } else { if (aDisplayer->isVisible(aObject)) { - if (aDisplayer->displayMode(aObject) == XGUI_Displayer::Shading) - aMenu->addAction(action("WIREFRAME_CMD")); - else - aMenu->addAction(action("SHADING_CMD")); + if (aDisplayer->canBeShaded(aObject)) { + if (aDisplayer->displayMode(aObject) == XGUI_Displayer::Shading) + aMenu->addAction(action("WIREFRAME_CMD")); + else + aMenu->addAction(action("SHADING_CMD")); + } aMenu->addSeparator(); aMenu->addAction(action("HIDE_CMD")); } else { @@ -206,20 +208,24 @@ void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const // theMenu->addAction(action("EDIT_CMD")); bool isVisible = false; bool isShading = false; + bool canBeShaded = false; foreach(ObjectPtr aObject, aObjects) { ResultPtr aRes = std::dynamic_pointer_cast(aObject); if (aRes && myWorkshop->displayer()->isVisible(aRes)) { isVisible = true; + canBeShaded = myWorkshop->displayer()->canBeShaded(aObject); isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading); break; } } if (isVisible) { - if (isShading) - theMenu->addAction(action("WIREFRAME_CMD")); - else - theMenu->addAction(action("SHADING_CMD")); + if (canBeShaded) { + if (isShading) + theMenu->addAction(action("WIREFRAME_CMD")); + else + theMenu->addAction(action("SHADING_CMD")); + } theMenu->addSeparator(); theMenu->addAction(action("SHOW_ONLY_CMD")); theMenu->addAction(action("HIDE_CMD")); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index c06aae88a..1927d19b8 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -129,7 +129,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!anAISIO.IsNull()) { myResult2AISObjectMap[theObject] = theAIS; - bool aCanBeShaded = canBeShaded(anAISIO); + bool aCanBeShaded = ::canBeShaded(anAISIO); // In order to avoid extra closing/opening context if (aCanBeShaded) closeLocalContexts(false); @@ -606,7 +606,15 @@ void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bo return; Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl(); + bool aCanBeShaded = ::canBeShaded(aAISIO); + // In order to avoid extra closing/opening context + if (aCanBeShaded) + closeLocalContexts(false); aContext->SetDisplayMode(aAISIO, theMode, toUpdate); + if (aCanBeShaded) { + openLocalContext(); + activateObjects(myActiveSelectionModes); + } } XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const @@ -666,3 +674,16 @@ void XGUI_Displayer::showOnly(const QObjectPtrList& theList) } updateViewer(); } + +bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const +{ + if (!isVisible(theObject)) + return false; + + AISObjectPtr aAISObj = getAISObject(theObject); + if (aAISObj.get() == NULL) + return false; + + Handle(AIS_InteractiveObject) anAIS = aAISObj->impl(); + return ::canBeShaded(anAIS); +} diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 176f52bc4..abb82f89d 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -142,6 +142,8 @@ class XGUI_EXPORT XGUI_Displayer /// Returns number of displayed objects int objectsCount() const { return myResult2AISObjectMap.size(); } + bool canBeShaded(ObjectPtr theObject) const; + protected: /// Returns currently installed AIS_InteractiveContext Handle(AIS_InteractiveContext) AISContext() const;