]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3060: Use HideFaces panel for groups creation operation
authorvsv <vsv@opencascade.com>
Wed, 20 Nov 2019 13:54:19 +0000 (16:54 +0300)
committervsv <vsv@opencascade.com>
Wed, 20 Nov 2019 13:55:31 +0000 (16:55 +0300)
15 files changed:
src/CollectionPlugin/plugin-Collection.xml
src/Config/Config_FeatureMessage.cpp
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_Keywords.h
src/ModuleBase/ModuleBase_ListView.cpp
src/ModuleBase/ModuleBase_ListView.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h
src/XGUI/XGUI_FacesPanel.cpp
src/XGUI/XGUI_FacesPanel.h
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Workshop.cpp

index a02f0bf2fb81c8b901d93f71b50aa83efe1d1043..ea913123b87290bd257e49b2f009961753ef997d 100644 (file)
@@ -18,7 +18,8 @@
         tooltip="Create named collection of geometry entities"
         icon="icons/Collection/shape_group.png"
         apply_continue="true"
-        helpfile="groupFeature.html">
+        helpfile="groupFeature.html"
+        hidefaces_panel="true">
         <source path="group_widget.xml"/>
       </feature>
 
index 47baeae2ee4da30faf6e77d3bb567fcf84bdd26e..4728b95f8ea3beb98419f64cbbbc96bfa02e3620 100644 (file)
@@ -40,6 +40,7 @@ Config_FeatureMessage::Config_FeatureMessage(const Events_ID theId, const void*
   myModal = false;
   myIsTitleInToolbar = true;
   myIsApplyContinue = false;
+  myHideFacesPanel = false;
 }
 
 Config_FeatureMessage::~Config_FeatureMessage()
@@ -238,3 +239,14 @@ void Config_FeatureMessage::setTitleInToolbar(bool theValue)
 {
   myIsTitleInToolbar = theValue;
 }
+
+bool Config_FeatureMessage::isHideFacesPanel() const
+{
+  return myHideFacesPanel;
+}
+
+
+void Config_FeatureMessage::setHideFacesPanel(bool theValue)
+{
+  myHideFacesPanel = theValue;
+}
index a027bec60b1df6e551dfa516bfba51af2f57ac00..89b7ada656742febd7fb5ef7cfbecf2112a1e721 100644 (file)
@@ -55,6 +55,7 @@ class Config_FeatureMessage : public Events_Message
   bool myModal;     ///<True if the feature has to be represented by modal dialog box
   bool myIsAutoPreview; ///< Preview computation is performed automatically
   bool myIsTitleInToolbar; ///< False if title should not be displayed in the toolbar
+  bool myHideFacesPanel; ///< Show or Hide HideFaces panel. By default is False
 
   /// True if the feature can have Apply/Continue button in its property panel
   bool myIsApplyContinue;
@@ -120,6 +121,8 @@ class Config_FeatureMessage : public Events_Message
   CONFIG_EXPORT bool isAutoPreview() const;
   /// If true - title should normally be displayed in the toolbar
   CONFIG_EXPORT bool isTitleInToolbar() const;
+  /// If true - then HideFaces panel has to be shown
+  CONFIG_EXPORT bool isHideFacesPanel() const;
 
   ///Set feature's Id
   CONFIG_EXPORT void setId(const std::string& id);
@@ -157,6 +160,8 @@ class Config_FeatureMessage : public Events_Message
   CONFIG_EXPORT void setModal(bool isModal);
   ///Set flag to display title in toolbar
   CONFIG_EXPORT void setTitleInToolbar(bool theValue);
+  ///Set flag to display title in toolbar
+  CONFIG_EXPORT void setHideFacesPanel(bool theValue);
   ///Set Apply/Continue state;
   ///If true - the feature can have Apply/Continue button in its property panel
   CONFIG_EXPORT void setApplyContinue(bool isModal);
index d983afb08b123ce2bd783102536785450d6cbffd..512137c922ebf1ac78d0b5bbe4c188fd9976352f 100644 (file)
@@ -179,6 +179,9 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode,
   if (!aHelpFile.empty())
     outFeatureMessage->setHelpFileName(myLibraryName + "/" + aHelpFile);
 
+  bool isHideFaces = getBooleanAttribute(theFeatureNode, HIDEFACES_PANEL, false);
+  outFeatureMessage->setHideFacesPanel(isHideFaces);
+
   //if (isInternal) {
   //  //Internal feature has no visual representation.
   //  return;
index 5637a989181b0f91a3c55d594435066d2e455d35..70ca0db2ad5a71b82ced91739e2ad1a8efd04e74 100644 (file)
@@ -78,6 +78,7 @@ const static char* GROUP_TOOLBAR = "toolbar";
 const static char* FEATURE_ICON = "icon";
 const static char* FEATURE_TEXT = "title";
 const static char* HELP_FILE = "helpfile";
+const static char* HIDEFACES_PANEL = "hidefaces_panel";
 const static char* FEATURE_KEYSEQUENCE = "keysequence";
 const static char* FEATURE_NESTED = "nested";
 const static char* FEATURE_WHEN_NESTED = "when_nested";
index d9fe13d2c18339a17daaafebe041484adacb8e43..5fd8909eefb4374cf7f6a24549fe17f26668cc24 100644 (file)
@@ -77,6 +77,19 @@ void ModuleBase_ListView::getSelectedIndices(std::set<int>& theIndices)
   }
 }
 
+//********************************************************************
+void  ModuleBase_ListView::selectIndices(const std::set<int>& theIndices)
+{
+  myListControl->clearSelection();
+  for (int i = 0; i < myListControl->count(); i++) {
+    QListWidgetItem* anItem = myListControl->item(i);
+    int aId = anItem->data(ATTRIBUTE_SELECTION_INDEX_ROLE).toInt();
+    if (theIndices.find(aId) != theIndices.end()) {
+      anItem->setSelected(true);
+    }
+  }
+}
+
 //********************************************************************
 void ModuleBase_ListView::removeSelectedItems()
 {
index aa973845e1c4ce44c5058e03ed309a308182eead..aa0620e9045471dbac2eb42f2e0d66d69f2daded 100644 (file)
@@ -118,6 +118,10 @@ public:
   /// \param theIndices an output container for indices
   void getSelectedIndices(std::set<int>& theIndices);
 
+  /// Selects items with indices
+  /// \param theIndices indices
+  void selectIndices(const std::set<int>& theIndices);
+
   /// Removes selected items from the list widget
   void removeSelectedItems();
 
index b4f4a38b05296e9a20a94d30cabc41198ee4a188..3055865095ba713812211ba3a28ee2a5289516fc 100644 (file)
@@ -50,7 +50,8 @@
 ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent)
     : QObject(theParent),
       myIsModified(false),
