Salome HOME
Issue #2092: Middle constraint not removed when creating a fillet
[modules/shaper.git] / src / Model / Model_ResultConstruction.h
index b6ca72156ef3c57ca568ebe4111ff6d8b2172cca..4efeb0e3ee2678255765439bc93d7ec7f4c549d5 100644 (file)
@@ -1,14 +1,20 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultConstruction.hxx
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
 
-#ifndef Model_ResultConstruction_HeaderFile
-#define Model_ResultConstruction_HeaderFile
+#ifndef Model_ResultConstruction_H_
+#define Model_ResultConstruction_H_
 
 #include "Model.h"
 #include <ModelAPI_ResultConstruction.h>
+#include <vector>
+
+class ModelAPI_Document;
+class TDF_Label;
 
-/**\class ModelAPI_ResultConstruction
+/**\class Model_ResultConstruction
  * \ingroup DataModel
  * \brief The construction element result of a feature.
  *
  */
 class Model_ResultConstruction : public ModelAPI_ResultConstruction
 {
-  boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
-  boost::shared_ptr<GeomAPI_Shape> myShape; ///< shape of this result created "on the fly"
-public:
-  /// Returns the group identifier of this result
-  virtual std::string group()
-    {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
+  std::shared_ptr<ModelAPI_Feature> myOwner;  ///< owner of this result
+  std::shared_ptr<GeomAPI_Shape> myShape;  ///< shape of this result created "on the fly"
+  bool myFacesUpToDate; ///< is true if faces in myuFaces are computed and up to date
+  /// stores the up to date faces if they exist
+  std::vector<std::shared_ptr<GeomAPI_Face> > myFaces;
+  bool myIsInHistory;
+  bool myIsInfinite;
+ public:
+  /// Retuns the parameters of color definition in the resources config manager
+  MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
+                                            std::string& theDefault);
+
+  /// By default object is displayed in the object browser.
+  MODEL_EXPORT virtual bool isInHistory()
+  {
+    return myIsInHistory;
+  }
+
   /// Sets the result
-  MODEL_EXPORT virtual void setShape(boost::shared_ptr<GeomAPI_Shape> theShape);
+  MODEL_EXPORT virtual void setShape(std::shared_ptr<GeomAPI_Shape> theShape);
   /// Returns the shape-result produced by this feature
-  MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape>& shape();
-  /// Returns the source feature of this result
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
+  MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
+
+  /// Sets the flag that it must be displayed in history (default is true)
+  MODEL_EXPORT virtual void setIsInHistory(const bool myIsInHistory);
+
+  /// if the construction result may be used as faces, this method returns not zero number of faces
+  MODEL_EXPORT virtual int facesNum();
+  /// if the construction result may be used as faces, this method returns face by zero based index
+  MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Face> face(const int theIndex);
 
-protected:
+  /// By default object is not infinite.
+  MODEL_EXPORT virtual bool isInfinite();
+  /// Sets the flag that it is infinite
+  MODEL_EXPORT virtual void setInfinite(const bool theInfinite);
+  /// The construction element is never concealed
+  MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
+
+  // methods related to selection of sub-shapes in construction, used by SelectionAttribute
+
+  /// Selects theSubShape in the construction. Returns an index of the selected sub-shape.
+  /// Puts the selected shape with a needed BRepNaming sub-structure to the data tree of result.
+  /// If theSubShape is null, it selects the whole construction and returns zero index.
+  /// If theIndex is not -1, it re-selects over the existing data (used for update selection).
+  /// If theExtDoc is document where this selection is needed, if it differs from this,
+  /// naming structures will be located there.
+  int select(const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+    const std::shared_ptr<ModelAPI_Document> theExtDoc, const int theIndex = -1);
+
+  /// Returns already selected shape by the given index. Zero index means the whole construction,
+  /// so, the returned shape in this case is null.
+  /// If theExtDoc is document where this selection is needed, if it differs from this,
+  /// naming structures will be located there.
+  std::shared_ptr<GeomAPI_Shape> shape(const int theIndex,
+    const std::shared_ptr<ModelAPI_Document> theExtDoc);
+
+  /// Updates the existing selection by the index.
+  /// Returns false if update is failed. Returns theModified true if the selection was updated.
+  /// If theExtDoc is document where this selection is needed, if it differs from this,
+  /// naming structures will be updated there.
+  bool update(const int theIndex, const std::shared_ptr<ModelAPI_Document> theExtDoc,
+    bool& theModified);
+
+ protected:
   /// Makes a body on the given feature
   Model_ResultConstruction();
 
-  friend class Model_Document;
+  /// Searchies for the working label selection/update will start from
+  /// Returns true if this is label of the external document.
+  /// theExtDoc is document where this selection is required
+  TDF_Label startLabel(const std::shared_ptr<ModelAPI_Document> theExtDoc, bool& theExternal);
+
+  friend class Model_Objects;
 };
 
 #endif