From 053e329f4c9e624cbf7b0a1759286fb49d537097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pe=C3=B1aranda?= Date: Tue, 22 Jan 2013 16:15:17 -0200 Subject: [PATCH] added variable fov_max --- openglcanvas.cpp | 56 +++++++++++++++++++++++++++++++++++++----------- openglcanvas.h | 2 ++ panowindow1.ui | 5 +++++ 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/openglcanvas.cpp b/openglcanvas.cpp index 27a6462..d752f25 100644 --- a/openglcanvas.cpp +++ b/openglcanvas.cpp @@ -27,6 +27,7 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) : { setFormat(QGL::DoubleBuffer | QGL::DepthBuffer); fov = 60.f; + fov_max = 60.f; // TODO: I only use floats here because Leo did... check scale = 1.0f; center_lambda = 0.f; center_phi = 0.f; @@ -37,6 +38,8 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) : time_timer.setInterval(0); connect(&time_timer, SIGNAL(timeout()), this, SLOT(slotTimer())); time_start = time_time.time(); + + fprintf(stderr,"scale=%f\nfov_max=%f\n",scale,fov_max); } void OpenGLCanvas::slotTimer(void) { @@ -45,23 +48,42 @@ void OpenGLCanvas::slotTimer(void) { void OpenGLCanvas::change_fov(double f){ - if (fov!=f && f>=1.f && f<=360.f) fov = f; - if (fov<60.f) scale = 1.f; - else if (fov>295.f) scale = 0.02f; + if (fov!=f && f>=1.f && f<=360.f) + fov=f; + 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 == "Square Root") scale = sqrt((300.f-fov)/240.f); - else if (fov_scale_relation == "Linear") scale = (300.f-fov)/240.f; - else if (fov_scale_relation == "Square Power") scale = powf((300.f-fov)/240.f,2); - else if (fov_scale_relation == "Cubic Power") scale = powf((300.f-fov)/240.f,3); - else if (fov_scale_relation == "Logarithm") scale = log(exp(1.f) + (1.f-exp(1.f))*(fov-60.f)/240.f); + if (fov_scale_relation == "Naive") + scale=fov_max/fov; + else if (fov_scale_relation == "Square Root") + scale=sqrt((360.f-fov_max-fov)/(360.-2*fov_max)); + else if (fov_scale_relation == "Linear") + scale=(360.f-fov_max-fov)/(360.-2*fov_max); + else if (fov_scale_relation == "Square Power") + scale=powf((360.f-fov_max-fov)/(360.-2*fov_max),2); + else if (fov_scale_relation == "Cubic Power") + scale=powf((360.f-fov_max-fov)/(360.-2*fov_max),3); + else if (fov_scale_relation == "Logarithm") + scale=log(exp(1.f)+(1.f-exp(1.f))*(fov-fov_max)/(360.-2*fov_max)); } // scale = 0.3f; + fprintf(stderr,"scale=%f\nfov_max=%f\n",scale,fov_max); + updateGL(); } +void OpenGLCanvas::change_fov_max(double new_fov_max){ + fov_max=new_fov_max; + // TODO: change also the scale + fprintf(stderr,"scale=%f\nfov_max=%f\n",scale,fov_max); + updateGL(); +} + //void OpenGLCanvas::change_scale(double s){ // if (scale!=s && s>=0.0 && s<=1.0) scale = s; @@ -93,12 +115,20 @@ void OpenGLCanvas::change_fov_scale_relation(QString name){ if (fov<60.f) scale = 1.f; else if (fov>295.f) scale = 0.01f; else{ - if (fov_scale_relation == "Square Root") scale = sqrt((300.f-fov)/240.f); - else if (fov_scale_relation == "Linear") scale = (300.f-fov)/240.f; - else if (fov_scale_relation == "Square Power") scale = powf((300.f-fov)/240.f,2); - else if (fov_scale_relation == "Cubic Power") scale = powf((300.f-fov)/240.f,3); - else if (fov_scale_relation == "Logarithm") scale = log(exp(1.f) + (1.f-exp(1.f))*(fov-60.f)/240.f); + if (fov_scale_relation == "Naive") + scale=fov_max/fov; + else if (fov_scale_relation == "Square Root") + scale=sqrt((360.f-fov_max-fov)/(360.-2*fov_max)); + else if (fov_scale_relation == "Linear") + scale=(360.f-fov_max-fov)/(360.-2*fov_max); + else if (fov_scale_relation == "Square Power") + scale=powf((360.f-fov_max-fov)/(360.-2*fov_max),2); + else if (fov_scale_relation == "Cubic Power") + scale=powf((360.f-fov_max-fov)/(360.-2*fov_max),3); + else if (fov_scale_relation == "Logarithm") + scale=log(exp(1.f)+(1.f-exp(1.f))*(fov-fov_max)/(360.-2*fov_max)); } + fprintf(stderr,"scale=%f\nfov_max=%f\n",scale,fov_max); updateGL(); } diff --git a/openglcanvas.h b/openglcanvas.h index 88dced1..6ba0507 100644 --- a/openglcanvas.h +++ b/openglcanvas.h @@ -61,6 +61,7 @@ signals: public slots: void change_fov(double f); + void change_fov_max(double new_fov_max); // void change_scale(double s); void change_center_lambda(double lambda); void change_center_phi(double phi); @@ -71,6 +72,7 @@ public slots: private: double fov; + double fov_max; // the \phi_{max} on the technote double scale; double center_lambda; double center_phi; diff --git a/panowindow1.ui b/panowindow1.ui index df1f5d3..7a9cb24 100644 --- a/panowindow1.ui +++ b/panowindow1.ui @@ -37,6 +37,11 @@ Square Root + + + Naive + + Linear -- GitLab