@@ -81,7 +81,7 @@ DsoWidget::DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::
81
81
82
82
// The table for the marker details
83
83
markerInfoLabel = new QLabel ();
84
- markerInfoLabel->setMinimumWidth ( 160 );
84
+ markerInfoLabel->setAlignment (Qt::AlignLeft );
85
85
markerInfoLabel->setPalette (palette);
86
86
markerTimeLabel = new QLabel ();
87
87
markerTimeLabel->setAlignment (Qt::AlignRight);
@@ -406,54 +406,32 @@ void DsoWidget::setMeasurementVisible(ChannelID channel) {
406
406
if (!scope->spectrum [channel].used ) { measurementMagnitudeLabel[channel]->setText (QString ()); }
407
407
}
408
408
409
- static QString markerToString (DsoSettingsScope *scope, unsigned index) {
410
- double value = (DIVS_TIME * (0.5 - scope->trigger .position ) + scope->getMarker (index )) * scope->horizontal .timebase ;
411
- int precision = 3 - (int )floor (log10 (fabs (value)));
412
-
413
- if (scope->horizontal .timebase < 1e-9 )
414
- return QApplication::tr (" %L1 ps" ).arg (value / 1e-12 , 0 , ' f' , qBound (0 , precision - 12 , 3 ));
415
- else if (scope->horizontal .timebase < 1e-6 )
416
- return QApplication::tr (" %L1 ns" ).arg (value / 1e-9 , 0 , ' f' , qBound (0 , precision - 9 , 3 ));
417
- else if (scope->horizontal .timebase < 1e-3 )
418
- return QApplication::tr (" %L1 µs" ).arg (value / 1e-6 , 0 , ' f' , qBound (0 , precision - 6 , 3 ));
419
- else if (scope->horizontal .timebase < 1 )
420
- return QApplication::tr (" %L1 ms" ).arg (value / 1e-3 , 0 , ' f' , qBound (0 , precision - 3 , 3 ));
421
- else
422
- return QApplication::tr (" %L1 s" ).arg (value, 0 , ' f' , qBound (0 , precision, 3 ));
423
- }
424
409
425
410
// / \brief Update the label about the marker measurements
426
411
void DsoWidget::updateMarkerDetails () {
427
- double divs = fabs (scope->horizontal .cursor .pos [1 ].x () - scope->horizontal .cursor .pos [0 ].x ());
412
+ double div0 = scope->horizontal .cursor .pos [0 ].x ();
413
+ double div1 = scope->horizontal .cursor .pos [1 ].x ();
414
+ if ( div0 > div1 )
415
+ std::swap ( div0, div1 );
416
+ double divs = div1 - div0;
417
+ double time0 = div0 * scope->horizontal .timebase ;
418
+ double time1 = div1 * scope->horizontal .timebase ;
428
419
double time = divs * scope->horizontal .timebase ;
429
-
430
- QString prefix (tr (" Markers" ));
431
- if (view->zoom ) {
432
- if ( divs != 0.0 )
433
- prefix = tr (" Zoom x%L1" ).arg (DIVS_TIME / divs, -1 , ' g' , 3 );
434
- else // avoid div by zero
435
- prefix = tr (" Zoom ---" );
436
- markerTimebaseLabel->setText (valueToString (time / DIVS_TIME, UNIT_SECONDS, 3 ) + tr (" /div" ));
437
- markerFrequencybaseLabel->setText (
438
- valueToString (divs * scope->horizontal .frequencybase / DIVS_TIME, UNIT_HERTZ, 4 ) + tr (" /div" ));
439
- }
440
- markerInfoLabel->setText (prefix.append (" : %1 %2" ).arg (markerToString (scope, 0 )).arg (markerToString (scope, 1 )));
441
- markerTimeLabel->setText (valueToString (time , UNIT_SECONDS, 4 ));
442
- if ( time != 0.0 )
443
- markerFrequencyLabel->setText (valueToString (1.0 / time , UNIT_HERTZ, 4 ));
444
- else // avoid div by zero
445
- markerFrequencyLabel->setText ( " --- Hz" );
420
+ div0 += DIVS_TIME / 2 ; // zero at center -> zero at left margin
421
+ div1 += DIVS_TIME / 2 ;
422
+ double freq0 = div0 * scope->horizontal .frequencybase ;
423
+ double freq1 = div1 * scope->horizontal .frequencybase ;
424
+ double freq = divs * scope->horizontal .frequencybase ;
425
+ bool timeUsed = false ;
426
+ bool freqUsed = false ;
446
427
447
428
int index = 0 ;
448
- if ( time != 0.0 )
449
- cursorDataGrid->updateInfo (index ++, true , QString (),
450
- valueToString (time , UNIT_SECONDS, 4 ), valueToString (1.0 / time , UNIT_HERTZ, 4 ));
451
- else // avoid div by zero
452
- cursorDataGrid->updateInfo (index ++, true , QString (),
453
- valueToString (time , UNIT_SECONDS, 4 ), " --- Hz" );
429
+ cursorDataGrid->updateInfo (index ++, true , QString (),
430
+ valueToString (time , UNIT_SECONDS, 3 ), valueToString ( freq, UNIT_HERTZ, 3 ) );
454
431
455
432
for (ChannelID channel = 0 ; channel < scope->voltage .size (); ++channel) {
456
433
if (scope->voltage [channel].used ) {
434
+ timeUsed = true ; // at least one voltage channel used -> show marker time details
457
435
QPointF p0 = scope->voltage [channel].cursor .pos [0 ];
458
436
QPointF p1 = scope->voltage [channel].cursor .pos [1 ];
459
437
cursorDataGrid->updateInfo (index , true ,
@@ -467,6 +445,7 @@ void DsoWidget::updateMarkerDetails() {
467
445
}
468
446
for (ChannelID channel = 0 ; channel < scope->spectrum .size (); ++channel) {
469
447
if (scope->spectrum [channel].used ) {
448
+ freqUsed = true ; // at least one spec channel used -> show marker freq details
470
449
QPointF p0 = scope->spectrum [channel].cursor .pos [0 ];
471
450
QPointF p1 = scope->spectrum [channel].cursor .pos [1 ];
472
451
cursorDataGrid->updateInfo (index , true ,
@@ -478,6 +457,53 @@ void DsoWidget::updateMarkerDetails() {
478
457
}
479
458
++index ;
480
459
}
460
+
461
+ if ( DIVS_TIME == divs || (div0 == 0 && div1 == 0 ) || (div0 == DIVS_TIME && div1 == DIVS_TIME) ) {
462
+ // markers at left/right margins -> don't display
463
+ markerInfoLabel->setVisible ( false );
464
+ markerTimeLabel->setVisible ( false );
465
+ markerFrequencyLabel->setVisible ( false );
466
+ markerTimebaseLabel->setVisible ( false );
467
+ markerFrequencybaseLabel->setVisible ( false );
468
+ } else {
469
+ markerInfoLabel->setVisible ( true );
470
+ markerTimeLabel->setVisible ( true );
471
+ markerFrequencyLabel->setVisible ( true );
472
+ markerTimebaseLabel->setVisible ( view->zoom );
473
+ markerFrequencybaseLabel->setVisible ( view->zoom );
474
+ QString mInfo ( tr ( " Markers " ) );
475
+ QString mTime ( tr ( " Time: " ) );
476
+ QString mFreq ( tr ( " Frequency: " ) );
477
+ if (view->zoom ) {
478
+ if ( divs != 0.0 )
479
+ mInfo = tr ( " Zoom x%L1 " ).arg ( DIVS_TIME / divs, -1 , ' g' , 3 );
480
+ else // avoid div by zero
481
+ mInfo = tr ( " Zoom --- " );
482
+ mTime = " t: " ;
483
+ mFreq = " f: " ;
484
+ markerTimebaseLabel->setText (" " + valueToString ( time / DIVS_TIME, UNIT_SECONDS, 3 ) + tr (" /div" ));
485
+ markerTimebaseLabel->setVisible ( timeUsed );
486
+ markerFrequencybaseLabel->setText ( " " + valueToString ( freq / DIVS_TIME, UNIT_HERTZ, 3 ) + tr (" /div" ));
487
+ markerFrequencybaseLabel->setVisible ( freqUsed );
488
+ }
489
+ markerInfoLabel->setText ( mInfo );
490
+ if ( timeUsed )
491
+ markerTimeLabel->setText ( mTime .append ( " %1 -> %2, Δt: %3 " )
492
+ .arg ( valueToString ( time0, UNIT_SECONDS, 4 ) )
493
+ .arg ( valueToString ( time1, UNIT_SECONDS, 4 ) )
494
+ .arg ( valueToString ( time , UNIT_SECONDS, 4 ) )
495
+ );
496
+ else
497
+ markerTimeLabel->setText ( " " );
498
+ if ( freqUsed )
499
+ markerFrequencyLabel->setText ( mFreq .append ( " %1 -> %2, Δf: %3 " )
500
+ .arg ( valueToString ( freq0, UNIT_HERTZ, 4 ) )
501
+ .arg ( valueToString ( freq1, UNIT_HERTZ, 4 ) )
502
+ .arg ( valueToString ( freq, UNIT_HERTZ, 4 ) )
503
+ );
504
+ else
505
+ markerFrequencyLabel->setText ( " " );
506
+ }
481
507
}
482
508
483
509
// / \brief Update the label about the trigger settings
@@ -535,6 +561,7 @@ void DsoWidget::updateVoltageDetails(ChannelID channel) {
535
561
// / \param frequencybase The frequencybase used for displaying the trace.
536
562
void DsoWidget::updateFrequencybase (double frequencybase) {
537
563
settingsFrequencybaseLabel->setText (valueToString (frequencybase, UNIT_HERTZ, -1 ) + tr (" /div" ));
564
+ updateMarkerDetails ();
538
565
}
539
566
540
567
// / \brief Updates the samplerate field after changing the samplerate.
0 commit comments