b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <Vrml_AsciiText.ixx> |
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 | |
85 | anOStream << "AsciiText {" << endl; |
86 | |
87 | i = myString->Lower(); |
88 | |
89 | if ( myString->Length() != 1 || myString->Value(i) != "" ) |
90 | { |
91 | anOStream << " string [" << endl << '\t'; |
92 | |
93 | for ( i = myString->Lower(); i <= myString->Upper(); i++ ) |
94 | { |
95 | anOStream << '"' << myString->Value(i) << '"'; |
96 | if ( i < myString->Length() ) |
97 | anOStream << ',' << endl << '\t'; |
98 | } |
99 | anOStream << " ]" << endl; |
100 | } |
101 | |
102 | if ( Abs(mySpacing - 1 ) > 0.0001 ) |
103 | { |
104 | anOStream << " spacing" << "\t\t"; |
105 | anOStream << mySpacing << endl; |
106 | } |
107 | |
108 | switch ( myJustification ) |
109 | { |
110 | case Vrml_LEFT: break; // anOStream << " justification" << "\t LEFT"; |
111 | case Vrml_CENTER: anOStream << " justification" << "\tCENTER" << endl; break; |
112 | case Vrml_RIGHT: anOStream << " justification" << "\tRIGHT" << endl; break; |
113 | } |
114 | |
115 | if ( Abs(myWidth - 0 ) > 0.0001 ) |
116 | { |
117 | anOStream << " width" << "\t\t"; |
118 | anOStream << myWidth << endl; |
119 | } |
120 | |
121 | anOStream << '}' << endl; |
122 | return anOStream; |
123 | } |