7fd59977 |
1 | #include <Aspect_WidthMapEntry.ixx> |
2 | #include <Aspect_Units.hxx> |
3 | |
4 | Aspect_WidthMapEntry::Aspect_WidthMapEntry() { |
5 | |
6 | SetPredefinedStyle(Aspect_WOL_THIN); |
7 | MyIndexIsDef = Standard_True; |
8 | MyIndex = 0; |
9 | |
10 | } |
11 | |
12 | Aspect_WidthMapEntry::Aspect_WidthMapEntry (const Standard_Integer index, const Aspect_WidthOfLine style) { |
13 | |
14 | SetPredefinedStyle(style); |
15 | MyIndexIsDef = Standard_True; |
16 | MyIndex = index; |
17 | |
18 | } |
19 | |
20 | Aspect_WidthMapEntry::Aspect_WidthMapEntry (const Standard_Integer index, const Quantity_Length width) { |
21 | |
22 | if( width < 0. ) |
23 | Aspect_BadAccess::Raise("Bad Line Width") ; |
24 | |
25 | MyType = Aspect_WOL_USERDEFINED ; |
26 | MyTypeIsDef = Standard_True; |
27 | MyIndexIsDef = Standard_True; |
28 | MyIndex = index; |
29 | MyWidth = width; |
30 | |
31 | } |
32 | |
33 | Aspect_WidthMapEntry::Aspect_WidthMapEntry (const Aspect_WidthMapEntry& entry) { |
34 | |
35 | if ( !entry.MyTypeIsDef || !entry.MyIndexIsDef ) { |
36 | Aspect_BadAccess::Raise("Unallocated WidthMapEntry") ; |
37 | } |
38 | else { |
39 | MyTypeIsDef = Standard_True; |
40 | MyIndexIsDef = Standard_True; |
41 | MyIndex = entry.MyIndex; |
42 | MyType = entry.MyType; |
43 | MyWidth = entry.MyWidth; |
44 | } |
45 | } |
46 | |
47 | void Aspect_WidthMapEntry::SetValue (const Standard_Integer index, const Aspect_WidthOfLine style) { |
48 | |
49 | SetPredefinedStyle(style); |
50 | MyIndexIsDef = Standard_True; |
51 | MyIndex = index; |
52 | |
53 | } |
54 | |
55 | void Aspect_WidthMapEntry::SetValue (const Standard_Integer index, const Quantity_Length width) { |
56 | |
57 | if( width < 0. ) |
58 | Aspect_BadAccess::Raise("Bad Line Width") ; |
59 | |
60 | MyType = Aspect_WOL_USERDEFINED ; |
61 | MyTypeIsDef = Standard_True; |
62 | MyWidth = width ; |
63 | MyIndexIsDef = Standard_True; |
64 | MyIndex = index; |
65 | |
66 | } |
67 | |
68 | void Aspect_WidthMapEntry::SetValue (const Aspect_WidthMapEntry& entry) { |
69 | |
70 | if ( !entry.MyTypeIsDef || !entry.MyIndexIsDef ) { |
71 | Aspect_BadAccess::Raise("Unallocated WidthMapEntry") ; |
72 | } |
73 | else { |
74 | MyTypeIsDef = Standard_True; |
75 | MyIndexIsDef = Standard_True; |
76 | MyIndex = entry.MyIndex; |
77 | MyType = entry.MyType; |
78 | MyWidth = entry.MyWidth; |
79 | } |
80 | |
81 | } |
82 | |
83 | void Aspect_WidthMapEntry::SetType (const Aspect_WidthOfLine style) { |
84 | |
85 | SetPredefinedStyle(style); |
86 | |
87 | } |
88 | |
89 | void Aspect_WidthMapEntry::SetWidth (const Quantity_Length width) { |
90 | |
91 | if( width < 0. ) |
92 | Aspect_BadAccess::Raise("Bad Line Width") ; |
93 | |
94 | MyType = Aspect_WOL_USERDEFINED ; |
95 | MyTypeIsDef = Standard_True; |
96 | MyWidth = width ; |
97 | |
98 | } |
99 | |
100 | Aspect_WidthOfLine Aspect_WidthMapEntry::Type () const { |
101 | |
102 | if ( !MyTypeIsDef || !MyIndexIsDef ) |
103 | Aspect_BadAccess::Raise("Unallocated WidthMapEntry") ; |
104 | |
105 | return MyType; |
106 | |
107 | } |
108 | |
109 | Standard_Real Aspect_WidthMapEntry::Width () const { |
110 | |
111 | if ( !MyTypeIsDef || !MyIndexIsDef ) |
112 | Aspect_BadAccess::Raise("Unallocated WidthMapEntry") ; |
113 | |
114 | return MyWidth; |
115 | |
116 | } |
117 | |
118 | void Aspect_WidthMapEntry::SetIndex (const Standard_Integer index) { |
119 | |
120 | MyTypeIsDef = Standard_True; |
121 | MyIndex = index; |
122 | |
123 | } |
124 | |
125 | Standard_Integer Aspect_WidthMapEntry::Index () const { |
126 | |
127 | if ( !MyTypeIsDef || !MyIndexIsDef ) |
128 | Aspect_BadAccess::Raise("Unallocated WidthMapEntry"); |
129 | |
130 | return MyIndex; |
131 | |
132 | } |
133 | |
134 | Standard_Boolean Aspect_WidthMapEntry::IsAllocated () const { |
135 | |
136 | return ( MyTypeIsDef && MyIndexIsDef ) ; |
137 | |
138 | } |
139 | |
140 | void Aspect_WidthMapEntry::Free () { |
141 | |
142 | MyTypeIsDef = Standard_False; |
143 | MyIndexIsDef = Standard_False; |
144 | |
145 | } |
146 | |
147 | void Aspect_WidthMapEntry::Dump () const { |
148 | |
149 | cout << " Aspect_WidthMapEntry::Dump ()\n"; |
150 | cout << " MyTypeIsDef : " << (MyTypeIsDef) ? "True\n" : "False\n"; |
151 | cout << " MyIndexIsDef : " << (MyIndexIsDef) ? "True\n" : "False\n"; |
152 | cout << " TypeOfWidth : " << (Standard_Integer) MyType << "\n";//WNT |
153 | cout << " LineWidth : " << MyWidth << "\n"; |
154 | cout << flush; |
155 | } |
156 | |
157 | void Aspect_WidthMapEntry::SetPredefinedStyle(const Aspect_WidthOfLine Style) { |
158 | |
159 | MyType = Style ; |
160 | MyTypeIsDef = Standard_True; |
161 | switch ( Style ) { |
162 | case Aspect_WOL_USERDEFINED : |
163 | Aspect_BadAccess::Raise("Bad Predefined Line Width Style") ; |
164 | case Aspect_WOL_THIN: |
165 | MyWidth = 0.25 MILLIMETER ; |
166 | break ; |
167 | case Aspect_WOL_MEDIUM : |
168 | MyWidth = 0.5 MILLIMETER ; |
169 | break ; |
170 | case Aspect_WOL_THICK : |
171 | MyWidth = 0.7 MILLIMETER ; |
172 | break ; |
173 | case Aspect_WOL_VERYTHICK : |
174 | MyWidth = 1.5 MILLIMETER ; |
175 | break ; |
176 | } |
177 | } |