MorphoGraphX  2.0-1-227
Clip.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef CLIP_HPP
12 #define CLIP_HPP
13 
14 #include <Config.hpp>
15 #include <Misc.hpp>
16 #include <MGXViewer/qglviewer.h>
17 
18 namespace mgx
19 {
20  class mgx_EXPORT Clip : public QObject
21  {
22  Q_OBJECT
23 
24  public:
25  Clip(int id, QObject* parent = 0);
26 
27  int clipNo() const {
28  return _clipNo;
29  }
30 
31  void enable()
32  {
33  if(!_enable) {
34  _enable = true;
35  hasChanged();
36  }
37  }
38  void disable()
39  {
40  if(_enable) {
41  _enable = false;
42  hasChanged();
43  }
44  }
45  bool enabled() const {
46  return _enable;
47  }
48 
49  void showGrid()
50  {
51  if(!_showGrid) {
52  _showGrid = true;
53  hasChanged();
54  }
55  }
56  void hideGrid()
57  {
58  if(_showGrid) {
59  _showGrid = false;
60  hasChanged();
61  }
62  }
66  bool grid() const {
67  return _showGrid;
68  }
69 
70  void setWidth(float f)
71  {
72  if(_width != f) {
73  _width = f;
74  hasChanged();
75  }
76  }
77  float width() const {
78  return _width;
79  }
80 
81  void setGridSize(float s)
82  {
83  if(_gridSize != s) {
84  _gridSize = s;
85  hasChanged();
86  }
87  }
88  float gridSize() const {
89  return _gridSize;
90  }
91 
92  void setNormal(const Point3f& n)
93  {
94  if(n != _normal) {
95  _normal = n;
96  hasChanged();
97  computeBasis();
98  }
99  }
100  const Point3f& normal() const {
101  return _normal;
102  }
103 
108  Point4f normalFormPos() const;
113  Point4f normalFormNeg() const;
114 
116  {
117  if(n != _gridSquares) {
118  _gridSquares = n;
119  hasChanged();
120  }
121  }
122  uint gridSquares() const {
123  return _gridSquares;
124  }
125 
128  return _frame;
129  }
131  return _frame;
132  }
133 
137  void hasChanged() {
138  _changed = true;
139  }
140 
141  bool changed() const {
142  return _changed;
143  }
144  void resetChanges() {
145  _changed = false;
146  }
147 
148  bool isClipped(const Point3f& p);
149 
150  const Point3f& xb() const {
151  return _xb;
152  }
153  const Point3f& yb() const {
154  return _yb;
155  }
156  const Point3f& zb() const {
157  return _zb;
158  }
159 
160  protected:
161  void computeBasis();
162 
163  bool _enable;
164  bool _showGrid;
165  float _width;
166  float _gridSize;
172  int _clipNo;
173  bool _changed;
175  };
176 }
177 #endif
mgx::Clip::_width
float _width
Width of the region.
Definition: Clip.hpp:165
mgx::Clip::showGrid
void showGrid()
Definition: Clip.hpp:49
mgx::uint
unsigned int uint
Definition: Geometry.hpp:41
mgx::Clip::_enable
bool _enable
If true, these planes are used to clipping.
Definition: Clip.hpp:163
mgx::Clip::_normal
Point3f _normal
Normal to the grid.
Definition: Clip.hpp:167
mgx::Clip::width
float width() const
Definition: Clip.hpp:77
mgx::Clip::disable
void disable()
Definition: Clip.hpp:38
qglviewer::ManipulatedFrame
n
#define n
Definition: Eigenvalues.hpp:36
mgx::Clip::zb
const Point3f & zb() const
Definition: Clip.hpp:156
mgx::Clip::frame
const qglviewer::ManipulatedFrame & frame() const
Definition: Clip.hpp:130
mgx::Clip::setWidth
void setWidth(float f)
Definition: Clip.hpp:70
mgx::Clip::_changed
bool _changed
If true, it changed and need update in OpenGL.
Definition: Clip.hpp:173
mgx::Clip::hideGrid
void hideGrid()
Definition: Clip.hpp:56
mgx::Clip::_clipNo
int _clipNo
Id of the clipping region (0, 1 or 2)
Definition: Clip.hpp:172
mgx::Clip::_yb
Point3f _yb
Y-axis of the planes.
Definition: Clip.hpp:169
mgx::Clip::changed
bool changed() const
Definition: Clip.hpp:141
mgx::Clip::hasChanged
void hasChanged()
Call this if you change the manipulated frame.
Definition: Clip.hpp:137
mgx::Clip::enabled
bool enabled() const
Definition: Clip.hpp:45
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::Clip::_zb
Point3f _zb
Thickness of the region.
Definition: Clip.hpp:170
mgx::Clip::setNormal
void setNormal(const Point3f &n)
Definition: Clip.hpp:92
mgx::Clip
Definition: Clip.hpp:20
mgx::Clip::_gridSize
float _gridSize
Size of the grid (i.e. in the clipping plane)
Definition: Clip.hpp:166
mgx::Clip::xb
const Point3f & xb() const
Definition: Clip.hpp:150
mgx::Clip::clipNo
int clipNo() const
Definition: Clip.hpp:27
mgx::Clip::yb
const Point3f & yb() const
Definition: Clip.hpp:153
mgx::Clip::normal
const Point3f & normal() const
Definition: Clip.hpp:100
mgx::Clip::_gridSquares
uint _gridSquares
Number of squares drawn for the grid.
Definition: Clip.hpp:171
mgx::Clip::gridSize
float gridSize() const
Definition: Clip.hpp:88
Misc.hpp
mgx::Clip::_frame
qglviewer::ManipulatedFrame _frame
Definition: Clip.hpp:174
mgx::Vector< 3, float >
mgx::Clip::frame
qglviewer::ManipulatedFrame & frame()
Get frame.
Definition: Clip.hpp:127
mgx::Clip::grid
bool grid() const
Returns true if the grid is sto be shown, false otherwise.
Definition: Clip.hpp:66
mgx::Clip::gridSquares
uint gridSquares() const
Definition: Clip.hpp:122
mgx::Clip::setGridSize
void setGridSize(float s)
Definition: Clip.hpp:81
mgx::Clip::enable
void enable()
Definition: Clip.hpp:31
mgx::Clip::_showGrid
bool _showGrid
Show the grid corresponding to the clipping plane.
Definition: Clip.hpp:164
mgx::Clip::resetChanges
void resetChanges()
Definition: Clip.hpp:144
mgx::Clip::_xb
Point3f _xb
X-axis of the planes.
Definition: Clip.hpp:168
mgx::Clip::setGridSquares
void setGridSquares(uint n)
Definition: Clip.hpp:115