Index: v3d_main/v3d/v3d_core.cpp =================================================================== --- v3d_main/v3d/v3d_core.cpp (revision 1965) +++ v3d_main/v3d/v3d_core.cpp (working copy) @@ -1528,12 +1528,21 @@ return roiPolygon.boundingRect(); } +QPointF XFormView::mouseEventToImageCoords(const QPoint& p) +{ + return QPointF( + double((p.x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5, + double((p.y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5 + ); +} + void XFormView::mouseDoubleClickEvent(QMouseEvent * e) { if (!imgData) return; - - QPoint cp = e->pos()/disp_scale; + + QPoint cp = mouseEventToImageCoords(e->pos()).toPoint(); + int sx,sy,sz; //current selection location's x,y,z switch(Ptype) @@ -1696,21 +1705,23 @@ else { #endif + QPoint eImgCoords = mouseEventToImageCoords(e->pos()).toPoint(); + switch (Ptype) { case imgPlaneX: - emit focusZChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5); - emit focusYChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5); + emit focusZChanged(eImgCoords.x()); + emit focusYChanged(eImgCoords.y()); break; case imgPlaneY: - emit focusXChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5); - emit focusZChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5); + emit focusXChanged(eImgCoords.x()); + emit focusZChanged(eImgCoords.y()); break; case imgPlaneZ: - emit focusXChanged(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5); - emit focusYChanged(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5); + emit focusXChanged(eImgCoords.x()); + emit focusYChanged(eImgCoords.y()); //qDebug()<<"x="<x()<<"y="<y()<<"disp_scale="<pos(); - //add zoom-in support. by PHC 20101119 - cp.setX(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5); - cp.setY(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5); + QPoint cp = mouseEventToImageCoords(e->pos()).toPoint(); roiPolygon << cp; update(); @@ -1747,11 +1756,7 @@ } else if (b_moveCurrentLandmark==true && ind_landmarkToBeChanged>=0 && QApplication::keyboardModifiers()==Qt::ShiftModifier) { - QPoint cp = e->pos(); ///(disp_scale*m_scale); //100909 - - //the following two lines are suggested by Carlos Becker, 111004. Apparently are duplicates of my code on 1733/1734 above. by PHC - cp.setX(double((e->x()-curDisplayCenter.x()))/(disp_scale*m_scale)+pixmap.width()/2.0+0.5); - cp.setY(double((e->y()-curDisplayCenter.y()))/(disp_scale*m_scale)+pixmap.height()/2.0+0.5); + QPoint cp = mouseEventToImageCoords(e->pos()).toPoint(); int sx,sy,sz; //current selection location's x,y,z Index: v3d_main/v3d/v3d_core.h =================================================================== --- v3d_main/v3d/v3d_core.h (revision 1965) +++ v3d_main/v3d/v3d_core.h (working copy) @@ -514,6 +514,9 @@ void set_disp_width(int a) {disp_width = a;} void set_disp_height(int a) {disp_height = a;} void set_disp_scale(double a) {disp_scale = a; } + + /* Converts point from mouse event coordinates to image coordinates */ + QPointF mouseEventToImageCoords(const QPoint& p); void mousePressEvent(QMouseEvent *e); void mouseLeftButtonPressEvent(QMouseEvent *e);