From bd86edbeb0ca925870cc0147cdbca12e471f33cc Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de> Date: Mon, 26 Apr 2021 15:35:36 +0200 Subject: [PATCH] m_units -> m_coords --- GUI/coregui/Models/DataViewUtils.cpp | 2 +- GUI/coregui/Models/InstrumentItems.cpp | 2 +- GUI/coregui/Models/JobItemUtils.cpp | 12 ++++++------ GUI/coregui/Models/JobItemUtils.h | 2 +- .../CsvImportAssistant/CsvDataColumn.cpp | 10 +++++----- .../CsvImportAssistant/CsvDataColumn.h | 2 +- .../CsvImportAssistant/CsvImportAssistant.cpp | 14 +++++++------- .../CsvImportAssistant/CsvImportAssistant.h | 6 +++--- GUI/coregui/utils/ImportDataInfo.cpp | 12 ++++++------ GUI/coregui/utils/ImportDataInfo.h | 2 +- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/GUI/coregui/Models/DataViewUtils.cpp b/GUI/coregui/Models/DataViewUtils.cpp index ce55c873214..d2370881bc5 100644 --- a/GUI/coregui/Models/DataViewUtils.cpp +++ b/GUI/coregui/Models/DataViewUtils.cpp @@ -36,7 +36,7 @@ Axes::Coords selectedUnits(Data1DViewItem* view_item) { auto current_unit_name = view_item->getItemValue(Data1DViewItem::P_AXES_UNITS).value<ComboProperty>().getValue(); - return JobItemUtils::axesUnitsFromName(current_unit_name); + return JobItemUtils::coordsFromName(current_unit_name); } } // namespace diff --git a/GUI/coregui/Models/InstrumentItems.cpp b/GUI/coregui/Models/InstrumentItems.cpp index 8491d1697df..840078fc34a 100644 --- a/GUI/coregui/Models/InstrumentItems.cpp +++ b/GUI/coregui/Models/InstrumentItems.cpp @@ -209,7 +209,7 @@ std::unique_ptr<ICoordSystem> SpecularInstrumentItem::createCoordSystem() const if (auto pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) { if (!pointwise_axis->containsNonXMLData()) // workaround for loading project return nullptr; - Axes::Coords native_units = JobItemUtils::axesUnitsFromName(pointwise_axis->getUnitsLabel()); + Axes::Coords native_units = JobItemUtils::coordsFromName(pointwise_axis->getUnitsLabel()); return std::make_unique<AngularReflectometryConverter>( instrument->beam(), *pointwise_axis->axis(), native_units); } else diff --git a/GUI/coregui/Models/JobItemUtils.cpp b/GUI/coregui/Models/JobItemUtils.cpp index 2a88c7bf53c..4bed3d3b9cd 100644 --- a/GUI/coregui/Models/JobItemUtils.cpp +++ b/GUI/coregui/Models/JobItemUtils.cpp @@ -31,7 +31,7 @@ const std::map<QString, Axes::Coords> units_from_names{{"nbins", Axes::Coords::N {"mm", Axes::Coords::MM}, {"q-space", Axes::Coords::QSPACE}}; -const std::map<Axes::Coords, QString> names_from_units{{Axes::Coords::NBINS, "nbins"}, +const std::map<Axes::Coords, QString> names_from_coords{{Axes::Coords::NBINS, "nbins"}, {Axes::Coords::RADIANS, "Radians"}, {Axes::Coords::MM, "mm"}, {Axes::Coords::QSPACE, "q-space"}, @@ -65,7 +65,7 @@ void JobItemUtils::updateDataAxes(DataItem* intensityItem, const InstrumentItem* if (!intensityItem->getOutputData()) return; - Axes::Coords requested_units = axesUnitsFromName(intensityItem->selectedCoords()); + Axes::Coords requested_units = coordsFromName(intensityItem->selectedCoords()); const auto converter = instrumentItem->createCoordSystem(); auto newData = converter->createOutputData(requested_units); @@ -80,15 +80,15 @@ void JobItemUtils::updateDataAxes(DataItem* intensityItem, const InstrumentItem* QString JobItemUtils::nameFromCoords(Axes::Coords units) { - const auto it = names_from_units.find(units); - if (it == names_from_units.end()) + const auto it = names_from_coords.find(units); + if (it == names_from_coords.end()) return ""; return it->second; } //! Correspondence of GUI axes units names to their domain counterpart. -Axes::Coords JobItemUtils::axesUnitsFromName(const QString& name) +Axes::Coords JobItemUtils::coordsFromName(const QString& name) { return units_from_names.at(name); } @@ -129,7 +129,7 @@ void JobItemUtils::setResults(DataItem* intensityItem, const ISimulation* simula JobItemUtils::setIntensityItemCoords(intensityItem, converter); updateAxesTitle(intensityItem, converter, converter.defaultUnits()); } - auto selected_units = JobItemUtils::axesUnitsFromName(intensityItem->selectedCoords()); + auto selected_units = JobItemUtils::coordsFromName(intensityItem->selectedCoords()); auto data = sim_result.data(selected_units); intensityItem->setOutputData(data.release()); } diff --git a/GUI/coregui/Models/JobItemUtils.h b/GUI/coregui/Models/JobItemUtils.h index 293fdf68735..b9fd3b6da81 100644 --- a/GUI/coregui/Models/JobItemUtils.h +++ b/GUI/coregui/Models/JobItemUtils.h @@ -37,7 +37,7 @@ void updateDataAxes(DataItem* intensityItem, const InstrumentItem* instrumentIte QString nameFromCoords(Axes::Coords units); //! returns domain axes units type from their GUI name -Axes::Coords axesUnitsFromName(const QString& name); +Axes::Coords coordsFromName(const QString& name); void setIntensityItemCoords(DataItem* intensityItem, const InstrumentItem* instrumentItem); diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp index bf652ba20a5..6b695c245a8 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.cpp @@ -66,23 +66,23 @@ void CsvIntensityColumn::resetColumn(int colNum, double multiplier, csv::DataCol /*Csv Coordinate Column*/ // Constructors: -CsvCoordinateColumn::CsvCoordinateColumn() : CsvIntensityColumn(), m_units(Axes::Coords::NBINS) {} +CsvCoordinateColumn::CsvCoordinateColumn() : CsvIntensityColumn(), m_coords(Axes::Coords::NBINS) {} CsvCoordinateColumn::CsvCoordinateColumn(const CsvCoordinateColumn& toCopy) - : CsvIntensityColumn(toCopy), m_units(toCopy.units()) + : CsvIntensityColumn(toCopy), m_coords(toCopy.units()) { } CsvCoordinateColumn::CsvCoordinateColumn(int colNum, double multiplier, csv::DataColumn values, Axes::Coords units) - : CsvIntensityColumn(colNum, multiplier, values), m_units(units) + : CsvIntensityColumn(colNum, multiplier, values), m_coords(units) { } Axes::Coords CsvCoordinateColumn::units() const { - return m_units; + return m_coords; } void CsvCoordinateColumn::setName(csv::ColumnType const name) @@ -93,6 +93,6 @@ void CsvCoordinateColumn::resetColumn(int colNum, double multiplier, csv::DataCo Axes::Coords units, csv::ColumnType name) { CsvIntensityColumn::resetColumn(colNum, multiplier, values); - m_units = units; + m_coords = units; m_name = name; } diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h index e6511158208..103e7c43df0 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h @@ -60,7 +60,7 @@ public: csv::ColumnType name = csv::_intensity_); private: - Axes::Coords m_units; + Axes::Coords m_coords; csv::ColumnType m_name; }; diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp index a72c6ba34ed..65bfb4a5e3d 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.cpp @@ -39,7 +39,7 @@ CsvImportAssistant::CsvImportAssistant(const QString& file, const bool useGUI, Q , m_coordinateMultiplier(1.0) , m_firstRow(-1) , m_lastRow(-1) - , m_units(Axes::Coords::NBINS) + , m_coords(Axes::Coords::NBINS) , m_dataAvailable(false) { if (!loadCsvFile()) { @@ -51,7 +51,7 @@ CsvImportAssistant::CsvImportAssistant(const QString& file, const bool useGUI, Q } else { m_intensityColNum = 0; m_coordinateColNum = -1; - m_units = Axes::Coords::NBINS; + m_coords = Axes::Coords::NBINS; m_firstRow = 0; m_lastRow = int(m_csvFile->NumberOfRows() - 1); m_dataAvailable = true; @@ -79,7 +79,7 @@ void CsvImportAssistant::runDataSelector(QWidget* parent) m_intensityMultiplier = selector.intensityMultiplier(); m_coordinateColNum = selector.coordinateColumn(); m_coordinateMultiplier = selector.coordinateMultiplier(); - m_units = selector.units(); + m_coords = selector.units(); m_firstRow = int(selector.firstLine() - 1); m_lastRow = int(selector.lastLine() - 1); m_rowsToDiscard = selector.rowsToDiscard(); @@ -98,7 +98,7 @@ void CsvImportAssistant::setIntensityColumn(int iCol, double multiplier) void CsvImportAssistant::setCoordinateColumn(int iCol, Axes::Coords units, double multiplier) { m_coordinateColNum = iCol - 1; - m_units = units; + m_coords = units; m_coordinateMultiplier = multiplier; } void CsvImportAssistant::setFirstRow(int iRow) @@ -175,12 +175,12 @@ ImportDataInfo CsvImportAssistant::fillData() getValuesFromColumns(intensityValues, coordinateValues); - const auto axisName = axisUnitLabel.at(m_units); + const auto axisName = axisUnitLabel.at(m_coords); PointwiseAxis coordAxis(axisName, coordinateValues); resultOutputData->addAxis(coordAxis); resultOutputData->setRawDataVector(intensityValues); - ImportDataInfo result(std::move(resultOutputData), m_units); + ImportDataInfo result(std::move(resultOutputData), m_coords); return result; } @@ -384,6 +384,6 @@ void CsvImportAssistant::resetSelection() m_coordinateColNum = -1; m_firstRow = -1; m_lastRow = -1; - m_units = Axes::Coords::NBINS; + m_coords = Axes::Coords::NBINS; m_dataAvailable = false; } diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h index 231069f1405..8eafac7e029 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h @@ -33,7 +33,7 @@ public: , m_coordinateMultiplier(1.) , m_firstRow(-1) , m_lastRow(-1) - , m_units(Axes::Coords::NBINS) + , m_coords(Axes::Coords::NBINS) { } @@ -43,7 +43,7 @@ public: double m_coordinateMultiplier; int m_firstRow; int m_lastRow; - Axes::Coords m_units; + Axes::Coords m_coords; bool availableData() { return m_intensityColNum > -1; } }; @@ -84,7 +84,7 @@ private: int m_firstRow; int m_lastRow; std::set<int> m_rowsToDiscard; - Axes::Coords m_units; + Axes::Coords m_coords; bool m_dataAvailable; }; #endif // BORNAGAIN_GUI_COREGUI_VIEWS_IMPORTDATAWIDGETS_CSVIMPORTASSISTANT_CSVIMPORTASSISTANT_H diff --git a/GUI/coregui/utils/ImportDataInfo.cpp b/GUI/coregui/utils/ImportDataInfo.cpp index 67274ab9653..7f3c86006e4 100644 --- a/GUI/coregui/utils/ImportDataInfo.cpp +++ b/GUI/coregui/utils/ImportDataInfo.cpp @@ -33,20 +33,20 @@ std::map<size_t, std::vector<Axes::Coords>> available_units = {{1u, specularUnit } // namespace ImportDataInfo::ImportDataInfo(ImportDataInfo&& other) - : m_data(std::move(other.m_data)), m_units(other.m_units) + : m_data(std::move(other.m_data)), m_coords(other.m_coords) { } ImportDataInfo::ImportDataInfo(std::unique_ptr<OutputData<double>> data, Axes::Coords units) : m_data(units == Axes::Coords::NBINS && data ? ImportDataUtils::binifyAxes(*data) : std::move(data)) - , m_units(units) + , m_coords(units) { checkValidity(); } ImportDataInfo::ImportDataInfo(std::unique_ptr<OutputData<double>> data, const QString& units_label) - : m_data(std::move(data)), m_units(JobItemUtils::axesUnitsFromName(units_label)) + : m_data(std::move(data)), m_coords(JobItemUtils::coordsFromName(units_label)) { checkValidity(); } @@ -85,7 +85,7 @@ size_t ImportDataInfo::dataRank() const QString ImportDataInfo::unitsLabel() const { - return JobItemUtils::nameFromCoords(m_units); + return JobItemUtils::nameFromCoords(m_coords); } QString ImportDataInfo::axisLabel(size_t axis_index) const @@ -99,7 +99,7 @@ QString ImportDataInfo::axisLabel(size_t axis_index) const else if (rank == 1) { if (axis_index > 0) return "Signal [a.u.]"; - return QString::fromStdString(AxisNames::specAxis.at(m_units)); + return QString::fromStdString(AxisNames::specAxis.at(m_coords)); } throw GUIHelpers::Error("Error in ImportDataInfo::axisLabel: unsupported data type"); } @@ -112,7 +112,7 @@ void ImportDataInfo::checkValidity() if (iter == available_units.end()) throw GUIHelpers::Error("Error in ImportDataInfo constructor: unsupported data type"); for (auto& value : iter->second) - if (m_units == value) + if (m_coords == value) return; throw GUIHelpers::Error("Error in ImportDataInfo constructor: inacceptable units passed."); diff --git a/GUI/coregui/utils/ImportDataInfo.h b/GUI/coregui/utils/ImportDataInfo.h index 6649eb07f8c..bd4489e727b 100644 --- a/GUI/coregui/utils/ImportDataInfo.h +++ b/GUI/coregui/utils/ImportDataInfo.h @@ -49,7 +49,7 @@ private: private: std::unique_ptr<OutputData<double>> m_data; - Axes::Coords m_units; + Axes::Coords m_coords; }; #endif // BORNAGAIN_GUI_COREGUI_UTILS_IMPORTDATAINFO_H -- GitLab