]> Shamusworld >> Repos - architektonas/blob - src/base/rs.h
Initial removal of unnecessary rs_ prefixes from files.
[architektonas] / src / base / rs.h
1 #ifndef __RS_H__
2 #define __RS_H__
3
4 #include <QtGui>
5 #include <QPrinter>
6
7 #define RS_TEST
8
9 #ifdef RS_TEST
10 #include <assert.h>
11 #endif
12
13 // Windoze XP can't handle the original MAX/MINDOUBLE's
14 #define RS_MAXDOUBLE 1.0E+10
15 #define RS_MINDOUBLE -1.0E+10
16
17 /**
18  * Class namespace for various enums along with some simple wrapper methods for
19  * converting the enums to the Qt counterparts.
20  *
21  * @author James Hammons
22  * @author Andrew Mustun
23  */
24 class RS2
25 {
26 public:
27
28     /**
29      * Flags.
30      */
31     enum Flags {
32         /** Flag for Undoables. */
33         FlagUndone      = 1 << 0,
34         /** Entity Visibility. */
35         FlagVisible     = 1 << 1,
36         /** Entity attribute (e.g. color) is defined by layer. */
37         FlagByLayer     = 1 << 2,
38         /** Entity attribute (e.g. color) defined by block. */
39         FlagByBlock     = 1 << 3,
40         /** Layer frozen. */
41         FlagFrozen      = 1 << 4,
42         /** Layer frozen by default. */
43         FlagDefFrozen   = 1 << 5,
44         /** Layer locked. */
45         FlagLocked      = 1 << 6,
46         /** Used for invalid pens. */
47         FlagInvalid     = 1 << 7,
48         /** Entity in current selection. */
49         FlagSelected    = 1 << 8,
50         /** Polyline closed? */
51         FlagClosed      = 1 << 9,
52         /** Flag for temporary entities (e.g. hatch) */
53         FlagTemp        = 1 << 10,
54         /** Flag for processed entities (optcontour) */
55         FlagProcessed   = 1 << 11,
56         /** Startpoint selected */
57         FlagSelected1   = 1 << 12,
58         /** Endpoint selected */
59         FlagSelected2   = 1 << 13,
60                 /** Entity is highlighted temporarily (as a user action feedback) */
61                 FlagHighlighted = 1 << 14
62     };
63
64     /**
65      * Variable types used by RS_VariableDict and RS_Variable.
66      */
67     enum VariableType {
68         VariableString,
69         VariableInt,
70         VariableDouble,
71         VariableVector,
72         VariableVoid
73     };
74
75     /**
76      * File types. Used by file dialogs. Note: the extension might not
77      * be enough to distinguish file types.
78      */
79     enum FormatType {
80         FormatUnknown,       /**< Unknown / unsupported format. */
81         FormatDXF1,          /**< QCad 1 compatibility DXF format. */
82         FormatDXF,           /**< DXF format. 2000. */
83         FormatDXF12,         /**< DXF format. R12. */
84         FormatCXF,           /**< CAM Expert Font format. */
85                 FormatCAM            /**< CAM Expert CAM format (NC, CNC, D, ..) */
86     };
87
88     /**
89      * Entity types returned by the rtti() method
90      */
91     enum EntityType {
92         EntityUnknown,      /**< Unknown */
93         EntityContainer,    /**< Container */
94         EntityBlock,        /**< Block (Group definition) */
95         EntityFontChar,     /**< Font character */
96         EntityInsert,       /**< Insert (Group instance) */
97         EntityGraphic,      /**< Graphic with layers */
98         EntityPoint,        /**< Point */
99         EntityLine,         /**< Line */
100         EntityPolyline,     /**< Polyline */
101         EntityVertex,       /**< Vertex (part of a polyline) */
102         EntityArc,          /**< Arc */
103         EntityCircle,       /**< Circle */
104         EntityEllipse,      /**< Ellipse */
105         EntitySolid,        /**< Ellipse */
106         EntityConstructionLine, /**< Construction line */
107         EntityText,         /**< Text */
108         EntityDimAligned,   /**< Aligned Dimension */
109         EntityDimLinear,    /**< Linear Dimension */
110         EntityDimRadial,    /**< Radial Dimension */
111         EntityDimDiametric, /**< Diametric Dimension */
112         EntityDimAngular,   /**< Angular Dimension */
113         EntityDimLeader,    /**< Leader Dimension */
114         EntityHatch,        /**< Hatch */
115         EntityImage,        /**< Image */
116         EntitySpline        /**< Spline */
117     };
118
119     /**
120      * Action types used by action factories.
121      */
122     enum ActionType {
123         ActionNone,        /**< Invalid action id. */
124
125         ActionDefault,
126
127         ActionFileNew,
128         ActionFileOpen,
129         ActionFileSave,
130         ActionFileSaveAs,
131         ActionFileExport,
132         ActionFileClose,
133         ActionFilePrint,
134         ActionFilePrintPreview,
135         ActionFileQuit,
136
137         ActionPrintPreview,
138
139         ActionEditUndo,
140         ActionEditRedo,
141         ActionEditCut,
142         ActionEditCutNoSelect,
143         ActionEditCopy,
144         ActionEditCopyNoSelect,
145         ActionEditPaste,
146
147         ActionViewStatusBar,
148         ActionViewLayerList,
149         ActionViewBlockList,
150         ActionViewCommandLine,
151         ActionViewOptionToolbar,
152         ActionViewGrid,
153         ActionViewDraft,
154
155         ActionZoomIn,
156         ActionZoomOut,
157         ActionZoomAuto,
158         ActionZoomWindow,
159         ActionZoomPan,
160         ActionZoomRedraw,
161         ActionZoomPrevious,
162
163         ActionSelectSingle,
164         ActionSelectContour,
165         ActionSelectWindow,
166         ActionDeselectWindow,
167         ActionSelectAll,
168         ActionDeselectAll,
169         ActionSelectIntersected,
170         ActionDeselectIntersected,
171         ActionSelectInvert,
172         ActionSelectLayer,
173         ActionSelectDouble,
174
175         ActionDrawArc,
176         ActionDrawArc3P,
177         ActionDrawArcParallel,
178         ActionDrawArcTangential,
179         ActionDrawCircle,
180         ActionDrawCircle2P,
181         ActionDrawCircle3P,
182         ActionDrawCircleCR,
183         ActionDrawCircleParallel,
184         ActionDrawEllipseArcAxis,
185         ActionDrawEllipseAxis,
186         ActionDrawHatch,
187         ActionDrawHatchNoSelect,
188         ActionDrawImage,
189         ActionDrawLine,
190         ActionDrawLineAngle,
191         ActionDrawLineBisector,
192         ActionDrawLineFree,
193         ActionDrawLineHorVert,
194         ActionDrawLineHorizontal,
195         ActionDrawLineOrthogonal,
196         ActionDrawLineParallel,
197         ActionDrawLineParallelThrough,
198         ActionDrawLinePolygon,
199         ActionDrawLinePolygon2,
200         ActionDrawLineRectangle,
201         ActionDrawLineRelAngle,
202         ActionDrawLineTangent1,
203         ActionDrawLineTangent2,
204         ActionDrawLineVertical,
205         ActionDrawPoint,
206         ActionDrawSpline,
207         ActionDrawPolyline,
208         ActionDrawText,
209
210                 ActionPolylineAdd,
211                 ActionPolylineAppend,
212                 ActionPolylineDel,
213                 ActionPolylineDelBetween,
214                 ActionPolylineTrim,
215
216         ActionDimAligned,
217         ActionDimLinear,
218         ActionDimLinearVer,
219         ActionDimLinearHor,
220         ActionDimRadial,
221         ActionDimDiametric,
222         ActionDimAngular,
223         ActionDimLeader,
224
225         ActionModifyAttributes,
226         ActionModifyAttributesNoSelect,
227         ActionModifyDelete,
228         ActionModifyDeleteNoSelect,
229         ActionModifyDeleteQuick,
230         ActionModifyDeleteFree,
231         ActionModifyMove,
232         ActionModifyMoveNoSelect,
233         ActionModifyRotate,
234         ActionModifyRotateNoSelect,
235         ActionModifyScale,
236         ActionModifyScaleNoSelect,
237         ActionModifyMirror,
238         ActionModifyMirrorNoSelect,
239         ActionModifyMoveRotate,
240         ActionModifyMoveRotateNoSelect,
241         ActionModifyRotate2,
242         ActionModifyRotate2NoSelect,
243         ActionModifyEntity,
244         ActionModifyTrim,
245         ActionModifyTrim2,
246         ActionModifyTrimAmount,
247         ActionModifyCut,
248         ActionModifyStretch,
249         ActionModifyBevel,
250         ActionModifyRound,
251
252         ActionSnapFree,
253         ActionSnapGrid,
254         ActionSnapEndpoint,
255         ActionSnapOnEntity,
256         ActionSnapCenter,
257         ActionSnapMiddle,
258         ActionSnapDist,
259         ActionSnapIntersection,
260         ActionSnapIntersectionManual,
261
262         ActionRestrictNothing,
263         ActionRestrictOrthogonal,
264         ActionRestrictHorizontal,
265         ActionRestrictVertical,
266
267         ActionSetRelativeZero,
268         ActionLockRelativeZero,
269         ActionUnlockRelativeZero,
270
271         ActionInfoInside,
272         ActionInfoDist,
273         ActionInfoDist2,
274         ActionInfoAngle,
275         ActionInfoTotalLength,
276         ActionInfoTotalLengthNoSelect,
277         ActionInfoArea,
278
279         ActionLayersDefreezeAll,
280         ActionLayersFreezeAll,
281         ActionLayersAdd,
282         ActionLayersRemove,
283         ActionLayersEdit,
284         ActionLayersToggleView,
285         ActionLayersToggleLock,
286
287         ActionBlocksDefreezeAll,
288         ActionBlocksFreezeAll,
289         ActionBlocksAdd,
290         ActionBlocksRemove,
291         ActionBlocksAttributes,
292         ActionBlocksEdit,
293         ActionBlocksInsert,
294         ActionBlocksToggleView,
295         ActionBlocksCreate,
296         ActionBlocksCreateNoSelect,
297         ActionBlocksExplode,
298         ActionBlocksExplodeNoSelect,
299
300         ActionModifyExplodeText,
301         ActionModifyExplodeTextNoSelect,
302
303         ActionLibraryInsert,
304
305         ActionOptionsGeneral,
306         ActionOptionsDrawing,
307
308                 ActionToolRegenerateDimensions,
309
310                 ActionScriptOpenIDE,
311                 ActionScriptRun,
312
313 #ifndef RS_NO_COMPLEX_ENTITIES
314                 ActionPARISDebugCreateContainer,
315 #endif
316
317 #ifdef RS_CAM
318                 ActionCamExportAuto,
319                 ActionCamReorder,
320 #endif
321
322         /** Needed to loop through all actions */
323         ActionLast
324     };
325
326     /**
327     * Entity ending. Used for returning which end of an entity is ment.
328      */
329     enum Ending {
330         EndingStart,    /**< Start point. */
331         EndingEnd,      /**< End point. */
332         EndingNone      /**< Neither. */
333     };
334
335     /**
336      * Update mode for non-atomic entities that need to be updated when
337      * they change. e.g. texts, inserts, ...
338      */
339     enum UpdateMode {
340         NoUpdate,       /**< No automatic updates. */
341         Update,         /**< Always update automatically when modified. */
342                 PreviewUpdate   /**< Update automatically but only for previews (quick update) */
343     };
344
345     /**
346      * Drawing mode.
347      */
348     enum DrawingMode {
349         ModeFull,       /**< Draw everything always detailed (default) */
350         ModeAuto,       /**< Draw details when reasonable */
351         ModePreview,    /**< Draw only in black/white without styles */
352         ModeXOR,        /**< XOR mode for moving previews */
353                 ModeBW          /**< Black/white. Can be used for printing. */
354     };
355
356     /**
357      * Undoable rtti.
358      */
359     enum UndoableType {
360         UndoableUnknown,    /**< Unknown undoable */
361         UndoableEntity,     /**< Entity */
362         UndoableLayer       /**< Layer */
363     };
364
365     /**
366      * Toolbar ID's.
367      */
368     enum ToolBarId {
369         ToolBarMain,        /**< Main (menu). */
370         ToolBarPoints,      /**< Points. */
371         ToolBarLines,       /**< Lines. */
372         ToolBarArcs,        /**< Arcs. */
373         ToolBarCircles,     /**< Circles. */
374         ToolBarEllipses,    /**< Ellipses. */
375         ToolBarSplines,     /**< Splines. */
376         ToolBarPolylines,   /**< Polylines. */
377         ToolBarText,        /**< Text. */
378         ToolBarDim,         /**< Dimensions. */
379         ToolBarSnap,        /**< Snap. */
380         ToolBarModify,      /**< Modify. */
381         ToolBarSelect,      /**< Select. */
382         ToolBarInfo         /**< Information */
383     };
384
385     /**
386      * Units.
387      */
388     enum Unit {
389         None = 0,               /**< No unit (unit from parent) */
390         Inch = 1,               /**< Inch */
391         Foot = 2,               /**< Foot: 12 Inches */
392         Mile = 3,               /**< Mile: 1760 Yards = 1609 m */
393         Millimeter = 4,         /**< Millimeter: 0.001m */
394         Centimeter = 5,         /**< Centimeter: 0.01m */
395         Meter = 6,              /**< Meter */
396         Kilometer = 7,          /**< Kilometer: 1000m */
397         Microinch = 8,          /**< Microinch: 0.000001 */
398         Mil = 9,                /**< Mil = 0.001 Inch*/
399         Yard = 10,              /**< Yard: 3 Feet */
400         Angstrom = 11,          /**< Angstrom: 10^-10m  */
401         Nanometer = 12,         /**< Nanometer: 10^-9m  */
402         Micron = 13,            /**< Micron: 10^-6m  */
403         Decimeter = 14,         /**< Decimeter: 0.1m */
404         Decameter = 15,         /**< Decameter: 10m */
405         Hectometer = 16,        /**< Hectometer: 100m */
406         Gigameter = 17,         /**< Gigameter: 1000000m */
407         Astro = 18,             /**< Astro: 149.6 x 10^9m */
408         Lightyear = 19,         /**< Lightyear: 9460731798 x 10^6m */
409         Parsec = 20,            /**< Parsec: 30857 x 10^12 */
410
411         LastUnit = 21           /**< Used to iterate through units */
412     };
413
414
415     /**
416      * Format for length values.
417      */
418     enum LinearFormat {
419         /** Scientific (e.g. 2.5E+05) */
420         Scientific,
421         /** Decimal (e.g. 9.5)*/
422         Decimal,
423         /** Engineering (e.g. 7' 11.5")*/
424         Engineering,
425         /** Architectural (e.g. 7'-9 1/8")*/
426         Architectural,
427         /** Fractional (e.g. 7 9 1/8) */
428         Fractional
429     };
430
431     /**
432      * Angle Units.
433      */
434     enum AngleUnit {
435         Deg,               /**< Degrees */
436         Rad,               /**< Radians */
437         Gra                /**< Gradians */
438     };
439
440     /**
441      * Display formats for angles.
442      */
443     enum AngleFormat {
444         /** Degrees with decimal point (e.g. 24.5°) */
445         DegreesDecimal,
446         /** Degrees, Minutes and Seconds (e.g. 24°30'5") */
447         DegreesMinutesSeconds,
448         /** Gradians with decimal point (e.g. 390.5)*/
449         Gradians,
450         /** Radians with decimal point (e.g. 1.57)*/
451         Radians,
452         /** Surveyor's units */
453         Surveyors
454     };
455
456     /**
457      * Enum of levels of resolving when iterating through an entity tree.
458      */
459     enum ResolveLevel {
460         /** Groups are not resolved */
461         ResolveNone,
462                 /**
463                  * Resolve all but not Inserts.
464                  */
465                 ResolveAllButInserts,
466         /**
467          * all Entity Containers are resolved
468          * (including Texts, Polylines, ...)
469          */
470         ResolveAll
471     };
472
473     /**
474      * Direction used for scrolling actions.
475      */
476     enum Direction {
477         Up, Left, Right, Down
478     };
479
480     /**
481      * Vertical alignments.
482      */
483     enum VAlign {
484         VAlignTop,      /**< Top. */
485         VAlignMiddle,   /**< Middle */
486         VAlignBottom    /**< Bottom */
487     };
488
489     /**
490      * Horizontal alignments.
491      */
492     enum HAlign {
493         HAlignLeft,     /**< Left */
494         HAlignCenter,   /**< Centered */
495         HAlignRight     /**< Right */
496     };
497
498     /**
499      * Text drawing direction.
500      */
501     enum TextDrawingDirection {
502         LeftToRight,     /**< Left to right */
503         TopToBottom,     /**< Top to bottom */
504         ByStyle          /**< Inherited from associated text style */
505     };
506
507     /**
508      * Line spacing style for texts.
509      */
510     enum TextLineSpacingStyle {
511         AtLeast,        /**< Taller characters will override */
512         Exact           /**< Taller characters will not override */
513     };
514
515     /**
516      * Leader path type.
517      */
518     enum LeaderPathType {
519         Straight,      /**< Straight line segments */
520         Spline         /**< Splines */
521     };
522
523     /**
524      * Direction for zooming actions.
525      */
526     enum ZoomDirection {
527         In, Out
528     };
529
530     /**
531      * Axis specification for zooming actions.
532      */
533     enum Axis {
534         OnlyX, OnlyY, Both
535     };
536
537     /**
538      * Snapping modes
539      */
540     enum SnapMode {
541         SnapFree,         /**< Free positioning */
542         SnapGrid,         /**< Snap to grid points */
543         SnapEndpoint,     /**< Snap to endpoints */
544         SnapMiddle,       /**< Snap to middle points */
545         SnapCenter,       /**< Snap to centers */
546         SnapOnEntity,     /**< Snap to the next point on an entity */
547         SnapDist,         /**< Snap to points with a distance to an endpoint */
548         SnapIntersection, /**< Snap to intersection */
549         SnapIntersectionManual  /**< Snap to intersection manually */
550     };
551
552     /**
553      * Snap restrictions
554      */
555     enum SnapRestriction {
556         RestrictNothing,        /**< No restriction to snap mode */
557         RestrictOrthogonal,     /**< Restrict to 90,180,270,0 degrees */
558         RestrictHorizontal,     /**< Restrict to 0,180 degrees */
559         RestrictVertical        /**< Restrict to 90,270 degrees */
560     };
561
562     /**
563      * Enum of line styles:
564      */
565     enum LineType {
566         NoPen = 0,            /**< No line at all. */
567         SolidLine = 1,        /**< Normal line. */
568
569         DotLine = 2,          /**< Dotted line. */
570         DotLine2 = 3,         /**< Dotted line small. */
571         DotLineX2 = 4,        /**< Dotted line large. */
572
573         DashLine = 5,         /**< Dashed line. */
574         DashLine2 = 6,        /**< Dashed line small. */
575         DashLineX2 = 7,       /**< Dashed line large. */
576
577         DashDotLine = 8,      /**< Alternate dots and dashes. */
578         DashDotLine2 = 9,     /**< Alternate dots and dashes small. */
579         DashDotLineX2 = 10,   /**< Alternate dots and dashes large. */
580
581         DivideLine = 11,      /**< dash, dot, dot. */
582         DivideLine2 = 12,     /**< dash, dot, dot small. */
583         DivideLineX2 = 13,    /**< dash, dot, dot large. */
584
585         CenterLine = 14,      /**< dash, small dash. */
586         CenterLine2 = 15,     /**< dash, small dash small. */
587         CenterLineX2 = 16,    /**< dash, small dash large. */
588
589         BorderLine = 17,      /**< dash, dash, dot. */
590         BorderLine2 = 18,     /**< dash, dash, dot small. */
591         BorderLineX2 = 19,    /**< dash, dash, dot large. */
592
593         LineByLayer = -1,     /**< Line type defined by layer not entity */
594         LineByBlock = -2      /**< Line type defined by block not entity */
595     };
596
597     /**
598      * Wrapper for Qt
599      */
600     static Qt::PenStyle rsToQtLineType(RS2::LineType t) {
601         switch (t) {
602         case NoPen:
603             return Qt::NoPen;
604             break;
605         case SolidLine:
606             return Qt::SolidLine;
607             break;
608         case DotLine:
609         case DotLine2:
610         case DotLineX2:
611             return Qt::DotLine;
612             break;
613         case DashLine:
614         case DashLine2:
615         case DashLineX2:
616             return Qt::DashLine;
617             break;
618         case DashDotLine:
619         case DashDotLine2:
620         case DashDotLineX2:
621             return Qt::DashDotLine;
622             break;
623         case DivideLine:
624         case DivideLine2:
625         case DivideLineX2:
626             return Qt::DashDotDotLine;
627             break;
628         case CenterLine:
629         case CenterLine2:
630         case CenterLineX2:
631             return Qt::DashDotLine;
632             break;
633         case BorderLine:
634         case BorderLine2:
635         case BorderLineX2:
636             return Qt::DashDotLine;
637             break;
638         case LineByLayer:
639         case LineByBlock:
640         default:
641             return Qt::SolidLine;
642             break;
643         }
644         return Qt::SolidLine;
645     }
646
647     /**
648      * Wrapper for Qt.
649      */
650     static RS2::LineType qtToRsPenStyle(Qt::PenStyle s)
651     {
652         switch (s)
653                 {
654         case Qt::NoPen:
655             return NoPen;
656         case Qt::SolidLine:
657             return SolidLine;
658             break;
659         case Qt::DashLine:
660             return DashLine;
661             break;
662         case Qt::DotLine:
663             return DotLine;
664             break;
665         case Qt::DashDotLine:
666             return DashDotLine;
667             break;
668         case Qt::DashDotDotLine:
669             return DivideLine;
670             break;
671         default:
672             return SolidLine;
673             break;
674         }
675
676                 return SolidLine;
677     }
678
679     /**
680      * \brief Struct that stores a line type pattern (e.g. dash dot dot).
681      */
682     struct LineTypePatternStruct
683     {
684         double * pattern;
685         int num;
686     }
687     LineTypePattern;
688
689     /**
690      * Enum of line widths:
691      */
692     enum LineWidth {
693         Width00 = 0,       /**< Width 1.  (0.00mm) */
694         Width01 = 5,       /**< Width 2.  (0.05mm) */
695         Width02 = 9,       /**< Width 3.  (0.09mm) */
696         Width03 = 13,      /**< Width 4.  (0.13mm) */
697         Width04 = 15,      /**< Width 5.  (0.15mm) */
698         Width05 = 18,      /**< Width 6.  (0.18mm) */
699         Width06 = 20,      /**< Width 7.  (0.20mm) */
700         Width07 = 25,      /**< Width 8.  (0.25mm) */
701         Width08 = 30,      /**< Width 9.  (0.30mm) */
702         Width09 = 35,      /**< Width 10. (0.35mm) */
703         Width10 = 40,      /**< Width 11. (0.40mm) */
704         Width11 = 50,      /**< Width 12. (0.50mm) */
705         Width12 = 53,      /**< Width 13. (0.53mm) */
706         Width13 = 60,      /**< Width 14. (0.60mm) */
707         Width14 = 70,      /**< Width 15. (0.70mm) */
708         Width15 = 80,      /**< Width 16. (0.80mm) */
709         Width16 = 90,      /**< Width 17. (0.90mm) */
710         Width17 = 100,     /**< Width 18. (1.00mm) */
711         Width18 = 106,     /**< Width 19. (1.06mm) */
712         Width19 = 120,     /**< Width 20. (1.20mm) */
713         Width20 = 140,     /**< Width 21. (1.40mm) */
714         Width21 = 158,     /**< Width 22. (1.58mm) */
715         Width22 = 200,     /**< Width 23. (2.00mm) */
716         Width23 = 211,     /**< Width 24. (2.11mm) */
717         WidthByLayer = -1, /**< Line width defined by layer not entity. */
718         WidthByBlock = -2, /**< Line width defined by block not entity. */
719         WidthDefault = -3  /**< Line width defaults to the predefined line width. */
720     };
721
722     /**
723      * Wrapper for Qt
724      */
725     static LineWidth intToLineWidth(int w)
726     {
727                 if (w == -3)
728                 {
729                         return WidthDefault;
730                 }
731                 else if (w == -2)
732                 {
733                         return WidthByBlock;
734                 }
735                 else if (w == -1)
736                 {
737                         return WidthByLayer;
738                 }
739                 else if (w < 3)
740                 {
741                         return Width00;
742                 }
743                 else if (w < 8)
744                 {
745                         return Width01;
746                 }
747                 else if (w < 12)
748                 {
749                         return Width02;
750                 }
751                 else if (w < 14)
752                 {
753                         return Width03;
754                 }
755                 else if (w < 17)
756                 {
757                         return Width04;
758                 }
759                 else if (w < 19)
760                 {
761                         return Width05;
762                 }
763                 else if (w < 23)
764                 {
765                         return Width06;
766                 }
767                 else if (w < 28)
768                 {
769                         return Width07;
770                 }
771                 else if (w < 33)
772                 {
773                         return Width08;
774                 }
775                 else if (w < 38)
776                 {
777                         return Width09;
778                 }
779                 else if (w < 46)
780                 {
781                         return Width10;
782                 }
783                 else if (w < 52)
784                 {
785                         return Width11;
786                 }
787                 else if (w < 57)
788                 {
789                         return Width12;
790                 }
791                 else if (w < 66)
792                 {
793                         return Width13;
794                 }
795                 else if (w < 76)
796                 {
797                         return Width14;
798                 }
799                 else if (w < 86)
800                 {
801                         return Width15;
802                 }
803                 else if (w < 96)
804                 {
805                         return Width16;
806                 }
807                 else if (w < 104)
808                 {
809                         return Width17;
810                 }
811                 else if (w < 114)
812                 {
813                         return Width18;
814                 }
815                 else if (w < 131)
816                 {
817                         return Width19;
818                 }
819                 else if (w < 150)
820                 {
821                         return Width20;
822                 }
823                 else if (w < 180)
824                 {
825                         return Width21;
826                 }
827                 else if (w < 206)
828                 {
829                         return Width22;
830                 }
831                 else
832                 {
833                         return Width23;
834                 }
835     }
836
837     /**
838      * Enum of cursor types.
839      */
840     enum CursorType {
841         ArrowCursor,          /**< ArrowCursor - standard arrow cursor. */
842         UpArrowCursor,        /**< UpArrowCursor - upwards arrow. */
843         CrossCursor,          /**< CrossCursor - crosshair. */
844         WaitCursor,           /**< WaitCursor - hourglass/watch. */
845         IbeamCursor,          /**< IbeamCursor - ibeam/text entry. */
846         SizeVerCursor,        /**< SizeVerCursor - vertical resize. */
847         SizeHorCursor,        /**< SizeHorCursor - horizontal resize. */
848         SizeBDiagCursor,      /**< SizeBDiagCursor - diagonal resize (/). */
849         SizeFDiagCursor,      /**< SizeFDiagCursor - diagonal resize (\). */
850         SizeAllCursor,        /**< SizeAllCursor - all directions resize. */
851         BlankCursor,          /**< BlankCursor - blank/invisible cursor. */
852         SplitVCursor,         /**< SplitVCursor - vertical splitting. */
853         SplitHCursor,         /**< SplitHCursor - horziontal splitting. */
854         PointingHandCursor,   /**< PointingHandCursor - a pointing hand. */
855         ForbiddenCursor,      /**< ForbiddenCursor - a slashed circle. */
856         WhatsThisCursor,      /**< WhatsThisCursor - an arrow with a ?. */
857         CadCursor,            /**< CadCursor - a bigger cross. */
858         DelCursor,            /**< DelCursor - cursor for choosing entities */
859         SelectCursor,         /**< SelectCursor - for selecting single entities */
860         MagnifierCursor,      /**< MagnifierCursor - a magnifying glass. */
861         MovingHandCursor      /**< Moving hand - a little flat hand. */
862     };
863
864     /**
865      * Wrapper for Qt.
866      */
867     static Qt::CursorShape rsToQtCursorType(RS2::CursorType t)
868     {
869         switch (t)
870                 {
871         case ArrowCursor:
872             return Qt::ArrowCursor;
873             break;
874         case UpArrowCursor:
875             return Qt::UpArrowCursor;
876             break;
877         case CrossCursor:
878             return Qt::CrossCursor;
879             break;
880         case WaitCursor:
881             return Qt::WaitCursor;
882             break;
883         case IbeamCursor:
884             return Qt::IBeamCursor;
885             break;
886         case SizeVerCursor:
887             return Qt::SizeVerCursor;
888             break;
889         case SizeHorCursor:
890             return Qt::SizeHorCursor;
891             break;
892         case SizeBDiagCursor:
893             return Qt::SizeBDiagCursor;
894             break;
895         case SizeFDiagCursor:
896             return Qt::SizeFDiagCursor;
897             break;
898         case SizeAllCursor:
899             return Qt::SizeAllCursor;
900             break;
901         case BlankCursor:
902             return Qt::BlankCursor;
903             break;
904         case SplitVCursor:
905             return Qt::SplitVCursor;
906             break;
907         case SplitHCursor:
908             return Qt::SplitHCursor;
909             break;
910         case PointingHandCursor:
911             return Qt::PointingHandCursor;
912             break;
913         case ForbiddenCursor:
914             return Qt::ForbiddenCursor;
915             break;
916         case WhatsThisCursor:
917             return Qt::WhatsThisCursor;
918             break;
919         default:
920             return Qt::ArrowCursor;
921             break;
922         }
923
924                 return Qt::ArrowCursor;
925     }
926
927     /**
928      * Paper formats.
929      */
930     enum PaperFormat {
931         Custom,
932                 Letter,
933                 Legal,
934                 Executive,
935         A0,
936                 A1,
937                 A2,
938                 A3,
939                 A4,
940                 A5,
941                 A6,
942                 A7,
943                 A8,
944                 A9,
945         B0,
946                 B1,
947                 B2,
948                 B3,
949                 B4,
950                 B5,
951                 B6,
952                 B7,
953                 B8,
954                 B9,
955                 B10,
956         C5E,
957                 Comm10E,
958         DLE,
959                 Folio,
960                 //Ledger,
961                 Tabloid,
962                 NPageSize
963         };
964
965     /**
966      * Wrapper for Qt.
967      */
968     static QPrinter::PageSize rsToQtPaperFormat(RS2::PaperFormat f)
969     {
970                 QPrinter::PageSize ret;
971
972                 switch (f)
973                 {
974         case Custom:
975                         ret = QPrinter::Custom;
976                         break;
977                 case Letter:
978                         ret = QPrinter::Letter;
979                         break;
980                 case Legal:
981                         ret = QPrinter::Legal;
982                         break;
983                 case Executive:
984                         ret = QPrinter::Executive;
985                         break;
986         case A0:
987                         ret = QPrinter::A0;
988                         break;
989                 case A1:
990                         ret = QPrinter::A1;
991                         break;
992                 case A2:
993                         ret = QPrinter::A2;
994                         break;
995                 case A3:
996                         ret = QPrinter::A3;
997                         break;
998                 default:
999                 case A4:
1000                         ret = QPrinter::A4;
1001                         break;
1002                 case A5:
1003                         ret = QPrinter::A5;
1004                         break;
1005                 case A6:
1006                         ret = QPrinter::A6;
1007                         break;
1008                 case A7:
1009                         ret = QPrinter::A7;
1010                         break;
1011                 case A8:
1012                         ret = QPrinter::A8;
1013                         break;
1014                 case A9:
1015                         ret = QPrinter::A9;
1016                         break;
1017                 case B0:
1018                         ret = QPrinter::B0;
1019                         break;
1020                 case B1:
1021                         ret = QPrinter::B1;
1022                         break;
1023                 case B2:
1024                         ret = QPrinter::B2;
1025                         break;
1026                 case B3:
1027                         ret = QPrinter::B3;
1028                         break;
1029                 case B4:
1030                         ret = QPrinter::B4;
1031                         break;
1032                 case B5:
1033                         ret = QPrinter::B5;
1034                         break;
1035                 case B6:
1036                         ret = QPrinter::B6;
1037                         break;
1038                 case B7:
1039                         ret = QPrinter::B7;
1040                         break;
1041                 case B8:
1042                         ret = QPrinter::B8;
1043                         break;
1044                 case B9:
1045                         ret = QPrinter::B9;
1046                         break;
1047                 case B10:
1048                         ret = QPrinter::B10;
1049                         break;
1050                 case C5E:
1051                         ret = QPrinter::C5E;
1052                         break;
1053                 case Comm10E:
1054                         ret = QPrinter::Comm10E;
1055                         break;
1056         case DLE:
1057                         ret = QPrinter::DLE;
1058                         break;
1059                 case Folio:
1060                         ret = QPrinter::Folio;
1061                         break;
1062                 //case Ledger:
1063                 //      ret = QPrinter::Ledger;
1064                 //      break;
1065                 case Tabloid:
1066                         ret = QPrinter::Tabloid;
1067                         break;
1068                 case NPageSize:
1069                         ret = QPrinter::NPageSize;
1070                         break;
1071                 }
1072
1073                 return ret;
1074         }
1075 };
1076
1077 #endif  // __RS_H__