Salome HOME
Issue #2192 : change the naming principles of compsolid in case of Partition to make...
[modules/shaper.git] / src / Model / Model_ResultCompSolid.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef Model_ResultCompSolid_H_
22 #define Model_ResultCompSolid_H_
23
24 #include "Model.h"
25 #include <ModelAPI_ResultCompSolid.h>
26 #include <vector>
27
28 /**\class Model_ResultCompSolid
29 * \ingroup DataModel
30 * \brief The compsolid (container of body results) result of a feature.
31 *
32 * Provides a container of shapes that may be displayed in the viewer.
33 */
34 class Model_ResultCompSolid : public ModelAPI_ResultCompSolid
35 {
36   /// Sub-bodies if this is compsolid: zero base index to subs
37   std::vector<std::shared_ptr<ModelAPI_ResultBody> > mySubs;
38   /// Flag that stores the previous state of "concealed": if it is changed,
39   /// The event must be generated to redisplay this and all subs.
40   bool myLastConcealed;
41
42
43 public:
44
45   /// Removes the stored builders
46   MODEL_EXPORT virtual ~Model_ResultCompSolid();
47
48   /// Stores the shape (called by the execution method). Creates sub-results for compsolid.
49   MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
50                                   const bool theIsStoreSameShapes = true);
51
52   /// Stores the generated shape.  Creates sub-results for compsolid.
53   MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
54     const std::shared_ptr<GeomAPI_Shape>& theToShape);
55
56   /// Stores the modified shape.  Creates sub-results for compsolid.
57   MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
58     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
59
60   /// load and orient modified shapes for sub-objects
61   MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
62     std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape, const int  theTag,
63     const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
64     const bool theIsStoreSeparate = false,
65     const bool theIsStoreAsGenerated = false);
66
67
68   /// Returns the number of sub-elements
69   MODEL_EXPORT virtual int numberOfSubs(bool forTree = false) const;
70
71   /// Returns the sub-result by zero-base index
72   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
73     bool forTree = false) const;
74
75   /// Returns true if feature or reuslt belong to this composite feature as subs
76   MODEL_EXPORT virtual bool isSub(ObjectPtr theObject) const;
77
78   /// Returns the parameters of color definition in the resources config manager
79   MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
80                                             std::string& theDefault);
81
82   /// Disables the result body: keeps the resulting shape as selection, but erases the underlaying
83   /// naming data structure if theFlag if false. Or restores everything on theFlag is true.
84   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
85     const bool theFlag);
86
87   /// The compsolid is concealed if at least one of the sub is concealed
88   MODEL_EXPORT virtual bool isConcealed();
89
90   /// Sets all subs as concealed in the data tree (referenced by other objects)
91   MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
92
93   /// Returns true if the latest modification of this body in the naming history
94   // is equal to the given shape
95   MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
96
97 protected:
98   /// Makes a body on the given feature
99   Model_ResultCompSolid();
100
101   /// Updates the sub-bodies if shape of this object is composite-solid
102   void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape);
103
104   friend class Model_Objects;
105 };
106
107 #endif