1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef _GEOM_Function_HeaderFile
24 #define _GEOM_Function_HeaderFile
26 #include <Standard_Transient.hxx>
27 #include <Standard_GUID.hxx>
28 #include <TColStd_HArray1OfExtendedString.hxx>
29 #include <TCollection_AsciiString.hxx>
30 #include <TDF_Label.hxx>
31 #include <TDF_LabelSequence.hxx>
32 #include <TDataStd_ListOfExtendedString.hxx>
33 #include <TopoDS_Shape.hxx>
35 class Handle_TColStd_HArray1OfByte;
36 class Handle_TColStd_HArray1OfReal;
37 class Handle_TColStd_HArray1OfInteger;
38 class Handle_TColStd_HSequenceOfTransient;
40 DEFINE_STANDARD_HANDLE (GEOM_Function, Standard_Transient);
42 class GEOM_Function : public Standard_Transient
44 GEOM_Function(const TDF_Label& theEntry) { _label = theEntry; }
48 //Returns a GUID for a function tree
49 Standard_EXPORT static const Standard_GUID& GetFunctionTreeID();
51 //Returns the ID which is associated with a reference to another function
52 Standard_EXPORT static const Standard_GUID& GetDependencyID();
54 //Finds and returns a function located on a label theEntry
55 Standard_EXPORT static Handle(GEOM_Function) GetFunction(const TDF_Label& theEntry);
58 Standard_EXPORT GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType);
59 Standard_EXPORT ~GEOM_Function();
61 Standard_EXPORT TDF_Label GetOwnerEntry();
63 //Access to properties
65 //Returns a result of the function built by the function Driver
66 Standard_EXPORT TopoDS_Shape GetValue();
68 //Sets the function result
69 Standard_EXPORT void SetValue(TopoDS_Shape& theShape);
71 //Returns a function entry in the OCAF document
72 Standard_EXPORT TDF_Label& GetEntry() { return _label; }
74 //Returns the type of the function
75 Standard_EXPORT int GetType();
77 //Returns a function Driver GUID
78 Standard_EXPORT Standard_GUID GetDriverGUID();
80 //Returns aPython description of the function
81 Standard_EXPORT TCollection_AsciiString GetDescription();
83 //Sets aPython description of the function
84 Standard_EXPORT void SetDescription(const TCollection_AsciiString& theDescription);
88 //Sets a real argument at position thePosition
89 Standard_EXPORT void SetReal(int thePosition, double theValue);
91 //Returns a real argument at position thePosition
92 Standard_EXPORT double GetReal(int thePosition);
94 //Sets a real array argument at position thePosition
95 Standard_EXPORT void SetRealArray(int thePosition, const Handle(TColStd_HArray1OfReal)& theArray);
97 //Returns a real array argument at position thePosition
98 Standard_EXPORT Handle(TColStd_HArray1OfReal) GetRealArray(int thePosition);
100 //Sets an integer argument at position thePosition
101 Standard_EXPORT void SetInteger(int thePosition, int theValue);
103 //Returns an integer argument at position thePosition
104 Standard_EXPORT int GetInteger(int thePosition);
106 //Sets an integer array argument at position thePosition
107 Standard_EXPORT void SetIntegerArray(int thePosition, const Handle(TColStd_HArray1OfInteger)& theArray);
109 //Returns an integer array argument at position thePosition
110 Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntegerArray(int thePosition);
112 //Sets a byte array argument at position thePosition
113 Standard_EXPORT void SetByteArray(int thePosition, const Handle(TColStd_HArray1OfByte)& theArray);
115 //Returns a byte array argument at position thePosition
116 Standard_EXPORT Handle(TColStd_HArray1OfByte) GetByteArray(int thePosition);
118 //Sets a boolean array argument at position thePosition
119 Standard_EXPORT void SetBooleanArray(int thePosition, const Handle(TColStd_HArray1OfByte)& theArray);
121 //Returns a boolean array argument at position thePosition
122 Standard_EXPORT Handle(TColStd_HArray1OfByte) GetBooleanArray(int thePosition);
124 //Sets a reference to other function argument at position thePosition
125 Standard_EXPORT void SetReference(int thePosition, Handle(GEOM_Function) theReference);
127 //Sets a string argument at position thePosition
128 Standard_EXPORT void SetString(int thePosition, const TCollection_AsciiString& theValue);
130 //Returns a string argument at position thePosition
131 Standard_EXPORT TCollection_AsciiString GetString(int thePosition);
133 //Returns a reference to other function argument at position thePosition
134 Standard_EXPORT Handle(GEOM_Function) GetReference(int thePosition);
136 //Set an array of ExtendedString
137 Standard_EXPORT void SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray);
139 //Returns the array of ExtendedString
140 Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringArray(int thePosition);
142 //Returns true if data of given type already exists
143 Standard_EXPORT bool HasData(int thePosition, const Standard_GUID& dataID);
145 //Returns a GUID for a references tree
146 Standard_EXPORT static const Standard_GUID& GetReferencesTreeID();
148 //Sets a list of references to other function arguments at position thePosition
149 Standard_EXPORT void SetReferenceList (int thePosition,
150 const Handle(TColStd_HSequenceOfTransient)& theRefList);
152 //Returns a list of references to other function arguments at position thePosition
153 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetReferenceList (int thePosition);
155 // Save a pointer to a data holder intended to pass data Driver -> Operation.
156 // This method should be called by Operation to set the data holder.
157 // An instance of GEOM_Function that sets the data holder will remove the
158 // corresponding OCAF attribute at it's destruction
159 Standard_EXPORT void SetCallBackData( void* data );
161 // Returns a pointer to a data holder intended to pass data Driver -> Operation.
162 // This method should be called by Driver to get the data holder to fill it in.
163 // Returns NULL if the Operation have not set the data holder.
164 Standard_EXPORT void* GetCallBackData();
166 //Sets a TopoDS_Shape argument at position thePosition
167 //void SetShape(int thePosition, const TopoDS_Shape& theShape);
169 //Returns a TopoDS_Shape argument at position thePosition
170 //TopoDS_Shape GetShape(int thePosition);
172 //Returns true if the last method succided
173 Standard_EXPORT bool IsDone() { return _isDone; }
175 //Retuns true if this function is the last one in the study
176 Standard_EXPORT bool IsLastFuntion();
178 //Returns a sequence of the external dependencies of this function
179 Standard_EXPORT void GetDependency(TDF_LabelSequence& theSeq);
181 // Add/Remove/Check/Get subshape references
182 Standard_EXPORT void AddSubShapeReference (Handle(GEOM_Function) theSubShape);
183 Standard_EXPORT void RemoveSubShapeReference(Handle(GEOM_Function) theSubShape);
184 Standard_EXPORT bool HasSubShapeReferences();
185 Standard_EXPORT const TDataStd_ListOfExtendedString& GetSubShapeReferences();
187 //Returns top label of this function's history tree
188 Standard_EXPORT TDF_Label GetHistoryEntry (const Standard_Boolean create = Standard_True);
190 //Returns history label, corresponding to the label,
191 //on which a reference on argument is stored
192 Standard_EXPORT TDF_Label GetArgumentHistoryEntry (const TDF_Label& theArgumentRefEntry,
193 const Standard_Boolean create = Standard_True);
195 //Returns top label of this function's naming tree
196 Standard_EXPORT TDF_Label GetNamingEntry (const Standard_Boolean create = Standard_True);
198 DEFINE_STANDARD_RTTI (GEOM_Function);
204 bool _isCallBackData;