From d2c03e503556b0cee3894632fd033ccfb11d5f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pe=C3=B1aranda?= Date: Fri, 6 Sep 2013 15:11:18 -0300 Subject: [PATCH] added "shrink all" button to the interface --- openglcanvas.cpp | 109 +++++++++++++++++------------------------------ openglcanvas.h | 2 + panowindow1.ui | 46 +++++++++++++++----- 3 files changed, 77 insertions(+), 80 deletions(-) diff --git a/openglcanvas.cpp b/openglcanvas.cpp index 6b69bd3..805aa58 100644 --- a/openglcanvas.cpp +++ b/openglcanvas.cpp @@ -58,29 +58,7 @@ void OpenGLCanvas::change_fov(double f){ if (fov!=f && f>=1.f && f<=360.f) fov=f; - if (shrink_for_all || visualization=="Moebius" || visualization=="3D Sphere"){ - if (fov<=fov_max) - scale=1.f; - //else if (fov>295.f) - // scale = 0.02f; // TODO: check this value wrt fov_max - else { - if (fov_scale_relation == "Naive") - scale=fov_max/fov; - else if (fov_scale_relation == "Square Root") - scale=sqrtf((360.f-fov_max-fov)/(360.-2*fov_max)); - else if (fov_scale_relation == "Linear") - scale=(360.f-fov_max-fov)/(360.f-2.f*fov_max); - else if (fov_scale_relation == "Square Power") - scale=powf((360.f-fov_max-fov)/(360.f-2.f*fov_max),2.f); - else if (fov_scale_relation == "Cubic Power") - scale=powf((360.f-fov_max-fov)/(360.f-2.f*fov_max),3.f); - else if (fov_scale_relation == "Logarithm") - scale=logf(expf(1.f)+(1.f-expf(1.f))*(fov-fov_max)/(360.f-2.f*fov_max)); - } - }else{ - scale=1.f; - } - + compute_scale(); // scale = 0.3f; fprintf(stderr,"change fov, fov=%f, fov_max=%f, scale=%f\n",fov,fov_max,scale); @@ -95,6 +73,12 @@ void OpenGLCanvas::automaxbutton(bool autovalue){ change_fov_max(compute_auto_fov_max(fov)); } +void OpenGLCanvas::shrinkallbutton(bool shrinkvalue){ + shrink_for_all=shrinkvalue; + compute_scale(); + updateGL(); +} + void OpenGLCanvas::change_fov(int new_fov){ if(new_fov<=360&&new_fov>=1){ change_fov((double)new_fov); @@ -106,28 +90,7 @@ void OpenGLCanvas::change_fov(int new_fov){ void OpenGLCanvas::change_fov_max(int new_fov_max){ if(new_fov_max<=360.f&&new_fov_max>=1) fov_max=(double)new_fov_max; - if (shrink_for_all || visualization=="Moebius" || visualization=="3D Sphere"){ - if (fov<=fov_max) - scale=1.f; - //else if (fov>295.f) - // scale = 0.02f; // TODO: check this value wrt fov_max - else { - if (fov_scale_relation == "Naive") - scale=fov_max/fov; - else if (fov_scale_relation == "Square Root") - scale=sqrtf((360.f-fov_max-fov)/(360.f-2.f*fov_max)); - else if (fov_scale_relation == "Linear") - scale=(360.f-fov_max-fov)/(360.f-2.f*fov_max); - else if (fov_scale_relation == "Square Power") - scale=powf((360.f-fov_max-fov)/(360.f-2.f*fov_max),2.f); - else if (fov_scale_relation == "Cubic Power") - scale=powf((360.f-fov_max-fov)/(360.f-2.f*fov_max),3.f); - else if (fov_scale_relation == "Logarithm") - scale=logf(expf(1.f)+(1.f-expf(1.f))*(fov-fov_max)/(360.f-2.f*fov_max)); - } - }else{ - scale=1.f; - } + compute_scale(); fprintf(stderr,"change fov_max, fov=%f, fov_max=%f, new scale=%f\n",fov,fov_max,scale); emit max_fov_changed((int)fov_max); updateGL(); @@ -167,26 +130,7 @@ void OpenGLCanvas::re_center(){ void OpenGLCanvas::change_fov_scale_relation(QString name){ fov_scale_relation = name; - if (shrink_for_all || visualization=="Moebius" || visualization=="3D Sphere"){ - if (fov295.f) scale = 0.01f; - else{ - if (fov_scale_relation == "Naive") - scale=fov_max/fov; - else if (fov_scale_relation == "Square Root") - scale=sqrtf((360.f-fov_max-fov)/(360.f-2.f*fov_max)); - else if (fov_scale_relation == "Linear") - scale=(360.f-fov_max-fov)/(360.f-2.f*fov_max); - else if (fov_scale_relation == "Square Power") - scale=powf((360.f-fov_max-fov)/(360.f-2.f*fov_max),2.f); - else if (fov_scale_relation == "Cubic Power") - scale=powf((360.f-fov_max-fov)/(360.f-2.f*fov_max),3.f); - else if (fov_scale_relation == "Logarithm") - scale=logf(expf(1.f)+(1.f-expf(1.f))*(fov-fov_max)/(360.f-2.f*fov_max)); - } - }else{ - scale=1.f; - } + compute_scale(); fprintf(stderr,"changed scale relation, scale=%f, fov_max=%f\n",scale,fov_max); updateGL(); @@ -194,8 +138,7 @@ void OpenGLCanvas::change_fov_scale_relation(QString name){ void OpenGLCanvas::change_visualization(QString name){ visualization=name; - if(!shrink_for_all && visualization!="Moebius" && visualization!="3D Sphere") - scale=1.f; + compute_scale(); updateGL(); } @@ -606,12 +549,12 @@ float OpenGLCanvas::calculate_extent(float fov_rads){ // Write now it's olny showing the entire panorama intead of // the corresponging FOV. } - if (visualization=="Zorin-Barr"){ + else if (visualization=="Zorin-Barr"){ // TODO: check whether this is correct u=x/(-z); v=y/(-z); } - if (visualization=="Orthographic"){ + else if (visualization=="Orthographic"){ if(z<0.f){ u=x; v=y; @@ -653,6 +596,34 @@ int OpenGLCanvas::compute_auto_fov_max(int new_fov){ return (90-new_fov/2); } +// This function computes the scale, in function of the projection method, +// the fov/scale ratio and the value of shrink_for_all. +void OpenGLCanvas::compute_scale(){ + if (shrink_for_all || visualization=="Moebius" || visualization=="3D Sphere"){ + if (fov<=fov_max){ + scale=1.f; + //else if (fov>295.f) + // scale = 0.02f; // TODO: check this value wrt fov_max + }else{ + if(fov_scale_relation == "Naive") + scale=fov_max/fov; + else if(fov_scale_relation == "Square Root") + scale=sqrtf((360.f-fov_max-fov)/(360.f-2.f*fov_max)); + else if(fov_scale_relation == "Linear") + scale=(360.f-fov_max-fov)/(360.f-2.f*fov_max); + else if(fov_scale_relation == "Square Power") + scale=powf((360.f-fov_max-fov)/(360.f-2.f*fov_max),2.f); + else if(fov_scale_relation == "Cubic Power") + scale=powf((360.f-fov_max-fov)/(360.f-2.f*fov_max),3.f); + else if(fov_scale_relation == "Logarithm") + scale=logf(expf(1.f)+(1.f-expf(1.f))*(fov-fov_max)/(360.f-2.f*fov_max)); + } + }else{ + scale=1.f; + } +} + + void OpenGLCanvas::resizeGL(int w, int h){ if(w>h) glViewport(0,(h-w)/2,w,w); diff --git a/openglcanvas.h b/openglcanvas.h index 7470e4e..f3d7b56 100644 --- a/openglcanvas.h +++ b/openglcanvas.h @@ -34,6 +34,7 @@ protected: private: int compute_auto_fov_max(int); + void compute_scale(); char *textFileRead(char *fn); void setShaders(); @@ -48,6 +49,7 @@ signals: public slots: void automaxbutton(bool); + void shrinkallbutton(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 e2164df..0fd6e7d 100644 --- a/panowindow1.ui +++ b/panowindow1.ui @@ -26,7 +26,7 @@ - + Re-center @@ -40,7 +40,7 @@ - + @@ -96,7 +96,7 @@ - + 1 @@ -118,14 +118,14 @@ - + Input Image - + QFrame::NoFrame @@ -135,14 +135,14 @@ - + Close - + 1 @@ -158,7 +158,7 @@ - + QFrame::NoFrame @@ -168,7 +168,7 @@ - + FOV @@ -214,14 +214,14 @@ - + FOV max - + true @@ -237,6 +237,13 @@ + + + + Shrink all + + + @@ -260,6 +267,7 @@ change_fov(int) re_center() automaxbutton(bool) + shrinkallbutton(bool) @@ -489,5 +497,21 @@ + + shrinkAll + toggled(bool) + GLCanvas + shrinkallbutton(bool) + + + 540 + 185 + + + 247 + 249 + + + -- GitLab