Skip to content

Commit 1c7190e

Browse files
author
David Graeff
committed
Introduce PostProcessingSettings. Remove utils/dsoStrings and add translation methods directly to the location where the relevant enums are declared. Remove union for math-channel/coupling value: Some compilers have issues here.
1 parent 9b32a46 commit 1c7190e

25 files changed

+316
-346
lines changed

openhantek/readme.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,28 @@ and the graphical part.
5252

5353
All OpenGL rendering takes place in the `GlScope` class. A helper class `GlScopeGraph` contains exactly one
5454
data sample snapshot including all channels for voltage and spectrum and a pointer to the respective GPU buffer.
55-
`GlScope` works for OpenGL 3.2 and OpenGL ES 2.0, but this needs to be decided at compile time. Usually Qt
56-
selects the right interface.
55+
`GlScope` works for OpenGL 3.2 and OpenGL ES 2.0. If both is present, OpenGL will be prefered, but can be
56+
overwritten by the user via a command flag.
57+
58+
### Export
59+
60+
All export related funtionality is within *src/exporting*.
61+
62+
The following exporters are implemented:
63+
64+
* Export to comma separated value file (CSV): Write to a user selected file,
65+
* Export to an image/pdf: Writes an image/pdf to a user selected file,
66+
* Print exporter: Creates a printable document and opens the print dialog.
67+
68+
All export classes (exportcsv, exportimage, exportprint) implement the
69+
ExporterInterface and are registered to the ExporterRegistry in the main.cpp.
70+
71+
Some export classes are still using the legacyExportDrawer class to
72+
draw the grid and paint all the labels, values and graphs.
73+
74+
The plan is to retire this legacy class and replace the paint code with
75+
a `GlScope` class shared OpenGL drawing code for at least the grid and the
76+
scope graphs.
5777

5878
## Data flow
5979

openhantek/src/configdialog/DsoConfigAnalysisPage.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ DsoConfigAnalysisPage::DsoConfigAnalysisPage(DsoSettings *settings, QWidget *par
1515
windowFunctionLabel = new QLabel(tr("Window function"));
1616
windowFunctionComboBox = new QComboBox();
1717
windowFunctionComboBox->addItems(windowFunctionStrings);
18-
windowFunctionComboBox->setCurrentIndex((int)settings->scope.spectrumWindow);
18+
windowFunctionComboBox->setCurrentIndex((int)settings->post.spectrumWindow);
1919

2020
referenceLevelLabel = new QLabel(tr("Reference level"));
2121
referenceLevelSpinBox = new QDoubleSpinBox();
2222
referenceLevelSpinBox->setDecimals(1);
2323
referenceLevelSpinBox->setMinimum(-40.0);
2424
referenceLevelSpinBox->setMaximum(100.0);
25-
referenceLevelSpinBox->setValue(settings->scope.spectrumReference);
25+
referenceLevelSpinBox->setValue(settings->post.spectrumReference);
2626
referenceLevelUnitLabel = new QLabel(tr("dBm"));
2727
referenceLevelLayout = new QHBoxLayout();
2828
referenceLevelLayout->addWidget(referenceLevelSpinBox);
@@ -33,7 +33,7 @@ DsoConfigAnalysisPage::DsoConfigAnalysisPage(DsoSettings *settings, QWidget *par
3333
minimumMagnitudeSpinBox->setDecimals(1);
3434
minimumMagnitudeSpinBox->setMinimum(-40.0);
3535
minimumMagnitudeSpinBox->setMaximum(100.0);
36-
minimumMagnitudeSpinBox->setValue(settings->scope.spectrumLimit);
36+
minimumMagnitudeSpinBox->setValue(settings->post.spectrumLimit);
3737
minimumMagnitudeUnitLabel = new QLabel(tr("dBm"));
3838
minimumMagnitudeLayout = new QHBoxLayout();
3939
minimumMagnitudeLayout->addWidget(minimumMagnitudeSpinBox);
@@ -59,7 +59,7 @@ DsoConfigAnalysisPage::DsoConfigAnalysisPage(DsoSettings *settings, QWidget *par
5959

6060
/// \brief Saves the new settings.
6161
void DsoConfigAnalysisPage::saveSettings() {
62-
settings->scope.spectrumWindow = (Dso::WindowFunction)windowFunctionComboBox->currentIndex();
63-
settings->scope.spectrumReference = referenceLevelSpinBox->value();
64-
settings->scope.spectrumLimit = minimumMagnitudeSpinBox->value();
62+
settings->post.spectrumWindow = (Dso::WindowFunction)windowFunctionComboBox->currentIndex();
63+
settings->post.spectrumReference = referenceLevelSpinBox->value();
64+
settings->post.spectrumLimit = minimumMagnitudeSpinBox->value();
6565
}

openhantek/src/docks/HorizontalDock.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "scopesettings.h"
1717
#include "sispinbox.h"
18-
#include "utils/dsoStrings.h"
1918
#include "utils/printutils.h"
2019

2120
template<typename... Args> struct SELECT {

openhantek/src/docks/SpectrumDock.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "settings.h"
1616
#include "sispinbox.h"
17-
#include "utils/dsoStrings.h"
1817
#include "utils/printutils.h"
1918

2019
template<typename... Args> struct SELECT {

openhantek/src/docks/TriggerDock.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "hantekdso/controlspecification.h"
1616
#include "settings.h"
1717
#include "sispinbox.h"
18-
#include "utils/dsoStrings.h"
1918
#include "utils/printutils.h"
2019

2120
TriggerDock::TriggerDock(DsoSettingsScope *scope, const Dso::ControlSpecification *spec, QWidget *parent,

openhantek/src/docks/VoltageDock.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "settings.h"
1616
#include "sispinbox.h"
17-
#include "utils/dsoStrings.h"
1817
#include "utils/printutils.h"
1918

2019
template<typename... Args> struct SELECT {
@@ -66,9 +65,9 @@ VoltageDock::VoltageDock(DsoSettingsScope *scope, const Dso::ControlSpecificatio
6665
dockLayout->addWidget(b.invertCheckBox, (int)channel * 3 + 2, 1);
6766

6867
if (channel < spec->channels)
69-
setCoupling(channel, scope->voltage[channel].couplingIndex);
68+
setCoupling(channel, scope->voltage[channel].couplingOrMathIndex);
7069
else
71-
setMode(scope->voltage[channel].math);
70+
setMode(scope->voltage[channel].couplingOrMathIndex);
7271
setGain(channel, scope->voltage[channel].gainStepIndex);
7372
setUsed(channel, scope->voltage[channel].used);
7473

@@ -80,12 +79,11 @@ VoltageDock::VoltageDock(DsoSettingsScope *scope, const Dso::ControlSpecificatio
8079
this->scope->voltage[channel].inverted = checked;
8180
});
8281
connect(b.miscComboBox, SELECT<int>::OVERLOAD_OF(&QComboBox::currentIndexChanged), [this,channel,spec,scope](int index){
82+
this->scope->voltage[channel].couplingOrMathIndex = (unsigned)index;
8383
if (channel < spec->channels) {
84-
this->scope->voltage[channel].couplingIndex = (unsigned)index;
8584
emit couplingChanged(channel, scope->coupling(channel, spec));
8685
} else {
87-
this->scope->voltage[channel].math = (Dso::MathMode) index;
88-
emit modeChanged(this->scope->voltage[channel].math);
86+
emit modeChanged(Dso::getMathMode(this->scope->voltage[channel]));
8987
}
9088
});
9189
connect(b.usedCheckBox, &QAbstractButton::toggled, [this,channel](bool checked) {
@@ -119,9 +117,9 @@ void VoltageDock::setGain(ChannelID channel, unsigned gainStepIndex) {
119117
channelBlocks[channel].gainComboBox->setCurrentIndex((unsigned)gainStepIndex);
120118
}
121119

122-
void VoltageDock::setMode(Dso::MathMode mode) {
120+
void VoltageDock::setMode(unsigned mathModeIndex) {
123121
QSignalBlocker blocker(channelBlocks[spec->channels].miscComboBox);
124-
channelBlocks[spec->channels].miscComboBox->setCurrentIndex((int)mode);
122+
channelBlocks[spec->channels].miscComboBox->setCurrentIndex((int)mathModeIndex);
125123
}
126124

127125
void VoltageDock::setUsed(ChannelID channel, bool used) {

openhantek/src/docks/VoltageDock.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "scopesettings.h"
1212
#include "hantekdso/controlspecification.h"
13+
#include "post/postprocessingsettings.h"
1314

1415
class SiSpinBox;
1516

@@ -28,7 +29,7 @@ class VoltageDock : public QDockWidget {
2829

2930
/// \brief Sets the coupling for a channel.
3031
/// \param channel The channel, whose coupling should be set.
31-
/// \param coupling The coupling-mode.
32+
/// \param couplingIndex The coupling-mode index.
3233
void setCoupling(ChannelID channel, unsigned couplingIndex);
3334

3435
/// \brief Sets the gain for a channel.
@@ -37,8 +38,8 @@ class VoltageDock : public QDockWidget {
3738
void setGain(ChannelID channel, unsigned gainStepIndex);
3839

3940
/// \brief Sets the mode for the math channel.
40-
/// \param mode The math-mode.
41-
void setMode(Dso::MathMode mode);
41+
/// \param mathModeIndex The math-mode index.
42+
void setMode(unsigned mathModeIndex);
4243

4344
/// \brief Enables/disables a channel.
4445
/// \param channel The channel, that should be enabled/disabled.

openhantek/src/docks/dockwindows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <cmath>
1010

11-
#include "post/enums.h"
11+
#include "post/postprocessingsettings.h"
1212
#include "hantekdso/enums.h"
1313
#include "hantekprotocol/types.h"
1414
#include "dockwindows.h"

openhantek/src/dsowidget.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
#include "dsowidget.h"
1212

13+
#include "post/postprocessingsettings.h"
1314
#include "post/graphgenerator.h"
1415
#include "post/ppresult.h"
1516

16-
#include "utils/dsoStrings.h"
1717
#include "utils/printutils.h"
1818

1919
#include "glscope.h"
@@ -252,10 +252,6 @@ void DsoWidget::setupSliders(DsoWidget::Sliders &sliders) {
252252
}
253253
}
254254

255-
void DsoWidget::setExporterForNextFrame(std::unique_ptr<Exporter> exporter) {
256-
this->exportNextFrame = std::move(exporter);
257-
}
258-
259255
/// \brief Set the trigger level sliders minimum and maximum to the new values.
260256
void DsoWidget::adaptTriggerLevelSlider(DsoWidget::Sliders &sliders, ChannelID channel) {
261257
sliders.triggerLevelSlider->setLimits((int)channel,
@@ -422,7 +418,8 @@ void DsoWidget::updateVoltageCoupling(ChannelID channel) {
422418

423419
/// \brief Handles modeChanged signal from the voltage dock.
424420
void DsoWidget::updateMathMode() {
425-
measurementMiscLabel[spec->channels]->setText(Dso::mathModeString(scope->voltage[spec->channels].math));
421+
measurementMiscLabel[spec->channels]->setText(
422+
Dso::mathModeString(Dso::getMathMode(scope->voltage[spec->channels])));
426423
}
427424

428425
/// \brief Handles gainChanged signal from the voltage dock.
@@ -486,15 +483,8 @@ void DsoWidget::updateZoom(bool enabled) {
486483

487484
/// \brief Prints analyzed data.
488485
void DsoWidget::showNew(std::shared_ptr<PPresult> data) {
489-
if (exportNextFrame) {
490-
exportNextFrame->exportSamples(data.get());
491-
exportNextFrame.reset(nullptr);
492-
}
493-
494-
mainScope->showData(data.get());
495-
mainScope->update();
496-
zoomScope->showData(data.get());
497-
zoomScope->update();
486+
mainScope->showData(data);
487+
zoomScope->showData(data);
498488

499489
if (spec->isSoftwareTriggerDevice) {
500490
QPalette triggerLabelPalette = palette();

openhantek/src/dsowidget.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <QGridLayout>
99
#include <memory>
1010

11-
#include "exporting/exporter.h"
1211
#include "glscope.h"
1312
#include "levelslider.h"
1413
#include "hantekdso/controlspecification.h"
@@ -36,7 +35,6 @@ class DsoWidget : public QWidget {
3635
/// \param parent The parent widget.
3736
/// \param flags Flags for the window manager.
3837
DsoWidget(DsoSettingsScope* scope, DsoSettingsView* view, const Dso::ControlSpecification* spec, QWidget *parent = 0, Qt::WindowFlags flags = 0);
39-
void setExporterForNextFrame(std::unique_ptr<Exporter> exporter);
4038

4139
// Data arrived
4240
void showNew(std::shared_ptr<PPresult> data);
@@ -87,7 +85,6 @@ class DsoWidget : public QWidget {
8785

8886
GlScope *mainScope; ///< The main scope screen
8987
GlScope *zoomScope; ///< The optional magnified scope screen
90-
std::unique_ptr<Exporter> exportNextFrame;
9188

9289
public slots:
9390
// Horizontal axis

0 commit comments

Comments
 (0)