MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Clip.hpp
1 #ifndef CLIP_HPP
2 #define CLIP_HPP
3 
4 #include <Config.hpp>
5 
6 #include <Misc.hpp>
7 
8 #include <MGXViewer/qglviewer.h>
9 
10 namespace mgx {
11 class mgx_EXPORT Clip : public QObject {
12  Q_OBJECT
13 
14 public:
15  Clip(int id, QObject* parent = 0);
16 
17  int clipNo() const {
18  return _clipNo;
19  }
20 
21  void enable()
22  {
23  if(!_enable) {
24  _enable = true;
25  hasChanged();
26  }
27  }
28  void disable()
29  {
30  if(_enable) {
31  _enable = false;
32  hasChanged();
33  }
34  }
35  bool enabled() const {
36  return _enable;
37  }
38 
39  void showGrid()
40  {
41  if(!_showGrid) {
42  _showGrid = true;
43  hasChanged();
44  }
45  }
46  void hideGrid()
47  {
48  if(_showGrid) {
49  _showGrid = false;
50  hasChanged();
51  }
52  }
56  bool grid() const {
57  return _showGrid;
58  }
59 
60  void setWidth(float f)
61  {
62  if(_width != f) {
63  _width = f;
64  hasChanged();
65  }
66  }
67  float width() const {
68  return _width;
69  }
70 
71  void setGridSize(float s)
72  {
73  if(_gridSize != s) {
74  _gridSize = s;
75  hasChanged();
76  }
77  }
78  float gridSize() const {
79  return _gridSize;
80  }
81 
82  void setNormal(const Point3f& n)
83  {
84  if(n != _normal) {
85  _normal = n;
86  hasChanged();
87  computeBasis();
88  }
89  }
90  const Point3f& normal() const {
91  return _normal;
92  }
93 
98  Point4f normalFormPos() const;
103  Point4f normalFormNeg() const;
104 
105  void setGridSquares(uint n)
106  {
107  if(n != _gridSquares) {
108  _gridSquares = n;
109  hasChanged();
110  }
111  }
112  uint gridSquares() const {
113  return _gridSquares;
114  }
115 
118  return _frame;
119  }
120  const qglviewer::ManipulatedFrame& frame() const {
121  return _frame;
122  }
123 
127  void hasChanged() {
128  _changed = true;
129  }
130 
131  bool changed() const {
132  return _changed;
133  }
134  void resetChanges() {
135  _changed = false;
136  }
137 
138  bool isClipped(const Point3f& p);
139 
140  const Point3f& xb() const {
141  return _xb;
142  }
143  const Point3f& yb() const {
144  return _yb;
145  }
146  const Point3f& zb() const {
147  return _zb;
148  }
149 
150 protected:
151  void computeBasis();
152 
153  bool _enable;
154  bool _showGrid;
155  float _width;
156  float _gridSize;
162  int _clipNo;
163  bool _changed;
165 };
166 } // namespace mgx
167 #endif // CLIP_HPP
bool _showGrid
Show the grid corresponding to the clipping plane.
Definition: Clip.hpp:154
Misc.
int _clipNo
Id of the clipping region (0, 1 or 2)
Definition: Clip.hpp:162
uint _gridSquares
Number of squares drawn for the grid.
Definition: Clip.hpp:161
bool grid() const
Returns true if the grid is sto be shown, false otherwise.
Definition: Clip.hpp:56
float _width
Width of the region.
Definition: Clip.hpp:155
float _gridSize
Size of the grid (i.e. in the clipping plane)
Definition: Clip.hpp:156
bool _changed
If true, it changed and need update in OpenGL.
Definition: Clip.hpp:163
bool _enable
If true, these planes are used to clipping.
Definition: Clip.hpp:153
qglviewer::ManipulatedFrame & frame()
Get frame.
Definition: Clip.hpp:117
Point3f _xb
X-axis of the planes.
Definition: Clip.hpp:158
void hasChanged()
Call this if you change the manipulated frame.
Definition: Clip.hpp:127
Point3f _yb
Y-axis of the planes.
Definition: Clip.hpp:159
Definition: Clip.hpp:11
Point3f _zb
Thickness of the region.
Definition: Clip.hpp:160
Point3f _normal
Normal to the grid.
Definition: Clip.hpp:157