From bb800ecdc8084dfb7bc614c9ec2aba7c4f94e0f7 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 15:25:32 +0200 Subject: [PATCH 01/17] ditto for std::string --- Base/Utils/FileSystemUtils.cpp | 2 +- GUI/coregui/mainwindow/PyImportAssistant.cpp | 2 +- Tests/UnitTests/Core/Parameters/RealParameterTest.cpp | 2 +- Tests/UnitTests/GUI/TestCsvImportData.cpp | 2 +- gui2/dataloader/parserpropertywidget.cpp | 4 ++-- gui2/model/materialitems.cpp | 2 +- gui2/model/materialmodel.h | 2 +- mvvm/model/mvvm/model/comboproperty.cpp | 2 +- mvvm/model/mvvm/model/path.cpp | 2 +- mvvm/model/mvvm/model/sessionitem.cpp | 4 ++-- mvvm/model/mvvm/project/project_types.h | 4 ++-- mvvm/model/mvvm/project/projectmanager.cpp | 2 +- mvvm/model/mvvm/standarditems/linkeditem.cpp | 2 +- mvvm/tests/testmodel/fileutils.test.cpp | 2 +- mvvm/tests/testmodel/itemconverterfactory.test.cpp | 2 +- mvvm/tests/testmodel/linkeditem.test.cpp | 4 ++-- mvvm/tests/testmodel/sessionitem.test.cpp | 2 +- mvvm/tests/testmodel/stringutils.test.cpp | 4 ++-- mvvm/tests/testmodel/taginfo.test.cpp | 2 +- mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp | 2 +- 20 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Base/Utils/FileSystemUtils.cpp b/Base/Utils/FileSystemUtils.cpp index 405984a75d6..a03f8dd904c 100644 --- a/Base/Utils/FileSystemUtils.cpp +++ b/Base/Utils/FileSystemUtils.cpp @@ -34,7 +34,7 @@ std::string FileSystemUtils::extensions(const std::string& path) return {}; const auto pos = name.find_first_of('.', 1); // 1: ignore any file-is-hidden dot - return pos != std::string::npos ? name.substr(pos, name.size() - pos) : std::string(); + return pos != std::string::npos ? name.substr(pos, name.size() - pos) : ""; } bool FileSystemUtils::createDirectory(const std::string& dir_name) diff --git a/GUI/coregui/mainwindow/PyImportAssistant.cpp b/GUI/coregui/mainwindow/PyImportAssistant.cpp index fcc45fe7a8d..d625859c113 100644 --- a/GUI/coregui/mainwindow/PyImportAssistant.cpp +++ b/GUI/coregui/mainwindow/PyImportAssistant.cpp @@ -40,7 +40,7 @@ namespace { std::string bornagainDir() { std::string pythonPath = SysUtils::getenv("PYTHONPATH"); - return pythonPath.empty() ? BABuild::buildLibDir() : std::string(); + return pythonPath.empty() ? BABuild::buildLibDir() : ""; } //! Returns a name from the list which looks like a function name intended for sample diff --git a/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp b/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp index 48bce878a1d..c23795bc494 100644 --- a/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp +++ b/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp @@ -13,7 +13,7 @@ TEST_F(RealParameterTest, simpleConstructor) std::unique_ptr<RealParameter> par(new RealParameter("name", &value)); EXPECT_EQ(par->value(), value); EXPECT_EQ(par->limits(), RealLimits::limitless()); - EXPECT_EQ(par->unit(), std::string()); + EXPECT_EQ(par->unit(), ""); EXPECT_EQ(&value, &par->getData()); EXPECT_FALSE(par->isNull()); } diff --git a/Tests/UnitTests/GUI/TestCsvImportData.cpp b/Tests/UnitTests/GUI/TestCsvImportData.cpp index 074e79252dd..734864f8013 100644 --- a/Tests/UnitTests/GUI/TestCsvImportData.cpp +++ b/Tests/UnitTests/GUI/TestCsvImportData.cpp @@ -120,7 +120,7 @@ TEST_F(TestCsvImportData, test_labels) model.setColumnAs(0, csv::_intensity_); EXPECT_EQ(model.columnLabel(CsvImportData::Intensity).toStdString(), "Intensity"); - EXPECT_EQ(model.columnLabel(CsvImportData::Coordinate).toStdString(), std::string()); + EXPECT_EQ(model.columnLabel(CsvImportData::Coordinate).toStdString(), ""); } TEST_F(TestCsvImportData, test_format_check) diff --git a/gui2/dataloader/parserpropertywidget.cpp b/gui2/dataloader/parserpropertywidget.cpp index 57058807708..11b20963e1e 100644 --- a/gui2/dataloader/parserpropertywidget.cpp +++ b/gui2/dataloader/parserpropertywidget.cpp @@ -252,7 +252,7 @@ void ParserPropertyWidget::addIgnoreStringPatternRow(QGridLayout* layout) startingWithRadio->setToolTip("Ignore lines starting with a given character(s)"); auto on_startingfrom_radio = [this, startingFromLineEdit](auto checked) { m_options.m_header_prefix = - checked ? startingFromLineEdit->text().toStdString() : std::string(); + checked ? startingFromLineEdit->text().toStdString() : ""; onParserPropertyChange(); }; connect(startingWithRadio, &QRadioButton::clicked, on_startingfrom_radio); @@ -287,7 +287,7 @@ void ParserPropertyWidget::addIgnoreNumbersPatternRow(QGridLayout* layout) lineNumbersRadio->setToolTip("Ignore lines with line numbers matching the pattern"); auto on_linenumbers_radio = [this, lineNumbersLineEdit](auto checked) { m_options.m_skip_index_pattern = - checked ? lineNumbersLineEdit->text().toStdString() : std::string(); + checked ? lineNumbersLineEdit->text().toStdString() : ""; onParserPropertyChange(); }; connect(lineNumbersRadio, &QRadioButton::clicked, on_linenumbers_radio); diff --git a/gui2/model/materialitems.cpp b/gui2/model/materialitems.cpp index d6a527b3e96..aa2959953dd 100644 --- a/gui2/model/materialitems.cpp +++ b/gui2/model/materialitems.cpp @@ -43,7 +43,7 @@ MaterialBaseItem::MaterialBaseItem(const std::string& model_type) ModelView::ExternalProperty MaterialBaseItem::external_property() const { QColor color = Utils::HasTag(*this, P_COLOR) ? property<QColor>(P_COLOR) : QColor(Qt::red); - std::string name = Utils::HasTag(*this, P_NAME) ? property<std::string>(P_NAME) : std::string(); + std::string name = Utils::HasTag(*this, P_NAME) ? property<std::string>(P_NAME) : ""; return ModelView::ExternalProperty(name, color, identifier()); } diff --git a/gui2/model/materialmodel.h b/gui2/model/materialmodel.h index 8e544812595..1d07fea591e 100644 --- a/gui2/model/materialmodel.h +++ b/gui2/model/materialmodel.h @@ -37,7 +37,7 @@ public: MaterialModel(std::shared_ptr<ModelView::ItemPool> pool = {}); std::vector<ModelView::ExternalProperty> - material_data(std::string container_id = std::string()) const; + material_data(std::string container_id = "") const; ModelView::ExternalProperty material_property(const std::string& id); diff --git a/mvvm/model/mvvm/model/comboproperty.cpp b/mvvm/model/mvvm/model/comboproperty.cpp index f68601c752e..33ee40a0e82 100644 --- a/mvvm/model/mvvm/model/comboproperty.cpp +++ b/mvvm/model/mvvm/model/comboproperty.cpp @@ -73,7 +73,7 @@ ComboProperty ComboProperty::createFrom(const std::vector<std::string>& values, std::string ComboProperty::value() const { - return currentIndex() < 0 ? std::string() : m_values.at(static_cast<size_t>(currentIndex())); + return currentIndex() < 0 ? "" : m_values.at(static_cast<size_t>(currentIndex())); } void ComboProperty::setValue(const std::string& name) diff --git a/mvvm/model/mvvm/model/path.cpp b/mvvm/model/mvvm/model/path.cpp index 4e284eb5939..71877a77d89 100644 --- a/mvvm/model/mvvm/model/path.cpp +++ b/mvvm/model/mvvm/model/path.cpp @@ -49,7 +49,7 @@ Path Path::fromVector(const std::vector<int>& data) std::string Path::str() const { auto comma_fold = [](std::string a, int b) { return std::move(a) + ',' + std::to_string(b); }; - return m_data.empty() ? std::string() + return m_data.empty() ? "" : std::accumulate(std::next(m_data.begin()), m_data.end(), std::to_string(m_data[0]), comma_fold); } diff --git a/mvvm/model/mvvm/model/sessionitem.cpp b/mvvm/model/mvvm/model/sessionitem.cpp index 65c4fd39ca9..67df28af94f 100644 --- a/mvvm/model/mvvm/model/sessionitem.cpp +++ b/mvvm/model/mvvm/model/sessionitem.cpp @@ -298,7 +298,7 @@ SessionItem* SessionItem::setEnabled(bool value) std::string SessionItem::toolTip() const { return hasData(ItemDataRole::TOOLTIP) ? data<std::string>(ItemDataRole::TOOLTIP) - : std::string(); + : ""; } //! Sets item tooltip (fluent interface). @@ -314,7 +314,7 @@ SessionItem* SessionItem::setToolTip(const std::string& tooltip) std::string SessionItem::editorType() const { return hasData(ItemDataRole::EDITORTYPE) ? data<std::string>(ItemDataRole::EDITORTYPE) - : std::string(); + : ""; } //! Sets editor type (fluent interface). diff --git a/mvvm/model/mvvm/project/project_types.h b/mvvm/model/mvvm/project/project_types.h index deded57d06f..4f7f3bf0c53 100644 --- a/mvvm/model/mvvm/project/project_types.h +++ b/mvvm/model/mvvm/project/project_types.h @@ -47,10 +47,10 @@ struct MVVM_MODEL_EXPORT ProjectContext { struct MVVM_MODEL_EXPORT UserInteractionContext { //!< To ask the user to select existing directory, returns full path to the directory. - using select_dir_callback_t = std::function<std::string()>; + using select_dir_callback_t = std::function<"">; //!< To ask the user to create a new directory, returns full path to the directory. - using create_dir_callback_t = std::function<std::string()>; + using create_dir_callback_t = std::function<"">; //!< To ask the user what to do with modified project. using answer_callback_t = std::function<SaveChangesAnswer()>; diff --git a/mvvm/model/mvvm/project/projectmanager.cpp b/mvvm/model/mvvm/project/projectmanager.cpp index 5b126f7d06f..6d841c4a7b1 100644 --- a/mvvm/model/mvvm/project/projectmanager.cpp +++ b/mvvm/model/mvvm/project/projectmanager.cpp @@ -111,7 +111,7 @@ bool ProjectManager::openExistingProject(const std::string& dirname) std::string ProjectManager::currentProjectDir() const { - return p_impl->m_current_project ? p_impl->m_current_project->projectDir() : std::string(); + return p_impl->m_current_project ? p_impl->m_current_project->projectDir() : ""; } //! Returns true if project was modified since last save. diff --git a/mvvm/model/mvvm/standarditems/linkeditem.cpp b/mvvm/model/mvvm/standarditems/linkeditem.cpp index f6c9d76025b..a2644f944f5 100644 --- a/mvvm/model/mvvm/standarditems/linkeditem.cpp +++ b/mvvm/model/mvvm/standarditems/linkeditem.cpp @@ -18,7 +18,7 @@ using namespace ModelView; namespace { -const Variant empty_link = Variant::fromValue(std::string()); +const Variant empty_link = Variant::fromValue(""); } LinkedItem::LinkedItem() : SessionItem(Constants::LinkedItemType) diff --git a/mvvm/tests/testmodel/fileutils.test.cpp b/mvvm/tests/testmodel/fileutils.test.cpp index 2ba7ccccc36..09e4fac3968 100644 --- a/mvvm/tests/testmodel/fileutils.test.cpp +++ b/mvvm/tests/testmodel/fileutils.test.cpp @@ -33,7 +33,7 @@ FileUtilsTest::~FileUtilsTest() = default; TEST_F(FileUtilsTest, exists) { EXPECT_TRUE(Utils::exists(testPath())); - EXPECT_FALSE(Utils::exists(std::string())); + EXPECT_FALSE(Utils::exists("")); EXPECT_FALSE(Utils::exists(std::string("abc"))); } diff --git a/mvvm/tests/testmodel/itemconverterfactory.test.cpp b/mvvm/tests/testmodel/itemconverterfactory.test.cpp index cdb2f948849..f7d8c918f9c 100644 --- a/mvvm/tests/testmodel/itemconverterfactory.test.cpp +++ b/mvvm/tests/testmodel/itemconverterfactory.test.cpp @@ -108,7 +108,7 @@ TEST_F(ItemConverterFactoryTest, propertyItemProjectConverter) EXPECT_EQ(reco->modelType(), item.modelType()); EXPECT_EQ(reco->displayName(), item.displayName()); - EXPECT_EQ(reco->toolTip(), std::string()); // tooltips are not preserved + EXPECT_EQ(reco->toolTip(), ""); // tooltips are not preserved EXPECT_TRUE(reco->identifier() == item.identifier()); // identifier preserved } diff --git a/mvvm/tests/testmodel/linkeditem.test.cpp b/mvvm/tests/testmodel/linkeditem.test.cpp index 45b7c490816..3cfbaa8a34b 100644 --- a/mvvm/tests/testmodel/linkeditem.test.cpp +++ b/mvvm/tests/testmodel/linkeditem.test.cpp @@ -37,7 +37,7 @@ TEST_F(LinkedItemTest, initialState) { LinkedItem item; EXPECT_EQ(item.get(), nullptr); - EXPECT_EQ(item.data<std::string>(), std::string()); + EXPECT_EQ(item.data<std::string>(), ""); } //! Link in single model context. @@ -124,5 +124,5 @@ TEST_F(LinkedItemTest, setNullAsLink) link->setLink(nullptr); EXPECT_EQ(link->get(), nullptr); EXPECT_TRUE(link->data<QVariant>().isValid()); - EXPECT_EQ(link->data<std::string>(), std::string()); + EXPECT_EQ(link->data<std::string>(), ""); } diff --git a/mvvm/tests/testmodel/sessionitem.test.cpp b/mvvm/tests/testmodel/sessionitem.test.cpp index 84ee22a14f2..8b909a68596 100644 --- a/mvvm/tests/testmodel/sessionitem.test.cpp +++ b/mvvm/tests/testmodel/sessionitem.test.cpp @@ -228,7 +228,7 @@ TEST_F(SessionItemTest, registerItem) TEST_F(SessionItemTest, defaultTag) { SessionItem item; - EXPECT_EQ(item.itemTags()->defaultTag(), std::string()); + EXPECT_EQ(item.itemTags()->defaultTag(), ""); EXPECT_FALSE(Utils::HasTag(item, "defaultTag")); } diff --git a/mvvm/tests/testmodel/stringutils.test.cpp b/mvvm/tests/testmodel/stringutils.test.cpp index 18dd6120e81..e45ab06702e 100644 --- a/mvvm/tests/testmodel/stringutils.test.cpp +++ b/mvvm/tests/testmodel/stringutils.test.cpp @@ -51,8 +51,8 @@ TEST_F(StringUtilsTest, DoubleToString) TEST_F(StringUtilsTest, TrimWhiteSpace) { using Utils::TrimWhitespace; - EXPECT_EQ(TrimWhitespace(""), std::string()); - EXPECT_EQ(TrimWhitespace(" "), std::string()); + EXPECT_EQ(TrimWhitespace(""), ""); + EXPECT_EQ(TrimWhitespace(" "), ""); EXPECT_EQ(TrimWhitespace("abc"), std::string("abc")); EXPECT_EQ(TrimWhitespace(" \t\n abc cde\n"), std::string("abc cde")); } diff --git a/mvvm/tests/testmodel/taginfo.test.cpp b/mvvm/tests/testmodel/taginfo.test.cpp index a30cf0251aa..5a530244f6a 100644 --- a/mvvm/tests/testmodel/taginfo.test.cpp +++ b/mvvm/tests/testmodel/taginfo.test.cpp @@ -29,7 +29,7 @@ TagInfoTest::~TagInfoTest() = default; TEST_F(TagInfoTest, initialState) { TagInfo tag; - EXPECT_EQ(tag.name(), std::string()); + EXPECT_EQ(tag.name(), ""); EXPECT_EQ(tag.min(), 0); EXPECT_EQ(tag.max(), -1); EXPECT_FALSE(tag.isSinglePropertyTag()); diff --git a/mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp b/mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp index 0ea47bd7512..910ac78158c 100644 --- a/mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp +++ b/mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp @@ -43,7 +43,7 @@ std::optional<std::string> DefaultCellDecorator::cellText(const QModelIndex& ind return std::optional<std::string>{variant.value<ExternalProperty>().text()}; else if (Utils::IsColorVariant(variant)) - return std::optional<std::string>{std::string()}; + return std::optional<std::string>{""}; else if (Utils::IsDoubleVariant(variant)) return std::optional<std::string>{ -- GitLab From a6a6d8eb9ebcf4a2195e61dbbd1c09d4eb56d91e Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 16:29:50 +0200 Subject: [PATCH 02/17] + comm --- GUI/coregui/Models/RealDataItem.cpp | 6 +++--- GUI/coregui/mainwindow/SaveLoadInterface.h | 14 ++++++-------- GUI/coregui/utils/ImportDataInfo.cpp | 2 +- GUI/coregui/utils/ImportDataInfo.h | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/GUI/coregui/Models/RealDataItem.cpp b/GUI/coregui/Models/RealDataItem.cpp index 70a341f4d9b..df39b839ef4 100644 --- a/GUI/coregui/Models/RealDataItem.cpp +++ b/GUI/coregui/Models/RealDataItem.cpp @@ -208,8 +208,8 @@ void RealDataItem::setOutputData(OutputData<double>* data) } //! Sets imported data to underlying item. Creates it if not existing. -//! This is used for 1-D import (2-D only using setOutputData). BUT: This last -//! statement seems wrong - in the unit tests it is used for 2D import +//! This is used for 1-D import (2-D only using setOutputData). BUT: +//! This last statement seems wrong - in the unit tests it is used for 2D import void RealDataItem::setImportData(ImportDataInfo data) { @@ -221,7 +221,7 @@ void RealDataItem::setImportData(ImportDataInfo data) initDataItem(data_rank, T_NATIVE_DATA); QString units_name = data.unitsLabel(); - auto output_data = data.intensityData(); + auto output_data = data.clonedData(); dataItem()->reset(std::move(data)); setNativeDataUnits(units_name); diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.h b/GUI/coregui/mainwindow/SaveLoadInterface.h index 795c4d445e0..71db68dcaf8 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.h +++ b/GUI/coregui/mainwindow/SaveLoadInterface.h @@ -18,19 +18,18 @@ #include <QDateTime> #include <QString> -//! Purely virtual interface to handle non-XML -//! data save and load. +//! Abstract base class to handle non-XML data save and load. + +//! Inherited (mix-in) by DataItem and PointwiseAxisItem. class SaveLoadInterface { public: virtual ~SaveLoadInterface(); - //! Loads non-XML data from _projectDir_ and returns - //! success flag. + //! Loads non-XML data from _projectDir_ and returns success flag. virtual bool load(const QString& projectDir) = 0; - //! Saves non-XML data in _projectDir_ and returns - //! success flag. + //! Saves non-XML data in _projectDir_ and returns success flag. virtual bool save(const QString& projectDir) = 0; //! Checks if object owns non-XML data @@ -42,8 +41,7 @@ public: //! Reports file name to save/load non-XML data. virtual QString fileName() const = 0; - //! Reports file name to save/load non-XML data with directory - //! name attached. + //! Reports file name to save/load non-XML data with directory name attached. QString fileName(const QString& projectDir) const; }; diff --git a/GUI/coregui/utils/ImportDataInfo.cpp b/GUI/coregui/utils/ImportDataInfo.cpp index 48e6342e440..07faa523e2a 100644 --- a/GUI/coregui/utils/ImportDataInfo.cpp +++ b/GUI/coregui/utils/ImportDataInfo.cpp @@ -65,7 +65,7 @@ ImportDataInfo::operator bool() const return static_cast<bool>(m_data); } -std::unique_ptr<OutputData<double>> ImportDataInfo::intensityData() const& +std::unique_ptr<OutputData<double>> ImportDataInfo::clonedData() const& { if (!m_data) return nullptr; diff --git a/GUI/coregui/utils/ImportDataInfo.h b/GUI/coregui/utils/ImportDataInfo.h index d6242b7ad4b..c7cf58952b0 100644 --- a/GUI/coregui/utils/ImportDataInfo.h +++ b/GUI/coregui/utils/ImportDataInfo.h @@ -35,7 +35,7 @@ public: //! True if the contained data is not nullptr (no info about empty data) operator bool() const; - std::unique_ptr<OutputData<double>> intensityData() const&; + std::unique_ptr<OutputData<double>> clonedData() const&; std::unique_ptr<OutputData<double>> intensityData() &&; //! Returns number of dimensions. -- GitLab From 3488704f1b96f96f537bcc33a9edb7845f7c99c5 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 16:31:24 +0200 Subject: [PATCH 03/17] clang-format --- Base/Types/CloneableVector.h | 4 +- Core/Export/SimulationToPython.cpp | 2 +- Core/Fitting/SimDataPair.cpp | 2 +- Core/Scan/UnitConverter1D.cpp | 14 ++-- Core/Simulation/SimulationFactory.cpp | 2 +- Device/Detector/IDetector.cpp | 2 +- Device/Detector/IDetector.h | 2 +- Device/Detector/IDetector2D.cpp | 2 +- Device/Detector/IDetector2D.h | 2 +- Device/Detector/SimpleUnitConverters.cpp | 10 +-- Device/Detector/SimulationArea.cpp | 4 +- Device/ProDetector/RegionOfInterest.cpp | 2 +- Device/ProDetector/RegionOfInterest.h | 4 +- Device/Unit/AxisNames.cpp | 74 +++++++++---------- GUI/coregui/Models/TransformFromDomain.cpp | 2 +- .../CsvImportAssistant/CsvImportTable.h | 2 +- .../ImportDataWidgets/ImportDataUtils.cpp | 9 +-- .../MaskWidgets/MaskResultsPresenter.cpp | 4 +- GUI/coregui/utils/ImportDataInfo.cpp | 5 +- .../Core/Instrument/SphericalDetectorTest.cpp | 2 +- gui2/dataloader/parserpropertywidget.cpp | 6 +- gui2/model/materialmodel.h | 3 +- mvvm/model/mvvm/model/sessionitem.cpp | 6 +- .../testmodel/itemconverterfactory.test.cpp | 2 +- 24 files changed, 76 insertions(+), 91 deletions(-) diff --git a/Base/Types/CloneableVector.h b/Base/Types/CloneableVector.h index c6ffff8c48a..2e747ea2bff 100644 --- a/Base/Types/CloneableVector.h +++ b/Base/Types/CloneableVector.h @@ -37,9 +37,7 @@ template <class T> class CloneableVector : public std::vector<std::unique_ptr<T> public: CloneableVector() {} - CloneableVector(const CloneableVector& other) - : super() - { copyOther(other); } + CloneableVector(const CloneableVector& other) : super() { copyOther(other); } CloneableVector& operator=(const CloneableVector& other) { if (this != &other) { diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index 57597df2fd7..5a37f906912 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -27,8 +27,8 @@ #include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintSquare.h" #include "Device/Detector/RectangularDetector.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SphericalDetector.h" +#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" #include "Device/Resolution/ResolutionFunction2DGaussian.h" #include "Device/Resolution/ScanResolution.h" diff --git a/Core/Fitting/SimDataPair.cpp b/Core/Fitting/SimDataPair.cpp index 072445a7e58..03db8dc1c8e 100644 --- a/Core/Fitting/SimDataPair.cpp +++ b/Core/Fitting/SimDataPair.cpp @@ -15,8 +15,8 @@ #include "Core/Fitting/SimDataPair.h" #include "Base/Math/Numeric.h" #include "Core/Scan/UnitConverter1D.h" -#include "Core/Simulation/includeSimulations.h" #include "Core/Simulation/UnitConverterUtils.h" +#include "Core/Simulation/includeSimulations.h" #include "Device/Data/DataUtils.h" namespace { diff --git a/Core/Scan/UnitConverter1D.cpp b/Core/Scan/UnitConverter1D.cpp index ac1869fd115..b214b42d4f1 100644 --- a/Core/Scan/UnitConverter1D.cpp +++ b/Core/Scan/UnitConverter1D.cpp @@ -69,7 +69,7 @@ size_t UnitConverter1D::dimension() const double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); units_type = substituteDefaultUnits(units_type); if (units_type == Axes::Units::NBINS) return 0.0; @@ -79,7 +79,7 @@ double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) cons double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); units_type = substituteDefaultUnits(units_type); auto coordinate_axis = coordinateAxis(); if (units_type == Axes::Units::NBINS) @@ -90,7 +90,7 @@ double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) cons std::unique_ptr<IAxis> UnitConverter1D::createConvertedAxis(size_t i_axis, Axes::Units units) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); units = substituteDefaultUnits(units); if (units == Axes::Units::NBINS) return std::make_unique<FixedBinAxis>(axisName(0, units), coordinateAxis()->size(), @@ -145,7 +145,7 @@ UnitConverterConvSpec* UnitConverterConvSpec::clone() const size_t UnitConverterConvSpec::axisSize(size_t i_axis) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); return m_axis->size(); } @@ -167,7 +167,7 @@ UnitConverterConvSpec::UnitConverterConvSpec(const UnitConverterConvSpec& other) std::vector<std::map<Axes::Units, std::string>> UnitConverterConvSpec::createNameMaps() const { - return { AxisNames::specAxis }; + return {AxisNames::specAxis}; } std::function<double(double)> UnitConverterConvSpec::getTraslatorFrom(Axes::Units units_type) const @@ -221,7 +221,7 @@ UnitConverterQSpec* UnitConverterQSpec::clone() const //! Returns the size of underlying axis. size_t UnitConverterQSpec::axisSize(size_t i_axis) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); return m_axis->size(); } @@ -245,7 +245,7 @@ UnitConverterQSpec::UnitConverterQSpec(const UnitConverterQSpec& other) //! Creates name map for axis in various units std::vector<std::map<Axes::Units, std::string>> UnitConverterQSpec::createNameMaps() const { - return { AxisNames::specAxisQ }; + return {AxisNames::specAxisQ}; } //! Returns translating functional (inv. nm --> desired units) diff --git a/Core/Simulation/SimulationFactory.cpp b/Core/Simulation/SimulationFactory.cpp index 38b75eccf9a..35e123e35e0 100644 --- a/Core/Simulation/SimulationFactory.cpp +++ b/Core/Simulation/SimulationFactory.cpp @@ -13,8 +13,8 @@ // ************************************************************************************************ #include "Core/Simulation/SimulationFactory.h" -#include "Core/Simulation/includeSimulations.h" #include "Core/Simulation/StandardSimulations.h" +#include "Core/Simulation/includeSimulations.h" #include "Param/Base/RealParameter.h" SimulationFactory::SimulationFactory() diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp index ca05526b4fb..13f2d4ca021 100644 --- a/Device/Detector/IDetector.cpp +++ b/Device/Detector/IDetector.cpp @@ -14,9 +14,9 @@ #include "Device/Detector/IDetector.h" #include "Base/Pixel/SimulationElement.h" +#include "Device/Detector/SimulationArea.h" #include "Device/ProDetector/DetectorMask.h" #include "Device/ProDetector/RegionOfInterest.h" -#include "Device/Detector/SimulationArea.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" IDetector::IDetector() diff --git a/Device/Detector/IDetector.h b/Device/Detector/IDetector.h index 0c9eb16b479..24d3d5d8df6 100644 --- a/Device/Detector/IDetector.h +++ b/Device/Detector/IDetector.h @@ -18,8 +18,8 @@ #include "Base/Types/CloneableVector.h" #include "Base/Types/ICloneable.h" -#include "Device/ProDetector/DetectionProperties.h" #include "Device/Detector/SimulationAreaIterator.h" +#include "Device/ProDetector/DetectionProperties.h" #include "Device/Unit/Axes.h" class Beam; diff --git a/Device/Detector/IDetector2D.cpp b/Device/Detector/IDetector2D.cpp index 00033b54cd4..f25e8e6a8c5 100644 --- a/Device/Detector/IDetector2D.cpp +++ b/Device/Detector/IDetector2D.cpp @@ -17,9 +17,9 @@ #include "Base/Pixel/SimulationElement.h" #include "Device/Beam/Beam.h" #include "Device/Detector/DetectorContext.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SimulationArea.h" #include "Device/Mask/InfinitePlane.h" +#include "Device/ProDetector/RegionOfInterest.h" IDetector2D::IDetector2D() = default; diff --git a/Device/Detector/IDetector2D.h b/Device/Detector/IDetector2D.h index 70c118a74b9..2cd34becc32 100644 --- a/Device/Detector/IDetector2D.h +++ b/Device/Detector/IDetector2D.h @@ -16,8 +16,8 @@ #ifndef BORNAGAIN_DEVICE_DETECTOR_IDETECTOR2D_H #define BORNAGAIN_DEVICE_DETECTOR_IDETECTOR2D_H -#include "Device/ProDetector/DetectorMask.h" #include "Device/Detector/IDetector.h" +#include "Device/ProDetector/DetectorMask.h" #include <memory> class Beam; diff --git a/Device/Detector/SimpleUnitConverters.cpp b/Device/Detector/SimpleUnitConverters.cpp index 0b97329b03b..7be4f59181d 100644 --- a/Device/Detector/SimpleUnitConverters.cpp +++ b/Device/Detector/SimpleUnitConverters.cpp @@ -18,8 +18,8 @@ #include "Base/Pixel/RectangularPixel.h" #include "Device/Beam/Beam.h" #include "Device/Detector/RectangularDetector.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SphericalDetector.h" +#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Unit/AxisNames.h" #include <algorithm> #include <cmath> @@ -192,7 +192,7 @@ double SphericalConverter::calculateValue(size_t i_axis, Axes::Units units_type, std::vector<std::map<Axes::Units, std::string>> SphericalConverter::createNameMaps() const { - return { AxisNames::sphericalAxis0, AxisNames::sphericalAxis1 }; + return {AxisNames::sphericalAxis0, AxisNames::sphericalAxis1}; } // ************************************************************************************************ @@ -276,7 +276,7 @@ double RectangularConverter::calculateValue(size_t i_axis, Axes::Units units_typ std::vector<std::map<Axes::Units, std::string>> RectangularConverter::createNameMaps() const { - return { AxisNames::rectangularAxis0, AxisNames::rectangularAxis1 }; + return {AxisNames::rectangularAxis0, AxisNames::rectangularAxis1}; } kvector_t RectangularConverter::normalizeToWavelength(kvector_t vector) const @@ -342,7 +342,7 @@ double OffSpecularConverter::calculateValue(size_t, Axes::Units units_type, doub std::vector<std::map<Axes::Units, std::string>> OffSpecularConverter::createNameMaps() const { - return { AxisNames::offSpecularAxis0, AxisNames::offSpecularAxis1 }; + return {AxisNames::offSpecularAxis0, AxisNames::offSpecularAxis1}; } void OffSpecularConverter::addDetectorYAxis(const IDetector2D& detector) @@ -429,7 +429,7 @@ double DepthProbeConverter::calculateValue(size_t i_axis, Axes::Units units_type std::vector<std::map<Axes::Units, std::string>> DepthProbeConverter::createNameMaps() const { - return { AxisNames::specAxis, AxisNames::sampleDepthAxis }; + return {AxisNames::specAxis, AxisNames::sampleDepthAxis}; } void DepthProbeConverter::checkUnits(Axes::Units units_type) const diff --git a/Device/Detector/SimulationArea.cpp b/Device/Detector/SimulationArea.cpp index 62f22953392..1ef1531316b 100644 --- a/Device/Detector/SimulationArea.cpp +++ b/Device/Detector/SimulationArea.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Device/Detector/SimulationArea.h" -#include "Device/ProDetector/DetectorMask.h" #include "Device/Detector/IDetector.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Mask/Rectangle.h" +#include "Device/ProDetector/DetectorMask.h" +#include "Device/ProDetector/RegionOfInterest.h" #include <sstream> SimulationArea::SimulationArea(const IDetector* detector) : m_detector(detector), m_max_index(0) diff --git a/Device/ProDetector/RegionOfInterest.cpp b/Device/ProDetector/RegionOfInterest.cpp index b8956d0ed1d..a6837047bcd 100644 --- a/Device/ProDetector/RegionOfInterest.cpp +++ b/Device/ProDetector/RegionOfInterest.cpp @@ -22,7 +22,7 @@ RegionOfInterest::RegionOfInterest(const CloneableVector<IAxis>& axes, double xl double xup, double yup) : RegionOfInterest(xlow, ylow, xup, yup) { - ASSERT(axes.size()==2); + ASSERT(axes.size() == 2); initFrom(*axes[0], *axes[1]); } diff --git a/Device/ProDetector/RegionOfInterest.h b/Device/ProDetector/RegionOfInterest.h index 19b269392ec..bc382df1110 100644 --- a/Device/ProDetector/RegionOfInterest.h +++ b/Device/ProDetector/RegionOfInterest.h @@ -34,8 +34,8 @@ template <class T> class OutputData; class RegionOfInterest : public ICloneable { public: - RegionOfInterest(const CloneableVector<IAxis>& axes, - double xlow, double ylow, double xup, double yup); + RegionOfInterest(const CloneableVector<IAxis>& axes, double xlow, double ylow, double xup, + double yup); RegionOfInterest& operator=(const RegionOfInterest& other) = delete; RegionOfInterest* clone() const; diff --git a/Device/Unit/AxisNames.cpp b/Device/Unit/AxisNames.cpp index d687f67b087..17a0c53eecb 100644 --- a/Device/Unit/AxisNames.cpp +++ b/Device/Unit/AxisNames.cpp @@ -19,56 +19,50 @@ namespace AxisNames { // For spherical detectors in GISAS simulations BA_DEVICE_API_ const std::map<Axes::Units, std::string> sphericalAxis0 = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::RADIANS, "phi_f [rad]" }, - { Axes::Units::DEGREES, "phi_f [deg]" }, - { Axes::Units::QSPACE, "Qy [1/nm]" }, - { Axes::Units::QXQY, "Qx [1/nm]" } }; + {Axes::Units::NBINS, "X [nbins]"}, + {Axes::Units::RADIANS, "phi_f [rad]"}, + {Axes::Units::DEGREES, "phi_f [deg]"}, + {Axes::Units::QSPACE, "Qy [1/nm]"}, + {Axes::Units::QXQY, "Qx [1/nm]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> sphericalAxis1 = { - { Axes::Units::NBINS, "Y [nbins]" }, - { Axes::Units::RADIANS, "alpha_f [rad]" }, - { Axes::Units::DEGREES, "alpha_f [deg]" }, - { Axes::Units::QSPACE, "Qz [1/nm]" }, - { Axes::Units::QXQY, "Qy [1/nm]" } }; + {Axes::Units::NBINS, "Y [nbins]"}, + {Axes::Units::RADIANS, "alpha_f [rad]"}, + {Axes::Units::DEGREES, "alpha_f [deg]"}, + {Axes::Units::QSPACE, "Qz [1/nm]"}, + {Axes::Units::QXQY, "Qy [1/nm]"}}; // For rectangular detectors in GISAS simulations BA_DEVICE_API_ const std::map<Axes::Units, std::string> rectangularAxis0 = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::RADIANS, "phi_f [rad]" }, - { Axes::Units::DEGREES, "phi_f [deg]" }, - { Axes::Units::MM, "X [mm]" }, - { Axes::Units::QSPACE, "Qy [1/nm]" }, - { Axes::Units::QXQY, "Qx [1/nm]" } }; + {Axes::Units::NBINS, "X [nbins]"}, {Axes::Units::RADIANS, "phi_f [rad]"}, + {Axes::Units::DEGREES, "phi_f [deg]"}, {Axes::Units::MM, "X [mm]"}, + {Axes::Units::QSPACE, "Qy [1/nm]"}, {Axes::Units::QXQY, "Qx [1/nm]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> rectangularAxis1 = { - { Axes::Units::NBINS, "Y [nbins]" }, - { Axes::Units::RADIANS, "alpha_f [rad]" }, - { Axes::Units::DEGREES, "alpha_f [deg]" }, - { Axes::Units::MM, "Y [mm]" }, - { Axes::Units::QSPACE, "Qz [1/nm]" }, - { Axes::Units::QXQY, "Qy [1/nm]" } }; + {Axes::Units::NBINS, "Y [nbins]"}, {Axes::Units::RADIANS, "alpha_f [rad]"}, + {Axes::Units::DEGREES, "alpha_f [deg]"}, {Axes::Units::MM, "Y [mm]"}, + {Axes::Units::QSPACE, "Qz [1/nm]"}, {Axes::Units::QXQY, "Qy [1/nm]"}}; // For off-specular simulations (both spherical and rectangular detectors) // Currently 'mm' is not supported for the y-axis BA_DEVICE_API_ const std::map<Axes::Units, std::string> offSpecularAxis0 = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::RADIANS, "alpha_i [rad]" }, - { Axes::Units::DEGREES, "alpha_i [deg]" }}; + {Axes::Units::NBINS, "X [nbins]"}, + {Axes::Units::RADIANS, "alpha_i [rad]"}, + {Axes::Units::DEGREES, "alpha_i [deg]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> offSpecularAxis1 = { - { Axes::Units::NBINS, "Y [nbins]" }, - { Axes::Units::RADIANS, "alpha_f [rad]" }, - { Axes::Units::DEGREES, "alpha_f [deg]" }}; + {Axes::Units::NBINS, "Y [nbins]"}, + {Axes::Units::RADIANS, "alpha_f [rad]"}, + {Axes::Units::DEGREES, "alpha_f [deg]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> specAxis = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::RADIANS, "alpha_i [rad]" }, - { Axes::Units::DEGREES, "alpha_i [deg]" }, - { Axes::Units::QSPACE, "Q [1/nm]" }, - { Axes::Units::RQ4, "Q [1/nm]" } }; + {Axes::Units::NBINS, "X [nbins]"}, + {Axes::Units::RADIANS, "alpha_i [rad]"}, + {Axes::Units::DEGREES, "alpha_i [deg]"}, + {Axes::Units::QSPACE, "Q [1/nm]"}, + {Axes::Units::RQ4, "Q [1/nm]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> specAxisQ = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::QSPACE, "Q [1/nm]" }, - { Axes::Units::RQ4, "Q [1/nm]" } }; + {Axes::Units::NBINS, "X [nbins]"}, + {Axes::Units::QSPACE, "Q [1/nm]"}, + {Axes::Units::RQ4, "Q [1/nm]"}}; // corner case: axis corresponding to the position // across sample is accepts only bins and nanometers, @@ -78,9 +72,9 @@ BA_DEVICE_API_ const std::map<Axes::Units, std::string> specAxisQ = { // nanometers except for bins. BA_DEVICE_API_ const std::map<Axes::Units, std::string> sampleDepthAxis = { - { Axes::Units::NBINS, "Y [nbins]" }, - { Axes::Units::RADIANS, "Position [nm]" }, - { Axes::Units::DEGREES, "Position [nm]" }, - { Axes::Units::QSPACE, "Position [nm]" } }; + {Axes::Units::NBINS, "Y [nbins]"}, + {Axes::Units::RADIANS, "Position [nm]"}, + {Axes::Units::DEGREES, "Position [nm]"}, + {Axes::Units::QSPACE, "Position [nm]"}}; } // namespace AxisNames diff --git a/GUI/coregui/Models/TransformFromDomain.cpp b/GUI/coregui/Models/TransformFromDomain.cpp index ac6fb583e85..fbd3dbb7775 100644 --- a/GUI/coregui/Models/TransformFromDomain.cpp +++ b/GUI/coregui/Models/TransformFromDomain.cpp @@ -22,13 +22,13 @@ #include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintSquare.h" #include "Device/Detector/RectangularDetector.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SphericalDetector.h" #include "Device/Mask/Ellipse.h" #include "Device/Mask/InfinitePlane.h" #include "Device/Mask/Line.h" #include "Device/Mask/Polygon.h" #include "Device/Mask/Rectangle.h" +#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" #include "Device/Resolution/ResolutionFunction2DGaussian.h" #include "Device/Resolution/ScanResolution.h" diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h index e2358424f23..28ec4507d30 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h @@ -17,8 +17,8 @@ #include "GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h" #include <QTableWidget> -#include <set> #include <memory> +#include <set> class CsvImportData : public QObject { public: diff --git a/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp b/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp index 4e946d87de1..09233b69718 100644 --- a/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp @@ -53,9 +53,9 @@ int rank(const InstrumentItem& item) //! Allocates OutputData, and returns owning pointer. //! Currently used for all 2D, and some 1D data files. -std::unique_ptr<OutputData<double>> ImportKnownData( - const QString& fileName, - IntensityDataIOFactory::LoaderSelector loader = IntensityDataIOFactory::automatic) +std::unique_ptr<OutputData<double>> +ImportKnownData(const QString& fileName, + IntensityDataIOFactory::LoaderSelector loader = IntensityDataIOFactory::automatic) { // Try to use the canonical tools for importing data std::unique_ptr<OutputData<double>> result; @@ -152,8 +152,7 @@ bool ImportDataUtils::Compatible(const InstrumentItem& instrumentItem, return rank(instrumentItem) == rank(realDataItem); } -std::unique_ptr<OutputData<double>> -ImportDataUtils::binifyAxes(const OutputData<double>& data) +std::unique_ptr<OutputData<double>> ImportDataUtils::binifyAxes(const OutputData<double>& data) { std::unique_ptr<OutputData<double>> result(new OutputData<double>); for (size_t i = 0; i < data.rank(); ++i) { diff --git a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp index a3f62c9e815..9a5214ba867 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp @@ -99,8 +99,8 @@ OutputData<double>* MaskResultsPresenter::createMaskPresentation() const double ylow = maskItem->getItemValue(RectangleItem::P_YLOW).toDouble(); double xup = maskItem->getItemValue(RectangleItem::P_XUP).toDouble(); double yup = maskItem->getItemValue(RectangleItem::P_YUP).toDouble(); - roi.reset(new RegionOfInterest(m_intensityDataItem->getOutputData()->axes(), - xlow, ylow, xup, yup)); + roi.reset(new RegionOfInterest(m_intensityDataItem->getOutputData()->axes(), xlow, + ylow, xup, yup)); } else { std::unique_ptr<IShape2D> shape(maskItem->createShape()); bool mask_value = maskItem->getItemValue(MaskItem::P_MASK_VALUE).toBool(); diff --git a/GUI/coregui/utils/ImportDataInfo.cpp b/GUI/coregui/utils/ImportDataInfo.cpp index 07faa523e2a..d78fd812efa 100644 --- a/GUI/coregui/utils/ImportDataInfo.cpp +++ b/GUI/coregui/utils/ImportDataInfo.cpp @@ -38,9 +38,8 @@ ImportDataInfo::ImportDataInfo(ImportDataInfo&& other) } ImportDataInfo::ImportDataInfo(std::unique_ptr<OutputData<double>> data, Axes::Units units) - : m_data(units == Axes::Units::NBINS && data - ? ImportDataUtils::binifyAxes(*data) - : std::move(data)) + : m_data(units == Axes::Units::NBINS && data ? ImportDataUtils::binifyAxes(*data) + : std::move(data)) , m_units(units) { checkValidity(); diff --git a/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp b/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp index 36bb82e5022..c2e885652cb 100644 --- a/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp +++ b/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp @@ -1,10 +1,10 @@ #include "Device/Detector/SphericalDetector.h" #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SimulationArea.h" #include "Device/Mask/Polygon.h" #include "Device/Mask/Rectangle.h" +#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" #include "Device/Resolution/ResolutionFunction2DGaussian.h" #include "Tests/GTestWrapper/google_test.h" diff --git a/gui2/dataloader/parserpropertywidget.cpp b/gui2/dataloader/parserpropertywidget.cpp index 11b20963e1e..18c39bf75ac 100644 --- a/gui2/dataloader/parserpropertywidget.cpp +++ b/gui2/dataloader/parserpropertywidget.cpp @@ -251,8 +251,7 @@ void ParserPropertyWidget::addIgnoreStringPatternRow(QGridLayout* layout) startingWithRadio->setChecked(true); startingWithRadio->setToolTip("Ignore lines starting with a given character(s)"); auto on_startingfrom_radio = [this, startingFromLineEdit](auto checked) { - m_options.m_header_prefix = - checked ? startingFromLineEdit->text().toStdString() : ""; + m_options.m_header_prefix = checked ? startingFromLineEdit->text().toStdString() : ""; onParserPropertyChange(); }; connect(startingWithRadio, &QRadioButton::clicked, on_startingfrom_radio); @@ -286,8 +285,7 @@ void ParserPropertyWidget::addIgnoreNumbersPatternRow(QGridLayout* layout) lineNumbersRadio->setText("Line numbers"); lineNumbersRadio->setToolTip("Ignore lines with line numbers matching the pattern"); auto on_linenumbers_radio = [this, lineNumbersLineEdit](auto checked) { - m_options.m_skip_index_pattern = - checked ? lineNumbersLineEdit->text().toStdString() : ""; + m_options.m_skip_index_pattern = checked ? lineNumbersLineEdit->text().toStdString() : ""; onParserPropertyChange(); }; connect(lineNumbersRadio, &QRadioButton::clicked, on_linenumbers_radio); diff --git a/gui2/model/materialmodel.h b/gui2/model/materialmodel.h index 1d07fea591e..e3baab611d7 100644 --- a/gui2/model/materialmodel.h +++ b/gui2/model/materialmodel.h @@ -36,8 +36,7 @@ class DAREFLCORE_EXPORT MaterialModel : public ModelView::SessionModel { public: MaterialModel(std::shared_ptr<ModelView::ItemPool> pool = {}); - std::vector<ModelView::ExternalProperty> - material_data(std::string container_id = "") const; + std::vector<ModelView::ExternalProperty> material_data(std::string container_id = "") const; ModelView::ExternalProperty material_property(const std::string& id); diff --git a/mvvm/model/mvvm/model/sessionitem.cpp b/mvvm/model/mvvm/model/sessionitem.cpp index 67df28af94f..46c8827eced 100644 --- a/mvvm/model/mvvm/model/sessionitem.cpp +++ b/mvvm/model/mvvm/model/sessionitem.cpp @@ -297,8 +297,7 @@ SessionItem* SessionItem::setEnabled(bool value) std::string SessionItem::toolTip() const { - return hasData(ItemDataRole::TOOLTIP) ? data<std::string>(ItemDataRole::TOOLTIP) - : ""; + return hasData(ItemDataRole::TOOLTIP) ? data<std::string>(ItemDataRole::TOOLTIP) : ""; } //! Sets item tooltip (fluent interface). @@ -313,8 +312,7 @@ SessionItem* SessionItem::setToolTip(const std::string& tooltip) std::string SessionItem::editorType() const { - return hasData(ItemDataRole::EDITORTYPE) ? data<std::string>(ItemDataRole::EDITORTYPE) - : ""; + return hasData(ItemDataRole::EDITORTYPE) ? data<std::string>(ItemDataRole::EDITORTYPE) : ""; } //! Sets editor type (fluent interface). diff --git a/mvvm/tests/testmodel/itemconverterfactory.test.cpp b/mvvm/tests/testmodel/itemconverterfactory.test.cpp index f7d8c918f9c..51cfb4e6593 100644 --- a/mvvm/tests/testmodel/itemconverterfactory.test.cpp +++ b/mvvm/tests/testmodel/itemconverterfactory.test.cpp @@ -108,7 +108,7 @@ TEST_F(ItemConverterFactoryTest, propertyItemProjectConverter) EXPECT_EQ(reco->modelType(), item.modelType()); EXPECT_EQ(reco->displayName(), item.displayName()); - EXPECT_EQ(reco->toolTip(), ""); // tooltips are not preserved + EXPECT_EQ(reco->toolTip(), ""); // tooltips are not preserved EXPECT_TRUE(reco->identifier() == item.identifier()); // identifier preserved } -- GitLab From d33c9133f249481fc6a5eb0383c02a73c003af25 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 17:00:19 +0200 Subject: [PATCH 04/17] longer fct names for disambiguation --- GUI/coregui/Models/DataItem.cpp | 4 ++-- GUI/coregui/Models/DataItem.h | 4 ++-- GUI/coregui/Models/PointwiseAxisItem.cpp | 4 ++-- GUI/coregui/Models/PointwiseAxisItem.h | 4 ++-- GUI/coregui/mainwindow/OutputDataIOService.cpp | 8 ++++---- GUI/coregui/mainwindow/SaveLoadInterface.h | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/GUI/coregui/Models/DataItem.cpp b/GUI/coregui/Models/DataItem.cpp index 477c8359a65..a8adfc09de4 100644 --- a/GUI/coregui/Models/DataItem.cpp +++ b/GUI/coregui/Models/DataItem.cpp @@ -57,7 +57,7 @@ bool DataItem::containsNonXMLData() const return static_cast<bool>(m_data); } -bool DataItem::load(const QString& projectDir) +bool DataItem::loadData(const QString& projectDir) { QString filename = fileName(projectDir); auto data = IntensityDataIOFactory::readOutputData(filename.toStdString()); @@ -67,7 +67,7 @@ bool DataItem::load(const QString& projectDir) return true; } -bool DataItem::save(const QString& projectDir) +bool DataItem::saveData(const QString& projectDir) { if (!containsNonXMLData()) return false; diff --git a/GUI/coregui/Models/DataItem.h b/GUI/coregui/Models/DataItem.h index 107f1014a7d..2166def5a61 100644 --- a/GUI/coregui/Models/DataItem.h +++ b/GUI/coregui/Models/DataItem.h @@ -51,8 +51,8 @@ public: void setFileName(const QString& filename); QDateTime lastModified() const override; bool containsNonXMLData() const override; - bool load(const QString& projectDir) override; - bool save(const QString& projectDir) override; + bool loadData(const QString& projectDir) override; + bool saveData(const QString& projectDir) override; void setLastModified(const QDateTime& dtime); diff --git a/GUI/coregui/Models/PointwiseAxisItem.cpp b/GUI/coregui/Models/PointwiseAxisItem.cpp index 4804a9abbd0..5f040fbc8e1 100644 --- a/GUI/coregui/Models/PointwiseAxisItem.cpp +++ b/GUI/coregui/Models/PointwiseAxisItem.cpp @@ -76,7 +76,7 @@ std::unique_ptr<IAxis> PointwiseAxisItem::createAxis(double scale) const return std::make_unique<PointwiseAxis>(converted_axis->getName(), std::move(centers)); } -bool PointwiseAxisItem::load(const QString& projectDir) +bool PointwiseAxisItem::loadData(const QString& projectDir) { QString filename = SaveLoadInterface::fileName(projectDir); auto data = IntensityDataIOFactory::readOutputData(filename.toStdString()); @@ -89,7 +89,7 @@ bool PointwiseAxisItem::load(const QString& projectDir) return true; } -bool PointwiseAxisItem::save(const QString& projectDir) +bool PointwiseAxisItem::saveData(const QString& projectDir) { if (!containsNonXMLData()) return false; diff --git a/GUI/coregui/Models/PointwiseAxisItem.h b/GUI/coregui/Models/PointwiseAxisItem.h index 878d7876b60..0e9171ebefc 100644 --- a/GUI/coregui/Models/PointwiseAxisItem.h +++ b/GUI/coregui/Models/PointwiseAxisItem.h @@ -45,8 +45,8 @@ public: void updateIndicators(); private: - bool load(const QString& projectDir) override; - bool save(const QString& projectDir) override; + bool loadData(const QString& projectDir) override; + bool saveData(const QString& projectDir) override; void setLastModified(const QDateTime& dtime); bool checkValidity() const; diff --git a/GUI/coregui/mainwindow/OutputDataIOService.cpp b/GUI/coregui/mainwindow/OutputDataIOService.cpp index fbd7315866c..68f6af62042 100644 --- a/GUI/coregui/mainwindow/OutputDataIOService.cpp +++ b/GUI/coregui/mainwindow/OutputDataIOService.cpp @@ -50,9 +50,9 @@ void OutputDataIOService::save(const QString& projectDir) OutputDataDirHistory newHistory; - for (auto item : nonXMLItems()) { + for (SaveLoadInterface* item : nonXMLItems()) { if (m_history.wasModifiedSinceLastSave(projectDir, item)) - item->save(projectDir); + item->saveData(projectDir); newHistory.markAsSaved(item); } @@ -69,9 +69,9 @@ void OutputDataIOService::load(const QString& projectDir, MessageService* messag { OutputDataDirHistory newHistory; - for (auto item : nonXMLItems()) { + for (SaveLoadInterface* item : nonXMLItems()) { try { - item->load(projectDir); + item->loadData(projectDir); newHistory.markAsSaved(item); // handling crash of GUI during job run and non-existing file if (auto jobItem = parentJobItem(item)) { diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.h b/GUI/coregui/mainwindow/SaveLoadInterface.h index 71db68dcaf8..2835a65dc55 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.h +++ b/GUI/coregui/mainwindow/SaveLoadInterface.h @@ -27,10 +27,10 @@ public: virtual ~SaveLoadInterface(); //! Loads non-XML data from _projectDir_ and returns success flag. - virtual bool load(const QString& projectDir) = 0; + virtual bool loadData(const QString& projectDir) = 0; //! Saves non-XML data in _projectDir_ and returns success flag. - virtual bool save(const QString& projectDir) = 0; + virtual bool saveData(const QString& projectDir) = 0; //! Checks if object owns non-XML data virtual bool containsNonXMLData() const = 0; -- GitLab From 6e6182820541d5c7c8999b2ef766186357626b83 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 17:27:42 +0200 Subject: [PATCH 05/17] generalize fct FileSystemUtils::jointPath --- Base/Utils/FileSystemUtils.cpp | 4 +++- Base/Utils/FileSystemUtils.h | 2 +- GUI/coregui/mainwindow/SaveLoadInterface.cpp | 2 -- GUI/coregui/mainwindow/SaveLoadInterface.h | 2 +- auto/Wrap/doxygenBase.i | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Base/Utils/FileSystemUtils.cpp b/Base/Utils/FileSystemUtils.cpp index a03f8dd904c..7b502099ae9 100644 --- a/Base/Utils/FileSystemUtils.cpp +++ b/Base/Utils/FileSystemUtils.cpp @@ -71,9 +71,11 @@ std::vector<std::string> FileSystemUtils::filesInDirectory(const std::string& di std::string FileSystemUtils::jointPath(const std::string& path1, const std::string& path2) { - ASSERT(path1 != ""); ASSERT(path2 != ""); + if (path1 == "") + return fs::path(path2).string(); + return (fs::path(path1) / fs::path(path2)).string(); } diff --git a/Base/Utils/FileSystemUtils.h b/Base/Utils/FileSystemUtils.h index 869e2494e92..832b6629484 100644 --- a/Base/Utils/FileSystemUtils.h +++ b/Base/Utils/FileSystemUtils.h @@ -44,7 +44,7 @@ bool createDirectories(const std::string& dir_name); //! Returns filenames of files in directory std::vector<std::string> filesInDirectory(const std::string& dir_name); -//! Returns joint path name. +//! Returns joint path name. Argument path1 may be empty, argument path2 not. std::string jointPath(const std::string& path1, const std::string& path2); //! Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz") diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.cpp b/GUI/coregui/mainwindow/SaveLoadInterface.cpp index 84531282ef7..49aa93c69a7 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.cpp +++ b/GUI/coregui/mainwindow/SaveLoadInterface.cpp @@ -14,8 +14,6 @@ #include "GUI/coregui/mainwindow/SaveLoadInterface.h" -SaveLoadInterface::~SaveLoadInterface() = default; - QString SaveLoadInterface::fileName(const QString& projectDir) const { const auto filename = fileName(); diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.h b/GUI/coregui/mainwindow/SaveLoadInterface.h index 2835a65dc55..a18f74ee0e3 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.h +++ b/GUI/coregui/mainwindow/SaveLoadInterface.h @@ -24,7 +24,7 @@ class SaveLoadInterface { public: - virtual ~SaveLoadInterface(); + virtual ~SaveLoadInterface() = default; //! Loads non-XML data from _projectDir_ and returns success flag. virtual bool loadData(const QString& projectDir) = 0; diff --git a/auto/Wrap/doxygenBase.i b/auto/Wrap/doxygenBase.i index d6d04bf493f..42a64595689 100644 --- a/auto/Wrap/doxygenBase.i +++ b/auto/Wrap/doxygenBase.i @@ -1310,7 +1310,7 @@ Returns filenames of files in directory. %feature("docstring") FileSystemUtils::jointPath "std::string FileSystemUtils::jointPath(const std::string &path1, const std::string &path2) -Returns joint path name. +Returns joint path name. Argument path1 may be empty, argument path2 not. "; %feature("docstring") FileSystemUtils::filename "std::string FileSystemUtils::filename(const std::string &path) -- GitLab From d86daf0beaa57747fe1565ada4f468bf9a34d2ac Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 17:36:45 +0200 Subject: [PATCH 06/17] Use jointPath from base --- GUI/coregui/mainwindow/SaveLoadInterface.cpp | 5 +++-- Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.cpp b/GUI/coregui/mainwindow/SaveLoadInterface.cpp index 49aa93c69a7..34d78ad8d48 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.cpp +++ b/GUI/coregui/mainwindow/SaveLoadInterface.cpp @@ -13,9 +13,10 @@ // ************************************************************************************************ #include "GUI/coregui/mainwindow/SaveLoadInterface.h" +#include "Base/Utils/FileSystemUtils.h" QString SaveLoadInterface::fileName(const QString& projectDir) const { - const auto filename = fileName(); - return projectDir.isEmpty() ? filename : projectDir + "/" + filename; + return QString::fromStdString( + FileSystemUtils::jointPath(projectDir.toStdString(), fileName().toStdString())); } diff --git a/Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp b/Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp index 6640a4aee5b..8b78a3b5690 100644 --- a/Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp +++ b/Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp @@ -153,7 +153,7 @@ TEST_F(FileSystemUtilsTest, jointPath) EXPECT_ANY_THROW(FileSystemUtils::jointPath("", "")); EXPECT_ANY_THROW(FileSystemUtils::jointPath("a", "")); - EXPECT_ANY_THROW(FileSystemUtils::jointPath("", "b")); + EXPECT_EQ(FileSystemUtils::jointPath("", "b"), "b"); } TEST_F(FileSystemUtilsTest, filesInDirectory_IsFileExists) @@ -182,4 +182,4 @@ TEST_F(FileSystemUtilsTest, filesInDirectory_IsFileExists) EXPECT_TRUE(FileSystemUtils::IsFileExists("file2.txt")); EXPECT_TRUE(FileSystemUtils::IsFileExists("file3.txt")); EXPECT_FALSE(FileSystemUtils::IsFileExists("nonexisting.txt")); -} \ No newline at end of file +} -- GitLab From 37cd6c881b3e93731167f68a5d576a1eccb1f4a0 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 17:56:17 +0200 Subject: [PATCH 07/17] restore QString() with addProperty --- GUI/coregui/Models/DataProperties.cpp | 2 +- GUI/coregui/Models/FitParameterItems.cpp | 4 ++-- GUI/coregui/Models/ParameterTreeItems.cpp | 4 ++-- mvvm/model/mvvm/standarditems/plottableitems.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GUI/coregui/Models/DataProperties.cpp b/GUI/coregui/Models/DataProperties.cpp index 426810fd5e8..58e21b018fd 100644 --- a/GUI/coregui/Models/DataProperties.cpp +++ b/GUI/coregui/Models/DataProperties.cpp @@ -43,7 +43,7 @@ const QString DataProperties::P_DATALINK = "data link"; DataProperties::DataProperties(const QString& model_type) : SessionItem(model_type) { - addProperty(P_DATALINK, ""); + addProperty(P_DATALINK, QString()); } void DataProperties::setDataItem(DataItem* item) diff --git a/GUI/coregui/Models/FitParameterItems.cpp b/GUI/coregui/Models/FitParameterItems.cpp index b16e65c9f69..328ab0833cf 100644 --- a/GUI/coregui/Models/FitParameterItems.cpp +++ b/GUI/coregui/Models/FitParameterItems.cpp @@ -52,8 +52,8 @@ const QString FitParameterLinkItem::P_DOMAIN = "Domain"; FitParameterLinkItem::FitParameterLinkItem() : SessionItem("FitParameterLink") { - addProperty(P_LINK, ""); - addProperty(P_DOMAIN, ""); + addProperty(P_LINK, QString()); + addProperty(P_DOMAIN, QString()); } // ---------------------------------------------------------------------------- diff --git a/GUI/coregui/Models/ParameterTreeItems.cpp b/GUI/coregui/Models/ParameterTreeItems.cpp index e59cc420606..1cb7f076e85 100644 --- a/GUI/coregui/Models/ParameterTreeItems.cpp +++ b/GUI/coregui/Models/ParameterTreeItems.cpp @@ -34,11 +34,11 @@ const QString ParameterItem::P_DOMAIN = "Domain"; ParameterItem::ParameterItem() : SessionItem("Parameter") { // Link to original PropertyItem in one of components of MultiLayerItem or InstrumentItem - addProperty(P_LINK, ""); + addProperty(P_LINK, QString()); // The back up value of PropertyItem to be able to reset parameter tuning tree to initial state addProperty(P_BACKUP, 0.0); // The domain name of corresponding ISampleNode's registered parameter - addProperty(P_DOMAIN, ""); + addProperty(P_DOMAIN, QString()); } // ---------------------------------------------------------------------------- diff --git a/mvvm/model/mvvm/standarditems/plottableitems.cpp b/mvvm/model/mvvm/standarditems/plottableitems.cpp index bfbb4bfbb04..6b82aa05f59 100644 --- a/mvvm/model/mvvm/standarditems/plottableitems.cpp +++ b/mvvm/model/mvvm/standarditems/plottableitems.cpp @@ -36,7 +36,7 @@ const std::string default_title_family = "Noto Sans"; TextItem::TextItem() : CompoundItem(Constants::TextItemType) { - addProperty(P_TEXT, "")->setDisplayName("Text"); + addProperty(P_TEXT, QString())->setDisplayName("Text"); addProperty(P_FONT, default_title_family)->setDisplayName("Font"); addProperty(P_SIZE, default_title_size)->setDisplayName("Size"); } -- GitLab From 6f13c3c11834e52a5aca0fa8b52958009d332167 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 18:12:30 +0200 Subject: [PATCH 08/17] standardize fct names --- GUI/coregui/mainwindow/SaveService.cpp | 2 +- GUI/coregui/mainwindow/SaveThread.cpp | 2 +- GUI/coregui/mainwindow/projectdocument.cpp | 10 +++++----- GUI/coregui/mainwindow/projectdocument.h | 6 +++--- GUI/coregui/mainwindow/projectmanager.cpp | 4 ++-- Tests/UnitTests/GUI/TestDataItemViews.cpp | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/GUI/coregui/mainwindow/SaveService.cpp b/GUI/coregui/mainwindow/SaveService.cpp index 2c8c14ac8e3..14c9b4ff9c8 100644 --- a/GUI/coregui/mainwindow/SaveService.cpp +++ b/GUI/coregui/mainwindow/SaveService.cpp @@ -148,7 +148,7 @@ void SaveService::process_queue() // saving project file in a main thread const bool isAutosave = project_file_name.contains(ProjectUtils::autosaveSubdir()); - m_document->save_project_file(project_file_name, isAutosave); + m_document->saveProjectFile(project_file_name, isAutosave); if (m_document->hasData()) { // saving heavy data in separate thread diff --git a/GUI/coregui/mainwindow/SaveThread.cpp b/GUI/coregui/mainwindow/SaveThread.cpp index 08fde575e3f..2e132a0af45 100644 --- a/GUI/coregui/mainwindow/SaveThread.cpp +++ b/GUI/coregui/mainwindow/SaveThread.cpp @@ -26,7 +26,7 @@ SaveThread::~SaveThread() void SaveThread::run() { ASSERT(m_document); - m_document->save_project_data(m_projectFile); + m_document->saveProjectData(m_projectFile); emit saveReady(); } diff --git a/GUI/coregui/mainwindow/projectdocument.cpp b/GUI/coregui/mainwindow/projectdocument.cpp index c1ca74073ba..8f387b5a7d0 100644 --- a/GUI/coregui/mainwindow/projectdocument.cpp +++ b/GUI/coregui/mainwindow/projectdocument.cpp @@ -93,11 +93,11 @@ void ProjectDocument::setApplicationModels(ApplicationModels* applicationModels) void ProjectDocument::save(const QString& project_file_name, bool autoSave) { - save_project_data(project_file_name); - save_project_file(project_file_name, autoSave); + saveProjectData(project_file_name); + saveProjectFile(project_file_name, autoSave); } -void ProjectDocument::save_project_file(const QString& project_file_name, bool autoSave) +void ProjectDocument::saveProjectFile(const QString& project_file_name, bool autoSave) { QElapsedTimer timer; timer.start(); @@ -118,7 +118,7 @@ void ProjectDocument::save_project_file(const QString& project_file_name, bool a } } -void ProjectDocument::save_project_data(const QString& project_file_name) +void ProjectDocument::saveProjectData(const QString& project_file_name) { QElapsedTimer timer; timer.start(); @@ -126,7 +126,7 @@ void ProjectDocument::save_project_data(const QString& project_file_name) m_dataService->save(ProjectUtils::projectDir(project_file_name)); } -void ProjectDocument::load(const QString& project_file_name) +void ProjectDocument::loadDataFile(const QString& project_file_name) { QElapsedTimer timer1, timer2; timer1.start(); diff --git a/GUI/coregui/mainwindow/projectdocument.h b/GUI/coregui/mainwindow/projectdocument.h index d7d696c7dd1..fd612e850e3 100644 --- a/GUI/coregui/mainwindow/projectdocument.h +++ b/GUI/coregui/mainwindow/projectdocument.h @@ -58,10 +58,10 @@ public: void save(const QString& project_file_name, bool autoSave = false); - void save_project_file(const QString& project_file_name, bool autoSave = false); - void save_project_data(const QString& project_file_name); + void saveProjectFile(const QString& project_file_name, bool autoSave = false); + void saveProjectData(const QString& project_file_name); - void load(const QString& project_file_name); + void loadDataFile(const QString& project_file_name); bool hasValidNameAndPath(); diff --git a/GUI/coregui/mainwindow/projectmanager.cpp b/GUI/coregui/mainwindow/projectmanager.cpp index 152fc581292..248b979d987 100644 --- a/GUI/coregui/mainwindow/projectmanager.cpp +++ b/GUI/coregui/mainwindow/projectmanager.cpp @@ -380,12 +380,12 @@ void ProjectManager::loadProject(const QString& projectFileName) if (useAutosave && restoreProjectDialog(projectFileName)) { QApplication::setOverrideCursor(Qt::WaitCursor); - m_project_document->load(ProjectUtils::autosaveName(projectFileName)); + m_project_document->loadDataFile(ProjectUtils::autosaveName(projectFileName)); m_project_document->setProjectFileName(projectFileName); m_project_document->setModified(true); } else { QApplication::setOverrideCursor(Qt::WaitCursor); - m_project_document->load(projectFileName); + m_project_document->loadDataFile(projectFileName); } QApplication::restoreOverrideCursor(); } diff --git a/Tests/UnitTests/GUI/TestDataItemViews.cpp b/Tests/UnitTests/GUI/TestDataItemViews.cpp index 311fb5b8ac7..b0a818f5554 100644 --- a/Tests/UnitTests/GUI/TestDataItemViews.cpp +++ b/Tests/UnitTests/GUI/TestDataItemViews.cpp @@ -147,7 +147,7 @@ TEST_F(TestDataItemViews, testSavingLinkedData) ProjectDocument document; document.setApplicationModels(&models); document.setLogger(&message_service); - document.load(projectFileName); + document.loadDataFile(projectFileName); SessionModel* real_data_model = models.realDataModel(); auto view_item = real_data_model->topItem<DataPropertyContainer>(); -- GitLab From 609450b86e05b08a7298dc29a845ace713cf4552 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 18:29:58 +0200 Subject: [PATCH 09/17] rename fcts to load project and data files --- GUI/coregui/mainwindow/OutputDataIOService.cpp | 8 ++++---- GUI/coregui/mainwindow/OutputDataIOService.h | 4 ++-- GUI/coregui/mainwindow/projectdocument.cpp | 10 +++++----- GUI/coregui/mainwindow/projectdocument.h | 4 ++-- GUI/coregui/mainwindow/projectmanager.cpp | 4 ++-- Tests/UnitTests/GUI/TestDataItemViews.cpp | 2 +- Tests/UnitTests/GUI/TestOutputDataIOService.cpp | 4 ++-- Tests/UnitTests/GUI/TestSavingSpecularData.cpp | 6 +++--- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/GUI/coregui/mainwindow/OutputDataIOService.cpp b/GUI/coregui/mainwindow/OutputDataIOService.cpp index 68f6af62042..b8f43f2d60a 100644 --- a/GUI/coregui/mainwindow/OutputDataIOService.cpp +++ b/GUI/coregui/mainwindow/OutputDataIOService.cpp @@ -50,7 +50,7 @@ void OutputDataIOService::save(const QString& projectDir) OutputDataDirHistory newHistory; - for (SaveLoadInterface* item : nonXMLItems()) { + for (SaveLoadInterface* item : dataInterfaces()) { if (m_history.wasModifiedSinceLastSave(projectDir, item)) item->saveData(projectDir); newHistory.markAsSaved(item); @@ -65,11 +65,11 @@ void OutputDataIOService::save(const QString& projectDir) m_history.setHistory(projectDir, newHistory); } -void OutputDataIOService::load(const QString& projectDir, MessageService* messageService) +void OutputDataIOService::loadDataFiles(const QString& projectDir, MessageService* messageService) { OutputDataDirHistory newHistory; - for (SaveLoadInterface* item : nonXMLItems()) { + for (SaveLoadInterface* item : dataInterfaces()) { try { item->loadData(projectDir); newHistory.markAsSaved(item); @@ -99,7 +99,7 @@ void OutputDataIOService::load(const QString& projectDir, MessageService* messag //! Returns all non-XML items available for save/load. -QVector<SaveLoadInterface*> OutputDataIOService::nonXMLItems() const +QVector<SaveLoadInterface*> OutputDataIOService::dataInterfaces() const { QVector<SaveLoadInterface*> result; diff --git a/GUI/coregui/mainwindow/OutputDataIOService.h b/GUI/coregui/mainwindow/OutputDataIOService.h index 39bd9fe7f76..252816e74dc 100644 --- a/GUI/coregui/mainwindow/OutputDataIOService.h +++ b/GUI/coregui/mainwindow/OutputDataIOService.h @@ -37,9 +37,9 @@ public: void save(const QString& projectDir); - void load(const QString& projectDir, MessageService* messageService = nullptr); + void loadDataFiles(const QString& projectDir, MessageService* messageService = nullptr); - QVector<SaveLoadInterface*> nonXMLItems() const; + QVector<SaveLoadInterface*> dataInterfaces() const; private: void cleanOldFiles(const QString& projectDir, const QStringList& oldSaves, diff --git a/GUI/coregui/mainwindow/projectdocument.cpp b/GUI/coregui/mainwindow/projectdocument.cpp index 8f387b5a7d0..f88857df23e 100644 --- a/GUI/coregui/mainwindow/projectdocument.cpp +++ b/GUI/coregui/mainwindow/projectdocument.cpp @@ -126,7 +126,7 @@ void ProjectDocument::saveProjectData(const QString& project_file_name) m_dataService->save(ProjectUtils::projectDir(project_file_name)); } -void ProjectDocument::loadDataFile(const QString& project_file_name) +void ProjectDocument::loadProjectFile(const QString& project_file_name) { QElapsedTimer timer1, timer2; timer1.start(); @@ -144,11 +144,11 @@ void ProjectDocument::loadDataFile(const QString& project_file_name) try { disconnectModels(); - readFrom(&file); + readProject(&file); file.close(); timer2.start(); - m_dataService->load(projectDir(), m_messageService); + m_dataService->loadDataFiles(projectDir(), m_messageService); connectModels(); if (m_messageService->warningCount()) @@ -205,7 +205,7 @@ bool ProjectDocument::hasErrors() const bool ProjectDocument::hasData() const { - return !m_dataService->nonXMLItems().isEmpty(); + return !m_dataService->dataInterfaces().isEmpty(); } QString ProjectDocument::documentVersion() const @@ -222,7 +222,7 @@ void ProjectDocument::onModelChanged() emit modified(); } -void ProjectDocument::readFrom(QIODevice* device) +void ProjectDocument::readProject(QIODevice* device) { ASSERT(m_messageService); QXmlStreamReader reader(device); diff --git a/GUI/coregui/mainwindow/projectdocument.h b/GUI/coregui/mainwindow/projectdocument.h index fd612e850e3..e35924e39ef 100644 --- a/GUI/coregui/mainwindow/projectdocument.h +++ b/GUI/coregui/mainwindow/projectdocument.h @@ -61,7 +61,7 @@ public: void saveProjectFile(const QString& project_file_name, bool autoSave = false); void saveProjectData(const QString& project_file_name); - void loadDataFile(const QString& project_file_name); + void loadProjectFile(const QString& project_file_name); bool hasValidNameAndPath(); @@ -89,7 +89,7 @@ public slots: void onModelChanged(); private: - void readFrom(QIODevice* device); + void readProject(QIODevice* device); void writeTo(QIODevice* device); void disconnectModels(); diff --git a/GUI/coregui/mainwindow/projectmanager.cpp b/GUI/coregui/mainwindow/projectmanager.cpp index 248b979d987..48207050633 100644 --- a/GUI/coregui/mainwindow/projectmanager.cpp +++ b/GUI/coregui/mainwindow/projectmanager.cpp @@ -380,12 +380,12 @@ void ProjectManager::loadProject(const QString& projectFileName) if (useAutosave && restoreProjectDialog(projectFileName)) { QApplication::setOverrideCursor(Qt::WaitCursor); - m_project_document->loadDataFile(ProjectUtils::autosaveName(projectFileName)); + m_project_document->loadProjectFile(ProjectUtils::autosaveName(projectFileName)); m_project_document->setProjectFileName(projectFileName); m_project_document->setModified(true); } else { QApplication::setOverrideCursor(Qt::WaitCursor); - m_project_document->loadDataFile(projectFileName); + m_project_document->loadProjectFile(projectFileName); } QApplication::restoreOverrideCursor(); } diff --git a/Tests/UnitTests/GUI/TestDataItemViews.cpp b/Tests/UnitTests/GUI/TestDataItemViews.cpp index b0a818f5554..f49c9edbc16 100644 --- a/Tests/UnitTests/GUI/TestDataItemViews.cpp +++ b/Tests/UnitTests/GUI/TestDataItemViews.cpp @@ -147,7 +147,7 @@ TEST_F(TestDataItemViews, testSavingLinkedData) ProjectDocument document; document.setApplicationModels(&models); document.setLogger(&message_service); - document.loadDataFile(projectFileName); + document.loadProjectFile(projectFileName); SessionModel* real_data_model = models.realDataModel(); auto view_item = real_data_model->topItem<DataPropertyContainer>(); diff --git a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp index 8fe0b279d55..7b998f1887a 100644 --- a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp +++ b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp @@ -63,7 +63,7 @@ TEST_F(TestOutputDataIOService, test_nonXMLData) // checking data items of OutputDataIOService OutputDataIOService service(&models); - EXPECT_EQ(service.nonXMLItems().size(), 3); + EXPECT_EQ(service.dataInterfaces().size(), 3); // checking data items of ApplicationModels dataItems = models.nonXMLItems(); @@ -271,7 +271,7 @@ TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) // checking data items of OutputDataIOService OutputDataIOService service(&models); - EXPECT_EQ(service.nonXMLItems().size(), 5); + EXPECT_EQ(service.dataInterfaces().size(), 5); const QString projectDir("test_NativeData"); GuiUnittestUtils::create_dir(projectDir); diff --git a/Tests/UnitTests/GUI/TestSavingSpecularData.cpp b/Tests/UnitTests/GUI/TestSavingSpecularData.cpp index 8adf5a8d981..8fd851afd25 100644 --- a/Tests/UnitTests/GUI/TestSavingSpecularData.cpp +++ b/Tests/UnitTests/GUI/TestSavingSpecularData.cpp @@ -91,7 +91,7 @@ TEST_F(TestSavingSpecularData, test_SpecularInsturment) // checking data items of OutputDataIOService OutputDataIOService service(&models); - EXPECT_EQ(service.nonXMLItems().size(), 1); + EXPECT_EQ(service.dataInterfaces().size(), 1); // checking data items of ApplicationModels dataItems = models.nonXMLItems(); @@ -120,7 +120,7 @@ TEST_F(TestSavingSpecularData, test_InstrumentInJobItem) EXPECT_EQ(models.jobModel()->nonXMLItems().size(), 2); OutputDataIOService service(&models); - EXPECT_EQ(service.nonXMLItems().size(), 2); + EXPECT_EQ(service.dataInterfaces().size(), 2); auto dataItems = models.nonXMLItems(); EXPECT_EQ(dataItems.size(), 2); @@ -129,7 +129,7 @@ TEST_F(TestSavingSpecularData, test_InstrumentInJobItem) // hiding pointwise axis, should be saved anyway axis_group->setCurrentType("BasicAxis"); EXPECT_EQ(models.jobModel()->nonXMLItems().size(), 2); - EXPECT_EQ(service.nonXMLItems().size(), 2); + EXPECT_EQ(service.dataInterfaces().size(), 2); dataItems = models.nonXMLItems(); EXPECT_EQ(dataItems.size(), 2); EXPECT_EQ(dataItems.indexOf(dataItem), 0); -- GitLab From 251b1fe3dd9db1c63f53be14bdd08d88835fd912 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 18:36:15 +0200 Subject: [PATCH 10/17] ... --- GUI/coregui/mainwindow/OutputDataIOService.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/GUI/coregui/mainwindow/OutputDataIOService.cpp b/GUI/coregui/mainwindow/OutputDataIOService.cpp index b8f43f2d60a..0010a582214 100644 --- a/GUI/coregui/mainwindow/OutputDataIOService.cpp +++ b/GUI/coregui/mainwindow/OutputDataIOService.cpp @@ -88,10 +88,9 @@ void OutputDataIOService::loadDataFiles(const QString& projectDir, MessageServic QString("Load of the data from disk failed with '%1'").arg(QString(ex.what()))); jobItem->setStatus("Failed"); } - if (messageService) - messageService->send_warning(this, QString(ex.what())); - else + if (!messageService) throw ex; + messageService->send_warning(this, QString(ex.what())); } } m_history.setHistory(projectDir, newHistory); -- GitLab From 50b980c895cfefe2f3ae3d40ec7a707329d2ebee Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 21:01:39 +0200 Subject: [PATCH 11/17] TODO note on test_RealDataItemWithNativeData --- GUI/coregui/Models/RealDataItem.cpp | 3 +-- Tests/UnitTests/GUI/TestOutputDataIOService.cpp | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GUI/coregui/Models/RealDataItem.cpp b/GUI/coregui/Models/RealDataItem.cpp index df39b839ef4..fc47cdd3d6d 100644 --- a/GUI/coregui/Models/RealDataItem.cpp +++ b/GUI/coregui/Models/RealDataItem.cpp @@ -208,8 +208,7 @@ void RealDataItem::setOutputData(OutputData<double>* data) } //! Sets imported data to underlying item. Creates it if not existing. -//! This is used for 1-D import (2-D only using setOutputData). BUT: -//! This last statement seems wrong - in the unit tests it is used for 2D import +//! This is used for 1D import. For 2D import, use setOutputData. void RealDataItem::setImportData(ImportDataInfo data) { diff --git a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp index 7b998f1887a..45169ecae8a 100644 --- a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp +++ b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp @@ -254,6 +254,7 @@ TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) ImportDataInfo import_data(std::unique_ptr<OutputData<double>>(m_data.clone()), "nbins"); realData->setImportData(std::move(import_data)); + // TODO: setImportData tested here with 2D data while main code uses it for 1D only. EXPECT_TRUE(realData->isIntensityData()); EXPECT_EQ(models.realDataModel()->nonXMLItems().size(), 2); -- GitLab From aa6e10820c97ce06b860a0448d2de5ff642db3f4 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 22:47:22 +0200 Subject: [PATCH 12/17] comment; eliminate local var --- GUI/coregui/Models/RealDataItem.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/GUI/coregui/Models/RealDataItem.cpp b/GUI/coregui/Models/RealDataItem.cpp index fc47cdd3d6d..80fa11aa92f 100644 --- a/GUI/coregui/Models/RealDataItem.cpp +++ b/GUI/coregui/Models/RealDataItem.cpp @@ -170,19 +170,18 @@ void RealDataItem::setNativeOutputData(OutputData<double>* data) nativeData()->setOutputData(data); // takes ownership of odata } -//! Creates data item if not existing so far. Checks for rank compatibility if already existing. No -//! further initialization like clearing the data etc. +//! Creates data item if not existing so far. +//! Checks for rank compatibility if already existing. +//! No further initialization (like clearing the data etc). void RealDataItem::initDataItem(size_t rank, const QString& tag) { ASSERT(rank <= 2 && rank > 0); - auto data_item = getItem(tag); + const SessionItem* data_item = getItem(tag); if (data_item != nullptr) { - const bool rankMismatch = (rank == 1 && !data_item->is<SpecularDataItem>()) - || (rank == 2 && !data_item->is<IntensityDataItem>()); - - if (rankMismatch) + if ((rank == 1 && !data_item->is<SpecularDataItem>()) + || (rank == 2 && !data_item->is<IntensityDataItem>())) throw GUIHelpers::Error("Error in RealDataItem::initDataItem: trying to set data " "incompatible with underlying data item"); } else { -- GitLab From fe9a3eb5549ff773c2cf8b8ebc39658395cf6ae7 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 22:01:59 +0200 Subject: [PATCH 13/17] rename variable --- GUI/coregui/Models/RealDataItem.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GUI/coregui/Models/RealDataItem.cpp b/GUI/coregui/Models/RealDataItem.cpp index 80fa11aa92f..67b9146d7ae 100644 --- a/GUI/coregui/Models/RealDataItem.cpp +++ b/GUI/coregui/Models/RealDataItem.cpp @@ -209,19 +209,19 @@ void RealDataItem::setOutputData(OutputData<double>* data) //! Sets imported data to underlying item. Creates it if not existing. //! This is used for 1D import. For 2D import, use setOutputData. -void RealDataItem::setImportData(ImportDataInfo data) +void RealDataItem::setImportData(ImportDataInfo info) { - if (!data) + if (!info) return; - const size_t data_rank = data.dataRank(); + const size_t data_rank = info.dataRank(); initDataItem(data_rank, T_INTENSITY_DATA); initDataItem(data_rank, T_NATIVE_DATA); - QString units_name = data.unitsLabel(); - auto output_data = data.clonedData(); + QString units_name = info.unitsLabel(); + auto output_data = info.clonedData(); - dataItem()->reset(std::move(data)); + dataItem()->reset(std::move(info)); setNativeDataUnits(units_name); item<DataItem>(T_NATIVE_DATA)->setOutputData(output_data.release()); } -- GitLab From 7652241d2d7b03b51fb4b4a8f34798955744567b Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 22:02:53 +0200 Subject: [PATCH 14/17] expand auto --- GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp index 44164eb00c0..35740dab40d 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp @@ -230,7 +230,7 @@ void RealDataSelectorWidget::importData1D() const AbstractDataLoader* selectedLoader = loaderOfFilter.value(selectedFilter, nullptr); for (const auto& fileName : fileNames) { - auto realDataItem = m_itemTreeModel->insertSpecularDataItem(); + RealDataItem* realDataItem = m_itemTreeModel->insertSpecularDataItem(); realDataItem->setName(QFileInfo(fileName).baseName()); realDataItem->setNativeFileName(fileName); @@ -239,7 +239,6 @@ void RealDataSelectorWidget::importData1D() setCurrentItem(realDataItem); else { m_itemTreeModel->removeItem(realDataItem); - GUIHelpers::warning("File import", QString("The file '%1' could not be imported.") .arg(QDir::toNativeSeparators(fileName)), -- GitLab From 29bd9a1f168ab4af226710027eaaffc0eb7145a3 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 22:04:04 +0200 Subject: [PATCH 15/17] handle exceptional case first --- .../RealDataSelectorWidget.cpp | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp index 35740dab40d..e4556217046 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp @@ -271,7 +271,6 @@ void RealDataSelectorWidget::importData2D() const QStringList fileNames = QFileDialog::getOpenFileNames(Q_NULLPTR, "Open Intensity Files", dirname, filters, &selectedFilter, QFileDialog::DontUseNativeDialog); - if (fileNames.isEmpty()) return; @@ -284,27 +283,25 @@ void RealDataSelectorWidget::importData2D() for (const auto& fileName : fileNames) { std::unique_ptr<OutputData<double>> data = ImportDataUtils::Import2dData(fileName, selectedLoader); + if (!data) + continue; + auto realDataItem = m_itemTreeModel->insertIntensityDataItem(); + realDataItem->setName(QFileInfo(fileName).baseName()); - if (data) { - - auto realDataItem = m_itemTreeModel->insertIntensityDataItem(); - realDataItem->setName(QFileInfo(fileName).baseName()); - - try { - if (data->rank() != 2) - throw GUIHelpers::Error( - "The content could not be interpreted correctly as 2-dimensional."); + try { + if (data->rank() != 2) + throw GUIHelpers::Error( + "The content could not be interpreted correctly as 2-dimensional."); - realDataItem->setOutputData(data.release()); - setCurrentItem(realDataItem); - } catch (std::exception& ex) { - m_itemTreeModel->removeItem(realDataItem); + realDataItem->setOutputData(data.release()); + setCurrentItem(realDataItem); + } catch (std::exception& ex) { + m_itemTreeModel->removeItem(realDataItem); - const QString message = QString("Error while trying to read file\n\n'%1'\n\n%2") - .arg(fileName) - .arg(QString::fromStdString(std::string(ex.what()))); - GUIHelpers::warning("File import", message); - } + const QString message = QString("Error while trying to read file\n\n'%1'\n\n%2") + .arg(fileName) + .arg(QString::fromStdString(std::string(ex.what()))); + GUIHelpers::warning("File import", message); } } } -- GitLab From 71667593ef6baaec60df23e89ee70c5a0152905b Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 22:04:44 +0200 Subject: [PATCH 16/17] expand auto --- GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp index e4556217046..4609c658e2b 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp @@ -285,7 +285,7 @@ void RealDataSelectorWidget::importData2D() ImportDataUtils::Import2dData(fileName, selectedLoader); if (!data) continue; - auto realDataItem = m_itemTreeModel->insertIntensityDataItem(); + RealDataItem* realDataItem = m_itemTreeModel->insertIntensityDataItem(); realDataItem->setName(QFileInfo(fileName).baseName()); try { -- GitLab From ef6343d74cf3df080beacd5ef93e84a48c800248 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 22 Apr 2021 22:16:56 +0200 Subject: [PATCH 17/17] comments --- GUI/coregui/DataLoaders/QREDataLoader.cpp | 3 +-- GUI/coregui/DataLoaders/QREDataLoader.h | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/GUI/coregui/DataLoaders/QREDataLoader.cpp b/GUI/coregui/DataLoaders/QREDataLoader.cpp index c8738653f71..6a6ed28972c 100644 --- a/GUI/coregui/DataLoaders/QREDataLoader.cpp +++ b/GUI/coregui/DataLoaders/QREDataLoader.cpp @@ -333,9 +333,8 @@ void QREDataLoader::guessSettings() continue; int endOfGap = startOfGap; - while (endOfGap < line.size() && !belongsToNumber(line[endOfGap])) { + while (endOfGap < line.size() && !belongsToNumber(line[endOfGap])) endOfGap++; - } QStringRef gapContent(&line, startOfGap, endOfGap - startOfGap); if (gapContent.isEmpty()) diff --git a/GUI/coregui/DataLoaders/QREDataLoader.h b/GUI/coregui/DataLoaders/QREDataLoader.h index 112dab4c05a..ce7aefd5136 100644 --- a/GUI/coregui/DataLoaders/QREDataLoader.h +++ b/GUI/coregui/DataLoaders/QREDataLoader.h @@ -22,7 +22,9 @@ class QString; class QREDataLoaderProperties; -//! Real data loader for Q/R/E reflectometry CSV files +//! Loader for experimental reflectometry CSV files that contain +//! three columns with Q,R,E, namely +//! Q = wavenumber, R = reflectivity, E = error of R. class QREDataLoader : public AbstractDataLoader1D { public: @@ -53,10 +55,10 @@ private: enum class UnitInFile { none, perNanoMeter, perAngstrom, other }; struct ColumnDefinition { - bool enabled; //< shall data type be used - int column; //< read the value from this raw column - UnitInFile unit; //< the unit of the data in the file - double factor; //< in case the raw data shall be multiplied + bool enabled; //!< shall data type be used + int column; //!< read the value from this raw column + UnitInFile unit; //!< the unit of the data in the file + double factor; //!< in case the raw data shall be multiplied bool operator==(const ColumnDefinition& other) const; }; -- GitLab