5e9031246fb60a827ce15cec54b8f83d05d02b7e
[occt.git] / src / IGESDimen / IGESDimen_NewGeneralNote.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
19 #include <gp_GTrsf.hxx>
20 #include <gp_Pnt.hxx>
21 #include <gp_XYZ.hxx>
22 #include <IGESData_IGESEntity.hxx>
23 #include <IGESDimen_NewGeneralNote.hxx>
24 #include <Standard_DimensionMismatch.hxx>
25 #include <Standard_OutOfRange.hxx>
26 #include <Standard_Type.hxx>
27 #include <TCollection_HAsciiString.hxx>
28
29 IMPLEMENT_STANDARD_RTTIEXT(IGESDimen_NewGeneralNote,IGESData_IGESEntity)
30
31 IGESDimen_NewGeneralNote::IGESDimen_NewGeneralNote ()    {  }
32
33
34     void  IGESDimen_NewGeneralNote::Init
35   (const Standard_Real    width,                const Standard_Real height,
36    const Standard_Integer justifyCode,          const gp_XYZ& areaLoc,
37    const Standard_Real    areaRotationAngle,    const gp_XYZ& baseLinePos,
38    const Standard_Real    normalInterlineSpace,
39    const Handle(TColStd_HArray1OfInteger)&        charDisplays,
40    const Handle(TColStd_HArray1OfReal)&           charWidths,
41    const Handle(TColStd_HArray1OfReal)&           charHeights,
42    const Handle(TColStd_HArray1OfReal)&           interCharSpc,
43    const Handle(TColStd_HArray1OfReal)&           interLineSpc,
44    const Handle(TColStd_HArray1OfInteger)&        fontStyles,
45    const Handle(TColStd_HArray1OfReal)&           charAngles,
46    const Handle(Interface_HArray1OfHAsciiString)& controlCodeStrings,
47    const Handle(TColStd_HArray1OfInteger)&        nbChars,
48    const Handle(TColStd_HArray1OfReal)&           boxWidths,
49    const Handle(TColStd_HArray1OfReal)&           boxHeights,
50    const Handle(TColStd_HArray1OfInteger)&        charSetCodes,
51    const Handle(IGESData_HArray1OfIGESEntity)&    charSetEntities,
52    const Handle(TColStd_HArray1OfReal)&           slAngles,
53    const Handle(TColStd_HArray1OfReal)&           rotAngles,
54    const Handle(TColStd_HArray1OfInteger)&        mirrorFlags,
55    const Handle(TColStd_HArray1OfInteger)&        rotateFlags,
56    const Handle(TColgp_HArray1OfXYZ)&             startPoints,
57    const Handle(Interface_HArray1OfHAsciiString)& texts)
58 {
59   Standard_Integer num = nbChars->Length();
60
61   if ( nbChars->Lower()         != 1 ||
62       (charDisplays->Lower()    != 1 || charDisplays->Length()    != num) ||
63       (charWidths->Lower()      != 1 || charWidths->Length()      != num) ||
64       (charHeights->Lower()     != 1 || charHeights->Length()     != num) ||
65       (interCharSpc->Lower()    != 1 || interCharSpc->Length()    != num) ||
66       (interLineSpc->Lower()    != 1 || interLineSpc->Length()    != num) ||
67       (fontStyles->Lower()      != 1 || fontStyles->Length()      != num) ||
68       (charAngles->Lower()      != 1 || charAngles->Length()      != num) ||
69       (controlCodeStrings->Lower() != 1 || controlCodeStrings->Length() != num)||
70       (boxWidths->Lower()       != 1 || boxWidths->Length()       != num) ||
71       (boxHeights->Lower()      != 1 || boxHeights->Length()      != num) ||
72       (charSetCodes->Lower()    != 1 || charSetCodes->Length()    != num) ||
73       (charSetEntities->Lower() != 1 || charSetEntities->Length() != num) ||
74       (slAngles->Lower()        != 1 || slAngles->Length()        != num) ||
75       (rotAngles->Lower()       != 1 || rotAngles->Length()       != num) ||
76       (mirrorFlags->Lower()     != 1 || mirrorFlags->Length()     != num) ||
77       (rotateFlags->Lower()     != 1 || rotateFlags->Length()     != num) ||
78       (startPoints->Lower()     != 1 || startPoints->Length()     != num) ||
79       (texts->Lower()           != 1 || texts->Length() != num))
80     Standard_DimensionMismatch::Raise("IGESDimen_GeneralNote : Init");
81
82   theWidth                = width;
83   theHeight               = height;
84   theJustifyCode          = justifyCode;
85   theAreaLoc              = areaLoc;
86   theAreaRotationAngle    = areaRotationAngle;
87   theBaseLinePos          = baseLinePos;
88   theNormalInterlineSpace = normalInterlineSpace;
89   theCharDisplays         = charDisplays;
90   theCharWidths           = charWidths;
91   theCharHeights          = charHeights;
92   theInterCharSpaces      = interCharSpc;
93   theInterlineSpaces      = interLineSpc;
94   theFontStyles           = fontStyles;
95   theCharAngles           = charAngles;
96   theControlCodeStrings   = controlCodeStrings;
97   theNbChars              = nbChars;
98   theBoxWidths            = boxWidths;
99   theBoxHeights           = boxHeights;
100   theCharSetCodes         = charSetCodes;
101   theCharSetEntities      = charSetEntities;
102   theSlantAngles          = slAngles;
103   theRotationAngles       = rotAngles;
104   theMirrorFlags          = mirrorFlags;
105   theRotateFlags          = rotateFlags;
106   theStartPoints          = startPoints;
107   theTexts                = texts;
108   InitTypeAndForm(213,0);
109 }
110
111     Standard_Real  IGESDimen_NewGeneralNote::TextWidth () const 
112 {
113   return theWidth;
114 }
115
116     Standard_Real  IGESDimen_NewGeneralNote::TextHeight () const 
117 {
118   return theHeight;
119 }
120
121     Standard_Integer  IGESDimen_NewGeneralNote::JustifyCode () const 
122 {
123   return theJustifyCode;
124 }
125
126     gp_Pnt  IGESDimen_NewGeneralNote::AreaLocation () const 
127 {
128   gp_Pnt loc(theAreaLoc);
129   return loc;
130 }
131
132     gp_Pnt  IGESDimen_NewGeneralNote::TransformedAreaLocation () const 
133 {
134   gp_XYZ tempXYZ = theAreaLoc;
135   if (HasTransf()) Location().Transforms(tempXYZ);
136   return gp_Pnt(tempXYZ);
137 }
138
139     Standard_Real  IGESDimen_NewGeneralNote::ZDepthAreaLocation () const 
140 {
141   return (theAreaLoc.Z());
142 }
143
144     Standard_Real  IGESDimen_NewGeneralNote::AreaRotationAngle () const 
145 {
146   return theAreaRotationAngle;
147 }
148
149     gp_Pnt  IGESDimen_NewGeneralNote::BaseLinePosition () const 
150 {
151   gp_Pnt pos(theBaseLinePos);
152   return pos;
153 }
154
155     gp_Pnt  IGESDimen_NewGeneralNote::TransformedBaseLinePosition () const 
156 {
157   gp_XYZ tempXYZ = theBaseLinePos;
158   if (HasTransf()) Location().Transforms(tempXYZ);
159   return gp_Pnt(tempXYZ);
160 }
161
162     Standard_Real  IGESDimen_NewGeneralNote::ZDepthBaseLinePosition () const 
163 {
164   return (theBaseLinePos.Z());
165 }
166
167     Standard_Real  IGESDimen_NewGeneralNote::NormalInterlineSpace () const 
168 {
169   return theNormalInterlineSpace;
170 }
171
172     Standard_Integer  IGESDimen_NewGeneralNote::NbStrings () const 
173 {
174   return theCharDisplays->Length();
175 }
176
177     Standard_Integer  IGESDimen_NewGeneralNote::CharacterDisplay
178   (const Standard_Integer Index) const 
179 {
180   return theCharDisplays->Value(Index);
181 }
182
183     Standard_Boolean  IGESDimen_NewGeneralNote::IsVariable
184   (const Standard_Integer Index) const 
185 {
186   return (theCharDisplays->Value(Index) == 1); 
187 }
188
189     Standard_Real  IGESDimen_NewGeneralNote::CharacterWidth
190   (const Standard_Integer Index) const 
191 {
192   return theCharWidths->Value(Index);
193 }
194
195     Standard_Real  IGESDimen_NewGeneralNote::CharacterHeight
196   (const Standard_Integer Index) const 
197 {
198   return theCharHeights->Value(Index);
199 }
200
201     Standard_Real  IGESDimen_NewGeneralNote::InterCharacterSpace
202   (const Standard_Integer Index) const 
203 {
204   return theInterCharSpaces->Value(Index);
205 }
206
207     Standard_Real  IGESDimen_NewGeneralNote::InterlineSpace
208   (const Standard_Integer Index) const 
209 {
210   return theInterlineSpaces->Value(Index);
211 }
212
213     Standard_Integer  IGESDimen_NewGeneralNote::FontStyle
214   (const Standard_Integer Index) const 
215 {
216   return theFontStyles->Value(Index);
217 }
218
219     Standard_Real  IGESDimen_NewGeneralNote::CharacterAngle
220   (const Standard_Integer Index) const 
221 {
222   return theCharAngles->Value(Index);
223 }
224
225     Handle(TCollection_HAsciiString)  IGESDimen_NewGeneralNote::ControlCodeString
226   (const Standard_Integer Index) const 
227 {
228   return theControlCodeStrings->Value(Index);
229 }
230
231     Standard_Integer  IGESDimen_NewGeneralNote::NbCharacters
232   (const Standard_Integer Index) const 
233 {
234   return theNbChars->Value(Index);
235 }
236
237     Standard_Real  IGESDimen_NewGeneralNote::BoxWidth
238   (const Standard_Integer Index) const 
239 {
240   return theBoxWidths->Value(Index);
241 }
242
243     Standard_Real  IGESDimen_NewGeneralNote::BoxHeight
244   (const Standard_Integer Index) const 
245 {
246   return theBoxHeights->Value(Index);
247 }
248
249     Standard_Boolean  IGESDimen_NewGeneralNote::IsCharSetEntity
250   (const Standard_Integer Index) const 
251 {
252   return (! (theCharSetEntities->Value(Index)).IsNull());
253 }
254
255     Standard_Integer  IGESDimen_NewGeneralNote::CharSetCode
256   (const Standard_Integer Index) const 
257 {
258   return theCharSetCodes->Value(Index);
259 }
260
261     Handle(IGESData_IGESEntity)  IGESDimen_NewGeneralNote::CharSetEntity
262   (const Standard_Integer Index) const 
263 {
264   return theCharSetEntities->Value(Index);
265 }
266
267     Standard_Real  IGESDimen_NewGeneralNote::SlantAngle
268   (const Standard_Integer Index) const 
269 {
270   return theSlantAngles->Value(Index);
271 }
272
273     Standard_Real  IGESDimen_NewGeneralNote::RotationAngle
274   (const Standard_Integer Index) const 
275 {
276   return theRotationAngles->Value(Index);
277 }
278
279     Standard_Integer  IGESDimen_NewGeneralNote::MirrorFlag
280   (const Standard_Integer Index) const 
281 {
282   return theMirrorFlags->Value(Index);
283 }
284
285     Standard_Boolean  IGESDimen_NewGeneralNote::IsMirrored
286   (const Standard_Integer Index) const 
287 {
288   return (theMirrorFlags->Value(Index) != 0);
289 }
290
291     Standard_Integer  IGESDimen_NewGeneralNote::RotateFlag
292   (const Standard_Integer Index) const 
293 {
294   return theRotateFlags->Value(Index);
295 }
296
297     gp_Pnt  IGESDimen_NewGeneralNote::StartPoint
298   (const Standard_Integer Index) const 
299 {
300   return gp_Pnt(theStartPoints->Value(Index));
301 }
302
303     gp_Pnt  IGESDimen_NewGeneralNote::TransformedStartPoint
304   (const Standard_Integer Index) const 
305 {
306   gp_XYZ tempXYZ = theStartPoints->Value(Index);
307   if (HasTransf()) Location().Transforms(tempXYZ);
308   return gp_Pnt(tempXYZ);
309 }
310
311     Standard_Real  IGESDimen_NewGeneralNote::ZDepthStartPoint
312   (const Standard_Integer Index) const 
313 {
314   return (theStartPoints->Value(Index).Z());
315 }
316
317     Handle(TCollection_HAsciiString)  IGESDimen_NewGeneralNote::Text
318   (const Standard_Integer Index) const 
319 {
320   return theTexts->Value(Index);
321 }