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