]> Shamusworld >> Repos - architektonas/blob - src/base/enums.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / base / enums.cpp
1 // enums.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  09/08/2010  Created this file. :-)
15 //
16
17 #include "enums.h"
18
19
20 /**
21  * Wrapper for Qt (ick)
22  */
23 /*static*/ Qt::PenStyle RS2::rsToQtLineType(RS2::LineType t)
24 {
25         switch (t)
26         {
27         case NoPen:
28                 return Qt::NoPen;
29                 break;
30         case SolidLine:
31                 return Qt::SolidLine;
32                 break;
33         case DotLine:
34         case DotLine2:
35         case DotLineX2:
36                 return Qt::DotLine;
37                 break;
38         case DashLine:
39         case DashLine2:
40         case DashLineX2:
41                 return Qt::DashLine;
42                 break;
43         case DashDotLine:
44         case DashDotLine2:
45         case DashDotLineX2:
46                 return Qt::DashDotLine;
47                 break;
48         case DivideLine:
49         case DivideLine2:
50         case DivideLineX2:
51                 return Qt::DashDotDotLine;
52                 break;
53         case CenterLine:
54         case CenterLine2:
55         case CenterLineX2:
56                 return Qt::DashDotLine;
57                 break;
58         case BorderLine:
59         case BorderLine2:
60         case BorderLineX2:
61                 return Qt::DashDotLine;
62                 break;
63         case LineByLayer:
64         case LineByBlock:
65         default:
66                 return Qt::SolidLine;
67                 break;
68         }
69         return Qt::SolidLine;
70 }
71
72 /**
73  * Wrapper for Qt. (ick)
74  */
75 /*static*/ RS2::LineType RS2::qtToRsPenStyle(Qt::PenStyle s)
76 {
77         switch (s)
78         {
79         case Qt::NoPen:
80                 return NoPen;
81         case Qt::SolidLine:
82                 return SolidLine;
83                 break;
84         case Qt::DashLine:
85                 return DashLine;
86                 break;
87         case Qt::DotLine:
88                 return DotLine;
89                 break;
90         case Qt::DashDotLine:
91                 return DashDotLine;
92                 break;
93         case Qt::DashDotDotLine:
94                 return DivideLine;
95                 break;
96         default:
97                 return SolidLine;
98                 break;
99         }
100
101         return SolidLine;
102 }
103
104 /**
105  * Wrapper for Qt (ick)
106  */
107 /*static*/ RS2::LineWidth RS2::intToLineWidth(int w)
108 {
109         if (w == -3)
110         {
111                 return WidthDefault;
112         }
113         else if (w == -2)
114         {
115                 return WidthByBlock;
116         }
117         else if (w == -1)
118         {
119                 return WidthByLayer;
120         }
121         else if (w < 3)
122         {
123                 return Width00;
124         }
125         else if (w < 8)
126         {
127                 return Width01;
128         }
129         else if (w < 12)
130         {
131                 return Width02;
132         }
133         else if (w < 14)
134         {
135                 return Width03;
136         }
137         else if (w < 17)
138         {
139                 return Width04;
140         }
141         else if (w < 19)
142         {
143                 return Width05;
144         }
145         else if (w < 23)
146         {
147                 return Width06;
148         }
149         else if (w < 28)
150         {
151                 return Width07;
152         }
153         else if (w < 33)
154         {
155                 return Width08;
156         }
157         else if (w < 38)
158         {
159                 return Width09;
160         }
161         else if (w < 46)
162         {
163                 return Width10;
164         }
165         else if (w < 52)
166         {
167                 return Width11;
168         }
169         else if (w < 57)
170         {
171                 return Width12;
172         }
173         else if (w < 66)
174         {
175                 return Width13;
176         }
177         else if (w < 76)
178         {
179                 return Width14;
180         }
181         else if (w < 86)
182         {
183                 return Width15;
184         }
185         else if (w < 96)
186         {
187                 return Width16;
188         }
189         else if (w < 104)
190         {
191                 return Width17;
192         }
193         else if (w < 114)
194         {
195                 return Width18;
196         }
197         else if (w < 131)
198         {
199                 return Width19;
200         }
201         else if (w < 150)
202         {
203                 return Width20;
204         }
205         else if (w < 180)
206         {
207                 return Width21;
208         }
209         else if (w < 206)
210         {
211                 return Width22;
212         }
213         else
214         {
215                 return Width23;
216         }
217 }
218
219 /**
220  * Wrapper for Qt. (ick)
221  */
222 /*static*/ Qt::CursorShape RS2::rsToQtCursorType(RS2::CursorType t)
223 {
224         switch (t)
225         {
226         case ArrowCursor:
227                 return Qt::ArrowCursor;
228                 break;
229         case UpArrowCursor:
230                 return Qt::UpArrowCursor;
231                 break;
232         case CrossCursor:
233                 return Qt::CrossCursor;
234                 break;
235         case WaitCursor:
236                 return Qt::WaitCursor;
237                 break;
238         case IbeamCursor:
239                 return Qt::IBeamCursor;
240                 break;
241         case SizeVerCursor:
242                 return Qt::SizeVerCursor;
243                 break;
244         case SizeHorCursor:
245                 return Qt::SizeHorCursor;
246                 break;
247         case SizeBDiagCursor:
248                 return Qt::SizeBDiagCursor;
249                 break;
250         case SizeFDiagCursor:
251                 return Qt::SizeFDiagCursor;
252                 break;
253         case SizeAllCursor:
254                 return Qt::SizeAllCursor;
255                 break;
256         case BlankCursor:
257                 return Qt::BlankCursor;
258                 break;
259         case SplitVCursor:
260                 return Qt::SplitVCursor;
261                 break;
262         case SplitHCursor:
263                 return Qt::SplitHCursor;
264                 break;
265         case PointingHandCursor:
266                 return Qt::PointingHandCursor;
267                 break;
268         case ForbiddenCursor:
269                 return Qt::ForbiddenCursor;
270                 break;
271         case WhatsThisCursor:
272                 return Qt::WhatsThisCursor;
273                 break;
274         default:
275                 return Qt::ArrowCursor;
276                 break;
277         }
278
279         return Qt::ArrowCursor;
280 }
281
282 /**
283  * Wrapper for Qt. (ick)
284  */
285 /*static*/ QPrinter::PageSize RS2::rsToQtPaperFormat(RS2::PaperFormat f)
286 {
287         QPrinter::PageSize ret;
288
289         switch (f)
290         {
291         case Custom:
292                 ret = QPrinter::Custom;
293                 break;
294         case Letter:
295                 ret = QPrinter::Letter;
296                 break;
297         case Legal:
298                 ret = QPrinter::Legal;
299                 break;
300         case Executive:
301                 ret = QPrinter::Executive;
302                 break;
303         case A0:
304                 ret = QPrinter::A0;
305                 break;
306         case A1:
307                 ret = QPrinter::A1;
308                 break;
309         case A2:
310                 ret = QPrinter::A2;
311                 break;
312         case A3:
313                 ret = QPrinter::A3;
314                 break;
315         default:
316         case A4:
317                 ret = QPrinter::A4;
318                 break;
319         case A5:
320                 ret = QPrinter::A5;
321                 break;
322         case A6:
323                 ret = QPrinter::A6;
324                 break;
325         case A7:
326                 ret = QPrinter::A7;
327                 break;
328         case A8:
329                 ret = QPrinter::A8;
330                 break;
331         case A9:
332                 ret = QPrinter::A9;
333                 break;
334         case B0:
335                 ret = QPrinter::B0;
336                 break;
337         case B1:
338                 ret = QPrinter::B1;
339                 break;
340         case B2:
341                 ret = QPrinter::B2;
342                 break;
343         case B3:
344                 ret = QPrinter::B3;
345                 break;
346         case B4:
347                 ret = QPrinter::B4;
348                 break;
349         case B5:
350                 ret = QPrinter::B5;
351                 break;
352         case B6:
353                 ret = QPrinter::B6;
354                 break;
355         case B7:
356                 ret = QPrinter::B7;
357                 break;
358         case B8:
359                 ret = QPrinter::B8;
360                 break;
361         case B9:
362                 ret = QPrinter::B9;
363                 break;
364         case B10:
365                 ret = QPrinter::B10;
366                 break;
367         case C5E:
368                 ret = QPrinter::C5E;
369                 break;
370         case Comm10E:
371                 ret = QPrinter::Comm10E;
372                 break;
373         case DLE:
374                 ret = QPrinter::DLE;
375                 break;
376         case Folio:
377                 ret = QPrinter::Folio;
378                 break;
379         //case Ledger:
380         //      ret = QPrinter::Ledger;
381         //      break;
382         case Tabloid:
383                 ret = QPrinter::Tabloid;
384                 break;
385         case NPageSize:
386                 ret = QPrinter::NPageSize;
387                 break;
388         }
389
390         return ret;
391 }