7 #include "rs_entitycontainer.h"
8 #include "rs_coordinateevent.h"
15 * This class is used for snapping functions in a graphic view.
16 * Actions are usually derrived from this base class if they need
17 * to catch entities or snap to coordinates. Use the methods to
18 * retrieve a graphic coordinate from a mouse coordinate.
20 * Possible snapping functions are described in RS_SnapMode.
22 * @author Andrew Mustun
27 RS_Snapper(RS_EntityContainer & container, RS_GraphicView & graphicView);
28 virtual ~RS_Snapper();
33 RS_Entity * getKeyEntity();
34 void setSnapMode(RS2::SnapMode snapMode);
35 void setSnapRestriction(RS2::SnapRestriction snapRes);
36 void setSnapRange(int r);
38 Vector snapPoint(QMouseEvent * e);
39 Vector snapFree(Vector coord);
40 Vector snapEndpoint(Vector coord);
41 Vector snapGrid(Vector coord);
42 Vector snapOnEntity(Vector coord);
43 Vector snapCenter(Vector coord);
44 Vector snapMiddle(Vector coord);
45 Vector snapDist(Vector coord);
46 Vector snapIntersection(Vector coord);
47 //Vector snapDirect(Vector coord, bool abs);
49 Vector restrictOrthogonal(Vector coord);
50 Vector restrictHorizontal(Vector coord);
51 Vector restrictVertical(Vector coord);
53 //RS_Entity* catchLeafEntity(const Vector& pos);
54 //RS_Entity* catchLeafEntity(QMouseEvent* e);
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();
70 RS_EntityContainer * container;
71 RS_GraphicView * graphicView;
72 RS_Entity * keyEntity;
75 RS2::SnapMode snapMode;
76 RS2::SnapRestriction snapRes;
78 * Snap distance for snaping to points with a
79 * given distance from endpoints.
83 * Keeps track of the drawings in XOR mode.
87 * Snap range for catching entities.
91 * Show large cross hairs.