diff --git a/GUI/coregui/Models/IntensityDataItem.cpp b/GUI/coregui/Models/IntensityDataItem.cpp index a5896a1a1c4e128f032b66df391c6e077111191e..a532a7cb5a564cab8f45c1e90b807be11b6fb37e 100644 --- a/GUI/coregui/Models/IntensityDataItem.cpp +++ b/GUI/coregui/Models/IntensityDataItem.cpp @@ -246,6 +246,11 @@ void IntensityDataItem::reset(ImportDataInfo data) converter.convertFromNbins(this); } +bool IntensityDataItem::isInterpolatedPropertyName(const QString& name) +{ + return name == P_IS_INTERPOLATED; +} + void IntensityDataItem::setLowerX(double value) { xAxisItem()->setLowerBound(value); diff --git a/GUI/coregui/Models/IntensityDataItem.h b/GUI/coregui/Models/IntensityDataItem.h index 03e4621f6269be6067c7c3119a8d8eb401ccb0d1..d789c64a83b9294b295a0758231b7227b3f4a8b0 100644 --- a/GUI/coregui/Models/IntensityDataItem.h +++ b/GUI/coregui/Models/IntensityDataItem.h @@ -26,9 +26,9 @@ class BA_CORE_API_ IntensityDataItem : public DataItem { private: static const QString P_PROJECTIONS; static const QString P_TITLE; + static const QString P_IS_INTERPOLATED; public: - static const QString P_IS_INTERPOLATED; static const QString P_GRADIENT; static const QString P_XAXIS; static const QString P_YAXIS; @@ -106,6 +106,8 @@ public: //! Returns data to the state defined by user (imported) data. void reset(ImportDataInfo data) override; + static bool isInterpolatedPropertyName(const QString& name); + public slots: void setLowerX(double value); void setUpperX(double value); diff --git a/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.cpp b/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.cpp index 8dae9d128a4d64e593f264f2842c7e298c952f5e..7435cc984453bee77d82a79264177efbcaf5f266 100644 --- a/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/DetectorMaskDelegate.cpp @@ -58,7 +58,7 @@ void DetectorMaskDelegate::createIntensityDataItem() m_tempIntensityDataModel->clear(); m_intensityItem = m_tempIntensityDataModel->insertItem<IntensityDataItem>(); m_intensityItem->projectionsItem()->setEnabled(false); - m_intensityItem->setItemValue(IntensityDataItem::P_IS_INTERPOLATED, false); + m_intensityItem->setInterpolated(false); auto zAxisItem = m_intensityItem->zAxisItem(); zAxisItem->setItemValue(BasicAxisItem::P_IS_VISIBLE, false); diff --git a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp index 38878e917e0363888de906c3b2e6f2d11e78ae25..b288b85898a9f1f75fbefcd8ebdc9baf555bd564 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ColorMap.cpp @@ -112,7 +112,7 @@ void ColorMap::onPropertyChanged(const QString& property_name) if (property_name == IntensityDataItem::P_GRADIENT) { m_colorMap->setGradient(ColorMapUtils::itemGradient(intensityItem())); replot(); - } else if (property_name == IntensityDataItem::P_IS_INTERPOLATED) { + } else if (IntensityDataItem::isInterpolatedPropertyName(property_name)) { m_colorMap->setInterpolate(intensityItem()->isInterpolated()); replot(); } else if (DataItem::isAxesUnitsPropertyName(property_name)) { diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp index 92d36cd209208d9ddc86320c2acf1bdc5394f1a1..fbdad3aae014ec59bf40ef959a8f2399c5692b7c 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp @@ -38,7 +38,7 @@ QString gradient_setting_name() } QString interpolation_setting_name() { - return group_name() + IntensityDataItem::P_IS_INTERPOLATED; + return group_name() + "Interpolation"; } } // namespace @@ -142,7 +142,7 @@ void IntensityDataCanvas::onPropertyChanged(const QString& name) if (name == IntensityDataItem::P_GRADIENT) { QSettings settings; settings.setValue(gradient_setting_name(), intensityDataItem()->getGradient()); - } else if (name == IntensityDataItem::P_IS_INTERPOLATED) { + } else if (IntensityDataItem::isInterpolatedPropertyName(name)) { QSettings settings; settings.setValue(interpolation_setting_name(), intensityDataItem()->isInterpolated()); } @@ -166,6 +166,6 @@ void IntensityDataCanvas::applyPersistentSettings() if (settings.contains(interpolation_setting_name())) { bool value = settings.value(interpolation_setting_name()).toBool(); - intensityDataItem()->setItemValue(IntensityDataItem::P_IS_INTERPOLATED, value); + intensityDataItem()->setInterpolated(value); } } diff --git a/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.cpp b/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.cpp index 5e02ae0b3f299a9e6c945b9e6d8b6faf2d1342ed..13367741992702c23ee346eadf98ed835176fe51 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/ProjectionsPlot.cpp @@ -244,7 +244,7 @@ void ProjectionsPlot::clearProjection(SessionItem* item) void ProjectionsPlot::onIntensityItemPropertyChanged(const QString& propertyName) { - if (propertyName == IntensityDataItem::P_IS_INTERPOLATED) { + if (IntensityDataItem::isInterpolatedPropertyName(propertyName)) { setInterpolate(intensityItem()->isInterpolated()); replot(); } diff --git a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp index 9a5214ba867b88ee1e712a45fc8a0f295fb235b0..46c9ae827f986f0f898f914063e81e962434feb5 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp @@ -59,7 +59,7 @@ void MaskResultsPresenter::setShowMaskMode() if (OutputData<double>* maskedData = createMaskPresentation()) { backup_data(); m_intensityDataItem->setOutputData(maskedData); - m_intensityDataItem->setItemValue(IntensityDataItem::P_IS_INTERPOLATED, false); + m_intensityDataItem->setInterpolated(false); } else { m_dataBackup.reset(); } @@ -71,15 +71,13 @@ void MaskResultsPresenter::setOriginalMode() { if (m_dataBackup) { m_intensityDataItem->setOutputData(m_dataBackup->clone()); - m_intensityDataItem->setItemValue(IntensityDataItem::P_IS_INTERPOLATED, - m_interpolation_flag_backup); + m_intensityDataItem->setInterpolated(m_interpolation_flag_backup); } } void MaskResultsPresenter::backup_data() { - m_interpolation_flag_backup = - m_intensityDataItem->getItemValue(IntensityDataItem::P_IS_INTERPOLATED).toBool(); + m_interpolation_flag_backup = m_intensityDataItem->isInterpolated(); m_dataBackup.reset(m_intensityDataItem->getOutputData()->clone()); } diff --git a/Tests/UnitTests/GUI/TestPropertyRepeater.cpp b/Tests/UnitTests/GUI/TestPropertyRepeater.cpp index 65d498048c87ef21c4193c741310bf080b2257b4..2a3e9667e87b0728da3384ab829376b240ed8ada 100644 --- a/Tests/UnitTests/GUI/TestPropertyRepeater.cpp +++ b/Tests/UnitTests/GUI/TestPropertyRepeater.cpp @@ -84,8 +84,8 @@ TEST_F(TestPropertyRepeater, test_repeatAll) { SessionModel model("test"); - auto item1 = createData(model); - auto item2 = createData(model); + IntensityDataItem* item1 = createData(model); + IntensityDataItem* item2 = createData(model); item1->xAxisItem()->setItemValue(BasicAxisItem::P_MAX_DEG, 2.0); item2->xAxisItem()->setItemValue(BasicAxisItem::P_MAX_DEG, 3.0); @@ -96,8 +96,8 @@ TEST_F(TestPropertyRepeater, test_repeatAll) repeater.addItem(item2); // adding items to the repeater do not change values - EXPECT_EQ(item1->getItemValue(IntensityDataItem::P_IS_INTERPOLATED).toBool(), true); - EXPECT_EQ(item2->getItemValue(IntensityDataItem::P_IS_INTERPOLATED).toBool(), true); + EXPECT_TRUE(item1->isInterpolated()); + EXPECT_TRUE(item2->isInterpolated()); EXPECT_EQ(item1->getUpperX(), 2.0); EXPECT_EQ(item2->getUpperX(), 3.0); @@ -106,9 +106,9 @@ TEST_F(TestPropertyRepeater, test_repeatAll) EXPECT_EQ(item1->getUpperX(), 4.0); EXPECT_EQ(item2->getUpperX(), 4.0); - item1->setItemValue(IntensityDataItem::P_IS_INTERPOLATED, false); - EXPECT_EQ(item1->getItemValue(IntensityDataItem::P_IS_INTERPOLATED).toBool(), false); - EXPECT_EQ(item2->getItemValue(IntensityDataItem::P_IS_INTERPOLATED).toBool(), false); + item1->setInterpolated(false); + EXPECT_FALSE(item1->isInterpolated()); + EXPECT_FALSE(item2->isInterpolated()); // clearing repeater will stop update repeater.clear();