-      myPropertyPanel(NULL)
+      myPropertyPanel(NULL),
+  myHideFacesVisibilityState(false)
 {
   myDescription = new ModuleBase_OperationDescription(theId);
 }
index 845f6368608e555ef9890aa7b0fcba0ed7fda172..ecc4c7c079de77230bd43f08be0efa3fbb05bb8b 100644 (file)
@@ -105,6 +105,10 @@ Q_OBJECT
     myHelpFileName = theName;
   }
 
+  void setHideFacesVisible(bool isVisible) { myHideFacesVisibilityState = isVisible; }
+
+  bool isHideFacesVisible() const { return myHideFacesVisibilityState; }
+
 signals:
   /// The operation is started
   void beforeStarted();
@@ -209,6 +213,9 @@ private:
   ModuleBase_IPropertyPanel* myPropertyPanel;
 
   QString myHelpFileName;
+
+  /// Visibility state of HideFaces panel before the operation launch
+  bool myHideFacesVisibilityState;
 };
 
 #endif
index e2d35c87b2a8111facc8ebd31d15db737b151aee..9bf101d3ffffb9612aa9310509d56485afcf38c0 100644 (file)
@@ -145,7 +145,7 @@ void ModuleBase_ResultPrs::setEdgesDefaultColor()
 
 
 //********************************************************************
-bool ModuleBase_ResultPrs::setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes)
+void ModuleBase_ResultPrs::setSubShapeHidden(const TopoDS_ListOfShape& theShapes)
 {
   bool isModified = false;
 
@@ -153,48 +153,16 @@ bool ModuleBase_ResultPrs::setSubShapeHidden(const NCollection_List<TopoDS_Shape
   BRep_Builder aBBuilder;
   aBBuilder.MakeCompound (aCompound);
 
-  TopoDS_Compound aShownComp;
-  if (myIsSubstituted)
-    aShownComp = TopoDS::Compound(Shape());
+  myHiddenSubShapes = theShapes;
+  collectSubShapes(aBBuilder, aCompound, myOriginalShape, myHiddenSubShapes);
+  myVisibleCompound = aCompound;
 
-  // restore hidden shapes if there are not the shapes in parameter container
-  NCollection_List<TopoDS_Shape> aVisibleSubShapes;
-  NCollection_List<TopoDS_Shape>::Iterator aHiddenIt(myHiddenSubShapes);
-  for (; aHiddenIt.More(); aHiddenIt.Next()) {
-    if (!theShapes.Contains(aHiddenIt.Value())) {
-      aVisibleSubShapes.Append(aHiddenIt.Value());
-    }
-    else {
-      aBBuilder.Add(aCompound, aHiddenIt.Value());
-      if (!aShownComp.IsNull())
-        aBBuilder.Remove(aShownComp, aHiddenIt.Value());
-    }
-  }
-  isModified = !aVisibleSubShapes.IsEmpty();
-  NCollection_List<TopoDS_Shape>::Iterator aVisibleIt(aVisibleSubShapes);
-  for (; aVisibleIt.More(); aVisibleIt.Next()) {
-    if (myHiddenSubShapes.Contains(aVisibleIt.Value())) {
-      myHiddenSubShapes.Remove(aVisibleIt.Value());
-      if (!aShownComp.IsNull())
-        aBBuilder.Add(aShownComp, aVisibleIt.Value());
-    }
-  }
-  // append hidden shapes into internal container if there are not these shapes
-  NCollection_List<TopoDS_Shape>::Iterator aShapeIt(theShapes);
-  for (; aShapeIt.More(); aShapeIt.Next()) {
-    if (aShapeIt.Value().ShapeType() != TopAbs_FACE) // only face shape can be hidden
-      continue;
-
-    if (!myHiddenSubShapes.Contains(aShapeIt.Value())) {
-      myHiddenSubShapes.Append(aShapeIt.Value());
-      aBBuilder.Add (aCompound, aShapeIt.Value());
-      if (!aShownComp.IsNull())
-        aBBuilder.Remove(aShownComp, aShapeIt.Value());
-      isModified = true;
-    }
+  aBBuilder.MakeCompound (aCompound);
+  TopoDS_ListOfShape::Iterator aIt(myHiddenSubShapes);
+  for (; aIt.More(); aIt.Next()) {
+    aBBuilder.Add(aCompound, aIt.Value());
   }
   myHiddenCompound = aCompound;
-  return isModified;
 }
 
 //********************************************************************
@@ -204,9 +172,8 @@ bool ModuleBase_ResultPrs::isSubShapeHidden(const TopoDS_Shape& theShape)
     return false;
 
   // orientation of parameter shape(come from selection) may be wrong, check isEqual() to be sure
-  for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt(myHiddenSubShapes); aShapeIt.More();
-    aShapeIt.Next())
-  {
+  TopoDS_ListOfShape::Iterator aShapeIt(myHiddenSubShapes);
+  for (; aShapeIt.More(); aShapeIt.Next()) {
     if (theShape.IsSame(aShapeIt.Value()))
       return true;
   }
@@ -216,14 +183,15 @@ bool ModuleBase_ResultPrs::isSubShapeHidden(const TopoDS_Shape& theShape)
 
 //********************************************************************
 bool ModuleBase_ResultPrs::hasSubShapeVisible(
-  const NCollection_List<TopoDS_Shape>& theShapesToSkip)
+  const TopoDS_ListOfShape& theShapesToSkip)
 {
   TopoDS_Compound aCompound;
   BRep_Builder aBuilder;
   aBuilder.MakeCompound (aCompound);
-  NCollection_List<TopoDS_Shape> aShapesToSkip;
-  aShapesToSkip.Append(myHiddenSubShapes);
-  for (NCollection_List<TopoDS_Shape>::Iterator anIt(theShapesToSkip); anIt.More(); anIt.Next())
+  TopoDS_ListOfShape aShapesToSkip;
+  TopoDS_ListOfShape aHiddenCopy(myHiddenSubShapes);
+  aShapesToSkip.Append(aHiddenCopy);
+  for (TopoDS_ListOfShape::Iterator anIt(theShapesToSkip); anIt.More(); anIt.Next())
     aShapesToSkip.Append(anIt.Value());
 
   collectSubShapes(aBuilder, aCompound, myOriginalShape, aShapesToSkip);
@@ -258,17 +226,8 @@ void ModuleBase_ResultPrs::Compute(
       }
     }
     else { // convert shape into SHELL
-      TopoDS_Compound aCompound;
-      if (!myIsSubstituted) {
-        BRep_Builder aBuilder;
-        aBuilder.MakeCompound(aCompound);
-        collectSubShapes(aBuilder, aCompound, myOriginalShape, myHiddenSubShapes);
-      }
-      else {
-        aCompound = TopoDS::Compound(Shape());
-      }
-      bool isEmptyShape = BOPTools_AlgoTools3D::IsEmptyShape(aCompound);
-      Set(aCompound);
+      bool isEmptyShape = BOPTools_AlgoTools3D::IsEmptyShape(myVisibleCompound);
+      Set(myVisibleCompound);
       myIsSubstituted = true;
       if (isEmptyShape)
         aReadyToDisplay = false;
@@ -301,7 +260,7 @@ void ModuleBase_ResultPrs::Compute(
 //********************************************************************
 void ModuleBase_ResultPrs::collectSubShapes(BRep_Builder& theBuilder,
   TopoDS_Shape& theCompound, const TopoDS_Shape& theShape,
-  const NCollection_List<TopoDS_Shape>& theHiddenSubShapes)
+  const TopoDS_ListOfShape& theHiddenSubShapes)
 {
   switch (theShape.ShapeType()) {
     case TopAbs_COMPSOLID:
index 1868ad8dbb4c2ada4fe36872510f02f161f053f5..84500eba65dfff600d2f6cbad61b76defbefa624 100644 (file)
@@ -91,17 +91,21 @@ public:
   /// Visual state of the face is controlled by the second parameter
   /// \param theShapes a container of shape objects
   /// \returns true if the presentation is changed, or false (if for example it was hidden)
-  Standard_EXPORT bool setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes);
+  Standard_EXPORT void setSubShapeHidden(const TopoDS_ListOfShape& theShapes);
 
   /// Returns true if parameter shape has been hidden
   /// \param theShape sub-shape of the presentation shape
   /// \return boolean value
   Standard_EXPORT bool isSubShapeHidden(const TopoDS_Shape& theShape);
 
+  /// Returns hidden sub shapes list
+  Standard_EXPORT const TopoDS_ListOfShape& hiddenSubShapes() const
+  { return myHiddenSubShapes; }
+
   /// Returns true if there are no hidden sub shapes or original shape has at least one not hidden
   /// \param theShapesToSkip container of shape to be hidden in the presentation (faces)
   /// \return boolean value
-  Standard_EXPORT bool hasSubShapeVisible(const NCollection_List<TopoDS_Shape>& theShapesToSkip);
+  Standard_EXPORT bool hasSubShapeVisible(const TopoDS_ListOfShape& theShapesToSkip);
 
   /// Set transparency of hidden sub shapes: if value is 1, shapes are entirely hidden
   /// \param theTransparency transparency value
@@ -144,7 +148,7 @@ private:
   /// \param theShape the processed shape
   /// \param theHiddenSubShapes container of shapes to be skipped (faces)
   void collectSubShapes(BRep_Builder& theBuilder, TopoDS_Shape& theCompound,
-    const TopoDS_Shape& theShape, const NCollection_List<TopoDS_Shape>& theHiddenSubShapes);
+    const TopoDS_Shape& theShape, const TopoDS_ListOfShape& theHiddenSubShapes);
 
   void setEdgesDefaultColor();
 
@@ -158,7 +162,8 @@ private:
   bool myIsSubstituted;
 
   /// Container of original Shape sub shape to be hidden and not selectable
-  NCollection_List<TopoDS_Shape> myHiddenSubShapes;
+  TopoDS_ListOfShape myHiddenSubShapes;
+  TopoDS_Compound myVisibleCompound; /// compound of hidden sub shapes
   TopoDS_Compound myHiddenCompound; /// compound of hidden sub shapes
   double myTransparency; ///< transparency of hidden shapes, where 0 - there is no transparency
   Handle(AIS_ColoredDrawer) myHiddenSubShapesDrawer; ///< drawer for hidden sub shapes
index d92ae5669053b9799e40617da2307bf3e1d137fb..b8fba2d25fe7cbbb858df23cf91b8d805613aa40 100644 (file)
 #include "XGUI_FacesPanel.h"
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_SelectionMgr.h"
+#include "XGUI_Selection.h"
 #include "XGUI_Tools.h"
 #include "XGUI_Workshop.h"
+#include "XGUI_Displayer.h"
+#include "XGUI_ViewerProxy.h"
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_ISelection.h>
 #include <Config_PropManager.h>
 #include <Events_Loop.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAPI_Shape.h>
 
 #include <ModelAPI_Events.h>
+#include <ModelAPI_ResultGroup.h>
+#include <ModelAPI_AttributeSelectionList.h>
 
 #include <QAction>
 #include <QCheckBox>
@@ -49,7 +55,7 @@
 static const int LayoutMargin = 3;
 
 //********************************************************************
-XGUI_FacesPanel::XGUI_FacesPanel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop)
+XGUI_FacesPanel::XGUI_FacesPanel(QWidget* theParent, XGUI_Workshop* theWorkshop)
   : QDockWidget(theParent), myIsActive(false), myWorkshop(theWorkshop)
 {
   setWindowTitle(tr("Hide Faces"));
@@ -80,20 +86,34 @@ void XGUI_FacesPanel::reset(const bool isToFlushRedisplay)
   if (myLastItemIndex == 0) // do nothing because there was no activity in the pane after reset
     return;
 
-  // clear internal containers
-  myListView->getControl()->clear();
-  myItems.clear();
+  std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+  QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> >::const_iterator aIt;
+  for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
+    getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs);
+  }
 
-  // restore previous view of presentations
-  bool isModified = redisplayObjects(myItemObjects);
-  std::set<std::shared_ptr<ModelAPI_Object> > aHiddenObjects = myHiddenObjects;
-  isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects) || isModified;
-  if (isModified)// && isToFlushRedisplay) // flush signal immediatelly until container is filled
+  std::set<ObjectPtr> aObjects;
+  TopoDS_ListOfShape anEmpty;
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::const_iterator aPrsIt;
+  for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) {
+    aObjects.insert(aPrsIt->first);
+    aPrsIt->second->setSubShapeHidden(anEmpty);
+  }
+  std::set<std::shared_ptr<ModelAPI_Object> >::const_iterator aGrpIt;
+  for (aGrpIt = myHiddenGroups.cbegin(); aGrpIt != myHiddenGroups.cend(); aGrpIt++)
+    (*aGrpIt)->setDisplayed(true);
+  myHiddenGroups.clear();
+
+  if (redisplayObjects(aObjects))
     flushRedisplay();
 
+  // clear internal containers
+  myListView->getControl()->clear();
+  myItems.clear();
   updateProcessedObjects(myItems, myItemObjects);
-  myHiddenObjects.clear();
   myLastItemIndex = 0; // it should be after redisplay as flag used in customize
+  myHiddenObjects.clear();
 }
 
 //********************************************************************
@@ -114,7 +134,8 @@ void XGUI_FacesPanel::selectionFilters(SelectMgr_ListOfFilter& theSelectionFilte
   ModuleBase_IModule* aModule = myWorkshop->module();
   QIntList aModuleSelectionFilters = myWorkshop->module()->selectionFilters();
 
-  theSelectionFilters.Append(aModule->selectionFilter(SF_GlobalFilter));
+  // The global filter makes problem for groups selection when any operation is launched
+  // theSelectionFilters.Append(aModule->selectionFilter(SF_GlobalFilter));
   theSelectionFilters.Append(aModule->selectionFilter(SF_FilterInfinite));
   theSelectionFilters.Append(aModule->selectionFilter(SF_ResultGroupNameFilter));
 }
@@ -146,7 +167,7 @@ void XGUI_FacesPanel::setActivePanel(const bool theIsActive)
     // selection should be cleared after emit of signal to do not process selection change
     // event by the previous selector
     // the selection is cleared by activating selection control
-    XGUI_Tools::workshop(myWorkshop)->selector()->clearSelection();
+    myWorkshop->selector()->clearSelection();
   }
   else
     emit deactivated();
@@ -158,6 +179,14 @@ bool XGUI_FacesPanel::useTransparency() const
   return myHiddenOrTransparent->isChecked();
 }
 
+//********************************************************************
+double XGUI_FacesPanel::transparency() const
+{
+  return useTransparency() ?
+    Config_PropManager::real("Visualization", "hidden_face_transparency") : 1;
+}
+
+
 //********************************************************************
 void XGUI_FacesPanel::restoreObjects(const std::set<ObjectPtr>& theHiddenObjects)
 {
@@ -209,48 +238,125 @@ bool XGUI_FacesPanel::processAction(ModuleBase_ActionType theActionType)
   }
 }
 
+//********************************************************************
+void XGUI_FacesPanel::getObjectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
+  std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs)
+{
+  ObjectPtr anObject = thePrs->object();
+  if (!anObject.get())
+    return;
+
+  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
+  if (aResGroup.get()) {
+    // Process a grouip result
+    FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aResGroup);
+    AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
+    AISObjectPtr aPrs;
+    for (int i = 0; i < aSelectionList->size(); i++) {
+      AttributeSelectionPtr aSelection = aSelectionList->value(i);
+      ResultPtr aRes = aSelection->context();
+      aPrs = aDisplayer->getAISObject(aRes);
+      if (aPrs.get()) {
+        Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
+          aPrs->impl<Handle(AIS_InteractiveObject)>());
+        if (!aResultPrs.IsNull()) {
+          GeomShapePtr aShape = aSelection->value();
+          if (theObjectToShapes.find(aRes) != theObjectToShapes.end())
+            theObjectToShapes.at(aRes).Append(aShape->impl<TopoDS_Shape>());
+          else {
+            TopoDS_ListOfShape aListOfShapes;
+            aListOfShapes.Append(aShape->impl<TopoDS_Shape>());
+            theObjectToShapes[aRes] = aListOfShapes;
+            theObjectToPrs[aRes] = aResultPrs;
+          }
+        }
+      }
+    }
+  }
+  else {
+    // Process bodies
+    Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
+      thePrs->interactive());
+    if (aResultPrs.IsNull())
+      return;
+
+    if (theObjectToShapes.find(anObject) != theObjectToShapes.end())
+      theObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(thePrs));
+    else {
+      TopoDS_ListOfShape aListOfShapes;
+      aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(thePrs));
+      theObjectToShapes[anObject] = aListOfShapes;
+      theObjectToPrs[anObject] = aResultPrs;
+    }
+  }
+}
+
 //********************************************************************
 void XGUI_FacesPanel::processSelection()
 {
-  QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(
-                                                       ModuleBase_ISelection::Viewer);
+  QList<ModuleBase_ViewerPrsPtr> aSelected =
+    myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Viewer);
+
   bool isModified = false;
   static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
 
-  std::map<ObjectPtr, NCollection_List<TopoDS_Shape> > anObjectToShapes;
+  std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
   std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+  std::set<int> aToRemove;
+
   for (int i = 0; i < aSelected.size(); i++) {
     ModuleBase_ViewerPrsPtr aPrs = aSelected[i];
     ObjectPtr anObject = aPrs->object();
     if (!anObject.get())
       continue;
-    if (ModuleBase_Tools::getSelectedShape(aPrs).ShapeType() != TopAbs_FACE)
-      continue;
 
-    Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
-      aPrs->interactive());
-    if (aResultPrs.IsNull())
-      continue;
-    QString aItemName = XGUI_Tools::generateName(aPrs);
+    ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
+    if (!aResGroup.get()) {
+      GeomShapePtr aShapePtr = aPrs->shape();
+      if (!aShapePtr.get() || !aShapePtr->isFace())
+        return;
+    }
+
+    QString aItemName = aResGroup.get()?
+      aResGroup->data()->name().c_str() : XGUI_Tools::generateName(aPrs);
     if (myListView->hasItem(aItemName))
       return;
 
+    getObjectsMapFromPrs(aPrs, anObjectToShapes, anObjectToPrs);
+    if (aResGroup.get() && aResGroup->isDisplayed()) {
+      aResGroup->setDisplayed(false);
+      myHiddenGroups.insert(aResGroup);
+    }
+
+    // The code is dedicated to remove already selected items if they are selected twice
+    // It can happen in case of groups selection
+    QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator aIt;
+    for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
+      ModuleBase_ViewerPrsPtr aPrs = aIt.value();
+      ObjectPtr aObject = aPrs->object();
+      ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aObject);
+      if (aResGroup.get())
+        continue;
+      if (anObjectToShapes.find(aObject) != anObjectToShapes.end()) {
+        TopoDS_ListOfShape aShapes = anObjectToShapes[aObject];
+        GeomShapePtr aShapePtr = aPrs->shape();
+        if (aShapes.Contains(aShapePtr->impl<TopoDS_Shape>())) {
+          aToRemove.insert(aIt.key());
+        }
+      }
+    }
+
     myItems.insert(myLastItemIndex, aPrs);
     myListView->addItem(aItemName, myLastItemIndex);
     myLastItemIndex++;
     isModified = true;
-
-    if (anObjectToShapes.find(anObject) != anObjectToShapes.end())
-      anObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(aPrs));
-    else {
-      NCollection_List<TopoDS_Shape> aListOfShapes;
-      aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(aPrs));
-      anObjectToShapes[anObject] = aListOfShapes;
-      anObjectToPrs[anObject] = aResultPrs;
-    }
   }
-  for (std::map<ObjectPtr, NCollection_List<TopoDS_Shape> >::const_iterator
-    anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) {
+
+  // Hide fully hidden shapes
+  std::map<ObjectPtr, TopoDS_ListOfShape>::const_iterator anIt;
+  for (anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) {
     ObjectPtr anObject = anIt->first;
     if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end())
       continue;
@@ -263,11 +369,35 @@ void XGUI_FacesPanel::processSelection()
     }
     ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
   }
+
+  // Process selected presentations
+  double aTransp = transparency();
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::iterator aPrsIt;
+  for (aPrsIt = anObjectToPrs.begin(); aPrsIt != anObjectToPrs.end(); aPrsIt++) {
+    ObjectPtr anObject = aPrsIt->first;
+    Handle(ModuleBase_ResultPrs) aPrs = aPrsIt->second;
+    TopoDS_ListOfShape aAlreadyHidden = aPrs->hiddenSubShapes();
+    TopoDS_ListOfShape aListOfShapes = anObjectToShapes[anObject];
+    TopoDS_ListOfShape::Iterator aShapesIt(aListOfShapes);
+    for (; aShapesIt.More(); aShapesIt.Next()) {
+      if (!aAlreadyHidden.Contains(aShapesIt.Value()))
+        aAlreadyHidden.Append(aShapesIt.Value());
+    }
+    aPrs->setSubShapeHidden(aAlreadyHidden);
+    aPrs->setHiddenSubShapeTransparency(aTransp);
+  }
+
+  // Remove duplicate items
+  if (aToRemove.size() > 0) {
+    myListView->removeItems(aToRemove);
+    std::set<int>::const_iterator aIntIt;
+    for (aIntIt = aToRemove.cbegin(); aIntIt != aToRemove.cend(); aIntIt++)
+      myItems.remove(*aIntIt);
+  }
   if (isModified) {
     updateProcessedObjects(myItems, myItemObjects);
     flushRedisplay();
   }
-  onTransparencyChanged();
 }
 
 //********************************************************************
@@ -282,32 +412,50 @@ bool XGUI_FacesPanel::processDelete()
     return false;
 
   bool isModified = false;
