From 5d488ffcd7441c4dfa3ff885b6b6f5e2ecef331c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pe=C3=B1aranda?= Date: Fri, 1 Mar 2013 16:20:44 -0300 Subject: [PATCH] hidden option to automatically compute fov_max activate with the option auto_max_fov=1 in ~/.panorc --- openglcanvas.cpp | 25 +++++++++++++++++++++---- openglcanvas.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/openglcanvas.cpp b/openglcanvas.cpp index 9d4dfbb..e032944 100644 --- a/openglcanvas.cpp +++ b/openglcanvas.cpp @@ -38,6 +38,7 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) : center_phi = 0.f; fov_scale_relation = "Square Root"; visualization = "Perspective"; + auto_fov_max=false; time_frames = 0; time_timer.setInterval(0); @@ -84,6 +85,15 @@ void OpenGLCanvas::change_fov(double f){ 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); + } } void OpenGLCanvas::change_fov_max(int new_fov_max){ @@ -185,7 +195,7 @@ void OpenGLCanvas::read_config_file(){ shader_dir[0]='\0'; input_image_file=(char*)malloc(512*sizeof(char)); input_image_file[0]='\0'; - char *max_fov_str=(char*)malloc(64*sizeof(char)); + char *read_line=(char*)malloc(64*sizeof(char)); struct stat testbuf; if(stat(filepath,&testbuf)){ fprintf(stderr,"~/.panorc does not exist\n"); @@ -217,11 +227,18 @@ void OpenGLCanvas::read_config_file(){ } // check for 'max_fov' option if(!strncmp(line,"max_fov=",8)){ - strcpy(max_fov_str,line+8); - max_fov_str[strlen(line)-9]='\0'; - fov_max=atof(max_fov_str); + strcpy(read_line,line+8); + read_line[strlen(line)-9]='\0'; + fov_max=atof(read_line); fprintf(stderr,"max_fov=%f\n",fov_max); } + // check for 'auto_max_fov' option + if(!strncmp(line,"auto_max_fov=",13)){ + strcpy(read_line,line+13); + read_line[strlen(line)-14]='\0'; + auto_fov_max=atof(read_line); + fprintf(stderr,"auto_max_fov=%d\n",auto_fov_max); + } } fclose(rcfile); } diff --git a/openglcanvas.h b/openglcanvas.h index c13215f..eefb5db 100644 --- a/openglcanvas.h +++ b/openglcanvas.h @@ -87,6 +87,7 @@ private: double center_phi; QString fov_scale_relation; QString visualization; + bool auto_fov_max; Chronos time_time; QTimer time_timer; -- GitLab