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
593 // static Qt::ButtonState rsToQtButtonState(RS2::ButtonState t) {
594 // return (Qt::ButtonState)t;
596 static int rsToQtButtonState(RS2::ButtonState t) { return t; }
601 // static RS2::ButtonState qtToRsButtonState(Qt::ButtonState t) {
602 // return (RS2::ButtonState)t;
604 static RS2::ButtonState qtToRsButtonState(int t) { return (RS2::ButtonState)t; }
608 * Enum of line styles:
611 NoPen = 0, /**< No line at all. */
612 SolidLine = 1, /**< Normal line. */
614 DotLine = 2, /**< Dotted line. */
615 DotLine2 = 3, /**< Dotted line small. */
616 DotLineX2 = 4, /**< Dotted line large. */
618 DashLine = 5, /**< Dashed line. */
619 DashLine2 = 6, /**< Dashed line small. */
620 DashLineX2 = 7, /**< Dashed line large. */
622 DashDotLine = 8, /**< Alternate dots and dashes. */
623 DashDotLine2 = 9, /**< Alternate dots and dashes small. */
624 DashDotLineX2 = 10, /**< Alternate dots and dashes large. */
626 DivideLine = 11, /**< dash, dot, dot. */
627 DivideLine2 = 12, /**< dash, dot, dot small. */
628 DivideLineX2 = 13, /**< dash, dot, dot large. */
630 CenterLine = 14, /**< dash, small dash. */
631 CenterLine2 = 15, /**< dash, small dash small. */
632 CenterLineX2 = 16, /**< dash, small dash large. */
634 BorderLine = 17, /**< dash, dash, dot. */
635 BorderLine2 = 18, /**< dash, dash, dot small. */
636 BorderLineX2 = 19, /**< dash, dash, dot large. */
638 LineByLayer = -1, /**< Line type defined by layer not entity */
639 LineByBlock = -2 /**< Line type defined by block not entity */
645 static Qt::PenStyle rsToQtLineType(RS2::LineType t) {
651 return Qt::SolidLine;
666 return Qt::DashDotLine;
671 return Qt::DashDotDotLine;
676 return Qt::DashDotLine;
681 return Qt::DashDotLine;
686 return Qt::SolidLine;
689 return Qt::SolidLine;
695 static RS2::LineType qtToRsPenStyle(Qt::PenStyle s) {
708 case Qt::DashDotLine:
711 case Qt::DashDotDotLine:
722 * \brief Struct that stores a line type pattern (e.g. dash dot dot).
724 struct LineTypePatternStruct {
731 * Enum of line widths:
734 Width00 = 0, /**< Width 1. (0.00mm) */
735 Width01 = 5, /**< Width 2. (0.05mm) */
736 Width02 = 9, /**< Width 3. (0.09mm) */
737 Width03 = 13, /**< Width 4. (0.13mm) */
738 Width04 = 15, /**< Width 5. (0.15mm) */
739 Width05 = 18, /**< Width 6. (0.18mm) */
740 Width06 = 20, /**< Width 7. (0.20mm) */
741 Width07 = 25, /**< Width 8. (0.25mm) */
742 Width08 = 30, /**< Width 9. (0.30mm) */
743 Width09 = 35, /**< Width 10. (0.35mm) */
744 Width10 = 40, /**< Width 11. (0.40mm) */
745 Width11 = 50, /**< Width 12. (0.50mm) */
746 Width12 = 53, /**< Width 13. (0.53mm) */
747 Width13 = 60, /**< Width 14. (0.60mm) */
748 Width14 = 70, /**< Width 15. (0.70mm) */
749 Width15 = 80, /**< Width 16. (0.80mm) */
750 Width16 = 90, /**< Width 17. (0.90mm) */
751 Width17 = 100, /**< Width 18. (1.00mm) */
752 Width18 = 106, /**< Width 19. (1.06mm) */
753 Width19 = 120, /**< Width 20. (1.20mm) */
754 Width20 = 140, /**< Width 21. (1.40mm) */
755 Width21 = 158, /**< Width 22. (1.58mm) */
756 Width22 = 200, /**< Width 23. (2.00mm) */
757 Width23 = 211, /**< Width 24. (2.11mm) */
758 WidthByLayer = -1, /**< Line width defined by layer not entity. */
759 WidthByBlock = -2, /**< Line width defined by block not entity. */
760 WidthDefault = -3 /**< Line width defaults to the predefined line width. */
767 static int qw(RS2::LineWidth w) {
770 return 1; // 0 is more accurate but quite slow
834 static LineWidth intToLineWidth(int w) {
893 * Enum of cursor types.
896 ArrowCursor, /**< ArrowCursor - standard arrow cursor. */
897 UpArrowCursor, /**< UpArrowCursor - upwards arrow. */
898 CrossCursor, /**< CrossCursor - crosshair. */
899 WaitCursor, /**< WaitCursor - hourglass/watch. */
900 IbeamCursor, /**< IbeamCursor - ibeam/text entry. */
901 SizeVerCursor, /**< SizeVerCursor - vertical resize. */
902 SizeHorCursor, /**< SizeHorCursor - horizontal resize. */
903 SizeBDiagCursor, /**< SizeBDiagCursor - diagonal resize (/). */
904 SizeFDiagCursor, /**< SizeFDiagCursor - diagonal resize (\). */
905 SizeAllCursor, /**< SizeAllCursor - all directions resize. */
906 BlankCursor, /**< BlankCursor - blank/invisible cursor. */
907 SplitVCursor, /**< SplitVCursor - vertical splitting. */
908 SplitHCursor, /**< SplitHCursor - horziontal splitting. */
909 PointingHandCursor, /**< PointingHandCursor - a pointing hand. */
910 ForbiddenCursor, /**< ForbiddenCursor - a slashed circle. */
911 WhatsThisCursor, /**< WhatsThisCursor - an arrow with a ?. */
912 CadCursor, /**< CadCursor - a bigger cross. */
913 DelCursor, /**< DelCursor - cursor for choosing entities */
914 SelectCursor, /**< SelectCursor - for selecting single entities */
915 MagnifierCursor, /**< MagnifierCursor - a magnifying glass. */
916 MovingHandCursor /**< Moving hand - a little flat hand. */
922 static Qt::CursorShape rsToQtCursorType(RS2::CursorType t) {
925 return Qt::ArrowCursor;
928 return Qt::UpArrowCursor;
931 return Qt::CrossCursor;
934 return Qt::WaitCursor;
937 return Qt::IBeamCursor;
940 return Qt::SizeVerCursor;
943 return Qt::SizeHorCursor;
945 case SizeBDiagCursor:
946 return Qt::SizeBDiagCursor;
948 case SizeFDiagCursor:
949 return Qt::SizeFDiagCursor;
952 return Qt::SizeAllCursor;
955 return Qt::BlankCursor;
958 return Qt::SplitVCursor;
961 return Qt::SplitHCursor;
963 case PointingHandCursor:
964 return Qt::PointingHandCursor;
966 case ForbiddenCursor:
967 return Qt::ForbiddenCursor;
969 case WhatsThisCursor:
970 return Qt::WhatsThisCursor;
973 return Qt::ArrowCursor;
976 return Qt::ArrowCursor;
1020 static QPrinter::PageSize rsToQtPaperFormat(RS2::PaperFormat f) {
1021 QPrinter::PageSize ret;
1025 ret = QPrinter::Custom;
1028 ret = QPrinter::Letter;
1031 ret = QPrinter::Legal;
1034 ret = QPrinter::Executive;
1098 ret = QPrinter::B10;
1101 ret = QPrinter::C5E;
1104 ret = QPrinter::Comm10E;
1107 ret = QPrinter::DLE;
1110 ret = QPrinter::Folio;
1113 // ret = QPrinter::Ledger;
1116 ret = QPrinter::Tabloid;
1119 ret = QPrinter::NPageSize;