diff --git a/openglcanvas.cpp b/openglcanvas.cpp index da7b7b4d7fbc3704f7e786887f6a1c322a998c08..a4544c158cad84f10009dc2ff4e7267a2ab219ca 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 0ba1f5dbb68e543ed1e3dcb51b2fe6e01c6aa33c..ac854b0461b2b359ddaee4889403a9a231c43a56 100644 --- a/openglcanvas.h +++ b/openglcanvas.h @@ -64,6 +64,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); @@ -74,6 +75,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 96a765677db817a13ce0dd225516972a8ee52158..a1f566e2ab7d0d59f8347412fc1fba144d611f64 100644 --- a/panowindow1.ui +++ b/panowindow1.ui @@ -37,6 +37,11 @@ Square Root + + + Naive + + Linear