BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::RealSpace::Buffer3DAxes Class Referencefinal

Description

Buffer for drawing 3D Coordinate Axes on canvas.

Definition at line 40 of file buffer.h.

Inheritance diagram for GUI::RealSpace::Buffer3DAxes:
[legend]
Collaboration diagram for GUI::RealSpace::Buffer3DAxes:
[legend]

Public Member Functions

 Buffer3DAxes ()
 
void draw3DAxes ()
 

Private Attributes

QOpenGLBuffer m_glBuffer3DAxes
 
QOpenGLVertexArrayObject m_vao3DAxes
 
int m_vertexCount3DAxes
 

Constructor & Destructor Documentation

◆ Buffer3DAxes()

GUI::RealSpace::Buffer3DAxes::Buffer3DAxes ( )

Definition at line 54 of file buffer.cpp.

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

Definition at line 107 of file buffer.cpp.

108 {
109  QOpenGLVertexArrayObject::Binder dummy(&m_vao3DAxes);
110  glLineWidth(1.4f);
111  glDrawArrays(GL_LINES, 0, m_vertexCount3DAxes);
112 }

References m_vao3DAxes, and m_vertexCount3DAxes.

Member Data Documentation

◆ m_glBuffer3DAxes

QOpenGLBuffer GUI::RealSpace::Buffer3DAxes::m_glBuffer3DAxes
private

Definition at line 48 of file buffer.h.

Referenced by Buffer3DAxes().

◆ m_vao3DAxes

QOpenGLVertexArrayObject GUI::RealSpace::Buffer3DAxes::m_vao3DAxes
private

Definition at line 47 of file buffer.h.

Referenced by Buffer3DAxes(), and draw3DAxes().

◆ m_vertexCount3DAxes

int GUI::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: