QCAD
Open Source 2D CAD
RSnap.h
Go to the documentation of this file.
1 
20 #ifndef RSNAP_H
21 #define RSNAP_H
22 
23 #include "core_global.h"
24 
25 #include <QSet>
26 
27 #include "REntity.h"
28 #include "RMouseEvent.h"
29 #include "RVector.h"
30 
31 class RGraphicsView;
32 
45 public:
50  enum Status {
65  CoordinatePolar
66  };
67 
68 public:
69  RSnap() : status(RSnap::Unknown), lastSnap(RVector::invalid) {}
70  virtual ~RSnap() {}
71 
76  virtual RVector snap(
77  const RVector& position,
78  RGraphicsView& view,
79  double range=RNANDOUBLE) = 0;
80 
85  virtual RVector snap(RMouseEvent& event) {
86  return snap(event.getModelPosition(), event.getGraphicsView());
87  }
88 
89  virtual void showUiOptions() {}
90  virtual void hideUiOptions() {}
91 
92  virtual void suspendEvent() {
93  hideUiOptions();
94  }
95  virtual void finishEvent() {
96  hideUiOptions();
97  }
98 
103  QSet<REntity::Id> getEntityIds() {
104  return entityIds;
105  }
106 
108  return status;
109  }
110 
112  return lastSnap;
113  }
114 
115  void reset() {
116  entityIds.clear();
117  status = RSnap::Unknown;
118  lastSnap = RVector::invalid;
119  }
120 
121 protected:
122  QSet<REntity::Id> entityIds;
125 };
126 
128 Q_DECLARE_METATYPE(RSnap::Status)
129 
130 #endif
virtual void showUiOptions()
Definition: RSnap.h:89
Definition: RSnap.h:56
QSet< REntity::Id > entityIds
Definition: RSnap.h:122
void reset()
Definition: RSnap.h:115
Abstract base class for all grid and object snap implementations.
Definition: RSnap.h:44
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
Definition: RSnap.h:55
Definition: RSnap.h:53
RSnap::Status getStatus() const
Definition: RSnap.h:107
Definition: RSnap.h:52
#define QCADCORE_EXPORT
Definition: core_global.h:10
Definition: RSnap.h:54
virtual void finishEvent()
Definition: RSnap.h:95
Definition: RSnap.h:61
Definition: RSnap.h:60
virtual RVector snap(RMouseEvent &event)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: RSnap.h:85
#define RNANDOUBLE
Definition: RMath.h:71
virtual void hideUiOptions()
Definition: RSnap.h:90
virtual ~RSnap()
Definition: RSnap.h:70
RVector lastSnap
Definition: RSnap.h:124
RVector getLastSnap() const
Definition: RSnap.h:111
Definition: RSnap.h:63
RSnap()
Definition: RSnap.h:69
Q_DECLARE_METATYPE(RMath *)
Definition: RSnap.h:62
QSet< REntity::Id > getEntityIds()
Definition: RSnap.h:103
RSnap::Status status
Definition: RSnap.h:123
A mouse event for a graphics scene.
Definition: RMouseEvent.h:42
Definition: RSnap.h:59
Definition: RSnap.h:51
Status
Snap status, returned by snap tools (most importantly auto snap tool) to indicate what snap was used...
Definition: RSnap.h:50
virtual void suspendEvent()
Definition: RSnap.h:92
RVector getModelPosition() const
Definition: RInputEvent.cpp:38
Definition: RSnap.h:64
static const RVector invalid
invalid vector
Definition: RVector.h:307
Definition: RSnap.h:57
Definition: RSnap.h:58
Graphics view.
Definition: RGraphicsView.h:58