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