0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / StepData / StepData_Field.hxx
1 // Created on: 1996-12-16
2 // Created by: Christian CAILLET
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _StepData_Field_HeaderFile
18 #define _StepData_Field_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Integer.hxx>
25 #include <Standard_Real.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <StepData_Logical.hxx>
28 #include <Standard_CString.hxx>
29 class Standard_Transient;
30 class StepData_SelectMember;
31
32
33 //! Defines a generally defined Field for STEP data : can be used
34 //! either in any kind of entity to implement it or in free format
35 //! entities in a "late-binding" mode
36 //! A field can have : no value (or derived), a single value of
37 //! any kind, a list of value : single or double list
38 //!
39 //! When a field is set, this defines its new kind (Integer etc..)
40 //! A single value is immediately set. A list of value is, firstly
41 //! declared as for a kind (Integer String etc), then declared as
42 //! a list with its initial size, after this its items are set
43 //! Also it can be set in once if the HArray is ready
44 class StepData_Field 
45 {
46 public:
47
48   DEFINE_STANDARD_ALLOC
49
50   
51   //! Creates a Field, empty ("no value defined")
52   Standard_EXPORT StepData_Field();
53   
54   //! Creates a Field from another one. If <copy> is True, Handled
55   //! data (Select,String,List, not entities) are copied
56   Standard_EXPORT StepData_Field(const StepData_Field& other, const Standard_Boolean copy = Standard_False);
57   
58   //! Gets the copy of the values of another field
59   Standard_EXPORT void CopyFrom (const StepData_Field& other);
60
61   //! Assignment
62   StepData_Field& operator= (const StepData_Field& theOther)
63   {
64     CopyFrom (theOther);
65     return *this;
66   }
67
68   //! Clears the field, to set it as "no value defined"
69   //! Just before SetList, predeclares it as "any"
70   //! A Kind can be directly set here to declare a type
71   Standard_EXPORT void Clear (const Standard_Integer kind = 0);
72   
73   //! Codes a Field as derived (no proper value)
74   Standard_EXPORT void SetDerived();
75   
76   //! Directly sets the Integer value, if its Kind matches
77   //! Integer, Boolean, Logical, or Enum (does not change Kind)
78   Standard_EXPORT void SetInt (const Standard_Integer val);
79   
80   //! Sets an Integer value (before SetList* declares it as Integer)
81   Standard_EXPORT void SetInteger (const Standard_Integer val = 0);
82   
83   //! Sets a Boolean value (or predeclares a list as boolean)
84   Standard_EXPORT void SetBoolean (const Standard_Boolean val = Standard_False);
85   
86   //! Sets a Logical Value (or predeclares a list as logical)
87   Standard_EXPORT void SetLogical (const StepData_Logical val = StepData_LFalse);
88   
89   //! Sets a Real    Value (or predeclares a list as Real);
90   Standard_EXPORT void SetReal (const Standard_Real val = 0.0);
91   
92   //! Sets a String  Value (or predeclares a list as String)
93   //! Does not redefine the Kind if it is alread String or Enum
94   Standard_EXPORT void SetString (const Standard_CString val = "");
95   
96   //! Sets an Enum Value (as its integer counterpart)
97   //! (or predeclares a list as Enum)
98   //! If <text> is given , also sets its textual expression
99   //! <val> negative means unknown (known values begin at 0)
100   Standard_EXPORT void SetEnum (const Standard_Integer val = -1, const Standard_CString text = "");
101   
102   //! Sets a SelectMember (for Integer,Boolean,Enum,Real,Logical)
103   //! Hence, the value of the field is accessed through this member
104   Standard_EXPORT void SetSelectMember (const Handle(StepData_SelectMember)& val);
105   
106   //! Sets an Entity Value
107   Standard_EXPORT void SetEntity (const Handle(Standard_Transient)& val);
108   
109   //! Predeclares a list as of entity
110   Standard_EXPORT void SetEntity();
111   
112   //! Declares a field as a list, with an initial size
113   //! Initial lower is defaulted as 1, can be defined
114   //! The list starts empty, typed by the last Set*
115   //! If no Set* before, sets it as "any" (transient/select)
116   Standard_EXPORT void SetList (const Standard_Integer size, const Standard_Integer first = 1);
117   
118   //! Declares a field as an homogeneous square list, with initial
119   //! sizes, and initial lowers
120   Standard_EXPORT void SetList2 (const Standard_Integer siz1, const Standard_Integer siz2, const Standard_Integer f1 = 1, const Standard_Integer f2 = 1);
121   
122   //! Sets an undetermined value : can be String, SelectMember,
123   //! HArray(1-2) ... else, an Entity
124   //! In case of an HArray, determines and records its size(s)
125   Standard_EXPORT void Set (const Handle(Standard_Transient)& val);
126   
127   //! Declares an item of the list as undefined
128   //! (ignored if list not defined as String,Entity or Any)
129   Standard_EXPORT void ClearItem (const Standard_Integer num);
130   
131   //! Internal access to an Integer Value for a list, plus its kind
132   Standard_EXPORT void SetInt (const Standard_Integer num, const Standard_Integer val, const Standard_Integer kind);
133   
134   //! Sets an Integer Value for a list (rank num)
135   //! (recognizes a SelectMember)
136   Standard_EXPORT void SetInteger (const Standard_Integer num, const Standard_Integer val);
137   
138   Standard_EXPORT void SetBoolean (const Standard_Integer num, const Standard_Boolean val);
139   
140   Standard_EXPORT void SetLogical (const Standard_Integer num, const StepData_Logical val);
141   
142   //! Sets an Enum Value (Integer counterpart), also its text
143   //! expression if known (if list has been set as "any")
144   Standard_EXPORT void SetEnum (const Standard_Integer num, const Standard_Integer val, const Standard_CString text = "");
145   
146   Standard_EXPORT void SetReal (const Standard_Integer num, const Standard_Real val);
147   
148   Standard_EXPORT void SetString (const Standard_Integer num, const Standard_CString val);
149   
150   Standard_EXPORT void SetEntity (const Standard_Integer num, const Handle(Standard_Transient)& val);
151   
152   Standard_EXPORT Standard_Boolean IsSet (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
153   
154   //! Returns the kind of an item in a list or double list
155   //! It is the kind of the list, except if it is "Any", in such a
156   //! case the true kind is determined and returned
157   Standard_EXPORT Standard_Integer ItemKind (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
158   
159   //! Returns the kind of the field
160   //! <type> True (D) : returns only the type itself
161   //! else, returns the complete kind
162   Standard_EXPORT Standard_Integer Kind (const Standard_Boolean type = Standard_True) const;
163   
164   Standard_EXPORT Standard_Integer Arity() const;
165   
166   Standard_EXPORT Standard_Integer Length (const Standard_Integer index = 1) const;
167   
168   Standard_EXPORT Standard_Integer Lower (const Standard_Integer index = 1) const;
169   
170   Standard_EXPORT Standard_Integer Int() const;
171   
172   Standard_EXPORT Standard_Integer Integer (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
173   
174   Standard_EXPORT Standard_Boolean Boolean (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
175   
176   Standard_EXPORT StepData_Logical Logical (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
177   
178   Standard_EXPORT Standard_Real Real (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
179   
180   Standard_EXPORT Standard_CString String (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
181   
182   Standard_EXPORT Standard_Integer Enum (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
183   
184   Standard_EXPORT Standard_CString EnumText (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
185   
186   Standard_EXPORT Handle(Standard_Transient) Entity (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
187   
188   Standard_EXPORT Handle(Standard_Transient) Transient() const;
189
190
191
192
193 protected:
194
195
196
197
198
199 private:
200
201
202
203   Standard_Integer thekind;
204   Standard_Integer theint;
205   Standard_Real thereal;
206   Handle(Standard_Transient) theany;
207
208
209 };
210
211
212
213
214
215
216
217 #endif // _StepData_Field_HeaderFile