-  std::set<ObjectPtr> aRestoredObjects;
-  for (std::set<int>::const_iterator anIt = aSelectedIds.begin(); anIt != aSelectedIds.end();
-       anIt++) {
+  std::set<ModuleBase_ViewerPrsPtr> aRestored;
+  std::set<int>::const_iterator anIt;
+  for (anIt = aSelectedIds.begin(); anIt != aSelectedIds.end(); anIt++) {
     ModuleBase_ViewerPrsPtr aPrs = myItems[*anIt];
-    if (aRestoredObjects.find(aPrs->object()) == aRestoredObjects.end())
-      aRestoredObjects.insert(aPrs->object());
-    myItems.remove(*anIt);
-    isModified = true;
+    if (aRestored.find(aPrs) == aRestored.end()) {
+      aRestored.insert(aPrs);
+      myItems.remove(*anIt);
+      isModified = true;
+    }
   }
-  if (isModified) {
-    bool isRedisplayed = redisplayObjects(aRestoredObjects);
-    isRedisplayed = displayHiddenObjects(aRestoredObjects, myHiddenObjects)
-                    || isRedisplayed;
-    if (isRedisplayed) {
-      flushRedisplay();
-      myWorkshop->viewer()->update();
+  std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+
+  std::set<ModuleBase_ViewerPrsPtr>::const_iterator aIt;
+  for (aIt = aRestored.cbegin(); aIt != aRestored.cend(); aIt++) {
+    getObjectsMapFromPrs((*aIt), anObjectToShapes, anObjectToPrs);
+    ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>((*aIt)->object());
+    if (aResGroup.get()) {
+      std::set<std::shared_ptr<ModelAPI_Object> >::iterator aGrpIt = myHiddenGroups.find(aResGroup);
+      if (aGrpIt != myHiddenGroups.end()) {
+        aResGroup->setDisplayed(true);
+        myHiddenGroups.erase(aGrpIt);
+      }
     }
-    // should be after flush of redisplay to have items object to be updated
-    updateProcessedObjects(myItems, myItemObjects);
+  }
 
+  std::set<ObjectPtr> aRestoredObjects;
+  std::map<ObjectPtr, TopoDS_ListOfShape>::const_iterator aShapesIt;
+  for (aShapesIt = anObjectToShapes.begin(); aShapesIt != anObjectToShapes.end(); aShapesIt++) {
+    TopoDS_ListOfShape aShapes = aShapesIt->second;
+    aRestoredObjects.insert(aShapesIt->first);
+    Handle(ModuleBase_ResultPrs) aPrs = anObjectToPrs[aShapesIt->first];
+    TopoDS_ListOfShape aHiddenShapes = aPrs->hiddenSubShapes();
+    TopoDS_ListOfShape::Iterator aSubShapesIt(aShapes);
+    for (; aSubShapesIt.More(); aSubShapesIt.Next()) {
+      if (aHiddenShapes.Contains(aSubShapesIt.Value()))
+        aHiddenShapes.Remove(aSubShapesIt.Value());
+    }
+    aPrs->setSubShapeHidden(aHiddenShapes);
   }
+  if (redisplayObjects(aRestoredObjects))
+    flushRedisplay();
 
   myListView->removeSelectedItems();
-  // Restore selection
-  myListView->restoreSelection(anIndices);
-  //appendSelectionInHistory();
   return true;
 }
 
@@ -332,79 +480,6 @@ bool XGUI_FacesPanel::redisplayObjects(
   return isModified;
 }
 
-//********************************************************************
-bool XGUI_FacesPanel::displayHiddenObjects(
-  const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
-  std::set<std::shared_ptr<ModelAPI_Object> >& theHiddenObjects)
-{
-  if (theObjects.empty())
-    return false;
-
-  bool isModified = false;
-  static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-
-  for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(); anIt != theObjects.end();
-       anIt++)
-  {
-    ObjectPtr anObject = *anIt;
-    // if the object was hidden by this panel
-    if (anObject->isDisplayed() || theHiddenObjects.find(anObject) == theHiddenObjects.end())
-      continue;
-    theHiddenObjects.erase(anObject);
-    anObject->setDisplayed(true); // it means that the object is hidden by hide all faces
-    ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
-    isModified = true;
-  }
-  return isModified;
-}
-
-//********************************************************************
-bool XGUI_FacesPanel::hideEmptyObjects()
-{
-  bool isModified = false;
-  static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-  std::map<ObjectPtr, NCollection_List<TopoDS_Shape> > anObjectToShapes;
-  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
-
-  for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = myItems.begin();
-       anIt != myItems.end(); anIt++) {
-    ModuleBase_ViewerPrsPtr aPrs = anIt.value();
-    ObjectPtr anObject = aPrs->object();
-    if (!anObject.get() || !anObject->isDisplayed())
-      continue;
-
-    Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
-      aPrs->interactive());
-    if (aResultPrs.IsNull())
-      continue;
-
-    if (anObjectToShapes.find(anObject) != anObjectToShapes.end())
-      anObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(aPrs));
-    else {
-      NCollection_List<TopoDS_Shape> aListOfShapes;
-      aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(aPrs));
-      anObjectToShapes[anObject] = aListOfShapes;
-      anObjectToPrs[anObject] = aResultPrs;
-    }
-  }
-  for (std::map<ObjectPtr, NCollection_List<TopoDS_Shape> >::const_iterator
-    anIt = anObjectToShapes.begin(); anIt != anObjectToShapes.end(); anIt++) {
-    ObjectPtr anObject = anIt->first;
-    if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end())
-      continue;
-    Handle(ModuleBase_ResultPrs) aResultPrs = anObjectToPrs.at(anObject);
-
-    if (!aResultPrs->hasSubShapeVisible(anIt->second)) {
-      // erase object because it is entirely hidden
-      anObject->setDisplayed(false);
-      myHiddenObjects.insert(anObject);
-      ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
-      isModified = true;
-    }
-  }
-  return isModified;
-}
-
 //********************************************************************
 void XGUI_FacesPanel::updateProcessedObjects(QMap<int, ModuleBase_ViewerPrsPtr> theItems,
                                              std::set<ObjectPtr>& theObjects)
@@ -414,9 +489,23 @@ void XGUI_FacesPanel::updateProcessedObjects(QMap<int, ModuleBase_ViewerPrsPtr>
        anIt != theItems.end(); anIt++) {
     ModuleBase_ViewerPrsPtr aPrs = anIt.value();
     ObjectPtr anObject = aPrs.get() ? aPrs->object() : ObjectPtr();
-    if (anObject.get() && theObjects.find(anObject) != theObjects.end())
-      continue;
-    theObjects.insert(anObject);
+    if (anObject.get()) {
+      ResultGroupPtr aResGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(anObject);
+      if (aResGroup.get()) {
+        FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aResGroup);
+        AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
+        for (int i = 0; i < aSelectionList->size(); i++) {
+          AttributeSelectionPtr aSelection = aSelectionList->value(i);
+          ResultPtr aRes = aSelection->context();
+          if (theObjects.find(aRes) == theObjects.end())
+            theObjects.insert(aRes);
+        }
+      }
+      else {
+        if (theObjects.find(anObject) == theObjects.end())
+          theObjects.insert(anObject);
+      }
+    }
   }
 }
 
