QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RSnap.h
Go to the documentation of this file.
1 #ifndef RSNAP_H
2 #define RSNAP_H
3 
4 #include <QSet>
5 
6 #include "REntity.h"
7 #include "RMouseEvent.h"
8 #include "RVector.h"
9 
10 class RGraphicsView;
11 
23 class RSnap {
24 public:
29  enum Status {
44  };
45 
46 public:
47  RSnap() : status(RSnap::Unknown), lastSnap(RVector::invalid) {}
48  virtual ~RSnap() {}
49 
54  virtual RVector snap(
55  const RVector& position,
56  RGraphicsView& view,
57  double range=RNANDOUBLE) = 0;
58 
63  virtual RVector snap(RMouseEvent& event) {
64  return snap(event.getModelPosition(), event.getGraphicsView());
65  }
66 
67  virtual void showUiOptions() {}
68  virtual void hideUiOptions() {}
69 
74  QSet<REntity::Id> getEntityIds() {
75  return entityIds;
76  }
77 
79  return status;
80  }
81 
82  RVector getLastSnap() const {
83  return lastSnap;
84  }
85 
86  void reset() {
87  entityIds.clear();
90  }
91 
92 protected:
93  QSet<REntity::Id> entityIds;
96 };
97 
100 
101 #endif