diff --git a/openglcanvas.cpp b/openglcanvas.cpp index dd34ee0af6353bf31563b52091b7731f4d84e5cc..1a111f83c5e0ed9fb76d0cab44dcb819e5dc3c5c 100644 --- a/openglcanvas.cpp +++ b/openglcanvas.cpp @@ -1,6 +1,6 @@ #include #ifdef NEEDGLEE -#include "GLee.h" + #include "GLee.h" #endif #include "openglcanvas.h" #include @@ -34,7 +34,6 @@ OpenGLCanvas::OpenGLCanvas(QWidget *parent) : time_timer.setInterval(0); connect(&time_timer, SIGNAL(timeout()), this, SLOT(slotTimer())); time_start = time_time.time(); - } void OpenGLCanvas::slotTimer(void) { @@ -104,14 +103,27 @@ void OpenGLCanvas::change_fov_scale_relation(QString name){ void OpenGLCanvas::change_visualization(QString name){ visualization = name; - updateGL(); + updateGL(); } +void OpenGLCanvas::load_image(const char *new_image){ + const char * const progname=(char*)(PROGNAME); + int textureSize=getTextureSize(progname,new_image); + unsigned char * textureBytes=(unsigned char*)malloc(textureSize); + int width,height; + readTextureBytes(progname,new_image,textureBytes,&width,&height); + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + GLuint tex; + glGenTextures(1,&tex); + glBindTexture(GL_TEXTURE_2D,tex); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D,0, GL_RGB, width,height,0,GL_RGB,GL_UNSIGNED_BYTE,textureBytes); +} + void OpenGLCanvas::change_input_image(){ - QString path = QFileDialog::getExistingDirectory(this,tr("Choose directory"),directory.path()); - if(path.isNull()==false) - directory.setPath(path); + load_image(QFileDialog::getOpenFileName(this,tr("Choose Panorama File")).toStdString().c_str()); updateGL(); } @@ -137,27 +149,17 @@ void OpenGLCanvas::initializeGL(){ #endif fprintf(stderr,"progname=%s\n",progname); - fprintf(stderr,"image=%s\n",input_image); - // exit if the input file does not exist + fprintf(stderr,"default image=%s\n",input_image); + // what to do if the input file does not exist struct stat testbuf; if(stat(input_image,&testbuf)){ - fprintf(stderr,"the file does not exist!\n"); + fprintf(stderr,"the default image file does not exist!\n"); free(input_image); - exit(-1); + load_image(QFileDialog::getOpenFileName(this,tr("Choose Panorama File")).toStdString().c_str()); + }else{ + load_image(input_image); } - int textureSize = getTextureSize(progname,input_image); - unsigned char * textureBytes = (unsigned char*)malloc(textureSize); - int width, height; - readTextureBytes(progname, input_image, textureBytes, &width, &height); - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - GLuint tex; - glGenTextures(1,&tex); - glBindTexture(GL_TEXTURE_2D, tex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D,0, GL_RGB, width,height,0,GL_RGB,GL_UNSIGNED_BYTE,textureBytes); - // mesh resolution int m,n; m = n = 100; diff --git a/openglcanvas.h b/openglcanvas.h index 7426b6b3dc79ff409e8fd1cf8c064a67df21d89c..3d3d25bc5149a01d25168c26e3d0ea5e1e640a3c 100644 --- a/openglcanvas.h +++ b/openglcanvas.h @@ -33,7 +33,7 @@ extern "C" { #include #endif -#include +#include #include class OpenGLCanvas : public QGLWidget @@ -43,6 +43,7 @@ public: explicit OpenGLCanvas(QWidget *parent = 0); protected: + void load_image(const char *new_image); void initializeGL(); void resizeGL(int w, int h); void paintGL(); @@ -76,7 +77,6 @@ private: double center_phi; QString fov_scale_relation; QString visualization; - QDir directory; Chronos time_time; QTimer time_timer; diff --git a/panowindow1.h b/panowindow1.h index 0cff4b6db5dcea5062d83710e56e91b9e33c47d1..05f2b800ab7dbdd6ee9e28d715fa3f887efaf925 100644 --- a/panowindow1.h +++ b/panowindow1.h @@ -18,5 +18,4 @@ public: private: Ui::PanoWindow1 *ui; }; - #endif // PANOWINDOW1_H diff --git a/panowindow1.ui b/panowindow1.ui index 744013851d4794a936c29ed80bf61cb523d6ea07..df1f5d37dcf4a9a0244a08a0bf3f4173f704b0c3 100644 --- a/panowindow1.ui +++ b/panowindow1.ui @@ -14,7 +14,7 @@ PanoWindow1 - + @@ -115,7 +115,7 @@ - + @@ -134,7 +134,7 @@ - + @@ -153,7 +153,14 @@ - + + + + Input Image + + + + Qt::Vertical @@ -166,7 +173,7 @@ - + Close @@ -180,7 +187,7 @@ OpenGLCanvas QWidget -
openglcanvas.h
+
openglcanvas.h
1 change_fov(double) @@ -290,5 +297,21 @@ + + chooseFile + clicked() + GLCanvas + change_input_image() + + + 566 + 258 + + + 247 + 249 + + +