@@ -429,42 +518,9 @@ void XGUI_FacesPanel::closeEvent(QCloseEvent* theEvent)
 
 //********************************************************************
 bool XGUI_FacesPanel::customizeObject(const ObjectPtr& theObject,
-                                      const AISObjectPtr& thePresentation)
+  const AISObjectPtr& thePresentation)
 {
-  if (myLastItemIndex == 0) // do nothing because there was no activity in the pane after reset
-    return false;
-
-  if (thePresentation.get() == NULL)
-    return false;
-
-  if (myItemObjects.find(theObject) == myItemObjects.end()) // not found
-    return false;
-
-  // if the object is displayed, the hidden faces are collected and set to the presentation
-  bool isModified = false;
-  NCollection_List<TopoDS_Shape> aHiddenSubShapes;
-  for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = myItems.begin();
-    anIt != myItems.end(); anIt++) {
-    ModuleBase_ViewerPrsPtr aPrs = anIt.value();
-    if (aPrs.get() && aPrs->object() != theObject)
-      continue;
-    TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs);
-    if (!aHiddenSubShapes.Contains(aShape))
-      aHiddenSubShapes.Append(aShape);
-  }
-
-  Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(
-    thePresentation->impl<Handle(AIS_InteractiveObject)>());
-  if (aResultPrs.IsNull())
-    return false;
-
-  isModified = aResultPrs->setSubShapeHidden(aHiddenSubShapes);
-
-  double aTransparency = !useTransparency() ? 1
-    : Config_PropManager::real("Visualization", "hidden_face_transparency");
-  isModified = aResultPrs->setHiddenSubShapeTransparency(aTransparency) || isModified;
-
-  return isModified;
+  return myItems.size() > 0;
 }
 
 //********************************************************************
@@ -476,16 +532,21 @@ void XGUI_FacesPanel::onDeleteItem()
 //********************************************************************
 void XGUI_FacesPanel::onTransparencyChanged()
 {
-  bool isModified = false;
-  if (useTransparency()) {
-    std::set<std::shared_ptr<ModelAPI_Object> > aHiddenObjects = myHiddenObjects;
-    isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects);
+  std::map<ObjectPtr, TopoDS_ListOfShape> anObjectToShapes;
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+  QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> >::const_iterator aIt;
+  for (aIt = myItems.cbegin(); aIt != myItems.cend(); aIt++) {
+    getObjectsMapFromPrs(aIt.value(), anObjectToShapes, anObjectToPrs);
   }
-  else
-    isModified = hideEmptyObjects();
 
-  isModified = redisplayObjects(myItemObjects) || isModified;
-  if (isModified)
+  double aTransp = Config_PropManager::real("Visualization", "hidden_face_transparency");
+  std::set<ObjectPtr> aObjects;
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs)>::const_iterator aPrsIt;
+  for (aPrsIt = anObjectToPrs.cbegin(); aPrsIt != anObjectToPrs.cend(); aPrsIt++) {
+    aObjects.insert(aPrsIt->first);
+    aPrsIt->second->setHiddenSubShapeTransparency(useTransparency()? aTransp : 1);
+  }
+  if (redisplayObjects(aObjects))
     flushRedisplay();
 }
 
@@ -501,7 +562,8 @@ void XGUI_FacesPanel::flushRedisplay() const
 {
   Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
   // Necessary for update visibility icons in ObjectBrowser
-  XGUI_ObjectsBrowser* anObjectBrowser = XGUI_Tools::workshop(myWorkshop)->objectBrowser();
+  XGUI_ObjectsBrowser* anObjectBrowser = myWorkshop->objectBrowser();
   if (anObjectBrowser)
     anObjectBrowser->updateAllIndexes();
+  myWorkshop->viewer()->update();
 }
index d4a0b04dae171cd5badcb5fba7e4715ee69f0c63..68a3ce53bd71b7be1b39341eb9648767052f85d7 100644 (file)
 #include <ModuleBase_ActionType.h>
 #include <ModuleBase_Definitions.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_ResultPrs.h>
 
 #include <SelectMgr_ListOfFilter.hxx>
+#include <TopoDS_Shape.hxx>
 
 #include <QDockWidget>
 #include <QObject>
@@ -40,7 +42,7 @@ class AIS_InteractiveObject;
 
 class GeomAPI_AISObject;
 
-class ModuleBase_IWorkshop;
+class XGUI_Workshop;
 class ModuleBase_ListView;
 
 class QAction;
@@ -69,7 +71,7 @@ class XGUI_EXPORT XGUI_FacesPanel : public QDockWidget
 public:
   /// Constructor
   /// \param theParent is a parent of the property panel
-  XGUI_FacesPanel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop);
+  XGUI_FacesPanel(QWidget* theParent, XGUI_Workshop* theWorkshop);
   ~XGUI_FacesPanel() {}
 
   /// Clear content of list widget
@@ -95,10 +97,6 @@ public:
   /// \param theIsActive state whether the panel should be activated or deactivated
   void setActivePanel(const bool theIsActive);
 
-  /// Returns true if transparency choice is checked
-  /// \return boolean value
-  bool useTransparency() const;
-
   /// Returns true if the object is in internal container of hidden objects by this panel
   /// \param theObject a checked object
   /// \return boolean value
@@ -135,6 +133,10 @@ public:
   bool customizeObject(const std::shared_ptr<ModelAPI_Object>& theObject,
     const std::shared_ptr<GeomAPI_AISObject>& thePresentation);
 
+
+  XGUI_Workshop* workshop() const { return myWorkshop; }
+
+
 protected:
   /// Reimplementation to emit a signal about the panel close
   virtual void closeEvent(QCloseEvent* theEvent);
@@ -153,23 +155,28 @@ private:
   /// \return true if some of objects was redisplayed
   static bool redisplayObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects);
 
-  /// Display objects if the objects are in a container of hidden by this pane.
-  /// \param theObjects container of objects
-  /// \param theHiddenObjects hidden objects, if object is in the container, it should be removed
-  /// \return true if some of objects was redisplayed
-  static bool displayHiddenObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
-                                   std::set<std::shared_ptr<ModelAPI_Object> >& theHiddenObjects);
-
-  /// Iterates by items and hide objects where all sub-shapes are hidden
-  /// \return true if some of objects was redisplayed
-  bool hideEmptyObjects();
-
   /// Container of objects participating in the panel, it is filled by internal container
   /// \param theItems container of selected values
   /// \param theObjects [out] container of objects
   static void updateProcessedObjects(QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> > theItems,
                                      std::set<std::shared_ptr<ModelAPI_Object> >& theObjects);
 
