]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Switch Wireframe/Shading with closing of context
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 26 Dec 2014 15:38:09 +0000 (18:38 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 26 Dec 2014 15:38:09 +0000 (18:38 +0300)
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index 2113803386cf3b49289e117e35dbf50946d2d1b5..4204870979762d92365ea481ea3a52fefba947d7 100644 (file)
@@ -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();
 }
index 94c577a55272a5a9b85722926c92af717655dfad..5898c252db08c15615fadd2313cbaf7cc2f004c2 100644 (file)
@@ -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<ModuleBase_ViewerPrs> 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<ModuleBase_ViewerPrs> 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();
   }
 }
 
index 8f4a49175b051d78f46dfee7224e8db3e184691e..dcde2a6b592a2bc710f42505b8e96983b26fd3d7 100644 (file)
@@ -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<ModelAPI_Result>(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"));
index c06aae88a7d4fbbd78c538005d9aed8ac2c77a27..1927d19b838ff0e48f863b7da004c07872cb2b50 100644 (file)
@@ -129,7 +129,7 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
   Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
   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<Handle(AIS_InteractiveObject)>();
+  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<Handle(AIS_InteractiveObject)>();
+  return ::canBeShaded(anAIS);
+}
index 176f52bc4ee7feda4b1cb925b983068ae9d2871a..abb82f89d27fd329572e4101529337d74cc88332 100644 (file)
@@ -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;