17#ifndef __gui_dwi_renderer_h__
18#define __gui_dwi_renderer_h__
21#include <Eigen/Eigenvalues>
49 using matrix_t = Eigen::MatrixXf;
50 using vector_t = Eigen::VectorXf;
51 using tensor_t = Eigen::Matrix3f;
72 bool use_lighting,
bool color_by_direction,
bool hide_neg_lobes,
bool orthographic =
false,
const GL::mat4* colour_relative_to_projection =
nullptr);
74 void draw (
const Eigen::Vector3f& origin,
int buffer_ID = 0)
const {
76 gl::Uniform3fv (
origin_ID, 1, origin.data());
106 void start (
mode_t mode,
bool use_lighting,
bool colour_by_direction,
bool hide_neg_values,
bool orthographic,
bool colour_relative_to_projection);
118 gl::DrawElements (gl::TRIANGLES, num_indices, gl::UNSIGNED_INT, (
void*)0);
125 ModeBase (
Renderer& parent) : parent (parent) { }
126 virtual ~ModeBase() { }
128 virtual void initGL() = 0;
129 virtual void bind() = 0;
130 virtual void set_data (
const vector_t&,
int buffer_ID = 0)
const = 0;
131 virtual GLuint num_indices()
const = 0;
138 class SH :
public ModeBase
141 SH (
Renderer& parent) : ModeBase (parent), LOD (0) { }
144 void initGL()
override;
145 void bind()
override;
146 void set_data (
const vector_t& r_del_daz,
int buffer_ID = 0)
const override;
147 GLuint num_indices()
const override {
return half_sphere.num_indices; }
149 void update_mesh (
const size_t,
const int);
151 void compute_r_del_daz (matrix_t& r_del_daz,
const matrix_t&
SH)
const {
152 if (!
SH.rows() || !
SH.cols())
return;
153 assert (transform.rows());
154 r_del_daz.noalias() =
SH * transform.transpose();
157 void compute_r_del_daz (vector_t& r_del_daz,
const vector_t&
SH)
const {
158 if (!
SH.size())
return;
159 assert (transform.rows());
160 r_del_daz.noalias() = transform *
SH;
163 int get_LOD()
const {
return LOD; }
183 void initGL()
override;
184 void bind()
override;
185 void set_data (
const vector_t& data,
int buffer_ID = 0)
const override;
186 GLuint num_indices()
const override {
return half_sphere.num_indices; }
188 void update_mesh (
const size_t);
190 int get_LOD()
const {
return LOD; }
197 mutable Eigen::SelfAdjointEigenSolver<tensor_t> eig;
216 void set_data (
const vector_t&,
int buffer_ID = 0)
const override;
225 GLuint vertex_count, index_count;
void set_data(const vector_t &, int buffer_ID=0) const override
void update_mesh(const MR::DWI::Directions::Set &)
GLuint num_indices() const override
bool colour_relative_to_projection_
std::string vertex_shader_source() const
std::string fragment_shader_source() const
std::string geometry_shader_source() const
bool colour_by_direction_
void start(mode_t mode, bool use_lighting, bool colour_by_direction, bool hide_neg_values, bool orthographic, bool colour_relative_to_projection)
MR::GUI::DWI::Renderer::Dixel dixel
MR::GUI::DWI::Renderer::Shader shader
void set_colour(const QColor &c)
void set_mode(const mode_t i)
void start(const Projection &projection, const GL::Lighting &lighting, float scale, bool use_lighting, bool color_by_direction, bool hide_neg_lobes, bool orthographic=false, const GL::mat4 *colour_relative_to_projection=nullptr)
MR::GUI::DWI::Renderer::SH sh
void draw(const Eigen::Vector3f &origin, int buffer_ID=0) const
MR::GUI::DWI::Renderer::Tensor tensor
QColor get_colour() const
mat4 scale(float x, float y, float z)