Commit 9a3834ef authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

plots are almost synchronized

parent f88175fb
......@@ -281,21 +281,25 @@ bool IntensityDataItem::isZaxisPropertyName(const QString& name)
void IntensityDataItem::setLowerX(double value)
{
xAxisItem()->setLowerBound(value);
emit axesRangeChangedFromPlot();
}
void IntensityDataItem::setUpperX(double value)
{
xAxisItem()->setUpperBound(value);
emit axesRangeChangedFromPlot();
}
void IntensityDataItem::setLowerY(double value)
{
yAxisItem()->setLowerBound(value);
emit axesRangeChangedFromPlot();
}
void IntensityDataItem::setUpperY(double value)
{
yAxisItem()->setUpperBound(value);
emit axesRangeChangedFromPlot();
}
void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax)
......@@ -310,17 +314,18 @@ void IntensityDataItem::setLowerAndUpperZ(double zmin, double zmax)
void IntensityDataItem::setLowerZ(double zmin)
{
zAxisItem()->setLowerBound(zmin);
emit axesRangeChangedFromPlot();
}
void IntensityDataItem::setUpperZ(double zmax)
{
zAxisItem()->setUpperBound(zmax);
emit axesRangeChangedFromPlot();
}
void IntensityDataItem::setLogz(bool logz)
{
zAxisItem()->setLogScale(logz);
emit zLogChanged();
}
void IntensityDataItem::setInterpolated(bool interp)
......
......@@ -123,9 +123,10 @@ public:
signals:
void gradientChanged();
void zAxisLockChanged();
void zLogChanged();
void interpolationChanged();
void axesRangeChangedFromPlot();
void updateOtherPlots();
void updateThisPlot();
public slots:
void setLowerX(double value);
......
......@@ -61,6 +61,10 @@ void IntensityDataWidget::setItem(SessionItem* job_Item)
#ifdef USE_MAPPERS
m_propertyWidget->setItem({intensityDataItem()});
#else
qInfo() << endl
<< "simu" << intensityDataItem() << endl
<< "real" << realIntensityDataItem() << endl
<< "diff" << diffIntensityDataItem() << endl;
m_propertyWidget->setItem({intensityDataItem(),
realIntensityDataItem(),
diffIntensityDataItem()});
......
......@@ -84,6 +84,7 @@ QList<QAction*> FitComparisonWidget::actionList()
void FitComparisonWidget::subscribeToItem()
{
qInfo() << "FitComparisonWidget::subscribeToItem" << endl;
if (!jobItem()->isValidForFitting())
return;
......@@ -106,6 +107,10 @@ void FitComparisonWidget::subscribeToItem()
#ifdef USE_MAPPERS
m_propertyWidget->setItem({simulatedDataItem()});
#else
qInfo() << endl
<< "simu" << simulatedDataItem() << endl
<< "real" << realDataItem() << endl
<< "diff" << diffItem() << endl;
m_propertyWidget->setItem({simulatedDataItem(), realDataItem(), diffItem()});
#endif
}
......
......@@ -125,6 +125,7 @@ void ColorMap::onPropertyChanged(const QString& property_name)
void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& propertyName)
{
#ifdef USE_MAPPERS
if (m_block_update)
return;
......@@ -162,13 +163,15 @@ void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& pro
replot();
}
}
#endif
}
//! Propagate zmin, zmax back to IntensityDataItem
void ColorMap::onDataRangeChanged(QCPRange newRange)
{
m_block_update = true;
intensityItem()->setLowerAndUpperZ(newRange.lower, newRange.upper);
intensityItem()->setLowerAndUpperZ(newRange.lower, newRange.upper);
emit intensityItem()->updateOtherPlots();
m_block_update = false;
}
......@@ -178,15 +181,18 @@ void ColorMap::onXaxisRangeChanged(QCPRange newRange)
m_block_update = true;
intensityItem()->setLowerX(newRange.lower);
intensityItem()->setUpperX(newRange.upper);
emit intensityItem()->updateOtherPlots();
m_block_update = false;
}
//! Propagate ymin, ymax back to IntensityDataItem
void ColorMap::onYaxisRangeChanged(QCPRange newRange)
{
// TODO remove m_block_update
m_block_update = true;
intensityItem()->setLowerY(newRange.lower);
intensityItem()->setUpperY(newRange.upper);
emit intensityItem()->updateOtherPlots();
m_block_update = false;
}
......@@ -277,12 +283,27 @@ void ColorMap::subscribeToItem()
replot();
});
// all axes
connect(intensityItem(), &IntensityDataItem::updateThisPlot, this, [=]() {
setConnected(false);
m_customPlot->xAxis->setRange(GUI::View::RangeUtils::itemZoomX(intensityItem()));
m_customPlot->yAxis->setRange(GUI::View::RangeUtils::itemZoomY(intensityItem()));
m_colorMap->setDataRange(GUI::View::RangeUtils::itemDataZoom(intensityItem()));
setConnected(true);
replot();
});
#endif
setConnected(true);
}
void ColorMap::unsubscribeFromItem()
{
disconnect(intensityItem(), nullptr, this, nullptr);
disconnect(intensityItem()->xAxisItem(), nullptr, this, nullptr);
disconnect(intensityItem()->yAxisItem(), nullptr, this, nullptr);
disconnect(intensityItem()->zAxisItem(), nullptr, this, nullptr);
setConnected(false);
}
......@@ -382,7 +403,7 @@ void ColorMap::setColorMapFromItem(IntensityDataItem* intensityItem)
setDataFromItem(intensityItem);
setColorScaleAppearanceFromItem(intensityItem);
setDataRangeFromItem(intensityItem);
setLogz(intensityItem->isLogz());
replot();
m_block_update = false;
......@@ -463,7 +484,6 @@ void ColorMap::setDataRangeFromItem(IntensityDataItem* item)
{
setDataRangeConnected(false);
m_colorMap->setDataRange(GUI::View::RangeUtils::itemDataZoom(item));
setLogz(item->isLogz());
setDataRangeConnected(true);
}
......
......@@ -54,7 +54,10 @@ void IntensityDataPropertyWidget::unsubscribe()
#ifdef USE_MAPPERS
FOR_EACH_ITEM item->mapper()->unsubscribe(this);
#else
FOR_EACH_ITEM disconnect(item, nullptr, this, nullptr);
FOR_EACH_ITEM {
disconnect(item, nullptr, this, nullptr);
qInfo() << "disco" << item<< endl;
}
#endif
}
......@@ -141,18 +144,41 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
updateUIValues();
// 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
#ifdef USE_MAPPERS
first_item->mapper()->setOnChildPropertyChange(
[=](SessionItem*, const QString&) { updateUIValues(); }, this);
first_item->mapper()->setOnPropertyChange(
[this](SessionItem* item, const QString& name) {
if(jobItem())
DataItem::updateAxesUnits(item, name, jobItem()->instrumentItem());
},
this);
FOR_EACH_ITEM
item->mapper()->setOnItemDestroy(
[&](SessionItem*) { item = nullptr; }, this);
#else
FOR_EACH_ITEM
connect(item, &IntensityDataItem::axesRangeChangedFromPlot, this, [=](){
updateUIValues();
});
FOR_EACH_ITEM {
qInfo() << "connect" << item << this;
connect(item, &IntensityDataItem::updateOtherPlots, this, [=]() {
// sync view area between sumulated, real and difference plots
qInfo() << item << "BasicAxisItem::updateOtherPlots" << this << endl;
for(IntensityDataItem* otherItem : m_items_vec)
if(otherItem && otherItem!=item) {
qInfo() << otherItem;
emit otherItem->updateThisPlot();
}
});
}
FOR_EACH_ITEM
connect(item, &IntensityDataItem::axesUnitsChanged, this, [=](){
if(jobItem()) {
......@@ -162,16 +188,9 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
emit item->axesUnitsReplotRequested();
}
});
#endif
for(int i=0; i<itemsVec.size(); i++)
if(itemsVec[i])
#ifdef USE_MAPPERS
itemsVec[i]->mapper()->setOnItemDestroy(
[this, i](SessionItem*) { m_items_vec[i] = nullptr; }, this);
#else
connect(itemsVec[i], &IntensityDataItem::destroyed, this,
[=]() { m_items_vec[i] = nullptr; });
FOR_EACH_ITEM
connect(item, &IntensityDataItem::destroyed, this,
[&]() { item = nullptr; });
#endif
}
......@@ -208,7 +227,10 @@ QWidget* IntensityDataPropertyWidget::createTextEdit(SessionItem* item,
slot(newText);
});
m_updaters << [=]() { edit->setText(item->value().toString()); };
m_updaters << [=]() {
QSignalBlocker b(this);
edit->setText(item->value().toString());
};
return edit;
}
......
......@@ -37,6 +37,7 @@ public:
~IntensityDataPropertyWidget();
void setItem(QVector<IntensityDataItem*> itemsVec);
void unsubscribe();
const JobItem* jobItem() const;
private:
......@@ -47,7 +48,6 @@ private:
QWidget* createComboBox(SelectionDescriptor<QString> d,
function<void(int)> slot = nullptr);
void updateUIValues();
void unsubscribe();
private:
QWidget* parent;
......
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