]> Shamusworld >> Repos - architektonas/blob - src/base/rs.h
Scrubbed out all references to RS2::qtToRsButton(). Gone!
[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
19  * wrapper methods for converting the enums to the Qt
20  * counterparts.
21  *
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 #if 0
563 enum Qt::ButtonState_enum
564 Constant                        Value
565 Qt::ShiftButton         Qt::ShiftModifier
566 Qt::ControlButton       Qt::ControlModifier
567 Qt::AltButton           Qt::AltModifier
568 Qt::MetaButton          Qt::MetaModifier
569 Qt::Keypad                      Qt::KeypadModifier
570 Qt::KeyButtonMask       Qt::KeyboardModifierMask
571 #endif
572         /**
573          * Mouse button and keyboard state for mouse events.
574          */
575         enum ButtonState {
576                 NoButton        = Qt::NoButton,
577                 LeftButton      = Qt::LeftButton,
578                 RightButton     = Qt::RightButton,
579                 MidButton       = Qt::MidButton,
580                 MouseButtonMask = Qt::MouseButtonMask,
581                 ShiftButton     = Qt::ShiftModifier,
582                 ControlButton   = Qt::ControlModifier,
583                 AltButton       = Qt::AltModifier,
584                 MetaButton      = Qt::MetaModifier,
585                 KeyButtonMask   = Qt::KeyboardModifierMask,
586                 Keypad          = Qt::KeypadModifier
587         };
588
589 //get rid of unnecessary shiaut like this:
590 #if 0
591     /**
592      * Wrapper for Qt
593      */
594 //    static Qt::ButtonState rsToQtButtonState(RS2::ButtonState t) {
595 //        return (Qt::ButtonState)t;
596 //    }
597     static int rsToQtButtonState(RS2::ButtonState t) { return t; }
598
599     /**
600      * Wrapper for Qt
601      */
602 //    static RS2::ButtonState qtToRsButtonState(Qt::ButtonState t) {
603 //        return (RS2::ButtonState)t;
604 //    }
605     static RS2::ButtonState qtToRsButtonState(int t) { return (RS2::ButtonState)t; }
606 #endif
607
608     /**
609      * Enum of line styles:
610      */
611     enum LineType {
612         NoPen = 0,            /**< No line at all. */
613         SolidLine = 1,        /**< Normal line. */
614
615         DotLine = 2,          /**< Dotted line. */
616         DotLine2 = 3,         /**< Dotted line small. */
617         DotLineX2 = 4,        /**< Dotted line large. */
618
619         DashLine = 5,         /**< Dashed line. */
620         DashLine2 = 6,        /**< Dashed line small. */
621         DashLineX2 = 7,       /**< Dashed line large. */
622
623         DashDotLine = 8,      /**< Alternate dots and dashes. */
624         DashDotLine2 = 9,     /**< Alternate dots and dashes small. */
625         DashDotLineX2 = 10,   /**< Alternate dots and dashes large. */
626
627         DivideLine = 11,      /**< dash, dot, dot. */
628         DivideLine2 = 12,     /**< dash, dot, dot small. */
629         DivideLineX2 = 13,    /**< dash, dot, dot large. */
630
631         CenterLine = 14,      /**< dash, small dash. */
632         CenterLine2 = 15,     /**< dash, small dash small. */
633         CenterLineX2 = 16,    /**< dash, small dash large. */
634
635         BorderLine = 17,      /**< dash, dash, dot. */
636         BorderLine2 = 18,     /**< dash, dash, dot small. */
637         BorderLineX2 = 19,    /**< dash, dash, dot large. */
638
639         LineByLayer = -1,     /**< Line type defined by layer not entity */
640         LineByBlock = -2      /**< Line type defined by block not entity */
641     };
642
643     /**
644      * Wrapper for Qt
645      */
646     static Qt::PenStyle rsToQtLineType(RS2::LineType t) {
647         switch (t) {
648         case NoPen:
649             return Qt::NoPen;
650             break;
651         case SolidLine:
652             return Qt::SolidLine;
653             break;
654         case DotLine:
655         case DotLine2:
656         case DotLineX2:
657             return Qt::DotLine;
658             break;
659         case DashLine:
660         case DashLine2:
661         case DashLineX2:
662             return Qt::DashLine;
663             break;
664         case DashDotLine:
665         case DashDotLine2:
666         case DashDotLineX2:
667             return Qt::DashDotLine;
668             break;
669         case DivideLine:
670         case DivideLine2:
671         case DivideLineX2:
672             return Qt::DashDotDotLine;
673             break;
674         case CenterLine:
675         case CenterLine2:
676         case CenterLineX2:
677             return Qt::DashDotLine;
678             break;
679         case BorderLine:
680         case BorderLine2:
681         case BorderLineX2:
682             return Qt::DashDotLine;
683             break;
684         case LineByLayer:
685         case LineByBlock:
686         default:
687             return Qt::SolidLine;
688             break;
689         }
690         return Qt::SolidLine;
691     }
692
693     /**
694      * Wrapper for Qt.
695      */
696     static RS2::LineType qtToRsPenStyle(Qt::PenStyle s) {
697         switch (s) {
698         case Qt::NoPen:
699             return NoPen;
700         case Qt::SolidLine:
701             return SolidLine;
702             break;
703         case Qt::DashLine:
704             return DashLine;
705             break;
706         case Qt::DotLine:
707             return DotLine;
708             break;
709         case Qt::DashDotLine:
710             return DashDotLine;
711             break;
712         case Qt::DashDotDotLine:
713             return DivideLine;
714             break;
715         default:
716             return SolidLine;
717             break;
718         }
719         return SolidLine;
720     }
721
722     /**
723      * \brief Struct that stores a line type pattern (e.g. dash dot dot).
724      */
725     struct LineTypePatternStruct {
726         double* pattern;
727         int num;
728     }
729     LineTypePattern;
730
731     /**
732      * Enum of line widths:
733      */
734     enum LineWidth {
735         Width00 = 0,       /**< Width 1.  (0.00mm) */
736         Width01 = 5,       /**< Width 2.  (0.05mm) */
737         Width02 = 9,       /**< Width 3.  (0.09mm) */
738         Width03 = 13,      /**< Width 4.  (0.13mm) */
739         Width04 = 15,      /**< Width 5.  (0.15mm) */
740         Width05 = 18,      /**< Width 6.  (0.18mm) */
741         Width06 = 20,      /**< Width 7.  (0.20mm) */
742         Width07 = 25,      /**< Width 8.  (0.25mm) */
743         Width08 = 30,      /**< Width 9.  (0.30mm) */
744         Width09 = 35,      /**< Width 10. (0.35mm) */
745         Width10 = 40,      /**< Width 11. (0.40mm) */
746         Width11 = 50,      /**< Width 12. (0.50mm) */
747         Width12 = 53,      /**< Width 13. (0.53mm) */
748         Width13 = 60,      /**< Width 14. (0.60mm) */
749         Width14 = 70,      /**< Width 15. (0.70mm) */
750         Width15 = 80,      /**< Width 16. (0.80mm) */
751         Width16 = 90,      /**< Width 17. (0.90mm) */
752         Width17 = 100,     /**< Width 18. (1.00mm) */
753         Width18 = 106,     /**< Width 19. (1.06mm) */
754         Width19 = 120,     /**< Width 20. (1.20mm) */
755         Width20 = 140,     /**< Width 21. (1.40mm) */
756         Width21 = 158,     /**< Width 22. (1.58mm) */
757         Width22 = 200,     /**< Width 23. (2.00mm) */
758         Width23 = 211,     /**< Width 24. (2.11mm) */
759         WidthByLayer = -1, /**< Line width defined by layer not entity. */
760         WidthByBlock = -2, /**< Line width defined by block not entity. */
761         WidthDefault = -3  /**< Line width defaults to the predefined line width. */
762     };
763
764     /**
765      * Wrapper for Qt
766      */
767     /*
768        static int qw(RS2::LineWidth w) {
769            switch (w) {
770            case Width00:
771                return 1;  // 0 is more accurate but quite slow
772                break;
773            case WidthByLayer:
774            case WidthByBlock:
775            case WidthDefault:
776                return 1;
777                break;
778            case Width01:
779            case Width02:
780            case Width03:
781            case Width04:
782            case Width05:
783            case Width06:
784            case Width07:
785            case Width08:
786                return 1;
787                break;
788            case Width09:
789            case Width10:
790                return 3;
791                break;
792            case Width11:
793                return 4;
794                break;
795            case Width12:
796            case Width13:
797                return 5;
798                break;
799            case Width14:
800                return 6;
801                break;
802            case Width15:
803                return 7;
804                break;
805            case Width16:
806                return 8;
807                break;
808            case Width17:
809                return 9;
810                break;
811            case Width18:
812            case Width19:
813                return 10;
814                break;
815            case Width20:
816                return 12;
817                break;
818            case Width21:
819            case Width22:
820            case Width23:
821            //case Width24:
822                return 14;
823                break;
824            default:
825                return (int)w;
826                break;
827            }
828            return (int)w;
829        }
830     */
831
832     /**
833      * Wrapper for Qt
834      */
835     static LineWidth intToLineWidth(int w) {
836                 if (w==-3) {
837                         return WidthDefault;
838                 } else if (w==-2) {
839                         return WidthByBlock;
840                 } else if (w==-1) {
841                         return WidthByLayer;
842                 } else if (w<3) {
843                         return Width00;
844                 } else if (w<8) {
845                         return Width01;
846                 } else if (w<12) {
847                         return Width02;
848                 } else if (w<14) {
849                         return Width03;
850                 } else if (w<17) {
851                         return Width04;
852                 } else if (w<19) {
853                         return Width05;
854                 } else if (w<23) {
855                         return Width06;
856                 } else if (w<28) {
857                         return Width07;
858                 } else if (w<33) {
859                         return Width08;
860                 } else if (w<38) {
861                         return Width09;
862                 } else if (w<46) {
863                         return Width10;
864                 } else if (w<52) {
865                         return Width11;
866                 } else if (w<57) {
867                         return Width12;
868                 } else if (w<66) {
869                         return Width13;
870                 } else if (w<76) {
871                         return Width14;
872                 } else if (w<86) {
873                         return Width15;
874                 } else if (w<96) {
875                         return Width16;
876                 } else if (w<104) {
877                         return Width17;
878                 } else if (w<114) {
879                         return Width18;
880                 } else if (w<131) {
881                         return Width19;
882                 } else if (w<150) {
883                         return Width20;
884                 } else if (w<180) {
885                         return Width21;
886                 } else if (w<206) {
887                         return Width22;
888                 } else {
889                         return Width23;
890                 }
891     }
892
893     /**
894      * Enum of cursor types.
895      */
896     enum CursorType {
897         ArrowCursor,          /**< ArrowCursor - standard arrow cursor. */
898         UpArrowCursor,        /**< UpArrowCursor - upwards arrow. */
899         CrossCursor,          /**< CrossCursor - crosshair. */
900         WaitCursor,           /**< WaitCursor - hourglass/watch. */
901         IbeamCursor,          /**< IbeamCursor - ibeam/text entry. */
902         SizeVerCursor,        /**< SizeVerCursor - vertical resize. */
903         SizeHorCursor,        /**< SizeHorCursor - horizontal resize. */
904         SizeBDiagCursor,      /**< SizeBDiagCursor - diagonal resize (/). */
905         SizeFDiagCursor,      /**< SizeFDiagCursor - diagonal resize (\). */
906         SizeAllCursor,        /**< SizeAllCursor - all directions resize. */
907         BlankCursor,          /**< BlankCursor - blank/invisible cursor. */
908         SplitVCursor,         /**< SplitVCursor - vertical splitting. */
909         SplitHCursor,         /**< SplitHCursor - horziontal splitting. */
910         PointingHandCursor,   /**< PointingHandCursor - a pointing hand. */
911         ForbiddenCursor,      /**< ForbiddenCursor - a slashed circle. */
912         WhatsThisCursor,      /**< WhatsThisCursor - an arrow with a ?. */
913         CadCursor,            /**< CadCursor - a bigger cross. */
914         DelCursor,            /**< DelCursor - cursor for choosing entities */
915         SelectCursor,         /**< SelectCursor - for selecting single entities */
916         MagnifierCursor,      /**< MagnifierCursor - a magnifying glass. */
917         MovingHandCursor      /**< Moving hand - a little flat hand. */
918     };
919
920     /**
921      * Wrapper for Qt.
922      */
923     static Qt::CursorShape rsToQtCursorType(RS2::CursorType t) {
924         switch (t) {
925         case ArrowCursor:
926             return Qt::ArrowCursor;
927             break;
928         case UpArrowCursor:
929             return Qt::UpArrowCursor;
930             break;
931         case CrossCursor:
932             return Qt::CrossCursor;
933             break;
934         case WaitCursor:
935             return Qt::WaitCursor;
936             break;
937         case IbeamCursor:
938             return Qt::IBeamCursor;
939             break;
940         case SizeVerCursor:
941             return Qt::SizeVerCursor;
942             break;
943         case SizeHorCursor:
944             return Qt::SizeHorCursor;
945             break;
946         case SizeBDiagCursor:
947             return Qt::SizeBDiagCursor;
948             break;
949         case SizeFDiagCursor:
950             return Qt::SizeFDiagCursor;
951             break;
952         case SizeAllCursor:
953             return Qt::SizeAllCursor;
954             break;
955         case BlankCursor:
956             return Qt::BlankCursor;
957             break;
958         case SplitVCursor:
959             return Qt::SplitVCursor;
960             break;
961         case SplitHCursor:
962             return Qt::SplitHCursor;
963             break;
964         case PointingHandCursor:
965             return Qt::PointingHandCursor;
966             break;
967         case ForbiddenCursor:
968             return Qt::ForbiddenCursor;
969             break;
970         case WhatsThisCursor:
971             return Qt::WhatsThisCursor;
972             break;
973         default:
974             return Qt::ArrowCursor;
975             break;
976         }
977         return Qt::ArrowCursor;
978     }
979
980     /**
981      * Paper formats.
982      */
983     enum PaperFormat {
984         Custom,
985                 Letter,
986                 Legal,
987                 Executive,
988         A0,
989                 A1,
990                 A2,
991                 A3,
992                 A4,
993                 A5,
994                 A6,
995                 A7,
996                 A8,
997                 A9,
998         B0,
999                 B1,
1000                 B2,
1001                 B3,
1002                 B4,
1003                 B5,
1004                 B6,
1005                 B7,
1006                 B8,
1007                 B9,
1008                 B10,
1009         C5E,
1010                 Comm10E,
1011         DLE,
1012                 Folio,
1013                 //Ledger,
1014                 Tabloid,
1015                 NPageSize
1016         };
1017
1018     /**
1019      * Wrapper for Qt.
1020      */
1021     static QPrinter::PageSize rsToQtPaperFormat(RS2::PaperFormat f) {
1022                 QPrinter::PageSize ret;
1023
1024                 switch (f) {
1025         case Custom:
1026                         ret = QPrinter::Custom;
1027                         break;
1028                 case Letter:
1029                         ret = QPrinter::Letter;
1030                         break;
1031                 case Legal:
1032                         ret = QPrinter::Legal;
1033                         break;
1034                 case Executive:
1035                         ret = QPrinter::Executive;
1036                         break;
1037         case A0:
1038                         ret = QPrinter::A0;
1039                         break;
1040                 case A1:
1041                         ret = QPrinter::A1;
1042                         break;
1043                 case A2:
1044                         ret = QPrinter::A2;
1045                         break;
1046                 case A3:
1047                         ret = QPrinter::A3;
1048                         break;
1049                 default:
1050                 case A4:
1051                         ret = QPrinter::A4;
1052                         break;
1053                 case A5:
1054                         ret = QPrinter::A5;
1055                         break;
1056                 case A6:
1057                         ret = QPrinter::A6;
1058                         break;
1059                 case A7:
1060                         ret = QPrinter::A7;
1061                         break;
1062                 case A8:
1063                         ret = QPrinter::A8;
1064                         break;
1065                 case A9:
1066                         ret = QPrinter::A9;
1067                         break;
1068                 case B0:
1069                         ret = QPrinter::B0;
1070                         break;
1071                 case B1:
1072                         ret = QPrinter::B1;
1073                         break;
1074                 case B2:
1075                         ret = QPrinter::B2;
1076                         break;
1077                 case B3:
1078                         ret = QPrinter::B3;
1079                         break;
1080                 case B4:
1081                         ret = QPrinter::B4;
1082                         break;
1083                 case B5:
1084                         ret = QPrinter::B5;
1085                         break;
1086                 case B6:
1087                         ret = QPrinter::B6;
1088                         break;
1089                 case B7:
1090                         ret = QPrinter::B7;
1091                         break;
1092                 case B8:
1093                         ret = QPrinter::B8;
1094                         break;
1095                 case B9:
1096                         ret = QPrinter::B9;
1097                         break;
1098                 case B10:
1099                         ret = QPrinter::B10;
1100                         break;
1101                 case C5E:
1102                         ret = QPrinter::C5E;
1103                         break;
1104                 case Comm10E:
1105                         ret = QPrinter::Comm10E;
1106                         break;
1107         case DLE:
1108                         ret = QPrinter::DLE;
1109                         break;
1110                 case Folio:
1111                         ret = QPrinter::Folio;
1112                         break;
1113                 //case Ledger:
1114                 //      ret = QPrinter::Ledger;
1115                 //      break;
1116                 case Tabloid:
1117                         ret = QPrinter::Tabloid;
1118                         break;
1119                 case NPageSize:
1120                         ret = QPrinter::NPageSize;
1121                         break;
1122                 }
1123
1124                 return ret;
1125         }
1126 };
1127
1128 #endif