Mercurial > hg > svgui
comparison widgets/AudioDial.cpp @ 908:4a578a360011 cxx11
More type fixes
author | Chris Cannam |
---|---|
date | Tue, 10 Mar 2015 13:22:10 +0000 |
parents | d26545a2a02d |
children | 1badacff7ab2 |
comparison
equal
deleted
inserted
replaced
907:28d05ae8741c | 908:4a578a360011 |
---|---|
119 { | 119 { |
120 Profiler profiler("AudioDial::paintEvent"); | 120 Profiler profiler("AudioDial::paintEvent"); |
121 | 121 |
122 QPainter paint; | 122 QPainter paint; |
123 | 123 |
124 float angle = AUDIO_DIAL_MIN // offset | 124 double angle = AUDIO_DIAL_MIN // offset |
125 + (AUDIO_DIAL_RANGE * | 125 + (AUDIO_DIAL_RANGE * |
126 (float(QDial::value() - QDial::minimum()) / | 126 (double(QDial::value() - QDial::minimum()) / |
127 (float(QDial::maximum() - QDial::minimum())))); | 127 (double(QDial::maximum() - QDial::minimum())))); |
128 int degrees = int(angle * 180.0 / M_PI); | 128 int degrees = int(angle * 180.0 / M_PI); |
129 | 129 |
130 int ns = notchSize(); | 130 int ns = notchSize(); |
131 int numTicks = 1 + (maximum() + ns - minimum()) / ns; | 131 int numTicks = 1 + (maximum() + ns - minimum()) / ns; |
132 | 132 |
266 width, false); | 266 width, false); |
267 } | 267 } |
268 | 268 |
269 // Pointer notch... | 269 // Pointer notch... |
270 | 270 |
271 float hyp = float(width) / 2.0; | 271 double hyp = double(width) / 2.0; |
272 float len = hyp - indent; | 272 double len = hyp - indent; |
273 --len; | 273 --len; |
274 | 274 |
275 float x0 = hyp; | 275 double x0 = hyp; |
276 float y0 = hyp; | 276 double y0 = hyp; |
277 | 277 |
278 float x = hyp - len * sin(angle); | 278 double x = hyp - len * sin(angle); |
279 float y = hyp + len * cos(angle); | 279 double y = hyp + len * cos(angle); |
280 | 280 |
281 c = palette().dark().color(); | 281 c = palette().dark().color(); |
282 pen.setColor(isEnabled() ? c.dark(130) : c); | 282 pen.setColor(isEnabled() ? c.dark(130) : c); |
283 pen.setWidth(scale * 2); | 283 pen.setWidth(scale * 2); |
284 paint.setPen(pen); | 284 paint.setPen(pen); |
287 paint.end(); | 287 paint.end(); |
288 } | 288 } |
289 | 289 |
290 | 290 |
291 void AudioDial::drawTick(QPainter &paint, | 291 void AudioDial::drawTick(QPainter &paint, |
292 float angle, int size, bool internal) | 292 double angle, int size, bool internal) |
293 { | 293 { |
294 float hyp = float(size) / 2.0; | 294 double hyp = double(size) / 2.0; |
295 float x0 = hyp - (hyp - 1) * sin(angle); | 295 double x0 = hyp - (hyp - 1) * sin(angle); |
296 float y0 = hyp + (hyp - 1) * cos(angle); | 296 double y0 = hyp + (hyp - 1) * cos(angle); |
297 | 297 |
298 // cerr << "drawTick: angle " << angle << ", size " << size << ", internal " << internal << endl; | 298 // cerr << "drawTick: angle " << angle << ", size " << size << ", internal " << internal << endl; |
299 | 299 |
300 if (internal) { | 300 if (internal) { |
301 | 301 |
302 float len = hyp / 4; | 302 double len = hyp / 4; |
303 float x1 = hyp - (hyp - len) * sin(angle); | 303 double x1 = hyp - (hyp - len) * sin(angle); |
304 float y1 = hyp + (hyp - len) * cos(angle); | 304 double y1 = hyp + (hyp - len) * cos(angle); |
305 | 305 |
306 paint.drawLine(int(x0), int(y0), int(x1), int(y1)); | 306 paint.drawLine(int(x0), int(y0), int(x1), int(y1)); |
307 | 307 |
308 } else { | 308 } else { |
309 | 309 |
310 float len = hyp / 4; | 310 double len = hyp / 4; |
311 float x1 = hyp - (hyp + len) * sin(angle); | 311 double x1 = hyp - (hyp + len) * sin(angle); |
312 float y1 = hyp + (hyp + len) * cos(angle); | 312 double y1 = hyp + (hyp + len) * cos(angle); |
313 | 313 |
314 paint.drawLine(int(x0), int(y0), int(x1), int(y1)); | 314 paint.drawLine(int(x0), int(y0), int(x1), int(y1)); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
348 { | 348 { |
349 QDial::setValue(value); | 349 QDial::setValue(value); |
350 updateMappedValue(value); | 350 updateMappedValue(value); |
351 } | 351 } |
352 | 352 |
353 void AudioDial::setDefaultMappedValue(float value) | 353 void AudioDial::setDefaultMappedValue(double value) |
354 { | 354 { |
355 m_defaultMappedValue = value; | 355 m_defaultMappedValue = value; |
356 if (m_rangeMapper) { | 356 if (m_rangeMapper) { |
357 m_defaultValue = m_rangeMapper->getPositionForValue(value); | 357 m_defaultValue = m_rangeMapper->getPositionForValue(value); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 void AudioDial::setMappedValue(float mappedValue) | 361 void AudioDial::setMappedValue(double mappedValue) |
362 { | 362 { |
363 if (m_rangeMapper) { | 363 if (m_rangeMapper) { |
364 int newPosition = m_rangeMapper->getPositionForValue(mappedValue); | 364 int newPosition = m_rangeMapper->getPositionForValue(mappedValue); |
365 bool changed = (m_mappedValue != mappedValue); | 365 bool changed = (m_mappedValue != mappedValue); |
366 m_mappedValue = mappedValue; | 366 m_mappedValue = mappedValue; |
385 updateMappedValue(value()); | 385 updateMappedValue(value()); |
386 m_noMappedUpdate = false; | 386 m_noMappedUpdate = false; |
387 } | 387 } |
388 | 388 |
389 | 389 |
390 float AudioDial::mappedValue() const | 390 double AudioDial::mappedValue() const |
391 { | 391 { |
392 if (m_rangeMapper) { | 392 if (m_rangeMapper) { |
393 // SVDEBUG << "AudioDial::mappedValue(): value = " << value() << ", mappedValue = " << m_mappedValue << endl; | 393 // SVDEBUG << "AudioDial::mappedValue(): value = " << value() << ", mappedValue = " << m_mappedValue << endl; |
394 return m_mappedValue; | 394 return m_mappedValue; |
395 } | 395 } |
462 | 462 |
463 bool ok = false; | 463 bool ok = false; |
464 | 464 |
465 if (m_rangeMapper) { | 465 if (m_rangeMapper) { |
466 | 466 |
467 float min = m_rangeMapper->getValueForPosition(minimum()); | 467 double min = m_rangeMapper->getValueForPosition(minimum()); |
468 float max = m_rangeMapper->getValueForPosition(maximum()); | 468 double max = m_rangeMapper->getValueForPosition(maximum()); |
469 | 469 |
470 if (min > max) { | 470 if (min > max) { |
471 float tmp = min; | 471 double tmp = min; |
472 min = max; | 472 min = max; |
473 max = tmp; | 473 max = tmp; |
474 } | 474 } |
475 | 475 |
476 QString unit = m_rangeMapper->getUnit(); | 476 QString unit = m_rangeMapper->getUnit(); |
492 text = tr("Enter a new value from %1 to %2:") | 492 text = tr("Enter a new value from %1 to %2:") |
493 .arg(min).arg(max); | 493 .arg(min).arg(max); |
494 } | 494 } |
495 } | 495 } |
496 | 496 |
497 float newValue = QInputDialog::getDouble | 497 double newValue = QInputDialog::getDouble |
498 (this, | 498 (this, |
499 tr("Enter new value"), | 499 tr("Enter new value"), |
500 text, | 500 text, |
501 m_mappedValue, | 501 m_mappedValue, |
502 min, | 502 min, |