Developer documentation
Version 3.0.3-105-gd3941f44
render_frame.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __gui_dwi_render_frame_h__
18#define __gui_dwi_render_frame_h__
19
20#include "memory.h"
21#include "types.h"
22#include "dwi/directions/set.h"
23#include "gui/opengl/lighting.h"
24#include "gui/dwi/renderer.h"
25#include "gui/projection.h"
26#include "gui/opengl/gl.h"
27#include "gui/opengl/font.h"
29
30#define MAX_LOD 8
31
32namespace MR
33{
34 namespace GUI
35 {
36 namespace DWI
37 {
38
39 class RenderFrame : public GL::Area
40 { MEMALIGN(RenderFrame)
41 Q_OBJECT
42
43 using mode_t = Renderer::mode_t;
44
45 public:
46 RenderFrame (QWidget* parent);
48
50
51 void set (const Eigen::VectorXf& new_values) {
52 values = new_values;
54 update();
55 }
56
57 void set_rotation (const GL::mat4& rotation);
58
59 void set_mode (mode_t new_mode) {
60 mode = new_mode;
61 if (mode != mode_t::DIXEL && dirs)
62 delete dirs.release();
64 update();
65 }
66 void set_show_axes (bool yesno = true) {
67 show_axes = yesno;
68 update();
69 }
70 void set_hide_neg_values (bool yesno = true) {
71 hide_neg_values = yesno;
72 update();
73 }
74 void set_color_by_dir (bool yesno = true) {
75 color_by_dir = yesno;
76 update();
77 }
78 void set_use_lighting (bool yesno = true) {
79 use_lighting = yesno;
80 update();
81 }
82 void set_scale (float new_scale) {
83 scale = new_scale;
84 update();
85 }
86 void reset_scale () {
87 set_scale (NaN);
88 }
89 void reset_view ();
90 void set_lmax (int lmax) {
91 assert (mode == mode_t::SH);
92 if (lmax != lmax_computed)
94 lmax_computed = lmax;
95 update();
96 }
97 void set_LOD (int lod) {
98 assert (mode == mode_t::SH || mode == mode_t::TENSOR);
99 if (lod != lod_computed)
101 lod_computed = lod;
102 update();
103 }
104 void set_dixels (const MR::DWI::Directions::Set& directions) {
105 assert (mode == mode_t::DIXEL);
106 if (dirs)
107 delete dirs.release();
108 dirs.reset (new MR::DWI::Directions::Set (directions));
110 update();
111 }
113 assert (mode == mode_t::DIXEL);
114 if (dirs)
115 delete dirs.release();
117 update();
118 }
119 void set_text (const std::string& text_to_display) {
120 text = text_to_display;
121 update();
122 }
123
124 int get_LOD () const { return lod_computed; }
125 int get_lmax () const { return lmax_computed; }
126 float get_scale () const { return scale; }
127 mode_t get_mode() const { return mode; }
128 bool get_show_axes () const { return show_axes; }
129 bool get_hide_neg_lobes () const { return hide_neg_values; }
130 bool get_color_by_dir () const { return color_by_dir; }
131 bool get_use_lighting () const { return use_lighting; }
132 bool get_normalise () const { return normalise; }
133
134 void screenshot (int oversampling, const std::string& image_name);
135
136 protected:
139 mode_t mode;
141 std::unique_ptr<MR::DWI::Directions::Set> dirs;
142
143 QPoint last_pos;
146 Eigen::Quaternionf orientation;
147 Eigen::Vector3f focus;
148
149 std::string screenshot_name;
150 std::unique_ptr<QImage> pix;
151 std::unique_ptr<GLubyte[]> framebuffer;
152 int OS, OS_x, OS_y;
153
157
159 Eigen::VectorXf values;
160
161 std::string text;
162
163 protected:
164 virtual void initializeGL () override;
165 virtual void resizeGL (int w, int h) override;
166 virtual void paintGL () override;
167 void mousePressEvent (QMouseEvent* event) override;
168 void mouseMoveEvent (QMouseEvent* event) override;
169 void wheelEvent (QWheelEvent* event) override;
170
171 void snapshot ();
172 };
173
174
175 }
176 }
177}
178
179#endif
180
181
void screenshot(int oversampling, const std::string &image_name)
void mouseMoveEvent(QMouseEvent *event) override
bool get_use_lighting() const
Definition: render_frame.h:131
bool get_hide_neg_lobes() const
Definition: render_frame.h:129
void set_mode(mode_t new_mode)
Definition: render_frame.h:59
GL::Shader::Program axes_shader
Definition: render_frame.h:156
void set_dixels(const MR::DWI::Directions::Set &directions)
Definition: render_frame.h:104
void set_scale(float new_scale)
Definition: render_frame.h:82
RenderFrame(QWidget *parent)
std::unique_ptr< MR::DWI::Directions::Set > dirs
Definition: render_frame.h:141
void set_lmax(int lmax)
Definition: render_frame.h:90
void set_rotation(const GL::mat4 &rotation)
GL::VertexArrayObject axes_VAO
Definition: render_frame.h:155
void set_color_by_dir(bool yesno=true)
Definition: render_frame.h:74
std::unique_ptr< QImage > pix
Definition: render_frame.h:150
void set_use_lighting(bool yesno=true)
Definition: render_frame.h:78
Eigen::Quaternionf orientation
Definition: render_frame.h:146
void set_hide_neg_values(bool yesno=true)
Definition: render_frame.h:70
void set_show_axes(bool yesno=true)
Definition: render_frame.h:66
void set(const Eigen::VectorXf &new_values)
Definition: render_frame.h:51
GL::VertexBuffer axes_VB
Definition: render_frame.h:154
void wheelEvent(QWheelEvent *event) override
Eigen::VectorXf values
Definition: render_frame.h:159
GL::Lighting * lighting
Definition: render_frame.h:49
std::unique_ptr< GLubyte[]> framebuffer
Definition: render_frame.h:151
virtual void paintGL() override
void mousePressEvent(QMouseEvent *event) override
virtual void initializeGL() override
bool get_color_by_dir() const
Definition: render_frame.h:130
virtual void resizeGL(int w, int h) override
void set_text(const std::string &text_to_display)
Definition: render_frame.h:119
Definition: base.h:24
constexpr default_type NaN
Definition: types.h:230