Diffstat (limited to 'core/settings/light-and-power/calibration.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/settings/light-and-power/calibration.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/core/settings/light-and-power/calibration.cpp b/core/settings/light-and-power/calibration.cpp index 307de1f..6a3360f 100644 --- a/core/settings/light-and-power/calibration.cpp +++ b/core/settings/light-and-power/calibration.cpp | |||
@@ -85,44 +85,44 @@ void Calibration::setInterval ( int iv ) | |||
85 | 85 | ||
86 | m_interval = iv; | 86 | m_interval = iv; |
87 | //update ( ); | 87 | //update ( ); |
88 | } | 88 | } |
89 | 89 | ||
90 | int Calibration::interval ( ) const | 90 | int Calibration::interval ( ) const |
91 | { | 91 | { |
92 | return m_interval; | 92 | return m_interval; |
93 | } | 93 | } |
94 | 94 | ||
95 | void Calibration::setStartPoint ( const QPoint &p ) | 95 | void Calibration::setStartPoint ( const QPoint &p ) |
96 | { | 96 | { |
97 | m_p [0] = p; | 97 | m_p [0] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); |
98 | checkPoints ( ); | 98 | checkPoints ( ); |
99 | update ( ); | 99 | update ( ); |
100 | } | 100 | } |
101 | 101 | ||
102 | QPoint Calibration::startPoint ( ) const | 102 | QPoint Calibration::startPoint ( ) const |
103 | { | 103 | { |
104 | return m_p [0]; | 104 | return QPoint ( m_p [0]. x ( ), m_scale. height ( ) - m_p [0]. y ( ) - 1 ); |
105 | } | 105 | } |
106 | 106 | ||
107 | void Calibration::setEndPoint ( const QPoint &p ) | 107 | void Calibration::setEndPoint ( const QPoint &p ) |
108 | { | 108 | { |
109 | m_p [1] = p; | 109 | m_p [1] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); |
110 | checkPoints ( ); | 110 | checkPoints ( ); |
111 | update ( ); | 111 | update ( ); |
112 | } | 112 | } |
113 | 113 | ||
114 | QPoint Calibration::endPoint ( ) const | 114 | QPoint Calibration::endPoint ( ) const |
115 | { | 115 | { |
116 | return m_p [1]; | 116 | return QPoint ( m_p [1]. x ( ), m_scale. height ( ) - m_p [1]. y ( ) - 1 ); |
117 | } | 117 | } |
118 | 118 | ||
119 | void Calibration::checkPoints ( ) | 119 | void Calibration::checkPoints ( ) |
120 | { | 120 | { |
121 | int dx = m_scale. width ( ); | 121 | int dx = m_scale. width ( ); |
122 | int dy = m_scale. height ( ); | 122 | int dy = m_scale. height ( ); |
123 | 123 | ||
124 | if ( m_p [1]. x ( ) >= dx ) | 124 | if ( m_p [1]. x ( ) >= dx ) |
125 | m_p [1]. setX ( dx - 1 ); | 125 | m_p [1]. setX ( dx - 1 ); |
126 | if ( m_p [0]. x ( ) > m_p [1]. x ( )) | 126 | if ( m_p [0]. x ( ) > m_p [1]. x ( )) |
127 | m_p [0]. setX ( m_p [1]. x ( )); | 127 | m_p [0]. setX ( m_p [1]. x ( )); |
128 | 128 | ||
@@ -195,30 +195,30 @@ void Calibration::mouseMoveEvent ( QMouseEvent *e ) | |||
195 | for ( int i = 0; i < 2; i++ ) { | 195 | for ( int i = 0; i < 2; i++ ) { |
196 | nx [i] = SCALEX( n [i]. x ( )); | 196 | nx [i] = SCALEX( n [i]. x ( )); |
197 | ny [i] = SCALEY( n [i]. y ( )); | 197 | ny [i] = SCALEY( n [i]. y ( )); |
198 | ox [i] = SCALEX( m_p [i]. x ( )); | 198 | ox [i] = SCALEX( m_p [i]. x ( )); |
199 | oy [i] = SCALEY( m_p [i]. y ( )); | 199 | oy [i] = SCALEY( m_p [i]. y ( )); |
200 | 200 | ||
201 | if ( n [i] != m_p [i] ){ | 201 | if ( n [i] != m_p [i] ){ |
202 | r |= around ( nx [i], ny [i] ); | 202 | r |= around ( nx [i], ny [i] ); |
203 | r |= around ( ox [i], oy [i] ); | 203 | r |= around ( ox [i], oy [i] ); |
204 | m_p [i] = n [i]; | 204 | m_p [i] = n [i]; |
205 | 205 | ||
206 | if ( i == 0 ) { | 206 | if ( i == 0 ) { |
207 | r |= QRect ( 0, 0, nx [0] - 0 + 1, ny [0] - 0 + 1 ); | 207 | r |= QRect ( 0, ny [0], nx [0] - 0 + 1, 1 ); |
208 | r |= QRect ( 0, 0, ox [0] - 0 + 1, oy [0] - 0 + 1 ); | 208 | r |= QRect ( 0, oy [0], ox [0] - 0 + 1, 1 ); |
209 | } | 209 | } |
210 | else if ( i == 1 ) { | 210 | else if ( i == 1 ) { |
211 | r |= QRect ( nx [1], ny [1], width ( ) - nx [1], height ( ) - ny [1] ); | 211 | r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); |
212 | r |= QRect ( ox [1], oy [1], width ( ) - ox [1], height ( ) - oy [1] ); | 212 | r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | } | 215 | } |
216 | if ( r. isValid ( )) { | 216 | if ( r. isValid ( )) { |
217 | r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ); | 217 | r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ); |
218 | r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ); | 218 | r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ); |
219 | 219 | ||
220 | repaint ( r ); | 220 | repaint ( r ); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | void Calibration::mouseReleaseEvent ( QMouseEvent *e ) | 224 | void Calibration::mouseReleaseEvent ( QMouseEvent *e ) |
@@ -244,26 +244,25 @@ void Calibration::paintEvent ( QPaintEvent * ) | |||
244 | int x0 = SCALEX( m_p [0]. x ( )); | 244 | int x0 = SCALEX( m_p [0]. x ( )); |
245 | int y0 = SCALEY( m_p [0]. y ( )); | 245 | int y0 = SCALEY( m_p [0]. y ( )); |
246 | int x1 = SCALEX( m_p [1]. x ( )); | 246 | int x1 = SCALEX( m_p [1]. x ( )); |
247 | int y1 = SCALEY( m_p [1]. y ( )); | 247 | int y1 = SCALEY( m_p [1]. y ( )); |
248 | 248 | ||
249 | int dx = x1 - x0; | 249 | int dx = x1 - x0; |
250 | int dy = y1 - y0; | 250 | int dy = y1 - y0; |
251 | 251 | ||
252 | int ex = x0, ey = y0; | 252 | int ex = x0, ey = y0; |
253 | 253 | ||
254 | p. setPen ( g. highlight ( )); | 254 | p. setPen ( g. highlight ( )); |
255 | 255 | ||
256 | p. drawLine ( BRD, BRD, ex, BRD ); | 256 | p. drawLine ( BRD, ey, ex, ey ); |
257 | p. drawLine ( ex, BRD, ex, ey ); | ||
258 | 257 | ||
259 | for ( int i = 1; i < m_steps; i++ ) { | 258 | for ( int i = 1; i < m_steps; i++ ) { |
260 | int fx = x0 + dx * i / m_steps; | 259 | int fx = x0 + dx * i / m_steps; |
261 | int fy = y0 + dy * i / ( m_steps - 1 ); | 260 | int fy = y0 + dy * i / ( m_steps - 1 ); |
262 | 261 | ||
263 | p. drawLine ( ex, ey, fx, ey ); | 262 | p. drawLine ( ex, ey, fx, ey ); |
264 | p. drawLine ( fx, ey, fx, fy ); | 263 | p. drawLine ( fx, ey, fx, fy ); |
265 | 264 | ||
266 | ex = fx; | 265 | ex = fx; |
267 | ey = fy; | 266 | ey = fy; |
268 | } | 267 | } |
269 | 268 | ||