Skip to content

Commit

Permalink
Minor display improvements
Browse files Browse the repository at this point in the history
Better default printer colors, better zoom window height steps

Signed-off-by: Martin <[email protected]>
  • Loading branch information
Ho-Ro committed Apr 25, 2022
1 parent f7ee66f commit 5d11ef6
Show file tree
Hide file tree
Showing 17 changed files with 367 additions and 341 deletions.
2 changes: 1 addition & 1 deletion openhantek/src/OH_BUILD.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Do not edit, will be re-created at each commit!
#define OH_BUILD "20220422 - commit 1010"
#define OH_BUILD "20220425 - commit 1011"
15 changes: 6 additions & 9 deletions openhantek/src/configdialog/DsoConfigScopePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,18 @@ DsoConfigScopePage::DsoConfigScopePage( DsoSettings *settings, QWidget *parent )
// Zoom group
zoomImageCheckBox = new QCheckBox( tr( "Export 1:1 zoomed screen in double height" ) );
zoomImageCheckBox->setChecked( settings->view.zoomImage );
zoomHeightLabel = new QLabel( tr( "Zoom area height" ) );
zoomHeightSpinBox = new QSpinBox();
zoomHeightSpinBox->setRange( 1, 20 );
zoomHeightSpinBox->setValue( settings->view.zoomHeightFactor );
zoomHeightLabel = new QLabel( tr( "Zoom area height factor" ) );
zoomHeightComboBox = new QComboBox();
zoomHeightComboBox->addItems( { "1", "2", "4", "8", "16" } );
zoomHeightComboBox->setCurrentIndex( settings->view.zoomHeightIndex );
zoomLayout = new QGridLayout();
row = 0;
zoomLayout->addWidget( zoomHeightLabel, row, 0 );
zoomLayout->addWidget( zoomHeightSpinBox, row, 1 );
zoomLayout->addWidget( zoomHeightComboBox, row, 1 );
++row;
zoomLayout->addWidget( zoomImageCheckBox, row, 0 );
zoomImageCheckBox->setVisible( 1 == settings->view.zoomHeightFactor );
zoomGroup = new QGroupBox( tr( "Zoom" ) );
zoomGroup->setLayout( zoomLayout );
connect( zoomHeightSpinBox, QOverload< int >::of( &QSpinBox::valueChanged ),
[ this ]( int value ) { this->zoomImageCheckBox->setVisible( 1 == value ); } );

