+QRect AudioSpectrum::scopeRect()
+{
+ m_scopeRect = QRect(
+ QPoint(
+ 10, // Left
+ ui->verticalSpacer->geometry().top()+6 // Top
+ ),
+ AbstractAudioScopeWidget::rect().bottomRight()
+ );
+ m_innerScopeRect = QRect(
+ QPoint(
+ m_scopeRect.left()+6, // Left
+ m_scopeRect.top()+6 // Top
+ ), QPoint(
+ ui->verticalSpacer->geometry().right()-70,
+ ui->verticalSpacer->geometry().bottom()-40
+ )
+ );
+ return m_scopeRect;
+}
+
+void AudioSpectrum::slotResetMaxFreq()
+{
+ m_customFreq = false;
+ forceUpdateHUD();
+ forceUpdateScope();
+}
+
+
+///// EVENTS /////
+
+void AudioSpectrum::handleMouseDrag(const QPoint movement, const RescaleDirection rescaleDirection, const Qt::KeyboardModifiers rescaleModifiers)
+{
+ if (rescaleDirection == North) {
+ // Nort-South direction: Adjust the dB scale
+
+ if ((rescaleModifiers & Qt::ShiftModifier) == 0) {
+
+ // By default adjust the min dB value
+ m_dBmin += movement.y();
+
+ } else {
+
+ // Adjust max dB value if Shift is pressed.
+ m_dBmax += movement.y();
+
+ }
+
+ // Ensure the dB values lie in [-100, 0] (or rather [MIN_DB_VALUE, 0])
+ // 0 is the upper bound, everything below -70 dB is most likely noise
+ if (m_dBmax > 0) {
+ m_dBmax = 0;
+ }
+ if (m_dBmin < MIN_DB_VALUE) {
+ m_dBmin = MIN_DB_VALUE;
+ }
+ // Ensure there is at least 6 dB between the minimum and the maximum value;
+ // lower values hardly make sense
+ if (m_dBmax - m_dBmin < 6) {
+ if ((rescaleModifiers & Qt::ShiftModifier) == 0) {
+ // min was adjusted; Try to adjust the max value to maintain the
+ // minimum dB difference of 6 dB
+ m_dBmax = m_dBmin + 6;
+ if (m_dBmax > 0) {
+ m_dBmax = 0;
+ m_dBmin = -6;
+ }
+ } else {
+ // max was adjusted, adjust min
+ m_dBmin = m_dBmax - 6;
+ if (m_dBmin < MIN_DB_VALUE) {
+ m_dBmin = MIN_DB_VALUE;
+ m_dBmax = MIN_DB_VALUE+6;
+ }
+ }
+ }
+
+ forceUpdateHUD();
+ forceUpdateScope();
+
+ } else if (rescaleDirection == East) {
+ // East-West direction: Adjust the maximum frequency
+ m_freqMax -= 100*movement.x();
+ if (m_freqMax < MIN_FREQ_VALUE) {
+ m_freqMax = MIN_FREQ_VALUE;
+ }
+ if (m_freqMax > MAX_FREQ_VALUE) {
+ m_freqMax = MAX_FREQ_VALUE;
+ }
+ m_customFreq = true;
+
+ forceUpdateHUD();
+ forceUpdateScope();
+ }