diff --git a/openglcanvas.cpp b/openglcanvas.cpp
index d752f2533393638e446748880bdd66a8695dcf22..92ae9af74b59b69ec27d32c882af65180f0b44cb 100644
--- a/openglcanvas.cpp
+++ b/openglcanvas.cpp
@@ -476,7 +476,9 @@ int OpenGLCanvas::getTextureSize(const char * const progname, const char * textu
pnm_readpaminit(in_file,&inpam,sizeof(struct pam));
#endif
- int size = inpam.width*inpam.height*inpam.depth*inpam.bytes_per_sample;
+ image_size_x=inpam.width;
+ image_size_y=inpam.height;
+ int size = image_size_x*image_size_y*inpam.depth*inpam.bytes_per_sample;
pm_close(in_file);
//fprintf(stderr,"size=%d\n",size);
@@ -620,6 +622,22 @@ void OpenGLCanvas::setShaders() {
}
+void OpenGLCanvas::mousePressEvent(QMouseEvent *event){
+ lastPos=event->pos();
+ //fprintf(stderr,"mouse click\n");
+}
+
+void OpenGLCanvas::mouseMoveEvent(QMouseEvent *event){
+ // scroll with the left button
+ if(event->buttons()==Qt::LeftButton){
+ // compute the delta and move the image
+ center_lambda+=(event->x()-lastPos.x())*3.1415926f/image_size_x;
+ center_phi+=(event->y()-lastPos.y())*3.1415926f/image_size_y;
+ lastPos=event->pos();
+ updateGL();
+ }
+}
+
void OpenGLCanvas::paintGL(){
float fov_rads = (fov/180.f)*1.5708f;
diff --git a/openglcanvas.h b/openglcanvas.h
index 6ba05070ce925493836e3032a0ce023e31f141c3..04c6222843d88d93b6d80129a6c35e690d7faa13 100644
--- a/openglcanvas.h
+++ b/openglcanvas.h
@@ -55,6 +55,8 @@ protected:
void readTextureBytes(const char * const progname, const char * texturePath,unsigned char * textureBytes,int * outImageWidth, int * outImageHeight);
char *textFileRead(char *fn);
void setShaders();
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
signals:
void fps(QString newFPS);
@@ -95,6 +97,12 @@ private:
// options set in the rc file
char* shader_dir;
char* input_image_file;
+
+ // input image size (determined automatically)
+ int image_size_x;
+ int image_size_y;
+
+ QPoint lastPos; // mouse click position
};
#endif // OPENGLCANVAS_H
diff --git a/panowindow1.ui b/panowindow1.ui
index 7a9cb24644d1fb03a001bd659e0c4aad2edd22d7..a1f566e2ab7d0d59f8347412fc1fba144d611f64 100644
--- a/panowindow1.ui
+++ b/panowindow1.ui
@@ -201,6 +201,7 @@
change_center_phi(double)
change_fov_scale_relation(QString)
change_visualization(QString)
+ change_input_image()