9 class RS_EntityContainer;
14 * This class is used for snapping functions in a graphic view.
15 * Actions are usually derrived from this base class if they need
16 * to catch entities or snap to coordinates. Use the methods to
17 * retrieve a graphic coordinate from a mouse coordinate.
19 * Possible snapping functions are described in RS_SnapMode.
21 * @author Andrew Mustun
26 RS_Snapper(RS_EntityContainer & container, GraphicView & graphicView);
28 virtual ~RS_Snapper();
33 void SetContainer(RS_EntityContainer *);
34 void SetGraphicView(GraphicView *);
35 RS_Entity * getKeyEntity();
36 void setSnapMode(RS2::SnapMode snapMode);
37 void setSnapRestriction(RS2::SnapRestriction snapRes);
38 RS2::SnapMode getSnapMode(void);
39 RS2::SnapRestriction getSnapRestriction(void);
40 void setSnapRange(int r);
42 Vector snapPoint(QMouseEvent * e);
43 Vector snapFree(Vector coord);
44 Vector snapEndpoint(Vector coord);
45 Vector snapGrid(Vector coord);
46 Vector snapOnEntity(Vector coord);
47 Vector snapCenter(Vector coord);
48 Vector snapMiddle(Vector coord);
49 Vector snapDist(Vector coord);
50 Vector snapIntersection(Vector coord);
52 Vector restrictOrthogonal(Vector coord);
53 Vector restrictHorizontal(Vector coord);
54 Vector restrictVertical(Vector coord);
56 RS_Entity * catchEntity(const Vector & pos, RS2::ResolveLevel level = RS2::ResolveNone);
57 RS_Entity * catchEntity(QMouseEvent * e, RS2::ResolveLevel level = RS2::ResolveNone);
59 virtual void suspend();
60 virtual void resume();
61 virtual void hideOptions();
62 virtual void showOptions();
64 // void drawSnapper();
65 // void deleteSnapper();
68 How should we handle this? All rendering goes through the GraphicView (QG_GraphicView to be
69 precise, soon to be merged in) as it should. So shouldn't we control the snapper through
70 that class as well? Unfortunately, all actions derive from this class...
74 Not 100% sure. It does seem to make more sense to have them be a part of the GraphicView,
75 since snapping is a function of the grid and the entities contained in the view. (This would
76 also hold for the preview as well.)
80 For allowing the crosshairs to be drawn, we'd have
81 void ShowSnapper(void)
84 void HideSnapper(void)
87 void SetSnapperCoords(Vector, Vector)
89 for setting the coordinates?
92 void SetVisible(bool visibility = true);
94 void Draw(GraphicView *, PaintInterface *);
100 RS_EntityContainer * container;
101 GraphicView * graphicView;
102 RS_Entity * keyEntity;
105 RS2::SnapMode snapMode;
106 RS2::SnapRestriction snapRes;
108 * Snap distance for snaping to points with a
109 * given distance from endpoints.
113 * Keeps track of the drawings in XOR mode.
117 * Snap range for catching entities.
121 * Show large cross hairs.