Salome HOME
Issues #2150 and #2151: Frequently appeared "Conflicting constraints" message for...
[modules/shaper.git] / src / Model / Model_ResultCompSolid.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_ResultCompSolid.h
4 // Created:     20 Jul 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef Model_ResultCompSolid_H_
8 #define Model_ResultCompSolid_H_
9
10 #include "Model.h"
11 #include <ModelAPI_ResultCompSolid.h>
12 #include <vector>
13
14 /**\class Model_ResultCompSolid
15 * \ingroup DataModel
16 * \brief The compsolid (container of body results) result of a feature.
17 *
18 * Provides a container of shapes that may be displayed in the viewer.
19 */
20 class Model_ResultCompSolid : public ModelAPI_ResultCompSolid
21 {
22   /// Sub-bodies if this is compsolid: zero base index to subs
23   std::vector<std::shared_ptr<ModelAPI_ResultBody> > mySubs;
24   /// Flag that stores the previous state of "concealed": if it is changed,
25   /// The event must be generated to redisplay this and all subs.
26   bool myLastConcealed;
27
28
29 public:
30
31   /// Removes the stored builders
32   MODEL_EXPORT virtual ~Model_ResultCompSolid();
33
34   /// Stores the shape (called by the execution method). Creates sub-results for compsolid.
35   MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
36                                   const bool theIsStoreSameShapes = true);
37
38   /// Stores the generated shape.  Creates sub-results for compsolid.
39   MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
40     const std::shared_ptr<GeomAPI_Shape>& theToShape);
41
42   /// Stores the modified shape.  Creates sub-results for compsolid.
43   MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
44     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
45
46   /// Returns the number of sub-elements
47   MODEL_EXPORT virtual int numberOfSubs(bool forTree = false) const;
48
49   /// Returns the sub-result by zero-base index
50   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
51     bool forTree = false) const;
52
53   /// Returns true if feature or reuslt belong to this composite feature as subs
54   MODEL_EXPORT virtual bool isSub(ObjectPtr theObject) const;
55
56   /// Returns the parameters of color definition in the resources config manager
57   MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
58                                             std::string& theDefault);
59
60   /// Disables the result body: keeps the resulting shape as selection, but erases the underlaying
61   /// naming data structure if theFlag if false. Or restores everything on theFlag is true.
62   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
63     const bool theFlag);
64
65   /// The compsolid is concealed if at least one of the sub is concealed
66   MODEL_EXPORT virtual bool isConcealed();
67
68   /// Sets all subs as concealed in the data tree (referenced by other objects)
69   MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
70
71   /// Returns true if the latest modification of this body in the naming history
72   // is equal to the given shape
73   MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
74
75 protected:
76   /// Makes a body on the given feature
77   Model_ResultCompSolid();
78
79   /// Updates the sub-bodies if shape of this object is composite-solid
80   void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape);
81
82   friend class Model_Objects;
83 };
84
85 #endif