17#ifndef __gui_projection_h__
18#define __gui_projection_h__
73 float depth_of (
const Eigen::Vector3f& x)
const {
74 float d =
MVP(2,0)*x[0] +
MVP(2,1)*x[1] +
MVP(2,2)*x[2] +
MVP(2,3);
75 if (
MVP(3,2)) d /=
MVP(3,0)*x[0] +
MVP(3,1)*x[1] +
MVP(3,2)*x[2] +
MVP(3,3);
81 MVP(0,0)*x[0] +
MVP(0,1)*x[1] +
MVP(0,2)*x[2] +
MVP(0,3),
82 MVP(1,0)*x[0] +
MVP(1,1)*x[1] +
MVP(1,2)*x[2] +
MVP(1,3),
83 MVP(2,0)*x[0] +
MVP(2,1)*x[1] +
MVP(2,2)*x[2] +
MVP(2,3));
85 S /=
MVP(3,0)*x[0] +
MVP(3,1)*x[1] +
MVP(3,2)*x[2] +
MVP(3,3);
93 MVP(0,0)*dir[0] +
MVP(0,1)*dir[1] +
MVP(0,2)*dir[2],
94 MVP(1,0)*dir[0] +
MVP(1,1)*dir[1] +
MVP(1,2)*dir[2],
95 MVP(2,0)*dir[0] +
MVP(2,1)*dir[1] +
MVP(2,2)*dir[2]);
121 Eigen::Vector3f
screen_to_model (
const Eigen::Vector3f& x,
const Eigen::Vector3f& depth)
const {
129 Eigen::Vector3f
screen_to_model (
const QPoint& x,
const Eigen::Vector3f& depth)
const {
134 return Eigen::Vector3f (
iMVP(0,2),
iMVP(1,2),
iMVP(2,2)).normalized().eval();
185#if QT_VERSION >= 0x050100
187 int m = frame.window()->devicePixelRatio();
207 void render_text_align (
int x,
int y,
const std::string& text,
int halign = 0,
int valign = 0)
const {
208 QString s (
qstr(text));
209 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
215 if (halign == 0) x -= w/2;
216 else if (halign > 0) x -= w;
217 if (valign == 0) y -= h/2;
218 else if (valign > 0) y -= h;
223 QString s (
qstr(text));
228 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
243 void render_text (
const std::string& text,
int position,
int line = 0)
const {
244 QString s (
qstr(text));
247 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
278 assert (shader_program != 0);
279 gl::UniformMatrix4fv (gl::GetUniformLocation (shader_program,
"MVP"), 1, gl::FALSE_,
modelview_projection());
void render(const std::string &text, int x, int y) const
void start(int width, int height, float red, float green, float blue) const
const QFontMetrics metric
Eigen::Vector3f screen_to_model(const QPoint &x, const Eigen::Vector3f &depth) const
Eigen::Vector3f screen_normal() const
float depth_of(const Eigen::Vector3f &x) const
void set_viewport(int x, int y, int w, int h)
Eigen::Vector3f screen_to_model(const Eigen::Vector3f &x, float depth) const
Eigen::Vector3f screen_to_model_direction(const QPoint &dx, const Eigen::Vector3f &x) const
Eigen::Vector3f screen_to_model(const Eigen::Vector3f &x, const Eigen::Vector3f &depth) const
Eigen::Vector3f screen_to_model(const QPoint &x, float depth) const
Eigen::Vector3f model_to_screen(const Eigen::Vector3f &x) const
Eigen::Vector3f screen_to_model_direction(const Eigen::Vector3f &dx, float x) const
Eigen::Vector3f screen_to_model_direction(const Eigen::Vector3f &dx, const Eigen::Vector3f &x) const
Eigen::Vector3f model_to_screen_direction(const Eigen::Vector3f &dir) const
Eigen::Vector3f screen_to_model(const Eigen::Vector3f &x) const
Eigen::Vector3f screen_to_model_direction(const QPoint &dx, float x) const
void set(const GL::mat4 &modelview, const GL::mat4 &projection)
Eigen::Vector3f screen_to_model(float x, float y, float depth) const
Eigen::Vector3f screen_to_model_direction(float x, float y, float depth) const
void render_text_align(int x, int y, const std::string &text, int halign=0, int valign=0) const
std::shared_ptr< Crosshair > crosshair
void render_text(const std::string &text, int position, int line=0) const
void draw_orientation_labels() const
void render_text(int x, int y, const std::string &text) const
const GL::mat4 & modelview_inverse() const
void done_render_text() const
void render_text_inset(int x, int y, const std::string &text, int inset=-1) const
void set_viewport(const QWidget &) const
void set(GL::Shader::Program &shader_program) const
const GL::mat4 & modelview_projection() const
const GL::mat4 & modelview() const
void render_crosshairs(const Eigen::Vector3f &focus) const
const GL::mat4 & modelview_projection_inverse() const
const GL::mat4 & projection() const
void setup_render_text(float red=1.0, float green=1.0, float blue=0.0) const
const GL::mat4 & projection_inverse() const
void set_viewport(const QWidget &frame, int x, int y, int w, int h)
Projection(GL::Area *parent, const GL::Font &font)
QString qstr(const std::string &s)