Skip to content

Commit 2b262af

Browse files
committed
fix: suppress resampling and background file loading errors on startup
1 parent 918bd04 commit 2b262af

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

octproz_project/octproz/src/octalgorithmparametersmanager.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,31 @@ bool OctAlgorithmParametersManager::saveCurveToFile(QString fileName, int nSampl
4545
}
4646

4747

48-
void OctAlgorithmParametersManager::loadPostProcessBackgroundFromFile(QString fileName) {
48+
void OctAlgorithmParametersManager::loadPostProcessBackgroundFromFile(QString fileName, bool suppressErrors) {
4949
QVector<float> curve = this->loadCurveFromFile(fileName);
5050
if(curve.size() > 0){
5151
this->octParams->loadPostProcessingBackground(curve.data(), curve.size());
5252
//this->sidebar->updateBackgroundPlot();
5353
emit backgroundDataUpdated();
5454
emit info(tr("Background data for post processing loaded. File used: ") + fileName);
5555
}else{
56-
emit error(tr("Background data has a size of 0. Check if the .csv file with background data is not empty and has the right format."));
56+
if(!suppressErrors){
57+
emit error(tr("Background data has a size of 0. Check if the .csv file with background data is not empty and has the right format."));
58+
}
5759
}
5860
}
5961

60-
void OctAlgorithmParametersManager::loadCustomResamplingCurveFromFile(QString fileName) {
62+
void OctAlgorithmParametersManager::loadCustomResamplingCurveFromFile(QString fileName, bool suppressErrors) {
6163
QVector<float> curve = this->loadCurveFromFile(fileName);
6264
if(curve.size() > 0){
6365
this->octParams->loadCustomResampleCurve(curve.data(), curve.size());
6466
this->octParams->customResampleCurveFilePath = fileName;
6567
emit resamplingCurveUpdated();
6668
emit info(tr("Resampling curve loaded. File used: ") + fileName);
6769
}else{
68-
emit error(tr("Resampling curve has a size of 0. Check if the .csv file with resampling curve data is not empty and has the right format."));
70+
if(!suppressErrors){
71+
emit error(tr("Resampling curve has a size of 0. Check if the .csv file with resampling curve data is not empty and has the right format."));
72+
}
6973
}
7074
}
7175

octproz_project/octproz/src/octalgorithmparametersmanager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class OctAlgorithmParametersManager : public QObject
2121

2222

2323
public slots:
24-
void loadPostProcessBackgroundFromFile(QString fileName);
25-
void loadCustomResamplingCurveFromFile(QString fileName);
24+
void loadPostProcessBackgroundFromFile(QString fileName, bool suppressErrors = false);
25+
void loadCustomResamplingCurveFromFile(QString fileName, bool suppressErrors = false);
2626
void savePostProcessBackgroundToFile(QString fileName);
2727
void saveCustomResamplingCurveToFile(QString fileName);
2828

octproz_project/octproz/src/sidebar.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ void Sidebar::loadSettings() {
202202
OctAlgorithmParameters::getInstance()->useCustomResampleCurve = this->processingSettings.value(PROC_CUSTOM_RESAMPLING).toBool(); //todo: move all actions for klin from octproz to sidebar
203203
QString customResamplingFilePath = this->processingSettings.value(PROC_CUSTOM_RESAMPLING_FILEPATH).toString();
204204
if (customResamplingFilePath.isEmpty() || !QFile::exists(customResamplingFilePath)) {
205-
emit loadResamplingCurveRequested(SETTINGS_PATH_RESAMPLING_FILE);
205+
emit loadResamplingCurveRequested(SETTINGS_PATH_RESAMPLING_FILE, true);
206206
} else {
207-
emit loadResamplingCurveRequested(customResamplingFilePath);
207+
emit loadResamplingCurveRequested(customResamplingFilePath, true);
208208
}
209209
this->ui.groupBox_dispersionCompensation->setChecked(this->processingSettings.value(PROC_DISPERSION_COMPENSATION).toBool());
210210
this->ui.doubleSpinBox_d0->setValue(this->processingSettings.value(PROC_DISPERSION_COMPENSATION_D0).toDouble());
@@ -222,7 +222,7 @@ void Sidebar::loadSettings() {
222222
this->ui.groupBox_postProcessBackgroundRemoval->setChecked(this->processingSettings.value(PROC_POST_BACKGROUND_REMOVAL).toBool());
223223
this->ui.doubleSpinBox_postProcessBackgroundWeight->setValue(this->processingSettings.value(PROC_POST_BACKGROUND_WEIGHT).toDouble());
224224
this->ui.doubleSpinBox_postProcessBackgroundOffset->setValue(this->processingSettings.value(PROC_POST_BACKGROUND_OFFSET).toDouble());
225-
emit loadPostProcessBackgroundRequested(SETTINGS_PATH_BACKGROUND_FILE);
225+
emit loadPostProcessBackgroundRequested(SETTINGS_PATH_BACKGROUND_FILE, true);
226226

227227
//GPU to RAM Streaming
228228
this->ui.groupBox_streaming->setChecked(this->streamingSettings.value(STREAM_STREAMING).toBool());
@@ -498,7 +498,7 @@ void Sidebar::slot_loadPostProcessingBackground() {
498498
QString savedPath = this->recordSettings.value(REC_PATH).toString();
499499
QString standardLocation = savedPath.size() == 0 ? QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) : savedPath;
500500
fileName = QFileDialog::getOpenFileName(this, tr("Load background data"), QDir::currentPath(), filters, &defaultFilter);
501-
emit loadPostProcessBackgroundRequested(fileName);
501+
emit loadPostProcessBackgroundRequested(fileName, false);
502502
emit dialogClosed();
503503
}
504504

octproz_project/octproz/src/sidebar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ public slots:
179179
void klinCoeffs(double k0, double k1, double k2, double k3);
180180
void dispCompCoeffs(double d0, double d1, double d2, double d3);
181181
void savePostProcessBackgroundRequested(QString fileName);
182-
void loadPostProcessBackgroundRequested(QString fileName);
182+
void loadPostProcessBackgroundRequested(QString fileName, bool suppressErrors);
183183
void saveResamplingCurveRequested(QString fileName);
184-
void loadResamplingCurveRequested(QString fileName);
184+
void loadResamplingCurveRequested(QString fileName, bool suppressErrors);
185185
void error(QString);
186186
void info(QString);
187187
};

0 commit comments

Comments
 (0)