@@ -40,6 +40,9 @@ VoltageDock::VoltageDock( DsoSettingsScope *scope, const Dso::ControlSpecificati
4040 for ( double gainStep : scope->gainSteps ) {
4141 gainStrings << valueToString ( gainStep, UNIT_VOLTS, 0 );
4242 }
43+ for ( double mathGainStep : scope->mathGainSteps ) {
44+ mathGainStrings << valueToString ( mathGainStep, UNIT_VOLTS, 0 );
45+ }
4346
4447 dockLayout = new QGridLayout ();
4548 dockLayout->setColumnMinimumWidth ( 0 , 50 );
@@ -73,12 +76,13 @@ VoltageDock::VoltageDock( DsoSettingsScope *scope, const Dso::ControlSpecificati
7376 b.miscComboBox ->addItems ( couplingStrings );
7477 if ( scope->toolTipVisible )
7578 b.miscComboBox ->setToolTip ( tr ( " Select DC or AC coupling" ) );
79+ b.gainComboBox ->addItems ( gainStrings );
7680 } else {
7781 b.miscComboBox ->addItems ( modeStrings );
7882 if ( scope->toolTipVisible )
7983 b.miscComboBox ->setToolTip ( tr ( " Select the mathematical operation for this channel" ) );
84+ b.gainComboBox ->addItems ( mathGainStrings );
8085 }
81- b.gainComboBox ->addItems ( gainStrings );
8286
8387 if ( channel < spec->channels ) {
8488 dockLayout->setColumnStretch ( 1 , 1 ); // stretch ComboBox in 2nd (middle) column 1x
@@ -196,10 +200,17 @@ void VoltageDock::setCoupling( ChannelID channel, unsigned couplingIndex ) {
196200void VoltageDock::setGain ( ChannelID channel, unsigned gainStepIndex ) {
197201 if ( channel >= scope->voltage .size () )
198202 return ;
199- if ( gainStepIndex >= scope->gainSteps .size () )
200- return ;
201- if ( scope->verboseLevel > 2 )
202- qDebug () << " VDock::setGain()" << channel << gainStrings[ int ( gainStepIndex ) ];
203+ if ( channel < spec->channels ) { // Voltage channel
204+ if ( gainStepIndex >= scope->gainSteps .size () )
205+ return ;
206+ if ( scope->verboseLevel > 2 )
207+ qDebug () << " VDock::setGain()" << channel << gainStrings[ int ( gainStepIndex ) ];
208+ } else {
209+ if ( gainStepIndex >= scope->mathGainSteps .size () )
210+ return ;
211+ if ( scope->verboseLevel > 2 )
212+ qDebug () << " VDock::setGain()" << channel << mathGainStrings[ int ( gainStepIndex ) ];
213+ }
203214 QSignalBlocker blocker ( channelBlocks[ channel ].gainComboBox );
204215 channelBlocks[ channel ].gainComboBox ->setCurrentIndex ( int ( gainStepIndex ) );
205216}
@@ -212,20 +223,23 @@ void VoltageDock::setAttn( ChannelID channel, double attnValue ) {
212223 return ;
213224 QSignalBlocker blocker ( channelBlocks[ channel ].gainComboBox );
214225 int index = channelBlocks[ channel ].gainComboBox ->currentIndex ();
215- gainStrings.clear ();
216226
227+ channelBlocks[ channel ].gainComboBox ->clear ();
217228 // change unit to V² for the multiplying math functions
218- if ( channel >= spec->channels ) // MATH channel
229+ if ( channel < spec->channels ) { // Voltage channel
230+ gainStrings.clear ();
219231 for ( double gainStep : scope->gainSteps )
220- gainStrings << valueToString (
221- gainStep * attnValue, Dso::mathModeUnit ( Dso::MathMode ( scope->voltage [ spec->channels ].couplingOrMathIndex ) ),
222- -1 ); // auto format V²
223- else
224- for ( double gainStep : scope->gainSteps )
225- gainStrings << valueToString ( gainStep * attnValue, UNIT_VOLTS, -1 ); // auto format V²
226-
227- channelBlocks[ channel ].gainComboBox ->clear ();
228- channelBlocks[ channel ].gainComboBox ->addItems ( gainStrings );
232+ gainStrings << valueToString ( gainStep * attnValue, UNIT_VOLTS, -1 );
233+ channelBlocks[ channel ].gainComboBox ->addItems ( gainStrings );
234+ } else {
235+ mathGainStrings.clear ();
236+ for ( double mathGainStep : scope->mathGainSteps )
237+ mathGainStrings << valueToString (
238+ mathGainStep * attnValue,
239+ Dso::mathModeUnit ( Dso::MathMode ( scope->voltage [ spec->channels ].couplingOrMathIndex ) ),
240+ -1 ); // auto format V or V²
241+ channelBlocks[ channel ].gainComboBox ->addItems ( mathGainStrings );
242+ }
229243 channelBlocks[ channel ].gainComboBox ->setCurrentIndex ( index );
230244 scope->voltage [ channel ].probeAttn = attnValue;
231245 channelBlocks[ channel ].attnSpinBox ->setValue ( int ( attnValue ) );
0 commit comments