-rw-r--r-- | core/settings/light-and-power/calibration.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/settings/light-and-power/calibration.cpp b/core/settings/light-and-power/calibration.cpp index aed2bc8..c5377d0 100644 --- a/core/settings/light-and-power/calibration.cpp +++ b/core/settings/light-and-power/calibration.cpp @@ -134,18 +134,18 @@ void Calibration::checkPoints ( ) m_p [0]. setX ( m_p [1]. x ( )); if ( m_p [1]. y ( ) < 0 ) m_p [1]. setY ( 0 ); if ( m_p [1]. y ( ) >= dy ) m_p [1]. setY ( dy - 1 ); if ( m_p [0]. y ( ) < 0 ) m_p [0]. setY ( 0 ); - if ( m_p [0]. y ( ) > m_p [1]. y ( )) - m_p [0]. setY ( m_p [1]. y ( )); + if ( m_p [0]. y ( ) >= dy ) + m_p [0]. setY ( dy - 1 ); } #define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width()) #define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height()) static QRect around ( int x, int y ) @@ -200,18 +200,18 @@ void Calibration::mouseMoveEvent ( QMouseEvent *e ) if ( n [m_dragged]. x ( ) >= m_scale. width ( )) n [m_dragged]. setX ( m_scale. width ( ) - 1 ); if ( n [0]. x ( ) > n [1]. x ( )) n [m_dragged]. setX ( n [1 - m_dragged]. x ( )); if ( n [m_dragged]. y ( ) < 0 ) n [m_dragged]. setY ( 0 ); if ( n [m_dragged]. y ( ) >= m_scale. height ( )) n [m_dragged]. setY ( m_scale. height ( ) - 1 ); - if ( n [0]. y ( ) > n [1]. y ( )) - n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); +// if ( n [0]. y ( ) > n [1]. y ( )) +// n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); QRect r; int ox [2], oy [2], nx [2], ny [2]; for ( int i = 0; i < 2; i++ ) { nx [i] = SCALEX( n [i]. x ( )); ny [i] = SCALEY( n [i]. y ( )); ox [i] = SCALEX( m_p [i]. x ( )); @@ -232,18 +232,18 @@ void Calibration::mouseMoveEvent ( QMouseEvent *e ) r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); emit endPointChanged ( endPoint ( )); } } } if ( r. isValid ( )) { - r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ); - r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ); + r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ). normalize ( ); + r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ). normalize ( ); repaint ( r, false ); } } void Calibration::mouseReleaseEvent ( QMouseEvent *e ) { if ( e-> button ( ) != LeftButton ) @@ -269,17 +269,17 @@ void Calibration::paintEvent ( QPaintEvent *pe ) int y0 = SCALEY( m_p [0]. y ( )); int x1 = SCALEX( m_p [1]. x ( )); int y1 = SCALEY( m_p [1]. y ( )); int dx = x1 - x0; int dy = y1 - y0; // restrict steps to real x and y resolution - int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( dy + 1 )); + int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( QABS( dy ) + 1 )); QString stepstr = tr( "%1 Steps" ). arg ( st ); QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr ); tr. setLeft ( tr. left ( ) - 20 ); if ( p. hasClipping ( )) p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr )); QColorGroup g = colorGroup ( ); |