17#ifndef __gui_mrview_mode_base_h__
18#define __gui_mrview_mode_base_h__
26#define ROTATION_INC 0.002
27#define MOVE_IN_OUT_FOV_MULTIPLIER 1.0e-3f
61 virtual void update_base_mode_gui(
const Base&) {}
62 virtual void update_slice_mode_gui(
const Slice&) {}
63 virtual void update_ortho_mode_gui(
const Ortho&) {}
64 virtual void update_volume_mode_gui(
const Volume&) {}
65 virtual void update_lightbox_mode_gui(
const LightBox&) {}
70 class Base :
public QObject
79 QList<ImageBase*> overlays_for_3D;
83 virtual void mouse_press_event ();
84 virtual void mouse_release_event ();
85 virtual void reset_event ();
86 virtual void slice_move_event (
float x);
87 virtual void set_focus_event ();
88 virtual void contrast_event ();
89 virtual void pan_event ();
90 virtual void panthrough_event ();
91 virtual void tilt_event ();
92 virtual void rotate_event ();
93 virtual void image_changed_event () {}
94 virtual const Projection* get_current_projection()
const;
95 virtual void reset_windowing ();
97 virtual void request_update_mode_gui(
ModeGuiVisitor& visitor)
const {
98 visitor.update_base_mode_gui(*
this); }
102 const Image* image ()
const {
return window().
image(); }
103 const Eigen::Vector3f& focus ()
const {
return window().
focus(); }
104 const Eigen::Vector3f& target ()
const {
return window().
target(); }
105 float FOV ()
const {
return window().
FOV(); }
106 int plane ()
const {
return window().
plane(); }
107 Eigen::Quaternionf orientation ()
const {
108 if (snap_to_image()) {
110 return Eigen::Quaternionf (image()->header().transform().rotation().cast<float>());
112 return Eigen::Quaternionf::Identity();
117 int width ()
const {
return glarea()->width(); }
118 int height ()
const {
return glarea()->height(); }
119 bool snap_to_image ()
const {
return window().
snap_to_image(); }
124 Eigen::Vector3f in_plane_target = projection.
model_to_screen (target());
125 in_plane_target[2] = projection.
depth_of (focus());
128 void set_visible (
bool v) {
if(
visible != v) {
visible = v; updateGL(); } }
129 void set_focus (
const Eigen::Vector3f& p) { window().
set_focus (p); }
130 void set_target (
const Eigen::Vector3f& p) { window().
set_target (p); }
132 void set_plane (
int p) { window().
set_plane (p); }
133 void set_orientation (
const Eigen::Quaternionf& V) { window().
set_orientation (V); }
134 void reset_orientation () {
136 set_orientation (Eigen::Quaternionf (image()->header().transform().rotation().cast<float>()));
138 set_orientation (Eigen::Quaternionf::Identity());
142 return reinterpret_cast <GL::Area*
> (window().glarea);
145 Eigen::Vector3f get_through_plane_translation (
float distance,
const ModelViewProjection& projection)
const {
152 Eigen::Vector3f get_through_plane_translation_FOV (
int increment,
const ModelViewProjection& projection) {
156 void render_tools (
const Projection& projection,
bool is_3D =
false,
int axis = 0,
int slice = 0) {
157 QList<QAction*> tools = window().
tools()->actions();
158 for (
int i = 0; i < tools.size(); ++i) {
159 Tool::Dock* dock =
dynamic_cast<Tool::__Action__*
>(tools[i])->dock;
175 Eigen::Vector3f voxel_at (
const Eigen::Vector3f& pos)
const {
176 if (!image())
return Eigen::Vector3f { NAN, NAN, NAN };
177 const Eigen::Vector3f result = image()->scanner2voxel().cast<
float>() * pos;
181 void draw_crosshairs (
const Projection& with_projection)
const {
182 if (window().show_crosshairs())
186 void draw_orientation_labels (
const Projection& with_projection)
const {
187 if (window().show_orientation_labels())
192 int slice ()
const {
return slice (plane()); }
194 void updateGL () { window().
updateGL(); }
218 class __Action__ :
public QAction
221 __Action__ (QActionGroup* parent,
222 const char*
const name,
223 const char*
const description,
225 QAction (
name, parent) {
227 setShortcut (tr (std::string (
"F"+
str (
index)).c_str()));
228 setStatusTip (tr (description));
231 virtual Base*
create()
const = 0;
237 template <
class T>
class Action :
public __Action__
241 const char*
const name,
242 const char*
const description,
244 __Action__ (parent,
name, description,
index) { }
virtual Base * create() const
Action(QActionGroup *parent, const char *const name, const char *const description, int index)
void slice_move_event(const ModelViewProjection &proj, float x)
void set_focus_event(const ModelViewProjection &proj)
GL::mat4 adjust_projection_matrix(const GL::mat4 &Q) const
GL::mat4 adjust_projection_matrix(const GL::mat4 &Q, int proj) const
void pan_event(const ModelViewProjection &proj)
void panthrough_event(const ModelViewProjection &proj)
void tilt_event(const ModelViewProjection &proj)
void rotate_event(const ModelViewProjection &proj)
const Eigen::Vector3f & focus() const
const Image * image() const
bool snap_to_image() const
void set_target(const Eigen::Vector3f &p)
QActionGroup * tools() const
const Eigen::Quaternionf & orientation() const
const Eigen::Vector3f & target() const
void set_FOV(float value)
void set_orientation(const Eigen::Quaternionf &V)
void set_focus(const Eigen::Vector3f &p)
Eigen::Vector3f screen_normal() const
float depth_of(const Eigen::Vector3f &x) const
Eigen::Vector3f model_to_screen(const Eigen::Vector3f &x) const
Eigen::Vector3f screen_to_model(float x, float y, float depth) const
void draw_orientation_labels() const
void render_crosshairs(const Eigen::Vector3f &focus) const
constexpr I round(const T x)
VectorType::Scalar value(const VectorType &coefs, typename VectorType::Scalar cos_elevation, typename VectorType::Scalar cos_azimuth, typename VectorType::Scalar sin_azimuth, int lmax)
void assert_context_is_current(QWidget *glarea=nullptr)
const int ShaderThreshold
const int ShaderTransparency
std::string str(const T &value, int precision=0)
#define MOVE_IN_OUT_FOV_MULTIPLIER