973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
42cf5bc1 |
14 | |
15 | #include <Standard_Type.hxx> |
16 | #include <Vrml_AsciiText.hxx> |
7fd59977 |
17 | |
25e59720 |
18 | IMPLEMENT_STANDARD_RTTIEXT(Vrml_AsciiText,Standard_Transient) |
92efcf78 |
19 | |
b311480e |
20 | Vrml_AsciiText::Vrml_AsciiText() |
7fd59977 |
21 | { |
22 | TCollection_AsciiString tmpS(""); |
23 | myString = new TColStd_HArray1OfAsciiString(1,1,tmpS); |
24 | |
25 | mySpacing = 1; |
26 | myJustification = Vrml_LEFT; |
27 | myWidth = 0; |
28 | } |
29 | |
30 | Vrml_AsciiText::Vrml_AsciiText(const Handle(TColStd_HArray1OfAsciiString)& aString, |
31 | const Standard_Real aSpacing, |
32 | const Vrml_AsciiTextJustification aJustification, |
33 | const Standard_Real aWidth) |
34 | { |
35 | myString = aString; |
36 | mySpacing = aSpacing; |
37 | myJustification = aJustification; |
38 | myWidth = aWidth; |
39 | } |
40 | |
41 | void Vrml_AsciiText::SetString(const Handle(TColStd_HArray1OfAsciiString)& aString) |
42 | { |
43 | myString = aString; |
44 | } |
45 | |
46 | Handle(TColStd_HArray1OfAsciiString) Vrml_AsciiText::String() const |
47 | { |
48 | return myString; |
49 | } |
50 | |
51 | void Vrml_AsciiText::SetSpacing(const Standard_Real aSpacing) |
52 | { |
53 | mySpacing = aSpacing; |
54 | } |
55 | |
56 | Standard_Real Vrml_AsciiText::Spacing() const |
57 | { |
58 | return mySpacing; |
59 | } |
60 | |
61 | void Vrml_AsciiText::SetJustification(const Vrml_AsciiTextJustification aJustification) |
62 | { |
63 | myJustification = aJustification; |
64 | } |
65 | |
66 | Vrml_AsciiTextJustification Vrml_AsciiText::Justification() const |
67 | { |
68 | return myJustification; |
69 | } |
70 | |
71 | void Vrml_AsciiText::SetWidth(const Standard_Real aWidth) |
72 | { |
73 | myWidth = aWidth; |
74 | } |
75 | |
76 | Standard_Real Vrml_AsciiText::Width() const |
77 | { |
78 | return myWidth; |
79 | } |
80 | |
81 | Standard_OStream& Vrml_AsciiText::Print(Standard_OStream& anOStream) const |
82 | { |
83 | Standard_Integer i; |
84 | |
586db386 |
85 | anOStream << "AsciiText {\n"; |
7fd59977 |
86 | |
87 | i = myString->Lower(); |
88 | |
89 | if ( myString->Length() != 1 || myString->Value(i) != "" ) |
90 | { |
586db386 |
91 | anOStream << " string [\n\t"; |
7fd59977 |
92 | |
93 | for ( i = myString->Lower(); i <= myString->Upper(); i++ ) |
94 | { |
95 | anOStream << '"' << myString->Value(i) << '"'; |
96 | if ( i < myString->Length() ) |
586db386 |
97 | anOStream << ",\n\t"; |
7fd59977 |
98 | } |
586db386 |
99 | anOStream << " ]\n"; |
7fd59977 |
100 | } |
101 | |
102 | if ( Abs(mySpacing - 1 ) > 0.0001 ) |
103 | { |
586db386 |
104 | anOStream << " spacing\t\t"; |
105 | anOStream << mySpacing << "\n"; |
7fd59977 |
106 | } |
107 | |
108 | switch ( myJustification ) |
109 | { |
586db386 |
110 | case Vrml_LEFT: break; // anOStream << " justification\t LEFT"; |
111 | case Vrml_CENTER: anOStream << " justification\tCENTER\n"; break; |
112 | case Vrml_RIGHT: anOStream << " justification\tRIGHT\n"; break; |
7fd59977 |
113 | } |
114 | |
115 | if ( Abs(myWidth - 0 ) > 0.0001 ) |
116 | { |
586db386 |
117 | anOStream << " width\t\t"; |
118 | anOStream << myWidth << "\n"; |
7fd59977 |
119 | } |
120 | |
586db386 |
121 | anOStream << "}\n"; |
7fd59977 |
122 | return anOStream; |
123 | } |