Commit 0ee21b9e authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

projections are reconnected

parent 89b869aa
......@@ -201,6 +201,7 @@ class GroupInfo;
//!
//! This code part again shows the (highly error-prone) string-based type checking.
//#define USE_MAPPERS
#include <QDebug>
class BA_CORE_API_ SessionItem {
friend class SessionModel;
......
......@@ -331,7 +331,7 @@ void IntensityDataItem::setLogz(bool logz)
void IntensityDataItem::setInterpolated(bool interp)
{
setItemValue(P_IS_INTERPOLATED, interp);
emit interpolationChanged();
emit interpolationChanged(interp);
}
//! Sets zoom range of X,Y axes, if it was not yet defined.
......
......@@ -26,6 +26,7 @@ class ProjectionContainerItem;
class BA_CORE_API_ IntensityDataItem : public DataItem {
Q_OBJECT
private:
// using DataItem::mapper;
static constexpr auto P_PROJECTIONS{"Projections"};
static constexpr auto P_TITLE{"Title"};
static constexpr auto P_IS_INTERPOLATED{"Interpolation"};
......@@ -123,7 +124,7 @@ public:
signals:
void gradientChanged();
void interpolationChanged();
void interpolationChanged(bool isInterpol);
void axesRangeChangedFromPlot();
void updateOtherPlots();
void updateThisPlot();
......
......@@ -195,7 +195,7 @@ bool AmplitudeAxisItem::isLogScale() const
void AmplitudeAxisItem::setLogScale(bool value)
{
setItemValue(P_IS_LOGSCALE, value);
emit logScaleChanged();
emit logScaleChanged(value);
}
SessionItem* AmplitudeAxisItem::logScaleItem() const
......
......@@ -99,7 +99,7 @@ public:
void setLocked(bool locked);
signals:
void logScaleChanged();
void logScaleChanged(bool isLog);
};
......
......@@ -174,17 +174,14 @@ void DiffItemController::subscribe()
void DiffItemController::unsubscribe()
{
#ifdef USE_MAPPERS
m_diff_item->mapper()->unsubscribe(this);
#else
disconnect(m_diff_item, nullptr, this, nullptr);
#endif
if (!m_current_item)
return;
#ifdef USE_MAPPERS
m_current_item->dataItem()->mapper()->unsubscribe(this);
m_diff_item->mapper()->unsubscribe(this);
#else
disconnect(m_current_item->dataItem(), nullptr, this, nullptr);
disconnect(m_diff_item, nullptr, this, nullptr);
#endif
m_current_item = nullptr;
}
......@@ -141,14 +141,12 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
updateUIValues();
// react on external changes (e.g. zooming in customplot shall update the axis values)
// update coordinates on axes units change
#ifdef USE_MAPPERS
// react on external changes (e.g. zooming in customplot shall update the axis values)
first_item->mapper()->setOnChildPropertyChange(
[=](SessionItem*, const QString&) { updateUIValues(); }, this);
// update coordinates on axes units change
first_item->mapper()->setOnPropertyChange(
[this](SessionItem* item, const QString& name) {
if(jobItem())
......@@ -160,7 +158,7 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
[&](SessionItem*) { item = nullptr; }, this);
#else
// update values on panel
// react on external changes (e.g. zooming in customplot shall update the axis values)
FOR_EACH_ITEM
connect(item, &IntensityDataItem::axesRangeChangedFromPlot, this, [=](){
updateUIValues();
......
......@@ -101,7 +101,10 @@ JobItem* ProjectionsEditor::jobItem()
IntensityDataItem* ProjectionsEditor::simulatedIntensity()
{
return dynamic_cast<IntensityDataItem*>(jobItem()->dataItem());
if(jobItem())
return dynamic_cast<IntensityDataItem*>(jobItem()->dataItem());
else
return nullptr;
}
IntensityDataItem* ProjectionsEditor::realIntensityDataItem()
......
......@@ -81,25 +81,64 @@ void ProjectionsPlot::subscribeToItem()
this);
// Values of intensity changed, regenerate everything.
intensityItem()->mapper()->setOnValueChange(
[this]() {
#ifdef USE_MAPPERS
// intensityItem()->mapper()->setOnValueChange(
// [this]() {
// updateProjectionsData();
// updateProjections();
// },
// this);
#else
connect(intensityItem(), &IntensityDataItem::datafieldChanged, this, [=]() {
updateProjectionsData();
updateProjections();
},
this);
});
#endif
// IntensityItem property (e.g. interpolation changed)
// interpolation changed
#ifdef USE_MAPPERS
intensityItem()->mapper()->setOnPropertyChange(
[this](const QString& name) { onIntensityItemPropertyChanged(name); }, this);
#else
connect(intensityItem(), &IntensityDataItem::interpolationChanged, this,
&ProjectionsPlot::setInterpolate, Qt::UniqueConnection);
#endif
// Update to changed IntensityDataItem axes
// AXES
#ifdef USE_MAPPERS
intensityItem()->mapper()->setOnChildPropertyChange(
[this](SessionItem* item, const QString name) {
if (item->modelType() == BasicAxisItem::M_TYPE
|| item->modelType() == AmplitudeAxisItem::M_TYPE)
|| item->modelType() == AmplitudeAxisItem::M_TYPE) {
onAxisPropertyChanged(item->itemName(), name);
}
},
this);
#else
// if the colormap is zoomed or dragged:
connect(intensityItem(), &IntensityDataItem::updateOtherPlots, this,
&ProjectionsPlot::updateAxesRange, Qt::UniqueConnection);
// if axes are changed externally, from the properties panel:
// axes range
connect(intensityItem()->xAxisItem(), &BasicAxisItem::axisRangeChanged, this,
&ProjectionsPlot::updateAxesRange, Qt::UniqueConnection);
connect(intensityItem()->yAxisItem(), &BasicAxisItem::axisRangeChanged, this,
&ProjectionsPlot::updateAxesRange, Qt::UniqueConnection);
connect(intensityItem()->zAxisItem(), &BasicAxisItem::axisRangeChanged, this,
&ProjectionsPlot::updateAxesRange, Qt::UniqueConnection);
// axes title
connect(intensityItem()->xAxisItem(), &BasicAxisItem::axisTitleChanged, this,
&ProjectionsPlot::updateAxesTitle, Qt::UniqueConnection);
connect(intensityItem()->yAxisItem(), &BasicAxisItem::axisTitleChanged, this,
&ProjectionsPlot::updateAxesTitle, Qt::UniqueConnection);
// z log scale
connect(intensityItem()->zAxisItem(), &AmplitudeAxisItem::logScaleChanged, this,
&ProjectionsPlot::setLogz, Qt::UniqueConnection);
#endif
updateProjectionsData();
updateProjections();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment