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
572 * Mouse button and keyboard state for mouse events.
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
589 //get rid of unnecessary shiaut like this:
594 // static Qt::ButtonState rsToQtButtonState(RS2::ButtonState t) {
595 // return (Qt::ButtonState)t;
597 static int rsToQtButtonState(RS2::ButtonState t) { return t; }
602 // static RS2::ButtonState qtToRsButtonState(Qt::ButtonState t) {
603 // return (RS2::ButtonState)t;
605 static RS2::ButtonState qtToRsButtonState(int t) { return (RS2::ButtonState)t; }
609 * Enum of line styles:
612 NoPen = 0, /**< No line at all. */
613 SolidLine = 1, /**< Normal line. */
615 DotLine = 2, /**< Dotted line. */
616 DotLine2 = 3, /**< Dotted line small. */
617 DotLineX2 = 4, /**< Dotted line large. */
619 DashLine = 5, /**< Dashed line. */
620 DashLine2 = 6, /**< Dashed line small. */
621 DashLineX2 = 7, /**< Dashed line large. */
623 DashDotLine = 8, /**< Alternate dots and dashes. */
624 DashDotLine2 = 9, /**< Alternate dots and dashes small. */
625 DashDotLineX2 = 10, /**< Alternate dots and dashes large. */
627 DivideLine = 11, /**< dash, dot, dot. */
628 DivideLine2 = 12, /**< dash, dot, dot small. */
629 DivideLineX2 = 13, /**< dash, dot, dot large. */
631 CenterLine = 14, /**< dash, small dash. */
632 CenterLine2 = 15, /**< dash, small dash small. */
633 CenterLineX2 = 16, /**< dash, small dash large. */
635 BorderLine = 17, /**< dash, dash, dot. */
636 BorderLine2 = 18, /**< dash, dash, dot small. */
637 BorderLineX2 = 19, /**< dash, dash, dot large. */
639 LineByLayer = -1, /**< Line type defined by layer not entity */
640 LineByBlock = -2 /**< Line type defined by block not entity */
646 static Qt::PenStyle rsToQtLineType(RS2::LineType t) {
652 return Qt::SolidLine;
667 return Qt::DashDotLine;
672 return Qt::DashDotDotLine;
677 return Qt::DashDotLine;
682 return Qt::DashDotLine;
687 return Qt::SolidLine;
690 return Qt::SolidLine;
696 static RS2::LineType qtToRsPenStyle(Qt::PenStyle s)
711 case Qt::DashDotLine:
714 case Qt::DashDotDotLine:
726 * \brief Struct that stores a line type pattern (e.g. dash dot dot).
728 struct LineTypePatternStruct
736 * Enum of line widths:
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. */
771 static LineWidth intToLineWidth(int w)
884 * Enum of cursor types.
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. */
913 static Qt::CursorShape rsToQtCursorType(RS2::CursorType t)
918 return Qt::ArrowCursor;
921 return Qt::UpArrowCursor;
924 return Qt::CrossCursor;
927 return Qt::WaitCursor;
930 return Qt::IBeamCursor;
933 return Qt::SizeVerCursor;
936 return Qt::SizeHorCursor;
938 case SizeBDiagCursor:
939 return Qt::SizeBDiagCursor;
941 case SizeFDiagCursor:
942 return Qt::SizeFDiagCursor;
945 return Qt::SizeAllCursor;
948 return Qt::BlankCursor;
951 return Qt::SplitVCursor;
954 return Qt::SplitHCursor;
956 case PointingHandCursor:
957 return Qt::PointingHandCursor;
959 case ForbiddenCursor:
960 return Qt::ForbiddenCursor;
962 case WhatsThisCursor:
963 return Qt::WhatsThisCursor;
966 return Qt::ArrowCursor;
970 return Qt::ArrowCursor;
1014 static QPrinter::PageSize rsToQtPaperFormat(RS2::PaperFormat f)
1016 QPrinter::PageSize ret;
1021 ret = QPrinter::Custom;
1024 ret = QPrinter::Letter;
1027 ret = QPrinter::Legal;
1030 ret = QPrinter::Executive;
1094 ret = QPrinter::B10;
1097 ret = QPrinter::C5E;
1100 ret = QPrinter::Comm10E;
1103 ret = QPrinter::DLE;
1106 ret = QPrinter::Folio;
1109 // ret = QPrinter::Ledger;
1112 ret = QPrinter::Tabloid;
1115 ret = QPrinter::NPageSize;