Salome HOME
Cut too long lines
[modules/shaper.git] / src / Model / Model_AttributeSelection.h
index 8f692da98abd2c99a951d90fe4ab83222c7eb37a..1896caa017f435687409907b388f0ac42a6c2d06 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 Model_AttributeSelection_H_
@@ -39,23 +38,26 @@ class Model_Document;
 class Model_AttributeSelection : public ModelAPI_AttributeSelection,
                                  public Selector_NameGenerator
 {
-  Model_AttributeReference myRef;  ///< The reference functionality reusage
+  Model_AttributeReference myRef;  ///< The reference functionality re-usage
   /// temporarily storages to avoid keeping in the data structure if not needed
   ResultPtr myTmpContext;
   /// temporarily storages to avoid keeping in the data structure if not needed
   std::shared_ptr<GeomAPI_Shape> myTmpSubShape;
   /// temporarily storages to avoid keeping in the data structure if not needed
   CenterType myTmpCenterType;
-  /// Reference to the partent attribute, if any (to split selection compounds in issue 1799)
+  /// Reference to the parent attribute, if any (to split selection compounds in issue 1799)
   Model_AttributeSelectionList* myParent;
 
   std::shared_ptr<Model_Document> myRestoreDocument; // current document to restore by name
+  /// If true attribute selects geometry instead of shape.
+  bool myIsGeometricalSelection;
+
 public:
   /// Defines the result and its selected sub-shape
   /// \param theContext object where the sub-shape was selected
   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
   /// \param theTemporarily if it is true, do not store and name the added in the data framework
-  ///           (used to remove immideately, without the following updates)
+  ///           (used to remove immediately, without the following updates)
   /// \returns true if attribute was updated
   MODEL_EXPORT virtual bool setValue(
     const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
@@ -89,7 +91,7 @@ public:
   /// Sets the feature object
   MODEL_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
 
-  /// Updates the underlied selection due to the changes in the referenced objects
+  /// Updates the selection due to the changes in the referenced objects
   /// \returns false if update is failed
   MODEL_EXPORT virtual bool update();
 
@@ -97,17 +99,10 @@ public:
   /// \param theDefaultValue a name, which is returned if the naming name can not be obtained
   MODEL_EXPORT virtual std::string namingName(const std::string& theDefaultValue = "");
 
-  /// Returns an Id of the selection
-  /// NOTE: This method has been added for temporary export of groups towards old GEOM
-  /// It should then be removed when a direct use of objects from SHAPER
-  /// will be possible from SMESH module of SALOME.
-  MODEL_EXPORT virtual int Id();
-
   /// Defines the sub-shape by Id
-  /// NOTE: This method is opposite to Id() method.
   MODEL_EXPORT virtual void setId(int theID);
 
-  /// Selects (i.e. creates Naming data structure) of sub-shape specifed by textual name
+  /// Selects (i.e. creates Naming data structure) of sub-shape specified by textual name
   MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
                                            const std::string& theSubShapeName);
 
@@ -121,12 +116,13 @@ public:
   /// Returns true if attribute was  initialized by some value
   MODEL_EXPORT virtual bool isInitialized();
 
-  /// Returns true if recomute of selection become impossible
+  /// Returns true if recompute of selection become impossible
   MODEL_EXPORT virtual bool isInvalid();
 
   /// Updates the arguments of selection if something was affected by creation
   /// or reorder of features upper in the history line (issue #1757)
-  MODEL_EXPORT virtual void updateInHistory();
+  /// Returns theRemove true if this attribute must be removed (become deleted)
+  MODEL_EXPORT virtual void updateInHistory(bool& theRemove);
 
   // Implementation of the name generator method from the Selector package
   // This method returns the context name by the label of the sub-selected shape
@@ -141,6 +137,12 @@ public:
   MODEL_EXPORT virtual bool isLater(const TDF_Label theResult1, const TDF_Label theResult2)
     const override;
 
+  /// Returns the name by context. Adds the part name if the context is located in other document
+  MODEL_EXPORT virtual std::string contextName(const ResultPtr& theContext) const;
+
+  /// Makes the current local selection becomes all sub-shapes with same base geometry.
+  MODEL_EXPORT virtual void combineGeometrical();
+
 protected:
   /// Objects are created for features automatically
   MODEL_EXPORT Model_AttributeSelection(TDF_Label& theLabel);
@@ -151,9 +153,6 @@ protected:
   /// Returns theType type of the center, or NOT_CENTER if it is not.
   std::shared_ptr<GeomAPI_Shape> internalValue(CenterType& theType);
 
-
-  /// Performs the selection for the body result (TNaming Selection)
-
   /// Performs the selection for the body result (TNaming selection)
   virtual void selectBody(
     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape);
@@ -162,7 +161,7 @@ protected:
   /// \param theContext the result - owner of the selection
   /// \param theSubShape selected shape
   /// \param theUpdate flag that shows that it must be just update, theShape is null
-  /// \returns true if eveything is selected correctly
+  /// \returns true if everything is selected correctly
   virtual bool selectPart(
     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
     const bool theUpdate = false);
@@ -174,9 +173,6 @@ protected:
   /// Sets the ID of the attribute in Data (called from Data): here it is used for myRef ID setting
   MODEL_EXPORT virtual void setID(const std::string theID);
 
-  /// Returns the name by context. Adds the part name if the context is located in other document
-  std::string contextName(const ResultPtr& theContext) const;
-
   /// Sets the parent attribute
   void setParent(Model_AttributeSelectionList* theParent);
 
@@ -189,14 +185,23 @@ protected:
                         std::list<ResultPtr>& theResults, TopTools_ListOfShape& theValShapes);
 
   /// Searches for the newest context, modification of the current, that contains theValue
-  ResultPtr newestContext(const ResultPtr theCurrent,
-    const std::shared_ptr<GeomAPI_Shape> theValue);
+  ResultPtr newestContext(
+    const ResultPtr theCurrent, const std::shared_ptr<GeomAPI_Shape> theValue);
 
   /// computes theShapes list - shapes that were generated/modified/deleted the theValShape
   /// during creation from new to old context
   void computeValues(ResultPtr theOldContext, ResultPtr theNewContext, TopoDS_Shape theValShape,
     TopTools_ListOfShape& theShapes);
 
+  /// Returns true if is geometrical selection.
+  virtual bool isGeometricalSelection() const {
+    return myIsGeometricalSelection;
+  };
+
+  /// Returns the module document label if this selection attribute is not in this document.
+  /// Returns null label otherwise.
+  TDF_Label baseDocumentLab();
+
   friend class Model_Data;
   friend class Model_AttributeSelectionList;
 };