// Configuration group
saveOnExitCheckBox = new QCheckBox( tr( "Save settings on exit" ) );
Expand Down Expand Up @@ -135,5 +132,5 @@ void DsoConfigScopePage::saveSettings() {
if ( defaultSettingsCheckBox->isChecked() )
settings->configVersion = 0;
settings->view.zoomImage = zoomImageCheckBox->isChecked();
settings->view.zoomHeightFactor = zoomHeightSpinBox->value();
settings->view.zoomHeightIndex = zoomHeightComboBox->currentIndex();
}
2 changes: 1 addition & 1 deletion openhantek/src/configdialog/DsoConfigScopePage.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ class DsoConfigScopePage : public QWidget {
QGroupBox *zoomGroup;
QGridLayout *zoomLayout;
QCheckBox *zoomImageCheckBox;
QSpinBox *zoomHeightSpinBox;
QComboBox *zoomHeightComboBox;
QLabel *zoomHeightLabel;
};
14 changes: 7 additions & 7 deletions openhantek/src/dsosettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ DsoSettings::DsoSettings( const ScopeDevice *scopeDevice, int verboseLevel, bool
newVoltage.name = tr( "MATH" );
scope.voltage.push_back( newVoltage );

view.screen.voltage.push_back( QColor::fromHsv( 300, 0xff, 0xff ) ); // purple
view.screen.spectrum.push_back( QColor::fromHsv( 320, 0xff, 0xff ) );
view.print.voltage.push_back( QColor::fromHsv( 300, 0xff, 0xff ) );
view.print.spectrum.push_back( QColor::fromHsv( 320, 0xff, 0xff ) );
view.screen.voltage.push_back( QColor::fromHsv( 300, 0xff, 0xff ) ); // purple (V=100%)
view.screen.spectrum.push_back( QColor::fromHsv( 300, 0xff, 0xc0 ) ); // brightness V=75%
view.print.voltage.push_back( QColor::fromHsv( 300, 0xff, 0xc0 ) ); // brightness V=75%
view.print.spectrum.push_back( QColor::fromHsv( 300, 0xff, 0x80 ) ); // brightness V=50%

// create an unique storage for this device based on device name and serial number
// individual device settings location:
Expand Down Expand Up @@ -311,8 +311,8 @@ void DsoSettings::load() {
view.printerColorImages = storeSettings->value( "printerColorImages" ).toBool();
if ( storeSettings->contains( "zoom" ) )
view.zoom = storeSettings->value( "zoom" ).toBool();
if ( storeSettings->contains( "zoomHeightFactor" ) )
view.zoomHeightFactor = storeSettings->value( "zoomHeightFactor" ).toInt();
if ( storeSettings->contains( "zoomHeightIndex" ) )
view.zoomHeightIndex = storeSettings->value( "zoomHeightIndex" ).toInt();
if ( storeSettings->contains( "zoomImage" ) )
view.zoomImage = storeSettings->value( "zoomImage" ).toBool();
if ( storeSettings->contains( "cursorGridPosition" ) )
Expand Down Expand Up @@ -477,7 +477,7 @@ void DsoSettings::save() {
storeSettings->setValue( "interpolation", view.interpolation );
storeSettings->setValue( "printerColorImages", view.printerColorImages );
storeSettings->setValue( "zoom", view.zoom );
storeSettings->setValue( "zoomHeightFactor", view.zoomHeightFactor );
storeSettings->setValue( "zoomHeightIndex", view.zoomHeightIndex );
storeSettings->setValue( "zoomImage", view.zoomImage );
storeSettings->setValue( "cursorGridPosition", view.cursorGridPosition );
storeSettings->setValue( "cursorsVisible", view.cursorsVisible );
Expand Down
21 changes: 13 additions & 8 deletions openhantek/src/dsowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void DsoWidget::restoreScreenColors() {
void DsoWidget::setColors() {
if ( scope->verboseLevel > 2 )
qDebug() << " DsoWidget::setColors()";
ChannelID numChannels = ChannelID( scope->voltage.size() );
cursorDataGrid->setBackgroundColor( view->colors->background ); // switch cursor measurement
cursorDataGrid->configureItem( 0, view->colors->text ); // and marker colors
// Palette for this widget
Expand All @@ -340,7 +341,7 @@ void DsoWidget::setColors() {
markerTimebaseLabel->setPalette( paletteNow );
markerFrequencybaseLabel->setPalette( paletteNow );
QPalette tablePalette = paletteNow;
for ( ChannelID channel = 0; channel < scope->voltage.size(); ++channel ) {
for ( ChannelID channel = 0; channel < numChannels; ++channel ) {
tablePalette.setColor( QPalette::WindowText, view->colors->spectrum[ channel ] );
measurementMagnitudeLabel[ channel ]->setPalette( tablePalette );
tablePalette.setColor( QPalette::WindowText, view->colors->voltage[ channel ] );
Expand All @@ -349,8 +350,8 @@ void DsoWidget::setColors() {
measurementGainLabel[ channel ]->setPalette( tablePalette );
mainSliders.voltageOffsetSlider->setColor( ( channel ), view->colors->voltage[ channel ] );
zoomSliders.voltageOffsetSlider->setColor( ( channel ), view->colors->voltage[ channel ] );
mainSliders.voltageOffsetSlider->setColor( unsigned( scope->voltage.size() ) + channel, view->colors->spectrum[ channel ] );
zoomSliders.voltageOffsetSlider->setColor( unsigned( scope->voltage.size() ) + channel, view->colors->spectrum[ channel ] );
mainSliders.voltageOffsetSlider->setColor( channel + numChannels, view->colors->spectrum[ channel ] );
zoomSliders.voltageOffsetSlider->setColor( channel + numChannels, view->colors->spectrum[ channel ] );
measurementVppLabel[ channel ]->setPalette( tablePalette );
measurementDCLabel[ channel ]->setPalette( tablePalette );
measurementACLabel[ channel ]->setPalette( tablePalette );
Expand All @@ -360,6 +361,9 @@ void DsoWidget::setColors() {
measurementTHDLabel[ channel ]->setPalette( tablePalette );
measurementFrequencyLabel[ channel ]->setPalette( tablePalette );
measurementNoteLabel[ channel ]->setPalette( tablePalette );
cursorDataGrid->configureItem( channel + 1, view->colors->voltage[ channel ] ); // and voltage colors
cursorDataGrid->configureItem( channel + numChannels + 1,
view->colors->spectrum[ channel ] ); // and spectrum colors
}

tablePalette = palette();
Expand Down Expand Up @@ -894,7 +898,7 @@ void DsoWidget::updateZoom( bool enabled ) {
cursorMeasurementValid = false;
showCursorMessage(); // remove dangling tool tip
// zoomed scope height in regards to main scope height if enabled, otherwise no space used
mainLayout->setRowStretch( zoomScopeRow, enabled ? view->zoomHeightFactor : 0 );
mainLayout->setRowStretch( zoomScopeRow, enabled ? int( pow( 2, view->zoomHeightIndex ) ) : 0 );
zoomScope->setVisible( enabled );
zoomSliders.voltageOffsetSlider->setVisible( enabled );
zoomSliders.triggerPositionSlider->setVisible( enabled );
Expand All @@ -908,14 +912,15 @@ void DsoWidget::updateZoom( bool enabled ) {
repaint();
}


// increase / decrease zoomed window when scrolling in the black scope border (outside the glscope)
void DsoWidget::wheelEvent( QWheelEvent *event ) {
if ( view->zoom ) {
if ( event->angleDelta().y() > 0 && view->zoomHeightFactor < 20 ) {
++view->zoomHeightFactor;
if ( event->angleDelta().y() > 0 && view->zoomHeightIndex < 4 ) {
++view->zoomHeightIndex;
updateZoom( true );
} else if ( event->angleDelta().y() < 0 && view->zoomHeightFactor > 1 ) {
--view->zoomHeightFactor;
} else if ( event->angleDelta().y() < 0 && view->zoomHeightIndex > 0 ) {
--view->zoomHeightIndex;
updateZoom( true );
}
}
Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/glscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ void GlScope::drawVertices( QOpenGLFunctions *gl, int marker, QColor color ) {
m_program->setUniformValue( colorLocation, ( marker == selectedCursor ) ? color : color.darker() );
gl->glDrawArrays( GL_LINE_LOOP, GLint( marker * VERTICES_ARRAY_SIZE ), GLint( VERTICES_ARRAY_SIZE ) );
if ( cursorInfo[ size_t( marker ) ]->shape == DsoSettingsScopeCursor::RECTANGULAR ) {
color.setAlphaF( 0.25 );
color.setAlphaF( 0.5 ); // increase this value if you encounter hardcopy/print artefacts (?)
m_program->setUniformValue( colorLocation, color.darker() );
gl->glDrawArrays( GL_TRIANGLE_FAN, GLint( marker * VERTICES_ARRAY_SIZE ), GLint( VERTICES_ARRAY_SIZE ) );
}
Expand Down
12 changes: 6 additions & 6 deletions openhantek/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,19 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
if ( dsoSettings->scope.toolTipVisible )
ui->actionSampling->setToolTip( tr( "Start and stop the sampling" ) );
else
ui->actionHistogram->setToolTip( QString() );
ui->actionSampling->setToolTip( QString() );
ui->actionRefresh->setIcon( QIcon( iconPath + "refresh.svg" ) );
ui->actionRefresh->setShortcut( Qt::Key::Key_R );
if ( dsoSettings->scope.toolTipVisible )
ui->actionRefresh->setToolTip( tr( "Refresh the screen trace for slow 'Roll' mode" ) );
else
ui->actionHistogram->setToolTip( QString() );
ui->actionRefresh->setToolTip( QString() );
ui->actionPhosphor->setIcon( QIcon( iconPath + "phosphor.svg" ) );
ui->actionPhosphor->setShortcut( Qt::Key::Key_P );
if ( dsoSettings->scope.toolTipVisible )
ui->actionPhosphor->setToolTip( tr( "Let the traces fade out slowly" ) );
else
ui->actionHistogram->setToolTip( QString() );
ui->actionPhosphor->setToolTip( QString() );
ui->actionHistogram->setIcon( QIcon( iconPath + "histogram.svg" ) );
ui->actionHistogram->setShortcut( Qt::Key::Key_H );
if ( dsoSettings->scope.toolTipVisible )
Expand All @@ -98,13 +98,13 @@ MainWindow::MainWindow( HantekDsoControl *dsoControl, DsoSettings *settings, Exp
if ( dsoSettings->scope.toolTipVisible )
ui->actionZoom->setToolTip( tr( "Zoom the range between the markers '1' and '2'" ) );
else
ui->actionHistogram->setToolTip( QString() );
ui->actionZoom->setToolTip( QString() );
ui->actionMeasure->setIcon( QIcon( iconPath + "measure.svg" ) );
ui->actionMeasure->setShortcut( Qt::Key::Key_M );
if ( dsoSettings->scope.toolTipVisible )
ui->actionMeasure->setToolTip( tr( "Enable cursor measurements" ) );
else
ui->actionHistogram->setToolTip( QString() );
ui->actionMeasure->setToolTip( QString() );
ui->actionOpen->setIcon( iconFont->icon( fa::folderopen, colorMap ) );
ui->actionOpen->setToolTip( tr( "Load scope settings from a config file" ) );
ui->actionSave->setIcon( iconFont->icon( fa::save, colorMap ) );
Expand Down Expand Up @@ -575,7 +575,7 @@ void MainWindow::screenShot( screenshotType_t screenshotType, bool autoSafe ) {
int sw = screenshot.width();
int sh = screenshot.height();
if ( screenshotType != SCREENSHOT && dsoSettings->view.zoom && dsoSettings->view.zoomImage &&
dsoSettings->view.zoomHeightFactor == 1 ) {
dsoSettings->view.zoomHeightIndex == 0 ) {
screenshot = screenshot.scaled( sw, sh *= 2 ); // make double height
}

Expand Down
2 changes: 1 addition & 1 deletion openhantek/src/viewsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct DsoSettingsView {
unsigned digitalPhosphorDepth = 8; ///< Number of channels shown at one time
Dso::InterpolationMode interpolation = Dso::INTERPOLATION_LINEAR; ///< Interpolation mode for the graph
bool printerColorImages = true; ///< Exports images with screen colors
int zoomHeightFactor = 4; ///< Zoom scope window height
int zoomHeightIndex = 2; ///< Zoom scope window height
bool zoomImage = true; ///< Export zoomed images with double height
bool zoom = false; ///< true if the magnified scope is enabled
Qt::ToolBarArea cursorGridPosition = Qt::RightToolBarArea;
Expand Down
Loading

0 comments on commit 5d11ef6

Please sign in to comment.