Salome HOME
Transfer BreakLink from Object to Gen
[modules/shaper_study.git] / src / PY / SHAPERSTUDY_Object.py
1 # Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 import SHAPERSTUDY_ORB__POA
24 import GEOM
25 from SHAPERSTUDY_utils import getEngine
26
27 import StudyData_Swig
28
29 class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object):
30     """
31     Construct an instance of SHAPERSTUDY Object.
32     """
33     def __init__ ( self, *args):
34         self.SO = None
35         self.data = None
36         pass
37
38     def GetShapeType( self ):
39         """
40         Get a GEOM.shape_type of the object value.
41         """
42         if self.data is None:
43             return GEOM.SHAPE
44         types = {0:GEOM.COMPOUND, 1:GEOM.COMPSOLID, 2:GEOM.SOLID,
45                  3:GEOM.SHELL, 4:GEOM.FACE, 5:GEOM.WIRE,
46                  6:GEOM.EDGE, 7:GEOM.VERTEX, 8:GEOM.SHAPE, 9:GEOM.FLAT}
47         return types[self.data.type()];
48
49     def IsMainShape( self ):
50         """
51         Returns True if this object is not a sub-shape of another object.
52         """
53         return True
54
55     def GetSubShapeIndices( self ):
56         """
57         Get a list of ID's of sub-shapes in the main shape.
58         """
59         return []
60
61     def GetMainShape( self ):
62         """
63         Get a main shape object to which this object is a sub-shape.
64         """
65         return getShape()
66
67     def getShape( self ):
68         """
69         Get the TopoDS_Shape, for colocated case only.
70         Called by GEOM_Client to get TopoDS_Shape pointer
71         """
72         if self.data is None:
73             return 0
74         return self.data.shape()
75
76     def GetShapeStream( self ):
77         """
78         Get geometric shape of the object as a byte stream in BRep format
79         """
80         if self.data is None:
81             return
82         return self.data.shapeStream()
83
84     def SetShapeByStream(self, theStream):
85         """
86         Sets geometric shape content of the object as a byte stream in BRep format
87         """
88         if self.data:
89           self.data.updateShape(theStream)
90         else:
91           self.data = StudyData_Swig.StudyData_Object(theStream)
92
93     """
94     Methods from BaseObject
95     """
96     def GetName( self ):
97         """
98         Get name of the object associated with this object.
99         """
100         return self.SO.GetName()
101
102     def SetEntry( self, theInternalEntry ):
103         """
104         Sets internal (unique) entry of the object in the component's data tree.
105         """
106         self.entry = theInternalEntry
107
108     def GetEntry( self ):
109         """
110         Get internal (unique) entry of the object in the component's data tree.
111         """
112         return self.entry
113
114     def GetType( self ):
115         """
116         Get internal type of operation created this object.
117         In SMESH is used to find out if an object is GROUP (type == 37)
118         """
119         # 1 corresponds to the Import feature (GEOMImpl_Types.hxx )
120         return 1
121
122     def GetTick( self ):
123         """
124         Get value of a modification counter of the object
125         """
126         if self.data:
127           return self.data.getTick()
128         return 0
129
130     def GetStudyEntry( self ):
131         """
132         Get a Study entry where this object was published.
133         """
134         return self.SO.GetID()
135
136     def IsShape( self ):
137         """
138         Return true if geom object represents a shape.
139         For example, method return false for GEOM_MARKER
140         """
141         return True
142
143     def IsSame( self, other ):
144         """
145         Return true if passed object is identical to this object
146         """
147         return self.GetType() == other.GetType() and self.GetEntry() == other.GetEntry()
148
149     def GetGen( self ):
150         """
151         Return the engine creating this object
152         """
153         return getEngine()
154
155     def SetSO( self, theSO ):
156         """
157         Sets SObject of this object (when it is published)
158         """
159         self.SO = theSO
160         
161     def GetSO( self ):
162         """
163         Returns SObject of this object
164         """
165         return self.SO
166
167     def IsParametrical(self):
168         """
169         Returns true if the current object has connection to a parametrical model
170         which can be modified by parameters change.
171         """
172         return True
173
174     pass