diff --git a/openhantek/src/configdialog/DsoConfigColorsPage.cpp b/openhantek/src/configdialog/DsoConfigColorsPage.cpp index 8c775ea..e11f86f 100644 --- a/openhantek/src/configdialog/DsoConfigColorsPage.cpp +++ b/openhantek/src/configdialog/DsoConfigColorsPage.cpp @@ -51,7 +51,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) printSpectrumLabel = new QLabel(tr("Spectrum")); printSpectrumLabel->setAlignment(Qt::AlignHCenter); - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { colorLabel.append(new QLabel(settings->scope.voltage[channel].name)); screenChannelColorBox.append(new ColorBox(colorSettings.screen.voltage[channel])); screenSpectrumColorBox.append(new ColorBox(colorSettings.screen.spectrum[channel])); @@ -106,7 +106,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) colorsLayout->addWidget(printSpectrumLabel, row, COL_PRT_SPECTRUM); ++row; - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel, ++row) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel, ++row) { colorsLayout->addWidget(colorLabel[channel], row, COL_LABEL); colorsLayout->addWidget(screenChannelColorBox[channel], row, COL_SCR_CHANNEL); colorsLayout->addWidget(screenSpectrumColorBox[channel], row, COL_SCR_SPECTRUM); @@ -146,7 +146,7 @@ void DsoConfigColorsPage::saveSettings() { colorSettings.print.text = printTextColorBox->getColor(); // Graph category - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { colorSettings.screen.voltage[channel] = screenChannelColorBox[channel]->getColor(); colorSettings.screen.spectrum[channel] = screenSpectrumColorBox[channel]->getColor(); colorSettings.print.voltage[channel] = printChannelColorBox[channel]->getColor(); diff --git a/openhantek/src/docks/SpectrumDock.cpp b/openhantek/src/docks/SpectrumDock.cpp index 23435e9..cd4448d 100644 --- a/openhantek/src/docks/SpectrumDock.cpp +++ b/openhantek/src/docks/SpectrumDock.cpp @@ -33,7 +33,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla this->magnitudeStrings << valueToString(*magnitude, UNIT_DECIBEL, 0); // Initialize elements - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { this->magnitudeComboBox.append(new QComboBox()); this->magnitudeComboBox[channel]->addItems(this->magnitudeStrings); @@ -43,7 +43,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla this->dockLayout = new QGridLayout(); this->dockLayout->setColumnMinimumWidth(0, 64); this->dockLayout->setColumnStretch(1, 1); - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { this->dockLayout->addWidget(this->usedCheckBox[channel], channel, 0); this->dockLayout->addWidget(this->magnitudeComboBox[channel], channel, 1); } @@ -52,13 +52,13 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla SetupDockWidget(this, dockWidget, dockLayout); // Connect signals and slots - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { connect(this->magnitudeComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(magnitudeSelected(int))); connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); } // Set values - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { this->setMagnitude(channel, settings->scope.spectrum[channel].magnitude); this->setUsed(channel, settings->scope.spectrum[channel].used); } @@ -77,7 +77,7 @@ void SpectrumDock::closeEvent(QCloseEvent *event) { /// \param magnitude The magnitude in dB. /// \return Index of magnitude-value, -1 on error. int SpectrumDock::setMagnitude(int channel, double magnitude) { - if (channel < 0 || channel >= settings->scope.voltage.count()) return -1; + if (channel < 0 || channel >= settings->scope.voltage.size()) return -1; int index = this->magnitudeSteps.indexOf(magnitude); if (index != -1) this->magnitudeComboBox[channel]->setCurrentIndex(index); @@ -90,7 +90,7 @@ int SpectrumDock::setMagnitude(int channel, double magnitude) { /// \param used True if the channel should be enabled, false otherwise. /// \return Index of channel, -1 on error. int SpectrumDock::setUsed(int channel, bool used) { - if (channel >= 0 && channel < settings->scope.voltage.count()) { + if (channel >= 0 && channel < settings->scope.voltage.size()) { this->usedCheckBox[channel]->setChecked(used); return channel; } @@ -104,11 +104,11 @@ void SpectrumDock::magnitudeSelected(int index) { int channel; // Which combobox was it? - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) if (this->sender() == this->magnitudeComboBox[channel]) break; // Send signal if it was one of the comboboxes - if (channel < settings->scope.voltage.count()) { + if (channel < settings->scope.voltage.size()) { settings->scope.spectrum[channel].magnitude = this->magnitudeSteps.at(index); emit magnitudeChanged(channel, settings->scope.spectrum[channel].magnitude); } @@ -120,11 +120,11 @@ void SpectrumDock::usedSwitched(bool checked) { int channel; // Which checkbox was it? - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) if (this->sender() == this->usedCheckBox[channel]) break; // Send signal if it was one of the checkboxes - if (channel < settings->scope.voltage.count()) { + if (channel < settings->scope.voltage.size()) { settings->scope.spectrum[channel].used = checked; emit usedChanged(channel, checked); } diff --git a/openhantek/src/docks/VoltageDock.cpp b/openhantek/src/docks/VoltageDock.cpp index aecfdf9..47f2563 100644 --- a/openhantek/src/docks/VoltageDock.cpp +++ b/openhantek/src/docks/VoltageDock.cpp @@ -38,7 +38,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags this->gainStrings << valueToString(*gain, UNIT_VOLTS, 0); // Initialize elements - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { this->miscComboBox.append(new QComboBox()); if (channel < (int)settings->scope.physicalChannels) this->miscComboBox[channel]->addItems(this->couplingStrings); @@ -56,7 +56,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags this->dockLayout = new QGridLayout(); this->dockLayout->setColumnMinimumWidth(0, 64); this->dockLayout->setColumnStretch(1, 1); - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { this->dockLayout->addWidget(this->usedCheckBox[channel], channel * 3, 0); this->dockLayout->addWidget(this->gainComboBox[channel], channel * 3, 1); this->dockLayout->addWidget(this->miscComboBox[channel], channel * 3 + 1, 1); @@ -67,7 +67,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags SetupDockWidget(this, dockWidget, dockLayout); // Connect signals and slots - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { connect(this->gainComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(gainSelected(int))); connect(this->invertCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(invertSwitched(bool))); connect(this->miscComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(miscSelected(int))); @@ -75,7 +75,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags } // Set values - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { if (channel < (int)settings->scope.physicalChannels) this->setCoupling(channel, settings->scope.voltage[channel].coupling); else @@ -110,7 +110,7 @@ int VoltageDock::setCoupling(int channel, Dso::Coupling coupling) { /// \param gain The gain in volts. /// \return Index of gain-value, -1 on error. int VoltageDock::setGain(int channel, double gain) { - if (channel < 0 || channel >= settings->scope.voltage.count()) return -1; + if (channel < 0 || channel >= settings->scope.voltage.size()) return -1; int index = this->gainSteps.indexOf(gain); if (index != -1) this->gainComboBox[channel]->setCurrentIndex(index); @@ -130,7 +130,7 @@ void VoltageDock::setMode(Dso::MathMode mode) { /// \param used True if the channel should be enabled, false otherwise. /// \return Index of channel, -1 on error. int VoltageDock::setUsed(int channel, bool used) { - if (channel >= 0 && channel < settings->scope.voltage.count()) { + if (channel >= 0 && channel < settings->scope.voltage.size()) { this->usedCheckBox[channel]->setChecked(used); return channel; } @@ -144,11 +144,11 @@ void VoltageDock::gainSelected(int index) { int channel; // Which combobox was it? - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) if (this->sender() == this->gainComboBox[channel]) break; // Send signal if it was one of the comboboxes - if (channel < settings->scope.voltage.count()) { + if (channel < settings->scope.voltage.size()) { settings->scope.voltage[channel].gain = this->gainSteps.at(index); emit gainChanged(channel, settings->scope.voltage[channel].gain); @@ -161,11 +161,11 @@ void VoltageDock::miscSelected(int index) { int channel; // Which combobox was it? - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) if (this->sender() == this->miscComboBox[channel]) break; // Send signal if it was one of the comboboxes - if (channel < settings->scope.voltage.count()) { + if (channel < settings->scope.voltage.size()) { if (channel < (int)settings->scope.physicalChannels) { settings->scope.voltage[channel].coupling = (Dso::Coupling) index; emit couplingChanged(channel, settings->scope.voltage[channel].coupling); @@ -182,11 +182,11 @@ void VoltageDock::usedSwitched(bool checked) { int channel; // Which checkbox was it? - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) if (this->sender() == this->usedCheckBox[channel]) break; // Send signal if it was one of the checkboxes - if (channel < settings->scope.voltage.count()) { + if (channel < settings->scope.voltage.size()) { settings->scope.voltage[channel].used = checked; emit usedChanged(channel, checked); } @@ -198,11 +198,11 @@ void VoltageDock::invertSwitched(bool checked) { int channel; // Which checkbox was it? - for (channel = 0; channel < settings->scope.voltage.count(); ++channel) + for (channel = 0; channel < settings->scope.voltage.size(); ++channel) if (this->sender() == this->invertCheckBox[channel]) break; // Send signal if it was one of the checkboxes - if (channel < settings->scope.voltage.count()) { + if (channel < settings->scope.voltage.size()) { settings->scope.voltage[channel].inverted = checked; // Should we emit an event here? } diff --git a/openhantek/src/dsowidget.cpp b/openhantek/src/dsowidget.cpp index fd67621..20d1de1 100644 --- a/openhantek/src/dsowidget.cpp +++ b/openhantek/src/dsowidget.cpp @@ -31,21 +31,21 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla // The offset sliders for all possible channels offsetSlider = new LevelSlider(Qt::RightArrow); - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (unsigned channel = 0; channel < settings->scope.voltage.size(); ++channel) { offsetSlider->addSlider(settings->scope.voltage[channel].name, channel); offsetSlider->setColor(channel, settings->view.screen.voltage[channel]); offsetSlider->setLimits(channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); offsetSlider->setStep(channel, 0.2); offsetSlider->setValue(channel, settings->scope.voltage[channel].offset); - offsetSlider->setVisible(channel, settings->scope.voltage[channel].used); + offsetSlider->setIndexVisible(channel, settings->scope.voltage[channel].used); } - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { - offsetSlider->addSlider(settings->scope.spectrum[channel].name, settings->scope.voltage.count() + channel); - offsetSlider->setColor(settings->scope.voltage.count() + channel, settings->view.screen.spectrum[channel]); - offsetSlider->setLimits(settings->scope.voltage.count() + channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); - offsetSlider->setStep(settings->scope.voltage.count() + channel, 0.2); - offsetSlider->setValue(settings->scope.voltage.count() + channel, settings->scope.spectrum[channel].offset); - offsetSlider->setVisible(settings->scope.voltage.count() + channel, settings->scope.spectrum[channel].used); + for (unsigned channel = 0; channel < settings->scope.voltage.size(); ++channel) { + offsetSlider->addSlider(settings->scope.spectrum[channel].name, settings->scope.voltage.size() + channel); + offsetSlider->setColor(settings->scope.voltage.size() + channel, settings->view.screen.spectrum[channel]); + offsetSlider->setLimits(settings->scope.voltage.size() + channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); + offsetSlider->setStep(settings->scope.voltage.size() + channel, 0.2); + offsetSlider->setValue(settings->scope.voltage.size() + channel, settings->scope.spectrum[channel].offset); + offsetSlider->setIndexVisible(settings->scope.voltage.size() + channel, settings->scope.spectrum[channel].used); } // The triggerPosition slider @@ -54,7 +54,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla triggerPositionSlider->setLimits(0, 0.0, 1.0); triggerPositionSlider->setStep(0, 0.2 / DIVS_TIME); triggerPositionSlider->setValue(0, settings->scope.trigger.position); - triggerPositionSlider->setVisible(0, true); + triggerPositionSlider->setIndexVisible(0, true); // The sliders for the trigger levels triggerLevelSlider = new LevelSlider(Qt::LeftArrow); @@ -67,7 +67,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla : settings->view.screen.voltage[channel].darker()); adaptTriggerLevelSlider(channel); triggerLevelSlider->setValue(channel, settings->scope.voltage[channel].trigger); - triggerLevelSlider->setVisible(channel, settings->scope.voltage[channel].used); + triggerLevelSlider->setIndexVisible(channel, settings->scope.voltage[channel].used); } // The marker slider @@ -77,7 +77,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla markerSlider->setLimits(marker, -DIVS_TIME / 2, DIVS_TIME / 2); markerSlider->setStep(marker, 0.2); markerSlider->setValue(marker, settings->scope.horizontal.marker[marker]); - markerSlider->setVisible(marker, true); + markerSlider->setIndexVisible(marker, true); settings->scope.horizontal.marker_visible[marker] = true; } @@ -135,7 +135,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla measurementLayout->setColumnStretch(3, 2); measurementLayout->setColumnStretch(4, 3); measurementLayout->setColumnStretch(5, 3); - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < (int)settings->scope.voltage.size(); ++channel) { tablePalette.setColor(QPalette::WindowText, settings->view.screen.voltage[channel]); measurementNameLabel.append(new QLabel(settings->scope.voltage[channel].name)); measurementNameLabel[channel]->setPalette(tablePalette); @@ -161,12 +161,12 @@ DsoWidget::DsoWidget(DsoSettings *settings, QWidget *parent, Qt::WindowFlags fla measurementLayout->addWidget(measurementMagnitudeLabel[channel], channel, 3); measurementLayout->addWidget(measurementAmplitudeLabel[channel], channel, 4); measurementLayout->addWidget(measurementFrequencyLabel[channel], channel, 5); - if ((unsigned int)channel < settings->scope.physicalChannels) - updateVoltageCoupling(channel); + if ((unsigned)channel < settings->scope.physicalChannels) + updateVoltageCoupling((unsigned)channel); else updateMathMode(); - updateVoltageDetails(channel); - updateSpectrumDetails(channel); + updateVoltageDetails((unsigned)channel); + updateSpectrumDetails((unsigned)channel); } // The layout for the widgets @@ -293,7 +293,7 @@ void DsoWidget::updateTriggerDetails() { /// \brief Update the label about the trigger settings void DsoWidget::updateVoltageDetails(unsigned int channel) { - if (channel >= (unsigned int)settings->scope.voltage.count()) return; + if (channel >= (unsigned int)settings->scope.voltage.size()) return; setMeasurementVisible(channel, settings->scope.voltage[channel].used || settings->scope.spectrum[channel].used); @@ -332,9 +332,9 @@ void DsoWidget::updateSpectrumMagnitude(unsigned int channel) { updateSpectrumDe /// \param channel The channel whose used-state was changed. /// \param used The new used-state for the channel. void DsoWidget::updateSpectrumUsed(unsigned int channel, bool used) { - if (channel >= (unsigned int)settings->scope.voltage.count()) return; + if (channel >= (unsigned int)settings->scope.voltage.size()) return; - offsetSlider->setVisible(settings->scope.voltage.count() + channel, used); + offsetSlider->setIndexVisible(settings->scope.voltage.size() + channel, used); updateSpectrumDetails(channel); } @@ -366,7 +366,7 @@ void DsoWidget::updateTriggerSource() { /// \brief Handles couplingChanged signal from the voltage dock. /// \param channel The channel whose coupling was changed. void DsoWidget::updateVoltageCoupling(unsigned int channel) { - if (channel >= (unsigned int)settings->scope.voltage.count()) return; + if (channel >= (unsigned int)settings->scope.voltage.size()) return; measurementMiscLabel[channel]->setText(Dso::couplingString(settings->scope.voltage[channel].coupling)); } @@ -380,7 +380,7 @@ void DsoWidget::updateMathMode() { /// \brief Handles gainChanged signal from the voltage dock. /// \param channel The channel whose gain was changed. void DsoWidget::updateVoltageGain(unsigned int channel) { - if (channel >= (unsigned int)settings->scope.voltage.count()) return; + if (channel >= (unsigned int)settings->scope.voltage.size()) return; if (channel < settings->scope.physicalChannels) adaptTriggerLevelSlider(channel); @@ -391,10 +391,10 @@ void DsoWidget::updateVoltageGain(unsigned int channel) { /// \param channel The channel whose used-state was changed. /// \param used The new used-state for the channel. void DsoWidget::updateVoltageUsed(unsigned int channel, bool used) { - if (channel >= (unsigned int)settings->scope.voltage.count()) return; + if (channel >= (unsigned int)settings->scope.voltage.size()) return; - offsetSlider->setVisible(channel, used); - triggerLevelSlider->setVisible(channel, used); + offsetSlider->setIndexVisible(channel, used); + triggerLevelSlider->setIndexVisible(channel, used); setMeasurementVisible(channel, settings->scope.voltage[channel].used); updateVoltageDetails(channel); @@ -442,8 +442,8 @@ void DsoWidget::doShowNewData() { updateRecordLength(data.get()->getMaxSamples()); - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { - if (settings->scope.voltage[channel].used && data.get()->data(channel)) { + for (int channel = 0; channel < (int)settings->scope.voltage.size(); ++channel) { + if (settings->scope.voltage[(unsigned)channel].used && data.get()->data(channel)) { // Amplitude string representation (4 significant digits) measurementAmplitudeLabel[channel]->setText( valueToString(data.get()->data(channel)->amplitude, UNIT_VOLTS, 4)); @@ -457,13 +457,13 @@ void DsoWidget::doShowNewData() { /// \brief Handles valueChanged signal from the offset sliders. /// \param channel The channel whose offset was changed. /// \param value The new offset for the channel. -void DsoWidget::updateOffset(int channel, double value) { - if (channel < settings->scope.voltage.count()) { +void DsoWidget::updateOffset(unsigned channel, double value) { + if (channel < settings->scope.voltage.size()) { settings->scope.voltage[channel].offset = value; - if (channel < (int)settings->scope.physicalChannels) adaptTriggerLevelSlider(channel); - } else if (channel < settings->scope.voltage.count() * 2) - settings->scope.spectrum[channel - settings->scope.voltage.count()].offset = value; + if (channel < settings->scope.physicalChannels) adaptTriggerLevelSlider(channel); + } else if (channel < settings->scope.voltage.size() * 2) + settings->scope.spectrum[channel - settings->scope.voltage.size()].offset = value; emit offsetChanged(channel, value); } diff --git a/openhantek/src/dsowidget.h b/openhantek/src/dsowidget.h index 66e578f..3e566ec 100644 --- a/openhantek/src/dsowidget.h +++ b/openhantek/src/dsowidget.h @@ -109,7 +109,7 @@ class DsoWidget : public QWidget { private slots: // Sliders - void updateOffset(int channel, double value); + void updateOffset(unsigned channel, double value); void updateTriggerPosition(int index, double value); void updateTriggerLevel(int channel, double value); void updateMarker(int marker, double value); diff --git a/openhantek/src/exporter.cpp b/openhantek/src/exporter.cpp index 54b1fe7..bfec9b6 100644 --- a/openhantek/src/exporter.cpp +++ b/openhantek/src/exporter.cpp @@ -136,7 +136,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { // Draw the measurement table stretchBase = (double)(paintDevice->width() - lineHeight * 6) / 10; int channelCount = 0; - for (int channel = settings->scope.voltage.count() - 1; channel >= 0; channel--) { + for (int channel = settings->scope.voltage.size() - 1; channel >= 0; channel--) { if ((settings->scope.voltage[channel].used || settings->scope.spectrum[channel].used) && result->data(channel)) { ++channelCount; @@ -232,7 +232,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { switch (settings->scope.horizontal.format) { case Dso::GRAPHFORMAT_TY: // Add graphs for channels - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { if (settings->scope.voltage[channel].used && result->data(channel)) { painter.setPen(QPen(colorValues->voltage[channel], 0)); @@ -267,7 +267,7 @@ bool Exporter::exportSamples(const DataAnalyzerResult *result) { } // Add spectrum graphs - for (int channel = 0; channel < settings->scope.spectrum.count(); ++channel) { + for (unsigned channel = 0; channel < settings->scope.spectrum.size(); ++channel) { if (settings->scope.spectrum[channel].used && result->data(channel)) { painter.setPen(QPen(colorValues->spectrum[channel], 0)); @@ -335,7 +335,7 @@ bool Exporter::exportCVS(const DataAnalyzerResult *result) { QTextStream csvStream(&csvFile); - int chCount = settings->scope.voltage.count(); + int chCount = settings->scope.voltage.size(); std::vector voltageData(size_t(chCount), nullptr); std::vector spectrumData(size_t(chCount), nullptr); size_t maxRow = 0; diff --git a/openhantek/src/exporter.h b/openhantek/src/exporter.h index 547d838..9e5c327 100644 --- a/openhantek/src/exporter.h +++ b/openhantek/src/exporter.h @@ -9,7 +9,7 @@ class DsoSettings; class DataAnalyzerResult; -class DsoSettingsColorValues; +struct DsoSettingsColorValues; //////////////////////////////////////////////////////////////////////////////// /// \enum ExportFormat exporter.h diff --git a/openhantek/src/glgenerator.cpp b/openhantek/src/glgenerator.cpp index 0cd6002..6bcda04 100644 --- a/openhantek/src/glgenerator.cpp +++ b/openhantek/src/glgenerator.cpp @@ -8,9 +8,13 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : settings(scope), view(view) { // Grid - vaGrid[0].resize(((DIVS_TIME * DIVS_SUB - 2) * (DIVS_VOLTAGE - 2) + - (DIVS_VOLTAGE * DIVS_SUB - 2) * (DIVS_TIME - 2) - ((DIVS_TIME - 2) * (DIVS_VOLTAGE - 2))) * - 2); + const int DIVS_TIME_S2 = (int)DIVS_TIME - 2; + const int DIVS_VOLTAGE_S2 = (int)DIVS_VOLTAGE - 2; + const int vaGrid0Size = (int) ((DIVS_TIME * DIVS_SUB - 2) * DIVS_VOLTAGE_S2 + + (DIVS_VOLTAGE * DIVS_SUB - 2) * DIVS_TIME_S2 - + (DIVS_TIME_S2 * DIVS_VOLTAGE_S2)) * 2; + + vaGrid[0].resize(vaGrid0Size); std::vector::iterator glIterator = vaGrid[0].begin(); // Draw vertical lines for (int div = 1; div < DIVS_TIME / 2; ++div) { @@ -43,7 +47,7 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti } // Axes - vaGrid[1].resize((2 + (DIVS_TIME * DIVS_SUB - 2) + (DIVS_VOLTAGE * DIVS_SUB - 2)) * 4); + vaGrid[1].resize((int)(2 + (DIVS_TIME * DIVS_SUB - 2) + (DIVS_VOLTAGE * DIVS_SUB - 2)) * 4); glIterator = vaGrid[1].begin(); // Horizontal axis *(glIterator++) = -DIVS_TIME / 2; @@ -59,24 +63,24 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti for (int line = 1; line < DIVS_TIME / 2 * DIVS_SUB; ++line) { float linePosition = (float)line / DIVS_SUB; *(glIterator++) = linePosition; - *(glIterator++) = -0.05; + *(glIterator++) = -0.05f; *(glIterator++) = linePosition; - *(glIterator++) = 0.05; + *(glIterator++) = 0.05f; *(glIterator++) = -linePosition; - *(glIterator++) = -0.05; + *(glIterator++) = -0.05f; *(glIterator++) = -linePosition; - *(glIterator++) = 0.05; + *(glIterator++) = 0.05f; } // Subdiv lines on vertical axis for (int line = 1; line < DIVS_VOLTAGE / 2 * DIVS_SUB; ++line) { float linePosition = (float)line / DIVS_SUB; - *(glIterator++) = -0.05; + *(glIterator++) = -0.05f; *(glIterator++) = linePosition; - *(glIterator++) = 0.05; + *(glIterator++) = 0.05f; *(glIterator++) = linePosition; - *(glIterator++) = -0.05; + *(glIterator++) = -0.05f; *(glIterator++) = -linePosition; - *(glIterator++) = 0.05; + *(glIterator++) = 0.05f; *(glIterator++) = -linePosition; } @@ -93,7 +97,7 @@ GlGenerator::GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view) : setti *(glIterator++) = DIVS_VOLTAGE / 2; } -const std::vector &GlGenerator::channel(int mode, int channel, int index) const { +const std::vector &GlGenerator::channel(int mode, unsigned channel, unsigned index) const { return vaChannel[mode][channel][index]; } @@ -108,7 +112,7 @@ void GlGenerator::generateGraphs(const DataAnalyzerResult *result) { // Handle all digital phosphor related list manipulations for (int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { // Adapt the number of graphs - vaChannel[mode].resize(settings->voltage.count()); + vaChannel[mode].resize(settings->voltage.size()); for (unsigned int channel = 0; channel < vaChannel[mode].size(); ++channel) { // Move the last list element to the front diff --git a/openhantek/src/glgenerator.h b/openhantek/src/glgenerator.h index 2d25c37..b8e6e7b 100644 --- a/openhantek/src/glgenerator.h +++ b/openhantek/src/glgenerator.h @@ -25,7 +25,7 @@ class GlGenerator : public QObject { /// \param parent The parent widget. GlGenerator(DsoSettingsScope *scope, DsoSettingsView *view); void generateGraphs(const DataAnalyzerResult *result); - const std::vector &channel(int mode, int channel, int index) const; + const std::vector &channel(int mode, unsigned channel, unsigned index) const; const std::vector &grid(int a) const; bool isReady() const; diff --git a/openhantek/src/glscope.cpp b/openhantek/src/glscope.cpp index c3c3298..f67dad0 100644 --- a/openhantek/src/glscope.cpp +++ b/openhantek/src/glscope.cpp @@ -154,7 +154,7 @@ void GlScope::drawGraph() { case Dso::GRAPHFORMAT_TY: // Real and virtual channels for (int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { - for (int channel = 0; channel < settings->scope.voltage.count(); ++channel) { + for (int channel = 0; channel < settings->scope.voltage.size(); ++channel) { if (!channelUsed(mode, channel)) continue; // Draw graph for all available depths @@ -167,7 +167,7 @@ void GlScope::drawGraph() { case Dso::GRAPHFORMAT_XY: // Real and virtual channels - for (int channel = 0; channel < settings->scope.voltage.count() - 1; channel += 2) { + for (int channel = 0; channel < settings->scope.voltage.size() - 1; channel += 2) { if (settings->scope.voltage[channel].used) { for (int index = settings->view.digitalPhosphorDepth - 1; index >= 0; index--) { drawGraphDepth(Dso::CHANNELMODE_VOLTAGE, channel, index); diff --git a/openhantek/src/hantekdso/controlsettings.h b/openhantek/src/hantekdso/controlsettings.h index 9fc92f5..c35b27e 100644 --- a/openhantek/src/hantekdso/controlsettings.h +++ b/openhantek/src/hantekdso/controlsettings.h @@ -4,7 +4,7 @@ namespace Hantek { -class ControlSamplerateLimits; +struct ControlSamplerateLimits; ////////////////////////////////////////////////////////////////////////////// /// \struct ControlSettingsSamplerateTarget hantek/control.h diff --git a/openhantek/src/hantekdso/dsomodel.cpp b/openhantek/src/hantekdso/dsomodel.cpp index 2085f75..33b1ee4 100644 --- a/openhantek/src/hantekdso/dsomodel.cpp +++ b/openhantek/src/hantekdso/dsomodel.cpp @@ -3,6 +3,7 @@ #include "dsomodel.h" -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) +DSOModel::DSOModel(int id, long vendorID, long productID, long vendorIDnoFirmware, + long productIDnoFirmware, const std::string &firmwareToken, const std::string &name, const Hantek::ControlSpecification &specification) : ID(id), vendorID(vendorID), productID(productID), vendorIDnoFirmware(vendorIDnoFirmware), productIDnoFirmware(productIDnoFirmware), firmwareToken(firmwareToken), name(name), specification(specification) {} diff --git a/openhantek/src/hantekdso/dsomodel.h b/openhantek/src/hantekdso/dsomodel.h index d3ae356..dda3061 100644 --- a/openhantek/src/hantekdso/dsomodel.h +++ b/openhantek/src/hantekdso/dsomodel.h @@ -30,7 +30,7 @@ class DSOModel { /// This model may need to modify the HantekDsoControl class to work correctly virtual void applyRequirements(HantekDsoControl*) const = 0; DSOModel(int id, long vendorID, long productID, long vendorIDnoFirmware, long productIDnoFirmware, - std::string firmwareToken, const std::string name, const Hantek::ControlSpecification& specification); + const std::string& firmwareToken, const std::string& name, const Hantek::ControlSpecification& specification); virtual ~DSOModel() = default; }; diff --git a/openhantek/src/mainwindow.cpp b/openhantek/src/mainwindow.cpp index 8c092a3..4606705 100644 --- a/openhantek/src/mainwindow.cpp +++ b/openhantek/src/mainwindow.cpp @@ -474,7 +474,7 @@ void OpenHantekMainWindow::updateOffset(unsigned int channel) { /// \brief Sets the state of the given oscilloscope channel. /// \param channel The channel whose state has changed. void OpenHantekMainWindow::updateUsed(unsigned int channel) { - if (channel >= (unsigned int)settings->scope.voltage.count()) return; + if (channel >= (unsigned int)settings->scope.voltage.size()) return; bool mathUsed = settings->scope.voltage[settings->scope.physicalChannels].used | settings->scope.spectrum[settings->scope.physicalChannels].used; diff --git a/openhantek/src/scopesettings.h b/openhantek/src/scopesettings.h index 08ee025..d294a04 100644 --- a/openhantek/src/scopesettings.h +++ b/openhantek/src/scopesettings.h @@ -1,7 +1,7 @@ #pragma once #include "definitions.h" -#include +#include #include "analyse/enums.h" #include "hantekdso/enums.h" @@ -37,6 +37,7 @@ struct DsoSettingsScopeTrigger { /// \struct DsoSettingsScopeSpectrum settings.h /// \brief Holds the settings for the spectrum analysis. struct DsoSettingsScopeSpectrum { + unsigned channel; double magnitude; ///< The vertical resolution in dB/div QString name; ///< Name of this channel double offset; ///< Vertical offset in divs @@ -66,8 +67,8 @@ struct DsoSettingsScopeVoltage { struct DsoSettingsScope { DsoSettingsScopeHorizontal horizontal; ///< Settings for the horizontal axis DsoSettingsScopeTrigger trigger; ///< Settings for the trigger - QVector spectrum; ///< Spectrum analysis settings - QVector voltage; ///< Settings for the normal graphs + std::vector spectrum; ///< Spectrum analysis settings + std::vector voltage; ///< Settings for the normal graphs unsigned int physicalChannels = 0; ///< Number of real channels (No math etc.) Dso::WindowFunction spectrumWindow = Dso::WindowFunction::HANN; ///< Window function for DFT diff --git a/openhantek/src/settings.cpp b/openhantek/src/settings.cpp index 5d49323..3c438b1 100644 --- a/openhantek/src/settings.cpp +++ b/openhantek/src/settings.cpp @@ -48,68 +48,31 @@ bool DsoSettings::setFilename(const QString &filename) { return true; } -void DsoSettings::setChannelCount(unsigned int channels) { - this->scope.physicalChannels = channels; - // Always put the math channel at the end of the list - - // Remove list items for removed channels - for (int channel = this->scope.spectrum.count() - 2; channel >= (int)channels; channel--) - this->scope.spectrum.removeAt(channel); - for (int channel = this->scope.voltage.count() - 2; channel >= (int)channels; channel--) - this->scope.voltage.removeAt(channel); - for (int channel = this->scope.spectrum.count() - 2; channel >= (int)channels; channel--) - this->scope.spectrum.removeAt(channel); - for (int channel = this->scope.spectrum.count() - 2; channel >= (int)channels; channel--) - this->scope.spectrum.removeAt(channel); +template +inline void removeIfPossible(std::vector& v, unsigned start, unsigned keepAtEnd) { + if (start=keepAtEnd) ? keepAtEnd : 0)); +} - // Add new channels to the list - for (int channel = 0; channel < (int)channels; ++channel) { - // Oscilloscope settings - // Spectrum - if (this->scope.spectrum.count() <= channel + 1) { - DsoSettingsScopeSpectrum newSpectrum; - newSpectrum.magnitude = 20.0; - newSpectrum.name = QApplication::tr("SP%1").arg(channel + 1); - newSpectrum.offset = 0.0; - newSpectrum.used = false; - this->scope.spectrum.insert(channel, newSpectrum); - } - // Voltage - if (this->scope.voltage.count() <= channel + 1) { - DsoSettingsScopeVoltage newVoltage; - newVoltage.gain = 1.0; - newVoltage.coupling = Dso::COUPLING_DC; - newVoltage.name = QApplication::tr("CH%1").arg(channel + 1); - newVoltage.offset = 0.0; - newVoltage.trigger = 0.0; - newVoltage.used = false; - this->scope.voltage.insert(channel, newVoltage); - } +void DsoSettings::setChannelCount(unsigned channels) { + scope.physicalChannels = channels; - // View - // Colors - // Screen - if (this->view.screen.voltage.count() <= channel + 1) - this->view.screen.voltage.insert(channel, QColor::fromHsv(channel * 60, 0xff, 0xff)); - if (this->view.screen.spectrum.count() <= channel + 1) - this->view.screen.spectrum.insert(channel, this->view.screen.voltage[channel].lighter()); - // Print - if (this->view.print.voltage.count() <= channel + 1) - this->view.print.voltage.insert(channel, this->view.screen.voltage[channel].darker(120)); - if (this->view.print.spectrum.count() <= channel + 1) - this->view.print.spectrum.insert(channel, this->view.screen.voltage[channel].darker()); - } + // Remove list items for removed channels, keep last channel (math channel) + removeIfPossible(scope.spectrum, channels, 1); + removeIfPossible(scope.voltage, channels, 1); + removeIfPossible(view.screen.voltage, channels, 1); + removeIfPossible(view.print.voltage, channels, 1); + // Add math channel if missing // Check if the math channel is missing - if (this->scope.spectrum.count() <= (int)channels) { + if (!scope.spectrum.size()) { DsoSettingsScopeSpectrum newSpectrum; newSpectrum.magnitude = 20.0; newSpectrum.name = QApplication::tr("SPM"); newSpectrum.offset = 0.0; newSpectrum.used = false; - this->scope.spectrum.append(newSpectrum); - } - if (this->scope.voltage.count() <= (int)channels) { + scope.spectrum.push_back(newSpectrum); + DsoSettingsScopeVoltage newVoltage; newVoltage.gain = 1.0; newVoltage.math = Dso::MathMode::ADD_CH1_CH2; @@ -117,23 +80,49 @@ void DsoSettings::setChannelCount(unsigned int channels) { newVoltage.offset = 0.0; newVoltage.trigger = 0.0; newVoltage.used = false; - this->scope.voltage.append(newVoltage); + scope.voltage.push_back(newVoltage); + + view.screen.voltage.push_back(QColor(0x7f, 0x7f, 0x7f, 0xff)); + view.screen.spectrum.push_back(view.screen.voltage.back().lighter()); + view.print.voltage.push_back(view.screen.voltage.back()); + view.print.spectrum.push_back(view.print.voltage.back().darker()); } - if (this->view.screen.voltage.count() <= (int)channels) - this->view.screen.voltage.append(QColor(0x7f, 0x7f, 0x7f, 0xff)); - if (this->view.screen.spectrum.count() <= (int)channels) - this->view.screen.spectrum.append(this->view.screen.voltage[channels].lighter()); - if (this->view.print.voltage.count() <= (int)channels) - this->view.print.voltage.append(this->view.screen.voltage[channels]); - if (this->view.print.spectrum.count() <= (int)channels) - this->view.print.spectrum.append(this->view.print.voltage[channels].darker()); + + // Add new channels to the list + while (scope.spectrum.size() <= channels) { + // Oscilloscope settings + // Spectrum + DsoSettingsScopeSpectrum newSpectrum; + newSpectrum.magnitude = 20.0; + newSpectrum.name = QApplication::tr("SP%1").arg(scope.spectrum.size()); + newSpectrum.offset = 0.0; + newSpectrum.used = false; + scope.spectrum.insert(scope.spectrum.end()-1, newSpectrum); + + // Voltage + DsoSettingsScopeVoltage newVoltage; + newVoltage.gain = 1.0; + newVoltage.coupling = Dso::COUPLING_DC; + newVoltage.name = QApplication::tr("CH%1").arg(scope.voltage.size()); + newVoltage.offset = 0.0; + newVoltage.trigger = 0.0; + newVoltage.used = false; + scope.voltage.insert(scope.voltage.end()-1, newVoltage); + + view.screen.voltage.insert(view.screen.voltage.end()-1, QColor::fromHsv((int)(view.screen.voltage.size()-1) * 60, 0xff, 0xff)); + view.screen.spectrum.insert(view.screen.spectrum.end()-1, view.screen.voltage.back().lighter()); + view.print.voltage.insert(view.print.voltage.end()-1, view.screen.voltage.back().darker(120)); + view.print.spectrum.insert(view.print.spectrum.end()-1, view.screen.voltage.back().darker()); + } + + } void DsoSettings::load() { // General options store->beginGroup("options"); - if (store->contains("alwaysSave")) this->options.alwaysSave = store->value("alwaysSave").toBool(); - if (store->contains("imageSize")) this->options.imageSize = store->value("imageSize").toSize(); + if (store->contains("alwaysSave")) options.alwaysSave = store->value("alwaysSave").toBool(); + if (store->contains("imageSize")) options.imageSize = store->value("imageSize").toSize(); // If the window/* keys were found in this group, remove them from settings store->remove("window"); store->endGroup(); @@ -142,52 +131,52 @@ void DsoSettings::load() { store->beginGroup("scope"); // Horizontal axis store->beginGroup("horizontal"); - if (store->contains("format")) this->scope.horizontal.format = (Dso::GraphFormat)store->value("format").toInt(); + if (store->contains("format")) scope.horizontal.format = (Dso::GraphFormat)store->value("format").toInt(); if (store->contains("frequencybase")) - this->scope.horizontal.frequencybase = store->value("frequencybase").toDouble(); + scope.horizontal.frequencybase = store->value("frequencybase").toDouble(); for (int marker = 0; marker < 2; ++marker) { QString name; name = QString("marker%1").arg(marker); - if (store->contains(name)) this->scope.horizontal.marker[marker] = store->value(name).toDouble(); + if (store->contains(name)) scope.horizontal.marker[marker] = store->value(name).toDouble(); } - if (store->contains("timebase")) this->scope.horizontal.timebase = store->value("timebase").toDouble(); - if (store->contains("recordLength")) this->scope.horizontal.recordLength = store->value("recordLength").toUInt(); - if (store->contains("samplerate")) this->scope.horizontal.samplerate = store->value("samplerate").toDouble(); - if (store->contains("samplerateSet")) this->scope.horizontal.samplerateSet = store->value("samplerateSet").toBool(); + if (store->contains("timebase")) scope.horizontal.timebase = store->value("timebase").toDouble(); + if (store->contains("recordLength")) scope.horizontal.recordLength = store->value("recordLength").toUInt(); + if (store->contains("samplerate")) scope.horizontal.samplerate = store->value("samplerate").toDouble(); + if (store->contains("samplerateSet")) scope.horizontal.samplerateSet = store->value("samplerateSet").toBool(); store->endGroup(); // Trigger store->beginGroup("trigger"); - if (store->contains("filter")) this->scope.trigger.filter = store->value("filter").toBool(); - if (store->contains("mode")) this->scope.trigger.mode = (Dso::TriggerMode)store->value("mode").toInt(); - if (store->contains("position")) this->scope.trigger.position = store->value("position").toDouble(); - if (store->contains("slope")) this->scope.trigger.slope = (Dso::Slope)store->value("slope").toInt(); - if (store->contains("source")) this->scope.trigger.source = store->value("source").toInt(); - if (store->contains("special")) this->scope.trigger.special = store->value("special").toInt(); + if (store->contains("filter")) scope.trigger.filter = store->value("filter").toBool(); + if (store->contains("mode")) scope.trigger.mode = (Dso::TriggerMode)store->value("mode").toInt(); + if (store->contains("position")) scope.trigger.position = store->value("position").toDouble(); + if (store->contains("slope")) scope.trigger.slope = (Dso::Slope)store->value("slope").toInt(); + if (store->contains("source")) scope.trigger.source = store->value("source").toInt(); + if (store->contains("special")) scope.trigger.special = store->value("special").toInt(); store->endGroup(); // Spectrum - for (int channel = 0; channel < this->scope.spectrum.count(); ++channel) { + for (unsigned channel = 0; channel < scope.spectrum.size(); ++channel) { store->beginGroup(QString("spectrum%1").arg(channel)); if (store->contains("magnitude")) - this->scope.spectrum[channel].magnitude = store->value("magnitude").toDouble(); - if (store->contains("offset")) this->scope.spectrum[channel].offset = store->value("offset").toDouble(); - if (store->contains("used")) this->scope.spectrum[channel].used = store->value("used").toBool(); + scope.spectrum[channel].magnitude = store->value("magnitude").toDouble(); + if (store->contains("offset")) scope.spectrum[channel].offset = store->value("offset").toDouble(); + if (store->contains("used")) scope.spectrum[channel].used = store->value("used").toBool(); store->endGroup(); } // Vertical axis - for (int channel = 0; channel < this->scope.voltage.count(); ++channel) { + for (unsigned channel = 0; channel < scope.voltage.size(); ++channel) { store->beginGroup(QString("vertical%1").arg(channel)); - if (store->contains("gain")) this->scope.voltage[channel].gain = store->value("gain").toDouble(); - if (store->contains("misc")) this->scope.voltage[channel].rawValue = store->value("misc").toInt(); - if (store->contains("offset")) this->scope.voltage[channel].offset = store->value("offset").toDouble(); - if (store->contains("trigger")) this->scope.voltage[channel].trigger = store->value("trigger").toDouble(); - if (store->contains("used")) this->scope.voltage[channel].used = store->value("used").toBool(); + if (store->contains("gain")) scope.voltage[channel].gain = store->value("gain").toDouble(); + if (store->contains("misc")) scope.voltage[channel].rawValue = store->value("misc").toInt(); + if (store->contains("offset")) scope.voltage[channel].offset = store->value("offset").toDouble(); + if (store->contains("trigger")) scope.voltage[channel].trigger = store->value("trigger").toDouble(); + if (store->contains("used")) scope.voltage[channel].used = store->value("used").toBool(); store->endGroup(); } - if (store->contains("spectrumLimit")) this->scope.spectrumLimit = store->value("spectrumLimit").toDouble(); + if (store->contains("spectrumLimit")) scope.spectrumLimit = store->value("spectrumLimit").toDouble(); if (store->contains("spectrumReference")) - this->scope.spectrumReference = store->value("spectrumReference").toDouble(); + scope.spectrumReference = store->value("spectrumReference").toDouble(); if (store->contains("spectrumWindow")) - this->scope.spectrumWindow = (Dso::WindowFunction)store->value("spectrumWindow").toInt(); + scope.spectrumWindow = (Dso::WindowFunction)store->value("spectrumWindow").toInt(); store->endGroup(); // View @@ -197,10 +186,10 @@ void DsoSettings::load() { DsoSettingsColorValues *colors; for (int mode = 0; mode < 2; ++mode) { if (mode == 0) { - colors = &this->view.screen; + colors = &view.screen; store->beginGroup("screen"); } else { - colors = &this->view.print; + colors = &view.print; store->beginGroup("print"); } @@ -209,12 +198,12 @@ void DsoSettings::load() { if (store->contains("border")) colors->border = store->value("border").value(); if (store->contains("grid")) colors->grid = store->value("grid").value(); if (store->contains("markers")) colors->markers = store->value("markers").value(); - for (int channel = 0; channel < this->scope.spectrum.count(); ++channel) { + for (unsigned channel = 0; channel < scope.spectrum.size(); ++channel) { QString key = QString("spectrum%1").arg(channel); if (store->contains(key)) colors->spectrum[channel] = store->value(key).value(); } if (store->contains("text")) colors->text = store->value("text").value(); - for (int channel = 0; channel < this->scope.voltage.count(); ++channel) { + for (unsigned channel = 0; channel < scope.voltage.size(); ++channel) { QString key = QString("voltage%1").arg(channel); if (store->contains(key)) colors->voltage[channel] = store->value(key).value(); } @@ -222,11 +211,11 @@ void DsoSettings::load() { } store->endGroup(); // Other view settings - if (store->contains("digitalPhosphor")) this->view.digitalPhosphor = store->value("digitalPhosphor").toBool(); + if (store->contains("digitalPhosphor")) view.digitalPhosphor = store->value("digitalPhosphor").toBool(); if (store->contains("interpolation")) - this->view.interpolation = (Dso::InterpolationMode)store->value("interpolation").toInt(); - if (store->contains("screenColorImages")) this->view.screenColorImages = store->value("screenColorImages").toBool(); - if (store->contains("zoom")) this->view.zoom = (Dso::InterpolationMode)store->value("zoom").toBool(); + view.interpolation = (Dso::InterpolationMode)store->value("interpolation").toInt(); + if (store->contains("screenColorImages")) view.screenColorImages = store->value("screenColorImages").toBool(); + if (store->contains("zoom")) view.zoom = (Dso::InterpolationMode)store->value("zoom").toBool(); store->endGroup(); store->beginGroup("window"); @@ -238,53 +227,53 @@ void DsoSettings::load() { void DsoSettings::save() { // Main window layout and other general options store->beginGroup("options"); - store->setValue("alwaysSave", this->options.alwaysSave); - store->setValue("imageSize", this->options.imageSize); + store->setValue("alwaysSave", options.alwaysSave); + store->setValue("imageSize", options.imageSize); store->endGroup(); // Oszilloskope settings store->beginGroup("scope"); // Horizontal axis store->beginGroup("horizontal"); - store->setValue("format", this->scope.horizontal.format); - store->setValue("frequencybase", this->scope.horizontal.frequencybase); + store->setValue("format", scope.horizontal.format); + store->setValue("frequencybase", scope.horizontal.frequencybase); for (int marker = 0; marker < 2; ++marker) - store->setValue(QString("marker%1").arg(marker), this->scope.horizontal.marker[marker]); - store->setValue("timebase", this->scope.horizontal.timebase); - store->setValue("recordLength", this->scope.horizontal.recordLength); - store->setValue("samplerate", this->scope.horizontal.samplerate); - store->setValue("samplerateSet", this->scope.horizontal.samplerateSet); + store->setValue(QString("marker%1").arg(marker), scope.horizontal.marker[marker]); + store->setValue("timebase", scope.horizontal.timebase); + store->setValue("recordLength", scope.horizontal.recordLength); + store->setValue("samplerate", scope.horizontal.samplerate); + store->setValue("samplerateSet", scope.horizontal.samplerateSet); store->endGroup(); // Trigger store->beginGroup("trigger"); - store->setValue("filter", this->scope.trigger.filter); - store->setValue("mode", this->scope.trigger.mode); - store->setValue("position", this->scope.trigger.position); - store->setValue("slope", this->scope.trigger.slope); - store->setValue("source", this->scope.trigger.source); - store->setValue("special", this->scope.trigger.special); + store->setValue("filter", scope.trigger.filter); + store->setValue("mode", scope.trigger.mode); + store->setValue("position", scope.trigger.position); + store->setValue("slope", scope.trigger.slope); + store->setValue("source", scope.trigger.source); + store->setValue("special", scope.trigger.special); store->endGroup(); // Spectrum - for (int channel = 0; channel < this->scope.spectrum.count(); ++channel) { + for (unsigned channel = 0; channel < scope.spectrum.size(); ++channel) { store->beginGroup(QString("spectrum%1").arg(channel)); - store->setValue("magnitude", this->scope.spectrum[channel].magnitude); - store->setValue("offset", this->scope.spectrum[channel].offset); - store->setValue("used", this->scope.spectrum[channel].used); + store->setValue("magnitude", scope.spectrum[channel].magnitude); + store->setValue("offset", scope.spectrum[channel].offset); + store->setValue("used", scope.spectrum[channel].used); store->endGroup(); } // Vertical axis - for (int channel = 0; channel < this->scope.voltage.count(); ++channel) { + for (unsigned channel = 0; channel < scope.voltage.size(); ++channel) { store->beginGroup(QString("vertical%1").arg(channel)); - store->setValue("gain", this->scope.voltage[channel].gain); - store->setValue("misc", this->scope.voltage[channel].rawValue); - store->setValue("offset", this->scope.voltage[channel].offset); - store->setValue("trigger", this->scope.voltage[channel].trigger); - store->setValue("used", this->scope.voltage[channel].used); + store->setValue("gain", scope.voltage[channel].gain); + store->setValue("misc", scope.voltage[channel].rawValue); + store->setValue("offset", scope.voltage[channel].offset); + store->setValue("trigger", scope.voltage[channel].trigger); + store->setValue("used", scope.voltage[channel].used); store->endGroup(); } - store->setValue("spectrumLimit", this->scope.spectrumLimit); - store->setValue("spectrumReference", this->scope.spectrumReference); - store->setValue("spectrumWindow", (int)this->scope.spectrumWindow); + store->setValue("spectrumLimit", scope.spectrumLimit); + store->setValue("spectrumReference", scope.spectrumReference); + store->setValue("spectrumWindow", (int)scope.spectrumWindow); store->endGroup(); // View @@ -295,10 +284,10 @@ void DsoSettings::save() { DsoSettingsColorValues *colors; for (int mode = 0; mode < 2; ++mode) { if (mode == 0) { - colors = &this->view.screen; + colors = &view.screen; store->beginGroup("screen"); } else { - colors = &this->view.print; + colors = &view.print; store->beginGroup("print"); } @@ -307,20 +296,20 @@ void DsoSettings::save() { store->setValue("border", colors->border); store->setValue("grid", colors->grid); store->setValue("markers", colors->markers); - for (int channel = 0; channel < this->scope.spectrum.count(); ++channel) + for (unsigned channel = 0; channel < scope.spectrum.size(); ++channel) store->setValue(QString("spectrum%1").arg(channel), colors->spectrum[channel]); store->setValue("text", colors->text); - for (int channel = 0; channel < this->scope.voltage.count(); ++channel) + for (unsigned channel = 0; channel < scope.voltage.size(); ++channel) store->setValue(QString("voltage%1").arg(channel), colors->voltage[channel]); store->endGroup(); } store->endGroup(); // Other view settings - store->setValue("digitalPhosphor", this->view.digitalPhosphor); - store->setValue("interpolation", this->view.interpolation); - store->setValue("screenColorImages", this->view.screenColorImages); - store->setValue("zoom", this->view.zoom); + store->setValue("digitalPhosphor", view.digitalPhosphor); + store->setValue("interpolation", view.interpolation); + store->setValue("screenColorImages", view.screenColorImages); + store->setValue("zoom", view.zoom); store->endGroup(); store->beginGroup("window"); diff --git a/openhantek/src/usb/ezusb.cpp b/openhantek/src/usb/ezusb.cpp index e5a0361..fa42e04 100644 --- a/openhantek/src/usb/ezusb.cpp +++ b/openhantek/src/usb/ezusb.cpp @@ -20,6 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#define _CRT_SECURE_NO_WARNINGS #include #include #include diff --git a/openhantek/src/viewsettings.h b/openhantek/src/viewsettings.h index ac96390..140bbfd 100644 --- a/openhantek/src/viewsettings.h +++ b/openhantek/src/viewsettings.h @@ -17,8 +17,8 @@ struct DsoSettingsColorValues { QColor grid; ///< The color of the grid QColor markers; ///< The color of the markers QColor text; ///< The default text color - QVector spectrum; ///< The colors of the spectrum graphs - QVector voltage; ///< The colors of the voltage graphs + std::vector spectrum; ///< The colors of the spectrum graphs + std::vector voltage; ///< The colors of the voltage graphs }; //////////////////////////////////////////////////////////////////////////////// @@ -31,16 +31,16 @@ struct DsoSettingsView { QColor(0xff, 0xff, 0xff, 0x3f), QColor(0xff, 0xff, 0xff, 0xbf), QColor(0xff, 0xff, 0xff, 0xff), - QVector(), - QVector()}; + std::vector(), + std::vector()}; DsoSettingsColorValues print = {QColor(0x00, 0x00, 0x00, 0xbf), QColor(0x00, 0x00, 0x00, 0x00), QColor(0x00, 0x00, 0x00, 0xff), QColor(0x00, 0x00, 0x00, 0x7f), QColor(0x00, 0x00, 0x00, 0xef), QColor(0x00, 0x00, 0x00, 0xff), - QVector(), - QVector()}; + std::vector(), + std::vector()}; bool antialiasing = true; ///< Antialiasing for the graphs bool digitalPhosphor = false; ///< true slowly fades out the previous graphs int digitalPhosphorDepth = 8; ///< Number of channels shown at one time diff --git a/openhantek/src/widgets/colorbox.h b/openhantek/src/widgets/colorbox.h index 840a0f5..8519fed 100644 --- a/openhantek/src/widgets/colorbox.h +++ b/openhantek/src/widgets/colorbox.h @@ -1,35 +1,10 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// OpenHantek -/// \file colorbox.h -/// \brief Declares the ColorBox class. -// -// Copyright (C) 2010 Oliver Haag -// oliver.haag@gmail.com -// -// This program is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with -// this program. If not, see . -// -//////////////////////////////////////////////////////////////////////////////// - -#ifndef COLORBOX_H -#define COLORBOX_H +// SPDX-License-Identifier: GPL-2.0+ + +#pragma once #include #include -//////////////////////////////////////////////////////////////////////////////// -/// \class ColorBox colorbox.h /// \brief A widget for the selection of a color. class ColorBox : public QPushButton { Q_OBJECT @@ -50,5 +25,3 @@ class ColorBox : public QPushButton { signals: void colorChanged(QColor color); ///< The color has been changed }; - -#endif diff --git a/openhantek/src/widgets/levelslider.cpp b/openhantek/src/widgets/levelslider.cpp index 4083d6f..f051baf 100644 --- a/openhantek/src/widgets/levelslider.cpp +++ b/openhantek/src/widgets/levelslider.cpp @@ -126,13 +126,11 @@ const QColor LevelSlider::color(int index) const { /// \param index The index of the slider whose color should be set. /// \param color The new color for the slider. /// \return The index of the slider, -1 on error. -int LevelSlider::setColor(int index, QColor color) { - if (index < 0 || index >= this->slider.count()) return -1; +void LevelSlider::setColor(unsigned index, QColor color) { + if (index >= (unsigned)this->slider.count()) return; - this->slider[index]->color = color; + this->slider[(int)index]->color = color; this->repaint(); - - return index; } /// \brief Return the text shown beside a slider. @@ -170,13 +168,11 @@ bool LevelSlider::visible(int index) const { /// \param index The index of the slider whose visibility should be set. /// \param visible true to show the slider, false to hide it. /// \return The index of the slider, -1 on error. -int LevelSlider::setVisible(int index, bool visible) { - if (index < 0 || index >= this->slider.count()) return -1; +void LevelSlider::setIndexVisible(unsigned index, bool visible) { + if (index >= (unsigned)this->slider.count()) return; - this->slider[index]->visible = visible; + this->slider[(int)index]->visible = visible; this->repaint(); - - return index; } /// \brief Return the minimal value of the sliders. diff --git a/openhantek/src/widgets/levelslider.h b/openhantek/src/widgets/levelslider.h index b521ddb..682f35d 100644 --- a/openhantek/src/widgets/levelslider.h +++ b/openhantek/src/widgets/levelslider.h @@ -1,36 +1,11 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// OpenHantek -/// \file levelslider.h -/// \brief Declares the LevelSlider class. -// -// Copyright (C) 2010 Oliver Haag -// oliver.haag@gmail.com -// -// This program is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with -// this program. If not, see . -// -//////////////////////////////////////////////////////////////////////////////// +// SPDX-License-Identifier: GPL-2.0+ -#ifndef LEVELSLIDER_H -#define LEVELSLIDER_H +#pragma once #include class QColor; -//////////////////////////////////////////////////////////////////////////////// -/// \struct LevelSliderParameters levelslider.h /// \brief Contains the color, text and value of one slider. struct LevelSliderParameters { QColor color; ///< The color of the slider and font @@ -68,11 +43,11 @@ class LevelSlider : public QWidget { // Parameters for a specific slider const QColor color(int index) const; - int setColor(int index, QColor color); + void setColor(unsigned index, QColor color); const QString text(int index) const; int setText(int index, QString text); bool visible(int index) const; - int setVisible(int index, bool visible); + void setIndexVisible(unsigned index, bool visible); double minimum(int index) const; double maximum(int index) const; @@ -110,5 +85,3 @@ class LevelSlider : public QWidget { signals: void valueChanged(int index, double value); ///< The value of a slider has changed }; - -#endif diff --git a/openhantek/src/widgets/sispinbox.h b/openhantek/src/widgets/sispinbox.h index 5e572e2..1795a44 100644 --- a/openhantek/src/widgets/sispinbox.h +++ b/openhantek/src/widgets/sispinbox.h @@ -1,37 +1,12 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// OpenHantek -/// \file sispinbox.h -/// \brief Declares the SiSpinBox class. -// -// Copyright (C) 2010, 2011 Oliver Haag -// oliver.haag@gmail.com -// -// This program is free software: you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation, either version 3 of the License, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with -// this program. If not, see . -// -//////////////////////////////////////////////////////////////////////////////// +// SPDX-License-Identifier: GPL-2.0+ -#ifndef SISPINBOX_H -#define SISPINBOX_H +#pragma once #include #include #include "utils/printutils.h" -//////////////////////////////////////////////////////////////////////////////// -/// \class SiSpinBox sispinbox.h /// \brief A spin box with SI prefix support. /// This spin box supports the SI prefixes (k/M/G/T) after its value and allows /// floating point values. The step size is increasing in an exponential way, to @@ -70,5 +45,3 @@ class SiSpinBox : public QDoubleSpinBox { private slots: void resetSteppedTo(); }; - -#endif