+  /// Returns maps of shapes and presentations. If object is a body result then it returns
+  /// its ruslts. If it is a group then it returns result of shapes included into the gropup
+  /// The function doesn't clear content of input maps.
+  /// \param thePrs a selected presintation
+  /// \param theObjectsToShapes map of objects to shapes list
+  /// \param theObjectToPrs map of objects to presentations
+  void getObjectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
+    std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectsToShapes,
+    std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs);
+
+  /// Returns true if transparency choice is checked
+  /// \return boolean value
+  bool useTransparency() const;
+
+  double transparency() const;
+
 protected slots:
   /// Deletes element in list of items
   void onDeleteItem();
@@ -188,14 +195,15 @@ private:
 protected:
   QCheckBox* myHiddenOrTransparent; ///< if checked - transparent, else hidden
   ModuleBase_ListView* myListView; ///< list control of processed faces
-  ModuleBase_IWorkshop* myWorkshop; ///< workshop
+  XGUI_Workshop* myWorkshop; ///< workshop
 
   bool myIsActive; ///< current state about the panel is active
   int myLastItemIndex; ///< last index to be used in the map of items for the next added item
 
-  QMap<int, std::shared_ptr<ModuleBase_ViewerPrs> > myItems; ///< selected face items
+  QMap<int, ModuleBase_ViewerPrsPtr> myItems; ///< selected face items
   std::set<std::shared_ptr<ModelAPI_Object> > myItemObjects; ///< cached objects of myItems
   std::set<std::shared_ptr<ModelAPI_Object> > myHiddenObjects; ///< hidden objects
+  std::set<std::shared_ptr<ModelAPI_Object> > myHiddenGroups; ///< hidden objects
 };
 
 #endif
\ No newline at end of file
index cb66e1837fdaf24eb62da0d0f3ce818caf4f65e2..ae2bb898412f6d02e03a09813dec6e30b8ef9058 100644 (file)
@@ -250,40 +250,42 @@ QString generateName(const ModuleBase_ViewerPrsPtr& thePrs)
   if (aContext.get()) {
     GeomShapePtr aSubShape(new GeomAPI_Shape());
     TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(thePrs);
-    aSubShape->setImpl(new TopoDS_Shape(aShape));
-    if (!aSubShape->isEqual(aContext)) {
-      QString aTypeName;
-      switch (aShape.ShapeType()) {
-      case TopAbs_COMPOUND:
-        aTypeName = "compound";
-        break;
-      case TopAbs_COMPSOLID:
-        aTypeName = "compsolid";
-        break;
-      case TopAbs_SOLID:
-        aTypeName = "solid";
-        break;
-      case TopAbs_SHELL:
-        aTypeName = "shell";
-        break;
-      case TopAbs_FACE:
-        aTypeName = "face";
-        break;
-      case TopAbs_WIRE:
-        aTypeName = "wire";
-        break;
-      case TopAbs_EDGE:
-        aTypeName = "edge";
-        break;
-      case TopAbs_VERTEX:
-        aTypeName = "vertex";
-        break;
-      case TopAbs_SHAPE:
-        aTypeName = "shape";
-        break;
+    if (!aShape.IsNull()) {
+      aSubShape->setImpl(new TopoDS_Shape(aShape));
+      if (!aSubShape->isEqual(aContext)) {
+        QString aTypeName;
+        switch (aShape.ShapeType()) {
+        case TopAbs_COMPOUND:
+          aTypeName = "compound";
+          break;
+        case TopAbs_COMPSOLID:
+          aTypeName = "compsolid";
+          break;
+        case TopAbs_SOLID:
+          aTypeName = "solid";
+          break;
+        case TopAbs_SHELL:
+          aTypeName = "shell";
+          break;
+        case TopAbs_FACE:
+          aTypeName = "face";
+          break;
+        case TopAbs_WIRE:
+          aTypeName = "wire";
+          break;
+        case TopAbs_EDGE:
+          aTypeName = "edge";
+          break;
+        case TopAbs_VERTEX:
+          aTypeName = "vertex";
+          break;
+        case TopAbs_SHAPE:
+          aTypeName = "shape";
+          break;
+        }
+        int aId = GeomAlgoAPI_CompoundBuilder::id(aContext, aSubShape);
+        aName += QString("/%1_%2").arg(aTypeName).arg(aId);
       }
-      int aId = GeomAlgoAPI_CompoundBuilder::id(aContext, aSubShape);
-      aName += QString("/%1_%2").arg(aTypeName).arg(aId);
     }
   }
   return aName;
index 0d2424dfa1292092342145236d39399fc2199142..3dce3196598833ccdccce880dee436ea88262127 100644 (file)
@@ -707,7 +707,6 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
   if (!aFOperation)
     return;
 
-  showPanel(myPropertyPanel);
   myPropertyPanel->cleanContent();
 
   QList<ModuleBase_ModelWidget*> aWidgets;
@@ -793,6 +792,10 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
 #endif
 
   myErrorMgr->setPropertyPanel(myPropertyPanel);
+  theOperation->setHideFacesVisible(myFacesPanel->isVisible());
+  if (aFeatureInfo->isHideFacesPanel() && !myFacesPanel->isVisible())
+    myFacesPanel->show();
+  showPanel(myPropertyPanel);
 }
 
 //******************************************************
@@ -874,6 +877,9 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
     }
   }
   activateObjectsSelection(anObjects);
+
+  if (!theOperation->isHideFacesVisible())
+    myFacesPanel->hide();
 }
 
 //******************************************************
@@ -1518,7 +1524,7 @@ void XGUI_Workshop::createDockWidgets()
 
   hidePanel(myPropertyPanel);  ///<! Invisible by default
 
-  myFacesPanel = new XGUI_FacesPanel(aDesktop, myModuleConnector);
+  myFacesPanel = new XGUI_FacesPanel(aDesktop, this);
   myActiveControlMgr->addSelector(new XGUI_FacesPanelSelector(myFacesPanel));
   myFacesPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
                                 Qt::RightDockWidgetArea |