support clip indication for bar meter as well

This commit is contained in:
Volker Fischer 2020-06-24 18:28:47 +02:00
parent d60b538ce6
commit 938112d65d
3 changed files with 124 additions and 62 deletions

View File

@ -31,8 +31,7 @@
TODO support clip indicator for bar meter as well TODO use signal level meter class for meter calculation in the server (avoid doubling code), i.e., max calc and smoothing
-> change background to red in case of clipping
TODO the new translation loading does not work on MacOS TODO the new translation loading does not work on MacOS

View File

@ -113,11 +113,6 @@ void CLevelMeter::SetLevelMeterType ( const ELevelMeterType eNType )
case MT_BAR: case MT_BAR:
pStackedLayout->setCurrentIndex ( 1 ); pStackedLayout->setCurrentIndex ( 1 );
pBarMeter->setStyleSheet (
"QProgressBar { margin: 1px;"
" padding: 1px;"
" width: 15px; }"
"QProgressBar::chunk { background: green; }" );
break; break;
case MT_SLIM_BAR: case MT_SLIM_BAR:
@ -128,20 +123,65 @@ void CLevelMeter::SetLevelMeterType ( const ELevelMeterType eNType )
} }
pStackedLayout->setCurrentIndex ( 1 ); pStackedLayout->setCurrentIndex ( 1 );
break;
}
// update bar meter style and reset clip state
SetBarMeterStyleAndClipStatus ( eNType, false );
}
void CLevelMeter::SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType,
const bool bIsClip )
{
switch ( eNType )
{
case MT_SLIM_BAR:
if ( bIsClip )
{
pBarMeter->setStyleSheet (
"QProgressBar { border: 0px solid red;"
" margin: 0px;"
" padding: 0px;"
" width: 4px;"
" background: red; }"
"QProgressBar::chunk { background: green; }" );
}
else
{
pBarMeter->setStyleSheet ( pBarMeter->setStyleSheet (
"QProgressBar { border: 0px;" "QProgressBar { border: 0px;"
" margin: 0px;" " margin: 0px;"
" padding: 0px;" " padding: 0px;"
" width: 4px; }" " width: 4px; }"
"QProgressBar::chunk { background: green; }" ); "QProgressBar::chunk { background: green; }" );
}
break;
default: /* MT_BAR */
if ( bIsClip )
{
pBarMeter->setStyleSheet (
"QProgressBar { border: 2px solid red;"
" margin: 1px;"
" padding: 1px;"
" width: 15px;"
" background: transparent; }"
"QProgressBar::chunk { background: green; }" );
}
else
{
pBarMeter->setStyleSheet (
"QProgressBar { margin: 1px;"
" padding: 1px;"
" width: 15px; }"
"QProgressBar::chunk { background: green; }" );
}
break; break;
} }
} }
void CLevelMeter::SetValue ( const double dValue ) void CLevelMeter::SetValue ( const double dValue )
{ {
if ( this->isEnabled() )
{
switch ( eLevelMeterType ) switch ( eLevelMeterType )
{ {
case MT_LED: case MT_LED:
@ -177,26 +217,46 @@ void CLevelMeter::SetValue ( const double dValue )
vecpLEDs[iLEDIdx]->SetColor ( cLED::RL_BLACK ); vecpLEDs[iLEDIdx]->SetColor ( cLED::RL_BLACK );
} }
} }
break;
// clip LED management (note that in case of clipping, i.e. full case MT_BAR:
case MT_SLIM_BAR:
pBarMeter->setValue ( 100 * dValue );
break;
}
// clip indicator management (note that in case of clipping, i.e. full
// scale level, the value is above NUM_STEPS_LED_BAR since the minimum // scale level, the value is above NUM_STEPS_LED_BAR since the minimum
// value of int16 is -32768 but we normalize with 32767 -> therefore // value of int16 is -32768 but we normalize with 32767 -> therefore
// we really only show the clipping indicator, if actually the largest // we really only show the clipping indicator, if actually the largest
// value of int16 is used) // value of int16 is used)
if ( dValue > NUM_STEPS_LED_BAR ) if ( dValue > NUM_STEPS_LED_BAR )
{ {
vecpLEDs[NUM_STEPS_LED_BAR]->SetColor ( cLED::RL_RED ); switch ( eLevelMeterType )
TimerClip.start();
}
else if ( vecpLEDs[NUM_STEPS_LED_BAR]->GetColor() != cLED::RL_RED )
{ {
vecpLEDs[NUM_STEPS_LED_BAR]->SetColor ( cLED::RL_BLACK ); case MT_LED:
} vecpLEDs[NUM_STEPS_LED_BAR]->SetColor ( cLED::RL_RED );
break; break;
case MT_BAR: case MT_BAR:
case MT_SLIM_BAR: case MT_SLIM_BAR:
pBarMeter->setValue ( 100 * dValue ); SetBarMeterStyleAndClipStatus ( eLevelMeterType, true );
break;
}
TimerClip.start();
}
else if ( !TimerClip.isActive() )
{
switch ( eLevelMeterType )
{
case MT_LED:
vecpLEDs[NUM_STEPS_LED_BAR]->SetColor ( cLED::RL_BLACK );
break;
case MT_BAR:
case MT_SLIM_BAR:
SetBarMeterStyleAndClipStatus ( eLevelMeterType, false );
break; break;
} }
} }

View File

@ -87,6 +87,9 @@ protected:
QLabel* pLEDLabel; QLabel* pLEDLabel;
}; };
void SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType,
const bool bIsClip );
QStackedLayout* pStackedLayout; QStackedLayout* pStackedLayout;
ELevelMeterType eLevelMeterType; ELevelMeterType eLevelMeterType;
CVector<cLED*> vecpLEDs; CVector<cLED*> vecpLEDs;