Skip to content
Snippets Groups Projects
Commit 68ccc19e authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

doing Plot1D mappers

parent f19db0fb
No related branches found
No related tags found
2 merge requests!963GUI refactoring: rm mappers from specular and projection plots,!962Draft: GUI refactoring: rm mappers from SpecularPlot
......@@ -37,13 +37,6 @@ Data1DViewItem::Data1DViewItem()
, m_job_item(nullptr)
{
registerTag(T_DATA_PROPERTIES, 1, 1, {DataPropertyContainer::M_TYPE});
mapper()->setOnPropertyChange([this](const QString& name) {
if (!DataItem::isAxesUnitsPropertyName(name))
return;
setAxesRangeToData();
GUI::Model::DataViewUtils::updateAxesTitle(this);
});
}
//! set zoom range of x,y axes to axes of input data
......
......@@ -17,6 +17,7 @@
#include "GUI/Model/Data/DataItem.h"
#include "GUI/Model/Data/DataProperties.h"
#include "GUI/Model/Data/DataPropertyContainer.h"
#include "GUI/Model/Data/DataViewUtils.h"
#include "GUI/Model/Device/AxesItems.h"
#include "GUI/View/PlotUtil/PlotConstants.h"
#include "GUI/View/PlotUtil/PlotEventInfo.h"
......@@ -116,40 +117,95 @@ void Plot1D::subscribeToItem()
initPlots();
refreshPlotData();
viewItem()->mapper()->setOnPropertyChange(
[this](const QString& name) { onPropertyChanged(name); }, this);
viewItem()->mapper()->setOnChildPropertyChange(
[this](SessionItem* item, const QString name) {
if (dynamic_cast<BasicAxisItem*>(item))
modifyAxesProperties(item->itemName(), name);
},
this);
//#ifdef USE_MAPPERS
// viewItem()->mapper()->setOnPropertyChange(
// [this](const QString& name) {
// if (DataItem::isAxesUnitsPropertyName(name)) {
// viewItem()->setAxesRangeToData();
// GUI::Model::DataViewUtils::updateAxesTitle(viewItem());
// }
// onPropertyChanged(name);
// }, this);
// viewItem()->mapper()->setOnChildPropertyChange(
// [this](SessionItem* item, const QString name) {
// if (dynamic_cast<BasicAxisItem*>(item))
// modifyAxesProperties(item->itemName(), name);
// },
// this);
// std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) {
// auto property_item = pair.first;
// property_item->dataItem()->mapper()->setOnValueChange(
// [caller]() { caller->refreshPlotData(); }, caller);
// });
//#else
// datafield
std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) {
#ifdef USE_MAPPERS
auto property_item = pair.first;
property_item->dataItem()->mapper()->setOnValueChange(
[caller]() { caller->refreshPlotData(); }, caller);
#else
DataItem* dataItem = pair.first->dataItem();
connect(dataItem, &DataItem::datafieldChanged, caller,
[caller]() { caller->refreshPlotData(); });
#endif
});
// units
connect(viewItem(), &DataItem::axesUnitsReplotRequested, this, [=]() {
viewItem()->setAxesRangeToData();
GUI::Model::DataViewUtils::updateAxesTitle(viewItem());
setAxesRangeFromItem(viewItem());
updateAllGraphs();
replot();
});
// x axis
connect(viewItem()->xAxisItem(), &BasicAxisItem::axisTitleChanged, this, [=]() {
setAxesLabelsFromItem(viewItem());
replot();
});
connect(viewItem()->xAxisItem(), &BasicAxisItem::axisRangeChanged, this, [=]() {
setAxesRangeConnected(false);
m_custom_plot->xAxis->setRange(viewItem()->getLowerX(),
viewItem()->getUpperX());
setAxesRangeConnected(true);
replot();
});
// y axis
connect(viewItem()->yAxisItem(), &BasicAxisItem::axisTitleChanged, this, [=]() {
setAxesLabelsFromItem(viewItem());
replot();
});
connect(viewItem()->yAxisItem(), &BasicAxisItem::axisRangeChanged, this, [=]() {
setAxesRangeConnected(false);
m_custom_plot->yAxis->setRange(viewItem()->getLowerY(),
viewItem()->getUpperY());
setAxesRangeConnected(true);
replot();
});
connect(viewItem()->yAxisItem(), &AmplitudeAxisItem::logScaleChanged, this, [=]() {
setLog(viewItem()->isLog());
replot();
});
//#endif
setConnected(true);
}
void Plot1D::unsubscribeFromItem()
{
m_custom_plot->clearGraphs();
std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) {
#ifdef USE_MAPPERS
std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) {
pair.first->dataItem()->mapper()->unsubscribe(caller);
});
#else
// disconnect(specularItem(), nullptr, this, nullptr);
// disconnect(specularItem()->xAxisItem(), nullptr, this, nullptr);
// disconnect(specularItem()->yAxisItem(), nullptr, this, nullptr);
std::for_each(m_graph_map.begin(), m_graph_map.end(), [caller = this](auto pair) {
disconnect(pair.first->dataItem(), nullptr, caller, nullptr);
#endif
});
#endif
m_graph_map.clear();
setConnected(false);
}
......
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