Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
box.h
Go to the documentation of this file.
1 #ifndef BOX_H
2 #define BOX_H
3 
4 #include "sceneobject.h"
5 
6 #include <QOpenGLBuffer>
7 
8 namespace LangmuirView {
9 
13 class Box : public SceneObject
14 {
15  Q_OBJECT
16 public:
22  explicit Box(LangmuirViewer &viewer, QObject *parent = 0);
23 
27  ~Box();
28 
32  enum Face {
33  None = 1,
34  North = 2,
35  South = 4,
36  East = 8,
37  West = 16,
38  Front = 32,
39  Back = 64,
40  All = North | South | East | West | Front | Back
41  };
42  Q_DECLARE_FLAGS(Faces, Face)
43  Q_FLAGS(Faces)
44 
48  const QColor& getColor() const;
49 
53  int getXSize() const;
54 
58  int getYSize() const;
59 
63  int getZSize() const;
64 
68  bool imageIsOn() const;
69 
70 signals:
75  void colorChanged(QColor color);
76 
83  void sizeChanged(double xvalue, double yvalue, double zvalue);
84 
89  void imageOnChanged(bool drawn);
90 
95  void facesChanged(Faces faces);
96 
101  void textureChanged(GLuint imageID);
102 
103 public slots:
107  virtual void makeConnections();
108 
113  void setColor(QColor color);
114 
124  void setSize(double xvalue, double yvalue, double zvalue, unsigned int tesselate_x = 10,
125  unsigned int tesselate_y = 10, unsigned int tesselate_z = 10);
126 
131  void setFaces(Faces faces);
132 
137  void showImage(bool on=true);
138 
142  void toggleImage();
143 
147  void setTexture(GLuint imageID);
148 
149 protected:
153  virtual void init();
154 
158  virtual void buildGeometry(unsigned int tesselate_x, unsigned int tesselate_y, unsigned int tesselate_z);
159 
163  virtual void draw();
164 
166  QColor m_color;
167 
169  double m_xsize;
170 
172  double m_ysize;
173 
175  double m_zsize;
176 
178  double m_halfXSize;
179 
181  double m_halfYSize;
182 
184  double m_halfZSize;
185 
187  GLuint m_imageID;
188 
190  bool m_imageOn;
191 
193  Faces m_faces;
194 
196  QOpenGLBuffer *m_verticesVBO;
197 
199  QOpenGLBuffer *m_normalsVBO;
200 
202  QOpenGLBuffer *m_texturesVBO;
203 
205  QOpenGLBuffer *m_indexVBO;
206 
208  unsigned int m_numVertices;
209 
211  unsigned int m_numIndices;
212 };
213 
214 Q_DECLARE_OPERATORS_FOR_FLAGS(Box::Faces)
215 
216 }
217 
218 #endif // BOX_H
void colorChanged(QColor color)
signal that the color of has changed
~Box()
destroy the Box
show texture on the -z
Definition: box.h:40
void sizeChanged(double xvalue, double yvalue, double zvalue)
signal that the box size has changed
double m_halfYSize
half ysize
Definition: box.h:181
Base class for objects in OpenGL scene.
Definition: sceneobject.h:22
QOpenGLBuffer * m_verticesVBO
vertices buffer
Definition: box.h:196
void toggleImage()
toggle if texture is shown
void setColor(QColor color)
set the color
double m_xsize
x length
Definition: box.h:169
virtual void draw()
perform OpenGL drawing operations
double m_ysize
y length
Definition: box.h:172
void imageOnChanged(bool drawn)
signal that the texture is drawn changed
show texture on the +y
Definition: box.h:35
void facesChanged(Faces faces)
signal that which faces the texture appears on changed
QOpenGLBuffer * m_normalsVBO
normals buffer
Definition: box.h:199
QColor m_color
color of box
Definition: box.h:166
double m_zsize
z length
Definition: box.h:175
int getXSize() const
get x length
show texture on the +x
Definition: box.h:37
QOpenGLBuffer * m_indexVBO
index buffer CW
Definition: box.h:205
show texture on the -x
Definition: box.h:38
GLuint m_imageID
texture ID
Definition: box.h:187
bool imageIsOn() const
true if texture is showing
Box(LangmuirViewer &viewer, QObject *parent=0)
create the Box
bool m_imageOn
show texture
Definition: box.h:190
const QColor & getColor() const
get color
void setSize(double xvalue, double yvalue, double zvalue, unsigned int tesselate_x=10, unsigned int tesselate_y=10, unsigned int tesselate_z=10)
set the box size
virtual void init()
initialize object
void showImage(bool on=true)
show the texture
Definition: axis.h:6
do not show texture on any face
Definition: box.h:34
Faces m_faces
texture faces
Definition: box.h:193
double m_halfZSize
half zsize
Definition: box.h:184
virtual void buildGeometry(unsigned int tesselate_x, unsigned int tesselate_y, unsigned int tesselate_z)
build cube geometry
int getYSize() const
get y length
int getZSize() const
get z length
Widget to view Langmuir Simulation in real time.
Definition: langmuirviewer.h:47
A class to represent a textured box.
Definition: box.h:13
void textureChanged(GLuint imageID)
signal that the texture has changed
show texture on the +z
Definition: box.h:39
QOpenGLBuffer * m_texturesVBO
texture buffer
Definition: box.h:202
Face
the faces to show texture on
Definition: box.h:32
Definition: box.h:33
unsigned int m_numIndices
index count
Definition: box.h:211
virtual void makeConnections()
make signal/slot connections
void setTexture(GLuint imageID)
set texture
double m_halfXSize
half xsize
Definition: box.h:178
unsigned int m_numVertices
number of vertices (3 * number of points)
Definition: box.h:208
void setFaces(Faces faces)
set the list of faces to show texture on
show texture on the -y
Definition: box.h:36