support clip indication for bar meter as well
This commit is contained in:
parent
d60b538ce6
commit
938112d65d
3 changed files with 124 additions and 62 deletions
|
@ -31,8 +31,7 @@
|
|||
|
||||
|
||||
|
||||
TODO support clip indicator for bar meter as well
|
||||
-> change background to red in case of clipping
|
||||
TODO use signal level meter class for meter calculation in the server (avoid doubling code), i.e., max calc and smoothing
|
||||
|
||||
TODO the new translation loading does not work on MacOS
|
||||
|
||||
|
|
|
@ -113,11 +113,6 @@ void CLevelMeter::SetLevelMeterType ( const ELevelMeterType eNType )
|
|||
|
||||
case MT_BAR:
|
||||
pStackedLayout->setCurrentIndex ( 1 );
|
||||
pBarMeter->setStyleSheet (
|
||||
"QProgressBar { margin: 1px;"
|
||||
" padding: 1px;"
|
||||
" width: 15px; }"
|
||||
"QProgressBar::chunk { background: green; }" );
|
||||
break;
|
||||
|
||||
case MT_SLIM_BAR:
|
||||
|
@ -128,19 +123,64 @@ void CLevelMeter::SetLevelMeterType ( const ELevelMeterType eNType )
|
|||
}
|
||||
|
||||
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 (
|
||||
"QProgressBar { border: 0px;"
|
||||
" margin: 0px;"
|
||||
" padding: 0px;"
|
||||
" width: 4px; }"
|
||||
"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;
|
||||
}
|
||||
}
|
||||
|
||||
void CLevelMeter::SetValue ( const double dValue )
|
||||
{
|
||||
if ( this->isEnabled() )
|
||||
{
|
||||
switch ( eLevelMeterType )
|
||||
{
|
||||
|
@ -177,26 +217,46 @@ void CLevelMeter::SetValue ( const double dValue )
|
|||
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
|
||||
// value of int16 is -32768 but we normalize with 32767 -> therefore
|
||||
// we really only show the clipping indicator, if actually the largest
|
||||
// value of int16 is used)
|
||||
if ( dValue > NUM_STEPS_LED_BAR )
|
||||
{
|
||||
vecpLEDs[NUM_STEPS_LED_BAR]->SetColor ( cLED::RL_RED );
|
||||
TimerClip.start();
|
||||
}
|
||||
else if ( vecpLEDs[NUM_STEPS_LED_BAR]->GetColor() != cLED::RL_RED )
|
||||
switch ( eLevelMeterType )
|
||||
{
|
||||
vecpLEDs[NUM_STEPS_LED_BAR]->SetColor ( cLED::RL_BLACK );
|
||||
}
|
||||
case MT_LED:
|
||||
vecpLEDs[NUM_STEPS_LED_BAR]->SetColor ( cLED::RL_RED );
|
||||
break;
|
||||
|
||||
case MT_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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,9 @@ protected:
|
|||
QLabel* pLEDLabel;
|
||||
};
|
||||
|
||||
void SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType,
|
||||
const bool bIsClip );
|
||||
|
||||
QStackedLayout* pStackedLayout;
|
||||
ELevelMeterType eLevelMeterType;
|
||||
CVector<cLED*> vecpLEDs;
|
||||
|
|
Loading…
Reference in a new issue