BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
RealSpace::Buffer3DAxes Class Referencefinal
Inheritance diagram for RealSpace::Buffer3DAxes:
[legend]
Collaboration diagram for RealSpace::Buffer3DAxes:
[legend]

Public Member Functions

 Buffer3DAxes ()
 
void draw3DAxes ()
 

Private Attributes

QOpenGLBuffer m_glBuffer3DAxes
 
QOpenGLVertexArrayObject m_vao3DAxes
 
int m_vertexCount3DAxes
 

Detailed Description

Definition at line 40 of file buffer.h.

Constructor & Destructor Documentation

◆ Buffer3DAxes()

RealSpace::Buffer3DAxes::Buffer3DAxes ( )

Definition at line 52 of file buffer.cpp.

53 {
54  initializeOpenGLFunctions();
55 
56  QOpenGLVertexArrayObject::Binder __(&m_vao3DAxes);
57 
58  // vertices (xyz) and colors (rgb) for drawing each line (also arrows) in the 3D axes
59  const GLfloat vertices3DAxes[] = {
60  0.00f, 0.00f, 0.00f, 1.0f, 0.0f, 0.0f, // x-axis
61  cx * 1.00f, 0.00f, 0.00f, 1.0f, 0.0f, 0.0f, cx * 1.00f,
62  0.00f, 0.00f, 1.0f, 0.0f, 0.0f, cx * 0.95f, cz * 0.05f,
63  cz * 0.05f, 1.0f, 0.0f, 0.0f, cx * 1.00f, 0.00f, 0.00f,
64  1.0f, 0.0f, 0.0f, cx * 0.95f, cz * 0.05f, cz * -0.05f, 1.0f,
65  0.0f, 0.0f, cx * 1.00f, 0.00f, 0.00f, 1.0f, 0.0f,
66  0.0f, cx * 0.95f, cz * -0.05f, cz * 0.05f, 1.0f, 0.0f, 0.0f,
67  cx * 1.00f, 0.00f, 0.00f, 1.0f, 0.0f, 0.0f, cx * 0.95f,
68  cz * -0.05f, cz * -0.05f, 1.0f, 0.0f, 0.0f,
69 
70  0.00f, 0.00f, 0.00f, 0.0f, 1.0f, 0.0f, // y-axis
71  0.00f, cx * 1.00f, 0.00f, 0.0f, 1.0f, 0.0f, 0.00f,
72  cx * 1.00f, 0.00f, 0.0f, 1.0f, 0.0f, cz * 0.05f, cx * 0.95f,
73  cz * 0.05f, 0.0f, 1.0f, 0.0f, 0.00f, cx * 1.00f, 0.00f,
74  0.0f, 1.0f, 0.0f, cz * 0.05f, cx * 0.95f, cz * -0.05f, 0.0f,
75  1.0f, 0.0f, 0.00f, cx * 1.00f, 0.00f, 0.0f, 1.0f,
76  0.0f, cz * -0.05f, cx * 0.95f, cz * 0.05f, 0.0f, 1.0f, 0.0f,
77  0.00f, cx * 1.00f, 0.00f, 0.0f, 1.0f, 0.0f, cz * -0.05f,
78  cx * 0.95f, cz * -0.05f, 0.0f, 1.0f, 0.0f,
79 
80  0.00f, 0.00f, 0.00f, 0.0f, 0.0f, 1.0f, // z-axis
81  0.00f, 0.00f, cz * 1.00f, 0.0f, 0.0f, 1.0f, 0.00f,
82  0.00f, cz * 1.00f, 0.0f, 0.0f, 1.0f, cz * 0.05f, cz * 0.05f,
83  cz * 0.95f, 0.0f, 0.0f, 1.0f, 0.00f, 0.00f, cz * 1.00f,
84  0.0f, 0.0f, 1.0f, cz * 0.05f, cz * -0.05f, cz * 0.95f, 0.0f,
85  0.0f, 1.0f, 0.00f, 0.00f, cz * 1.00f, 0.0f, 0.0f,
86  1.0f, cz * -0.05f, cz * 0.05f, cz * 0.95f, 0.0f, 0.0f, 1.0f,
87  0.00f, 0.00f, cz * 1.00f, 0.0f, 0.0f, 1.0f, cz * -0.05f,
88  cz * -0.05f, cz * 0.95f, 0.0f, 0.0f, 1.0f,
89  };
90 
92 
93  m_glBuffer3DAxes.create();
94  m_glBuffer3DAxes.bind();
95  m_glBuffer3DAxes.allocate(vertices3DAxes, int(sizeof(vertices3DAxes)));
96 
97  glEnableVertexAttribArray(0); // 3D axes vertices
98  glEnableVertexAttribArray(2); // 3D axes colors
99 
100  glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), nullptr);
101  glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float),
102  reinterpret_cast<void*>(3 * sizeof(float)));
103 }
QOpenGLVertexArrayObject m_vao3DAxes
Definition: buffer.h:47
QOpenGLBuffer m_glBuffer3DAxes
Definition: buffer.h:48

References m_glBuffer3DAxes, m_vao3DAxes, and m_vertexCount3DAxes.

Member Function Documentation

◆ draw3DAxes()

void RealSpace::Buffer3DAxes::draw3DAxes ( )

Definition at line 105 of file buffer.cpp.

106 {
107  QOpenGLVertexArrayObject::Binder __(&m_vao3DAxes);
108  glLineWidth(1.4f);
109  glDrawArrays(GL_LINES, 0, m_vertexCount3DAxes);
110 }

References m_vao3DAxes, and m_vertexCount3DAxes.

Member Data Documentation

◆ m_glBuffer3DAxes

QOpenGLBuffer RealSpace::Buffer3DAxes::m_glBuffer3DAxes
private

Definition at line 48 of file buffer.h.

Referenced by Buffer3DAxes().

◆ m_vao3DAxes

QOpenGLVertexArrayObject RealSpace::Buffer3DAxes::m_vao3DAxes
private

Definition at line 47 of file buffer.h.

Referenced by Buffer3DAxes(), and draw3DAxes().

◆ m_vertexCount3DAxes

int RealSpace::Buffer3DAxes::m_vertexCount3DAxes
private

Definition at line 46 of file buffer.h.

Referenced by Buffer3DAxes(), and draw3DAxes().


The documentation for this class was generated from the following files: