]> SALOME platform Git repositories - modules/shaper_study.git/blob - src/PY/SHAPERSTUDY_Object.py
Salome HOME
3ad6599a868c9be2fc9fd005271cebe827ab0dc5
[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         return self.data.type();
45
46     def IsMainShape( self ):
47         """
48         Returns True if this object is not a sub-shape of another object.
49         """
50         return True
51
52     def GetSubShapeIndices( self ):
53         """
54         Get a list of ID's of sub-shapes in the main shape.
55         """
56         return []
57
58     def GetMainShape( self ):
59         """
60         Get a main shape object to which this object is a sub-shape.
61         """
62         return getShape()
63
64     def getShape( self ):
65         """
66         Get the TopoDS_Shape, for colocated case only.
67         Called by GEOM_Client to get TopoDS_Shape pointer
68         """
69         if self.data is None:
70             return 0
71         return self.data.shape()
72
73     def GetShapeStream( self ):
74         """
75         Get geometric shape of the object as a byte stream in BRep format
76         """
77         if self.data is None:
78             return
79         return self.data.shapeStream()
80
81     def SetShapeByStream(self, theStream):
82         """
83         Sets geometric shape content of the object as a byte stream in BRep format
84         """
85         if self.data:
86           self.data.updateShape(theStream)
87         else:
88           self.data = StudyData_Swig.StudyData_Object(theStream)
89
90     """
91     Methods from BaseObject
92     """
93     def GetName( self ):
94         """
95         Get name of the object associated with this object.
96         """
97         return self.SO.GetName()
98
99     def SetEntry( self, theInternalEntry ):
100         """
101         Sets internal (unique) entry of the object in the component's data tree.
102         """
103         self.entry = theInternalEntry
104
105     def GetEntry( self ):
106         """
107         Get internal (unique) entry of the object in the component's data tree.
108         """
109         return self.entry
110
111     def GetType( self ):
112         """
113         Get internal type of operation created this object.
114         In SMESH is used to find out if an object is GROUP (type == 37)
115         """
116         # 1 corresponds to the Import feature (GEOMImpl_Types.hxx )
117         return 1
118
119     def GetTick( self ):
120         """
121         Get value of a modification counter of the object
122         """
123         if self.data:
124           return self.data.getTick()
125         return 0
126
127     def GetStudyEntry( self ):
128         """
129         Get a Study entry where this object was published.
130         """
131         return self.SO.GetID()
132
133     def IsShape( self ):
134         """
135         Return true if geom object represents a shape.
136         For example, method return false for GEOM_MARKER
137         """
138         return True
139
140     def IsSame( self, other ):
141         """
142         Return true if passed object is identical to this object
143         """
144         return self.GetType() == other.GetType() and self.GetEntry() == other.GetEntry()
145
146     def GetGen( self ):
147         """
148         Return the engine creating this object
149         """
150         return getEngine()
151
152     def SetSO( self, theSO ):
153         """
154         Sets SObject of this object (when it is published)
155         """
156         self.SO = theSO
157         
158     def GetSO( self ):
159         """
160         Returns SObject of this object
161         """
162         return self.SO
163
164     def IsParametrical(self):
165         """
166         Returns true if the current object has connection to a parametrical model
167         which can be modified by parameters change.
168         """
169         return True
170
171     def BreakLinks(self):
172         """
173         Breaks links to parametrical mode for parametrical shape
174         """
175         print("##### Break parametrical links")
176
177     pass