Commit 4691d3823f41a0f254a0e793a8955a259a9d85cb
Committed by
David Gräff
1 parent
aa138ea1
Correct signess and compile errors structs vs class
Showing
22 changed files
with
240 additions
and
329 deletions
openhantek/src/configdialog/DsoConfigColorsPage.cpp
| @@ -51,7 +51,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) | @@ -51,7 +51,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) | ||
| 51 | printSpectrumLabel = new QLabel(tr("Spectrum")); | 51 | printSpectrumLabel = new QLabel(tr("Spectrum")); |
| 52 | printSpectrumLabel->setAlignment(Qt::AlignHCenter); | 52 | printSpectrumLabel->setAlignment(Qt::AlignHCenter); |
| 53 | 53 | ||
| 54 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 54 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 55 | colorLabel.append(new QLabel(settings->scope.voltage[channel].name)); | 55 | colorLabel.append(new QLabel(settings->scope.voltage[channel].name)); |
| 56 | screenChannelColorBox.append(new ColorBox(colorSettings.screen.voltage[channel])); | 56 | screenChannelColorBox.append(new ColorBox(colorSettings.screen.voltage[channel])); |
| 57 | screenSpectrumColorBox.append(new ColorBox(colorSettings.screen.spectrum[channel])); | 57 | screenSpectrumColorBox.append(new ColorBox(colorSettings.screen.spectrum[channel])); |
| @@ -106,7 +106,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) | @@ -106,7 +106,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) | ||
| 106 | colorsLayout->addWidget(printSpectrumLabel, row, COL_PRT_SPECTRUM); | 106 | colorsLayout->addWidget(printSpectrumLabel, row, COL_PRT_SPECTRUM); |
| 107 | ++row; | 107 | ++row; |
| 108 | 108 | ||
| 109 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel, ++row) { | 109 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel, ++row) { |
| 110 | colorsLayout->addWidget(colorLabel[channel], row, COL_LABEL); | 110 | colorsLayout->addWidget(colorLabel[channel], row, COL_LABEL); |
| 111 | colorsLayout->addWidget(screenChannelColorBox[channel], row, COL_SCR_CHANNEL); | 111 | colorsLayout->addWidget(screenChannelColorBox[channel], row, COL_SCR_CHANNEL); |
| 112 | colorsLayout->addWidget(screenSpectrumColorBox[channel], row, COL_SCR_SPECTRUM); | 112 | colorsLayout->addWidget(screenSpectrumColorBox[channel], row, COL_SCR_SPECTRUM); |
| @@ -146,7 +146,7 @@ void DsoConfigColorsPage::saveSettings() { | @@ -146,7 +146,7 @@ void DsoConfigColorsPage::saveSettings() { | ||
| 146 | colorSettings.print.text = printTextColorBox->getColor(); | 146 | colorSettings.print.text = printTextColorBox->getColor(); |
| 147 | 147 | ||
| 148 | // Graph category | 148 | // Graph category |
| 149 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 149 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 150 | colorSettings.screen.voltage[channel] = screenChannelColorBox[channel]->getColor(); | 150 | colorSettings.screen.voltage[channel] = screenChannelColorBox[channel]->getColor(); |
| 151 | colorSettings.screen.spectrum[channel] = screenSpectrumColorBox[channel]->getColor(); | 151 | colorSettings.screen.spectrum[channel] = screenSpectrumColorBox[channel]->getColor(); |
| 152 | colorSettings.print.voltage[channel] = printChannelColorBox[channel]->getColor(); | 152 | colorSettings.print.voltage[channel] = printChannelColorBox[channel]->getColor(); |
openhantek/src/docks/SpectrumDock.cpp
| @@ -33,7 +33,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | @@ -33,7 +33,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | ||
| 33 | this->magnitudeStrings << valueToString(*magnitude, UNIT_DECIBEL, 0); | 33 | this->magnitudeStrings << valueToString(*magnitude, UNIT_DECIBEL, 0); |
| 34 | 34 | ||
| 35 | // Initialize elements | 35 | // Initialize elements |
| 36 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 36 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 37 | this->magnitudeComboBox.append(new QComboBox()); | 37 | this->magnitudeComboBox.append(new QComboBox()); |
| 38 | this->magnitudeComboBox[channel]->addItems(this->magnitudeStrings); | 38 | this->magnitudeComboBox[channel]->addItems(this->magnitudeStrings); |
| 39 | 39 | ||
| @@ -43,7 +43,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | @@ -43,7 +43,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | ||
| 43 | this->dockLayout = new QGridLayout(); | 43 | this->dockLayout = new QGridLayout(); |
| 44 | this->dockLayout->setColumnMinimumWidth(0, 64); | 44 | this->dockLayout->setColumnMinimumWidth(0, 64); |
| 45 | this->dockLayout->setColumnStretch(1, 1); | 45 | this->dockLayout->setColumnStretch(1, 1); |
| 46 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 46 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 47 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel, 0); | 47 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel, 0); |
| 48 | this->dockLayout->addWidget(this->magnitudeComboBox[channel], channel, 1); | 48 | this->dockLayout->addWidget(this->magnitudeComboBox[channel], channel, 1); |
| 49 | } | 49 | } |
| @@ -52,13 +52,13 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | @@ -52,13 +52,13 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla | ||
| 52 | SetupDockWidget(this, dockWidget, dockLayout); | 52 | SetupDockWidget(this, dockWidget, dockLayout); |
| 53 | 53 | ||
| 54 | // Connect signals and slots | 54 | // Connect signals and slots |
| 55 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 55 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 56 | connect(this->magnitudeComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(magnitudeSelected(int))); | 56 | connect(this->magnitudeComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(magnitudeSelected(int))); |
| 57 | connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); | 57 | connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | // Set values | 60 | // Set values |
| 61 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 61 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 62 | this->setMagnitude(channel, settings->scope.spectrum[channel].magnitude); | 62 | this->setMagnitude(channel, settings->scope.spectrum[channel].magnitude); |
| 63 | this->setUsed(channel, settings->scope.spectrum[channel].used); | 63 | this->setUsed(channel, settings->scope.spectrum[channel].used); |
| 64 | } | 64 | } |
| @@ -77,7 +77,7 @@ void SpectrumDock::closeEvent(QCloseEvent *event) { | @@ -77,7 +77,7 @@ void SpectrumDock::closeEvent(QCloseEvent *event) { | ||
| 77 | /// \param magnitude The magnitude in dB. | 77 | /// \param magnitude The magnitude in dB. |
| 78 | /// \return Index of magnitude-value, -1 on error. | 78 | /// \return Index of magnitude-value, -1 on error. |
| 79 | int SpectrumDock::setMagnitude(int channel, double magnitude) { | 79 | int SpectrumDock::setMagnitude(int channel, double magnitude) { |
| 80 | - if (channel < 0 || channel >= settings->scope.voltage.count()) return -1; | 80 | + if (channel < 0 || channel >= settings->scope.voltage.size()) return -1; |
| 81 | 81 | ||
| 82 | int index = this->magnitudeSteps.indexOf(magnitude); | 82 | int index = this->magnitudeSteps.indexOf(magnitude); |
| 83 | if (index != -1) this->magnitudeComboBox[channel]->setCurrentIndex(index); | 83 | if (index != -1) this->magnitudeComboBox[channel]->setCurrentIndex(index); |
| @@ -90,7 +90,7 @@ int SpectrumDock::setMagnitude(int channel, double magnitude) { | @@ -90,7 +90,7 @@ int SpectrumDock::setMagnitude(int channel, double magnitude) { | ||
| 90 | /// \param used True if the channel should be enabled, false otherwise. | 90 | /// \param used True if the channel should be enabled, false otherwise. |
| 91 | /// \return Index of channel, -1 on error. | 91 | /// \return Index of channel, -1 on error. |
| 92 | int SpectrumDock::setUsed(int channel, bool used) { | 92 | int SpectrumDock::setUsed(int channel, bool used) { |
| 93 | - if (channel >= 0 && channel < settings->scope.voltage.count()) { | 93 | + if (channel >= 0 && channel < settings->scope.voltage.size()) { |
| 94 | this->usedCheckBox[channel]->setChecked(used); | 94 | this->usedCheckBox[channel]->setChecked(used); |
| 95 | return channel; | 95 | return channel; |
| 96 | } | 96 | } |
| @@ -104,11 +104,11 @@ void SpectrumDock::magnitudeSelected(int index) { | @@ -104,11 +104,11 @@ void SpectrumDock::magnitudeSelected(int index) { | ||
| 104 | int channel; | 104 | int channel; |
| 105 | 105 | ||
| 106 | // Which combobox was it? | 106 | // Which combobox was it? |
| 107 | - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) | 107 | + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) |
| 108 | if (this->sender() == this->magnitudeComboBox[channel]) break; | 108 | if (this->sender() == this->magnitudeComboBox[channel]) break; |
| 109 | 109 | ||
| 110 | // Send signal if it was one of the comboboxes | 110 | // Send signal if it was one of the comboboxes |
| 111 | - if (channel < settings->scope.voltage.count()) { | 111 | + if (channel < settings->scope.voltage.size()) { |
| 112 | settings->scope.spectrum[channel].magnitude = this->magnitudeSteps.at(index); | 112 | settings->scope.spectrum[channel].magnitude = this->magnitudeSteps.at(index); |
| 113 | emit magnitudeChanged(channel, settings->scope.spectrum[channel].magnitude); | 113 | emit magnitudeChanged(channel, settings->scope.spectrum[channel].magnitude); |
| 114 | } | 114 | } |
| @@ -120,11 +120,11 @@ void SpectrumDock::usedSwitched(bool checked) { | @@ -120,11 +120,11 @@ void SpectrumDock::usedSwitched(bool checked) { | ||
| 120 | int channel; | 120 | int channel; |
| 121 | 121 | ||
| 122 | // Which checkbox was it? | 122 | // Which checkbox was it? |
| 123 | - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) | 123 | + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) |
| 124 | if (this->sender() == this->usedCheckBox[channel]) break; | 124 | if (this->sender() == this->usedCheckBox[channel]) break; |
| 125 | 125 | ||
| 126 | // Send signal if it was one of the checkboxes | 126 | // Send signal if it was one of the checkboxes |
| 127 | - if (channel < settings->scope.voltage.count()) { | 127 | + if (channel < settings->scope.voltage.size()) { |
| 128 | settings->scope.spectrum[channel].used = checked; | 128 | settings->scope.spectrum[channel].used = checked; |
| 129 | emit usedChanged(channel, checked); | 129 | emit usedChanged(channel, checked); |
| 130 | } | 130 | } |
openhantek/src/docks/VoltageDock.cpp
| @@ -38,7 +38,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | @@ -38,7 +38,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | ||
| 38 | this->gainStrings << valueToString(*gain, UNIT_VOLTS, 0); | 38 | this->gainStrings << valueToString(*gain, UNIT_VOLTS, 0); |
| 39 | 39 | ||
| 40 | // Initialize elements | 40 | // Initialize elements |
| 41 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 41 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 42 | this->miscComboBox.append(new QComboBox()); | 42 | this->miscComboBox.append(new QComboBox()); |
| 43 | if (channel < (int)settings->scope.physicalChannels) | 43 | if (channel < (int)settings->scope.physicalChannels) |
| 44 | this->miscComboBox[channel]->addItems(this->couplingStrings); | 44 | this->miscComboBox[channel]->addItems(this->couplingStrings); |
| @@ -56,7 +56,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | @@ -56,7 +56,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | ||
| 56 | this->dockLayout = new QGridLayout(); | 56 | this->dockLayout = new QGridLayout(); |
| 57 | this->dockLayout->setColumnMinimumWidth(0, 64); | 57 | this->dockLayout->setColumnMinimumWidth(0, 64); |
| 58 | this->dockLayout->setColumnStretch(1, 1); | 58 | this->dockLayout->setColumnStretch(1, 1); |
| 59 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 59 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 60 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel * 3, 0); | 60 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel * 3, 0); |
| 61 | this->dockLayout->addWidget(this->gainComboBox[channel], channel * 3, 1); | 61 | this->dockLayout->addWidget(this->gainComboBox[channel], channel * 3, 1); |
| 62 | this->dockLayout->addWidget(this->miscComboBox[channel], channel * 3 + 1, 1); | 62 | this->dockLayout->addWidget(this->miscComboBox[channel], channel * 3 + 1, 1); |
| @@ -67,7 +67,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | @@ -67,7 +67,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | ||
| 67 | SetupDockWidget(this, dockWidget, dockLayout); | 67 | SetupDockWidget(this, dockWidget, dockLayout); |
| 68 | 68 | ||
| 69 | // Connect signals and slots | 69 | // Connect signals and slots |
| 70 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 70 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 71 | connect(this->gainComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(gainSelected(int))); | 71 | connect(this->gainComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(gainSelected(int))); |
| 72 | connect(this->invertCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(invertSwitched(bool))); | 72 | connect(this->invertCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(invertSwitched(bool))); |
| 73 | connect(this->miscComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(miscSelected(int))); | 73 | connect(this->miscComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(miscSelected(int))); |
| @@ -75,7 +75,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | @@ -75,7 +75,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags | ||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | // Set values | 77 | // Set values |
| 78 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 78 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 79 | if (channel < (int)settings->scope.physicalChannels) | 79 | if (channel < (int)settings->scope.physicalChannels) |
| 80 | this->setCoupling(channel, settings->scope.voltage[channel].coupling); | 80 | this->setCoupling(channel, settings->scope.voltage[channel].coupling); |
| 81 | else | 81 | else |
| @@ -110,7 +110,7 @@ int VoltageDock::setCoupling(int channel, Dso::Coupling coupling) { | @@ -110,7 +110,7 @@ int VoltageDock::setCoupling(int channel, Dso::Coupling coupling) { | ||
| 110 | /// \param gain The gain in volts. | 110 | /// \param gain The gain in volts. |
| 111 | /// \return Index of gain-value, -1 on error. | 111 | /// \return Index of gain-value, -1 on error. |
| 112 | int VoltageDock::setGain(int channel, double gain) { | 112 | int VoltageDock::setGain(int channel, double gain) { |
| 113 | - if (channel < 0 || channel >= settings->scope.voltage.count()) return -1; | 113 | + if (channel < 0 || channel >= settings->scope.voltage.size()) return -1; |
| 114 | 114 | ||
| 115 | int index = this->gainSteps.indexOf(gain); | 115 | int index = this->gainSteps.indexOf(gain); |
| 116 | if (index != -1) this->gainComboBox[channel]->setCurrentIndex(index); | 116 | if (index != -1) this->gainComboBox[channel]->setCurrentIndex(index); |
| @@ -130,7 +130,7 @@ void VoltageDock::setMode(Dso::MathMode mode) { | @@ -130,7 +130,7 @@ void VoltageDock::setMode(Dso::MathMode mode) { | ||
| 130 | /// \param used True if the channel should be enabled, false otherwise. | 130 | /// \param used True if the channel should be enabled, false otherwise. |
| 131 | /// \return Index of channel, -1 on error. | 131 | /// \return Index of channel, -1 on error. |
| 132 | int VoltageDock::setUsed(int channel, bool used) { | 132 | int VoltageDock::setUsed(int channel, bool used) { |
| 133 | - if (channel >= 0 && channel < settings->scope.voltage.count()) { | 133 | + if (channel >= 0 && channel < settings->scope.voltage.size()) { |
| 134 | this->usedCheckBox[channel]->setChecked(used); | 134 | this->usedCheckBox[channel]->setChecked(used); |
| 135 | return channel; | 135 | return channel; |
| 136 | } | 136 | } |
| @@ -144,11 +144,11 @@ void VoltageDock::gainSelected(int index) { | @@ -144,11 +144,11 @@ void VoltageDock::gainSelected(int index) { | ||
| 144 | int channel; | 144 | int channel; |
| 145 | 145 | ||
| 146 | // Which combobox was it? | 146 | // Which combobox was it? |
| 147 | - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) | 147 | + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) |
| 148 | if (this->sender() == this->gainComboBox[channel]) break; | 148 | if (this->sender() == this->gainComboBox[channel]) break; |
| 149 | 149 | ||
| 150 | // Send signal if it was one of the comboboxes | 150 | // Send signal if it was one of the comboboxes |
| 151 | - if (channel < settings->scope.voltage.count()) { | 151 | + if (channel < settings->scope.voltage.size()) { |
| 152 | settings->scope.voltage[channel].gain = this->gainSteps.at(index); | 152 | settings->scope.voltage[channel].gain = this->gainSteps.at(index); |
| 153 | 153 | ||
| 154 | emit gainChanged(channel, settings->scope.voltage[channel].gain); | 154 | emit gainChanged(channel, settings->scope.voltage[channel].gain); |
| @@ -161,11 +161,11 @@ void VoltageDock::miscSelected(int index) { | @@ -161,11 +161,11 @@ void VoltageDock::miscSelected(int index) { | ||
| 161 | int channel; | 161 | int channel; |
| 162 | 162 | ||
| 163 | // Which combobox was it? | 163 | // Which combobox was it? |
| 164 | - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) | 164 | + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) |
| 165 | if (this->sender() == this->miscComboBox[channel]) break; | 165 | if (this->sender() == this->miscComboBox[channel]) break; |
| 166 | 166 | ||
| 167 | // Send signal if it was one of the comboboxes | 167 | // Send signal if it was one of the comboboxes |
| 168 | - if (channel < settings->scope.voltage.count()) { | 168 | + if (channel < settings->scope.voltage.size()) { |
| 169 | if (channel < (int)settings->scope.physicalChannels) { | 169 | if (channel < (int)settings->scope.physicalChannels) { |
| 170 | settings->scope.voltage[channel].coupling = (Dso::Coupling) index; | 170 | settings->scope.voltage[channel].coupling = (Dso::Coupling) index; |
| 171 | emit couplingChanged(channel, settings->scope.voltage[channel].coupling); | 171 | emit couplingChanged(channel, settings->scope.voltage[channel].coupling); |
| @@ -182,11 +182,11 @@ void VoltageDock::usedSwitched(bool checked) { | @@ -182,11 +182,11 @@ void VoltageDock::usedSwitched(bool checked) { | ||
| 182 | int channel; | 182 | int channel; |
| 183 | 183 | ||
| 184 | // Which checkbox was it? | 184 | // Which checkbox was it? |
| 185 | - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) | 185 | + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) |
| 186 | if (this->sender() == this->usedCheckBox[channel]) break; | 186 | if (this->sender() == this->usedCheckBox[channel]) break; |
| 187 | 187 | ||
| 188 | // Send signal if it was one of the checkboxes | 188 | // Send signal if it was one of the checkboxes |
| 189 | - if (channel < settings->scope.voltage.count()) { | 189 | + if (channel < settings->scope.voltage.size()) { |
| 190 | settings->scope.voltage[channel].used = checked; | 190 | settings->scope.voltage[channel].used = checked; |
| 191 | emit usedChanged(channel, checked); | 191 | emit usedChanged(channel, checked); |
| 192 | } | 192 | } |
| @@ -198,11 +198,11 @@ void VoltageDock::invertSwitched(bool checked) { | @@ -198,11 +198,11 @@ void VoltageDock::invertSwitched(bool checked) { | ||
| 198 | int channel; | 198 | int channel; |
| 199 | 199 | ||
| 200 | // Which checkbox was it? | 200 | // Which checkbox was it? |
| 201 | - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) | 201 | + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) |
| 202 | if (this->sender() == this->invertCheckBox[channel]) break; | 202 | if (this->sender() == this->invertCheckBox[channel]) break; |
| 203 | 203 | ||
| 204 | // Send signal if it was one of the checkboxes | 204 | // Send signal if it was one of the checkboxes |
| 205 | - if (channel < settings->scope.voltage.count()) { | 205 | + if (channel < settings->scope.voltage.size()) { |
| 206 | settings->scope.voltage[channel].inverted = checked; | 206 | settings->scope.voltage[channel].inverted = checked; |
| 207 | // Should we emit an event here? | 207 | // Should we emit an event here? |
| 208 | } | 208 | } |
openhantek/src/dsowidget.cpp
| @@ -31,21 +31,21 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | @@ -31,21 +31,21 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | ||
| 31 | 31 | ||
| 32 | // The offset sliders for all possible channels | 32 | // The offset sliders for all possible channels |
| 33 | offsetSlider = new LevelSlider(Qt::RightArrow); | 33 | offsetSlider = new LevelSlider(Qt::RightArrow); |
| 34 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 34 | + for (unsigned channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 35 | offsetSlider->addSlider(settings->scope.voltage[channel].name, channel); | 35 | offsetSlider->addSlider(settings->scope.voltage[channel].name, channel); |
| 36 | offsetSlider->setColor(channel, settings->view.screen.voltage[channel]); | 36 | offsetSlider->setColor(channel, settings->view.screen.voltage[channel]); |
| 37 | offsetSlider->setLimits(channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); | 37 | offsetSlider->setLimits(channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); |
| 38 | offsetSlider->setStep(channel, 0.2); | 38 | offsetSlider->setStep(channel, 0.2); |
| 39 | offsetSlider->setValue(channel, settings->scope.voltage[channel].offset); | 39 | offsetSlider->setValue(channel, settings->scope.voltage[channel].offset); |
| 40 | - offsetSlider->setVisible(channel, settings->scope.voltage[channel].used); | 40 | + offsetSlider->setIndexVisible(channel, settings->scope.voltage[channel].used); |
| 41 | } | 41 | } |
| 42 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | ||
| 43 | - offsetSlider->addSlider(settings->scope.spectrum[channel].name, settings->scope.voltage.count() + channel); | ||
| 44 | - offsetSlider->setColor(settings->scope.voltage.count() + channel, settings->view.screen.spectrum[channel]); | ||
| 45 | - offsetSlider->setLimits(settings->scope.voltage.count() + channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); | ||
| 46 | - offsetSlider->setStep(settings->scope.voltage.count() + channel, 0.2); | ||
| 47 | - offsetSlider->setValue(settings->scope.voltage.count() + channel, settings->scope.spectrum[channel].offset); | ||
| 48 | - offsetSlider->setVisible(settings->scope.voltage.count() + channel, settings->scope.spectrum[channel].used); | 42 | + for (unsigned channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 43 | + offsetSlider->addSlider(settings->scope.spectrum[channel].name, settings->scope.voltage.size() + channel); | ||
| 44 | + offsetSlider->setColor(settings->scope.voltage.size() + channel, settings->view.screen.spectrum[channel]); | ||
| 45 | + offsetSlider->setLimits(settings->scope.voltage.size() + channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); | ||
| 46 | + offsetSlider->setStep(settings->scope.voltage.size() + channel, 0.2); | ||
| 47 | + offsetSlider->setValue(settings->scope.voltage.size() + channel, settings->scope.spectrum[channel].offset); | ||
| 48 | + offsetSlider->setIndexVisible(settings->scope.voltage.size() + channel, settings->scope.spectrum[channel].used); | ||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | // The triggerPosition slider | 51 | // The triggerPosition slider |
| @@ -54,7 +54,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | @@ -54,7 +54,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | ||
| 54 | triggerPositionSlider->setLimits(0, 0.0, 1.0); | 54 | triggerPositionSlider->setLimits(0, 0.0, 1.0); |
| 55 | triggerPositionSlider->setStep(0, 0.2 / DIVS_TIME); | 55 | triggerPositionSlider->setStep(0, 0.2 / DIVS_TIME); |
| 56 | triggerPositionSlider->setValue(0, settings->scope.trigger.position); | 56 | triggerPositionSlider->setValue(0, settings->scope.trigger.position); |
| 57 | - triggerPositionSlider->setVisible(0, true); | 57 | + triggerPositionSlider->setIndexVisible(0, true); |
| 58 | 58 | ||
| 59 | // The sliders for the trigger levels | 59 | // The sliders for the trigger levels |
| 60 | triggerLevelSlider = new LevelSlider(Qt::LeftArrow); | 60 | triggerLevelSlider = new LevelSlider(Qt::LeftArrow); |
| @@ -67,7 +67,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | @@ -67,7 +67,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | ||
| 67 | : settings->view.screen.voltage[channel].darker()); | 67 | : settings->view.screen.voltage[channel].darker()); |
| 68 | adaptTriggerLevelSlider(channel); | 68 | adaptTriggerLevelSlider(channel); |
| 69 | triggerLevelSlider->setValue(channel, settings->scope.voltage[channel].trigger); | 69 | triggerLevelSlider->setValue(channel, settings->scope.voltage[channel].trigger); |
| 70 | - triggerLevelSlider->setVisible(channel, settings->scope.voltage[channel].used); | 70 | + triggerLevelSlider->setIndexVisible(channel, settings->scope.voltage[channel].used); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | // The marker slider | 73 | // The marker slider |
| @@ -77,7 +77,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | @@ -77,7 +77,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | ||
| 77 | markerSlider->setLimits(marker, -DIVS_TIME / 2, DIVS_TIME / 2); | 77 | markerSlider->setLimits(marker, -DIVS_TIME / 2, DIVS_TIME / 2); |
| 78 | markerSlider->setStep(marker, 0.2); | 78 | markerSlider->setStep(marker, 0.2); |
| 79 | markerSlider->setValue(marker, settings->scope.horizontal.marker[marker]); | 79 | markerSlider->setValue(marker, settings->scope.horizontal.marker[marker]); |
| 80 | - markerSlider->setVisible(marker, true); | 80 | + markerSlider->setIndexVisible(marker, true); |
| 81 | settings->scope.horizontal.marker_visible[marker] = true; | 81 | settings->scope.horizontal.marker_visible[marker] = true; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| @@ -135,7 +135,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | @@ -135,7 +135,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | ||
| 135 | measurementLayout->setColumnStretch(3, 2); | 135 | measurementLayout->setColumnStretch(3, 2); |
| 136 | measurementLayout->setColumnStretch(4, 3); | 136 | measurementLayout->setColumnStretch(4, 3); |
| 137 | measurementLayout->setColumnStretch(5, 3); | 137 | measurementLayout->setColumnStretch(5, 3); |
| 138 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 138 | + for (int channel = 0; channel < (int)settings->scope.voltage.size(); ++channel) { |
| 139 | tablePalette.setColor(QPalette::WindowText, settings->view.screen.voltage[channel]); | 139 | tablePalette.setColor(QPalette::WindowText, settings->view.screen.voltage[channel]); |
| 140 | measurementNameLabel.append(new QLabel(settings->scope.voltage[channel].name)); | 140 | measurementNameLabel.append(new QLabel(settings->scope.voltage[channel].name)); |
| 141 | measurementNameLabel[channel]->setPalette(tablePalette); | 141 | measurementNameLabel[channel]->setPalette(tablePalette); |
| @@ -161,12 +161,12 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | @@ -161,12 +161,12 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla | ||
| 161 | measurementLayout->addWidget(measurementMagnitudeLabel[channel], channel, 3); | 161 | measurementLayout->addWidget(measurementMagnitudeLabel[channel], channel, 3); |
| 162 | measurementLayout->addWidget(measurementAmplitudeLabel[channel], channel, 4); | 162 | measurementLayout->addWidget(measurementAmplitudeLabel[channel], channel, 4); |
| 163 | measurementLayout->addWidget(measurementFrequencyLabel[channel], channel, 5); | 163 | measurementLayout->addWidget(measurementFrequencyLabel[channel], channel, 5); |
| 164 | - if ((unsigned int)channel < settings->scope.physicalChannels) | ||
| 165 | - updateVoltageCoupling(channel); | 164 | + if ((unsigned)channel < settings->scope.physicalChannels) |
| 165 | + updateVoltageCoupling((unsigned)channel); | ||
| 166 | else | 166 | else |
| 167 | updateMathMode(); | 167 | updateMathMode(); |
| 168 | - updateVoltageDetails(channel); | ||
| 169 | - updateSpectrumDetails(channel); | 168 | + updateVoltageDetails((unsigned)channel); |
| 169 | + updateSpectrumDetails((unsigned)channel); | ||
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | // The layout for the widgets | 172 | // The layout for the widgets |
| @@ -293,7 +293,7 @@ void DsoWidget::updateTriggerDetails() { | @@ -293,7 +293,7 @@ void DsoWidget::updateTriggerDetails() { | ||
| 293 | 293 | ||
| 294 | /// \brief Update the label about the trigger settings | 294 | /// \brief Update the label about the trigger settings |
| 295 | void DsoWidget::updateVoltageDetails(unsigned int channel) { | 295 | void DsoWidget::updateVoltageDetails(unsigned int channel) { |
| 296 | - if (channel >= (unsigned int)settings->scope.voltage.count()) return; | 296 | + if (channel >= (unsigned int)settings->scope.voltage.size()) return; |
| 297 | 297 | ||
| 298 | setMeasurementVisible(channel, settings->scope.voltage[channel].used || settings->scope.spectrum[channel].used); | 298 | setMeasurementVisible(channel, settings->scope.voltage[channel].used || settings->scope.spectrum[channel].used); |
| 299 | 299 | ||
| @@ -332,9 +332,9 @@ void DsoWidget::updateSpectrumMagnitude(unsigned int channel) { updateSpectrumDe | @@ -332,9 +332,9 @@ void DsoWidget::updateSpectrumMagnitude(unsigned int channel) { updateSpectrumDe | ||
| 332 | /// \param channel The channel whose used-state was changed. | 332 | /// \param channel The channel whose used-state was changed. |
| 333 | /// \param used The new used-state for the channel. | 333 | /// \param used The new used-state for the channel. |
| 334 | void DsoWidget::updateSpectrumUsed(unsigned int channel, bool used) { | 334 | void DsoWidget::updateSpectrumUsed(unsigned int channel, bool used) { |
| 335 | - if (channel >= (unsigned int)settings->scope.voltage.count()) return; | 335 | + if (channel >= (unsigned int)settings->scope.voltage.size()) return; |
| 336 | 336 | ||
| 337 | - offsetSlider->setVisible(settings->scope.voltage.count() + channel, used); | 337 | + offsetSlider->setIndexVisible(settings->scope.voltage.size() + channel, used); |
| 338 | 338 | ||
| 339 | updateSpectrumDetails(channel); | 339 | updateSpectrumDetails(channel); |
| 340 | } | 340 | } |
| @@ -366,7 +366,7 @@ void DsoWidget::updateTriggerSource() { | @@ -366,7 +366,7 @@ void DsoWidget::updateTriggerSource() { | ||
| 366 | /// \brief Handles couplingChanged signal from the voltage dock. | 366 | /// \brief Handles couplingChanged signal from the voltage dock. |
| 367 | /// \param channel The channel whose coupling was changed. | 367 | /// \param channel The channel whose coupling was changed. |
| 368 | void DsoWidget::updateVoltageCoupling(unsigned int channel) { | 368 | void DsoWidget::updateVoltageCoupling(unsigned int channel) { |
| 369 | - if (channel >= (unsigned int)settings->scope.voltage.count()) return; | 369 | + if (channel >= (unsigned int)settings->scope.voltage.size()) return; |
| 370 | 370 | ||
| 371 | measurementMiscLabel[channel]->setText(Dso::couplingString(settings->scope.voltage[channel].coupling)); | 371 | measurementMiscLabel[channel]->setText(Dso::couplingString(settings->scope.voltage[channel].coupling)); |
| 372 | } | 372 | } |
| @@ -380,7 +380,7 @@ void DsoWidget::updateMathMode() { | @@ -380,7 +380,7 @@ void DsoWidget::updateMathMode() { | ||
| 380 | /// \brief Handles gainChanged signal from the voltage dock. | 380 | /// \brief Handles gainChanged signal from the voltage dock. |
| 381 | /// \param channel The channel whose gain was changed. | 381 | /// \param channel The channel whose gain was changed. |
| 382 | void DsoWidget::updateVoltageGain(unsigned int channel) { | 382 | void DsoWidget::updateVoltageGain(unsigned int channel) { |
| 383 | - if (channel >= (unsigned int)settings->scope.voltage.count()) return; | 383 | + if (channel >= (unsigned int)settings->scope.voltage.size()) return; |
| 384 | 384 | ||
| 385 | if (channel < settings->scope.physicalChannels) adaptTriggerLevelSlider(channel); | 385 | if (channel < settings->scope.physicalChannels) adaptTriggerLevelSlider(channel); |
| 386 | 386 | ||
| @@ -391,10 +391,10 @@ void DsoWidget::updateVoltageGain(unsigned int channel) { | @@ -391,10 +391,10 @@ void DsoWidget::updateVoltageGain(unsigned int channel) { | ||
| 391 | /// \param channel The channel whose used-state was changed. | 391 | /// \param channel The channel whose used-state was changed. |
| 392 | /// \param used The new used-state for the channel. | 392 | /// \param used The new used-state for the channel. |
| 393 | void DsoWidget::updateVoltageUsed(unsigned int channel, bool used) { | 393 | void DsoWidget::updateVoltageUsed(unsigned int channel, bool used) { |
| 394 | - if (channel >= (unsigned int)settings->scope.voltage.count()) return; | 394 | + if (channel >= (unsigned int)settings->scope.voltage.size()) return; |
| 395 | 395 | ||
| 396 | - offsetSlider->setVisible(channel, used); | ||
| 397 | - triggerLevelSlider->setVisible(channel, used); | 396 | + offsetSlider->setIndexVisible(channel, used); |
| 397 | + triggerLevelSlider->setIndexVisible(channel, used); | ||
| 398 | setMeasurementVisible(channel, settings->scope.voltage[channel].used); | 398 | setMeasurementVisible(channel, settings->scope.voltage[channel].used); |
| 399 | 399 | ||
| 400 | updateVoltageDetails(channel); | 400 | updateVoltageDetails(channel); |
| @@ -442,8 +442,8 @@ void DsoWidget::doShowNewData() { | @@ -442,8 +442,8 @@ void DsoWidget::doShowNewData() { | ||
| 442 | 442 | ||
| 443 | updateRecordLength(data.get()->getMaxSamples()); | 443 | updateRecordLength(data.get()->getMaxSamples()); |
| 444 | 444 | ||
| 445 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | ||
| 446 | - if (settings->scope.voltage[channel].used && data.get()->data(channel)) { | 445 | + for (int channel = 0; channel < (int)settings->scope.voltage.size(); ++channel) { |
| 446 | + if (settings->scope.voltage[(unsigned)channel].used && data.get()->data(channel)) { | ||
| 447 | // Amplitude string representation (4 significant digits) | 447 | // Amplitude string representation (4 significant digits) |
| 448 | measurementAmplitudeLabel[channel]->setText( | 448 | measurementAmplitudeLabel[channel]->setText( |
| 449 | valueToString(data.get()->data(channel)->amplitude, UNIT_VOLTS, 4)); | 449 | valueToString(data.get()->data(channel)->amplitude, UNIT_VOLTS, 4)); |
| @@ -457,13 +457,13 @@ void DsoWidget::doShowNewData() { | @@ -457,13 +457,13 @@ void DsoWidget::doShowNewData() { | ||
| 457 | /// \brief Handles valueChanged signal from the offset sliders. | 457 | /// \brief Handles valueChanged signal from the offset sliders. |
| 458 | /// \param channel The channel whose offset was changed. | 458 | /// \param channel The channel whose offset was changed. |
| 459 | /// \param value The new offset for the channel. | 459 | /// \param value The new offset for the channel. |
| 460 | -void DsoWidget::updateOffset(int channel, double value) { | ||
| 461 | - if (channel < settings->scope.voltage.count()) { | 460 | +void DsoWidget::updateOffset(unsigned channel, double value) { |
| 461 | + if (channel < settings->scope.voltage.size()) { | ||
| 462 | settings->scope.voltage[channel].offset = value; | 462 | settings->scope.voltage[channel].offset = value; |
| 463 | 463 | ||
| 464 | - if (channel < (int)settings->scope.physicalChannels) adaptTriggerLevelSlider(channel); | ||
| 465 | - } else if (channel < settings->scope.voltage.count() * 2) | ||
| 466 | - settings->scope.spectrum[channel - settings->scope.voltage.count()].offset = value; | 464 | + if (channel < settings->scope.physicalChannels) adaptTriggerLevelSlider(channel); |
| 465 | + } else if (channel < settings->scope.voltage.size() * 2) | ||
| 466 | + settings->scope.spectrum[channel - settings->scope.voltage.size()].offset = value; | ||
| 467 | 467 | ||
| 468 | emit offsetChanged(channel, value); | 468 | emit offsetChanged(channel, value); |
| 469 | } | 469 | } |
openhantek/src/dsowidget.h
| @@ -109,7 +109,7 @@ class DsoWidget : public QWidget { | @@ -109,7 +109,7 @@ class DsoWidget : public QWidget { | ||
| 109 | 109 | ||
| 110 | private slots: | 110 | private slots: |
| 111 | // Sliders | 111 | // Sliders |
| 112 | - void updateOffset(int channel, double value); | 112 | + void updateOffset(unsigned channel, double value); |
| 113 | void updateTriggerPosition(int index, double value); | 113 | void updateTriggerPosition(int index, double value); |
| 114 | void updateTriggerLevel(int channel, double value); | 114 | void updateTriggerLevel(int channel, double value); |
| 115 | void updateMarker(int marker, double value); | 115 | void updateMarker(int marker, double value); |
openhantek/src/exporter.cpp
| @@ -136,7 +136,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { | @@ -136,7 +136,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { | ||
| 136 | // Draw the measurement table | 136 | // Draw the measurement table |
| 137 | stretchBase = (double)(paintDevice->width() - lineHeight * 6) / 10; | 137 | stretchBase = (double)(paintDevice->width() - lineHeight * 6) / 10; |
| 138 | int channelCount = 0; | 138 | int channelCount = 0; |
| 139 | - for (int channel = settings->scope.voltage.count() - 1; channel >= 0; channel--) { | 139 | + for (int channel = settings->scope.voltage.size() - 1; channel >= 0; channel--) { |
| 140 | if ((settings->scope.voltage[channel].used || settings->scope.spectrum[channel].used) && | 140 | if ((settings->scope.voltage[channel].used || settings->scope.spectrum[channel].used) && |
| 141 | result->data(channel)) { | 141 | result->data(channel)) { |
| 142 | ++channelCount; | 142 | ++channelCount; |
| @@ -232,7 +232,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { | @@ -232,7 +232,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { | ||
| 232 | switch (settings->scope.horizontal.format) { | 232 | switch (settings->scope.horizontal.format) { |
| 233 | case Dso::GRAPHFORMAT_TY: | 233 | case Dso::GRAPHFORMAT_TY: |
| 234 | // Add graphs for channels | 234 | // Add graphs for channels |
| 235 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 235 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 236 | if (settings->scope.voltage[channel].used && result->data(channel)) { | 236 | if (settings->scope.voltage[channel].used && result->data(channel)) { |
| 237 | painter.setPen(QPen(colorValues->voltage[channel], 0)); | 237 | painter.setPen(QPen(colorValues->voltage[channel], 0)); |
| 238 | 238 | ||
| @@ -267,7 +267,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { | @@ -267,7 +267,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { | ||
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | // Add spectrum graphs | 269 | // Add spectrum graphs |
| 270 | - for (int channel = 0; channel < settings->scope.spectrum.count(); ++channel) { | 270 | + for (unsigned channel = 0; channel < settings->scope.spectrum.size(); ++channel) { |
| 271 | if (settings->scope.spectrum[channel].used && result->data(channel)) { | 271 | if (settings->scope.spectrum[channel].used && result->data(channel)) { |
| 272 | painter.setPen(QPen(colorValues->spectrum[channel], 0)); | 272 | painter.setPen(QPen(colorValues->spectrum[channel], 0)); |
| 273 | 273 | ||
| @@ -335,7 +335,7 @@ bool Exporter::exportCVS(const DataAnalyzerResult *result) { | @@ -335,7 +335,7 @@ bool Exporter::exportCVS(const DataAnalyzerResult *result) { | ||
| 335 | 335 | ||
| 336 | QTextStream csvStream(&csvFile); | 336 | QTextStream csvStream(&csvFile); |
| 337 | 337 | ||
| 338 | - int chCount = settings->scope.voltage.count(); | 338 | + int chCount = settings->scope.voltage.size(); |
| 339 | std::vector<const SampleValues *> voltageData(size_t(chCount), nullptr); | 339 | std::vector<const SampleValues *> voltageData(size_t(chCount), nullptr); |
| 340 | std::vector<const SampleValues *> spectrumData(size_t(chCount), nullptr); | 340 | std::vector<const SampleValues *> spectrumData(size_t(chCount), nullptr); |
| 341 | size_t maxRow = 0; | 341 | size_t maxRow = 0; |
openhantek/src/exporter.h
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | 9 | ||
| 10 | class DsoSettings; | 10 | class DsoSettings; |
| 11 | class DataAnalyzerResult; | 11 | class DataAnalyzerResult; |
| 12 | -class DsoSettingsColorValues; | 12 | +struct DsoSettingsColorValues; |
| 13 | 13 | ||
| 14 | //////////////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////////////// |
| 15 | /// \enum ExportFormat exporter.h | 15 | /// \enum ExportFormat exporter.h |
openhantek/src/glgenerator.cpp
| @@ -8,9 +8,13 @@ | @@ -8,9 +8,13 @@ | ||
| 8 | 8 | ||
| 9 | GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : settings(scope), view(view) { | 9 | GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : settings(scope), view(view) { |
| 10 | // Grid | 10 | // Grid |
| 11 | - vaGrid[0].resize(((DIVS_TIME * DIVS_SUB - 2) * (DIVS_VOLTAGE - 2) + | ||
| 12 | - (DIVS_VOLTAGE * DIVS_SUB - 2) * (DIVS_TIME - 2) - ((DIVS_TIME - 2) * (DIVS_VOLTAGE - 2))) * | ||
| 13 | - 2); | 11 | + const int DIVS_TIME_S2 = (int)DIVS_TIME - 2; |
| 12 | + const int DIVS_VOLTAGE_S2 = (int)DIVS_VOLTAGE - 2; | ||
| 13 | + const int vaGrid0Size = (int) ((DIVS_TIME * DIVS_SUB - 2) * DIVS_VOLTAGE_S2 + | ||
| 14 | + (DIVS_VOLTAGE * DIVS_SUB - 2) * DIVS_TIME_S2 - | ||
| 15 | + (DIVS_TIME_S2 * DIVS_VOLTAGE_S2)) * 2; | ||
| 16 | + | ||
| 17 | + vaGrid[0].resize(vaGrid0Size); | ||
| 14 | std::vector<GLfloat>::iterator glIterator = vaGrid[0].begin(); | 18 | std::vector<GLfloat>::iterator glIterator = vaGrid[0].begin(); |
| 15 | // Draw vertical lines | 19 | // Draw vertical lines |
| 16 | for (int div = 1; div < DIVS_TIME / 2; ++div) { | 20 | for (int div = 1; div < DIVS_TIME / 2; ++div) { |
| @@ -43,7 +47,7 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti | @@ -43,7 +47,7 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti | ||
| 43 | } | 47 | } |
| 44 | 48 | ||
| 45 | // Axes | 49 | // Axes |
| 46 | - vaGrid[1].resize((2 + (DIVS_TIME * DIVS_SUB - 2) + (DIVS_VOLTAGE * DIVS_SUB - 2)) * 4); | 50 | + vaGrid[1].resize((int)(2 + (DIVS_TIME * DIVS_SUB - 2) + (DIVS_VOLTAGE * DIVS_SUB - 2)) * 4); |
| 47 | glIterator = vaGrid[1].begin(); | 51 | glIterator = vaGrid[1].begin(); |
| 48 | // Horizontal axis | 52 | // Horizontal axis |
| 49 | *(glIterator++) = -DIVS_TIME / 2; | 53 | *(glIterator++) = -DIVS_TIME / 2; |
| @@ -59,24 +63,24 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti | @@ -59,24 +63,24 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti | ||
| 59 | for (int line = 1; line < DIVS_TIME / 2 * DIVS_SUB; ++line) { | 63 | for (int line = 1; line < DIVS_TIME / 2 * DIVS_SUB; ++line) { |
| 60 | float linePosition = (float)line / DIVS_SUB; | 64 | float linePosition = (float)line / DIVS_SUB; |
| 61 | *(glIterator++) = linePosition; | 65 | *(glIterator++) = linePosition; |
| 62 | - *(glIterator++) = -0.05; | 66 | + *(glIterator++) = -0.05f; |
| 63 | *(glIterator++) = linePosition; | 67 | *(glIterator++) = linePosition; |
| 64 | - *(glIterator++) = 0.05; | 68 | + *(glIterator++) = 0.05f; |
| 65 | *(glIterator++) = -linePosition; | 69 | *(glIterator++) = -linePosition; |
| 66 | - *(glIterator++) = -0.05; | 70 | + *(glIterator++) = -0.05f; |
| 67 | *(glIterator++) = -linePosition; | 71 | *(glIterator++) = -linePosition; |
| 68 | - *(glIterator++) = 0.05; | 72 | + *(glIterator++) = 0.05f; |
| 69 | } | 73 | } |
| 70 | // Subdiv lines on vertical axis | 74 | // Subdiv lines on vertical axis |
| 71 | for (int line = 1; line < DIVS_VOLTAGE / 2 * DIVS_SUB; ++line) { | 75 | for (int line = 1; line < DIVS_VOLTAGE / 2 * DIVS_SUB; ++line) { |
| 72 | float linePosition = (float)line / DIVS_SUB; | 76 | float linePosition = (float)line / DIVS_SUB; |
| 73 | - *(glIterator++) = -0.05; | 77 | + *(glIterator++) = -0.05f; |
| 74 | *(glIterator++) = linePosition; | 78 | *(glIterator++) = linePosition; |
| 75 | - *(glIterator++) = 0.05; | 79 | + *(glIterator++) = 0.05f; |
| 76 | *(glIterator++) = linePosition; | 80 | *(glIterator++) = linePosition; |
| 77 | - *(glIterator++) = -0.05; | 81 | + *(glIterator++) = -0.05f; |
| 78 | *(glIterator++) = -linePosition; | 82 | *(glIterator++) = -linePosition; |
| 79 | - *(glIterator++) = 0.05; | 83 | + *(glIterator++) = 0.05f; |
| 80 | *(glIterator++) = -linePosition; | 84 | *(glIterator++) = -linePosition; |
| 81 | } | 85 | } |
| 82 | 86 | ||
| @@ -93,7 +97,7 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti | @@ -93,7 +97,7 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti | ||
| 93 | *(glIterator++) = DIVS_VOLTAGE / 2; | 97 | *(glIterator++) = DIVS_VOLTAGE / 2; |
| 94 | } | 98 | } |
| 95 | 99 | ||
| 96 | -const std::vector<GLfloat> &GlGenerator::channel(int mode, int channel, int index) const { | 100 | +const std::vector<GLfloat> &GlGenerator::channel(int mode, unsigned channel, unsigned index) const { |
| 97 | return vaChannel[mode][channel][index]; | 101 | return vaChannel[mode][channel][index]; |
| 98 | } | 102 | } |
| 99 | 103 | ||
| @@ -108,7 +112,7 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { | @@ -108,7 +112,7 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { | ||
| 108 | // Handle all digital phosphor related list manipulations | 112 | // Handle all digital phosphor related list manipulations |
| 109 | for (int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { | 113 | for (int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { |
| 110 | // Adapt the number of graphs | 114 | // Adapt the number of graphs |
| 111 | - vaChannel[mode].resize(settings->voltage.count()); | 115 | + vaChannel[mode].resize(settings->voltage.size()); |
| 112 | 116 | ||
| 113 | for (unsigned int channel = 0; channel < vaChannel[mode].size(); ++channel) { | 117 | for (unsigned int channel = 0; channel < vaChannel[mode].size(); ++channel) { |
| 114 | // Move the last list element to the front | 118 | // Move the last list element to the front |
openhantek/src/glgenerator.h
| @@ -25,7 +25,7 @@ class GlGenerator : public QObject { | @@ -25,7 +25,7 @@ class GlGenerator : public QObject { | ||
| 25 | /// \param parent The parent widget. | 25 | /// \param parent The parent widget. |
| 26 | GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view); | 26 | GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view); |
| 27 | void generateGraphs(const DataAnalyzerResult *result); | 27 | void generateGraphs(const DataAnalyzerResult *result); |
| 28 | - const std::vector<GLfloat> &channel(int mode, int channel, int index) const; | 28 | + const std::vector<GLfloat> &channel(int mode, unsigned channel, unsigned index) const; |
| 29 | const std::vector<GLfloat> &grid(int a) const; | 29 | const std::vector<GLfloat> &grid(int a) const; |
| 30 | bool isReady() const; | 30 | bool isReady() const; |
| 31 | 31 |
openhantek/src/glscope.cpp
| @@ -154,7 +154,7 @@ void GlScope::drawGraph() { | @@ -154,7 +154,7 @@ void GlScope::drawGraph() { | ||
| 154 | case Dso::GRAPHFORMAT_TY: | 154 | case Dso::GRAPHFORMAT_TY: |
| 155 | // Real and virtual channels | 155 | // Real and virtual channels |
| 156 | for (int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { | 156 | for (int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { |
| 157 | - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { | 157 | + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { |
| 158 | if (!channelUsed(mode, channel)) continue; | 158 | if (!channelUsed(mode, channel)) continue; |
| 159 | 159 | ||
| 160 | // Draw graph for all available depths | 160 | // Draw graph for all available depths |
| @@ -167,7 +167,7 @@ void GlScope::drawGraph() { | @@ -167,7 +167,7 @@ void GlScope::drawGraph() { | ||
| 167 | 167 | ||
| 168 | case Dso::GRAPHFORMAT_XY: | 168 | case Dso::GRAPHFORMAT_XY: |
| 169 | // Real and virtual channels | 169 | // Real and virtual channels |
| 170 | - for (int channel = 0; channel < settings->scope.voltage.count() - 1; channel += 2) { | 170 | + for (int channel = 0; channel < settings->scope.voltage.size() - 1; channel += 2) { |
| 171 | if (settings->scope.voltage[channel].used) { | 171 | if (settings->scope.voltage[channel].used) { |
| 172 | for (int index = settings->view.digitalPhosphorDepth - 1; index >= 0; index--) { | 172 | for (int index = settings->view.digitalPhosphorDepth - 1; index >= 0; index--) { |
| 173 | drawGraphDepth(Dso::CHANNELMODE_VOLTAGE, channel, index); | 173 | drawGraphDepth(Dso::CHANNELMODE_VOLTAGE, channel, index); |
openhantek/src/hantekdso/controlsettings.h
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | 4 | ||
| 5 | namespace Hantek { | 5 | namespace Hantek { |
| 6 | 6 | ||
| 7 | -class ControlSamplerateLimits; | 7 | +struct ControlSamplerateLimits; |
| 8 | 8 | ||
| 9 | ////////////////////////////////////////////////////////////////////////////// | 9 | ////////////////////////////////////////////////////////////////////////////// |
| 10 | /// \struct ControlSettingsSamplerateTarget hantek/control.h | 10 | /// \struct ControlSettingsSamplerateTarget hantek/control.h |
openhantek/src/hantekdso/dsomodel.cpp
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | 3 | ||
| 4 | #include "dsomodel.h" | 4 | #include "dsomodel.h" |
| 5 | 5 | ||
| 6 | -DSOModel::DSOModel(int id, long vendorID, long productID, long vendorIDnoFirmware, long productIDnoFirmware, std::__cxx11::string firmwareToken, const std::__cxx11::string name, const Hantek::ControlSpecification &specification) | 6 | +DSOModel::DSOModel(int id, long vendorID, long productID, long vendorIDnoFirmware, |
| 7 | + long productIDnoFirmware, const std::string &firmwareToken, const std::string &name, const Hantek::ControlSpecification &specification) | ||
| 7 | : ID(id), vendorID(vendorID), productID(productID), vendorIDnoFirmware(vendorIDnoFirmware), | 8 | : ID(id), vendorID(vendorID), productID(productID), vendorIDnoFirmware(vendorIDnoFirmware), |
| 8 | productIDnoFirmware(productIDnoFirmware), firmwareToken(firmwareToken), name(name), specification(specification) {} | 9 | productIDnoFirmware(productIDnoFirmware), firmwareToken(firmwareToken), name(name), specification(specification) {} |
openhantek/src/hantekdso/dsomodel.h
| @@ -30,7 +30,7 @@ class DSOModel { | @@ -30,7 +30,7 @@ class DSOModel { | ||
| 30 | /// This model may need to modify the HantekDsoControl class to work correctly | 30 | /// This model may need to modify the HantekDsoControl class to work correctly |
| 31 | virtual void applyRequirements(HantekDsoControl*) const = 0; | 31 | virtual void applyRequirements(HantekDsoControl*) const = 0; |
| 32 | DSOModel(int id, long vendorID, long productID, long vendorIDnoFirmware, long productIDnoFirmware, | 32 | DSOModel(int id, long vendorID, long productID, long vendorIDnoFirmware, long productIDnoFirmware, |
| 33 | - std::string firmwareToken, const std::string name, const Hantek::ControlSpecification& specification); | 33 | + const std::string& firmwareToken, const std::string& name, const Hantek::ControlSpecification& specification); |
| 34 | virtual ~DSOModel() = default; | 34 | virtual ~DSOModel() = default; |
| 35 | }; | 35 | }; |
| 36 | 36 |
openhantek/src/mainwindow.cpp
| @@ -474,7 +474,7 @@ void OpenHantekMainWindow::updateOffset(unsigned int channel) { | @@ -474,7 +474,7 @@ void OpenHantekMainWindow::updateOffset(unsigned int channel) { | ||
| 474 | /// \brief Sets the state of the given oscilloscope channel. | 474 | /// \brief Sets the state of the given oscilloscope channel. |
| 475 | /// \param channel The channel whose state has changed. | 475 | /// \param channel The channel whose state has changed. |
| 476 | void OpenHantekMainWindow::updateUsed(unsigned int channel) { | 476 | void OpenHantekMainWindow::updateUsed(unsigned int channel) { |
| 477 | - if (channel >= (unsigned int)settings->scope.voltage.count()) return; | 477 | + if (channel >= (unsigned int)settings->scope.voltage.size()) return; |
| 478 | 478 | ||
| 479 | bool mathUsed = settings->scope.voltage[settings->scope.physicalChannels].used | | 479 | bool mathUsed = settings->scope.voltage[settings->scope.physicalChannels].used | |
| 480 | settings->scope.spectrum[settings->scope.physicalChannels].used; | 480 | settings->scope.spectrum[settings->scope.physicalChannels].used; |
openhantek/src/scopesettings.h
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #include "definitions.h" | 3 | #include "definitions.h" |
| 4 | -#include <QVector> | 4 | +#include <vector> |
| 5 | #include "analyse/enums.h" | 5 | #include "analyse/enums.h" |
| 6 | #include "hantekdso/enums.h" | 6 | #include "hantekdso/enums.h" |
| 7 | 7 | ||
| @@ -37,6 +37,7 @@ struct DsoSettingsScopeTrigger { | @@ -37,6 +37,7 @@ struct DsoSettingsScopeTrigger { | ||
| 37 | /// \struct DsoSettingsScopeSpectrum settings.h | 37 | /// \struct DsoSettingsScopeSpectrum settings.h |
| 38 | /// \brief Holds the settings for the spectrum analysis. | 38 | /// \brief Holds the settings for the spectrum analysis. |
| 39 | struct DsoSettingsScopeSpectrum { | 39 | struct DsoSettingsScopeSpectrum { |
| 40 | + unsigned channel; | ||
| 40 | double magnitude; ///< The vertical resolution in dB/div | 41 | double magnitude; ///< The vertical resolution in dB/div |
| 41 | QString name; ///< Name of this channel | 42 | QString name; ///< Name of this channel |
| 42 | double offset; ///< Vertical offset in divs | 43 | double offset; ///< Vertical offset in divs |
| @@ -66,8 +67,8 @@ struct DsoSettingsScopeVoltage { | @@ -66,8 +67,8 @@ struct DsoSettingsScopeVoltage { | ||
| 66 | struct DsoSettingsScope { | 67 | struct DsoSettingsScope { |
| 67 | DsoSettingsScopeHorizontal horizontal; ///< Settings for the horizontal axis | 68 | DsoSettingsScopeHorizontal horizontal; ///< Settings for the horizontal axis |
| 68 | DsoSettingsScopeTrigger trigger; ///< Settings for the trigger | 69 | DsoSettingsScopeTrigger trigger; ///< Settings for the trigger |
| 69 | - QVector<DsoSettingsScopeSpectrum> spectrum; ///< Spectrum analysis settings | ||
| 70 | - QVector<DsoSettingsScopeVoltage> voltage; ///< Settings for the normal graphs | 70 | + std::vector<DsoSettingsScopeSpectrum> spectrum; ///< Spectrum analysis settings |
| 71 | + std::vector<DsoSettingsScopeVoltage> voltage; ///< Settings for the normal graphs | ||
| 71 | 72 | ||
| 72 | unsigned int physicalChannels = 0; ///< Number of real channels (No math etc.) | 73 | unsigned int physicalChannels = 0; ///< Number of real channels (No math etc.) |
| 73 | Dso::WindowFunction spectrumWindow = Dso::WindowFunction::HANN; ///< Window function for DFT | 74 | Dso::WindowFunction spectrumWindow = Dso::WindowFunction::HANN; ///< Window function for DFT |
openhantek/src/settings.cpp
| @@ -48,68 +48,31 @@ bool DsoSettings::setFilename(const QString &filename) { | @@ -48,68 +48,31 @@ bool DsoSettings::setFilename(const QString &filename) { | ||
| 48 | return true; | 48 | return true; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | -void DsoSettings::setChannelCount(unsigned int channels) { | ||
| 52 | - this->scope.physicalChannels = channels; | ||
| 53 | - // Always put the math channel at the end of the list | ||
| 54 | - | ||
| 55 | - // Remove list items for removed channels | ||
| 56 | - for (int channel = this->scope.spectrum.count() - 2; channel >= (int)channels; channel--) | ||
| 57 | - this->scope.spectrum.removeAt(channel); | ||
| 58 | - for (int channel = this->scope.voltage.count() - 2; channel >= (int)channels; channel--) | ||
| 59 | - this->scope.voltage.removeAt(channel); | ||
| 60 | - for (int channel = this->scope.spectrum.count() - 2; channel >= (int)channels; channel--) | ||
| 61 | - this->scope.spectrum.removeAt(channel); | ||
| 62 | - for (int channel = this->scope.spectrum.count() - 2; channel >= (int)channels; channel--) | ||
| 63 | - this->scope.spectrum.removeAt(channel); | 51 | +template<typename S> |
| 52 | +inline void removeIfPossible(std::vector<S>& v, unsigned start, unsigned keepAtEnd) { | ||
| 53 | + if (start<v.size()) | ||
| 54 | + v.erase(v.begin()+start, v.end()-((v.size()-start>=keepAtEnd) ? keepAtEnd : 0)); | ||
| 55 | +} | ||
| 64 | 56 | ||
| 65 | - // Add new channels to the list | ||
| 66 | - for (int channel = 0; channel < (int)channels; ++channel) { | ||
| 67 | - // Oscilloscope settings | ||
| 68 | - // Spectrum | ||
| 69 | - if (this->scope.spectrum.count() <= channel + 1) { | ||
| 70 | - DsoSettingsScopeSpectrum newSpectrum; | ||
| 71 | - newSpectrum.magnitude = 20.0; | ||
| 72 | - newSpectrum.name = QApplication::tr("SP%1").arg(channel + 1); | ||
| 73 | - newSpectrum.offset = 0.0; | ||
| 74 | - newSpectrum.used = false; | ||
| 75 | - this->scope.spectrum.insert(channel, newSpectrum); | ||
| 76 | - } | ||
| 77 | - // Voltage | ||
| 78 | - if (this->scope.voltage.count() <= channel + 1) { | ||
| 79 | - DsoSettingsScopeVoltage newVoltage; | ||
| 80 | - newVoltage.gain = 1.0; | ||
| 81 | - newVoltage.coupling = Dso::COUPLING_DC; | ||
| 82 | - newVoltage.name = QApplication::tr("CH%1").arg(channel + 1); | ||
| 83 | - newVoltage.offset = 0.0; | ||
| 84 | - newVoltage.trigger = 0.0; | ||
| 85 | - newVoltage.used = false; | ||
| 86 | - this->scope.voltage.insert(channel, newVoltage); | ||
| 87 | - } | 57 | +void DsoSettings::setChannelCount(unsigned channels) { |
| 58 | + scope.physicalChannels = channels; | ||
| 88 | 59 | ||
| 89 | - // View | ||
| 90 | - // Colors | ||
| 91 | - // Screen | ||
| 92 | - if (this->view.screen.voltage.count() <= channel + 1) | ||
| 93 | - this->view.screen.voltage.insert(channel, QColor::fromHsv(channel * 60, 0xff, 0xff)); | ||
| 94 | - if (this->view.screen.spectrum.count() <= channel + 1) | ||
| 95 | - this->view.screen.spectrum.insert(channel, this->view.screen.voltage[channel].lighter()); | ||
| 96 | |||
| 97 | - if (this->view.print.voltage.count() <= channel + 1) | ||
| 98 | - this->view.print.voltage.insert(channel, this->view.screen.voltage[channel].darker(120)); | ||
| 99 | - if (this->view.print.spectrum.count() <= channel + 1) | ||
| 100 | - this->view.print.spectrum.insert(channel, this->view.screen.voltage[channel].darker()); | ||
| 101 | - } | 60 | + // Remove list items for removed channels, keep last channel (math channel) |
| 61 | + removeIfPossible(scope.spectrum, channels, 1); | ||
| 62 | + removeIfPossible(scope.voltage, channels, 1); | ||
| 63 | + removeIfPossible(view.screen.voltage, channels, 1); | ||
| 64 | + removeIfPossible(view.print.voltage, channels, 1); | ||
| 102 | 65 | ||
| 66 | + // Add math channel if missing | ||
| 103 | // Check if the math channel is missing | 67 | // Check if the math channel is missing |
| 104 | - if (this->scope.spectrum.count() <= (int)channels) { | 68 | + if (!scope.spectrum.size()) { |
| 105 | DsoSettingsScopeSpectrum newSpectrum; | 69 | DsoSettingsScopeSpectrum newSpectrum; |
| 106 | newSpectrum.magnitude = 20.0; | 70 | newSpectrum.magnitude = 20.0; |
| 107 | newSpectrum.name = QApplication::tr("SPM"); | 71 | newSpectrum.name = QApplication::tr("SPM"); |
| 108 | newSpectrum.offset = 0.0; | 72 | newSpectrum.offset = 0.0; |
| 109 | newSpectrum.used = false; | 73 | newSpectrum.used = false; |
| 110 | - this->scope.spectrum.append(newSpectrum); | ||
| 111 | - } | ||
| 112 | - if (this->scope.voltage.count() <= (int)channels) { | 74 | + scope.spectrum.push_back(newSpectrum); |
| 75 | + | ||
| 113 | DsoSettingsScopeVoltage newVoltage; | 76 | DsoSettingsScopeVoltage newVoltage; |
| 114 | newVoltage.gain = 1.0; | 77 | newVoltage.gain = 1.0; |
| 115 | newVoltage.math = Dso::MathMode::ADD_CH1_CH2; | 78 | newVoltage.math = Dso::MathMode::ADD_CH1_CH2; |
| @@ -117,23 +80,49 @@ void DsoSettings::setChannelCount(unsigned int channels) { | @@ -117,23 +80,49 @@ void DsoSettings::setChannelCount(unsigned int channels) { | ||
| 117 | newVoltage.offset = 0.0; | 80 | newVoltage.offset = 0.0; |
| 118 | newVoltage.trigger = 0.0; | 81 | newVoltage.trigger = 0.0; |
| 119 | newVoltage.used = false; | 82 | newVoltage.used = false; |
| 120 | - this->scope.voltage.append(newVoltage); | 83 | + scope.voltage.push_back(newVoltage); |
| 84 | + | ||
| 85 | + view.screen.voltage.push_back(QColor(0x7f, 0x7f, 0x7f, 0xff)); | ||
| 86 | + view.screen.spectrum.push_back(view.screen.voltage.back().lighter()); | ||
| 87 | + view.print.voltage.push_back(view.screen.voltage.back()); | ||
| 88 | + view.print.spectrum.push_back(view.print.voltage.back().darker()); | ||
| 121 | } | 89 | } |
| 122 | - if (this->view.screen.voltage.count() <= (int)channels) | ||
| 123 | - this->view.screen.voltage.append(QColor(0x7f, 0x7f, 0x7f, 0xff)); | ||
| 124 | - if (this->view.screen.spectrum.count() <= (int)channels) | ||
| 125 | - this->view.screen.spectrum.append(this->view.screen.voltage[channels].lighter()); | ||
| 126 | - if (this->view.print.voltage.count() <= (int)channels) | ||
| 127 | - this->view.print.voltage.append(this->view.screen.voltage[channels]); | ||
| 128 | - if (this->view.print.spectrum.count() <= (int)channels) | ||
| 129 | - this->view.print.spectrum.append(this->view.print.voltage[channels].darker()); | 90 | + |
| 91 | + // Add new channels to the list | ||
| 92 | + while (scope.spectrum.size() <= channels) { | ||
| 93 | + // Oscilloscope settings | ||
| 94 | + // Spectrum | ||
| 95 | + DsoSettingsScopeSpectrum newSpectrum; | ||
| 96 | + newSpectrum.magnitude = 20.0; | ||
| 97 | + newSpectrum.name = QApplication::tr("SP%1").arg(scope.spectrum.size()); | ||
| 98 | + newSpectrum.offset = 0.0; | ||
| 99 | + newSpectrum.used = false; | ||
| 100 | + scope.spectrum.insert(scope.spectrum.end()-1, newSpectrum); | ||
| 101 | + | ||
| 102 | + // Voltage | ||
| 103 | + DsoSettingsScopeVoltage newVoltage; | ||
| 104 | + newVoltage.gain = 1.0; | ||
| 105 | + newVoltage.coupling = Dso::COUPLING_DC; | ||
| 106 | + newVoltage.name = QApplication::tr("CH%1").arg(scope.voltage.size()); | ||
| 107 | + newVoltage.offset = 0.0; | ||
| 108 | + newVoltage.trigger = 0.0; | ||
| 109 | + newVoltage.used = false; | ||
| 110 | + scope.voltage.insert(scope.voltage.end()-1, newVoltage); | ||
| 111 | + | ||
| 112 | + view.screen.voltage.insert(view.screen.voltage.end()-1, QColor::fromHsv((int)(view.screen.voltage.size()-1) * 60, 0xff, 0xff)); | ||
| 113 | + view.screen.spectrum.insert(view.screen.spectrum.end()-1, view.screen.voltage.back().lighter()); | ||
| 114 | + view.print.voltage.insert(view.print.voltage.end()-1, view.screen.voltage.back().darker(120)); | ||
| 115 | + view.print.spectrum.insert(view.print.spectrum.end()-1, view.screen.voltage.back().darker()); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + | ||
| 130 | } | 119 | } |
| 131 | 120 | ||
| 132 | void DsoSettings::load() { | 121 | void DsoSettings::load() { |
| 133 | // General options | 122 | // General options |
| 134 | store->beginGroup("options"); | 123 | store->beginGroup("options"); |
| 135 | - if (store->contains("alwaysSave")) this->options.alwaysSave = store->value("alwaysSave").toBool(); | ||
| 136 | - if (store->contains("imageSize")) this->options.imageSize = store->value("imageSize").toSize(); | 124 | + if (store->contains("alwaysSave")) options.alwaysSave = store->value("alwaysSave").toBool(); |
| 125 | + if (store->contains("imageSize")) options.imageSize = store->value("imageSize").toSize(); | ||
| 137 | // If the window/* keys were found in this group, remove them from settings | 126 | // If the window/* keys were found in this group, remove them from settings |
| 138 | store->remove("window"); | 127 | store->remove("window"); |
| 139 | store->endGroup(); | 128 | store->endGroup(); |
| @@ -142,52 +131,52 @@ void DsoSettings::load() { | @@ -142,52 +131,52 @@ void DsoSettings::load() { | ||
| 142 | store->beginGroup("scope"); | 131 | store->beginGroup("scope"); |
| 143 | // Horizontal axis | 132 | // Horizontal axis |
| 144 | store->beginGroup("horizontal"); | 133 | store->beginGroup("horizontal"); |
| 145 | - if (store->contains("format")) this->scope.horizontal.format = (Dso::GraphFormat)store->value("format").toInt(); | 134 | + if (store->contains("format")) scope.horizontal.format = (Dso::GraphFormat)store->value("format").toInt(); |
| 146 | if (store->contains("frequencybase")) | 135 | if (store->contains("frequencybase")) |
| 147 | - this->scope.horizontal.frequencybase = store->value("frequencybase").toDouble(); | 136 | + scope.horizontal.frequencybase = store->value("frequencybase").toDouble(); |
| 148 | for (int marker = 0; marker < 2; ++marker) { | 137 | for (int marker = 0; marker < 2; ++marker) { |
| 149 | QString name; | 138 | QString name; |
| 150 | name = QString("marker%1").arg(marker); | 139 | name = QString("marker%1").arg(marker); |
| 151 | - if (store->contains(name)) this->scope.horizontal.marker[marker] = store->value(name).toDouble(); | 140 | + if (store->contains(name)) scope.horizontal.marker[marker] = store->value(name).toDouble(); |
| 152 | } | 141 | } |
| 153 | - if (store->contains("timebase")) this->scope.horizontal.timebase = store->value("timebase").toDouble(); | ||
| 154 | - if (store->contains("recordLength")) this->scope.horizontal.recordLength = store->value("recordLength").toUInt(); | ||
| 155 | - if (store->contains("samplerate")) this->scope.horizontal.samplerate = store->value("samplerate").toDouble(); | ||
| 156 | - if (store->contains("samplerateSet")) this->scope.horizontal.samplerateSet = store->value("samplerateSet").toBool(); | 142 | + if (store->contains("timebase")) scope.horizontal.timebase = store->value("timebase").toDouble(); |
| 143 | + if (store->contains("recordLength")) scope.horizontal.recordLength = store->value("recordLength").toUInt(); | ||
| 144 | + if (store->contains("samplerate")) scope.horizontal.samplerate = store->value("samplerate").toDouble(); | ||
| 145 | + if (store->contains("samplerateSet")) scope.horizontal.samplerateSet = store->value("samplerateSet").toBool(); | ||
| 157 | store->endGroup(); | 146 | store->endGroup(); |
| 158 | // Trigger | 147 | // Trigger |
| 159 | store->beginGroup("trigger"); | 148 | store->beginGroup("trigger"); |
| 160 | - if (store->contains("filter")) this->scope.trigger.filter = store->value("filter").toBool(); | ||
| 161 | - if (store->contains("mode")) this->scope.trigger.mode = (Dso::TriggerMode)store->value("mode").toInt(); | ||
| 162 | - if (store->contains("position")) this->scope.trigger.position = store->value("position").toDouble(); | ||
| 163 | - if (store->contains("slope")) this->scope.trigger.slope = (Dso::Slope)store->value("slope").toInt(); | ||
| 164 | - if (store->contains("source")) this->scope.trigger.source = store->value("source").toInt(); | ||
| 165 | - if (store->contains("special")) this->scope.trigger.special = store->value("special").toInt(); | 149 | + if (store->contains("filter")) scope.trigger.filter = store->value("filter").toBool(); |
| 150 | + if (store->contains("mode")) scope.trigger.mode = (Dso::TriggerMode)store->value("mode").toInt(); | ||
| 151 | + if (store->contains("position")) scope.trigger.position = store->value("position").toDouble(); | ||
| 152 | + if (store->contains("slope")) scope.trigger.slope = (Dso::Slope)store->value("slope").toInt(); | ||
| 153 | + if (store->contains("source")) scope.trigger.source = store->value("source").toInt(); | ||
| 154 | + if (store->contains("special")) scope.trigger.special = store->value("special").toInt(); | ||
| 166 | store->endGroup(); | 155 | store->endGroup(); |
| 167 | // Spectrum | 156 | // Spectrum |
| 168 | - for (int channel = 0; channel < this->scope.spectrum.count(); ++channel) { | 157 | + for (unsigned channel = 0; channel < scope.spectrum.size(); ++channel) { |
| 169 | store->beginGroup(QString("spectrum%1").arg(channel)); | 158 | store->beginGroup(QString("spectrum%1").arg(channel)); |
| 170 | if (store->contains("magnitude")) | 159 | if (store->contains("magnitude")) |
| 171 | - this->scope.spectrum[channel].magnitude = store->value("magnitude").toDouble(); | ||
| 172 | - if (store->contains("offset")) this->scope.spectrum[channel].offset = store->value("offset").toDouble(); | ||
| 173 | - if (store->contains("used")) this->scope.spectrum[channel].used = store->value("used").toBool(); | 160 | + scope.spectrum[channel].magnitude = store->value("magnitude").toDouble(); |
| 161 | + if (store->contains("offset")) scope.spectrum[channel].offset = store->value("offset").toDouble(); | ||
| 162 | + if (store->contains("used")) scope.spectrum[channel].used = store->value("used").toBool(); | ||
| 174 | store->endGroup(); | 163 | store->endGroup(); |
| 175 | } | 164 | } |
| 176 | // Vertical axis | 165 | // Vertical axis |
| 177 | - for (int channel = 0; channel < this->scope.voltage.count(); ++channel) { | 166 | + for (unsigned channel = 0; channel < scope.voltage.size(); ++channel) { |
| 178 | store->beginGroup(QString("vertical%1").arg(channel)); | 167 | store->beginGroup(QString("vertical%1").arg(channel)); |
| 179 | - if (store->contains("gain")) this->scope.voltage[channel].gain = store->value("gain").toDouble(); | ||
| 180 | - if (store->contains("misc")) this->scope.voltage[channel].rawValue = store->value("misc").toInt(); | ||
| 181 | - if (store->contains("offset")) this->scope.voltage[channel].offset = store->value("offset").toDouble(); | ||
| 182 | - if (store->contains("trigger")) this->scope.voltage[channel].trigger = store->value("trigger").toDouble(); | ||
| 183 | - if (store->contains("used")) this->scope.voltage[channel].used = store->value("used").toBool(); | 168 | + if (store->contains("gain")) scope.voltage[channel].gain = store->value("gain").toDouble(); |
| 169 | + if (store->contains("misc")) scope.voltage[channel].rawValue = store->value("misc").toInt(); | ||
| 170 | + if (store->contains("offset")) scope.voltage[channel].offset = store->value("offset").toDouble(); | ||
| 171 | + if (store->contains("trigger")) scope.voltage[channel].trigger = store->value("trigger").toDouble(); | ||
| 172 | + if (store->contains("used")) scope.voltage[channel].used = store->value("used").toBool(); | ||
| 184 | store->endGroup(); | 173 | store->endGroup(); |
| 185 | } | 174 | } |
| 186 | - if (store->contains("spectrumLimit")) this->scope.spectrumLimit = store->value("spectrumLimit").toDouble(); | 175 | + if (store->contains("spectrumLimit")) scope.spectrumLimit = store->value("spectrumLimit").toDouble(); |
| 187 | if (store->contains("spectrumReference")) | 176 | if (store->contains("spectrumReference")) |
| 188 | - this->scope.spectrumReference = store->value("spectrumReference").toDouble(); | 177 | + scope.spectrumReference = store->value("spectrumReference").toDouble(); |
| 189 | if (store->contains("spectrumWindow")) | 178 | if (store->contains("spectrumWindow")) |
| 190 | - this->scope.spectrumWindow = (Dso::WindowFunction)store->value("spectrumWindow").toInt(); | 179 | + scope.spectrumWindow = (Dso::WindowFunction)store->value("spectrumWindow").toInt(); |
| 191 | store->endGroup(); | 180 | store->endGroup(); |
| 192 | 181 | ||
| 193 | // View | 182 | // View |
| @@ -197,10 +186,10 @@ void DsoSettings::load() { | @@ -197,10 +186,10 @@ void DsoSettings::load() { | ||
| 197 | DsoSettingsColorValues *colors; | 186 | DsoSettingsColorValues *colors; |
| 198 | for (int mode = 0; mode < 2; ++mode) { | 187 | for (int mode = 0; mode < 2; ++mode) { |
| 199 | if (mode == 0) { | 188 | if (mode == 0) { |
| 200 | - colors = &this->view.screen; | 189 | + colors = &view.screen; |
| 201 | store->beginGroup("screen"); | 190 | store->beginGroup("screen"); |
| 202 | } else { | 191 | } else { |
| 203 | - colors = &this->view.print; | 192 | + colors = &view.print; |
| 204 | store->beginGroup("print"); | 193 | store->beginGroup("print"); |
| 205 | } | 194 | } |
| 206 | 195 | ||
| @@ -209,12 +198,12 @@ void DsoSettings::load() { | @@ -209,12 +198,12 @@ void DsoSettings::load() { | ||
| 209 | if (store->contains("border")) colors->border = store->value("border").value<QColor>(); | 198 | if (store->contains("border")) colors->border = store->value("border").value<QColor>(); |
| 210 | if (store->contains("grid")) colors->grid = store->value("grid").value<QColor>(); | 199 | if (store->contains("grid")) colors->grid = store->value("grid").value<QColor>(); |
| 211 | if (store->contains("markers")) colors->markers = store->value("markers").value<QColor>(); | 200 | if (store->contains("markers")) colors->markers = store->value("markers").value<QColor>(); |
| 212 | - for (int channel = 0; channel < this->scope.spectrum.count(); ++channel) { | 201 | + for (unsigned channel = 0; channel < scope.spectrum.size(); ++channel) { |
| 213 | QString key = QString("spectrum%1").arg(channel); | 202 | QString key = QString("spectrum%1").arg(channel); |
| 214 | if (store->contains(key)) colors->spectrum[channel] = store->value(key).value<QColor>(); | 203 | if (store->contains(key)) colors->spectrum[channel] = store->value(key).value<QColor>(); |
| 215 | } | 204 | } |
| 216 | if (store->contains("text")) colors->text = store->value("text").value<QColor>(); | 205 | if (store->contains("text")) colors->text = store->value("text").value<QColor>(); |
| 217 | - for (int channel = 0; channel < this->scope.voltage.count(); ++channel) { | 206 | + for (unsigned channel = 0; channel < scope.voltage.size(); ++channel) { |
| 218 | QString key = QString("voltage%1").arg(channel); | 207 | QString key = QString("voltage%1").arg(channel); |
| 219 | if (store->contains(key)) colors->voltage[channel] = store->value(key).value<QColor>(); | 208 | if (store->contains(key)) colors->voltage[channel] = store->value(key).value<QColor>(); |
| 220 | } | 209 | } |
| @@ -222,11 +211,11 @@ void DsoSettings::load() { | @@ -222,11 +211,11 @@ void DsoSettings::load() { | ||
| 222 | } | 211 | } |
| 223 | store->endGroup(); | 212 | store->endGroup(); |
| 224 | // Other view settings | 213 | // Other view settings |
| 225 | - if (store->contains("digitalPhosphor")) this->view.digitalPhosphor = store->value("digitalPhosphor").toBool(); | 214 | + if (store->contains("digitalPhosphor")) view.digitalPhosphor = store->value("digitalPhosphor").toBool(); |
| 226 | if (store->contains("interpolation")) | 215 | if (store->contains("interpolation")) |
| 227 | - this->view.interpolation = (Dso::InterpolationMode)store->value("interpolation").toInt(); | ||
| 228 | - if (store->contains("screenColorImages")) this->view.screenColorImages = store->value("screenColorImages").toBool(); | ||
| 229 | - if (store->contains("zoom")) this->view.zoom = (Dso::InterpolationMode)store->value("zoom").toBool(); | 216 | + view.interpolation = (Dso::InterpolationMode)store->value("interpolation").toInt(); |
| 217 | + if (store->contains("screenColorImages")) view.screenColorImages = store->value("screenColorImages").toBool(); | ||
| 218 | + if (store->contains("zoom")) view.zoom = (Dso::InterpolationMode)store->value("zoom").toBool(); | ||
| 230 | store->endGroup(); | 219 | store->endGroup(); |
| 231 | 220 | ||
| 232 | store->beginGroup("window"); | 221 | store->beginGroup("window"); |
| @@ -238,53 +227,53 @@ void DsoSettings::load() { | @@ -238,53 +227,53 @@ void DsoSettings::load() { | ||
| 238 | void DsoSettings::save() { | 227 | void DsoSettings::save() { |
| 239 | // Main window layout and other general options | 228 | // Main window layout and other general options |
| 240 | store->beginGroup("options"); | 229 | store->beginGroup("options"); |
| 241 | - store->setValue("alwaysSave", this->options.alwaysSave); | ||
| 242 | - store->setValue("imageSize", this->options.imageSize); | 230 | + store->setValue("alwaysSave", options.alwaysSave); |
| 231 | + store->setValue("imageSize", options.imageSize); | ||
| 243 | store->endGroup(); | 232 | store->endGroup(); |
| 244 | 233 | ||
| 245 | // Oszilloskope settings | 234 | // Oszilloskope settings |
| 246 | store->beginGroup("scope"); | 235 | store->beginGroup("scope"); |
| 247 | // Horizontal axis | 236 | // Horizontal axis |
| 248 | store->beginGroup("horizontal"); | 237 | store->beginGroup("horizontal"); |
| 249 | - store->setValue("format", this->scope.horizontal.format); | ||
| 250 | - store->setValue("frequencybase", this->scope.horizontal.frequencybase); | 238 | + store->setValue("format", scope.horizontal.format); |
| 239 | + store->setValue("frequencybase", scope.horizontal.frequencybase); | ||
| 251 | for (int marker = 0; marker < 2; ++marker) | 240 | for (int marker = 0; marker < 2; ++marker) |
| 252 | - store->setValue(QString("marker%1").arg(marker), this->scope.horizontal.marker[marker]); | ||
| 253 | - store->setValue("timebase", this->scope.horizontal.timebase); | ||
| 254 | - store->setValue("recordLength", this->scope.horizontal.recordLength); | ||
| 255 | - store->setValue("samplerate", this->scope.horizontal.samplerate); | ||
| 256 | - store->setValue("samplerateSet", this->scope.horizontal.samplerateSet); | 241 | + store->setValue(QString("marker%1").arg(marker), scope.horizontal.marker[marker]); |
| 242 | + store->setValue("timebase", scope.horizontal.timebase); | ||
| 243 | + store->setValue("recordLength", scope.horizontal.recordLength); | ||
| 244 | + store->setValue("samplerate", scope.horizontal.samplerate); | ||
| 245 | + store->setValue("samplerateSet", scope.horizontal.samplerateSet); | ||
| 257 | store->endGroup(); | 246 | store->endGroup(); |
| 258 | // Trigger | 247 | // Trigger |
| 259 | store->beginGroup("trigger"); | 248 | store->beginGroup("trigger"); |
| 260 | - store->setValue("filter", this->scope.trigger.filter); | ||
| 261 | - store->setValue("mode", this->scope.trigger.mode); | ||
| 262 | - store->setValue("position", this->scope.trigger.position); | ||
| 263 | - store->setValue("slope", this->scope.trigger.slope); | ||
| 264 | - store->setValue("source", this->scope.trigger.source); | ||
| 265 | - store->setValue("special", this->scope.trigger.special); | 249 | + store->setValue("filter", scope.trigger.filter); |
| 250 | + store->setValue("mode", scope.trigger.mode); | ||
| 251 | + store->setValue("position", scope.trigger.position); | ||
| 252 | + store->setValue("slope", scope.trigger.slope); | ||
| 253 | + store->setValue("source", scope.trigger.source); | ||
| 254 | + store->setValue("special", scope.trigger.special); | ||
| 266 | store->endGroup(); | 255 | store->endGroup(); |
| 267 | // Spectrum | 256 | // Spectrum |
| 268 | - for (int channel = 0; channel < this->scope.spectrum.count(); ++channel) { | 257 | + for (unsigned channel = 0; channel < scope.spectrum.size(); ++channel) { |
| 269 | store->beginGroup(QString("spectrum%1").arg(channel)); | 258 | store->beginGroup(QString("spectrum%1").arg(channel)); |
| 270 | - store->setValue("magnitude", this->scope.spectrum[channel].magnitude); | ||
| 271 | - store->setValue("offset", this->scope.spectrum[channel].offset); | ||
| 272 | - store->setValue("used", this->scope.spectrum[channel].used); | 259 | + store->setValue("magnitude", scope.spectrum[channel].magnitude); |
| 260 | + store->setValue("offset", scope.spectrum[channel].offset); | ||
| 261 | + store->setValue("used", scope.spectrum[channel].used); | ||
| 273 | store->endGroup(); | 262 | store->endGroup(); |
| 274 | } | 263 | } |
| 275 | // Vertical axis | 264 | // Vertical axis |
| 276 | - for (int channel = 0; channel < this->scope.voltage.count(); ++channel) { | 265 | + for (unsigned channel = 0; channel < scope.voltage.size(); ++channel) { |
| 277 | store->beginGroup(QString("vertical%1").arg(channel)); | 266 | store->beginGroup(QString("vertical%1").arg(channel)); |
| 278 | - store->setValue("gain", this->scope.voltage[channel].gain); | ||
| 279 | - store->setValue("misc", this->scope.voltage[channel].rawValue); | ||
| 280 | - store->setValue("offset", this->scope.voltage[channel].offset); | ||
| 281 | - store->setValue("trigger", this->scope.voltage[channel].trigger); | ||
| 282 | - store->setValue("used", this->scope.voltage[channel].used); | 267 | + store->setValue("gain", scope.voltage[channel].gain); |
| 268 | + store->setValue("misc", scope.voltage[channel].rawValue); | ||
| 269 | + store->setValue("offset", scope.voltage[channel].offset); | ||
| 270 | + store->setValue("trigger", scope.voltage[channel].trigger); | ||
| 271 | + store->setValue("used", scope.voltage[channel].used); | ||
| 283 | store->endGroup(); | 272 | store->endGroup(); |
| 284 | } | 273 | } |
| 285 | - store->setValue("spectrumLimit", this->scope.spectrumLimit); | ||
| 286 | - store->setValue("spectrumReference", this->scope.spectrumReference); | ||
| 287 | - store->setValue("spectrumWindow", (int)this->scope.spectrumWindow); | 274 | + store->setValue("spectrumLimit", scope.spectrumLimit); |
| 275 | + store->setValue("spectrumReference", scope.spectrumReference); | ||
| 276 | + store->setValue("spectrumWindow", (int)scope.spectrumWindow); | ||
| 288 | store->endGroup(); | 277 | store->endGroup(); |
| 289 | 278 | ||
| 290 | // View | 279 | // View |
| @@ -295,10 +284,10 @@ void DsoSettings::save() { | @@ -295,10 +284,10 @@ void DsoSettings::save() { | ||
| 295 | DsoSettingsColorValues *colors; | 284 | DsoSettingsColorValues *colors; |
| 296 | for (int mode = 0; mode < 2; ++mode) { | 285 | for (int mode = 0; mode < 2; ++mode) { |
| 297 | if (mode == 0) { | 286 | if (mode == 0) { |
| 298 | - colors = &this->view.screen; | 287 | + colors = &view.screen; |
| 299 | store->beginGroup("screen"); | 288 | store->beginGroup("screen"); |
| 300 | } else { | 289 | } else { |
| 301 | - colors = &this->view.print; | 290 | + colors = &view.print; |
| 302 | store->beginGroup("print"); | 291 | store->beginGroup("print"); |
| 303 | } | 292 | } |
| 304 | 293 | ||
| @@ -307,20 +296,20 @@ void DsoSettings::save() { | @@ -307,20 +296,20 @@ void DsoSettings::save() { | ||
| 307 | store->setValue("border", colors->border); | 296 | store->setValue("border", colors->border); |
| 308 | store->setValue("grid", colors->grid); | 297 | store->setValue("grid", colors->grid); |
| 309 | store->setValue("markers", colors->markers); | 298 | store->setValue("markers", colors->markers); |
| 310 | - for (int channel = 0; channel < this->scope.spectrum.count(); ++channel) | 299 | + for (unsigned channel = 0; channel < scope.spectrum.size(); ++channel) |
| 311 | store->setValue(QString("spectrum%1").arg(channel), colors->spectrum[channel]); | 300 | store->setValue(QString("spectrum%1").arg(channel), colors->spectrum[channel]); |
| 312 | store->setValue("text", colors->text); | 301 | store->setValue("text", colors->text); |
| 313 | - for (int channel = 0; channel < this->scope.voltage.count(); ++channel) | 302 | + for (unsigned channel = 0; channel < scope.voltage.size(); ++channel) |
| 314 | store->setValue(QString("voltage%1").arg(channel), colors->voltage[channel]); | 303 | store->setValue(QString("voltage%1").arg(channel), colors->voltage[channel]); |
| 315 | store->endGroup(); | 304 | store->endGroup(); |
| 316 | } | 305 | } |
| 317 | store->endGroup(); | 306 | store->endGroup(); |
| 318 | 307 | ||
| 319 | // Other view settings | 308 | // Other view settings |
| 320 | - store->setValue("digitalPhosphor", this->view.digitalPhosphor); | ||
| 321 | - store->setValue("interpolation", this->view.interpolation); | ||
| 322 | - store->setValue("screenColorImages", this->view.screenColorImages); | ||
| 323 | - store->setValue("zoom", this->view.zoom); | 309 | + store->setValue("digitalPhosphor", view.digitalPhosphor); |
| 310 | + store->setValue("interpolation", view.interpolation); | ||
| 311 | + store->setValue("screenColorImages", view.screenColorImages); | ||
| 312 | + store->setValue("zoom", view.zoom); | ||
| 324 | store->endGroup(); | 313 | store->endGroup(); |
| 325 | 314 | ||
| 326 | store->beginGroup("window"); | 315 | store->beginGroup("window"); |
openhantek/src/usb/ezusb.cpp
| @@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
| 20 | * along with this program; if not, write to the Free Software | 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
| 22 | */ | 22 | */ |
| 23 | +#define _CRT_SECURE_NO_WARNINGS | ||
| 23 | #include <errno.h> | 24 | #include <errno.h> |
| 24 | #include <stdint.h> | 25 | #include <stdint.h> |
| 25 | #include <stdio.h> | 26 | #include <stdio.h> |
openhantek/src/viewsettings.h
| @@ -17,8 +17,8 @@ struct DsoSettingsColorValues { | @@ -17,8 +17,8 @@ struct DsoSettingsColorValues { | ||
| 17 | QColor grid; ///< The color of the grid | 17 | QColor grid; ///< The color of the grid |
| 18 | QColor markers; ///< The color of the markers | 18 | QColor markers; ///< The color of the markers |
| 19 | QColor text; ///< The default text color | 19 | QColor text; ///< The default text color |
| 20 | - QVector<QColor> spectrum; ///< The colors of the spectrum graphs | ||
| 21 | - QVector<QColor> voltage; ///< The colors of the voltage graphs | 20 | + std::vector<QColor> spectrum; ///< The colors of the spectrum graphs |
| 21 | + std::vector<QColor> voltage; ///< The colors of the voltage graphs | ||
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | //////////////////////////////////////////////////////////////////////////////// | 24 | //////////////////////////////////////////////////////////////////////////////// |
| @@ -31,16 +31,16 @@ struct DsoSettingsView { | @@ -31,16 +31,16 @@ struct DsoSettingsView { | ||
| 31 | QColor(0xff, 0xff, 0xff, 0x3f), | 31 | QColor(0xff, 0xff, 0xff, 0x3f), |
| 32 | QColor(0xff, 0xff, 0xff, 0xbf), | 32 | QColor(0xff, 0xff, 0xff, 0xbf), |
| 33 | QColor(0xff, 0xff, 0xff, 0xff), | 33 | QColor(0xff, 0xff, 0xff, 0xff), |
| 34 | - QVector<QColor>(), | ||
| 35 | - QVector<QColor>()}; | 34 | + std::vector<QColor>(), |
| 35 | + std::vector<QColor>()}; | ||
| 36 | DsoSettingsColorValues print = {QColor(0x00, 0x00, 0x00, 0xbf), | 36 | DsoSettingsColorValues print = {QColor(0x00, 0x00, 0x00, 0xbf), |
| 37 | QColor(0x00, 0x00, 0x00, 0x00), | 37 | QColor(0x00, 0x00, 0x00, 0x00), |
| 38 | QColor(0x00, 0x00, 0x00, 0xff), | 38 | QColor(0x00, 0x00, 0x00, 0xff), |
| 39 | QColor(0x00, 0x00, 0x00, 0x7f), | 39 | QColor(0x00, 0x00, 0x00, 0x7f), |
| 40 | QColor(0x00, 0x00, 0x00, 0xef), | 40 | QColor(0x00, 0x00, 0x00, 0xef), |
| 41 | QColor(0x00, 0x00, 0x00, 0xff), | 41 | QColor(0x00, 0x00, 0x00, 0xff), |
| 42 | - QVector<QColor>(), | ||
| 43 | - QVector<QColor>()}; | 42 | + std::vector<QColor>(), |
| 43 | + std::vector<QColor>()}; | ||
| 44 | bool antialiasing = true; ///< Antialiasing for the graphs | 44 | bool antialiasing = true; ///< Antialiasing for the graphs |
| 45 | bool digitalPhosphor = false; ///< true slowly fades out the previous graphs | 45 | bool digitalPhosphor = false; ///< true slowly fades out the previous graphs |
| 46 | int digitalPhosphorDepth = 8; ///< Number of channels shown at one time | 46 | int digitalPhosphorDepth = 8; ///< Number of channels shown at one time |
openhantek/src/widgets/colorbox.h
| 1 | -//////////////////////////////////////////////////////////////////////////////// | ||
| 2 | -// | ||
| 3 | -// OpenHantek | ||
| 4 | -/// \file colorbox.h | ||
| 5 | -/// \brief Declares the ColorBox class. | ||
| 6 | -// | ||
| 7 | -// Copyright (C) 2010 Oliver Haag | ||
| 8 | -// oliver.haag@gmail.com | ||
| 9 | -// | ||
| 10 | -// This program is free software: you can redistribute it and/or modify it | ||
| 11 | -// under the terms of the GNU General Public License as published by the Free | ||
| 12 | -// Software Foundation, either version 3 of the License, or (at your option) | ||
| 13 | -// any later version. | ||
| 14 | -// | ||
| 15 | -// This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 16 | -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 17 | -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 18 | -// more details. | ||
| 19 | -// | ||
| 20 | -// You should have received a copy of the GNU General Public License along with | ||
| 21 | -// this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | -// | ||
| 23 | -//////////////////////////////////////////////////////////////////////////////// | ||
| 24 | - | ||
| 25 | -#ifndef COLORBOX_H | ||
| 26 | -#define COLORBOX_H | 1 | +// SPDX-License-Identifier: GPL-2.0+ |
| 2 | + | ||
| 3 | +#pragma once | ||
| 27 | 4 | ||
| 28 | #include <QColor> | 5 | #include <QColor> |
| 29 | #include <QPushButton> | 6 | #include <QPushButton> |
| 30 | 7 | ||
| 31 | -//////////////////////////////////////////////////////////////////////////////// | ||
| 32 | -/// \class ColorBox colorbox.h | ||
| 33 | /// \brief A widget for the selection of a color. | 8 | /// \brief A widget for the selection of a color. |
| 34 | class ColorBox : public QPushButton { | 9 | class ColorBox : public QPushButton { |
| 35 | Q_OBJECT | 10 | Q_OBJECT |
| @@ -50,5 +25,3 @@ class ColorBox : public QPushButton { | @@ -50,5 +25,3 @@ class ColorBox : public QPushButton { | ||
| 50 | signals: | 25 | signals: |
| 51 | void colorChanged(QColor color); ///< The color has been changed | 26 | void colorChanged(QColor color); ///< The color has been changed |
| 52 | }; | 27 | }; |
| 53 | - | ||
| 54 | -#endif |
openhantek/src/widgets/levelslider.cpp
| @@ -126,13 +126,11 @@ const QColor LevelSlider::color(int index) const { | @@ -126,13 +126,11 @@ const QColor LevelSlider::color(int index) const { | ||
| 126 | /// \param index The index of the slider whose color should be set. | 126 | /// \param index The index of the slider whose color should be set. |
| 127 | /// \param color The new color for the slider. | 127 | /// \param color The new color for the slider. |
| 128 | /// \return The index of the slider, -1 on error. | 128 | /// \return The index of the slider, -1 on error. |
| 129 | -int LevelSlider::setColor(int index, QColor color) { | ||
| 130 | - if (index < 0 || index >= this->slider.count()) return -1; | 129 | +void LevelSlider::setColor(unsigned index, QColor color) { |
| 130 | + if (index >= (unsigned)this->slider.count()) return; | ||
| 131 | 131 | ||
| 132 | - this->slider[index]->color = color; | 132 | + this->slider[(int)index]->color = color; |
| 133 | this->repaint(); | 133 | this->repaint(); |
| 134 | - | ||
| 135 | - return index; | ||
| 136 | } | 134 | } |
| 137 | 135 | ||
| 138 | /// \brief Return the text shown beside a slider. | 136 | /// \brief Return the text shown beside a slider. |
| @@ -170,13 +168,11 @@ bool LevelSlider::visible(int index) const { | @@ -170,13 +168,11 @@ bool LevelSlider::visible(int index) const { | ||
| 170 | /// \param index The index of the slider whose visibility should be set. | 168 | /// \param index The index of the slider whose visibility should be set. |
| 171 | /// \param visible true to show the slider, false to hide it. | 169 | /// \param visible true to show the slider, false to hide it. |
| 172 | /// \return The index of the slider, -1 on error. | 170 | /// \return The index of the slider, -1 on error. |
| 173 | -int LevelSlider::setVisible(int index, bool visible) { | ||
| 174 | - if (index < 0 || index >= this->slider.count()) return -1; | 171 | +void LevelSlider::setIndexVisible(unsigned index, bool visible) { |
| 172 | + if (index >= (unsigned)this->slider.count()) return; | ||
| 175 | 173 | ||
| 176 | - this->slider[index]->visible = visible; | 174 | + this->slider[(int)index]->visible = visible; |
| 177 | this->repaint(); | 175 | this->repaint(); |
| 178 | - | ||
| 179 | - return index; | ||
| 180 | } | 176 | } |
| 181 | 177 | ||
| 182 | /// \brief Return the minimal value of the sliders. | 178 | /// \brief Return the minimal value of the sliders. |
openhantek/src/widgets/levelslider.h
| 1 | -//////////////////////////////////////////////////////////////////////////////// | ||
| 2 | -// | ||
| 3 | -// OpenHantek | ||
| 4 | -/// \file levelslider.h | ||
| 5 | -/// \brief Declares the LevelSlider class. | ||
| 6 | -// | ||
| 7 | -// Copyright (C) 2010 Oliver Haag | ||
| 8 | -// oliver.haag@gmail.com | ||
| 9 | -// | ||
| 10 | -// This program is free software: you can redistribute it and/or modify it | ||
| 11 | -// under the terms of the GNU General Public License as published by the Free | ||
| 12 | -// Software Foundation, either version 3 of the License, or (at your option) | ||
| 13 | -// any later version. | ||
| 14 | -// | ||
| 15 | -// This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 16 | -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 17 | -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 18 | -// more details. | ||
| 19 | -// | ||
| 20 | -// You should have received a copy of the GNU General Public License along with | ||
| 21 | -// this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | -// | ||
| 23 | -//////////////////////////////////////////////////////////////////////////////// | 1 | +// SPDX-License-Identifier: GPL-2.0+ |
| 24 | 2 | ||
| 25 | -#ifndef LEVELSLIDER_H | ||
| 26 | -#define LEVELSLIDER_H | 3 | +#pragma once |
| 27 | 4 | ||
| 28 | #include <QWidget> | 5 | #include <QWidget> |
| 29 | 6 | ||
| 30 | class QColor; | 7 | class QColor; |
| 31 | 8 | ||
| 32 | -//////////////////////////////////////////////////////////////////////////////// | ||
| 33 | -/// \struct LevelSliderParameters levelslider.h | ||
| 34 | /// \brief Contains the color, text and value of one slider. | 9 | /// \brief Contains the color, text and value of one slider. |
| 35 | struct LevelSliderParameters { | 10 | struct LevelSliderParameters { |
| 36 | QColor color; ///< The color of the slider and font | 11 | QColor color; ///< The color of the slider and font |
| @@ -68,11 +43,11 @@ class LevelSlider : public QWidget { | @@ -68,11 +43,11 @@ class LevelSlider : public QWidget { | ||
| 68 | 43 | ||
| 69 | // Parameters for a specific slider | 44 | // Parameters for a specific slider |
| 70 | const QColor color(int index) const; | 45 | const QColor color(int index) const; |
| 71 | - int setColor(int index, QColor color); | 46 | + void setColor(unsigned index, QColor color); |
| 72 | const QString text(int index) const; | 47 | const QString text(int index) const; |
| 73 | int setText(int index, QString text); | 48 | int setText(int index, QString text); |
| 74 | bool visible(int index) const; | 49 | bool visible(int index) const; |
| 75 | - int setVisible(int index, bool visible); | 50 | + void setIndexVisible(unsigned index, bool visible); |
| 76 | 51 | ||
| 77 | double minimum(int index) const; | 52 | double minimum(int index) const; |
| 78 | double maximum(int index) const; | 53 | double maximum(int index) const; |
| @@ -110,5 +85,3 @@ class LevelSlider : public QWidget { | @@ -110,5 +85,3 @@ class LevelSlider : public QWidget { | ||
| 110 | signals: | 85 | signals: |
| 111 | void valueChanged(int index, double value); ///< The value of a slider has changed | 86 | void valueChanged(int index, double value); ///< The value of a slider has changed |
| 112 | }; | 87 | }; |
| 113 | - | ||
| 114 | -#endif |
openhantek/src/widgets/sispinbox.h
| 1 | -//////////////////////////////////////////////////////////////////////////////// | ||
| 2 | -// | ||
| 3 | -// OpenHantek | ||
| 4 | -/// \file sispinbox.h | ||
| 5 | -/// \brief Declares the SiSpinBox class. | ||
| 6 | -// | ||
| 7 | -// Copyright (C) 2010, 2011 Oliver Haag | ||
| 8 | -// oliver.haag@gmail.com | ||
| 9 | -// | ||
| 10 | -// This program is free software: you can redistribute it and/or modify it | ||
| 11 | -// under the terms of the GNU General Public License as published by the Free | ||
| 12 | -// Software Foundation, either version 3 of the License, or (at your option) | ||
| 13 | -// any later version. | ||
| 14 | -// | ||
| 15 | -// This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 16 | -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 17 | -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 18 | -// more details. | ||
| 19 | -// | ||
| 20 | -// You should have received a copy of the GNU General Public License along with | ||
| 21 | -// this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | -// | ||
| 23 | -//////////////////////////////////////////////////////////////////////////////// | 1 | +// SPDX-License-Identifier: GPL-2.0+ |
| 24 | 2 | ||
| 25 | -#ifndef SISPINBOX_H | ||
| 26 | -#define SISPINBOX_H | 3 | +#pragma once |
| 27 | 4 | ||
| 28 | #include <QDoubleSpinBox> | 5 | #include <QDoubleSpinBox> |
| 29 | #include <QStringList> | 6 | #include <QStringList> |
| 30 | 7 | ||
| 31 | #include "utils/printutils.h" | 8 | #include "utils/printutils.h" |
| 32 | 9 | ||
| 33 | -//////////////////////////////////////////////////////////////////////////////// | ||
| 34 | -/// \class SiSpinBox sispinbox.h | ||
| 35 | /// \brief A spin box with SI prefix support. | 10 | /// \brief A spin box with SI prefix support. |
| 36 | /// This spin box supports the SI prefixes (k/M/G/T) after its value and allows | 11 | /// This spin box supports the SI prefixes (k/M/G/T) after its value and allows |
| 37 | /// floating point values. The step size is increasing in an exponential way, to | 12 | /// floating point values. The step size is increasing in an exponential way, to |
| @@ -70,5 +45,3 @@ class SiSpinBox : public QDoubleSpinBox { | @@ -70,5 +45,3 @@ class SiSpinBox : public QDoubleSpinBox { | ||
| 70 | private slots: | 45 | private slots: |
| 71 | void resetSteppedTo(); | 46 | void resetSteppedTo(); |
| 72 | }; | 47 | }; |
| 73 | - | ||
| 74 | -#endif |