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
18 * Class namespace for various enums along with some simple
19 * wrapper methods for converting the enums to the Qt
22 * @author Andrew Mustun
32 /** Flag for Undoables. */
34 /** Entity Visibility. */
36 /** Entity attribute (e.g. color) is defined by layer. */
38 /** Entity attribute (e.g. color) defined by block. */
42 /** Layer frozen by default. */
43 FlagDefFrozen = 1 << 5,
46 /** Used for invalid pens. */
48 /** Entity in current selection. */
49 FlagSelected = 1 << 8,
50 /** Polyline closed? */
52 /** Flag for temporary entities (e.g. hatch) */
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
65 * Variable types used by RS_VariableDict and RS_Variable.
76 * File types. Used by file dialogs. Note: the extension might not
77 * be enough to distinguish file types.
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, ..) */
89 * Entity types returned by the rtti() method
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 */
120 * Action types used by action factories.
123 ActionNone, /**< Invalid action id. */
134 ActionFilePrintPreview,
142 ActionEditCutNoSelect,
144 ActionEditCopyNoSelect,
150 ActionViewCommandLine,
151 ActionViewOptionToolbar,
166 ActionDeselectWindow,
169 ActionSelectIntersected,
170 ActionDeselectIntersected,
177 ActionDrawArcParallel,
178 ActionDrawArcTangential,
183 ActionDrawCircleParallel,
184 ActionDrawEllipseArcAxis,
185 ActionDrawEllipseAxis,
187 ActionDrawHatchNoSelect,
191 ActionDrawLineBisector,
193 ActionDrawLineHorVert,
194 ActionDrawLineHorizontal,
195 ActionDrawLineOrthogonal,
196 ActionDrawLineParallel,
197 ActionDrawLineParallelThrough,
198 ActionDrawLinePolygon,
199 ActionDrawLinePolygon2,
200 ActionDrawLineRectangle,
201 ActionDrawLineRelAngle,
202 ActionDrawLineTangent1,
203 ActionDrawLineTangent2,
204 ActionDrawLineVertical,
211 ActionPolylineAppend,
213 ActionPolylineDelBetween,
225 ActionModifyAttributes,
226 ActionModifyAttributesNoSelect,
228 ActionModifyDeleteNoSelect,
229 ActionModifyDeleteQuick,
230 ActionModifyDeleteFree,
232 ActionModifyMoveNoSelect,
234 ActionModifyRotateNoSelect,
236 ActionModifyScaleNoSelect,
238 ActionModifyMirrorNoSelect,
239 ActionModifyMoveRotate,
240 ActionModifyMoveRotateNoSelect,
242 ActionModifyRotate2NoSelect,
246 ActionModifyTrimAmount,
259 ActionSnapIntersection,
260 ActionSnapIntersectionManual,
262 ActionRestrictNothing,
263 ActionRestrictOrthogonal,
264 ActionRestrictHorizontal,
265 ActionRestrictVertical,
267 ActionSetRelativeZero,
268 ActionLockRelativeZero,
269 ActionUnlockRelativeZero,
275 ActionInfoTotalLength,
276 ActionInfoTotalLengthNoSelect,
279 ActionLayersDefreezeAll,
280 ActionLayersFreezeAll,
284 ActionLayersToggleView,
285 ActionLayersToggleLock,
287 ActionBlocksDefreezeAll,
288 ActionBlocksFreezeAll,
291 ActionBlocksAttributes,
294 ActionBlocksToggleView,
296 ActionBlocksCreateNoSelect,
298 ActionBlocksExplodeNoSelect,
300 ActionModifyExplodeText,
301 ActionModifyExplodeTextNoSelect,
305 ActionOptionsGeneral,
306 ActionOptionsDrawing,
308 ActionToolRegenerateDimensions,
313 #ifndef RS_NO_COMPLEX_ENTITIES
314 ActionPARISDebugCreateContainer,
322 /** Needed to loop through all actions */
327 * Entity ending. Used for returning which end of an entity is ment.
330 EndingStart, /**< Start point. */
331 EndingEnd, /**< End point. */
332 EndingNone /**< Neither. */
336 * Update mode for non-atomic entities that need to be updated when
337 * they change. e.g. texts, inserts, ...
340 NoUpdate, /**< No automatic updates. */
341 Update, /**< Always update automatically when modified. */
342 PreviewUpdate /**< Update automatically but only for previews (quick update) */
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. */
360 UndoableUnknown, /**< Unknown undoable */
361 UndoableEntity, /**< Entity */
362 UndoableLayer /**< Layer */
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 */
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 */
411 LastUnit = 21 /**< Used to iterate through units */
416 * Format for length values.
419 /** Scientific (e.g. 2.5E+05) */
421 /** Decimal (e.g. 9.5)*/
423 /** Engineering (e.g. 7' 11.5")*/
425 /** Architectural (e.g. 7'-9 1/8")*/
427 /** Fractional (e.g. 7 9 1/8) */
441 * Display formats for angles.
444 /** Degrees with decimal point (e.g. 24.5°) */
446 /** Degrees, Minutes and Seconds (e.g. 24°30'5") */
447 DegreesMinutesSeconds,
448 /** Gradians with decimal point (e.g. 390.5)*/
450 /** Radians with decimal point (e.g. 1.57)*/
452 /** Surveyor's units */
457 * Enum of levels of resolving when iterating through an entity tree.
460 /** Groups are not resolved */
463 * Resolve all but not Inserts.
465 ResolveAllButInserts,
467 * all Entity Containers are resolved
468 * (including Texts, Polylines, ...)
474 * Direction used for scrolling actions.
477 Up, Left, Right, Down
481 * Vertical alignments.
484 VAlignTop, /**< Top. */
485 VAlignMiddle, /**< Middle */
486 VAlignBottom /**< Bottom */
490 * Horizontal alignments.
493 HAlignLeft, /**< Left */
494 HAlignCenter, /**< Centered */
495 HAlignRight /**< Right */
499 * Text drawing direction.
501 enum TextDrawingDirection {
502 LeftToRight, /**< Left to right */
503 TopToBottom, /**< Top to bottom */
504 ByStyle /**< Inherited from associated text style */
508 * Line spacing style for texts.
510 enum TextLineSpacingStyle {
511 AtLeast, /**< Taller characters will override */
512 Exact /**< Taller characters will not override */
518 enum LeaderPathType {
519 Straight, /**< Straight line segments */
520 Spline /**< Splines */
524 * Direction for zooming actions.
531 * Axis specification for zooming actions.
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 */
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 */
563 enum Qt::ButtonState_enum
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
573 * Mouse button and keyboard state for mouse events.
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
592 // static Qt::ButtonState rsToQtButtonState(RS2::ButtonState t) {
593 // return (Qt::ButtonState)t;
595 static int rsToQtButtonState(RS2::ButtonState t) { return t; }
600 // static RS2::ButtonState qtToRsButtonState(Qt::ButtonState t) {
601 // return (RS2::ButtonState)t;
603 static RS2::ButtonState qtToRsButtonState(int t) { return (RS2::ButtonState)t; }
606 * Enum of line styles:
609 NoPen = 0, /**< No line at all. */
610 SolidLine = 1, /**< Normal line. */
612 DotLine = 2, /**< Dotted line. */
613 DotLine2 = 3, /**< Dotted line small. */
614 DotLineX2 = 4, /**< Dotted line large. */
616 DashLine = 5, /**< Dashed line. */
617 DashLine2 = 6, /**< Dashed line small. */
618 DashLineX2 = 7, /**< Dashed line large. */
620 DashDotLine = 8, /**< Alternate dots and dashes. */
621 DashDotLine2 = 9, /**< Alternate dots and dashes small. */
622 DashDotLineX2 = 10, /**< Alternate dots and dashes large. */
624 DivideLine = 11, /**< dash, dot, dot. */
625 DivideLine2 = 12, /**< dash, dot, dot small. */
626 DivideLineX2 = 13, /**< dash, dot, dot large. */
628 CenterLine = 14, /**< dash, small dash. */
629 CenterLine2 = 15, /**< dash, small dash small. */
630 CenterLineX2 = 16, /**< dash, small dash large. */
632 BorderLine = 17, /**< dash, dash, dot. */
633 BorderLine2 = 18, /**< dash, dash, dot small. */
634 BorderLineX2 = 19, /**< dash, dash, dot large. */
636 LineByLayer = -1, /**< Line type defined by layer not entity */
637 LineByBlock = -2 /**< Line type defined by block not entity */
643 static Qt::PenStyle rsToQtLineType(RS2::LineType t) {
649 return Qt::SolidLine;
664 return Qt::DashDotLine;
669 return Qt::DashDotDotLine;
674 return Qt::DashDotLine;
679 return Qt::DashDotLine;
684 return Qt::SolidLine;
687 return Qt::SolidLine;
693 static RS2::LineType qtToRsPenStyle(Qt::PenStyle s) {
706 case Qt::DashDotLine:
709 case Qt::DashDotDotLine:
720 * \brief Struct that stores a line type pattern (e.g. dash dot dot).
722 struct LineTypePatternStruct {
729 * Enum of line widths:
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. */
765 static int qw(RS2::LineWidth w) {
768 return 1; // 0 is more accurate but quite slow
832 static LineWidth intToLineWidth(int w) {
891 * Enum of cursor types.
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. */
920 static Qt::CursorShape rsToQtCursorType(RS2::CursorType t) {
923 return Qt::ArrowCursor;
926 return Qt::UpArrowCursor;
929 return Qt::CrossCursor;
932 return Qt::WaitCursor;
935 return Qt::IBeamCursor;
938 return Qt::SizeVerCursor;
941 return Qt::SizeHorCursor;
943 case SizeBDiagCursor:
944 return Qt::SizeBDiagCursor;
946 case SizeFDiagCursor:
947 return Qt::SizeFDiagCursor;
950 return Qt::SizeAllCursor;
953 return Qt::BlankCursor;
956 return Qt::SplitVCursor;
959 return Qt::SplitHCursor;
961 case PointingHandCursor:
962 return Qt::PointingHandCursor;
964 case ForbiddenCursor:
965 return Qt::ForbiddenCursor;
967 case WhatsThisCursor:
968 return Qt::WhatsThisCursor;
971 return Qt::ArrowCursor;
974 return Qt::ArrowCursor;
1018 static QPrinter::PageSize rsToQtPaperFormat(RS2::PaperFormat f) {
1019 QPrinter::PageSize ret;
1023 ret = QPrinter::Custom;
1026 ret = QPrinter::Letter;
1029 ret = QPrinter::Legal;
1032 ret = QPrinter::Executive;
1096 ret = QPrinter::B10;
1099 ret = QPrinter::C5E;
1102 ret = QPrinter::Comm10E;
1105 ret = QPrinter::DLE;
1108 ret = QPrinter::Folio;
1111 // ret = QPrinter::Ledger;
1114 ret = QPrinter::Tabloid;
1117 ret = QPrinter::NPageSize;