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 void setSnapRange(int r);
40 Vector snapPoint(QMouseEvent * e);
41 Vector snapFree(Vector coord);
42 Vector snapEndpoint(Vector coord);
43 Vector snapGrid(Vector coord);
44 Vector snapOnEntity(Vector coord);
45 Vector snapCenter(Vector coord);
46 Vector snapMiddle(Vector coord);
47 Vector snapDist(Vector coord);
48 Vector snapIntersection(Vector coord);
49 //Vector snapDirect(Vector coord, bool abs);
51 Vector restrictOrthogonal(Vector coord);
52 Vector restrictHorizontal(Vector coord);
53 Vector restrictVertical(Vector coord);
55 RS_Entity * catchEntity(const Vector & pos, RS2::ResolveLevel level = RS2::ResolveNone);
56 RS_Entity * catchEntity(QMouseEvent * e, RS2::ResolveLevel level = RS2::ResolveNone);
58 virtual void suspend();
59 virtual void resume();
60 virtual void hideOptions();
61 virtual void showOptions();
67 How should we handle this? All rendering goes through the GraphicView (QG_GraphicView to be
68 precise, soon to be merged in) as it should. So shouldn't we control the snapper through
69 that class as well? Unfortunately, all actions derive from this class...
73 Not 100% sure. It does seem to make more sense to have them be a part of the GraphicView,
74 since snapping is a function of the grid and the entities contained in the view. (This would
75 also hold for the preview as well.)
79 For allowing the crosshairs to be drawn, we'd have
80 void ShowSnapper(void)
83 void HideSnapper(void)
86 void SetSnapperCoords(Vector, Vector)
88 for setting the coordinates?
91 void SetVisible(bool visibility = true);
93 void Draw(GraphicView *, PaintInterface *);
99 RS_EntityContainer * container;
100 GraphicView * graphicView;
101 RS_Entity * keyEntity;
104 RS2::SnapMode snapMode;
105 RS2::SnapRestriction snapRes;
107 * Snap distance for snaping to points with a
108 * given distance from endpoints.
112 * Keeps track of the drawings in XOR mode.
116 * Snap range for catching entities.
120 * Show large cross hairs.