Salome HOME
Fix for selection of groups features
[modules/shaper.git] / src / XGUI / XGUI_FacesPanel.h
index 4c147ab7dd6a8e11dbc88dc1fcd37487a532ce55..50dfacc5d214931ce5001b48a195da71ae349a1b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #ifndef XGUI_FacesPanel_H_
 
 #include "XGUI.h"
 
-#include <ModelAPI_Object.h>
-
 #include <ModuleBase_ActionType.h>
+#include <ModuleBase_Definitions.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_ResultPrs.h>
+
+#include <ModelAPI_Object.h>
+#include <ModelAPI_ResultGroup.h>
+#include <ModelAPI_Feature.h>
+
+#include <SelectMgr_ListOfFilter.hxx>
+#include <TopoDS_Shape.hxx>
 
 #include <QDockWidget>
 #include <QObject>
@@ -36,7 +42,9 @@
 
 class AIS_InteractiveObject;
 
-class ModuleBase_IWorkshop;
+class GeomAPI_AISObject;
+
+class XGUI_Workshop;
 class ModuleBase_ListView;
 
 class QAction;
@@ -65,13 +73,25 @@ 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
   /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
   virtual void reset(const bool isToFlushRedisplay);
 
+  /// Returns whether faces panel contains elements
+  /// \return boolean value
+  bool isEmpty() const;
+
+  /// Fills container with the panel selection mode: FACE
+  // \param theModes [out] a container of modes
+  void selectionModes(QIntList& theModes);
+
+  /// Appends into container of workshop selection filters
+  /// \param [out] selection filters
+  void selectionFilters(SelectMgr_ListOfFilter& theSelectionFilters);
+
   /// Returns whether the panel is active or not
   bool isActivePanel() const { return myIsActive; }
 
@@ -79,10 +99,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
@@ -108,22 +124,8 @@ public:
   /// \param theEvent an event
   virtual bool eventFilter(QObject* theObject, QEvent *theEvent);
 
-  /// Hide/show faces of the object if:
-  /// - face selector is active
-  /// - object is mentioned in the list of selected elements
-  /// If the object is displayed, all panel faces selected on it will be moved into presentation
-  /// or, if redisplayed, fuction return if the object should be redisplayed or not
-  /// \param theObject a customized object
-  /// \param isDisplayed state if the object is displayed or redisplayed
-  /// \return true if the presentation is customized
-  bool customizeObject(const std::shared_ptr<ModelAPI_Object>& theObject, const bool isDisplayed);
-
-protected:
-  /// Add panel selection filters to the current viewer
-  virtual void activateSelectionFilters() {}
+  XGUI_Workshop* workshop() const { return myWorkshop; }
 
-  /// Remove panel selection filters from the current viewer
-  virtual void deactivateSelectionFilters() {}
 
 protected:
   /// Reimplementation to emit a signal about the panel close
@@ -138,43 +140,64 @@ signals:
   void closed();
 
 private:
-  /// Activate or deactivate selection and selection filters
-  void activateSelection(bool toActivate);
-
-  /// Redisplay or display objects. The viewer is not updated after redisplay.
+  /// Redisplay objects.
   /// \param theObjects container of objects
-  /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
-  /// \return true if some of objects was redisplayed to update viewer
-  bool redisplayObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
-                        const bool isToFlushRedisplay);
+  /// \return true if some of objects was redisplayed
+  static bool redisplayObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects);
+
+  /// 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 getObjectsMapFromResult(ResultGroupPtr theResGroup, FeaturePtr theGroupFeature,
+    std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectsToShapes,
+    std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs);
+
+  void getObjectsMapFromPrs(ModuleBase_ViewerPrsPtr thePrs,
+    std::map<ObjectPtr, TopoDS_ListOfShape>& theObjectToShapes,
+    std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) >& theObjectToPrs);
 
-  /// Change the presentation to have the selected presentation hidden
-  /// \param theIndex an index of selected item that should be hidden
-  /// \return true if presentation is changed
-  bool hideFace(const int theIndex);
+  /// Returns true if transparency choice is checked
+  /// \return boolean value
+  bool useTransparency() const;
 
-  /// Generates a presentation name in form: <object_name>/<face>_<face_index>
-  /// \param thePrs a presentation
-  /// \return string value
-  static QString generateName(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+  double transparency() const;
 
 protected slots:
   /// Deletes element in list of items
   void onDeleteItem();
 
+  /// Upates hidden faces to be hidden or transparent
+  void onTransparencyChanged();
+
   /// Closes faces panel restore all hidden faces by calling reset()
   void onClosed();
 
+private:
+  /// Flushes redisplay event and perform update of object browser icons
+  /// (objects might be hidden/shown)
+  void flushRedisplay() const;
+
 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