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

Description

Definition at line 26 of file program.h.

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

Public Member Functions

 Program ()
 

Private Member Functions

void init ()
 
void needsInit ()
 
void set (Camera const &)
 
void set (QColor const &)
 
void set (QMatrix4x4 const &)
 
void setAxis (bool const &)
 
void setMatModel (QMatrix4x4 const &)
 

Private Attributes

int ambient
 
bool doInit
 
int eye
 
int locAxis
 
int locColor
 
int locLightPos1
 
int locMatModel
 
int locMatObject
 
int locMatProj
 

Friends

class Canvas
 

Constructor & Destructor Documentation

◆ Program()

GUI::RealSpace::Program::Program ( )

Definition at line 30 of file program.cpp.

31 {
32  // make sure our resource file gets initialized
34 
35  needsInit();
36 }
void InitShaderResources()
Definition: program.cpp:21

References InitShaderResources(), and needsInit().

Here is the call graph for this function:

Member Function Documentation

◆ init()

void GUI::RealSpace::Program::init ( )
private

Definition at line 43 of file program.cpp.

44 {
45  if (!doInit)
46  return;
47  doInit = false;
48 
49  auto shader_found =
50  addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shaders/vertex_shader.vert");
51  if (!shader_found)
52  throw std::runtime_error("Vertex shader not loaded");
53 
54  shader_found =
55  addShaderFromSourceFile(QOpenGLShader::Fragment, ":/shaders/fragment_shader.frag");
56  if (!shader_found)
57  throw std::runtime_error("Fragment shader not loaded");
58 
59  bindAttributeLocation("vertex", 0);
60  bindAttributeLocation("normal", 1);
61  bindAttributeLocation("axiscolor", 2);
62 
63  link();
64 
65  bind();
66  locMatProj = uniformLocation("matProj");
67  locMatModel = uniformLocation("matModel");
68  locMatObject = uniformLocation("matObject");
69  locLightPos1 = uniformLocation("lightPos1");
70  locColor = uniformLocation("color");
71  ambient = uniformLocation("ambient");
72  eye = uniformLocation("eye");
73  locAxis = uniformLocation("axis");
74  release();
75 }

References ambient, doInit, eye, locAxis, locColor, locLightPos1, locMatModel, locMatObject, and locMatProj.

Referenced by GUI::RealSpace::Canvas::paintGL().

◆ needsInit()

void GUI::RealSpace::Program::needsInit ( )
private

Definition at line 38 of file program.cpp.

39 {
40  doInit = true;
41 }

References doInit.

Referenced by Program(), and GUI::RealSpace::Canvas::setProgram().

◆ set() [1/3]

void GUI::RealSpace::Program::set ( Camera const &  camera)
private

Definition at line 77 of file program.cpp.

78 {
79  setUniformValue(ambient, AMBIENT);
80  setUniformValue(locMatProj, camera.matProj);
81  setUniformValue(locMatModel, camera.matModel);
82  setUniformValue(locLightPos1, camera.lightPosRotated1);
83  setUniformValue(eye, camera.getPos().eye);
84 }
static constexpr float AMBIENT
Definition: program.cpp:26

References AMBIENT, ambient, GUI::RealSpace::Camera::Position::eye, eye, GUI::RealSpace::Camera::getPos(), GUI::RealSpace::Camera::lightPosRotated1, locLightPos1, locMatModel, locMatProj, GUI::RealSpace::Camera::matModel, and GUI::RealSpace::Camera::matProj.

Referenced by GUI::RealSpace::Canvas::draw(), and GUI::RealSpace::Canvas::paintGL().

Here is the call graph for this function:

◆ set() [2/3]

void GUI::RealSpace::Program::set ( QColor const &  color)
private

Definition at line 86 of file program.cpp.

87 {
88  setUniformValue(locColor, color);
89 }

References locColor.

◆ set() [3/3]

void GUI::RealSpace::Program::set ( QMatrix4x4 const &  mat)
private

Definition at line 91 of file program.cpp.

92 {
93  setUniformValue(locMatObject, mat);
94 }

References locMatObject.

◆ setAxis()

void GUI::RealSpace::Program::setAxis ( bool const &  axis_)
private

Definition at line 101 of file program.cpp.

102 {
103  setUniformValue(locAxis, axis_);
104 }

References locAxis.

Referenced by GUI::RealSpace::Canvas::paintGL().

◆ setMatModel()

void GUI::RealSpace::Program::setMatModel ( QMatrix4x4 const &  mat)
private

Definition at line 96 of file program.cpp.

97 {
98  setUniformValue(locMatModel, mat);
99 }

References locMatModel.

Referenced by GUI::RealSpace::Canvas::paintGL().

Friends And Related Function Documentation

◆ Canvas

friend class Canvas
friend

Definition at line 27 of file program.h.

Member Data Documentation

◆ ambient

int GUI::RealSpace::Program::ambient
private

Definition at line 44 of file program.h.

Referenced by init(), and set().

◆ doInit

bool GUI::RealSpace::Program::doInit
private

Definition at line 42 of file program.h.

Referenced by init(), and needsInit().

◆ eye

int GUI::RealSpace::Program::eye
private

Definition at line 44 of file program.h.

Referenced by init(), and set().

◆ locAxis

int GUI::RealSpace::Program::locAxis
private

Definition at line 45 of file program.h.

Referenced by init(), and setAxis().

◆ locColor

int GUI::RealSpace::Program::locColor
private

Definition at line 44 of file program.h.

Referenced by init(), and set().

◆ locLightPos1

int GUI::RealSpace::Program::locLightPos1
private

Definition at line 44 of file program.h.

Referenced by init(), and set().

◆ locMatModel

int GUI::RealSpace::Program::locMatModel
private

Definition at line 43 of file program.h.

Referenced by init(), set(), and setMatModel().

◆ locMatObject

int GUI::RealSpace::Program::locMatObject
private

Definition at line 43 of file program.h.

Referenced by init(), and set().

◆ locMatProj

int GUI::RealSpace::Program::locMatProj
private

Definition at line 43 of file program.h.

Referenced by init(), and set().


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