Commit 77f4c7b5fe01cfbce44ebaac7222fbc641583670
1 parent
8c511e69
Small fixes and performance improvements
Showing
18 changed files
with
479 additions
and
384 deletions
openhantek/ChangeLog
| ... | ... | @@ -164,3 +164,8 @@ |
| 164 | 164 | |
| 165 | 165 | 2012-10-07 Oliver Haag <oliver.haag@gmail.com> |
| 166 | 166 | * Ignore errors after first packet was received by Hantek::Device::bulkReadMulti |
| 167 | + | |
| 168 | +2012-10-17 Oliver Haag <oliver.haag@gmail.com> | |
| 169 | +* Change back workaround for Mac OS that is most probably not required anymore | |
| 170 | +* Various performance improvements and small fixes | |
| 171 | +* New cppcheck build target | ... | ... |
openhantek/OpenHantek.pro
| 1 | +# Helper functions | |
| 2 | +defineReplace(surround) { | |
| 3 | + elements = $$1 | |
| 4 | + prefix = $$2 | |
| 5 | + postfix = $$3 | |
| 6 | + result = | |
| 7 | + for(element, elements) { | |
| 8 | + result += "$${prefix}$${element}$${postfix}" | |
| 9 | + } | |
| 10 | + return($${result}) | |
| 11 | +} | |
| 12 | + | |
| 1 | 13 | TEMPLATE = app |
| 2 | 14 | |
| 3 | 15 | # Configuration |
| 4 | -CONFIG += warn_on \ | |
| 5 | - qt | |
| 16 | +CONFIG += \ | |
| 17 | + warn_on \ | |
| 18 | + qt | |
| 6 | 19 | QT += opengl |
| 7 | 20 | LIBS += -lfftw3 |
| 8 | 21 | |
| 9 | 22 | # Source files |
| 10 | -SOURCES += src/colorbox.cpp \ | |
| 11 | - src/configdialog.cpp \ | |
| 12 | - src/configpages.cpp \ | |
| 13 | - src/dataanalyzer.cpp \ | |
| 14 | - src/dockwindows.cpp \ | |
| 15 | - src/dsocontrol.cpp \ | |
| 16 | - src/dsowidget.cpp \ | |
| 17 | - src/exporter.cpp \ | |
| 18 | - src/glgenerator.cpp \ | |
| 19 | - src/glscope.cpp \ | |
| 20 | - src/helper.cpp \ | |
| 21 | - src/levelslider.cpp \ | |
| 22 | - src/main.cpp \ | |
| 23 | - src/openhantek.cpp \ | |
| 24 | - src/settings.cpp \ | |
| 25 | - src/hantek/control.cpp \ | |
| 26 | - src/hantek/device.cpp \ | |
| 27 | - src/hantek/types.cpp \ | |
| 28 | - src/dso.cpp | |
| 29 | -HEADERS += src/colorbox.h \ | |
| 30 | - src/configdialog.h \ | |
| 31 | - src/configpages.h \ | |
| 32 | - src/dataanalyzer.h \ | |
| 33 | - src/dockwindows.h \ | |
| 34 | - src/dsocontrol.h \ | |
| 35 | - src/dsowidget.h \ | |
| 36 | - src/exporter.h \ | |
| 37 | - src/glscope.h \ | |
| 38 | - src/glgenerator.h \ | |
| 39 | - src/helper.h \ | |
| 40 | - src/levelslider.h \ | |
| 41 | - src/openhantek.h \ | |
| 42 | - src/settings.h \ | |
| 43 | - src/hantek/control.h \ | |
| 44 | - src/hantek/device.h \ | |
| 45 | - src/hantek/types.h \ | |
| 46 | - src/dso.h | |
| 23 | +SOURCES += \ | |
| 24 | + src/colorbox.cpp \ | |
| 25 | + src/configdialog.cpp \ | |
| 26 | + src/configpages.cpp \ | |
| 27 | + src/dataanalyzer.cpp \ | |
| 28 | + src/dockwindows.cpp \ | |
| 29 | + src/dsocontrol.cpp \ | |
| 30 | + src/dsowidget.cpp \ | |
| 31 | + src/exporter.cpp \ | |
| 32 | + src/glgenerator.cpp \ | |
| 33 | + src/glscope.cpp \ | |
| 34 | + src/helper.cpp \ | |
| 35 | + src/levelslider.cpp \ | |
| 36 | + src/main.cpp \ | |
| 37 | + src/openhantek.cpp \ | |
| 38 | + src/settings.cpp \ | |
| 39 | + src/hantek/control.cpp \ | |
| 40 | + src/hantek/device.cpp \ | |
| 41 | + src/hantek/types.cpp \ | |
| 42 | + src/dso.cpp | |
| 43 | +HEADERS += \ | |
| 44 | + src/colorbox.h \ | |
| 45 | + src/configdialog.h \ | |
| 46 | + src/configpages.h \ | |
| 47 | + src/dataanalyzer.h \ | |
| 48 | + src/dockwindows.h \ | |
| 49 | + src/dsocontrol.h \ | |
| 50 | + src/dsowidget.h \ | |
| 51 | + src/exporter.h \ | |
| 52 | + src/glscope.h \ | |
| 53 | + src/glgenerator.h \ | |
| 54 | + src/helper.h \ | |
| 55 | + src/levelslider.h \ | |
| 56 | + src/openhantek.h \ | |
| 57 | + src/settings.h \ | |
| 58 | + src/hantek/control.h \ | |
| 59 | + src/hantek/device.h \ | |
| 60 | + src/hantek/types.h \ | |
| 61 | + src/dso.h | |
| 47 | 62 | |
| 48 | 63 | # Ressource files |
| 49 | -RESOURCES += res/application.qrc \ | |
| 50 | - res/configdialog.qrc | |
| 64 | +RESOURCES += \ | |
| 65 | + res/application.qrc \ | |
| 66 | + res/configdialog.qrc | |
| 51 | 67 | |
| 52 | 68 | # Doxygen files |
| 53 | -DOXYFILES += Doxyfile \ | |
| 54 | - mainpage.dox \ | |
| 55 | - roadmap.dox | |
| 69 | +DOXYFILES += \ | |
| 70 | + Doxyfile \ | |
| 71 | + mainpage.dox \ | |
| 72 | + roadmap.dox | |
| 56 | 73 | |
| 57 | 74 | # Files copied into the distribution package |
| 58 | -DISTFILES += ChangeLog \ | |
| 59 | - COPYING \ | |
| 60 | - INSTALL \ | |
| 61 | - res/images/*.png \ | |
| 62 | - res/images/*.icns \ | |
| 63 | - res/images/*.svg \ | |
| 64 | - translations/*.qm \ | |
| 65 | - translations/*.ts \ | |
| 66 | - $${DOXYFILES} | |
| 75 | +DISTFILES += \ | |
| 76 | + ChangeLog \ | |
| 77 | + COPYING \ | |
| 78 | + INSTALL \ | |
| 79 | + res/images/*.png \ | |
| 80 | + res/images/*.icns \ | |
| 81 | + res/images/*.svg \ | |
| 82 | + translations/*.qm \ | |
| 83 | + translations/*.ts \ | |
| 84 | + $${DOXYFILES} | |
| 67 | 85 | |
| 68 | 86 | # Translations |
| 69 | 87 | TRANSLATIONS += translations/openhantek_de.ts |
| ... | ... | @@ -82,15 +100,14 @@ OBJECTS_DIR = build/obj |
| 82 | 100 | UI_DIR = build/ui |
| 83 | 101 | MOC_DIR = build/moc |
| 84 | 102 | |
| 85 | -# Include directory | |
| 86 | -QMAKE_CXXFLAGS += "-iquote $${IN_PWD}/src" | |
| 87 | - | |
| 88 | 103 | # libusb version |
| 89 | 104 | LIBUSB_VERSION = $$(LIBUSB_VERSION) |
| 90 | -contains(LIBUSB_VERSION, 0): LIBS += -lusb | |
| 105 | +contains(LIBUSB_VERSION, 0) { | |
| 106 | + LIBS += -lusb | |
| 107 | +} | |
| 91 | 108 | else { |
| 92 | - LIBUSB_VERSION = 1 | |
| 93 | - LIBS += -lusb-1.0 | |
| 109 | + LIBUSB_VERSION = 1 | |
| 110 | + LIBS += -lusb-1.0 | |
| 94 | 111 | } |
| 95 | 112 | DEFINES += LIBUSB_VERSION=$${LIBUSB_VERSION} |
| 96 | 113 | |
| ... | ... | @@ -98,49 +115,74 @@ DEFINES += LIBUSB_VERSION=$${LIBUSB_VERSION} |
| 98 | 115 | CONFIG(debug, debug|release): DEFINES += DEBUG |
| 99 | 116 | else: DEFINES += QT_NO_DEBUG_OUTPUT |
| 100 | 117 | |
| 118 | +# Quoted include directories | |
| 119 | +INCLUDEPATH_QUOTE = "$${IN_PWD}/src" | |
| 120 | + | |
| 121 | +# Include directory | |
| 122 | +QMAKE_CXXFLAGS += "-iquote $${INCLUDEPATH_QUOTE}" | |
| 123 | + | |
| 101 | 124 | # Settings for different operating systems |
| 102 | 125 | unix:!macx { |
| 103 | - isEmpty(PREFIX):PREFIX = /usr/local | |
| 104 | - TARGET = openhantek | |
| 105 | - | |
| 106 | - # Installation directories | |
| 107 | - target.path = $${PREFIX}/bin | |
| 108 | - translations.path = $${PREFIX}/share/apps/openhantek/translations | |
| 109 | - INCLUDEPATH += /usr/include/libusb | |
| 110 | - DEFINES += QMAKE_TRANSLATIONS_PATH=\\\"$${translations.path}\\\" \ | |
| 111 | - OS_UNIX VERSION=\\\"$${VERSION}\\\" | |
| 126 | + isEmpty(PREFIX): PREFIX = /usr/local | |
| 127 | + TARGET = openhantek | |
| 128 | + | |
| 129 | + # Installation directories | |
| 130 | + target.path = $${PREFIX}/bin | |
| 131 | + translations.path = $${PREFIX}/share/apps/openhantek/translations | |
| 132 | + contains(LIBUSB_VERSION, 0) { | |
| 133 | + INCLUDEPATH += /usr/include/libusb | |
| 134 | + } | |
| 135 | + else { | |
| 136 | + INCLUDEPATH += /usr/include/libusb-1.0 | |
| 137 | + } | |
| 138 | + DEFINES += \ | |
| 139 | + QMAKE_TRANSLATIONS_PATH=\\\"$${translations.path}\\\" \ | |
| 140 | + OS_UNIX VERSION=\\\"$${VERSION}\\\" | |
| 112 | 141 | } |
| 113 | 142 | macx { |
| 114 | - isEmpty(PREFIX):PREFIX = OpenHantek.app | |
| 115 | - TARGET = OpenHantek | |
| 116 | - | |
| 117 | - # Installation directories | |
| 118 | - target.path = $${PREFIX}/Contents/MacOS | |
| 119 | - translations.path = $${PREFIX}/Contents/Resources/translations | |
| 120 | - INCLUDEPATH += src | |
| 121 | - LIBS += -framework IOKit -framework CoreFoundation | |
| 122 | - ICON = res/images/openhantek.icns | |
| 123 | - DEFINES += QMAKE_TRANSLATIONS_PATH=\"Contents/Resources/translations\" \ | |
| 124 | - OS_DARWIN VERSION=\"$${VERSION}\" | |
| 143 | + isEmpty(PREFIX): PREFIX = OpenHantek.app | |
| 144 | + TARGET = OpenHantek | |
| 145 | + | |
| 146 | + # Installation directories | |
| 147 | + target.path = $${PREFIX}/Contents/MacOS | |
| 148 | + translations.path = $${PREFIX}/Contents/Resources/translations | |
| 149 | + INCLUDEPATH += $${INCLUDEPATH_QUOTE} | |
| 150 | + LIBS += -framework IOKit -framework CoreFoundation | |
| 151 | + ICON = res/images/openhantek.icns | |
| 152 | + DEFINES += \ | |
| 153 | + QMAKE_TRANSLATIONS_PATH=\\\"Contents/Resources/translations\\\" \ | |
| 154 | + OS_DARWIN VERSION=\\\"$${VERSION}\\\" | |
| 125 | 155 | } |
| 126 | 156 | win32 { |
| 127 | - isEmpty(PREFIX):PREFIX = OpenHantek | |
| 128 | - TARGET = OpenHantek | |
| 129 | - | |
| 130 | - # Installation directories | |
| 131 | - target.path = $${PREFIX} | |
| 132 | - translations.path = $${PREFIX}/translations | |
| 133 | - DEFINES += QMAKE_TRANSLATIONS_PATH=\\\"translations\\\" \ | |
| 134 | - OS_WINDOWS VERSION=\\\"$${VERSION}\\\" | |
| 157 | + isEmpty(PREFIX): PREFIX = OpenHantek | |
| 158 | + TARGET = OpenHantek | |
| 159 | + | |
| 160 | + # Installation directories | |
| 161 | + target.path = $${PREFIX} | |
| 162 | + translations.path = $${PREFIX}/translations | |
| 163 | + INCLUDEPATH += $${INCLUDEPATH_QUOTE} | |
| 164 | + DEFINES += \ | |
| 165 | + QMAKE_TRANSLATIONS_PATH=\\\"translations\\\" \ | |
| 166 | + OS_WINDOWS VERSION=\\\"$${VERSION}\\\" | |
| 135 | 167 | } |
| 136 | 168 | translations.files += translations/*.qm |
| 137 | -INSTALLS += target \ | |
| 138 | - translations | |
| 169 | +INSTALLS += \ | |
| 170 | + target \ | |
| 171 | + translations | |
| 172 | + | |
| 173 | +# Custom target "cppcheck" for Cppcheck | |
| 174 | +INCLUDEPARAMETERS = $$surround($${INCLUDEPATH} $${INCLUDEPATH_QUOTE}, "-I \"", "\"") | |
| 175 | +cppcheck.commands = "cppcheck --enable=all $${INCLUDEPARAMETERS} -q $${SOURCES} --template=\"{file}:{line}: {severity}: {message}\"" | |
| 176 | +cppcheck.depends = $${SOURCES} | |
| 139 | 177 | |
| 140 | 178 | # Custom target "doc" for Doxygen |
| 141 | -doxygen.target = doc | |
| 179 | +doxygen.target = "doc" | |
| 142 | 180 | doxygen.commands = "rm -r doc/; env DEFINES=\"$${DEFINES}\" doxygen Doxyfile" |
| 143 | -doxygen.depends = $${SOURCES} \ | |
| 144 | - $${HEADERS} \ | |
| 145 | - $${DOXYFILES} | |
| 146 | -QMAKE_EXTRA_TARGETS += doxygen | |
| 181 | +doxygen.depends = \ | |
| 182 | + $${SOURCES} \ | |
| 183 | + $${HEADERS} \ | |
| 184 | + $${DOXYFILES} | |
| 185 | + | |
| 186 | +QMAKE_EXTRA_TARGETS += \ | |
| 187 | + cppcheck \ | |
| 188 | + doxygen | ... | ... |
openhantek/src/configpages.cpp
| ... | ... | @@ -170,7 +170,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) |
| 170 | 170 | this->channelLabel->setAlignment(Qt::AlignHCenter); |
| 171 | 171 | this->spectrumLabel = new QLabel(tr("Spectrum")); |
| 172 | 172 | this->spectrumLabel->setAlignment(Qt::AlignHCenter); |
| 173 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 173 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 174 | 174 | this->colorLabel.append(new QLabel(this->settings->scope.voltage[channel].name)); |
| 175 | 175 | this->channelColorBox.append(new ColorBox(this->settings->view.color.screen.voltage[channel])); |
| 176 | 176 | this->spectrumColorBox.append(new ColorBox(this->settings->view.color.screen.spectrum[channel])); |
| ... | ... | @@ -182,7 +182,7 @@ DsoConfigColorsPage::DsoConfigColorsPage(DsoSettings *settings, QWidget *parent) |
| 182 | 182 | this->graphLayout->setColumnMinimumWidth(2, 80); |
| 183 | 183 | this->graphLayout->addWidget(this->channelLabel, 0, 1); |
| 184 | 184 | this->graphLayout->addWidget(this->spectrumLabel, 0, 2); |
| 185 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 185 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 186 | 186 | this->graphLayout->addWidget(this->colorLabel[channel], channel + 1, 0); |
| 187 | 187 | this->graphLayout->addWidget(this->channelColorBox[channel], channel + 1, 1); |
| 188 | 188 | this->graphLayout->addWidget(this->spectrumColorBox[channel], channel + 1, 2); |
| ... | ... | @@ -215,7 +215,7 @@ void DsoConfigColorsPage::saveSettings() { |
| 215 | 215 | this->settings->view.color.screen.text = this->textColorBox->getColor(); |
| 216 | 216 | |
| 217 | 217 | // Graph category |
| 218 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 218 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 219 | 219 | this->settings->view.color.screen.voltage[channel] = this->channelColorBox[channel]->getColor(); |
| 220 | 220 | this->settings->view.color.screen.spectrum[channel] = this->spectrumColorBox[channel]->getColor(); |
| 221 | 221 | } | ... | ... |
openhantek/src/dataanalyzer.cpp
| ... | ... | @@ -50,15 +50,22 @@ DataAnalyzer::DataAnalyzer(DsoSettings *settings, QObject *parent) : QThread(par |
| 50 | 50 | this->window = 0; |
| 51 | 51 | |
| 52 | 52 | this->analyzedDataMutex = new QMutex(); |
| 53 | + | |
| 54 | + this->maxSamples = 0; | |
| 55 | + | |
| 56 | + this->waitingDataSamplerate = 0.0; | |
| 57 | + this->waitingDataMutex = 0; | |
| 53 | 58 | } |
| 54 | 59 | |
| 55 | 60 | /// \brief Deallocates the buffers. |
| 56 | 61 | DataAnalyzer::~DataAnalyzer() { |
| 57 | - for(int channel = 0; channel < this->analyzedData.count(); channel++) { | |
| 58 | - if(this->analyzedData[channel]->samples.voltage.sample) | |
| 59 | - delete[] this->analyzedData[channel]->samples.voltage.sample; | |
| 60 | - if(this->analyzedData[channel]->samples.spectrum.sample) | |
| 61 | - delete[] this->analyzedData[channel]->samples.spectrum.sample; | |
| 62 | + for(int channel = 0; channel < this->analyzedData.count(); ++channel) { | |
| 63 | + AnalyzedData *channelData = this->analyzedData[channel]; | |
| 64 | + | |
| 65 | + if(channelData->samples.voltage.sample) | |
| 66 | + delete[] channelData->samples.voltage.sample; | |
| 67 | + if(channelData->samples.spectrum.sample) | |
| 68 | + delete[] channelData->samples.spectrum.sample; | |
| 62 | 69 | } |
| 63 | 70 | } |
| 64 | 71 | |
| ... | ... | @@ -89,32 +96,48 @@ void DataAnalyzer::run() { |
| 89 | 96 | this->analyzedDataMutex->lock(); |
| 90 | 97 | |
| 91 | 98 | unsigned long int maxSamples = 0; |
| 99 | + unsigned int channelCount = (unsigned int) this->settings->scope.voltage.count(); | |
| 92 | 100 | |
| 93 | 101 | // Adapt the number of channels for analyzed data |
| 94 | - for(int channel = this->analyzedData.count(); channel < this->settings->scope.voltage.count(); channel++) { | |
| 95 | - this->analyzedData.append(new AnalyzedData); | |
| 96 | - this->analyzedData[channel]->samples.voltage.count = 0; | |
| 97 | - this->analyzedData[channel]->samples.voltage.interval = 0; | |
| 98 | - this->analyzedData[channel]->samples.voltage.sample = 0; | |
| 99 | - this->analyzedData[channel]->samples.spectrum.count = 0; | |
| 100 | - this->analyzedData[channel]->samples.spectrum.interval = 0; | |
| 101 | - this->analyzedData[channel]->samples.spectrum.sample = 0; | |
| 102 | - this->analyzedData[channel]->amplitude = 0; | |
| 103 | - this->analyzedData[channel]->frequency = 0; | |
| 102 | + for(unsigned int channel = this->analyzedData.count(); channel < channelCount; ++channel) { | |
| 103 | + AnalyzedData *channelData = new AnalyzedData; | |
| 104 | + channelData->samples.voltage.count = 0; | |
| 105 | + channelData->samples.voltage.interval = 0; | |
| 106 | + channelData->samples.voltage.sample = 0; | |
| 107 | + channelData->samples.spectrum.count = 0; | |
| 108 | + channelData->samples.spectrum.interval = 0; | |
| 109 | + channelData->samples.spectrum.sample = 0; | |
| 110 | + channelData->amplitude = 0; | |
| 111 | + channelData->frequency = 0; | |
| 112 | + this->analyzedData.append(channelData); | |
| 104 | 113 | } |
| 105 | - for(int channel = this->settings->scope.voltage.count(); channel < this->analyzedData.count(); channel++) { | |
| 106 | - if(this->analyzedData.last()->samples.voltage.sample) | |
| 107 | - delete[] this->analyzedData.last()->samples.voltage.sample; | |
| 108 | - if(this->analyzedData.last()->samples.spectrum.sample) | |
| 109 | - delete[] this->analyzedData.last()->samples.spectrum.sample; | |
| 114 | + for(unsigned int channel = this->analyzedData.count(); channel > channelCount; --channel) { | |
| 115 | + AnalyzedData *channelData = this->analyzedData.last(); | |
| 116 | + if(channelData->samples.voltage.sample) | |
| 117 | + delete[] channelData->samples.voltage.sample; | |
| 118 | + if(channelData->samples.spectrum.sample) | |
| 119 | + delete[] channelData->samples.spectrum.sample; | |
| 110 | 120 | this->analyzedData.removeLast(); |
| 111 | 121 | } |
| 112 | 122 | |
| 113 | - for(unsigned int channel = 0; channel < (unsigned int) this->analyzedData.count(); channel++) { | |
| 114 | - // Check if we got data for this channel or if it's a math channel that can be calculated | |
| 115 | - if(((channel < this->settings->scope.physicalChannels) && channel < (unsigned int) this->waitingData.count() && this->waitingData[channel]) || ((channel >= this->settings->scope.physicalChannels) && (this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) && this->analyzedData.count() >= 2 && this->analyzedData[0]->samples.voltage.sample && this->analyzedData[1]->samples.voltage.sample)) { | |
| 123 | + for(unsigned int channel = 0; channel < channelCount; ++channel) { | |
| 124 | + AnalyzedData *channelData = this->analyzedData[channel]; | |
| 125 | + | |
| 126 | + if( // Check... | |
| 127 | + ( // ...if we got data for this channel... | |
| 128 | + channel < this->settings->scope.physicalChannels && | |
| 129 | + channel < (unsigned int) this->waitingData.count() && | |
| 130 | + this->waitingData[channel]) || | |
| 131 | + ( // ...or if it's a math channel that can be calculated | |
| 132 | + channel >= this->settings->scope.physicalChannels && | |
| 133 | + (this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) && | |
| 134 | + this->analyzedData.count() >= 2 && | |
| 135 | + this->analyzedData[0]->samples.voltage.sample && | |
| 136 | + this->analyzedData[1]->samples.voltage.sample | |
| 137 | + ) | |
| 138 | + ) { | |
| 116 | 139 | // Set sampling interval |
| 117 | - this->analyzedData[channel]->samples.voltage.interval = 1.0 / this->waitingDataSamplerate; | |
| 140 | + channelData->samples.voltage.interval = 1.0 / this->waitingDataSamplerate; | |
| 118 | 141 | |
| 119 | 142 | unsigned int size; |
| 120 | 143 | if(channel < this->settings->scope.physicalChannels) { |
| ... | ... | @@ -125,19 +148,19 @@ void DataAnalyzer::run() { |
| 125 | 148 | else |
| 126 | 149 | size = maxSamples; |
| 127 | 150 | // Reallocate memory for samples if the sample count has changed |
| 128 | - if(this->analyzedData[channel]->samples.voltage.count != size) { | |
| 129 | - this->analyzedData[channel]->samples.voltage.count = size; | |
| 130 | - if(this->analyzedData[channel]->samples.voltage.sample) | |
| 131 | - delete[] this->analyzedData[channel]->samples.voltage.sample; | |
| 132 | - this->analyzedData[channel]->samples.voltage.sample = new double[size]; | |
| 151 | + if(channelData->samples.voltage.count != size) { | |
| 152 | + channelData->samples.voltage.count = size; | |
| 153 | + if(channelData->samples.voltage.sample) | |
| 154 | + delete[] channelData->samples.voltage.sample; | |
| 155 | + channelData->samples.voltage.sample = new double[size]; | |
| 133 | 156 | } |
| 134 | 157 | |
| 135 | 158 | // Physical channels |
| 136 | 159 | if(channel < this->settings->scope.physicalChannels) { |
| 137 | 160 | // Copy the buffer of the oscilloscope into the sample buffer |
| 138 | 161 | if(channel < (unsigned int) this->waitingData.count()) |
| 139 | - for(unsigned int position = 0; position < this->waitingDataSize[channel]; position++) | |
| 140 | - this->analyzedData[channel]->samples.voltage.sample[position] = this->waitingData[channel][position]; | |
| 162 | + for(unsigned int position = 0; position < this->waitingDataSize[channel]; ++position) | |
| 163 | + channelData->samples.voltage.sample[position] = this->waitingData[channel][position]; | |
| 141 | 164 | } |
| 142 | 165 | // Math channel |
| 143 | 166 | else { |
| ... | ... | @@ -153,7 +176,7 @@ void DataAnalyzer::run() { |
| 153 | 176 | } |
| 154 | 177 | |
| 155 | 178 | // Calculate values and write them into the sample buffer |
| 156 | - for(unsigned int realPosition = 0; realPosition < this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.count; realPosition++) { | |
| 179 | + for(unsigned int realPosition = 0; realPosition < this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.count; ++realPosition) { | |
| 157 | 180 | switch(this->settings->scope.voltage[this->settings->scope.physicalChannels].misc) { |
| 158 | 181 | case Dso::MATHMODE_1ADD2: |
| 159 | 182 | this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.sample[realPosition] = this->analyzedData[0]->samples.voltage.sample[realPosition] + this->analyzedData[1]->samples.voltage.sample[realPosition]; |
| ... | ... | @@ -170,11 +193,11 @@ void DataAnalyzer::run() { |
| 170 | 193 | } |
| 171 | 194 | else { |
| 172 | 195 | // Clear unused channels |
| 173 | - this->analyzedData[channel]->samples.voltage.count = 0; | |
| 196 | + channelData->samples.voltage.count = 0; | |
| 174 | 197 | this->analyzedData[this->settings->scope.physicalChannels]->samples.voltage.interval = 0; |
| 175 | - if(this->analyzedData[channel]->samples.voltage.sample) { | |
| 176 | - delete[] this->analyzedData[channel]->samples.voltage.sample; | |
| 177 | - this->analyzedData[channel]->samples.voltage.sample = 0; | |
| 198 | + if(channelData->samples.voltage.sample) { | |
| 199 | + delete[] channelData->samples.voltage.sample; | |
| 200 | + channelData->samples.voltage.sample = 0; | |
| 178 | 201 | } |
| 179 | 202 | } |
| 180 | 203 | } |
| ... | ... | @@ -186,12 +209,14 @@ void DataAnalyzer::run() { |
| 186 | 209 | |
| 187 | 210 | |
| 188 | 211 | // Calculate frequencies, peak-to-peak voltages and spectrums |
| 189 | - for(int channel = 0; channel < this->analyzedData.count(); channel++) { | |
| 190 | - if(this->analyzedData[channel]->samples.voltage.sample) { | |
| 212 | + for(int channel = 0; channel < this->analyzedData.count(); ++channel) { | |
| 213 | + AnalyzedData *channelData = this->analyzedData[channel]; | |
| 214 | + | |
| 215 | + if(channelData->samples.voltage.sample) { | |
| 191 | 216 | // Calculate new window |
| 192 | - if(this->lastWindow != this->settings->scope.spectrumWindow || this->lastRecordLength != this->analyzedData[channel]->samples.voltage.count) { | |
| 193 | - if(this->lastRecordLength != this->analyzedData[channel]->samples.voltage.count) { | |
| 194 | - this->lastRecordLength = this->analyzedData[channel]->samples.voltage.count; | |
| 217 | + if(this->lastWindow != this->settings->scope.spectrumWindow || this->lastRecordLength != channelData->samples.voltage.count) { | |
| 218 | + if(this->lastRecordLength != channelData->samples.voltage.count) { | |
| 219 | + this->lastRecordLength = channelData->samples.voltage.count; | |
| 195 | 220 | |
| 196 | 221 | if(this->window) |
| 197 | 222 | fftw_free(this->window); |
| ... | ... | @@ -203,19 +228,19 @@ void DataAnalyzer::run() { |
| 203 | 228 | |
| 204 | 229 | switch(this->settings->scope.spectrumWindow) { |
| 205 | 230 | case Dso::WINDOW_HAMMING: |
| 206 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 231 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 207 | 232 | *(this->window + windowPosition) = 0.54 - 0.46 * cos(2.0 * M_PI * windowPosition / windowEnd); |
| 208 | 233 | break; |
| 209 | 234 | case Dso::WINDOW_HANN: |
| 210 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 235 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 211 | 236 | *(this->window + windowPosition) = 0.5 * (1.0 - cos(2.0 * M_PI * windowPosition / windowEnd)); |
| 212 | 237 | break; |
| 213 | 238 | case Dso::WINDOW_COSINE: |
| 214 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 239 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 215 | 240 | *(this->window + windowPosition) = sin(M_PI * windowPosition / windowEnd); |
| 216 | 241 | break; |
| 217 | 242 | case Dso::WINDOW_LANCZOS: |
| 218 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) { | |
| 243 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) { | |
| 219 | 244 | double sincParameter = (2.0 * windowPosition / windowEnd - 1.0) * M_PI; |
| 220 | 245 | if(sincParameter == 0) |
| 221 | 246 | *(this->window + windowPosition) = 1; |
| ... | ... | @@ -224,82 +249,82 @@ void DataAnalyzer::run() { |
| 224 | 249 | } |
| 225 | 250 | break; |
| 226 | 251 | case Dso::WINDOW_BARTLETT: |
| 227 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 252 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 228 | 253 | *(this->window + windowPosition) = 2.0 / windowEnd * (windowEnd / 2 - abs(windowPosition - windowEnd / 2)); |
| 229 | 254 | break; |
| 230 | 255 | case Dso::WINDOW_TRIANGULAR: |
| 231 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 256 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 232 | 257 | *(this->window + windowPosition) = 2.0 / this->lastRecordLength * (this->lastRecordLength / 2 - abs(windowPosition - windowEnd / 2)); |
| 233 | 258 | break; |
| 234 | 259 | case Dso::WINDOW_GAUSS: |
| 235 | 260 | { |
| 236 | 261 | double sigma = 0.4; |
| 237 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 262 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 238 | 263 | *(this->window + windowPosition) = exp(-0.5 * pow(((windowPosition - windowEnd / 2) / (sigma * windowEnd / 2)), 2)); |
| 239 | 264 | } |
| 240 | 265 | break; |
| 241 | 266 | case Dso::WINDOW_BARTLETTHANN: |
| 242 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 267 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 243 | 268 | *(this->window + windowPosition) = 0.62 - 0.48 * abs(windowPosition / windowEnd - 0.5) - 0.38 * cos(2.0 * M_PI * windowPosition / windowEnd); |
| 244 | 269 | break; |
| 245 | 270 | case Dso::WINDOW_BLACKMAN: |
| 246 | 271 | { |
| 247 | 272 | double alpha = 0.16; |
| 248 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 273 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 249 | 274 | *(this->window + windowPosition) = (1 - alpha) / 2 - 0.5 * cos(2.0 * M_PI * windowPosition / windowEnd) + alpha / 2 * cos(4.0 * M_PI * windowPosition / windowEnd); |
| 250 | 275 | } |
| 251 | 276 | break; |
| 252 | 277 | //case WINDOW_KAISER: |
| 253 | 278 | // TODO |
| 254 | 279 | //double alpha = 3.0; |
| 255 | - //for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 280 | + //for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 256 | 281 | //*(this->window + windowPosition) = ; |
| 257 | 282 | //break; |
| 258 | 283 | case Dso::WINDOW_NUTTALL: |
| 259 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 284 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 260 | 285 | *(this->window + windowPosition) = 0.355768 - 0.487396 * cos(2 * M_PI * windowPosition / windowEnd) + 0.144232 * cos(4 * M_PI * windowPosition / windowEnd) - 0.012604 * cos(6 * M_PI * windowPosition / windowEnd); |
| 261 | 286 | break; |
| 262 | 287 | case Dso::WINDOW_BLACKMANHARRIS: |
| 263 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 288 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 264 | 289 | *(this->window + windowPosition) = 0.35875 - 0.48829 * cos(2 * M_PI * windowPosition / windowEnd) + 0.14128 * cos(4 * M_PI * windowPosition / windowEnd) - 0.01168 * cos(6 * M_PI * windowPosition / windowEnd); |
| 265 | 290 | break; |
| 266 | 291 | case Dso::WINDOW_BLACKMANNUTTALL: |
| 267 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 292 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 268 | 293 | *(this->window + windowPosition) = 0.3635819 - 0.4891775 * cos(2 * M_PI * windowPosition / windowEnd) + 0.1365995 * cos(4 * M_PI * windowPosition / windowEnd) - 0.0106411 * cos(6 * M_PI * windowPosition / windowEnd); |
| 269 | 294 | break; |
| 270 | 295 | case Dso::WINDOW_FLATTOP: |
| 271 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 296 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 272 | 297 | *(this->window + windowPosition) = 1.0 - 1.93 * cos(2 * M_PI * windowPosition / windowEnd) + 1.29 * cos(4 * M_PI * windowPosition / windowEnd) - 0.388 * cos(6 * M_PI * windowPosition / windowEnd) + 0.032 * cos(8 * M_PI * windowPosition / windowEnd); |
| 273 | 298 | break; |
| 274 | 299 | default: // Dso::WINDOW_RECTANGULAR |
| 275 | - for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; windowPosition++) | |
| 300 | + for(unsigned int windowPosition = 0; windowPosition < this->lastRecordLength; ++windowPosition) | |
| 276 | 301 | *(this->window + windowPosition) = 1.0; |
| 277 | 302 | } |
| 278 | 303 | } |
| 279 | 304 | |
| 280 | 305 | // Set sampling interval |
| 281 | - this->analyzedData[channel]->samples.spectrum.interval = 1.0 / this->analyzedData[channel]->samples.voltage.interval / this->analyzedData[channel]->samples.voltage.count; | |
| 306 | + channelData->samples.spectrum.interval = 1.0 / channelData->samples.voltage.interval / channelData->samples.voltage.count; | |
| 282 | 307 | |
| 283 | 308 | // Number of real/complex samples |
| 284 | - unsigned int dftLength = this->analyzedData[channel]->samples.voltage.count / 2; | |
| 309 | + unsigned int dftLength = channelData->samples.voltage.count / 2; | |
| 285 | 310 | |
| 286 | 311 | // Reallocate memory for samples if the sample count has changed |
| 287 | - if(this->analyzedData[channel]->samples.spectrum.count != dftLength) { | |
| 288 | - this->analyzedData[channel]->samples.spectrum.count = dftLength; | |
| 289 | - if(this->analyzedData[channel]->samples.spectrum.sample) | |
| 290 | - delete[] this->analyzedData[channel]->samples.spectrum.sample; | |
| 291 | - this->analyzedData[channel]->samples.spectrum.sample = new double[this->analyzedData[channel]->samples.voltage.count]; | |
| 312 | + if(channelData->samples.spectrum.count != dftLength) { | |
| 313 | + channelData->samples.spectrum.count = dftLength; | |
| 314 | + if(channelData->samples.spectrum.sample) | |
| 315 | + delete[] channelData->samples.spectrum.sample; | |
| 316 | + channelData->samples.spectrum.sample = new double[channelData->samples.voltage.count]; | |
| 292 | 317 | } |
| 293 | 318 | |
| 294 | 319 | // Create sample buffer and apply window |
| 295 | - double *windowedValues = new double[this->analyzedData[channel]->samples.voltage.count]; | |
| 296 | - for(unsigned int position = 0; position < this->analyzedData[channel]->samples.voltage.count; position++) | |
| 297 | - windowedValues[position] = this->window[position] * this->analyzedData[channel]->samples.voltage.sample[position]; | |
| 320 | + double *windowedValues = new double[channelData->samples.voltage.count]; | |
| 321 | + for(unsigned int position = 0; position < channelData->samples.voltage.count; ++position) | |
| 322 | + windowedValues[position] = this->window[position] * channelData->samples.voltage.sample[position]; | |
| 298 | 323 | |
| 299 | 324 | // Do discrete real to half-complex transformation |
| 300 | 325 | /// \todo Check if record length is multiple of 2 |
| 301 | 326 | /// \todo Reuse plan and use FFTW_MEASURE to get fastest algorithm |
| 302 | - fftw_plan fftPlan = fftw_plan_r2r_1d(this->analyzedData[channel]->samples.voltage.count, windowedValues, this->analyzedData[channel]->samples.spectrum.sample, FFTW_R2HC, FFTW_ESTIMATE); | |
| 327 | + fftw_plan fftPlan = fftw_plan_r2r_1d(channelData->samples.voltage.count, windowedValues, channelData->samples.spectrum.sample, FFTW_R2HC, FFTW_ESTIMATE); | |
| 303 | 328 | fftw_execute(fftPlan); |
| 304 | 329 | fftw_destroy_plan(fftPlan); |
| 305 | 330 | |
| ... | ... | @@ -309,40 +334,40 @@ void DataAnalyzer::run() { |
| 309 | 334 | // Real values |
| 310 | 335 | unsigned int position; |
| 311 | 336 | double correctionFactor = 1.0 / dftLength / dftLength; |
| 312 | - conjugateComplex[0] = (this->analyzedData[channel]->samples.spectrum.sample[0] * this->analyzedData[channel]->samples.spectrum.sample[0]) * correctionFactor; | |
| 313 | - for(position = 1; position < dftLength; position++) | |
| 314 | - conjugateComplex[position] = (this->analyzedData[channel]->samples.spectrum.sample[position] * this->analyzedData[channel]->samples.spectrum.sample[position] + this->analyzedData[channel]->samples.spectrum.sample[this->analyzedData[channel]->samples.voltage.count - position] * this->analyzedData[channel]->samples.spectrum.sample[this->analyzedData[channel]->samples.voltage.count - position]) * correctionFactor; | |
| 337 | + conjugateComplex[0] = (channelData->samples.spectrum.sample[0] * channelData->samples.spectrum.sample[0]) * correctionFactor; | |
| 338 | + for(position = 1; position < dftLength; ++position) | |
| 339 | + conjugateComplex[position] = (channelData->samples.spectrum.sample[position] * channelData->samples.spectrum.sample[position] + channelData->samples.spectrum.sample[channelData->samples.voltage.count - position] * channelData->samples.spectrum.sample[channelData->samples.voltage.count - position]) * correctionFactor; | |
| 315 | 340 | // Complex values, all zero for autocorrelation |
| 316 | - conjugateComplex[dftLength] = (this->analyzedData[channel]->samples.spectrum.sample[dftLength] * this->analyzedData[channel]->samples.spectrum.sample[dftLength]) * correctionFactor; | |
| 317 | - for(position++; position < this->analyzedData[channel]->samples.voltage.count; position++) | |
| 341 | + conjugateComplex[dftLength] = (channelData->samples.spectrum.sample[dftLength] * channelData->samples.spectrum.sample[dftLength]) * correctionFactor; | |
| 342 | + for(++position; position < channelData->samples.voltage.count; ++position) | |
| 318 | 343 | conjugateComplex[position] = 0; |
| 319 | 344 | |
| 320 | 345 | // Do half-complex to real inverse transformation |
| 321 | - double *correlation = new double[this->analyzedData[channel]->samples.voltage.count]; | |
| 322 | - fftPlan = fftw_plan_r2r_1d(this->analyzedData[channel]->samples.voltage.count, conjugateComplex, correlation, FFTW_HC2R, FFTW_ESTIMATE); | |
| 346 | + double *correlation = new double[channelData->samples.voltage.count]; | |
| 347 | + fftPlan = fftw_plan_r2r_1d(channelData->samples.voltage.count, conjugateComplex, correlation, FFTW_HC2R, FFTW_ESTIMATE); | |
| 323 | 348 | fftw_execute(fftPlan); |
| 324 | 349 | fftw_destroy_plan(fftPlan); |
| 325 | 350 | delete[] conjugateComplex; |
| 326 | 351 | |
| 327 | 352 | // Calculate peak-to-peak voltage |
| 328 | 353 | double minimalVoltage, maximalVoltage; |
| 329 | - minimalVoltage = maximalVoltage = this->analyzedData[channel]->samples.voltage.sample[0]; | |
| 354 | + minimalVoltage = maximalVoltage = channelData->samples.voltage.sample[0]; | |
| 330 | 355 | |
| 331 | - for(unsigned int position = 1; position < this->analyzedData[channel]->samples.voltage.count; position++) { | |
| 332 | - if(this->analyzedData[channel]->samples.voltage.sample[position] < minimalVoltage) | |
| 333 | - minimalVoltage = this->analyzedData[channel]->samples.voltage.sample[position]; | |
| 334 | - else if(this->analyzedData[channel]->samples.voltage.sample[position] > maximalVoltage) | |
| 335 | - maximalVoltage = this->analyzedData[channel]->samples.voltage.sample[position]; | |
| 356 | + for(unsigned int position = 1; position < channelData->samples.voltage.count; ++position) { | |
| 357 | + if(channelData->samples.voltage.sample[position] < minimalVoltage) | |
| 358 | + minimalVoltage = channelData->samples.voltage.sample[position]; | |
| 359 | + else if(channelData->samples.voltage.sample[position] > maximalVoltage) | |
| 360 | + maximalVoltage = channelData->samples.voltage.sample[position]; | |
| 336 | 361 | } |
| 337 | 362 | |
| 338 | - this->analyzedData[channel]->amplitude = maximalVoltage - minimalVoltage; | |
| 363 | + channelData->amplitude = maximalVoltage - minimalVoltage; | |
| 339 | 364 | |
| 340 | 365 | // Get the frequency from the correlation results |
| 341 | 366 | double minimumCorrelation = correlation[0]; |
| 342 | 367 | double peakCorrelation = 0; |
| 343 | 368 | unsigned int peakPosition = 0; |
| 344 | 369 | |
| 345 | - for(unsigned int position = 1; position < this->analyzedData[channel]->samples.voltage.count / 2; position++) { | |
| 370 | + for(unsigned int position = 1; position < channelData->samples.voltage.count / 2; ++position) { | |
| 346 | 371 | if(correlation[position] > peakCorrelation && correlation[position] > minimumCorrelation * 2) { |
| 347 | 372 | peakCorrelation = correlation[position]; |
| 348 | 373 | peakPosition = position; |
| ... | ... | @@ -354,30 +379,30 @@ void DataAnalyzer::run() { |
| 354 | 379 | |
| 355 | 380 | // Calculate the frequency in Hz |
| 356 | 381 | if(peakPosition) |
| 357 | - this->analyzedData[channel]->frequency = 1.0 / (this->analyzedData[channel]->samples.voltage.interval * peakPosition); | |
| 382 | + channelData->frequency = 1.0 / (channelData->samples.voltage.interval * peakPosition); | |
| 358 | 383 | else |
| 359 | - this->analyzedData[channel]->frequency = 0; | |
| 384 | + channelData->frequency = 0; | |
| 360 | 385 | |
| 361 | 386 | // Finally calculate the real spectrum if we want it |
| 362 | 387 | if(this->settings->scope.spectrum[channel].used) { |
| 363 | 388 | // Convert values into dB (Relative to the reference level) |
| 364 | 389 | double offset = 60 - this->settings->scope.spectrumReference - 20 * log10(dftLength); |
| 365 | 390 | double offsetLimit = this->settings->scope.spectrumLimit - this->settings->scope.spectrumReference; |
| 366 | - for(unsigned int position = 0; position < this->analyzedData[channel]->samples.spectrum.count; position++) { | |
| 367 | - this->analyzedData[channel]->samples.spectrum.sample[position] = 20 * log10(fabs(this->analyzedData[channel]->samples.spectrum.sample[position])) + offset; | |
| 391 | + for(unsigned int position = 0; position < channelData->samples.spectrum.count; ++position) { | |
| 392 | + channelData->samples.spectrum.sample[position] = 20 * log10(fabs(channelData->samples.spectrum.sample[position])) + offset; | |
| 368 | 393 | |
| 369 | 394 | // Check if this value has to be limited |
| 370 | - if(offsetLimit > this->analyzedData[channel]->samples.spectrum.sample[position]) | |
| 371 | - this->analyzedData[channel]->samples.spectrum.sample[position] = offsetLimit; | |
| 395 | + if(offsetLimit > channelData->samples.spectrum.sample[position]) | |
| 396 | + channelData->samples.spectrum.sample[position] = offsetLimit; | |
| 372 | 397 | } |
| 373 | 398 | } |
| 374 | 399 | } |
| 375 | - else if(this->analyzedData[channel]->samples.spectrum.sample) { | |
| 400 | + else if(channelData->samples.spectrum.sample) { | |
| 376 | 401 | // Clear unused channels |
| 377 | - this->analyzedData[channel]->samples.spectrum.count = 0; | |
| 378 | - this->analyzedData[channel]->samples.spectrum.interval = 0; | |
| 379 | - delete[] this->analyzedData[channel]->samples.spectrum.sample; | |
| 380 | - this->analyzedData[channel]->samples.spectrum.sample = 0; | |
| 402 | + channelData->samples.spectrum.count = 0; | |
| 403 | + channelData->samples.spectrum.interval = 0; | |
| 404 | + delete[] channelData->samples.spectrum.sample; | |
| 405 | + channelData->samples.spectrum.sample = 0; | |
| 381 | 406 | } |
| 382 | 407 | } |
| 383 | 408 | ... | ... |
openhantek/src/dockwindows.cpp
| ... | ... | @@ -50,13 +50,13 @@ HorizontalDock::HorizontalDock(DsoSettings *settings, QWidget *parent, Qt::Windo |
| 50 | 50 | << 1e-3 << 2e-3 << 4e-3 << 1e-2 << 2e-2 << 4e-2 << 1e-1 << 2e-1 << 4e-1 |
| 51 | 51 | << 1e0 << 2e0 << 4e0 << 1e1 << 2e1 << 4e1 << 6e1 << 12e1 << 24e1 |
| 52 | 52 | << 6e2 << 12e2 << 24e2 << 36e2; ///< Timebase steps in seconds/div |
| 53 | - for(QList<double>::iterator timebase = this->timebaseSteps.begin(); timebase != this->timebaseSteps.end(); timebase++) | |
| 53 | + for(QList<double>::iterator timebase = this->timebaseSteps.begin(); timebase != this->timebaseSteps.end(); ++timebase) | |
| 54 | 54 | this->timebaseStrings << Helper::valueToString(*timebase, Helper::UNIT_SECONDS, 0); |
| 55 | 55 | this->frequencybaseSteps |
| 56 | 56 | << 1.0 << 2.0 << 5.0 << 1e1 << 2e1 << 5e1 << 1e2 << 2e2 << 5e2 |
| 57 | 57 | << 1e3 << 2e3 << 5e3 << 1e4 << 2e4 << 4e4 << 1e5 << 2e5 << 5e5 |
| 58 | 58 | << 1e6 << 2e6 << 5e6 << 1e7; ///< Frequencybase steps in Hz/div |
| 59 | - for(QList<double>::iterator frequencybase = this->frequencybaseSteps.begin(); frequencybase != this->frequencybaseSteps.end(); frequencybase++) | |
| 59 | + for(QList<double>::iterator frequencybase = this->frequencybaseSteps.begin(); frequencybase != this->frequencybaseSteps.end(); ++frequencybase) | |
| 60 | 60 | this->frequencybaseStrings << Helper::valueToString(*frequencybase, Helper::UNIT_HERTZ, 0); |
| 61 | 61 | |
| 62 | 62 | // Initialize elements |
| ... | ... | @@ -70,7 +70,7 @@ HorizontalDock::HorizontalDock(DsoSettings *settings, QWidget *parent, Qt::Windo |
| 70 | 70 | |
| 71 | 71 | this->formatLabel = new QLabel(tr("Format")); |
| 72 | 72 | this->formatComboBox = new QComboBox(); |
| 73 | - for(int format = Dso::GRAPHFORMAT_TY; format < Dso::GRAPHFORMAT_COUNT; format++) | |
| 73 | + for(int format = Dso::GRAPHFORMAT_TY; format < Dso::GRAPHFORMAT_COUNT; ++format) | |
| 74 | 74 | this->formatComboBox->addItem(Dso::graphFormatString((Dso::GraphFormat) format)); |
| 75 | 75 | |
| 76 | 76 | this->dockLayout = new QGridLayout(); |
| ... | ... | @@ -181,19 +181,19 @@ TriggerDock::TriggerDock(DsoSettings *settings, const QStringList *specialTrigge |
| 181 | 181 | this->settings = settings; |
| 182 | 182 | |
| 183 | 183 | // Initialize lists for comboboxes |
| 184 | - for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; channel++) | |
| 184 | + for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; ++channel) | |
| 185 | 185 | this->sourceStandardStrings << tr("CH%1").arg(channel + 1); |
| 186 | 186 | this->sourceSpecialStrings << *specialTriggers; |
| 187 | 187 | |
| 188 | 188 | // Initialize elements |
| 189 | 189 | this->modeLabel = new QLabel(tr("Mode")); |
| 190 | 190 | this->modeComboBox = new QComboBox(); |
| 191 | - for(int mode = Dso::TRIGGERMODE_AUTO; mode < Dso::TRIGGERMODE_COUNT; mode++) | |
| 191 | + for(int mode = Dso::TRIGGERMODE_AUTO; mode < Dso::TRIGGERMODE_COUNT; ++mode) | |
| 192 | 192 | this->modeComboBox->addItem(Dso::triggerModeString((Dso::TriggerMode) mode)); |
| 193 | 193 | |
| 194 | 194 | this->slopeLabel = new QLabel(tr("Slope")); |
| 195 | 195 | this->slopeComboBox = new QComboBox(); |
| 196 | - for(int slope = Dso::SLOPE_POSITIVE; slope < Dso::SLOPE_COUNT; slope++) | |
| 196 | + for(int slope = Dso::SLOPE_POSITIVE; slope < Dso::SLOPE_COUNT; ++slope) | |
| 197 | 197 | this->slopeComboBox->addItem(Dso::slopeString((Dso::Slope) slope)); |
| 198 | 198 | |
| 199 | 199 | this->sourceLabel = new QLabel(tr("Source")); |
| ... | ... | @@ -323,11 +323,11 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla |
| 323 | 323 | // Initialize lists for comboboxes |
| 324 | 324 | this->magnitudeSteps << 1e0 << 2e0 << 3e0 << 6e0 |
| 325 | 325 | << 1e1 << 2e1 << 3e1 << 6e1 << 1e2 << 2e2 << 3e2 << 6e2; ///< Magnitude steps in dB/div |
| 326 | - for(QList<double>::iterator magnitude = this->magnitudeSteps.begin(); magnitude != this->magnitudeSteps.end(); magnitude++) | |
| 326 | + for(QList<double>::iterator magnitude = this->magnitudeSteps.begin(); magnitude != this->magnitudeSteps.end(); ++magnitude) | |
| 327 | 327 | this->magnitudeStrings << Helper::valueToString(*magnitude, Helper::UNIT_DECIBEL, 0); |
| 328 | 328 | |
| 329 | 329 | // Initialize elements |
| 330 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 330 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 331 | 331 | this->magnitudeComboBox.append(new QComboBox()); |
| 332 | 332 | this->magnitudeComboBox[channel]->addItems(this->magnitudeStrings); |
| 333 | 333 | |
| ... | ... | @@ -337,7 +337,7 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla |
| 337 | 337 | this->dockLayout = new QGridLayout(); |
| 338 | 338 | this->dockLayout->setColumnMinimumWidth(0, 64); |
| 339 | 339 | this->dockLayout->setColumnStretch(1, 1); |
| 340 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 340 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 341 | 341 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel, 0); |
| 342 | 342 | this->dockLayout->addWidget(this->magnitudeComboBox[channel], channel, 1); |
| 343 | 343 | } |
| ... | ... | @@ -349,13 +349,13 @@ SpectrumDock::SpectrumDock(DsoSettings *settings, QWidget *parent, Qt::WindowFla |
| 349 | 349 | this->setWidget(this->dockWidget); |
| 350 | 350 | |
| 351 | 351 | // Connect signals and slots |
| 352 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 352 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 353 | 353 | connect(this->magnitudeComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(magnitudeSelected(int))); |
| 354 | 354 | connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | // Set values |
| 358 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 358 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 359 | 359 | this->setMagnitude(channel, this->settings->scope.spectrum[channel].magnitude); |
| 360 | 360 | this->setUsed(channel, this->settings->scope.spectrum[channel].used); |
| 361 | 361 | } |
| ... | ... | @@ -407,7 +407,7 @@ void SpectrumDock::magnitudeSelected(int index) { |
| 407 | 407 | int channel; |
| 408 | 408 | |
| 409 | 409 | // Which combobox was it? |
| 410 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | |
| 410 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) | |
| 411 | 411 | if(this->sender() == this->magnitudeComboBox[channel]) |
| 412 | 412 | break; |
| 413 | 413 | |
| ... | ... | @@ -424,7 +424,7 @@ void SpectrumDock::usedSwitched(bool checked) { |
| 424 | 424 | int channel; |
| 425 | 425 | |
| 426 | 426 | // Which checkbox was it? |
| 427 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | |
| 427 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) | |
| 428 | 428 | if(this->sender() == this->usedCheckBox[channel]) |
| 429 | 429 | break; |
| 430 | 430 | |
| ... | ... | @@ -446,19 +446,19 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags |
| 446 | 446 | this->settings = settings; |
| 447 | 447 | |
| 448 | 448 | // Initialize lists for comboboxes |
| 449 | - for(int coupling = Dso::COUPLING_AC; coupling < Dso::COUPLING_COUNT; coupling++) | |
| 449 | + for(int coupling = Dso::COUPLING_AC; coupling < Dso::COUPLING_COUNT; ++coupling) | |
| 450 | 450 | this->couplingStrings.append(Dso::couplingString((Dso::Coupling) coupling)); |
| 451 | 451 | |
| 452 | - for(int mode = Dso::MATHMODE_1ADD2; mode < Dso::MATHMODE_COUNT; mode++) | |
| 452 | + for(int mode = Dso::MATHMODE_1ADD2; mode < Dso::MATHMODE_COUNT; ++mode) | |
| 453 | 453 | this->modeStrings.append(Dso::mathModeString((Dso::MathMode) mode)); |
| 454 | 454 | |
| 455 | 455 | this->gainSteps << 1e-2 << 2e-2 << 5e-2 << 1e-1 << 2e-1 << 5e-1 |
| 456 | 456 | << 1e0 << 2e0 << 5e0; ///< Voltage steps in V/div |
| 457 | - for(QList<double>::iterator gain = this->gainSteps.begin(); gain != this->gainSteps.end(); gain++) | |
| 457 | + for(QList<double>::iterator gain = this->gainSteps.begin(); gain != this->gainSteps.end(); ++gain) | |
| 458 | 458 | this->gainStrings << Helper::valueToString(*gain, Helper::UNIT_VOLTS, 0); |
| 459 | 459 | |
| 460 | 460 | // Initialize elements |
| 461 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 461 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 462 | 462 | this->miscComboBox.append(new QComboBox()); |
| 463 | 463 | if(channel < (int) this->settings->scope.physicalChannels) |
| 464 | 464 | this->miscComboBox[channel]->addItems(this->couplingStrings); |
| ... | ... | @@ -474,7 +474,7 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags |
| 474 | 474 | this->dockLayout = new QGridLayout(); |
| 475 | 475 | this->dockLayout->setColumnMinimumWidth(0, 64); |
| 476 | 476 | this->dockLayout->setColumnStretch(1, 1); |
| 477 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 477 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 478 | 478 | this->dockLayout->addWidget(this->usedCheckBox[channel], channel * 2, 0); |
| 479 | 479 | this->dockLayout->addWidget(this->gainComboBox[channel], channel * 2, 1); |
| 480 | 480 | this->dockLayout->addWidget(this->miscComboBox[channel], channel * 2 + 1, 1); |
| ... | ... | @@ -487,14 +487,14 @@ VoltageDock::VoltageDock(DsoSettings *settings, QWidget *parent, Qt::WindowFlags |
| 487 | 487 | this->setWidget(this->dockWidget); |
| 488 | 488 | |
| 489 | 489 | // Connect signals and slots |
| 490 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 490 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 491 | 491 | connect(this->gainComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(gainSelected(int))); |
| 492 | 492 | connect(this->miscComboBox[channel], SIGNAL(currentIndexChanged(int)), this, SLOT(miscSelected(int))); |
| 493 | 493 | connect(this->usedCheckBox[channel], SIGNAL(toggled(bool)), this, SLOT(usedSwitched(bool))); |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | // Set values |
| 497 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 497 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 498 | 498 | if(channel < (int) this->settings->scope.physicalChannels) |
| 499 | 499 | this->setCoupling(channel, (Dso::Coupling) this->settings->scope.voltage[channel].misc); |
| 500 | 500 | else |
| ... | ... | @@ -576,7 +576,7 @@ void VoltageDock::gainSelected(int index) { |
| 576 | 576 | int channel; |
| 577 | 577 | |
| 578 | 578 | // Which combobox was it? |
| 579 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | |
| 579 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) | |
| 580 | 580 | if(this->sender() == this->gainComboBox[channel]) |
| 581 | 581 | break; |
| 582 | 582 | |
| ... | ... | @@ -594,7 +594,7 @@ void VoltageDock::miscSelected(int index) { |
| 594 | 594 | int channel; |
| 595 | 595 | |
| 596 | 596 | // Which combobox was it? |
| 597 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | |
| 597 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) | |
| 598 | 598 | if(this->sender() == this->miscComboBox[channel]) |
| 599 | 599 | break; |
| 600 | 600 | |
| ... | ... | @@ -614,7 +614,7 @@ void VoltageDock::usedSwitched(bool checked) { |
| 614 | 614 | int channel; |
| 615 | 615 | |
| 616 | 616 | // Which checkbox was it? |
| 617 | - for(channel = 0; channel < this->settings->scope.voltage.count(); channel++) | |
| 617 | + for(channel = 0; channel < this->settings->scope.voltage.count(); ++channel) | |
| 618 | 618 | if(this->sender() == this->usedCheckBox[channel]) |
| 619 | 619 | break; |
| 620 | 620 | ... | ... |
openhantek/src/dsowidget.cpp
| ... | ... | @@ -66,7 +66,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget |
| 66 | 66 | |
| 67 | 67 | // The offset sliders for all possible channels |
| 68 | 68 | this->offsetSlider = new LevelSlider(Qt::RightArrow); |
| 69 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 69 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 70 | 70 | this->offsetSlider->addSlider(this->settings->scope.voltage[channel].name, channel); |
| 71 | 71 | this->offsetSlider->setColor(channel, this->settings->view.color.screen.voltage[channel]); |
| 72 | 72 | this->offsetSlider->setLimits(channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); |
| ... | ... | @@ -74,7 +74,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget |
| 74 | 74 | this->offsetSlider->setValue(channel, this->settings->scope.voltage[channel].offset); |
| 75 | 75 | this->offsetSlider->setVisible(channel, this->settings->scope.voltage[channel].used); |
| 76 | 76 | } |
| 77 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 77 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 78 | 78 | this->offsetSlider->addSlider(this->settings->scope.spectrum[channel].name, this->settings->scope.voltage.count() + channel); |
| 79 | 79 | this->offsetSlider->setColor(this->settings->scope.voltage.count() + channel, this->settings->view.color.screen.spectrum[channel]); |
| 80 | 80 | this->offsetSlider->setLimits(this->settings->scope.voltage.count() + channel, -DIVS_VOLTAGE / 2, DIVS_VOLTAGE / 2); |
| ... | ... | @@ -93,7 +93,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget |
| 93 | 93 | |
| 94 | 94 | // The sliders for the trigger levels |
| 95 | 95 | this->triggerLevelSlider = new LevelSlider(Qt::LeftArrow); |
| 96 | - for(int channel = 0; channel < (int) this->settings->scope.physicalChannels; channel++) { | |
| 96 | + for(int channel = 0; channel < (int) this->settings->scope.physicalChannels; ++channel) { | |
| 97 | 97 | this->triggerLevelSlider->addSlider(channel); |
| 98 | 98 | this->triggerLevelSlider->setColor(channel, (!this->settings->scope.trigger.special && channel == (int) this->settings->scope.trigger.source) ? this->settings->view.color.screen.voltage[channel] : this->settings->view.color.screen.voltage[channel].darker()); |
| 99 | 99 | this->adaptTriggerLevelSlider(channel); |
| ... | ... | @@ -103,7 +103,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget |
| 103 | 103 | |
| 104 | 104 | // The marker slider |
| 105 | 105 | this->markerSlider = new LevelSlider(Qt::UpArrow); |
| 106 | - for(int marker = 0; marker < MARKER_COUNT; marker++) { | |
| 106 | + for(int marker = 0; marker < MARKER_COUNT; ++marker) { | |
| 107 | 107 | this->markerSlider->addSlider(QString::number(marker + 1), marker); |
| 108 | 108 | this->markerSlider->setLimits(marker, -DIVS_TIME / 2, DIVS_TIME / 2); |
| 109 | 109 | this->markerSlider->setStep(marker, 0.2); |
| ... | ... | @@ -165,7 +165,7 @@ DsoWidget::DsoWidget(DsoSettings *settings, DataAnalyzer *dataAnalyzer, QWidget |
| 165 | 165 | this->measurementLayout->setColumnStretch(3, 2); |
| 166 | 166 | this->measurementLayout->setColumnStretch(4, 3); |
| 167 | 167 | this->measurementLayout->setColumnStretch(5, 3); |
| 168 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 168 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 169 | 169 | tablePalette.setColor(QPalette::WindowText, this->settings->view.color.screen.voltage[channel]); |
| 170 | 170 | this->measurementNameLabel.append(new QLabel(this->settings->scope.voltage[channel].name)); |
| 171 | 171 | this->measurementNameLabel[channel]->setPalette(tablePalette); |
| ... | ... | @@ -378,7 +378,7 @@ void DsoWidget::updateTriggerSource() { |
| 378 | 378 | else |
| 379 | 379 | this->triggerPositionSlider->setColor(0, this->settings->view.color.screen.voltage[this->settings->scope.trigger.source]); |
| 380 | 380 | |
| 381 | - for(int channel = 0; channel < (int) this->settings->scope.physicalChannels; channel++) | |
| 381 | + for(int channel = 0; channel < (int) this->settings->scope.physicalChannels; ++channel) | |
| 382 | 382 | this->triggerLevelSlider->setColor(channel, (!this->settings->scope.trigger.special && channel == (int) this->settings->scope.trigger.source) ? this->settings->view.color.screen.voltage[channel] : this->settings->view.color.screen.voltage[channel].darker()); |
| 383 | 383 | |
| 384 | 384 | this->updateTriggerDetails(); |
| ... | ... | @@ -439,13 +439,13 @@ bool DsoWidget::exportAs() { |
| 439 | 439 | << tr("Image (*.png *.xpm *.jpg)") |
| 440 | 440 | << tr("Comma-Separated Values (*.csv)"); |
| 441 | 441 | |
| 442 | - QFileDialog fileDialog((QWidget *) this->parent(), tr("Export file..."), QString(), filters.join(";;")); | |
| 442 | + QFileDialog fileDialog(static_cast<QWidget *>(this->parent()), tr("Export file..."), QString(), filters.join(";;")); | |
| 443 | 443 | fileDialog.setFileMode(QFileDialog::AnyFile); |
| 444 | 444 | fileDialog.setAcceptMode(QFileDialog::AcceptSave); |
| 445 | 445 | if(fileDialog.exec() != QDialog::Accepted) |
| 446 | 446 | return false; |
| 447 | 447 | |
| 448 | - Exporter exporter(this->settings, this->dataAnalyzer, (QWidget *) this->parent()); | |
| 448 | + Exporter exporter(this->settings, this->dataAnalyzer, static_cast<QWidget *>(this->parent())); | |
| 449 | 449 | exporter.setFilename(fileDialog.selectedFiles().first()); |
| 450 | 450 | exporter.setFormat((ExportFormat) (EXPORT_FORMAT_PDF + filters.indexOf(fileDialog.selectedFilter()))); |
| 451 | 451 | |
| ... | ... | @@ -455,7 +455,7 @@ bool DsoWidget::exportAs() { |
| 455 | 455 | /// \brief Print the oscilloscope screen. |
| 456 | 456 | /// \return true if the document was sent to the printer successfully. |
| 457 | 457 | bool DsoWidget::print() { |
| 458 | - Exporter exporter(this->settings, this->dataAnalyzer, (QWidget *) this->parent()); | |
| 458 | + Exporter exporter(this->settings, this->dataAnalyzer, static_cast<QWidget *>(this->parent())); | |
| 459 | 459 | exporter.setFormat(EXPORT_FORMAT_PRINTER); |
| 460 | 460 | |
| 461 | 461 | return exporter.doExport(); |
| ... | ... | @@ -481,7 +481,7 @@ void DsoWidget::updateZoom(bool enabled) { |
| 481 | 481 | |
| 482 | 482 | /// \brief Prints analyzed data. |
| 483 | 483 | void DsoWidget::dataAnalyzed() { |
| 484 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 484 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 485 | 485 | if(this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)) { |
| 486 | 486 | // Amplitude string representation (4 significant digits) |
| 487 | 487 | this->measurementAmplitudeLabel[channel]->setText(Helper::valueToString(this->dataAnalyzer->data(channel)->amplitude, Helper::UNIT_VOLTS, 4)); | ... | ... |
openhantek/src/exporter.cpp
| ... | ... | @@ -84,26 +84,28 @@ bool Exporter::doExport() { |
| 84 | 84 | if(this->format < EXPORT_FORMAT_IMAGE) { |
| 85 | 85 | // We need a QPrinter for printing, pdf- and ps-export |
| 86 | 86 | paintDevice = new QPrinter(QPrinter::HighResolution); |
| 87 | - ((QPrinter *) paintDevice)->setOrientation(this->settings->view.zoom ? QPrinter::Portrait : QPrinter::Landscape); | |
| 88 | - ((QPrinter *) paintDevice)->setPageMargins(20, 20, 20, 20, QPrinter::Millimeter); | |
| 87 | + static_cast<QPrinter *>(paintDevice)->setOrientation(this->settings->view.zoom ? QPrinter::Portrait : QPrinter::Landscape); | |
| 88 | + static_cast<QPrinter *>(paintDevice)->setPageMargins(20, 20, 20, 20, QPrinter::Millimeter); | |
| 89 | 89 | |
| 90 | 90 | if(this->format == EXPORT_FORMAT_PRINTER) { |
| 91 | 91 | // Show the printing dialog |
| 92 | - QPrintDialog *dialog = new QPrintDialog((QPrinter *) paintDevice, (QWidget *) this->parent()); | |
| 93 | - dialog->setWindowTitle(tr("Print oscillograph")); | |
| 94 | - if(dialog->exec() != QDialog::Accepted) | |
| 92 | + QPrintDialog dialog(static_cast<QPrinter *>(paintDevice), static_cast<QWidget *>(this->parent())); | |
| 93 | + dialog.setWindowTitle(tr("Print oscillograph")); | |
| 94 | + if(dialog.exec() != QDialog::Accepted) { | |
| 95 | + delete paintDevice; | |
| 95 | 96 | return false; |
| 97 | + } | |
| 96 | 98 | } |
| 97 | 99 | else { |
| 98 | 100 | // Configure the QPrinter |
| 99 | - ((QPrinter *) paintDevice)->setOutputFileName(this->filename); | |
| 100 | - ((QPrinter *) paintDevice)->setOutputFormat((this->format == EXPORT_FORMAT_PDF) ? QPrinter::PdfFormat : QPrinter::PostScriptFormat); | |
| 101 | + static_cast<QPrinter *>(paintDevice)->setOutputFileName(this->filename); | |
| 102 | + static_cast<QPrinter *>(paintDevice)->setOutputFormat((this->format == EXPORT_FORMAT_PDF) ? QPrinter::PdfFormat : QPrinter::PostScriptFormat); | |
| 101 | 103 | } |
| 102 | 104 | } |
| 103 | 105 | else { |
| 104 | 106 | // We need a QPixmap for image-export |
| 105 | 107 | paintDevice = new QPixmap(this->settings->options.imageSize); |
| 106 | - ((QPixmap *) paintDevice)->fill(colorValues->background); | |
| 108 | + static_cast<QPixmap *>(paintDevice)->fill(colorValues->background); | |
| 107 | 109 | } |
| 108 | 110 | |
| 109 | 111 | // Create a painter for our device |
| ... | ... | @@ -142,7 +144,7 @@ bool Exporter::doExport() { |
| 142 | 144 | int channelCount = 0; |
| 143 | 145 | for(int channel = this->settings->scope.voltage.count() - 1; channel >= 0; channel--) { |
| 144 | 146 | if((this->settings->scope.voltage[channel].used || this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel)) { |
| 145 | - channelCount++; | |
| 147 | + ++channelCount; | |
| 146 | 148 | double top = (double) paintDevice->height() - channelCount * lineHeight; |
| 147 | 149 | |
| 148 | 150 | // Print label |
| ... | ... | @@ -208,11 +210,11 @@ bool Exporter::doExport() { |
| 208 | 210 | painter.setRenderHint(QPainter::Antialiasing); |
| 209 | 211 | painter.setBrush(Qt::NoBrush); |
| 210 | 212 | |
| 211 | - for(int zoomed = 0; zoomed < (this->settings->view.zoom ? 2 : 1); zoomed++) { | |
| 213 | + for(int zoomed = 0; zoomed < (this->settings->view.zoom ? 2 : 1); ++zoomed) { | |
| 212 | 214 | switch(this->settings->scope.horizontal.format) { |
| 213 | 215 | case Dso::GRAPHFORMAT_TY: |
| 214 | 216 | // Add graphs for channels |
| 215 | - for(int channel = 0 ; channel < this->settings->scope.voltage.count(); channel++) { | |
| 217 | + for(int channel = 0 ; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 216 | 218 | if(this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel)) { |
| 217 | 219 | painter.setPen(colorValues->voltage[channel]); |
| 218 | 220 | |
| ... | ... | @@ -233,14 +235,17 @@ bool Exporter::doExport() { |
| 233 | 235 | |
| 234 | 236 | // Draw graph |
| 235 | 237 | QPointF *graph = new QPointF[lastPosition - firstPosition + 1]; |
| 236 | - for(unsigned int position = firstPosition; position <= lastPosition; position++) | |
| 238 | + | |
| 239 | + for(unsigned int position = firstPosition; position <= lastPosition; ++position) | |
| 237 | 240 | graph[position - firstPosition] = QPointF(position * horizontalFactor - DIVS_TIME / 2, this->dataAnalyzer->data(channel)->samples.voltage.sample[position] / this->settings->scope.voltage[channel].gain + this->settings->scope.voltage[channel].offset); |
| 241 | + | |
| 238 | 242 | painter.drawPolyline(graph, lastPosition - firstPosition + 1); |
| 243 | + delete[] graph; | |
| 239 | 244 | } |
| 240 | 245 | } |
| 241 | 246 | |
| 242 | 247 | // Add spectrum graphs |
| 243 | - for (int channel = 0; channel < this->settings->scope.spectrum.count(); channel++) { | |
| 248 | + for (int channel = 0; channel < this->settings->scope.spectrum.count(); ++channel) { | |
| 244 | 249 | if(this->settings->scope.spectrum[channel].used && this->dataAnalyzer->data(channel)) { |
| 245 | 250 | painter.setPen(colorValues->spectrum[channel]); |
| 246 | 251 | |
| ... | ... | @@ -261,9 +266,12 @@ bool Exporter::doExport() { |
| 261 | 266 | |
| 262 | 267 | // Draw graph |
| 263 | 268 | QPointF *graph = new QPointF[lastPosition - firstPosition + 1]; |
| 264 | - for(unsigned int position = firstPosition; position <= lastPosition; position++) | |
| 269 | + | |
| 270 | + for(unsigned int position = firstPosition; position <= lastPosition; ++position) | |
| 265 | 271 | graph[position - firstPosition] = QPointF(position * horizontalFactor - DIVS_TIME / 2, this->dataAnalyzer->data(channel)->samples.spectrum.sample[position] / this->settings->scope.spectrum[channel].magnitude + this->settings->scope.spectrum[channel].offset); |
| 272 | + | |
| 266 | 273 | painter.drawPolyline(graph, lastPosition - firstPosition + 1); |
| 274 | + delete[] graph; | |
| 267 | 275 | } |
| 268 | 276 | } |
| 269 | 277 | break; |
| ... | ... | @@ -283,7 +291,7 @@ bool Exporter::doExport() { |
| 283 | 291 | |
| 284 | 292 | // Draw grids |
| 285 | 293 | painter.setRenderHint(QPainter::Antialiasing, false); |
| 286 | - for(int zoomed = 0; zoomed < (this->settings->view.zoom ? 2 : 1); zoomed++) { | |
| 294 | + for(int zoomed = 0; zoomed < (this->settings->view.zoom ? 2 : 1); ++zoomed) { | |
| 287 | 295 | // Set DIVS_TIME x DIVS_VOLTAGE matrix for oscillograph |
| 288 | 296 | painter.setMatrix(QMatrix((paintDevice->width() - 1) / DIVS_TIME, 0, 0, -(scopeHeight - 1) / DIVS_VOLTAGE, (double) (paintDevice->width() - 1) / 2, (scopeHeight - 1) * (zoomed + 0.5) + lineHeight * 1.5 + lineHeight * 2.5 * zoomed), false); |
| 289 | 297 | |
| ... | ... | @@ -292,8 +300,8 @@ bool Exporter::doExport() { |
| 292 | 300 | |
| 293 | 301 | if(this->format < EXPORT_FORMAT_IMAGE) { |
| 294 | 302 | // Draw vertical lines |
| 295 | - for(int div = 1; div < DIVS_TIME / 2; div++) { | |
| 296 | - for(int dot = 1; dot < DIVS_VOLTAGE / 2 * 5; dot++) { | |
| 303 | + for(int div = 1; div < DIVS_TIME / 2; ++div) { | |
| 304 | + for(int dot = 1; dot < DIVS_VOLTAGE / 2 * 5; ++dot) { | |
| 297 | 305 | painter.drawLine(QPointF((double) -div - 0.02, (double) -dot / 5), QPointF((double) -div + 0.02, (double) -dot / 5)); |
| 298 | 306 | painter.drawLine(QPointF((double) -div - 0.02, (double) dot / 5), QPointF((double) -div + 0.02, (double) dot / 5)); |
| 299 | 307 | painter.drawLine(QPointF((double) div - 0.02, (double) -dot / 5), QPointF((double) div + 0.02, (double) -dot / 5)); |
| ... | ... | @@ -301,8 +309,8 @@ bool Exporter::doExport() { |
| 301 | 309 | } |
| 302 | 310 | } |
| 303 | 311 | // Draw horizontal lines |
| 304 | - for(int div = 1; div < DIVS_VOLTAGE / 2; div++) { | |
| 305 | - for(int dot = 1; dot < DIVS_TIME / 2 * 5; dot++) { | |
| 312 | + for(int div = 1; div < DIVS_VOLTAGE / 2; ++div) { | |
| 313 | + for(int dot = 1; dot < DIVS_TIME / 2 * 5; ++dot) { | |
| 306 | 314 | painter.drawLine(QPointF((double) -dot / 5, (double) -div - 0.02), QPointF((double) -dot / 5, (double) -div + 0.02)); |
| 307 | 315 | painter.drawLine(QPointF((double) dot / 5, (double) -div - 0.02), QPointF((double) dot / 5, (double) -div + 0.02)); |
| 308 | 316 | painter.drawLine(QPointF((double) -dot / 5, (double) div - 0.02), QPointF((double) -dot / 5, (double) div + 0.02)); |
| ... | ... | @@ -312,8 +320,8 @@ bool Exporter::doExport() { |
| 312 | 320 | } |
| 313 | 321 | else { |
| 314 | 322 | // Draw vertical lines |
| 315 | - for(int div = 1; div < DIVS_TIME / 2; div++) { | |
| 316 | - for(int dot = 1; dot < DIVS_VOLTAGE / 2 * 5; dot++) { | |
| 323 | + for(int div = 1; div < DIVS_TIME / 2; ++div) { | |
| 324 | + for(int dot = 1; dot < DIVS_VOLTAGE / 2 * 5; ++dot) { | |
| 317 | 325 | painter.drawPoint(QPointF(-div, (double) -dot / 5)); |
| 318 | 326 | painter.drawPoint(QPointF(-div, (double) dot / 5)); |
| 319 | 327 | painter.drawPoint(QPointF(div, (double) -dot / 5)); |
| ... | ... | @@ -321,8 +329,8 @@ bool Exporter::doExport() { |
| 321 | 329 | } |
| 322 | 330 | } |
| 323 | 331 | // Draw horizontal lines |
| 324 | - for(int div = 1; div < DIVS_VOLTAGE / 2; div++) { | |
| 325 | - for(int dot = 1; dot < DIVS_TIME / 2 * 5; dot++) { | |
| 332 | + for(int div = 1; div < DIVS_VOLTAGE / 2; ++div) { | |
| 333 | + for(int dot = 1; dot < DIVS_TIME / 2 * 5; ++dot) { | |
| 326 | 334 | if(dot % 5 == 0) |
| 327 | 335 | continue; // Already done by vertical lines |
| 328 | 336 | painter.drawPoint(QPointF((double) -dot / 5, -div)); |
| ... | ... | @@ -354,7 +362,9 @@ bool Exporter::doExport() { |
| 354 | 362 | painter.end(); |
| 355 | 363 | |
| 356 | 364 | if(this->format == EXPORT_FORMAT_IMAGE) |
| 357 | - ((QPixmap *) paintDevice)->save(this->filename); | |
| 365 | + static_cast<QPixmap *>(paintDevice)->save(this->filename); | |
| 366 | + | |
| 367 | + delete paintDevice; | |
| 358 | 368 | |
| 359 | 369 | return true; |
| 360 | 370 | } |
| ... | ... | @@ -365,14 +375,14 @@ bool Exporter::doExport() { |
| 365 | 375 | |
| 366 | 376 | QTextStream csvStream(&csvFile); |
| 367 | 377 | |
| 368 | - for(int channel = 0 ; channel < this->settings->scope.voltage.count(); channel++) { | |
| 378 | + for(int channel = 0 ; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 369 | 379 | if(this->dataAnalyzer->data(channel)) { |
| 370 | 380 | if(this->settings->scope.voltage[channel].used) { |
| 371 | 381 | // Start with channel name and the sample interval |
| 372 | 382 | csvStream << "\"" << this->settings->scope.voltage[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.voltage.interval; |
| 373 | 383 | |
| 374 | 384 | // And now all sample values in volts |
| 375 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; position++) | |
| 385 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; ++position) | |
| 376 | 386 | csvStream << "," << this->dataAnalyzer->data(channel)->samples.voltage.sample[position]; |
| 377 | 387 | |
| 378 | 388 | // Finally a newline |
| ... | ... | @@ -384,7 +394,7 @@ bool Exporter::doExport() { |
| 384 | 394 | csvStream << "\"" << this->settings->scope.spectrum[channel].name << "\"," << this->dataAnalyzer->data(channel)->samples.spectrum.interval; |
| 385 | 395 | |
| 386 | 396 | // And now all magnitudes in dB |
| 387 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; position++) | |
| 397 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; ++position) | |
| 388 | 398 | csvStream << "," << this->dataAnalyzer->data(channel)->samples.spectrum.sample[position]; |
| 389 | 399 | |
| 390 | 400 | // Finally a newline | ... | ... |
openhantek/src/glgenerator.cpp
| ... | ... | @@ -104,10 +104,10 @@ void GlGenerator::generateGraphs() { |
| 104 | 104 | return; |
| 105 | 105 | |
| 106 | 106 | // Adapt the number of graphs |
| 107 | - for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | |
| 108 | - for(int channel = this->vaChannel[mode].count(); channel < this->settings->scope.voltage.count(); channel++) | |
| 107 | + for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { | |
| 108 | + for(int channel = this->vaChannel[mode].count(); channel < this->settings->scope.voltage.count(); ++channel) | |
| 109 | 109 | this->vaChannel[mode].append(QList<GlArray *>()); |
| 110 | - for(int channel = this->settings->scope.voltage.count(); channel < this->vaChannel[mode].count(); channel++) | |
| 110 | + for(int channel = this->settings->scope.voltage.count(); channel < this->vaChannel[mode].count(); ++channel) | |
| 111 | 111 | this->vaChannel[mode].removeLast(); |
| 112 | 112 | } |
| 113 | 113 | |
| ... | ... | @@ -118,13 +118,13 @@ void GlGenerator::generateGraphs() { |
| 118 | 118 | this->digitalPhosphorDepth = 1; |
| 119 | 119 | |
| 120 | 120 | // Handle all digital phosphor related list manipulations |
| 121 | - for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | |
| 122 | - for(int channel = 0; channel < this->vaChannel[mode].count(); channel++) { | |
| 121 | + for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { | |
| 122 | + for(int channel = 0; channel < this->vaChannel[mode].count(); ++channel) { | |
| 123 | 123 | // Resize lists for vector array if the digital phosphor depth has changed |
| 124 | 124 | if(this->vaChannel[mode][channel].count() != this->digitalPhosphorDepth) |
| 125 | - for(int index = this->vaChannel[mode][channel].count(); index < this->digitalPhosphorDepth; index++) | |
| 125 | + for(int index = this->vaChannel[mode][channel].count(); index < this->digitalPhosphorDepth; ++index) | |
| 126 | 126 | this->vaChannel[mode][channel].append(new GlArray()); |
| 127 | - for(int index = this->digitalPhosphorDepth; index < this->vaChannel[mode][channel].count(); index++) { | |
| 127 | + for(int index = this->digitalPhosphorDepth; index < this->vaChannel[mode][channel].count(); ++index) { | |
| 128 | 128 | delete this->vaChannel[mode][channel].last(); |
| 129 | 129 | this->vaChannel[mode][channel].removeLast(); |
| 130 | 130 | } |
| ... | ... | @@ -139,13 +139,13 @@ void GlGenerator::generateGraphs() { |
| 139 | 139 | switch(this->settings->scope.horizontal.format) { |
| 140 | 140 | case Dso::GRAPHFORMAT_TY: |
| 141 | 141 | // Add graphs for channels |
| 142 | - for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | |
| 143 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 142 | + for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { | |
| 143 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 144 | 144 | // Check if this channel is used and available at the data analyzer |
| 145 | 145 | if(((mode == Dso::CHANNELMODE_VOLTAGE) ? this->settings->scope.voltage[channel].used : this->settings->scope.spectrum[channel].used) && this->dataAnalyzer->data(channel) && this->dataAnalyzer->data(channel)->samples.voltage.sample) { |
| 146 | 146 | // Check if the sample count has changed |
| 147 | 147 | unsigned int neededSize = ((mode == Dso::CHANNELMODE_VOLTAGE) ? this->dataAnalyzer->data(channel)->samples.voltage.count : this->dataAnalyzer->data(channel)->samples.spectrum.count) * 2; |
| 148 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) { | |
| 148 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) { | |
| 149 | 149 | if(this->vaChannel[mode][channel][index]->getSize() != neededSize) |
| 150 | 150 | this->vaChannel[mode][channel][index]->setSize(0); |
| 151 | 151 | } |
| ... | ... | @@ -166,13 +166,13 @@ void GlGenerator::generateGraphs() { |
| 166 | 166 | // Fill vector array |
| 167 | 167 | unsigned int arrayPosition = 0; |
| 168 | 168 | if(mode == Dso::CHANNELMODE_VOLTAGE) { |
| 169 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; position++) { | |
| 169 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; ++position) { | |
| 170 | 170 | vaNewChannel[arrayPosition++] = position * horizontalFactor - DIVS_TIME / 2; |
| 171 | 171 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(channel)->samples.voltage.sample[position] / this->settings->scope.voltage[channel].gain + this->settings->scope.voltage[channel].offset; |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | else { |
| 175 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; position++) { | |
| 175 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.spectrum.count; ++position) { | |
| 176 | 176 | vaNewChannel[arrayPosition++] = position * horizontalFactor - DIVS_TIME / 2; |
| 177 | 177 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(channel)->samples.spectrum.sample[position] / this->settings->scope.spectrum[channel].magnitude + this->settings->scope.spectrum[channel].offset; |
| 178 | 178 | } |
| ... | ... | @@ -180,7 +180,7 @@ void GlGenerator::generateGraphs() { |
| 180 | 180 | } |
| 181 | 181 | else { |
| 182 | 182 | // Delete all vector arrays |
| 183 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) | |
| 183 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) | |
| 184 | 184 | this->vaChannel[mode][channel][index]->setSize(0); |
| 185 | 185 | } |
| 186 | 186 | } |
| ... | ... | @@ -188,12 +188,12 @@ void GlGenerator::generateGraphs() { |
| 188 | 188 | break; |
| 189 | 189 | |
| 190 | 190 | case Dso::GRAPHFORMAT_XY: |
| 191 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel ++) { | |
| 191 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 192 | 192 | // For even channel numbers check if this channel is used and this and the following channel are available at the data analyzer |
| 193 | 193 | if(channel % 2 == 0 && channel + 1 < this->settings->scope.voltage.count() && this->settings->scope.voltage[channel].used && this->dataAnalyzer->data(channel) && this->dataAnalyzer->data(channel)->samples.voltage.sample && this->dataAnalyzer->data(channel + 1) && this->dataAnalyzer->data(channel + 1)->samples.voltage.sample) { |
| 194 | 194 | // Check if the sample count has changed |
| 195 | 195 | unsigned int neededSize = qMin(this->dataAnalyzer->data(channel)->samples.voltage.count, this->dataAnalyzer->data(channel + 1)->samples.voltage.count) * 2; |
| 196 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) { | |
| 196 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) { | |
| 197 | 197 | if(this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->getSize() != neededSize) |
| 198 | 198 | this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->setSize(0); |
| 199 | 199 | } |
| ... | ... | @@ -208,19 +208,19 @@ void GlGenerator::generateGraphs() { |
| 208 | 208 | unsigned int arrayPosition = 0; |
| 209 | 209 | unsigned int xChannel = channel; |
| 210 | 210 | unsigned int yChannel = channel + 1; |
| 211 | - for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; position++) { | |
| 211 | + for(unsigned int position = 0; position < this->dataAnalyzer->data(channel)->samples.voltage.count; ++position) { | |
| 212 | 212 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(xChannel)->samples.voltage.sample[position] / this->settings->scope.voltage[xChannel].gain + this->settings->scope.voltage[xChannel].offset; |
| 213 | 213 | vaNewChannel[arrayPosition++] = this->dataAnalyzer->data(yChannel)->samples.voltage.sample[position] / this->settings->scope.voltage[yChannel].gain + this->settings->scope.voltage[yChannel].offset; |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | else { |
| 217 | 217 | // Delete all vector arrays |
| 218 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) | |
| 218 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) | |
| 219 | 219 | this->vaChannel[Dso::CHANNELMODE_VOLTAGE][channel][index]->setSize(0); |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // Delete all spectrum graphs |
| 223 | - for(int index = 0; index < this->digitalPhosphorDepth; index++) | |
| 223 | + for(int index = 0; index < this->digitalPhosphorDepth; ++index) | |
| 224 | 224 | this->vaChannel[Dso::CHANNELMODE_SPECTRUM][channel][index]->setSize(0); |
| 225 | 225 | } |
| 226 | 226 | break; |
| ... | ... | @@ -240,8 +240,8 @@ void GlGenerator::generateGrid() { |
| 240 | 240 | this->vaGrid[0].setSize(((DIVS_TIME * DIVS_SUB - 2) * (DIVS_VOLTAGE - 2) + (DIVS_VOLTAGE * DIVS_SUB - 2) * (DIVS_TIME - 2) - ((DIVS_TIME - 2) * (DIVS_VOLTAGE - 2))) * 2); |
| 241 | 241 | int pointIndex = 0; |
| 242 | 242 | // Draw vertical lines |
| 243 | - for(int div = 1; div < DIVS_TIME / 2; div++) { | |
| 244 | - for(int dot = 1; dot < DIVS_VOLTAGE / 2 * DIVS_SUB; dot++) { | |
| 243 | + for(int div = 1; div < DIVS_TIME / 2; ++div) { | |
| 244 | + for(int dot = 1; dot < DIVS_VOLTAGE / 2 * DIVS_SUB; ++dot) { | |
| 245 | 245 | float dotPosition = (float) dot / DIVS_SUB; |
| 246 | 246 | this->vaGrid[0].data[pointIndex++] = -div; |
| 247 | 247 | this->vaGrid[0].data[pointIndex++] = -dotPosition; |
| ... | ... | @@ -254,8 +254,8 @@ void GlGenerator::generateGrid() { |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | // Draw horizontal lines |
| 257 | - for(int div = 1; div < DIVS_VOLTAGE / 2; div++) { | |
| 258 | - for(int dot = 1; dot < DIVS_TIME / 2 * DIVS_SUB; dot++) { | |
| 257 | + for(int div = 1; div < DIVS_VOLTAGE / 2; ++div) { | |
| 258 | + for(int dot = 1; dot < DIVS_TIME / 2 * DIVS_SUB; ++dot) { | |
| 259 | 259 | if(dot % DIVS_SUB == 0) |
| 260 | 260 | continue; // Already done by vertical lines |
| 261 | 261 | float dotPosition = (float) dot / DIVS_SUB; |
| ... | ... | @@ -284,7 +284,7 @@ void GlGenerator::generateGrid() { |
| 284 | 284 | this->vaGrid[1].data[pointIndex++] = 0; |
| 285 | 285 | this->vaGrid[1].data[pointIndex++] = DIVS_VOLTAGE / 2; |
| 286 | 286 | // Subdiv lines on horizontal axis |
| 287 | - for(int line = 1; line < DIVS_TIME / 2 * DIVS_SUB; line++) { | |
| 287 | + for(int line = 1; line < DIVS_TIME / 2 * DIVS_SUB; ++line) { | |
| 288 | 288 | float linePosition = (float) line / DIVS_SUB; |
| 289 | 289 | this->vaGrid[1].data[pointIndex++] = linePosition; |
| 290 | 290 | this->vaGrid[1].data[pointIndex++] = -0.05; |
| ... | ... | @@ -296,7 +296,7 @@ void GlGenerator::generateGrid() { |
| 296 | 296 | this->vaGrid[1].data[pointIndex++] = 0.05; |
| 297 | 297 | } |
| 298 | 298 | // Subdiv lines on vertical axis |
| 299 | - for(int line = 1; line < DIVS_VOLTAGE / 2 * DIVS_SUB; line++) { | |
| 299 | + for(int line = 1; line < DIVS_VOLTAGE / 2 * DIVS_SUB; ++line) { | |
| 300 | 300 | float linePosition = (float) line / DIVS_SUB; |
| 301 | 301 | this->vaGrid[1].data[pointIndex++] = -0.05; |
| 302 | 302 | this->vaGrid[1].data[pointIndex++] = linePosition; | ... | ... |
openhantek/src/glscope.cpp
| ... | ... | @@ -96,14 +96,14 @@ void GlScope::paintGL() { |
| 96 | 96 | double *fadingFactor = new double[this->generator->digitalPhosphorDepth]; |
| 97 | 97 | fadingFactor[0] = 100; |
| 98 | 98 | double fadingRatio = pow(10.0, 2.0 / this->generator->digitalPhosphorDepth); |
| 99 | - for(int index = 1; index < this->generator->digitalPhosphorDepth; index++) | |
| 99 | + for(int index = 1; index < this->generator->digitalPhosphorDepth; ++index) | |
| 100 | 100 | fadingFactor[index] = fadingFactor[index - 1] * fadingRatio; |
| 101 | 101 | |
| 102 | 102 | switch(this->settings->scope.horizontal.format) { |
| 103 | 103 | case Dso::GRAPHFORMAT_TY: |
| 104 | 104 | // Real and virtual channels |
| 105 | - for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; mode++) { | |
| 106 | - for(int channel = 0; channel < this->settings->scope.voltage.count(); channel++) { | |
| 105 | + for(int mode = Dso::CHANNELMODE_VOLTAGE; mode < Dso::CHANNELMODE_COUNT; ++mode) { | |
| 106 | + for(int channel = 0; channel < this->settings->scope.voltage.count(); ++channel) { | |
| 107 | 107 | if((mode == Dso::CHANNELMODE_VOLTAGE) ? this->settings->scope.voltage[channel].used : this->settings->scope.spectrum[channel].used) { |
| 108 | 108 | // Draw graph for all available depths |
| 109 | 109 | for(int index = this->generator->digitalPhosphorDepth - 1; index >= 0; index--) { |
| ... | ... | @@ -155,7 +155,7 @@ void GlScope::paintGL() { |
| 155 | 155 | glEnable(GL_LINE_STIPPLE); |
| 156 | 156 | this->qglColor(this->settings->view.color.screen.markers); |
| 157 | 157 | |
| 158 | - for(int marker = 0; marker < MARKER_COUNT; marker++) { | |
| 158 | + for(int marker = 0; marker < MARKER_COUNT; ++marker) { | |
| 159 | 159 | if(!this->vaMarker[marker].data) { |
| 160 | 160 | this->vaMarker[marker].setSize(2 * 2); |
| 161 | 161 | this->vaMarker[marker].data[1] = - DIVS_VOLTAGE; | ... | ... |
openhantek/src/hantek/control.cpp
| ... | ... | @@ -58,21 +58,32 @@ namespace Hantek { |
| 58 | 58 | this->specification.samplerate.multi.base = 100e6; |
| 59 | 59 | this->specification.samplerate.multi.max = 100e6; |
| 60 | 60 | |
| 61 | - for(unsigned int channel = 0; channel < HANTEK_CHANNELS; channel++) { | |
| 62 | - for(unsigned int gainId = 0; gainId < 9; gainId++) { | |
| 61 | + for(unsigned int channel = 0; channel < HANTEK_CHANNELS; ++channel) { | |
| 62 | + for(unsigned int gainId = 0; gainId < 9; ++gainId) { | |
| 63 | 63 | this->specification.offsetLimit[channel][gainId][OFFSET_START] = 0x0000; |
| 64 | 64 | this->specification.offsetLimit[channel][gainId][OFFSET_END] = 0xffff; |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Set settings to default values |
| 69 | - this->settings.recordLengthId = 0; | |
| 70 | 69 | this->settings.samplerate.limits = &(this->specification.samplerate.single); |
| 71 | 70 | this->settings.samplerate.downsampling = 1; |
| 71 | + this->settings.samplerate.current = 0.0; | |
| 72 | 72 | this->settings.trigger.position = 0; |
| 73 | + this->settings.trigger.point = 0; | |
| 74 | + this->settings.trigger.mode = Dso::TRIGGERMODE_NORMAL; | |
| 73 | 75 | this->settings.trigger.slope = Dso::SLOPE_POSITIVE; |
| 74 | 76 | this->settings.trigger.special = false; |
| 75 | 77 | this->settings.trigger.source = 0; |
| 78 | + for(unsigned int channel = 0; channel < HANTEK_CHANNELS; ++channel) { | |
| 79 | + this->settings.trigger.level[channel] = 0.0; | |
| 80 | + this->settings.voltage[channel].gain = 0; | |
| 81 | + this->settings.voltage[channel].offset = 0.0; | |
| 82 | + this->settings.voltage[channel].offsetReal = 0.0; | |
| 83 | + this->settings.voltage[channel].used = false; | |
| 84 | + } | |
| 85 | + this->settings.recordLengthId = 0; | |
| 86 | + this->settings.usedChannels = 0; | |
| 76 | 87 | |
| 77 | 88 | // Special trigger sources |
| 78 | 89 | this->specialTriggerSources << tr("EXT") << tr("EXT/10"); |
| ... | ... | @@ -89,14 +100,14 @@ namespace Hantek { |
| 89 | 100 | this->control[CONTROLINDEX_SETRELAYS] = new ControlSetRelays(); |
| 90 | 101 | this->controlCode[CONTROLINDEX_SETRELAYS] = CONTROL_SETRELAYS; |
| 91 | 102 | |
| 92 | - for(int control = 0; control < CONTROLINDEX_COUNT; control++) | |
| 103 | + for(int control = 0; control < CONTROLINDEX_COUNT; ++control) | |
| 93 | 104 | this->controlPending[control] = false; |
| 94 | 105 | |
| 95 | 106 | // USB device |
| 96 | 107 | this->device = new Device(this); |
| 97 | 108 | |
| 98 | 109 | // Sample buffers |
| 99 | - for(unsigned int channel = 0; channel < HANTEK_CHANNELS; channel++) { | |
| 110 | + for(unsigned int channel = 0; channel < HANTEK_CHANNELS; ++channel) { | |
| 100 | 111 | this->samples.append(0); |
| 101 | 112 | this->samplesSize.append(0); |
| 102 | 113 | } |
| ... | ... | @@ -132,7 +143,7 @@ namespace Hantek { |
| 132 | 143 | |
| 133 | 144 | while(captureState != LIBUSB_ERROR_NO_DEVICE && !this->terminate) { |
| 134 | 145 | // Send all pending bulk commands |
| 135 | - for(int command = 0; command < BULK_COUNT; command++) { | |
| 146 | + for(int command = 0; command < BULK_COUNT; ++command) { | |
| 136 | 147 | if(!this->commandPending[command]) |
| 137 | 148 | continue; |
| 138 | 149 | |
| ... | ... | @@ -142,7 +153,7 @@ namespace Hantek { |
| 142 | 153 | |
| 143 | 154 | errorCode = this->device->bulkCommand(this->command[command]); |
| 144 | 155 | if(errorCode < 0) { |
| 145 | - qWarning("Sending bulk command 0x%02x failed: %s", command, Helper::libUsbErrorString(errorCode).toLocal8Bit().data()); | |
| 156 | + qWarning("Sending bulk command %02x failed: %s", command, Helper::libUsbErrorString(errorCode).toLocal8Bit().data()); | |
| 146 | 157 | |
| 147 | 158 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) { |
| 148 | 159 | captureState = LIBUSB_ERROR_NO_DEVICE; |
| ... | ... | @@ -156,17 +167,17 @@ namespace Hantek { |
| 156 | 167 | break; |
| 157 | 168 | |
| 158 | 169 | // Send all pending control commands |
| 159 | - for(int control = 0; control < CONTROLINDEX_COUNT; control++) { | |
| 170 | + for(int control = 0; control < CONTROLINDEX_COUNT; ++control) { | |
| 160 | 171 | if(!this->controlPending[control]) |
| 161 | 172 | continue; |
| 162 | 173 | |
| 163 | 174 | #ifdef DEBUG |
| 164 | - qDebug("Sending control command 0x%02x:%s", control, Helper::hexDump(this->control[control]->data(), this->control[control]->getSize()).toLocal8Bit().data()); | |
| 175 | + qDebug("Sending control command %02x:%s", this->controlCode[control], Helper::hexDump(this->control[control]->data(), this->control[control]->getSize()).toLocal8Bit().data()); | |
| 165 | 176 | #endif |
| 166 | 177 | |
| 167 | 178 | errorCode = this->device->controlWrite(this->controlCode[control], this->control[control]->data(), this->control[control]->getSize()); |
| 168 | 179 | if(errorCode < 0) { |
| 169 | - qWarning("Sending control command 0x%2x failed: %s", control, Helper::libUsbErrorString(errorCode).toLocal8Bit().data()); | |
| 180 | + qWarning("Sending control command %2x failed: %s", this->controlCode[control], Helper::libUsbErrorString(errorCode).toLocal8Bit().data()); | |
| 170 | 181 | |
| 171 | 182 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) { |
| 172 | 183 | captureState = LIBUSB_ERROR_NO_DEVICE; |
| ... | ... | @@ -181,7 +192,7 @@ namespace Hantek { |
| 181 | 192 | |
| 182 | 193 | // Check the current oscilloscope state everytime 25% of the time the buffer should be refilled |
| 183 | 194 | // Not more often than every 10 ms though |
| 184 | - int cycleTime = qMax((unsigned long int) (this->specification.recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), (long unsigned int) 10); | |
| 195 | + int cycleTime = qMax((unsigned long int) (this->specification.recordLengths[this->settings.recordLengthId] / this->settings.samplerate.current * 250), 10lu); | |
| 185 | 196 | this->msleep(cycleTime); |
| 186 | 197 | |
| 187 | 198 | if(!this->sampling) { |
| ... | ... | @@ -225,7 +236,7 @@ namespace Hantek { |
| 225 | 236 | |
| 226 | 237 | case CAPTURE_WAITING: |
| 227 | 238 | if(samplingStarted && lastTriggerMode == this->settings.trigger.mode) { |
| 228 | - cycleCounter++; | |
| 239 | + ++cycleCounter; | |
| 229 | 240 | |
| 230 | 241 | if(cycleCounter == startCycle) { |
| 231 | 242 | // Buffer refilled completely since start of sampling, enable the trigger now |
| ... | ... | @@ -249,7 +260,7 @@ namespace Hantek { |
| 249 | 260 | #endif |
| 250 | 261 | } |
| 251 | 262 | |
| 252 | - if(cycleCounter < 50 || cycleCounter < 4000 / cycleTime) | |
| 263 | + if(cycleCounter < 20 || cycleCounter < 4000 / cycleTime) | |
| 253 | 264 | break; |
| 254 | 265 | } |
| 255 | 266 | |
| ... | ... | @@ -356,7 +367,7 @@ namespace Hantek { |
| 356 | 367 | } |
| 357 | 368 | |
| 358 | 369 | // Clear unused channels |
| 359 | - for(int channelCounter = 0; channelCounter < HANTEK_CHANNELS; channelCounter++) | |
| 370 | + for(int channelCounter = 0; channelCounter < HANTEK_CHANNELS; ++channelCounter) | |
| 360 | 371 | if(channelCounter != channel && this->samples[channelCounter]) { |
| 361 | 372 | |
| 362 | 373 | delete this->samples[channelCounter]; |
| ... | ... | @@ -380,7 +391,7 @@ namespace Hantek { |
| 380 | 391 | unsigned int extraBitsSize = this->specification.sampleSize - 8; // Number of extra bits |
| 381 | 392 | unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction |
| 382 | 393 | |
| 383 | - for(unsigned int realPosition = 0; realPosition < dataCount; realPosition++, bufferPosition++) { | |
| 394 | + for(unsigned int realPosition = 0; realPosition < dataCount; ++realPosition, ++bufferPosition) { | |
| 384 | 395 | if(bufferPosition >= dataCount) |
| 385 | 396 | bufferPosition %= dataCount; |
| 386 | 397 | |
| ... | ... | @@ -390,7 +401,7 @@ namespace Hantek { |
| 390 | 401 | } |
| 391 | 402 | } |
| 392 | 403 | else { |
| 393 | - for(unsigned int realPosition = 0; realPosition < dataCount; realPosition++, bufferPosition++) { | |
| 404 | + for(unsigned int realPosition = 0; realPosition < dataCount; ++realPosition, ++bufferPosition) { | |
| 394 | 405 | if(bufferPosition >= dataCount) |
| 395 | 406 | bufferPosition %= dataCount; |
| 396 | 407 | |
| ... | ... | @@ -403,7 +414,7 @@ namespace Hantek { |
| 403 | 414 | // Normal mode, channels are using their separate buffers |
| 404 | 415 | unsigned int channelDataCount = dataCount / HANTEK_CHANNELS; |
| 405 | 416 | |
| 406 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) { | |
| 417 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) { | |
| 407 | 418 | if(this->settings.voltage[channel].used) { |
| 408 | 419 | // Reallocate memory for samples if the sample count has changed |
| 409 | 420 | if(!this->samples[channel] || this->samplesSize[channel] != channelDataCount) { |
| ... | ... | @@ -421,7 +432,7 @@ namespace Hantek { |
| 421 | 432 | unsigned short int extraBitsMask = (0x00ff << extraBitsSize) & 0xff00; // Mask for extra bits extraction |
| 422 | 433 | unsigned int extraBitsIndex = 8 - channel * 2; // Bit position offset for extra bits extraction |
| 423 | 434 | |
| 424 | - for(unsigned int realPosition = 0; realPosition < channelDataCount; realPosition++, bufferPosition += 2) { | |
| 435 | + for(unsigned int realPosition = 0; realPosition < channelDataCount; ++realPosition, bufferPosition += 2) { | |
| 425 | 436 | if(bufferPosition >= dataCount) |
| 426 | 437 | bufferPosition %= dataCount; |
| 427 | 438 | |
| ... | ... | @@ -429,7 +440,7 @@ namespace Hantek { |
| 429 | 440 | } |
| 430 | 441 | } |
| 431 | 442 | else { |
| 432 | - for(unsigned int realPosition = 0; realPosition < channelDataCount; realPosition++, bufferPosition += 2) { | |
| 443 | + for(unsigned int realPosition = 0; realPosition < channelDataCount; ++realPosition, bufferPosition += 2) { | |
| 433 | 444 | if(bufferPosition >= dataCount) |
| 434 | 445 | bufferPosition %= dataCount; |
| 435 | 446 | |
| ... | ... | @@ -459,7 +470,7 @@ namespace Hantek { |
| 459 | 470 | unsigned long int Control::updateRecordLength(unsigned long int size) { |
| 460 | 471 | // Get the record length supporting the highest samplerate while meeting the requirement |
| 461 | 472 | int bestSizeId = -1; |
| 462 | - for(int sizeId = 0; sizeId < this->specification.recordLengths.count(); sizeId++) { | |
| 473 | + for(int sizeId = 0; sizeId < this->specification.recordLengths.count(); ++sizeId) { | |
| 463 | 474 | if(this->specification.recordLengths[sizeId] >= size) { |
| 464 | 475 | // We meet the size-requirement, check if we provide the highest possible samplerate |
| 465 | 476 | if(bestSizeId == -1 || this->specification.recordLengths[bestSizeId] < size || this->specification.bufferDividers[sizeId] < this->specification.bufferDividers[bestSizeId]) |
| ... | ... | @@ -475,7 +486,7 @@ namespace Hantek { |
| 475 | 486 | switch(this->specification.command.bulk.setRecordLength) { |
| 476 | 487 | case BULK_SETTRIGGERANDSAMPLERATE: |
| 477 | 488 | // SetTriggerAndSamplerate bulk command for record length |
| 478 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setRecordLength(bestSizeId); | |
| 489 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setRecordLength(bestSizeId); | |
| 479 | 490 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 480 | 491 | |
| 481 | 492 | break; |
| ... | ... | @@ -483,8 +494,8 @@ namespace Hantek { |
| 483 | 494 | case BULK_DSETBUFFER: |
| 484 | 495 | if(this->specification.command.bulk.setPretrigger == BULK_FSETBUFFER) { |
| 485 | 496 | // Pointers to needed commands |
| 486 | - BulkSetRecordLength2250 *commandSetRecordLength2250 = (BulkSetRecordLength2250 *) this->command[BULK_DSETBUFFER]; | |
| 487 | - BulkSetBuffer2250 *commandSetBuffer2250 = (BulkSetBuffer2250 *) this->command[BULK_FSETBUFFER]; | |
| 497 | + BulkSetRecordLength2250 *commandSetRecordLength2250 = static_cast<BulkSetRecordLength2250 *>(this->command[BULK_DSETBUFFER]); | |
| 498 | + BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(this->command[BULK_FSETBUFFER]); | |
| 488 | 499 | |
| 489 | 500 | commandSetRecordLength2250->setRecordLength(bestSizeId); |
| 490 | 501 | commandSetBuffer2250->setUsedPre(FTRIGGERPOSITION_ON); |
| ... | ... | @@ -497,7 +508,7 @@ namespace Hantek { |
| 497 | 508 | } |
| 498 | 509 | else { |
| 499 | 510 | // SetBuffer5200 bulk command for record length |
| 500 | - BulkSetBuffer5200 *commandSetBuffer5200 = (BulkSetBuffer5200 *) this->command[BULK_DSETBUFFER]; | |
| 511 | + BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(this->command[BULK_DSETBUFFER]); | |
| 501 | 512 | commandSetBuffer5200->setUsedPre(DTRIGGERPOSITION_ON); |
| 502 | 513 | commandSetBuffer5200->setUsedPost(DTRIGGERPOSITION_ON); |
| 503 | 514 | commandSetBuffer5200->setRecordLength(bestSizeId); |
| ... | ... | @@ -617,14 +628,14 @@ namespace Hantek { |
| 617 | 628 | if(unsupported) |
| 618 | 629 | qWarning("Warning: This Hantek DSO model isn't supported officially, so it may not be working as expected. Reports about your experiences are very welcome though (Please open a feature request in the tracker at https://sf.net/projects/openhantek/ or email me directly to oliver.haag@gmail.com). If it's working perfectly I can remove this warning, if not it should be possible to get it working with your help soon."); |
| 619 | 630 | |
| 620 | - for(int control = 0; control < CONTROLINDEX_COUNT; control++) | |
| 631 | + for(int control = 0; control < CONTROLINDEX_COUNT; ++control) | |
| 621 | 632 | this->controlPending[control] = true; |
| 622 | 633 | |
| 623 | 634 | // Maximum possible samplerate for a single channel and dividers for record lengths |
| 624 | 635 | this->specification.bufferDividers.clear(); |
| 625 | 636 | this->specification.recordLengths.clear(); |
| 626 | 637 | this->specification.gainSteps.clear(); |
| 627 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | |
| 638 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) | |
| 628 | 639 | this->specification.voltageLimit[channel].clear(); |
| 629 | 640 | |
| 630 | 641 | switch(this->device->getModel()) { |
| ... | ... | @@ -639,7 +650,7 @@ namespace Hantek { |
| 639 | 650 | this->specification.gainSteps |
| 640 | 651 | << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0 << 80.0; |
| 641 | 652 | /// \todo Use calibration data to get the DSO-5200(A) sample ranges |
| 642 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | |
| 653 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) | |
| 643 | 654 | this->specification.voltageLimit[channel] |
| 644 | 655 | << 368 << 454 << 908 << 368 << 454 << 908 << 368 << 454 << 908; |
| 645 | 656 | this->specification.gainIndex |
| ... | ... | @@ -656,7 +667,7 @@ namespace Hantek { |
| 656 | 667 | this->specification.recordLengths << ULONG_MAX << 10240 << 524288; |
| 657 | 668 | this->specification.gainSteps |
| 658 | 669 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; |
| 659 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | |
| 670 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) | |
| 660 | 671 | this->specification.voltageLimit[channel] |
| 661 | 672 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 662 | 673 | this->specification.gainIndex |
| ... | ... | @@ -673,7 +684,7 @@ namespace Hantek { |
| 673 | 684 | this->specification.recordLengths << ULONG_MAX << 10240 << 32768; |
| 674 | 685 | this->specification.gainSteps |
| 675 | 686 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; |
| 676 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | |
| 687 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) | |
| 677 | 688 | this->specification.voltageLimit[channel] |
| 678 | 689 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 679 | 690 | this->specification.gainIndex |
| ... | ... | @@ -690,7 +701,7 @@ namespace Hantek { |
| 690 | 701 | this->specification.recordLengths << ULONG_MAX << 10240 << 32768; |
| 691 | 702 | this->specification.gainSteps |
| 692 | 703 | << 0.08 << 0.16 << 0.40 << 0.80 << 1.60 << 4.00 << 8.0 << 16.0 << 40.0; |
| 693 | - for(int channel = 0; channel < HANTEK_CHANNELS; channel++) | |
| 704 | + for(int channel = 0; channel < HANTEK_CHANNELS; ++channel) | |
| 694 | 705 | this->specification.voltageLimit[channel] |
| 695 | 706 | << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255 << 255; |
| 696 | 707 | this->specification.gainIndex |
| ... | ... | @@ -779,7 +790,7 @@ namespace Hantek { |
| 779 | 790 | switch(this->specification.command.bulk.setSamplerate) { |
| 780 | 791 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 781 | 792 | // Pointers to needed commands |
| 782 | - BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = (BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE]; | |
| 793 | + BulkSetTriggerAndSamplerate *commandSetTriggerAndSamplerate = static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE]); | |
| 783 | 794 | |
| 784 | 795 | // Store samplerate fast value |
| 785 | 796 | commandSetTriggerAndSamplerate->setSamplerateFast(valueFast); |
| ... | ... | @@ -794,8 +805,8 @@ namespace Hantek { |
| 794 | 805 | } |
| 795 | 806 | case BULK_CSETTRIGGERORSAMPLERATE: { |
| 796 | 807 | // Pointers to needed commands |
| 797 | - BulkSetSamplerate5200 *commandSetSamplerate5200 = (BulkSetSamplerate5200 *) this->command[BULK_CSETTRIGGERORSAMPLERATE]; | |
| 798 | - BulkSetTrigger5200 *commandSetTrigger5200 = (BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE]; | |
| 808 | + BulkSetSamplerate5200 *commandSetSamplerate5200 = static_cast<BulkSetSamplerate5200 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE]); | |
| 809 | + BulkSetTrigger5200 *commandSetTrigger5200 = static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE]); | |
| 799 | 810 | |
| 800 | 811 | // Store samplerate fast value |
| 801 | 812 | commandSetSamplerate5200->setSamplerateFast(4 - valueFast); |
| ... | ... | @@ -811,7 +822,7 @@ namespace Hantek { |
| 811 | 822 | } |
| 812 | 823 | case BULK_ESETTRIGGERORSAMPLERATE: { |
| 813 | 824 | // Pointers to needed commands |
| 814 | - BulkSetSamplerate2250 *commandSetSamplerate2250 = (BulkSetSamplerate2250 *) this->command[BULK_ESETTRIGGERORSAMPLERATE]; | |
| 825 | + BulkSetSamplerate2250 *commandSetSamplerate2250 = static_cast<BulkSetSamplerate2250 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE]); | |
| 815 | 826 | |
| 816 | 827 | // Store samplerate fast value |
| 817 | 828 | commandSetSamplerate2250->setSamplerateFast(4 - valueFast); |
| ... | ... | @@ -848,7 +859,7 @@ namespace Hantek { |
| 848 | 859 | switch(this->specification.command.bulk.setFilter) { |
| 849 | 860 | case BULK_SETFILTER: { |
| 850 | 861 | // SetFilter bulk command for channel filter (used has to be inverted!) |
| 851 | - BulkSetFilter *commandSetFilter = (BulkSetFilter *) this->command[BULK_SETFILTER]; | |
| 862 | + BulkSetFilter *commandSetFilter = static_cast<BulkSetFilter *>(this->command[BULK_SETFILTER]); | |
| 852 | 863 | commandSetFilter->setChannel(channel, !used); |
| 853 | 864 | this->commandPending[BULK_SETFILTER] = true; |
| 854 | 865 | |
| ... | ... | @@ -856,7 +867,7 @@ namespace Hantek { |
| 856 | 867 | } |
| 857 | 868 | case BULK_BSETFILTER: { |
| 858 | 869 | // SetFilter2250 bulk command for channel filter (used has to be inverted!) |
| 859 | - BulkSetFilter2250 *commandSetFilter2250 = (BulkSetFilter2250 *) this->command[BULK_BSETFILTER]; | |
| 870 | + BulkSetFilter2250 *commandSetFilter2250 = static_cast<BulkSetFilter2250 *>(this->command[BULK_BSETFILTER]); | |
| 860 | 871 | commandSetFilter2250->setChannel(channel, !used); |
| 861 | 872 | this->commandPending[BULK_BSETFILTER] = true; |
| 862 | 873 | |
| ... | ... | @@ -889,13 +900,13 @@ namespace Hantek { |
| 889 | 900 | switch(this->specification.command.bulk.setTrigger) { |
| 890 | 901 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 891 | 902 | // SetTriggerAndSamplerate bulk command for trigger source |
| 892 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setUsedChannels(usedChannels); | |
| 903 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setUsedChannels(usedChannels); | |
| 893 | 904 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 894 | 905 | break; |
| 895 | 906 | } |
| 896 | 907 | case BULK_ESETTRIGGERORSAMPLERATE: { |
| 897 | 908 | // SetTrigger5200s bulk command for trigger source |
| 898 | - ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setUsedChannels(usedChannels); | |
| 909 | + static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE])->setUsedChannels(usedChannels); | |
| 899 | 910 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; |
| 900 | 911 | break; |
| 901 | 912 | } |
| ... | ... | @@ -919,7 +930,7 @@ namespace Hantek { |
| 919 | 930 | return Dso::ERROR_PARAMETER; |
| 920 | 931 | |
| 921 | 932 | // SetRelays control command for coupling relays |
| 922 | - ((ControlSetRelays *) this->control[CONTROLINDEX_SETRELAYS])->setCoupling(channel, coupling != Dso::COUPLING_AC); | |
| 933 | + static_cast<ControlSetRelays *>(this->control[CONTROLINDEX_SETRELAYS])->setCoupling(channel, coupling != Dso::COUPLING_AC); | |
| 923 | 934 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; |
| 924 | 935 | |
| 925 | 936 | return Dso::ERROR_NONE; |
| ... | ... | @@ -938,16 +949,16 @@ namespace Hantek { |
| 938 | 949 | |
| 939 | 950 | // Find lowest gain voltage thats at least as high as the requested |
| 940 | 951 | int gainId; |
| 941 | - for(gainId = 0; gainId < this->specification.gainSteps.count() - 1; gainId++) | |
| 952 | + for(gainId = 0; gainId < this->specification.gainSteps.count() - 1; ++gainId) | |
| 942 | 953 | if(this->specification.gainSteps[gainId] >= gain) |
| 943 | 954 | break; |
| 944 | 955 | |
| 945 | 956 | // SetGain bulk command for gain |
| 946 | - ((BulkSetGain *) this->command[BULK_SETGAIN])->setGain(channel, this->specification.gainIndex[gainId]); | |
| 957 | + static_cast<BulkSetGain *>(this->command[BULK_SETGAIN])->setGain(channel, this->specification.gainIndex[gainId]); | |
| 947 | 958 | this->commandPending[BULK_SETGAIN] = true; |
| 948 | 959 | |
| 949 | 960 | // SetRelays control command for gain relays |
| 950 | - ControlSetRelays *controlSetRelays = (ControlSetRelays *) this->control[CONTROLINDEX_SETRELAYS]; | |
| 961 | + ControlSetRelays *controlSetRelays = static_cast<ControlSetRelays *>(this->control[CONTROLINDEX_SETRELAYS]); | |
| 951 | 962 | controlSetRelays->setBelow1V(channel, gainId < 3); |
| 952 | 963 | controlSetRelays->setBelow100mV(channel, gainId < 6); |
| 953 | 964 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; |
| ... | ... | @@ -978,7 +989,7 @@ namespace Hantek { |
| 978 | 989 | double offsetReal = (double) (offsetValue - minimum) / (maximum - minimum); |
| 979 | 990 | |
| 980 | 991 | // SetOffset control command for channel offset |
| 981 | - ((ControlSetOffset *) this->control[CONTROLINDEX_SETOFFSET])->setChannel(channel, offsetValue); | |
| 992 | + static_cast<ControlSetOffset *>(this->control[CONTROLINDEX_SETOFFSET])->setChannel(channel, offsetValue); | |
| 982 | 993 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; |
| 983 | 994 | |
| 984 | 995 | this->settings.voltage[channel].offset = offset; |
| ... | ... | @@ -1023,19 +1034,19 @@ namespace Hantek { |
| 1023 | 1034 | switch(this->specification.command.bulk.setTrigger) { |
| 1024 | 1035 | case BULK_SETTRIGGERANDSAMPLERATE: |
| 1025 | 1036 | // SetTriggerAndSamplerate bulk command for trigger source |
| 1026 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSource(sourceValue); | |
| 1037 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSource(sourceValue); | |
| 1027 | 1038 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 1028 | 1039 | break; |
| 1029 | 1040 | |
| 1030 | 1041 | case BULK_CSETTRIGGERORSAMPLERATE: |
| 1031 | 1042 | // SetTrigger2250 bulk command for trigger source |
| 1032 | - ((BulkSetTrigger2250 *) this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); | |
| 1043 | + static_cast<BulkSetTrigger2250 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); | |
| 1033 | 1044 | this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; |
| 1034 | 1045 | break; |
| 1035 | 1046 | |
| 1036 | 1047 | case BULK_ESETTRIGGERORSAMPLERATE: |
| 1037 | 1048 | // SetTrigger5200 bulk command for trigger source |
| 1038 | - ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); | |
| 1049 | + static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSource(sourceValue); | |
| 1039 | 1050 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; |
| 1040 | 1051 | break; |
| 1041 | 1052 | |
| ... | ... | @@ -1044,7 +1055,7 @@ namespace Hantek { |
| 1044 | 1055 | } |
| 1045 | 1056 | |
| 1046 | 1057 | // SetRelays control command for external trigger relay |
| 1047 | - ((ControlSetRelays *) this->control[CONTROLINDEX_SETRELAYS])->setTrigger(special); | |
| 1058 | + static_cast<ControlSetRelays *>(this->control[CONTROLINDEX_SETRELAYS])->setTrigger(special); | |
| 1048 | 1059 | this->controlPending[CONTROLINDEX_SETRELAYS] = true; |
| 1049 | 1060 | |
| 1050 | 1061 | this->settings.trigger.special = special; |
| ... | ... | @@ -1053,7 +1064,7 @@ namespace Hantek { |
| 1053 | 1064 | // Apply trigger level of the new source |
| 1054 | 1065 | if(special) { |
| 1055 | 1066 | // SetOffset control command for changed trigger level |
| 1056 | - ((ControlSetOffset *) this->control[CONTROLINDEX_SETOFFSET])->setTrigger(0x7f); | |
| 1067 | + static_cast<ControlSetOffset *>(this->control[CONTROLINDEX_SETOFFSET])->setTrigger(0x7f); | |
| 1057 | 1068 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; |
| 1058 | 1069 | } |
| 1059 | 1070 | else |
| ... | ... | @@ -1096,7 +1107,7 @@ namespace Hantek { |
| 1096 | 1107 | // Check if the set channel is the trigger source |
| 1097 | 1108 | if(!this->settings.trigger.special && channel == this->settings.trigger.source) { |
| 1098 | 1109 | // SetOffset control command for trigger level |
| 1099 | - ((ControlSetOffset *) this->control[CONTROLINDEX_SETOFFSET])->setTrigger(levelValue); | |
| 1110 | + static_cast<ControlSetOffset *>(this->control[CONTROLINDEX_SETOFFSET])->setTrigger(levelValue); | |
| 1100 | 1111 | this->controlPending[CONTROLINDEX_SETOFFSET] = true; |
| 1101 | 1112 | } |
| 1102 | 1113 | |
| ... | ... | @@ -1119,19 +1130,19 @@ namespace Hantek { |
| 1119 | 1130 | switch(this->specification.command.bulk.setTrigger) { |
| 1120 | 1131 | case BULK_SETTRIGGERANDSAMPLERATE: { |
| 1121 | 1132 | // SetTriggerAndSamplerate bulk command for trigger slope |
| 1122 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSlope(slope); | |
| 1133 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerSlope(slope); | |
| 1123 | 1134 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 1124 | 1135 | break; |
| 1125 | 1136 | } |
| 1126 | 1137 | case BULK_CSETTRIGGERORSAMPLERATE: { |
| 1127 | 1138 | // SetTrigger2250 bulk command for trigger slope |
| 1128 | - ((BulkSetTrigger2250 *) this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); | |
| 1139 | + static_cast<BulkSetTrigger2250 *>(this->command[BULK_CSETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); | |
| 1129 | 1140 | this->commandPending[BULK_CSETTRIGGERORSAMPLERATE] = true; |
| 1130 | 1141 | break; |
| 1131 | 1142 | } |
| 1132 | 1143 | case BULK_ESETTRIGGERORSAMPLERATE: { |
| 1133 | 1144 | // SetTrigger5200 bulk command for trigger slope |
| 1134 | - ((BulkSetTrigger5200 *) this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); | |
| 1145 | + static_cast<BulkSetTrigger5200 *>(this->command[BULK_ESETTRIGGERORSAMPLERATE])->setTriggerSlope(slope); | |
| 1135 | 1146 | this->commandPending[BULK_ESETTRIGGERORSAMPLERATE] = true; |
| 1136 | 1147 | break; |
| 1137 | 1148 | } |
| ... | ... | @@ -1162,7 +1173,7 @@ namespace Hantek { |
| 1162 | 1173 | unsigned long int position = 0x7ffff - this->specification.recordLengths[this->settings.recordLengthId] + positionSamples; |
| 1163 | 1174 | |
| 1164 | 1175 | // SetTriggerAndSamplerate bulk command for trigger position |
| 1165 | - ((BulkSetTriggerAndSamplerate *) this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position); | |
| 1176 | + static_cast<BulkSetTriggerAndSamplerate *>(this->command[BULK_SETTRIGGERANDSAMPLERATE])->setTriggerPosition(position); | |
| 1166 | 1177 | this->commandPending[BULK_SETTRIGGERANDSAMPLERATE] = true; |
| 1167 | 1178 | |
| 1168 | 1179 | break; |
| ... | ... | @@ -1173,7 +1184,7 @@ namespace Hantek { |
| 1173 | 1184 | unsigned short int positionPost = 0xffff - positionSamples; |
| 1174 | 1185 | |
| 1175 | 1186 | // SetBuffer2250 bulk command for trigger position |
| 1176 | - BulkSetBuffer2250 *commandSetBuffer2250 = (BulkSetBuffer2250 *) this->command[BULK_FSETBUFFER]; | |
| 1187 | + BulkSetBuffer2250 *commandSetBuffer2250 = static_cast<BulkSetBuffer2250 *>(this->command[BULK_FSETBUFFER]); | |
| 1177 | 1188 | commandSetBuffer2250->setTriggerPositionPre(positionPre); |
| 1178 | 1189 | commandSetBuffer2250->setTriggerPositionPost(positionPost); |
| 1179 | 1190 | this->commandPending[BULK_FSETBUFFER] = true; |
| ... | ... | @@ -1186,7 +1197,7 @@ namespace Hantek { |
| 1186 | 1197 | unsigned short int positionPost = 0xffff - positionSamples; |
| 1187 | 1198 | |
| 1188 | 1199 | // SetBuffer5200 bulk command for trigger position |
| 1189 | - BulkSetBuffer5200 *commandSetBuffer5200 = (BulkSetBuffer5200 *) this->command[BULK_DSETBUFFER]; | |
| 1200 | + BulkSetBuffer5200 *commandSetBuffer5200 = static_cast<BulkSetBuffer5200 *>(this->command[BULK_DSETBUFFER]); | |
| 1190 | 1201 | commandSetBuffer5200->setTriggerPositionPre(positionPre); |
| 1191 | 1202 | commandSetBuffer5200->setTriggerPositionPost(positionPost); |
| 1192 | 1203 | this->commandPending[BULK_DSETBUFFER] = true; |
| ... | ... | @@ -1240,7 +1251,7 @@ namespace Hantek { |
| 1240 | 1251 | // Get control code from third part |
| 1241 | 1252 | unsigned char controlCode = commandParts[2].toUShort(); |
| 1242 | 1253 | int control; |
| 1243 | - for(control = 0; control < CONTROLINDEX_COUNT; control++) { | |
| 1254 | + for(control = 0; control < CONTROLINDEX_COUNT; ++control) { | |
| 1244 | 1255 | if(this->controlCode[control] == controlCode) |
| 1245 | 1256 | break; |
| 1246 | 1257 | } | ... | ... |
openhantek/src/hantek/control.h
| ... | ... | @@ -133,7 +133,6 @@ namespace Hantek { |
| 133 | 133 | /// \brief Stores the current samplerate settings of the device. |
| 134 | 134 | struct ControlSettingsSamplerate { |
| 135 | 135 | ControlSamplerateLimits *limits; ///< The samplerate limits |
| 136 | - //unsigned long int divider; ///< The fixed samplerate divider | |
| 137 | 136 | unsigned long int downsampling; ///< The variable downsampling factor |
| 138 | 137 | double current; ///< The current samplerate |
| 139 | 138 | }; |
| ... | ... | @@ -144,7 +143,7 @@ namespace Hantek { |
| 144 | 143 | struct ControlSettingsTrigger { |
| 145 | 144 | double level[HANTEK_CHANNELS]; ///< The trigger level for each channel in V |
| 146 | 145 | double position; ///< The current pretrigger position |
| 147 | - unsigned int point; ///< The trigger point value | |
| 146 | + unsigned int point; ///< The trigger position in Hantek coding | |
| 148 | 147 | Dso::TriggerMode mode; ///< The trigger mode |
| 149 | 148 | Dso::Slope slope; ///< The trigger slope |
| 150 | 149 | bool special; ///< true, if the trigger source is special | ... | ... |
openhantek/src/hantek/device.cpp
| ... | ... | @@ -51,6 +51,9 @@ namespace Hantek { |
| 51 | 51 | this->handle = 0; |
| 52 | 52 | this->interface = -1; |
| 53 | 53 | |
| 54 | + this->outPacketLength = 0; | |
| 55 | + this->inPacketLength = 0; | |
| 56 | + | |
| 54 | 57 | #if LIBUSB_VERSION == 0 |
| 55 | 58 | usb_init(); |
| 56 | 59 | this->error = LIBUSB_SUCCESS; |
| ... | ... | @@ -107,7 +110,7 @@ namespace Hantek { |
| 107 | 110 | struct usb_config_descriptor *configDescriptor = device->config; |
| 108 | 111 | struct usb_interface *interface; |
| 109 | 112 | struct usb_interface_descriptor *interfaceDescriptor; |
| 110 | - for(int interfaceIndex = 0; interfaceIndex < configDescriptor->bNumInterfaces; interfaceIndex++) { | |
| 113 | + for(int interfaceIndex = 0; interfaceIndex < configDescriptor->bNumInterfaces; ++interfaceIndex) { | |
| 111 | 114 | interface = &configDescriptor->interface[interfaceIndex]; |
| 112 | 115 | if(interface->num_altsetting < 1) |
| 113 | 116 | continue; |
| ... | ... | @@ -128,7 +131,7 @@ namespace Hantek { |
| 128 | 131 | usb_endpoint_descriptor *endpointDescriptor; |
| 129 | 132 | this->outPacketLength = 0; |
| 130 | 133 | this->inPacketLength = 0; |
| 131 | - for (int endpoint = 0; endpoint < interfaceDescriptor->bNumEndpoints; endpoint++) { | |
| 134 | + for (int endpoint = 0; endpoint < interfaceDescriptor->bNumEndpoints; ++endpoint) { | |
| 132 | 135 | endpointDescriptor = &interfaceDescriptor->endpoint[endpoint]; |
| 133 | 136 | switch(endpointDescriptor->bEndpointAddress) { |
| 134 | 137 | case HANTEK_EP_OUT: |
| ... | ... | @@ -163,7 +166,7 @@ namespace Hantek { |
| 163 | 166 | |
| 164 | 167 | // Iterate through all usb devices |
| 165 | 168 | this->model = MODEL_UNKNOWN; |
| 166 | - for(ssize_t deviceIterator = 0; deviceIterator < deviceCount; deviceIterator++) { | |
| 169 | + for(ssize_t deviceIterator = 0; deviceIterator < deviceCount; ++deviceIterator) { | |
| 167 | 170 | device = deviceList[deviceIterator]; |
| 168 | 171 | // Get device descriptor |
| 169 | 172 | if(libusb_get_device_descriptor(device, &(this->descriptor)) < 0) |
| ... | ... | @@ -188,7 +191,7 @@ namespace Hantek { |
| 188 | 191 | |
| 189 | 192 | // Search for the needed interface |
| 190 | 193 | libusb_get_config_descriptor(device, 0, &configDescriptor); |
| 191 | - for(int interfaceIndex = 0; interfaceIndex < (int) configDescriptor->bNumInterfaces; interfaceIndex++) { | |
| 194 | + for(int interfaceIndex = 0; interfaceIndex < (int) configDescriptor->bNumInterfaces; ++interfaceIndex) { | |
| 192 | 195 | interface = &configDescriptor->interface[interfaceIndex]; |
| 193 | 196 | if(interface->num_altsetting < 1) |
| 194 | 197 | continue; |
| ... | ... | @@ -209,7 +212,7 @@ namespace Hantek { |
| 209 | 212 | const libusb_endpoint_descriptor *endpointDescriptor; |
| 210 | 213 | this->outPacketLength = 0; |
| 211 | 214 | this->inPacketLength = 0; |
| 212 | - for (int endpoint = 0; endpoint < interfaceDescriptor->bNumEndpoints; endpoint++) { | |
| 215 | + for (int endpoint = 0; endpoint < interfaceDescriptor->bNumEndpoints; ++endpoint) { | |
| 213 | 216 | endpointDescriptor = &(interfaceDescriptor->endpoint[endpoint]); |
| 214 | 217 | switch(endpointDescriptor->bEndpointAddress) { |
| 215 | 218 | case HANTEK_EP_OUT: |
| ... | ... | @@ -285,7 +288,7 @@ namespace Hantek { |
| 285 | 288 | |
| 286 | 289 | int errorCode = LIBUSB_ERROR_TIMEOUT; |
| 287 | 290 | int transferred; |
| 288 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | |
| 291 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) | |
| 289 | 292 | errorCode = libusb_bulk_transfer(this->handle, endpoint, data, length, &transferred, HANTEK_TIMEOUT); |
| 290 | 293 | |
| 291 | 294 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) |
| ... | ... | @@ -312,7 +315,7 @@ namespace Hantek { |
| 312 | 315 | |
| 313 | 316 | #if LIBUSB_VERSION == 0 |
| 314 | 317 | errorCode = LIBUSB_ERROR_TIMEOUT; |
| 315 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | |
| 318 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) | |
| 316 | 319 | errorCode = usb_bulk_write(this->handle, HANTEK_EP_OUT, (char *) data, length, HANTEK_TIMEOUT); |
| 317 | 320 | |
| 318 | 321 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) |
| ... | ... | @@ -339,7 +342,7 @@ namespace Hantek { |
| 339 | 342 | |
| 340 | 343 | #if LIBUSB_VERSION == 0 |
| 341 | 344 | errorCode = LIBUSB_ERROR_TIMEOUT; |
| 342 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | |
| 345 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) | |
| 343 | 346 | errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data, length, HANTEK_TIMEOUT); |
| 344 | 347 | |
| 345 | 348 | if(errorCode == LIBUSB_ERROR_NO_DEVICE) |
| ... | ... | @@ -385,10 +388,10 @@ namespace Hantek { |
| 385 | 388 | |
| 386 | 389 | errorCode = this->inPacketLength; |
| 387 | 390 | unsigned int packet, received = 0; |
| 388 | - for(packet = 0; received < length && errorCode == this->inPacketLength; packet++) { | |
| 391 | + for(packet = 0; received < length && errorCode == this->inPacketLength; ++packet) { | |
| 389 | 392 | #if LIBUSB_VERSION == 0 |
| 390 | 393 | errorCode = LIBUSB_ERROR_TIMEOUT; |
| 391 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | |
| 394 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) | |
| 392 | 395 | errorCode = usb_bulk_read(this->handle, HANTEK_EP_IN, (char *) data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), HANTEK_TIMEOUT); |
| 393 | 396 | #else |
| 394 | 397 | errorCode = this->bulkTransfer(HANTEK_EP_IN, data + packet * this->inPacketLength, qMin(length - received, (unsigned int) this->inPacketLength), attempts); |
| ... | ... | @@ -417,7 +420,7 @@ namespace Hantek { |
| 417 | 420 | return LIBUSB_ERROR_NO_DEVICE; |
| 418 | 421 | |
| 419 | 422 | int errorCode = LIBUSB_ERROR_TIMEOUT; |
| 420 | - for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; attempt++) | |
| 423 | + for(int attempt = 0; (attempt < attempts || attempts == -1) && errorCode == LIBUSB_ERROR_TIMEOUT; ++attempt) | |
| 421 | 424 | #if LIBUSB_VERSION == 0 |
| 422 | 425 | errorCode = usb_control_msg(this->handle, type, request, value, index, (char *) data, length, HANTEK_TIMEOUT); |
| 423 | 426 | #else |
| ... | ... | @@ -441,7 +444,7 @@ namespace Hantek { |
| 441 | 444 | if(!this->handle) |
| 442 | 445 | return LIBUSB_ERROR_NO_DEVICE; |
| 443 | 446 | |
| 444 | - return this->controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT, request, data, length, value, index,attempts); | |
| 447 | + return this->controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT, request, data, length, value, index, attempts); | |
| 445 | 448 | } |
| 446 | 449 | |
| 447 | 450 | /// \brief Control read to the oscilloscope. | ... | ... |
openhantek/src/hantek/device.h
openhantek/src/helper.cpp
| ... | ... | @@ -151,7 +151,7 @@ namespace Helper { |
| 151 | 151 | QString hexDump(unsigned char *data, unsigned int length) { |
| 152 | 152 | QString dumpString, byteString; |
| 153 | 153 | |
| 154 | - for(unsigned int index = 0; index < length; index++) | |
| 154 | + for(unsigned int index = 0; index < length; ++index) | |
| 155 | 155 | dumpString.append(byteString.sprintf(" %02x", data[index])); |
| 156 | 156 | |
| 157 | 157 | return dumpString; |
| ... | ... | @@ -168,7 +168,7 @@ namespace Helper { |
| 168 | 168 | QString byteString; |
| 169 | 169 | unsigned int index; |
| 170 | 170 | |
| 171 | - for(index = 0; index < length; index++) { | |
| 171 | + for(index = 0; index < length; ++index) { | |
| 172 | 172 | byteString = dumpString.mid(index * 2, 2); |
| 173 | 173 | |
| 174 | 174 | // Check if we reached the end of the string | ... | ... |
openhantek/src/helper.h
| ... | ... | @@ -93,7 +93,7 @@ namespace Helper { |
| 93 | 93 | /// \param size Size of the data array. |
| 94 | 94 | template <class T> DataArray<T>::DataArray(unsigned int size) { |
| 95 | 95 | this->array = new T[size]; |
| 96 | - for(unsigned int index = 0; index < size; index++) | |
| 96 | + for(unsigned int index = 0; index < size; ++index) | |
| 97 | 97 | this->array[index] = 0; |
| 98 | 98 | this->size = size; |
| 99 | 99 | } | ... | ... |
openhantek/src/levelslider.cpp
| ... | ... | @@ -353,7 +353,7 @@ void LevelSlider::mousePressEvent(QMouseEvent *event) { |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | this->pressedSlider = -1; |
| 356 | - for(int sliderId = 0; sliderId < this->slider.count(); sliderId++) { | |
| 356 | + for(int sliderId = 0; sliderId < this->slider.count(); ++sliderId) { | |
| 357 | 357 | if(this->slider[sliderId]->visible && this->slider[sliderId]->rect.contains(event->pos())) { |
| 358 | 358 | this->pressedSlider = sliderId; |
| 359 | 359 | break; |
| ... | ... | @@ -400,7 +400,7 @@ void LevelSlider::paintEvent(QPaintEvent *event) { |
| 400 | 400 | |
| 401 | 401 | QList<LevelSliderParameters *>::iterator slider = this->slider.end(); |
| 402 | 402 | while(slider != this->slider.begin()) { |
| 403 | - slider--; | |
| 403 | + --slider; | |
| 404 | 404 | |
| 405 | 405 | if(!(*slider)->visible) |
| 406 | 406 | continue; |
| ... | ... | @@ -475,7 +475,7 @@ void LevelSlider::paintEvent(QPaintEvent *event) { |
| 475 | 475 | void LevelSlider::resizeEvent(QResizeEvent *event) { |
| 476 | 476 | Q_UNUSED(event); |
| 477 | 477 | |
| 478 | - for(int sliderId = 0; sliderId < this->slider.count(); sliderId++) | |
| 478 | + for(int sliderId = 0; sliderId < this->slider.count(); ++sliderId) | |
| 479 | 479 | this->calculateRect(sliderId); |
| 480 | 480 | |
| 481 | 481 | this->repaint(); | ... | ... |
openhantek/src/openhantek.cpp
| ... | ... | @@ -133,7 +133,7 @@ OpenHantekMainWindow::OpenHantekMainWindow(QWidget *parent, Qt::WindowFlags flag |
| 133 | 133 | // Set up the oscilloscope |
| 134 | 134 | this->dsoControl->connectDevice(); |
| 135 | 135 | |
| 136 | - for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; channel++) { | |
| 136 | + for(unsigned int channel = 0; channel < this->settings->scope.physicalChannels; ++channel) { | |
| 137 | 137 | this->dsoControl->setCoupling(channel, (Dso::Coupling) this->settings->scope.voltage[channel].misc); |
| 138 | 138 | this->updateVoltageGain(channel); |
| 139 | 139 | this->updateOffset(channel); |
| ... | ... | @@ -489,7 +489,7 @@ void OpenHantekMainWindow::applySettings() { |
| 489 | 489 | |
| 490 | 490 | QList<int> dockedWindows[2]; // Docks docked on the sides of the main window |
| 491 | 491 | |
| 492 | - for(int dockId = 0; dockId < docks.size(); dockId++) { | |
| 492 | + for(int dockId = 0; dockId < docks.size(); ++dockId) { | |
| 493 | 493 | docks[dockId]->setVisible(dockSettings[dockId]->visible); |
| 494 | 494 | if(!dockSettings[dockId]->position.isNull()) { |
| 495 | 495 | if(dockSettings[dockId]->floating) { |
| ... | ... | @@ -502,7 +502,7 @@ void OpenHantekMainWindow::applySettings() { |
| 502 | 502 | int side = (dockSettings[dockId]->position.x() < this->settings->options.window.size.width() / 2) ? 0 : 1; |
| 503 | 503 | int index = 0; |
| 504 | 504 | while(index < dockedWindows[side].size() && dockSettings[dockedWindows[side][index]]->position.y() <= dockSettings[dockId]->position.y()) |
| 505 | - index++; | |
| 505 | + ++index; | |
| 506 | 506 | dockedWindows[side].insert(index, dockId); |
| 507 | 507 | } |
| 508 | 508 | } |
| ... | ... | @@ -512,9 +512,9 @@ void OpenHantekMainWindow::applySettings() { |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | // Put the docked docking windows into the main window |
| 515 | - for(int position = 0; position < dockedWindows[0].size(); position++) | |
| 515 | + for(int position = 0; position < dockedWindows[0].size(); ++position) | |
| 516 | 516 | this->addDockWidget(Qt::LeftDockWidgetArea, docks[dockedWindows[0][position]]); |
| 517 | - for(int position = 0; position < dockedWindows[1].size(); position++) | |
| 517 | + for(int position = 0; position < dockedWindows[1].size(); ++position) | |
| 518 | 518 | this->addDockWidget(Qt::RightDockWidgetArea, docks[dockedWindows[1][position]]); |
| 519 | 519 | |
| 520 | 520 | // Toolbars |
| ... | ... | @@ -530,7 +530,7 @@ void OpenHantekMainWindow::applySettings() { |
| 530 | 530 | |
| 531 | 531 | QList<int> dockedToolbars; // Docks docked on the sides of the main window |
| 532 | 532 | |
| 533 | - for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { | |
| 533 | + for(int toolbarId = 0; toolbarId < toolbars.size(); ++toolbarId) { | |
| 534 | 534 | toolbars[toolbarId]->setVisible(toolbarSettings[toolbarId]->visible); |
| 535 | 535 | //toolbars[toolbarId]->setFloating(toolbarSettings[toolbarId]->floating); // setFloating missing, a bug in Qt? |
| 536 | 536 | if(!toolbarSettings[toolbarId]->position.isNull() && !toolbarSettings[toolbarId]->floating) { |
| ... | ... | @@ -541,7 +541,7 @@ void OpenHantekMainWindow::applySettings() { |
| 541 | 541 | // Check in which order the toolbars where placed |
| 542 | 542 | int index = 0; |
| 543 | 543 | while(index < dockedToolbars.size() && toolbarSettings[dockedToolbars[index]]->position.x() <= toolbarSettings[toolbarId]->position.x()) |
| 544 | - index++; | |
| 544 | + ++index; | |
| 545 | 545 | dockedToolbars.insert(index, toolbarId); |
| 546 | 546 | } |
| 547 | 547 | } |
| ... | ... | @@ -551,7 +551,7 @@ void OpenHantekMainWindow::applySettings() { |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | // Put the docked toolbars into the main window |
| 554 | - for(int position = 0; position < dockedToolbars.size(); position++) | |
| 554 | + for(int position = 0; position < dockedToolbars.size(); ++position) | |
| 555 | 555 | this->addToolBar(toolbars[dockedToolbars[position]]); |
| 556 | 556 | } |
| 557 | 557 | |
| ... | ... | @@ -574,7 +574,7 @@ void OpenHantekMainWindow::updateSettings() { |
| 574 | 574 | dockSettings.append(&(this->settings->options.window.dock.trigger)); |
| 575 | 575 | dockSettings.append(&(this->settings->options.window.dock.voltage)); |
| 576 | 576 | |
| 577 | - for(int dockId = 0; dockId < docks.size(); dockId++) { | |
| 577 | + for(int dockId = 0; dockId < docks.size(); ++dockId) { | |
| 578 | 578 | dockSettings[dockId]->floating = docks[dockId]->isFloating(); |
| 579 | 579 | dockSettings[dockId]->position = docks[dockId]->pos(); |
| 580 | 580 | dockSettings[dockId]->visible = docks[dockId]->isVisible(); |
| ... | ... | @@ -591,7 +591,7 @@ void OpenHantekMainWindow::updateSettings() { |
| 591 | 591 | toolbarSettings.append(&(this->settings->options.window.toolbar.oscilloscope)); |
| 592 | 592 | toolbarSettings.append(&(this->settings->options.window.toolbar.view)); |
| 593 | 593 | |
| 594 | - for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { | |
| 594 | + for(int toolbarId = 0; toolbarId < toolbars.size(); ++toolbarId) { | |
| 595 | 595 | toolbarSettings[toolbarId]->floating = toolbars[toolbarId]->isFloating(); |
| 596 | 596 | toolbarSettings[toolbarId]->position = toolbars[toolbarId]->pos(); |
| 597 | 597 | toolbarSettings[toolbarId]->visible = toolbars[toolbarId]->isVisible(); |
| ... | ... | @@ -636,7 +636,7 @@ void OpenHantekMainWindow::updateUsed(unsigned int channel) { |
| 636 | 636 | this->dsoControl->setChannelUsed(channel, mathUsed | this->settings->scope.voltage[channel].used | this->settings->scope.spectrum[channel].used); |
| 637 | 637 | // Math channel, update all channels |
| 638 | 638 | else if(channel == this->settings->scope.physicalChannels) { |
| 639 | - for(unsigned int channelCounter = 0; channelCounter < this->settings->scope.physicalChannels; channelCounter++) | |
| 639 | + for(unsigned int channelCounter = 0; channelCounter < this->settings->scope.physicalChannels; ++channelCounter) | |
| 640 | 640 | this->dsoControl->setChannelUsed(channelCounter, mathUsed | this->settings->scope.voltage[channelCounter].used | this->settings->scope.spectrum[channelCounter].used); |
| 641 | 641 | } |
| 642 | 642 | } | ... | ... |
openhantek/src/settings.cpp
| ... | ... | @@ -51,7 +51,7 @@ DsoSettings::DsoSettings(QWidget *parent) : QObject(parent) { |
| 51 | 51 | panels.append(&(this->options.window.toolbar.file)); |
| 52 | 52 | panels.append(&(this->options.window.toolbar.oscilloscope)); |
| 53 | 53 | panels.append(&(this->options.window.toolbar.view)); |
| 54 | - for(int panelId = 0; panelId < panels.size(); panelId++) { | |
| 54 | + for(int panelId = 0; panelId < panels.size(); ++panelId) { | |
| 55 | 55 | panels[panelId]->floating = false; |
| 56 | 56 | panels[panelId]->position = QPoint(); |
| 57 | 57 | panels[panelId]->visible = true; |
| ... | ... | @@ -126,7 +126,7 @@ void DsoSettings::setChannelCount(unsigned int channels) { |
| 126 | 126 | this->scope.spectrum.removeAt(channel); |
| 127 | 127 | |
| 128 | 128 | // Add new channels to the list |
| 129 | - for(int channel = 0; channel < (int) channels; channel++) { | |
| 129 | + for(int channel = 0; channel < (int) channels; ++channel) { | |
| 130 | 130 | // Oscilloscope settings |
| 131 | 131 | // Spectrum |
| 132 | 132 | if(this->scope.spectrum.count() <= channel + 1) { |
| ... | ... | @@ -218,7 +218,7 @@ int DsoSettings::load(const QString &fileName) { |
| 218 | 218 | docks.append(&(this->options.window.dock.voltage)); |
| 219 | 219 | QStringList dockNames; |
| 220 | 220 | dockNames << "horizontal" << "spectrum" << "trigger" << "voltage"; |
| 221 | - for(int dockId = 0; dockId < docks.size(); dockId++) { | |
| 221 | + for(int dockId = 0; dockId < docks.size(); ++dockId) { | |
| 222 | 222 | settingsLoader->beginGroup(dockNames[dockId]); |
| 223 | 223 | if(settingsLoader->contains("floating")) |
| 224 | 224 | docks[dockId]->floating = settingsLoader->value("floating").toBool(); |
| ... | ... | @@ -236,7 +236,7 @@ int DsoSettings::load(const QString &fileName) { |
| 236 | 236 | toolbars.append(&(this->options.window.toolbar.view)); |
| 237 | 237 | QStringList toolbarNames; |
| 238 | 238 | toolbarNames << "file" << "oscilloscope" << "view"; |
| 239 | - for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { | |
| 239 | + for(int toolbarId = 0; toolbarId < toolbars.size(); ++toolbarId) { | |
| 240 | 240 | settingsLoader->beginGroup(toolbarNames[toolbarId]); |
| 241 | 241 | if(settingsLoader->contains("floating")) |
| 242 | 242 | toolbars[toolbarId]->floating = settingsLoader->value("floating").toBool(); |
| ... | ... | @@ -268,7 +268,7 @@ int DsoSettings::load(const QString &fileName) { |
| 268 | 268 | this->scope.horizontal.format = (Dso::GraphFormat) settingsLoader->value("format").toInt(); |
| 269 | 269 | if(settingsLoader->contains("frequencybase")) |
| 270 | 270 | this->scope.horizontal.frequencybase = settingsLoader->value("frequencybase").toDouble(); |
| 271 | - for(int marker = 0; marker < 2; marker++) { | |
| 271 | + for(int marker = 0; marker < 2; ++marker) { | |
| 272 | 272 | QString name; |
| 273 | 273 | name = QString("marker%1").arg(marker); |
| 274 | 274 | if(settingsLoader->contains(name)) |
| ... | ... | @@ -293,7 +293,7 @@ int DsoSettings::load(const QString &fileName) { |
| 293 | 293 | this->scope.trigger.special = settingsLoader->value("special").toInt(); |
| 294 | 294 | settingsLoader->endGroup(); |
| 295 | 295 | // Spectrum |
| 296 | - for(int channel = 0; channel < this->scope.spectrum.count(); channel++) { | |
| 296 | + for(int channel = 0; channel < this->scope.spectrum.count(); ++channel) { | |
| 297 | 297 | settingsLoader->beginGroup(QString("spectrum%1").arg(channel)); |
| 298 | 298 | if(settingsLoader->contains("magnitude")) |
| 299 | 299 | this->scope.spectrum[channel].magnitude = settingsLoader->value("magnitude").toDouble(); |
| ... | ... | @@ -304,7 +304,7 @@ int DsoSettings::load(const QString &fileName) { |
| 304 | 304 | settingsLoader->endGroup(); |
| 305 | 305 | } |
| 306 | 306 | // Vertical axis |
| 307 | - for(int channel = 0; channel < this->scope.voltage.count(); channel++) { | |
| 307 | + for(int channel = 0; channel < this->scope.voltage.count(); ++channel) { | |
| 308 | 308 | settingsLoader->beginGroup(QString("vertical%1").arg(channel)); |
| 309 | 309 | if(settingsLoader->contains("gain")) |
| 310 | 310 | this->scope.voltage[channel].gain = settingsLoader->value("gain").toDouble(); |
| ... | ... | @@ -331,7 +331,7 @@ int DsoSettings::load(const QString &fileName) { |
| 331 | 331 | // Colors |
| 332 | 332 | settingsLoader->beginGroup("color"); |
| 333 | 333 | DsoSettingsColorValues *colors; |
| 334 | - for(int mode = 0; mode < 2; mode++) { | |
| 334 | + for(int mode = 0; mode < 2; ++mode) { | |
| 335 | 335 | if(mode == 0) { |
| 336 | 336 | colors = &this->view.color.screen; |
| 337 | 337 | settingsLoader->beginGroup("screen"); |
| ... | ... | @@ -351,14 +351,14 @@ int DsoSettings::load(const QString &fileName) { |
| 351 | 351 | colors->grid = settingsLoader->value("grid").value<QColor>(); |
| 352 | 352 | if(settingsLoader->contains("markers")) |
| 353 | 353 | colors->markers = settingsLoader->value("markers").value<QColor>(); |
| 354 | - for(int channel = 0; channel < this->scope.spectrum.count(); channel++) { | |
| 354 | + for(int channel = 0; channel < this->scope.spectrum.count(); ++channel) { | |
| 355 | 355 | QString key = QString("spectrum%1").arg(channel); |
| 356 | 356 | if(settingsLoader->contains(key)) |
| 357 | 357 | colors->spectrum[channel] = settingsLoader->value(key).value<QColor>(); |
| 358 | 358 | } |
| 359 | 359 | if(settingsLoader->contains("text")) |
| 360 | 360 | colors->text = settingsLoader->value("text").value<QColor>(); |
| 361 | - for(int channel = 0; channel < this->scope.voltage.count(); channel++) { | |
| 361 | + for(int channel = 0; channel < this->scope.voltage.count(); ++channel) { | |
| 362 | 362 | QString key = QString("voltage%1").arg(channel); |
| 363 | 363 | if(settingsLoader->contains(key)) |
| 364 | 364 | colors->voltage[channel] = settingsLoader->value(key).value<QColor>(); |
| ... | ... | @@ -409,7 +409,7 @@ int DsoSettings::save(const QString &fileName) { |
| 409 | 409 | docks.append(&(this->options.window.dock.voltage)); |
| 410 | 410 | QStringList dockNames; |
| 411 | 411 | dockNames << "horizontal" << "spectrum" << "trigger" << "voltage"; |
| 412 | - for(int dockId = 0; dockId < docks.size(); dockId++) { | |
| 412 | + for(int dockId = 0; dockId < docks.size(); ++dockId) { | |
| 413 | 413 | settingsSaver->beginGroup(dockNames[dockId]); |
| 414 | 414 | settingsSaver->setValue("floating", docks[dockId]->floating); |
| 415 | 415 | settingsSaver->setValue("position", docks[dockId]->position); |
| ... | ... | @@ -424,7 +424,7 @@ int DsoSettings::save(const QString &fileName) { |
| 424 | 424 | toolbars.append(&(this->options.window.toolbar.view)); |
| 425 | 425 | QStringList toolbarNames; |
| 426 | 426 | toolbarNames << "file" << "oscilloscope" << "view"; |
| 427 | - for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { | |
| 427 | + for(int toolbarId = 0; toolbarId < toolbars.size(); ++toolbarId) { | |
| 428 | 428 | settingsSaver->beginGroup(toolbarNames[toolbarId]); |
| 429 | 429 | settingsSaver->setValue("floating", toolbars[toolbarId]->floating); |
| 430 | 430 | settingsSaver->setValue("position", toolbars[toolbarId]->position); |
| ... | ... | @@ -446,7 +446,7 @@ int DsoSettings::save(const QString &fileName) { |
| 446 | 446 | settingsSaver->beginGroup("horizontal"); |
| 447 | 447 | settingsSaver->setValue("format", this->scope.horizontal.format); |
| 448 | 448 | settingsSaver->setValue("frequencybase", this->scope.horizontal.frequencybase); |
| 449 | - for(int marker = 0; marker < 2; marker++) | |
| 449 | + for(int marker = 0; marker < 2; ++marker) | |
| 450 | 450 | settingsSaver->setValue(QString("marker%1").arg(marker), this->scope.horizontal.marker[marker]); |
| 451 | 451 | settingsSaver->setValue("timebase", this->scope.horizontal.timebase); |
| 452 | 452 | settingsSaver->endGroup(); |
| ... | ... | @@ -459,7 +459,7 @@ int DsoSettings::save(const QString &fileName) { |
| 459 | 459 | settingsSaver->setValue("source", this->scope.trigger.source); |
| 460 | 460 | settingsSaver->endGroup(); |
| 461 | 461 | // Spectrum |
| 462 | - for(int channel = 0; channel < this->scope.spectrum.count(); channel++) { | |
| 462 | + for(int channel = 0; channel < this->scope.spectrum.count(); ++channel) { | |
| 463 | 463 | settingsSaver->beginGroup(QString("spectrum%1").arg(channel)); |
| 464 | 464 | settingsSaver->setValue("magnitude", this->scope.spectrum[channel].magnitude); |
| 465 | 465 | settingsSaver->setValue("offset", this->scope.spectrum[channel].offset); |
| ... | ... | @@ -467,7 +467,7 @@ int DsoSettings::save(const QString &fileName) { |
| 467 | 467 | settingsSaver->endGroup(); |
| 468 | 468 | } |
| 469 | 469 | // Vertical axis |
| 470 | - for(int channel = 0; channel < this->scope.voltage.count(); channel++) { | |
| 470 | + for(int channel = 0; channel < this->scope.voltage.count(); ++channel) { | |
| 471 | 471 | settingsSaver->beginGroup(QString("vertical%1").arg(channel)); |
| 472 | 472 | settingsSaver->setValue("gain", this->scope.voltage[channel].gain); |
| 473 | 473 | settingsSaver->setValue("misc", this->scope.voltage[channel].misc); |
| ... | ... | @@ -487,7 +487,7 @@ int DsoSettings::save(const QString &fileName) { |
| 487 | 487 | if(complete) { |
| 488 | 488 | settingsSaver->beginGroup("color"); |
| 489 | 489 | DsoSettingsColorValues *colors; |
| 490 | - for(int mode = 0; mode < 2; mode++) { | |
| 490 | + for(int mode = 0; mode < 2; ++mode) { | |
| 491 | 491 | if(mode == 0) { |
| 492 | 492 | colors = &this->view.color.screen; |
| 493 | 493 | settingsSaver->beginGroup("screen"); |
| ... | ... | @@ -502,10 +502,10 @@ int DsoSettings::save(const QString &fileName) { |
| 502 | 502 | settingsSaver->setValue("border", colors->border); |
| 503 | 503 | settingsSaver->setValue("grid", colors->grid); |
| 504 | 504 | settingsSaver->setValue("markers", colors->markers); |
| 505 | - for(int channel = 0; channel < this->scope.spectrum.count(); channel++) | |
| 505 | + for(int channel = 0; channel < this->scope.spectrum.count(); ++channel) | |
| 506 | 506 | settingsSaver->setValue(QString("spectrum%1").arg(channel), colors->spectrum[channel]); |
| 507 | 507 | settingsSaver->setValue("text", colors->text); |
| 508 | - for(int channel = 0; channel < this->scope.voltage.count(); channel++) | |
| 508 | + for(int channel = 0; channel < this->scope.voltage.count(); ++channel) | |
| 509 | 509 | settingsSaver->setValue(QString("voltage%1").arg(channel), colors->voltage[channel]); |
| 510 | 510 | settingsSaver->endGroup(); |
| 511 | 511 | } | ... | ... |