]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ModuleBase/ModuleBase_WidgetValidated.h
Salome HOME
Feature selector widget for recover feature.
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetValidated.h
index cb826704bec6cb15544bd64c26ddec065c2a9e3c..31b7b59a0982b9de0ff8221bc98e7aae7c370db7 100644 (file)
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        ModuleBase_WidgetValidated.h
-// Created:     12 Mar 2015
-// Author:      Natalia ERMOLAEVA
-
-
-#ifndef MODULEBASE_WIDGETVALIDATED_H_
-#define MODULEBASE_WIDGETVALIDATED_H_
-
-#include <ModuleBase.h>
-#include <ModuleBase_ModelWidget.h>
-
-#include <GeomAPI_Shape.h>
-#include <GeomAPI_AISObject.h>
-#include <ModelAPI_Object.h>
-#include <ModelAPI_Attribute.h>
-
-#include <SelectMgr_ListOfFilter.hxx>
-#include <NCollection_DataMap.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <QList>
-#include <QMap>
-
-class QWidget;
-class ModuleBase_IWorkshop;
-class ModuleBase_ISelection;
-class ModuleBase_WidgetSelectorStore;
-class ModelAPI_Validator;
-class Config_WidgetAPI;
-class Handle_SelectMgr_EntityOwner;
-
-//#define LIST_OF_VALID_PRS
-
-/**
-* \ingroup GUI
-* Implementation of widget with validators and filters processing.
-*/
-class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidget
-{
-  Q_OBJECT
- public:
-  /// Constructor
-  /// \param theParent the parent object
-  /// \param theWorkshop a reference to workshop
-  /// \param theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetValidated(QWidget* theParent,
-                             ModuleBase_IWorkshop* theWorkshop,
-                             const Config_WidgetAPI* theData);
-  virtual ~ModuleBase_WidgetValidated();
-
-  /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,
-  /// next, the attribute's validating. It trying on the give selection to current attribute by
-  /// setting the value inside and calling validators. After this, the previous attribute value is
-  /// restored.The valid/invalid value is cashed.
-  /// \param theValue a selected presentation in the view
-  /// \return a boolean value
-  virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
-
-  //! Returns data object by AIS
-  ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
-
-  //! Clear all validated cash in the widget
-  void clearValidatedCash();
-
-  /// Returns true if the workshop validator filter has been already activated
-  /// \return boolean value
-  bool isFilterActivated() const;
-
-protected:
-  /// Checks whether all active viewer filters validate the presentation
-  /// \param thePrs a selected presentation in the view
-  /// \return a boolean value
-  bool isValidInFilters(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
-
-  /// Checks all attribute validators returns valid. It tries on the given selection
-  /// to current attribute by setting the value inside and calling validators. After this,
-  /// the previous attribute value is restored.The valid/invalid value is cashed.
-  /// \param theValue a selected presentation in the view
-  /// \param theAttribute the attribute
-  /// \return a boolean value
-  bool isValidSelectionForAttribute(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue,
-                                    const AttributePtr& theAttribute);
-
-  /// Retunrs attribute, which should be validated. In default implementation,
-  /// this is an attribute of ID
-  /// \return an attribute
-  virtual AttributePtr attribute() const;
-
-  /// Creates a backup of the current values of the attribute
-  /// It should be realized in the specific widget because of different
-  /// parameters of the current attribute
-  /// \param theAttribute an attribute to be stored
-  virtual void storeAttributeValue(const AttributePtr& theAttribute);
-
-  /// Creates a backup of the current values of the attribute
-  /// It should be realized in the specific widget because of different
-  /// parameters of the current attribute
-  /// \param theAttribute an attribute to be restored
-  /// \param theValid a boolean flag, if restore happens for valid parameters
-  virtual void restoreAttributeValue(const AttributePtr& theAttribute, const bool theValid);
-
-  /// Checks the widget validity. By default, it returns true.
-  /// \param thePrs a selected presentation in the view
-  /// \return a boolean value
-  virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
-
-  /// Fills the attribute with the value of the selected owner
-  /// \param thePrs a selected owner
-  virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs) = 0;
-
-  /// Returns a list of selected presentations in the viewer and object browser
-  /// The presentations from the object browser are filtered by the AIS context filters
-  /// \return a list of presentations
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> getFilteredSelected();
-
-  /// It obtains selection filters from the workshop and activates them in the active viewer
-  /// \param toActivate a flag about activation or deactivation the filters
-  /// \return true if the selection filter of the widget is activated in viewer context
-  bool activateFilters(const bool toActivate);
-
-  /// Block the model flush of update and intialization of attribute
-  /// \param theAttribute an attribute of blocking
-  /// \param theToBlock flag whether the model is blocked or unblocked
-  /// \param isFlushesActived out value if model is blocked, in value if model is unblocked
-  /// to be used to restore flush state when unblocked
-  /// \param isAttributeSetInitializedBlocked out value if model is blocked
-  /// in value if model is unblocked to be used to restore previous state when unblocked
-  virtual void blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock,
-                              bool& isFlushesActived, bool& isAttributeSetInitializedBlocked);
-
-private:
-  /// Checks the current attibute in all attribute validators
-  /// \param theAttribute an attribute to be validated
-  /// \return true if all validators return that the attribute is valid
-  bool isValidAttribute(const AttributePtr& theAttribute) const;
-
-protected:
-  /// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored
-  /// \param theValue a viewer presentation
-  /// \param theValid a valid state
-  bool getValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, bool& theValid);
-
-  /// Store the validity state of the presentation in an internal map
-  /// \param theValue a viewer presentation
-  /// \param theValid a valid state
-  void storeValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, const bool theValid);
-
-private:
-  /// Applies AIS context filters to the parameter list. The not approved presentations are
-  /// removed from the parameters.
-  /// \param theValues a list of presentations.
-  void filterPresentations(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
-
-  /// Remove subshapes of compsolids if whole compsolid is present.
-  /// \param theValues a list of presentations.
-  void filterCompSolids(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
-
-protected:
-  /// Reference to workshop
-  ModuleBase_IWorkshop* myWorkshop;
-  /// The widget is in validation mode: store is performed, restore is not
-  bool myIsInValidate;
-
-private:
-  ObjectPtr myPresentedObject; /// back up of the filtered object
-#ifdef LIST_OF_VALID_PRS
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> myValidPrs; /// cash of valid selection presentations
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> myInvalidPrs; /// cash of invalid selection presentations
-#else
-  // assume that one presentation selection presentation corresponds only one shape
-  NCollection_DataMap<TopoDS_Shape, std::shared_ptr<ModuleBase_ViewerPrs> > myValidPrs;
-  NCollection_DataMap<TopoDS_Shape, std::shared_ptr<ModuleBase_ViewerPrs> > myInvalidPrs;
-#endif
-
-  /// store to backup parameters of the model
-  ModuleBase_WidgetSelectorStore* myAttributeStore;
-};
-
-#endif /* MODULEBASE_WIDGETVALIDATED_H_ */
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
+// File:        ModuleBase_WidgetValidated.h\r
+// Created:     12 Mar 2015\r
+// Author:      Natalia ERMOLAEVA\r
+\r
+\r
+#ifndef MODULEBASE_WIDGETVALIDATED_H_\r
+#define MODULEBASE_WIDGETVALIDATED_H_\r
+\r
+#include <ModuleBase.h>\r
+#include <ModuleBase_ModelWidget.h>\r
+\r
+#include <GeomAPI_Shape.h>\r
+#include <GeomAPI_AISObject.h>\r
+#include <ModelAPI_Object.h>\r
+#include <ModelAPI_Attribute.h>\r
+\r
+#include <SelectMgr_ListOfFilter.hxx>\r
+#include <NCollection_DataMap.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+\r
+#include <QList>\r
+#include <QMap>\r
+\r
+class QWidget;\r
+class ModuleBase_IWorkshop;\r
+class ModuleBase_ISelection;\r
+class ModuleBase_WidgetSelectorStore;\r
+class ModelAPI_Validator;\r
+class Config_WidgetAPI;\r
+class Handle_SelectMgr_EntityOwner;\r
+\r
+//#define LIST_OF_VALID_PRS\r
+\r
+/**\r
+* \ingroup GUI\r
+* Implementation of widget with validators and filters processing.\r
+*/\r
+class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidget\r
+{\r
+  Q_OBJECT\r
+ public:\r
+  /// Constructor\r
+  /// \param theParent the parent object\r
+  /// \param theWorkshop a reference to workshop\r
+  /// \param theData the widget configuation. The attribute of the model widget is obtained from\r
+  ModuleBase_WidgetValidated(QWidget* theParent,\r
+                             ModuleBase_IWorkshop* theWorkshop,\r
+                             const Config_WidgetAPI* theData);\r
+  virtual ~ModuleBase_WidgetValidated();\r
+\r
+  /// Checks all widget validator if the owner is valid. Firstly it checks custom widget validating,\r
+  /// next, the attribute's validating. It trying on the give selection to current attribute by\r
+  /// setting the value inside and calling validators. After this, the previous attribute value is\r
+  /// restored.The valid/invalid value is cashed.\r
+  /// \param theValue a selected presentation in the view\r
+  /// \return a boolean value\r
+  virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);\r
+\r
+  //! Returns data object by AIS\r
+  ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;\r
+\r
+  //! Clear all validated cash in the widget\r
+  void clearValidatedCash();\r
+\r
+  /// Returns true if the workshop validator filter has been already activated\r
+  /// \return boolean value\r
+  bool isFilterActivated() const;\r
+\r
+protected:\r
+  /// Checks whether all active viewer filters validate the presentation\r
+  /// \param thePrs a selected presentation in the view\r
+  /// \return a boolean value\r
+  virtual bool isValidInFilters(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);\r
+\r
+  /// Checks all attribute validators returns valid. It tries on the given selection\r
+  /// to current attribute by setting the value inside and calling validators. After this,\r
+  /// the previous attribute value is restored.The valid/invalid value is cashed.\r
+  /// \param theValue a selected presentation in the view\r
+  /// \param theAttribute the attribute\r
+  /// \return a boolean value\r
+  bool isValidSelectionForAttribute(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue,\r
+                                    const AttributePtr& theAttribute);\r
+\r
+  /// Retunrs attribute, which should be validated. In default implementation,\r
+  /// this is an attribute of ID\r
+  /// \return an attribute\r
+  virtual AttributePtr attribute() const;\r
+\r
+  /// Creates a backup of the current values of the attribute\r
+  /// It should be realized in the specific widget because of different\r
+  /// parameters of the current attribute\r
+  /// \param theAttribute an attribute to be stored\r
+  virtual void storeAttributeValue(const AttributePtr& theAttribute);\r
+\r
+  /// Creates a backup of the current values of the attribute\r
+  /// It should be realized in the specific widget because of different\r
+  /// parameters of the current attribute\r
+  /// \param theAttribute an attribute to be restored\r
+  /// \param theValid a boolean flag, if restore happens for valid parameters\r
+  virtual void restoreAttributeValue(const AttributePtr& theAttribute, const bool theValid);\r
+\r
+  /// Checks the widget validity. By default, it returns true.\r
+  /// \param thePrs a selected presentation in the view\r
+  /// \return a boolean value\r
+  virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);\r
+\r
+  /// Fills the attribute with the value of the selected owner\r
+  /// \param thePrs a selected owner\r
+  virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs) = 0;\r
+\r
+  /// Returns a list of selected presentations in the viewer and object browser\r
+  /// The presentations from the object browser are filtered by the AIS context filters\r
+  /// \return a list of presentations\r
+  QList<std::shared_ptr<ModuleBase_ViewerPrs>> getFilteredSelected();\r
+\r
+  /// It obtains selection filters from the workshop and activates them in the active viewer\r
+  /// \param toActivate a flag about activation or deactivation the filters\r
+  /// \return true if the selection filter of the widget is activated in viewer context\r
+  bool activateFilters(const bool toActivate);\r
+\r
+  /// Block the model flush of update and intialization of attribute\r
+  /// \param theAttribute an attribute of blocking\r
+  /// \param theToBlock flag whether the model is blocked or unblocked\r
+  /// \param isFlushesActived out value if model is blocked, in value if model is unblocked\r
+  /// to be used to restore flush state when unblocked\r
+  /// \param isAttributeSetInitializedBlocked out value if model is blocked\r
+  /// in value if model is unblocked to be used to restore previous state when unblocked\r
+  virtual void blockAttribute(const AttributePtr& theAttribute, const bool& theToBlock,\r
+                              bool& isFlushesActived, bool& isAttributeSetInitializedBlocked);\r
+\r
+private:\r
+  /// Checks the current attibute in all attribute validators\r
+  /// \param theAttribute an attribute to be validated\r
+  /// \return true if all validators return that the attribute is valid\r
+  bool isValidAttribute(const AttributePtr& theAttribute) const;\r
+\r
+protected:\r
+  /// Gets the validity state of the presentation in an internal map. Returns true if the valid state of value is stored\r
+  /// \param theValue a viewer presentation\r
+  /// \param theValid a valid state\r
+  bool getValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, bool& theValid);\r
+\r
+  /// Store the validity state of the presentation in an internal map\r
+  /// \param theValue a viewer presentation\r
+  /// \param theValid a valid state\r
+  void storeValidState(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue, const bool theValid);\r
+\r
+private:\r
+  /// Applies AIS context filters to the parameter list. The not approved presentations are\r
+  /// removed from the parameters.\r
+  /// \param theValues a list of presentations.\r
+  void filterPresentations(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);\r
+\r
+  /// Remove subshapes of compsolids if whole compsolid is present.\r
+  /// \param theValues a list of presentations.\r
+  void filterCompSolids(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);\r
+\r
+protected:\r
+  /// Reference to workshop\r
+  ModuleBase_IWorkshop* myWorkshop;\r
+  /// The widget is in validation mode: store is performed, restore is not\r
+  bool myIsInValidate;\r
+\r
+private:\r
+  ObjectPtr myPresentedObject; /// back up of the filtered object\r
+#ifdef LIST_OF_VALID_PRS\r
+  QList<std::shared_ptr<ModuleBase_ViewerPrs>> myValidPrs; /// cash of valid selection presentations\r
+  QList<std::shared_ptr<ModuleBase_ViewerPrs>> myInvalidPrs; /// cash of invalid selection presentations\r
+#else\r
+  // assume that one presentation selection presentation corresponds only one shape\r
+  NCollection_DataMap<TopoDS_Shape, std::shared_ptr<ModuleBase_ViewerPrs> > myValidPrs;\r
+  NCollection_DataMap<TopoDS_Shape, std::shared_ptr<ModuleBase_ViewerPrs> > myInvalidPrs;\r
+#endif\r
+\r
+  /// store to backup parameters of the model\r
+  ModuleBase_WidgetSelectorStore* myAttributeStore;\r
+};\r
+\r
+#endif /* MODULEBASE_WIDGETVALIDATED_H_ */\r