Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pointcloud.h
Go to the documentation of this file.
1 #ifndef POINTCLOUD_H
2 #define POINTCLOUD_H
3 
4 #include "sceneobject.h"
5 
6 #include <QOpenGLShaderProgram>
7 #include <QOpenGLShader>
8 #include <QOpenGLBuffer>
9 #include <QMatrix4x4>
10 #include <QVector>
11 
12 namespace LangmuirView {
13 
17 class PointCloud : public SceneObject
18 {
19  Q_OBJECT
20 public:
26  explicit PointCloud(LangmuirViewer &viewer, QObject *parent = 0);
27 
31  ~PointCloud();
32 
36  enum Mode {
37  Points = 1,
38  Squares = 2,
39  Cubes = 3,
40  };
41  Q_DECLARE_FLAGS(Modes, Mode)
42  Q_FLAGS(Modes)
43 
47  const QColor& getColor() const;
48 
52  float getPointSize() const;
53 
57  Mode getMode() const;
58 
59 public:
64  QVector<float>& vertices();
65 
69  unsigned int getMaxPoints();
70 
75  unsigned int getMaxRender();
76 
77 signals:
82  void maxPointsChanged(unsigned int value);
83 
88  void maxRenderChanged(unsigned int value);
89 
94  void pointSizeChanged(float value);
95 
100  void colorChanged(QColor color);
101 
106  void modeChanged(PointCloud::Mode mode);
107 
112  void modeChanged(QString mode);
113 
114 public slots:
118  virtual void makeConnections();
119 
127  void setMaxPoints(unsigned int value);
128 
135  void setMaxRender(unsigned int value);
136 
141  void setPointSize(float value);
142 
147  void setColor(QColor color);
148 
153  void setMode(Mode mode);
154 
160  void updateVBO();
161 
166  static QString modeToQString(Mode mode);
167 
172  static Mode QStringToMode(QString string);
173 
174 protected:
178  virtual void init();
179 
183  virtual void draw();
184 
188  void initShaders();
189 
191  void drawFallback();
192 
194  void drawPoints();
195 
197  void drawSquares();
198 
200  void drawCubes();
201 
203  QOpenGLShaderProgram m_shader1;
204 
206  QOpenGLShaderProgram m_shader2;
207 
209  QOpenGLShaderProgram m_shader3;
210 
212  QOpenGLBuffer *m_verticesVBO;
213 
215  QVector<float> m_vertices;
216 
218  unsigned int m_maxPoints;
219 
221  unsigned int m_maxRender;
222 
224  float m_pointSize;
225 
227  QColor m_color;
228 
231 
234 
237 
240 };
241 
242 }
243 
245 
246 #endif // POINTCLOUD_H
unsigned int m_maxPoints
maximum number of points allowed (# vertices / 3)
Definition: pointcloud.h:218
static Mode QStringToMode(QString string)
convert string to Mode enum
bool m_shader3OK
shader3 ok to use
Definition: pointcloud.h:239
void drawFallback()
render function
Base class for objects in OpenGL scene.
Definition: sceneobject.h:22
static QString modeToQString(Mode mode)
convert Mode to string
Mode m_mode
rendering mode
Definition: pointcloud.h:230
void setMaxPoints(unsigned int value)
change the maximum number of points allowed
void maxRenderChanged(unsigned int value)
signal that the maximum number of points rendered has changed
const QColor & getColor() const
get color
Mode getMode() const
get render mode
virtual void makeConnections()
make signal/slot connections
void drawPoints()
render function
virtual void draw()
perform OpenGL drawing operations
void modeChanged(PointCloud::Mode mode)
signal that the render mode has changed
void drawCubes()
render function
bool m_shader1OK
shader1 ok to use
Definition: pointcloud.h:233
void setPointSize(float value)
set the point size
QOpenGLShaderProgram m_shader2
OpenGL shading pipeline for squares.
Definition: pointcloud.h:206
Q_DECLARE_METATYPE(LangmuirView::PointCloud::Mode)
PointCloud(LangmuirViewer &viewer, QObject *parent=0)
create the PointCloud
Mode
The rendering mode for the cloud.
Definition: pointcloud.h:36
unsigned int getMaxPoints()
get the maximum number of points that can be rendered
A class to represent a point cloud.
Definition: pointcloud.h:17
void setMode(Mode mode)
set the mode
unsigned int getMaxRender()
get the number of points currently being rendered
QOpenGLShaderProgram m_shader1
OpenGL shading pipeline for points.
Definition: pointcloud.h:203
render points as squares
Definition: pointcloud.h:39
QOpenGLBuffer * m_verticesVBO
vertices buffer (GPU)
Definition: pointcloud.h:212
Definition: axis.h:6
float getPointSize() const
get x length
void colorChanged(QColor color)
signal that the color of has changed
QOpenGLShaderProgram m_shader3
OpenGL shading pipeline for cubes.
Definition: pointcloud.h:209
render points as OpenGL points
Definition: pointcloud.h:38
Widget to view Langmuir Simulation in real time.
Definition: langmuirviewer.h:47
void maxPointsChanged(unsigned int value)
signal that the maximum number of points has changed
void initShaders()
load the shaders
unsigned int m_maxRender
maximum number of points rendered (less than or equal to max points)
Definition: pointcloud.h:221
void drawSquares()
render function
QVector< float > & vertices()
get the list of vertices (CPU memory)
Definition: pointcloud.h:37
virtual void init()
initialize object
~PointCloud()
destroy the PointCloud
QColor m_color
color of points
Definition: pointcloud.h:227
void setMaxRender(unsigned int value)
change the maximum number of points to render
bool m_shader2OK
shader2 ok to use
Definition: pointcloud.h:236
float m_pointSize
the size of points
Definition: pointcloud.h:224
QVector< float > m_vertices
vertices buffer (CPU)
Definition: pointcloud.h:215
void pointSizeChanged(float value)
signal that the point size has changed
void updateVBO()
update the GPU memory using CPU vertices
void setColor(QColor color)
set the color