From 26cacb9de95e534bd842af05f55216a5bf8dae9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pe=C3=B1aranda?= Date: Fri, 21 Jun 2013 14:48:57 -0300 Subject: [PATCH] unhide option to control phi_max automatically --- openglcanvas.cpp | 41 ++++++------- openglcanvas.h | 4 ++ panowindow1.ui | 147 +++++++++++++++++++++++++++++------------------ 3 files changed, 116 insertions(+), 76 deletions(-) diff --git a/openglcanvas.cpp b/openglcanvas.cpp index c3e8d24..e0c4ba2 100644 --- a/openglcanvas.cpp +++ b/openglcanvas.cpp @@ -37,7 +37,7 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) : scale = 1.0f; center_lambda = 0.f; center_phi = 0.f; - fov_scale_relation = "Square Root"; + fov_scale_relation = "Naive"; visualization = "Perspective"; auto_fov_max=false; @@ -83,17 +83,15 @@ void OpenGLCanvas::change_fov(double f){ } +void OpenGLCanvas::automaxbutton(bool autovalue){ + auto_fov_max=autovalue; +} + void OpenGLCanvas::change_fov(int new_fov){ - if(new_fov<=360&&new_fov>=1) - change_fov((double)new_fov); - if(auto_fov_max){ - if(new_fov<60) - change_fov_max(60); - else - if(new_fov>180) - change_fov_max(1); - else - change_fov_max(90-new_fov/2); + if(new_fov<=360&&new_fov>=1){ + change_fov((double)new_fov); + if(auto_fov_max) + change_fov_max(compute_auto_fov_max(new_fov)); } } @@ -543,6 +541,16 @@ void OpenGLCanvas::define_triangle_indices(unsigned int * indices, int m, int n) } +// This function computes a new value of the maximum fov and must be called +// when the fov is changed and the auto setting is enabled. +int OpenGLCanvas::compute_auto_fov_max(int new_fov){ + if(new_fov<60) + return 60; + if(new_fov>180) + return 1; + //if(new_fov>60) + return (90-new_fov/2); +} void OpenGLCanvas::resizeGL(int w, int h){ if(w>h) @@ -666,15 +674,8 @@ void OpenGLCanvas::wheelEvent(QWheelEvent *event){ }else{ int new_fov=fov+event->delta()/30; change_fov((double)new_fov); - if(auto_fov_max){ - if(new_fov<60) - change_fov_max(60); - else - if(new_fov>180) - change_fov_max(1); - else - change_fov_max(90-new_fov/2); - } + if(auto_fov_max) + change_fov_max(compute_auto_fov_max(new_fov)); } } } diff --git a/openglcanvas.h b/openglcanvas.h index ee084a8..e614574 100644 --- a/openglcanvas.h +++ b/openglcanvas.h @@ -32,6 +32,9 @@ protected: float calculate_extent(float fov_rads); void define_triangle_indices(unsigned int * indices, int m, int n); +private: + int compute_auto_fov_max(int); + char *textFileRead(char *fn); void setShaders(); void mousePressEvent(QMouseEvent *event); @@ -44,6 +47,7 @@ signals: void max_fov_changed(int new_max_fov); public slots: + void automaxbutton(bool); void change_fov(double f); void change_fov(int new_fov); void change_fov_max(int new_fov_max); diff --git a/panowindow1.ui b/panowindow1.ui index fbfa7a3..051fa5c 100644 --- a/panowindow1.ui +++ b/panowindow1.ui @@ -14,7 +14,9 @@ Panoramic - + + + @@ -24,7 +26,7 @@ - + Re-center @@ -38,7 +40,7 @@ - + @@ -54,13 +56,6 @@ - - - - FOV max - - - @@ -71,12 +66,12 @@ - Square Root + Naive - Naive + Square Root @@ -101,7 +96,7 @@ - + 1 @@ -123,33 +118,14 @@ - - - - - Perspective - - - - - 3D Sphere - - - - - Equi-Rectangular - - - - - + Input Image - + QFrame::NoFrame @@ -159,14 +135,14 @@ - + Close - + 1 @@ -182,7 +158,7 @@ - + QFrame::NoFrame @@ -192,13 +168,55 @@ - + FOV + + + + + Perspective + + + + + 3D Sphere + + + + + Equi-Rectangular + + + + + + + + FOV max + + + + + + + true + + + + 0 + 0 + + + + Auto FOV max + + + @@ -221,6 +239,7 @@ change_fov_max(int) change_fov(int) re_center() + automaxbutton(bool) @@ -233,8 +252,8 @@ close() - 596 - 409 + 640 + 490 629 @@ -269,8 +288,8 @@ 106 - 496 - 123 + 492 + 132 @@ -281,8 +300,8 @@ change_input_image() - 566 - 258 + 640 + 457 247 @@ -329,8 +348,8 @@ re_center() - 569 - 444 + 640 + 424 250 @@ -345,8 +364,8 @@ change_fov_max(int) - 512 - 363 + 546 + 391 250 @@ -381,8 +400,8 @@ 245 - 606 - 380 + 629 + 236 @@ -397,8 +416,8 @@ 248 - 532 - 380 + 555 + 236 @@ -413,8 +432,8 @@ 249 - 606 - 197 + 629 + 236 @@ -429,8 +448,24 @@ 249 - 532 - 197 + 555 + 236 + + + + + automax + toggled(bool) + GLCanvas + automaxbutton(bool) + + + 504 + 174 + + + 454 + 172 -- GitLab