LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
snapconstrain.h
Go to the documentation of this file.
1 //
2 // Created by R. van Twisk on 4/30/15.
3 //
4 
5 #pragma once
6 
8 
9 namespace lc {
16  public:
17  const static uint16_t NONE;
18  const static uint16_t ON_ENTITY; // Find a point anywhere on it's entity.
19  const static uint16_t ON_ENTITYPATH; // Find a point anywhere on it's entity's path
20  const static uint16_t ENTITY_CENTER; // Get a snap point centered along the entity. For a arc with will be in the middle between arc start and arc end, for line it will be the center, for a circle this is not possible.
21  // ENTITY_GRAVCENTER = 8; // Entities gravitationally center, for a circle this would be the circle's center
22  const static uint16_t LOGICAL; // enable to entities 'handles' There can be for example end point's of a line, or the center of a circle, or the 4 corners of a circle, grid point's etc..
23  // basically anything that might makes sense to snap into.
24  const static uint16_t DIVIDED; // DIVIDED divides the entity into X equal portions given by divisions
25 
26 
28  if (this != &other) {
29  _angle = other._angle;
30  _divisions = other._divisions;
31  _constrain = other._constrain;
32  }
33  return *this;
34  }
35 
36 
38  _constrain(LOGICAL),
39  _divisions(0),
40  _angle(0.) { }
41 
42  SimpleSnapConstrain(uint16_t constrain, int divisions, double angle) :
43  _constrain(constrain),
44  _divisions(divisions),
45  _angle(angle) { }
46 
47  const uint16_t constrain() const {
48  return _constrain;
49  }
50 
51  int divisions() const {
52  return _divisions;
53  }
54 
55  double angle() const {
56  return _angle;
57  }
58 
60  return SimpleSnapConstrain(_constrain, divisions, _angle);
61  }
62 
65  }
66 
68  return SimpleSnapConstrain(_constrain | constrain, _divisions, _angle);
69  }
70 
72  return SimpleSnapConstrain(_constrain & ~constrain, _divisions, _angle);
73  }
74 
75  bool hasConstrain(uint16_t constrain) const {
76  return (bool) (_constrain & constrain);
77  }
78 
79 
80  private:
81  uint16_t _constrain;
83  double _angle;
84  };
85 }
SimpleSnapConstrain setAngle(double angle) const
Definition: snapconstrain.h:63
static const uint16_t LOGICAL
Definition: snapconstrain.h:22
static const uint16_t ON_ENTITYPATH
Definition: snapconstrain.h:19
SimpleSnapConstrain(uint16_t constrain, int divisions, double angle)
Definition: snapconstrain.h:42
static const uint16_t ENTITY_CENTER
Definition: snapconstrain.h:20
static const uint16_t ON_ENTITY
Definition: snapconstrain.h:18
SimpleSnapConstrain disableConstrain(uint16_t constrain) const
Definition: snapconstrain.h:71
Definition: cadentity.h:12
SimpleSnapConstrain enableConstrain(uint16_t constrain) const
Definition: snapconstrain.h:67
SimpleSnapConstrain & operator=(const SimpleSnapConstrain &other)
Definition: snapconstrain.h:27
bool hasConstrain(uint16_t constrain) const
Definition: snapconstrain.h:75
const uint16_t constrain() const
Definition: snapconstrain.h:47
double angle() const
Definition: snapconstrain.h:55
SimpleSnapConstrain setDivisions(int divisions) const
Definition: snapconstrain.h:59
static const uint16_t DIVIDED
Definition: snapconstrain.h:24
static const uint16_t NONE
Definition: snapconstrain.h:17