Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
langmuirviewer.h
Go to the documentation of this file.
1 #ifndef LANGMUIRVIEWER_H
2 #define LANGMUIRVIEWER_H
3 
4 #include <QGLViewer/qglviewer.h>
5 #include <QGLViewer/manipulatedCameraFrame.h>
6 #include <QErrorMessage>
7 #include <QColorDialog>
8 #include <QMatrix4x4>
9 #include <QSettings>
10 
11 #include "isosurface.h"
12 #include "corneraxis.h"
13 #include "pointcloud.h"
14 #include "light.h"
15 #include "grid.h"
16 #include "rand.h"
17 #include "mesh.h"
18 #include "box.h"
19 
20 #define BOOST_DISABLE_ASSERTS
21 
22 #ifndef Q_MOC_RUN
23 
24 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
25 #pragma GCC diagnostic push
26 #pragma GCC system_header
27 #endif
28 
29 #include "boost/multi_array.hpp"
30 
31 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
32 #pragma GCC diagnostic pop
33 #endif
34 
35 #endif
36 
37 namespace LangmuirCore {
38  class Simulation;
39  class World;
40 }
41 
42 namespace LangmuirView {
43 
47 class LangmuirViewer : public QGLViewer
48 {
49  Q_OBJECT
50 public:
55  explicit LangmuirViewer(QWidget *parent = 0);
56 
61 
65  QMatrix4x4& getModelViewProjectionMatrix();
66 
70  QMatrix4x4& getProjectionMatrix();
71 
75  QMatrix4x4& getOpenGLModelViewMatrix();
76 
80  QMatrix4x4& getOpenGLProjectionMatrix();
81 
86 
91 
95  const QColor& trapColor() const { return m_trapColor; }
96 
100  const QColor& stageColor2() const { return m_stageColor2; }
101 
106 
111 
115  PointCloud & defects() { return *m_defects; }
116 
120  PointCloud & holes() { return *m_holes; }
121 
125  PointCloud & traps() { return *m_traps; }
126 
130  Box & rightBox() { return *m_rBox; }
131 
135  Box & leftBox() { return *m_lBox; }
136 
140  Box & baseBox() { return *m_baseBox; }
141 
145  Box & trapBox() { return *m_trapBox; }
146 
150  Box & stageBox() { return *m_stageBox; }
151 
155  Mesh & trapMesh() { return *m_trapMesh; }
156 
160  Light & light() { return *m_light0; }
161 
165  Grid & grid() { return *m_grid; }
166 
167 signals:
173  void showMessage(const QString& message, int timeout=0);
174 
178  void clearMessage();
179 
184  void isUsingOpenCL(bool useOpenCL);
185 
190  void isUsingCoulomb(bool useCoulomb);
191 
196  void isAnimated(bool playing);
197 
202  void isShowingTraps(bool shown);
203 
208  void iterationsPrintChanged(int value);
209 
214  void currentStepChanged(int value);
215 
219  void openGLInitFinished();
220 
224  void trapColorChanged(QColor color);
225 
229  void stageColor2Changed(QColor color);
230 
234  void backgroundColorChanged(QColor color);
235 
239  void canCalculateIsoSurface(bool able);
240 
244  void isoSurfaceProgress(int);
245 
249  void checkerSizeChanged(float);
250 
251 public slots:
256 
261 
266 
270  void setPointMode(PointCloud::Mode mode);
271 
276  void setIterationsPrint(int value);
277 
282  void toggleTrapsShown(bool on=true);
283 
288  void toggleOpenCL(bool on=true);
289 
294  void toggleCoulomb(bool on=true);
295 
300 
304  void toggleGridIsVisible();
305 
310  void load(QString fileName);
311 
316  void save(QString fileName);
317 
321  void resetCamera();
322 
326  void unload();
327 
331  void reset();
332 
336  void pause();
337 
341  void play();
342 
346  void showParameters();
347 
353  void drawLightSource(GLenum light, float scale = 1.0f) const;
354 
359  void loadSettings(QString fileName);
360 
365  void saveSettings(QString fileName);
366 
371  void errorMessage(QString message);
372 
377  void setSettings(QSettings &settings);
378 
383  void getSettings(QSettings &settings);
384 
389  void setTrapColor(QColor color);
390 
395  void setStageColor2(QColor color);
396 
401  void setBackgroundColor(QColor color);
402 
406  void initTraps();
407 
411  void initStage();
412 
416  void generateIsoSurface(float value);
417 
421  void updateTrapMesh();
422 
426  void resetSettings();
427 
431  void setCanCalculateIsoSurface(bool enabled);
432 
436  void setCheckerSize(float size);
437 
438 protected:
442  void updateElectronCloud();
443 
447  void updateDefectCloud();
448 
452  void updateTrapCloud();
453 
457  void updateHoleCloud();
458 
462  void initGeometry();
463 
467  virtual void init();
468 
472  virtual void preDraw();
473 
477  virtual void draw();
478 
482  virtual void postDraw();
483 
487  virtual void animate();
488 
492  virtual void help();
493 
497  virtual QString helpString() const;
498 
506  void drawTraps(QImage &image, QColor bcolor, QColor fcolor);
507 
514  void drawChecker(QImage &image, QColor color1, QColor color2);
515 
521  void loadTexture(GLuint imageID, QImage &image);
522 
524  GLuint m_textures[2];
525 
528 
531 
534 
537 
540 
543 
546 
549 
552 
555 
558 
560  QColor m_trapColor;
561 
564 
567 
570 
573 
576 
579 
582 
585 
587  float m_gridHalfX;
588 
590  float m_gridHalfY;
591 
593  float m_gridHalfZ;
594 
596  float m_gridX;
597 
599  float m_gridY;
600 
602  float m_gridZ;
603 
605  QErrorMessage *m_error;
606 
609 
612 
615 
618 };
619 
620 }
621 
622 #endif // LANGMUIRVIEWER_H
void setCanCalculateIsoSurface(bool enabled)
set can calculate isosurface
Box & trapBox()
get trap box object
Definition: langmuirviewer.h:145
PointCloud & defects()
get defects object
Definition: langmuirviewer.h:115
A class to generate random numbers.
Definition: rand.h:31
void toggleGridIsVisible()
show/hide the grid
void resetSettings()
set default colors
Grid * m_grid
grid that outlines sites
Definition: langmuirviewer.h:566
QMatrix4x4 & getOpenGLModelViewMatrix()
obtain the model-view matrix (OpenGL matrix stack)
void isUsingCoulomb(bool useCoulomb)
signal if Coulomb is being used
QMatrix4x4 & getOpenGLProjectionMatrix()
obtain the projection matrix (OpenGL matrix stack)
float m_stageExtend
stage size
Definition: langmuirviewer.h:614
void loadSettings(QString fileName)
load settings from a file
const QColor & trapColor() const
get the trap color
Definition: langmuirviewer.h:95
Mesh & trapMesh()
get trap mesh object
Definition: langmuirviewer.h:155
MarchingCubes::Isosurface * m_isoSurface
isosurface
Definition: langmuirviewer.h:572
void initGeometry()
update the geometry using simulation parameters
Box * m_trapBox
trap box
Definition: langmuirviewer.h:542
LangmuirCore::Simulation * m_simulation
the simulation manipulator
Definition: langmuirviewer.h:578
void clearMessage()
clear the status bar message
float m_gridX
grid.x
Definition: langmuirviewer.h:596
Light & light()
get light object
Definition: langmuirviewer.h:160
void setBackgroundColor(QColor color)
set background color
void drawLightSource(GLenum light, float scale=1.0f) const
draw an OpenGL light source
void isoSurfaceProgress(int)
show calculation progress
void initTraps()
init trap texture
A class to represent an xyz axis that doesnt change size/position.
Definition: corneraxis.h:11
void currentStepChanged(int value)
signal that current.step changed
void showParameters()
show parameters in a window
Box * m_rBox
box (right)
Definition: langmuirviewer.h:551
Box & stageBox()
get stage box object
Definition: langmuirviewer.h:150
double m_boxThickness
box parameter
Definition: langmuirviewer.h:557
void trapColorChanged(QColor color)
signal that the trap color changed
Box & rightBox()
get right box object
Definition: langmuirviewer.h:130
void toggleCoulomb(bool on=true)
turn Coulomb on and off
void setHolePointMode(PointCloud::Mode mode)
set the render mode for points
PointCloud * m_traps
point cloud representing traps
Definition: langmuirviewer.h:539
PointCloud * m_electrons
point cloud representing electrons
Definition: langmuirviewer.h:530
void setIterationsPrint(int value)
set the value of iterations.print
float m_sceneRadius
size of scene
Definition: langmuirviewer.h:611
Grid & grid()
get grid object
Definition: langmuirviewer.h:165
PointCloud & electrons()
get electrons object
Definition: langmuirviewer.h:110
PointCloud & traps()
get traps object
Definition: langmuirviewer.h:125
void toggleTrapsShown(bool on=true)
turn on the traps texture
Mode
The rendering mode for the cloud.
Definition: pointcloud.h:36
void generateIsoSurface(float value)
generate isosurface
void setSettings(QSettings &settings)
set the properties of settings object
A class to represent a point cloud.
Definition: pointcloud.h:17
void initStage()
init stage texture
A class to hold all objects in a simulation.
Definition: world.h:51
Light * m_light0
main light source
Definition: langmuirviewer.h:575
void errorMessage(QString message)
show error message window
void isAnimated(bool playing)
signal if simulation is playing
const QColor & stageColor2() const
get the stage color
Definition: langmuirviewer.h:100
void load(QString fileName)
load a simulation
CornerAxis * m_cornerAxis
axis that sits in the corner and doesnt change size
Definition: langmuirviewer.h:527
void setCheckerSize(float size)
set size of checkers on stage
A class to compute a contour iso-surface.
Definition: isosurface.h:385
void openGLInitFinished()
signal that OpenGL has been initialized
QMatrix4x4 & getModelViewProjectionMatrix()
obtain the model-view-projection matrix (QGLViewer camera)
PointCloud * m_defects
point cloud representing defects
Definition: langmuirviewer.h:533
void setPointMode(PointCloud::Mode mode)
set the render mode for points
LangmuirCore::World * m_world
the simulation data
Definition: langmuirviewer.h:584
Definition: axis.h:6
PointCloud * m_holes
point cloud representing holes
Definition: langmuirviewer.h:536
void toggleOpenCL(bool on=true)
turn OpenCL on and off
void getSettings(QSettings &settings)
get the properties of settings object
void save(QString fileName)
save a checkpoint file
CornerAxis & cornerAxis()
get corner axis object
Definition: langmuirviewer.h:105
void updateHoleCloud()
update the hole point cloud
virtual void animate()
change the state of the system before drawing
float m_gridY
grid.y
Definition: langmuirviewer.h:599
void stageColor2Changed(QColor color)
signal that the stage color2 changed
void toggleCornerAxisIsVisible()
show/hide the corner axis
void setElectronPointMode(PointCloud::Mode mode)
set the render mode for points
Widget to view Langmuir Simulation in real time.
Definition: langmuirviewer.h:47
void iterationsPrintChanged(int value)
signal that iterations.print changed
A class to represent a textured box.
Definition: box.h:13
void updateTrapCloud()
update the defect point cloud
void reset()
reset the current simulation
void pause()
pause the simulation
Definition: agent.h:12
float m_gridHalfZ
half of grid.z
Definition: langmuirviewer.h:593
A class to represent a light source.
Definition: light.h:13
void updateDefectCloud()
update the defect point cloud
void play()
play the simulation
PointCloud & holes()
get holes object
Definition: langmuirviewer.h:120
void setDefectPointMode(PointCloud::Mode mode)
set the render mode for points
Box * m_baseBox
base box
Definition: langmuirviewer.h:545
LangmuirCore::Random & random()
get the random number generator
virtual QString helpString() const
get the help string
virtual void postDraw()
draw on the OpenGL widget after the main draw event
void backgroundColorChanged(QColor color)
signal that the background color changed
void updateElectronCloud()
update the electron point cloud
void drawChecker(QImage &image, QColor color1, QColor color2)
draw checker pattern on stage
QColor m_stageColor2
stage color
Definition: langmuirviewer.h:563
void isUsingOpenCL(bool useOpenCL)
signal if OpenCL is being used
LangmuirCore::Random m_random
a random number generator instance
Definition: langmuirviewer.h:581
A class to represent simulation grid.
Definition: grid.h:17
QMatrix4x4 & getProjectionMatrix()
obtain the projection matrix (QGLViewer camera)
Mesh * m_trapMesh
trap mesh
Definition: langmuirviewer.h:569
virtual void draw()
draw on the OpenGL widget
void saveSettings(QString fileName)
save settings to a file
void resetCamera()
reset the camera to the default position
Box * m_stageBox
box (stage)
Definition: langmuirviewer.h:554
void setTrapColor(QColor color)
Change the trap color.
Box & leftBox()
get left box object
Definition: langmuirviewer.h:135
float m_gridHalfY
half of grid.y
Definition: langmuirviewer.h:590
void loadTexture(GLuint imageID, QImage &image)
load texture to gpu memory
void isShowingTraps(bool shown)
signal if traps are shown
void unload()
unload the current simulation
virtual void preDraw()
draw on the OpenGL widget before the main draw event
float m_gridHalfX
half of grid.x
Definition: langmuirviewer.h:587
void drawTraps(QImage &image, QColor bcolor, QColor fcolor)
draw traps on image
void showMessage(const QString &message, int timeout=0)
show a message in the status bar
~LangmuirViewer()
destroy the LangmuirViewer
void updateTrapMesh()
update trap mesh
void setStageColor2(QColor color)
Change the stage color2.
QColor m_trapColor
box parameter
Definition: langmuirviewer.h:560
A class to represent a mesh.
Definition: mesh.h:17
virtual void init()
setup OpenGL
void canCalculateIsoSurface(bool able)
signal that the isosurface can by calculated again
LangmuirViewer(QWidget *parent=0)
create the LangmuirViewer
bool okToCalculateIsoSurface()
its ok when not already calculating
Definition: langmuirviewer.h:90
void checkerSizeChanged(float)
signal that the checker size changed
QErrorMessage * m_error
error messages
Definition: langmuirviewer.h:605
Box & baseBox()
get base box object
Definition: langmuirviewer.h:140
bool m_canCalculateIsoSurface
can calculate isosurface
Definition: langmuirviewer.h:608
A class to orchestrate the calculation.
Definition: simulation.h:21
virtual void help()
open the help widget
GLuint m_textures[2]
texture ids
Definition: langmuirviewer.h:524
float m_checkerSize
size of checkers on stage
Definition: langmuirviewer.h:617
Box * m_lBox
box (left)
Definition: langmuirviewer.h:548
float m_gridZ
grid.z
Definition: langmuirviewer.h:602