Commit d95dd39c authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

[i88g] GUI: change data items signaling in IntensityDataPropertyWidget ()

Merging branch 'i88g'  into 'main'.

See merge request !955
parents 18aca57d 89b869aa
Pipeline #67482 failed with stage
in 5 minutes and 48 seconds
...@@ -158,6 +158,7 @@ double SphericalCoords::calculateValue(size_t i_axis, Coords units, double value ...@@ -158,6 +158,7 @@ double SphericalCoords::calculateValue(size_t i_axis, Coords units, double value
return (k_f - k_i).z(); return (k_f - k_i).z();
} }
ASSERT(0); ASSERT(0);
return 0;
} }
case Coords::QXQY: { case Coords::QXQY: {
const R3 k_i = vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i); const R3 k_i = vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i);
...@@ -170,6 +171,7 @@ double SphericalCoords::calculateValue(size_t i_axis, Coords units, double value ...@@ -170,6 +171,7 @@ double SphericalCoords::calculateValue(size_t i_axis, Coords units, double value
return (k_f - k_i).x(); return (k_f - k_i).x();
} }
ASSERT(0); ASSERT(0);
return 0;
} }
default: default:
ASSERT(0); ASSERT(0);
......
...@@ -200,7 +200,7 @@ class GroupInfo; ...@@ -200,7 +200,7 @@ class GroupInfo;
//! \endcode //! \endcode
//! //!
//! This code part again shows the (highly error-prone) string-based type checking. //! This code part again shows the (highly error-prone) string-based type checking.
//#define USE_MAPPERS
class BA_CORE_API_ SessionItem { class BA_CORE_API_ SessionItem {
friend class SessionModel; friend class SessionModel;
......
...@@ -24,6 +24,9 @@ void DataItem::setDatafield(Datafield* data) ...@@ -24,6 +24,9 @@ void DataItem::setDatafield(Datafield* data)
setLastModified(QDateTime::currentDateTime()); setLastModified(QDateTime::currentDateTime());
emit datafieldChanged(data); emit datafieldChanged(data);
#ifdef USE_MAPPERS
emitDataChanged();
#endif
} }
void DataItem::setRawDataVector(const std::vector<double>& data) void DataItem::setRawDataVector(const std::vector<double>& data)
...@@ -36,6 +39,9 @@ void DataItem::setRawDataVector(const std::vector<double>& data) ...@@ -36,6 +39,9 @@ void DataItem::setRawDataVector(const std::vector<double>& data)
setLastModified(QDateTime::currentDateTime()); setLastModified(QDateTime::currentDateTime());
emit rawDataVectorChanged(data); emit rawDataVectorChanged(data);
#ifdef USE_MAPPERS
emitDataChanged();
#endif
} }
QString DataItem::fileName() const QString DataItem::fileName() const
...@@ -96,18 +102,18 @@ QString DataItem::selectedCoords() const ...@@ -96,18 +102,18 @@ QString DataItem::selectedCoords() const
void DataItem::setAxesUnits(const ComboProperty& units) void DataItem::setAxesUnits(const ComboProperty& units)
{ {
setItemValue(P_AXES_UNITS, units.variant()); setItemValue(P_AXES_UNITS, units.variant());
emit axesUnitsChanged(units);
}
SessionItem* DataItem::getAxesUnitsItem() const
{
return getItem(P_AXES_UNITS);
} }
SelectionDescriptor<QString> DataItem::axesUnits() const SelectionDescriptor<QString> DataItem::axesUnits() const
{ {
return SelectionDescriptor<QString>(getItem(P_AXES_UNITS)); SelectionDescriptor<QString> d = SelectionDescriptor<QString>(getItem(P_AXES_UNITS));
// temporary setter with signal
d.currentIndexSetter = [=](int index) {
d.currentIndexSetter(index);
emit const_cast<DataItem*>(this)->axesUnitsChanged();
};
return d;
} }
bool DataItem::isAxesUnitsPropertyName(const QString& name) bool DataItem::isAxesUnitsPropertyName(const QString& name)
...@@ -130,5 +136,5 @@ DataItem::DataItem(const QString& modelType) ...@@ -130,5 +136,5 @@ DataItem::DataItem(const QString& modelType)
// name of the file used to serialize given IntensityDataItem // name of the file used to serialize given IntensityDataItem
addProperty(P_FILE_NAME, "undefined"); addProperty(P_FILE_NAME, "undefined");
addProperty(P_AXES_UNITS, ComboProperty::fromList({"nbins"}).variant()); addProperty(P_AXES_UNITS, ComboProperty::fromList({"nbins"}).variant());
} }
...@@ -61,7 +61,6 @@ public: ...@@ -61,7 +61,6 @@ public:
QString selectedCoords() const; QString selectedCoords() const;
void setAxesUnits(const ComboProperty& units); void setAxesUnits(const ComboProperty& units);
SessionItem* getAxesUnitsItem() const;
SelectionDescriptor<QString> axesUnits() const; SelectionDescriptor<QString> axesUnits() const;
static bool isAxesUnitsPropertyName(const QString& name); static bool isAxesUnitsPropertyName(const QString& name);
static void updateAxesUnits(SessionItem* item, const QString& name, static void updateAxesUnits(SessionItem* item, const QString& name,
...@@ -80,7 +79,8 @@ signals: ...@@ -80,7 +79,8 @@ signals:
void datafieldChanged(Datafield* data); void datafieldChanged(Datafield* data);
void rawDataVectorChanged(const std::vector<double>& data); void rawDataVectorChanged(const std::vector<double>& data);
void fileNameChanged(const QString& filename); void fileNameChanged(const QString& filename);
void axesUnitsChanged(const ComboProperty& units); void axesUnitsChanged();
void axesUnitsReplotRequested();
protected: protected:
explicit DataItem(const QString& modelType); explicit DataItem(const QString& modelType);
......
...@@ -79,8 +79,9 @@ void IntensityDataItem::setDatafield(Datafield* data) ...@@ -79,8 +79,9 @@ void IntensityDataItem::setDatafield(Datafield* data)
updateAxesZoomLevel(); updateAxesZoomLevel();
updateAxesLabels(); updateAxesLabels();
updateDataRange(); updateDataRange();
#ifdef USE_MAPPERS
emitDataChanged(); emitDataChanged();
#endif
} }
int IntensityDataItem::xSize() const int IntensityDataItem::xSize() const
...@@ -164,7 +165,14 @@ void IntensityDataItem::setGradient(const ComboProperty& gradient) ...@@ -164,7 +165,14 @@ void IntensityDataItem::setGradient(const ComboProperty& gradient)
SelectionDescriptor<QString> IntensityDataItem::gradient() const SelectionDescriptor<QString> IntensityDataItem::gradient() const
{ {
return SelectionDescriptor<QString>(getItem(P_GRADIENT)); SelectionDescriptor<QString> d = SelectionDescriptor<QString>(getItem(P_GRADIENT));
// temporary setter with signal
d.currentIndexSetter = [=](int index) {
d.currentIndexSetter(index);
emit const_cast<IntensityDataItem*>(this)->gradientChanged();
};
return d;
} }
bool IntensityDataItem::isLogz() const bool IntensityDataItem::isLogz() const
...@@ -273,21 +281,25 @@ bool IntensityDataItem::isZaxisPropertyName(const QString& name) ...@@ -273,21 +281,25 @@ bool IntensityDataItem::isZaxisPropertyName(const QString& name)
void IntensityDataItem::setLowerX(double value) void IntensityDataItem::setLowerX(double value)
{ {
xAxisItem()->setLowerBound(value); xAxisItem()->setLowerBound(value);
emit axesRangeChangedFromPlot();
} }
void IntensityDataItem::setUpperX(double value) void IntensityDataItem::setUpperX(double value)
{ {
xAxisItem()->setUpperBound(value); xAxisItem()->setUpperBound(value);
emit axesRangeChangedFromPlot();
} }
void IntensityDataItem::setLowerY(double value) void IntensityDataItem::setLowerY(double value)
{ {
yAxisItem()->setLowerBound(value); yAxisItem()->setLowerBound(value);
emit axesRangeChangedFromPlot();
} }
void IntensityDataItem::setUpperY(double value) void IntensityDataItem::setUpperY(double value)
{ {
yAxisItem()->setUpperBound(value); yAxisItem()->setUpperBound(value);
emit axesRangeChangedFromPlot();
} }
void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax) void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax)
...@@ -302,11 +314,13 @@ void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax) ...@@ -302,11 +314,13 @@ void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax)
void IntensityDataItem::setLowerZ(double zmin) void IntensityDataItem::setLowerZ(double zmin)
{ {
zAxisItem()->setLowerBound(zmin); zAxisItem()->setLowerBound(zmin);
emit axesRangeChangedFromPlot();
} }
void IntensityDataItem::setUpperZ(double zmax) void IntensityDataItem::setUpperZ(double zmax)
{ {
zAxisItem()->setUpperBound(zmax); zAxisItem()->setUpperBound(zmax);
emit axesRangeChangedFromPlot();
} }
void IntensityDataItem::setLogz(bool logz) void IntensityDataItem::setLogz(bool logz)
...@@ -317,6 +331,7 @@ void IntensityDataItem::setLogz(bool logz) ...@@ -317,6 +331,7 @@ void IntensityDataItem::setLogz(bool logz)
void IntensityDataItem::setInterpolated(bool interp) void IntensityDataItem::setInterpolated(bool interp)
{ {
setItemValue(P_IS_INTERPOLATED, interp); setItemValue(P_IS_INTERPOLATED, interp);
emit interpolationChanged();
} }
//! Sets zoom range of X,Y axes, if it was not yet defined. //! Sets zoom range of X,Y axes, if it was not yet defined.
......
...@@ -24,6 +24,7 @@ class MaskContainerItem; ...@@ -24,6 +24,7 @@ class MaskContainerItem;
class ProjectionContainerItem; class ProjectionContainerItem;
class BA_CORE_API_ IntensityDataItem : public DataItem { class BA_CORE_API_ IntensityDataItem : public DataItem {
Q_OBJECT
private: private:
static constexpr auto P_PROJECTIONS{"Projections"}; static constexpr auto P_PROJECTIONS{"Projections"};
static constexpr auto P_TITLE{"Title"}; static constexpr auto P_TITLE{"Title"};
...@@ -120,6 +121,13 @@ public: ...@@ -120,6 +121,13 @@ public:
static bool isYaxisPropertyName(const QString& name); static bool isYaxisPropertyName(const QString& name);
static bool isZaxisPropertyName(const QString& name); static bool isZaxisPropertyName(const QString& name);
signals:
void gradientChanged();
void interpolationChanged();
void axesRangeChangedFromPlot();
void updateOtherPlots();
void updateThisPlot();
public slots: public slots:
void setLowerX(double value); void setLowerX(double value);
void setUpperX(double value); void setUpperX(double value);
......
...@@ -42,6 +42,11 @@ DoubleDescriptor BasicAxisItem::min(const QString& unit) const ...@@ -42,6 +42,11 @@ DoubleDescriptor BasicAxisItem::min(const QString& unit) const
{ {
DoubleDescriptor d(getItem(P_MIN_DEG), unit); DoubleDescriptor d(getItem(P_MIN_DEG), unit);
d.label = "Min"; d.label = "Min";
// temp setter with signal
d.set = [=](double v) {
d.set(v);
emit const_cast<BasicAxisItem*>(this)->axisRangeChanged();
};
return d; return d;
} }
...@@ -59,6 +64,11 @@ DoubleDescriptor BasicAxisItem::max(const QString& unit) const ...@@ -59,6 +64,11 @@ DoubleDescriptor BasicAxisItem::max(const QString& unit) const
{ {
DoubleDescriptor d(getItem(P_MAX_DEG), unit); DoubleDescriptor d(getItem(P_MAX_DEG), unit);
d.label = "Max"; d.label = "Max";
// temp setter with signal
d.set = [=](double v) {
d.set(v);
emit const_cast<BasicAxisItem*>(this)->axisRangeChanged();
};
return d; return d;
} }
...@@ -85,6 +95,7 @@ QString BasicAxisItem::title() const ...@@ -85,6 +95,7 @@ QString BasicAxisItem::title() const
void BasicAxisItem::setTitle(const QString& title) void BasicAxisItem::setTitle(const QString& title)
{ {
setItemValue(P_TITLE, title); setItemValue(P_TITLE, title);
emit axisTitleChanged();
} }
SessionItem* BasicAxisItem::titleItem() const SessionItem* BasicAxisItem::titleItem() const
...@@ -118,7 +129,7 @@ SessionItem* BasicAxisItem::visibilityItem() const ...@@ -118,7 +129,7 @@ SessionItem* BasicAxisItem::visibilityItem() const
return getItem(P_IS_VISIBLE); return getItem(P_IS_VISIBLE);
} }
bool BasicAxisItem::visibilityValue() const bool BasicAxisItem::isVisible() const
{ {
return visibilityItem()->value().toBool(); return visibilityItem()->value().toBool();
} }
...@@ -126,6 +137,7 @@ bool BasicAxisItem::visibilityValue() const ...@@ -126,6 +137,7 @@ bool BasicAxisItem::visibilityValue() const
void BasicAxisItem::setVisibilityValue(bool b) void BasicAxisItem::setVisibilityValue(bool b)
{ {
setItemValue(P_IS_VISIBLE, b); setItemValue(P_IS_VISIBLE, b);
emit axisVisibilityChanged();
} }
bool BasicAxisItem::isVisibilityPropertyName(const QString& name) bool BasicAxisItem::isVisibilityPropertyName(const QString& name)
...@@ -183,6 +195,7 @@ bool AmplitudeAxisItem::isLogScale() const ...@@ -183,6 +195,7 @@ bool AmplitudeAxisItem::isLogScale() const
void AmplitudeAxisItem::setLogScale(bool value) void AmplitudeAxisItem::setLogScale(bool value)
{ {
setItemValue(P_IS_LOGSCALE, value); setItemValue(P_IS_LOGSCALE, value);
emit logScaleChanged();
} }
SessionItem* AmplitudeAxisItem::logScaleItem() const SessionItem* AmplitudeAxisItem::logScaleItem() const
......
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
class IAxis; class IAxis;
class Streamer; class Streamer;
class BasicAxisItem : public SessionItem { class BasicAxisItem : public QObject, public SessionItem {
Q_OBJECT
private: private:
static constexpr auto P_IS_VISIBLE{"Visibility"}; static constexpr auto P_IS_VISIBLE{"Visibility"};
static constexpr auto P_NBINS{"Nbins"}; static constexpr auto P_NBINS{"Nbins"};
...@@ -64,15 +65,21 @@ public: ...@@ -64,15 +65,21 @@ public:
virtual std::unique_ptr<IAxis> createAxis(double scale) const; virtual std::unique_ptr<IAxis> createAxis(double scale) const;
SessionItem* visibilityItem() const; SessionItem* visibilityItem() const;
bool visibilityValue() const; bool isVisible() const;
void setVisibilityValue(bool b); void setVisibilityValue(bool b);
static bool isVisibilityPropertyName(const QString& name); static bool isVisibilityPropertyName(const QString& name);
signals:
void axisRangeChanged();
void axisTitleChanged();
void axisVisibilityChanged();
protected: protected:
explicit BasicAxisItem(const QString& type); explicit BasicAxisItem(const QString& type);
}; };
class AmplitudeAxisItem : public BasicAxisItem { class AmplitudeAxisItem : public BasicAxisItem {
Q_OBJECT
private: private:
static constexpr auto P_IS_LOGSCALE{"log10"}; static constexpr auto P_IS_LOGSCALE{"log10"};
static constexpr auto P_LOCK_MIN_MAX{"Lock (min, max)"}; static constexpr auto P_LOCK_MIN_MAX{"Lock (min, max)"};
...@@ -90,6 +97,10 @@ public: ...@@ -90,6 +97,10 @@ public:
bool isLocked() const; bool isLocked() const;
void setLocked(bool locked); void setLocked(bool locked);
signals:
void logScaleChanged();
}; };
#endif // BORNAGAIN_GUI_MODEL_DEVICE_AXESITEMS_H #endif // BORNAGAIN_GUI_MODEL_DEVICE_AXESITEMS_H
...@@ -59,17 +59,13 @@ JobItem::JobItem() ...@@ -59,17 +59,13 @@ JobItem::JobItem()
addProperty(P_PRESENTATION_TYPE, QVariant::Type::Invalid); addProperty(P_PRESENTATION_TYPE, QVariant::Type::Invalid);
registerTag(T_OUTPUT, 1, 1, {IntensityDataItem::M_TYPE, SpecularDataItem::M_TYPE}); registerTag(T_OUTPUT, 1, 1, {IntensityDataItem::M_TYPE, SpecularDataItem::M_TYPE});
registerTag(T_DIFF, 1, 1, {IntensityDataItem::M_TYPE, SpecularDataItem::M_TYPE});
registerTag(T_REALDATA, 1, 1, {RealDataItem::M_TYPE}); registerTag(T_REALDATA, 1, 1, {RealDataItem::M_TYPE});
registerTag(T_DATAVIEW, 1, 1, {Data1DViewItem::M_TYPE}); registerTag(T_DATAVIEW, 1, 1, {Data1DViewItem::M_TYPE});
registerTag(T_FIT_SUITE, 1, 1, {FitSuiteItem::M_TYPE}); registerTag(T_FIT_SUITE, 1, 1, {FitSuiteItem::M_TYPE});
} }
JobItem::~JobItem()
{
emit jobDestroyed();
}
QString JobItem::getIdentifier() const QString JobItem::getIdentifier() const
{ {
return getItemValue(P_IDENTIFIER).toString(); return getItemValue(P_IDENTIFIER).toString();
...@@ -294,7 +290,26 @@ RealDataItem* JobItem::realDataItem() ...@@ -294,7 +290,26 @@ RealDataItem* JobItem::realDataItem()
RealDataItem* JobItem::copyRealDataIntoJob(const RealDataItem* real_data) RealDataItem* JobItem::copyRealDataIntoJob(const RealDataItem* real_data)
{ {
return model()->copyItem(real_data, this, T_REALDATA); // create diffDataItem together with realDataItem
if(!diffDataItem()) {
if(real_data->isIntensityData())
model()->insertItem<IntensityDataItem>(this, -1, T_DIFF);
else if(real_data->isSpecularData())
model()->insertItem<SpecularDataItem>(this, -1, T_DIFF);
else
ASSERT(0)
// immediately create coordinate system and axes units
if (instrumentItem()) {
GUI::Model::JobItemUtils::setIntensityItemCoords(diffDataItem(), instrumentItem());
diffDataItem()->updateCoords(instrumentItem());
}
}
RealDataItem* realDataCopy = model()->copyItem(real_data, this, T_REALDATA);
if(!isSpecularJob()) {
realDataCopy->intensityDataItem()->setGradient(intensityDataItem()->getGradient());
}
return realDataCopy;
} }
RealDataItem* JobItem::createRealDataItem() RealDataItem* JobItem::createRealDataItem()
...@@ -302,14 +317,14 @@ RealDataItem* JobItem::createRealDataItem() ...@@ -302,14 +317,14 @@ RealDataItem* JobItem::createRealDataItem()
return model()->insertItem<RealDataItem>(this, -1, T_REALDATA); return model()->insertItem<RealDataItem>(this, -1, T_REALDATA);
} }
Data1DViewItem* JobItem::dataItemView() DataItem* JobItem::diffDataItem()
{ {
return dynamic_cast<Data1DViewItem*>(getItem(JobItem::T_DATAVIEW)); return dynamic_cast<DataItem*>(getItem(T_DIFF));
} }
void JobItem::addDataViewItem(Data1DViewItem* data_view) Data1DViewItem* JobItem::dataItemView()
{ {
insertChild(-1, data_view, T_DATAVIEW); return dynamic_cast<Data1DViewItem*>(getItem(JobItem::T_DATAVIEW));
} }
Data1DViewItem* JobItem::createDataViewItem() Data1DViewItem* JobItem::createDataViewItem()
......
...@@ -54,6 +54,7 @@ private: ...@@ -54,6 +54,7 @@ private:
static constexpr auto P_PRESENTATION_TYPE{"Presentation type"}; static constexpr auto P_PRESENTATION_TYPE{"Presentation type"};
static constexpr auto T_MATERIAL_CONTAINER{"Material container tag"}; static constexpr auto T_MATERIAL_CONTAINER{"Material container tag"};
static constexpr auto T_OUTPUT{"Output tag"}; static constexpr auto T_OUTPUT{"Output tag"};
static constexpr auto T_DIFF{"Diff tag"};
static constexpr auto T_REALDATA{"Real Data tag"}; static constexpr auto T_REALDATA{"Real Data tag"};
static constexpr auto T_DATAVIEW{"Data View tag"}; static constexpr auto T_DATAVIEW{"Data View tag"};
static constexpr auto T_FIT_SUITE{"Fit suite tag"}; static constexpr auto T_FIT_SUITE{"Fit suite tag"};
...@@ -62,7 +63,6 @@ public: ...@@ -62,7 +63,6 @@ public:
static constexpr auto M_TYPE{"JobItem"}; static constexpr auto M_TYPE{"JobItem"};
JobItem(); JobItem();
~JobItem();
QString getIdentifier() const; QString getIdentifier() const;
void setIdentifier(const QString& identifier); void setIdentifier(const QString& identifier);
...@@ -127,8 +127,8 @@ public: ...@@ -127,8 +127,8 @@ public:
RealDataItem* copyRealDataIntoJob(const RealDataItem* real_data); RealDataItem* copyRealDataIntoJob(const RealDataItem* real_data);
RealDataItem* createRealDataItem(); RealDataItem* createRealDataItem();
DataItem* diffDataItem();
Data1DViewItem* dataItemView(); Data1DViewItem* dataItemView();
void addDataViewItem(Data1DViewItem* data_view);
Data1DViewItem* createDataViewItem(); Data1DViewItem* createDataViewItem();
QString sampleName() const; QString sampleName() const;
...@@ -147,7 +147,6 @@ public: ...@@ -147,7 +147,6 @@ public:
friend class JobModel; friend class JobModel;
signals: signals:
void jobDestroyed();
void jobNameChanged(const QString& name); void jobNameChanged(const QString& name);
void jobStatusChanged(const JobStatus status); void jobStatusChanged(const JobStatus status);
void jobBeginTimeChanged(const QDateTime& begin_time); void jobBeginTimeChanged(const QDateTime& begin_time);
......
...@@ -49,8 +49,7 @@ FitSessionController* FitSessionManager::sessionController(JobItem* jobItem) ...@@ -49,8 +49,7 @@ FitSessionController* FitSessionManager::sessionController(JobItem* jobItem)
FitSessionController* FitSessionManager::createController(JobItem* jobItem) FitSessionController* FitSessionManager::createController(JobItem* jobItem)
{ {
// job destruction connect(jobItem, &JobItem::destroyed, this, [=]() { removeController(jobItem); });
connect(jobItem, &JobItem::jobDestroyed, this, [=]() { removeController(jobItem); });
auto* result = new FitSessionController(this); auto* result = new FitSessionController(this);
result->setItem(jobItem); result->setItem(jobItem);
......
...@@ -107,7 +107,7 @@ void MaskEditorPropertyPanel::setMaskContext(SessionModel* model, ...@@ -107,7 +107,7 @@ void MaskEditorPropertyPanel::setMaskContext(SessionModel* model,
connect(m_listView->selectionModel(), &QItemSelectionModel::selectionChanged, this, connect(m_listView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
&MaskEditorPropertyPanel::onSelectionChanged, Qt::UniqueConnection); &MaskEditorPropertyPanel::onSelectionChanged, Qt::UniqueConnection);
m_plotPropertyEditor->setItem(m_intensityDataItem); m_plotPropertyEditor->setItem({m_intensityDataItem});
} }
void MaskEditorPropertyPanel::resetContext() void MaskEditorPropertyPanel::resetContext()
...@@ -117,7 +117,7 @@ void MaskEditorPropertyPanel::resetContext() ...@@ -117,7 +117,7 @@ void MaskEditorPropertyPanel::resetContext()