Skip to content
Snippets Groups Projects
Commit 5e1101ab authored by t.knopff's avatar t.knopff
Browse files

Make IntensityDataItem::P_IS_INTERPOLATED private

parent 6948c609
No related branches found
No related tags found
1 merge request!66Refactor model2: improve interface of IntensityDataItem
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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)) {
......
......@@ -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);
}
}
......@@ -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();
}
......
......@@ -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());
}
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment