Commit d5e41ac8 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov Committed by Mikhail Svechnikov
Browse files

axes units signals work

parent e7257e5a
...@@ -102,8 +102,6 @@ QString DataItem::selectedCoords() const ...@@ -102,8 +102,6 @@ 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());
qInfo() << "axesUnitsChanged" << endl;
emit axesUnitsChanged(units);
} }
SessionItem* DataItem::getAxesUnitsItem() const SessionItem* DataItem::getAxesUnitsItem() const
...@@ -111,26 +109,9 @@ SessionItem* DataItem::getAxesUnitsItem() const ...@@ -111,26 +109,9 @@ SessionItem* DataItem::getAxesUnitsItem() const
return getItem(P_AXES_UNITS); return getItem(P_AXES_UNITS);
} }
void DataItem::createAxesUnitsDescriptor()
{
SessionItem* item = getAxesUnitsItem();
qInfo() << item << "createAxesUnitsDescriptor" << endl;
m_axes_units = SelectionDescriptor<QString>(item);
#ifndef USE_MAPPERS
m_axes_units.currentIndexSetter = [=](int index) {
ComboProperty comboProperty = item->value().value<ComboProperty>();
if (comboProperty.currentIndex() != index) {
comboProperty.setCurrentIndex(index);
qInfo() << "new setter" << endl;
const_cast<DataItem*>(this)->setAxesUnits(comboProperty);
}
};
#endif
}
SelectionDescriptor<QString> DataItem::axesUnits() const SelectionDescriptor<QString> DataItem::axesUnits() const
{ {
return m_axes_units; return SelectionDescriptor<QString>(getAxesUnitsItem());
} }
bool DataItem::isAxesUnitsPropertyName(const QString& name) bool DataItem::isAxesUnitsPropertyName(const QString& name)
......
...@@ -81,13 +81,12 @@ signals: ...@@ -81,13 +81,12 @@ 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 replotRequested(); void replotRequested();
protected: protected:
explicit DataItem(const QString& modelType); explicit DataItem(const QString& modelType);
SelectionDescriptor<QString> m_axes_units;
std::unique_ptr<Datafield> m_data; //!< simulation results std::unique_ptr<Datafield> m_data; //!< simulation results
QDateTime m_last_modified; QDateTime m_last_modified;
std::mutex m_update_data_mutex; std::mutex m_update_data_mutex;
......
...@@ -88,7 +88,6 @@ public: ...@@ -88,7 +88,6 @@ public:
if (comboProperty.currentIndex() != index) { if (comboProperty.currentIndex() != index) {
comboProperty.setCurrentIndex(index); comboProperty.setCurrentIndex(index);
item->setValue(QVariant::fromValue<ComboProperty>(comboProperty)); item->setValue(QVariant::fromValue<ComboProperty>(comboProperty));
qInfo() << item << "old setter" << endl;
} }
}; };
currentIndexGetter = [=] { return item->value().value<ComboProperty>().currentIndex(); }; currentIndexGetter = [=] { return item->value().value<ComboProperty>().currentIndex(); };
......
...@@ -290,6 +290,15 @@ RealDataItem* JobItem::realDataItem() ...@@ -290,6 +290,15 @@ RealDataItem* JobItem::realDataItem()
RealDataItem* JobItem::copyRealDataIntoJob(const RealDataItem* real_data) RealDataItem* JobItem::copyRealDataIntoJob(const RealDataItem* real_data)
{ {
qInfo() << "copyRealDataIntoJob" << endl;
if(!diffDataItem()) {
if(real_data->isIntensityData())
model()->insertItem<IntensityDataItem>(this, -1, T_DIFF);
else
model()->insertItem<SpecularDataItem>(this, -1, T_DIFF);
qInfo() << "JobItem::diff inserted in copy" << endl;
}
return model()->copyItem(real_data, this, T_REALDATA); return model()->copyItem(real_data, this, T_REALDATA);
} }
......
...@@ -171,7 +171,13 @@ T* JobItem::setDataType() ...@@ -171,7 +171,13 @@ T* JobItem::setDataType()
{ {
static_assert(std::is_base_of<DataItem, T>::value, "Class must be derived from DataItem"); static_assert(std::is_base_of<DataItem, T>::value, "Class must be derived from DataItem");
model()->insertItem<T>(this, -1, T_DIFF); qInfo() << "JobItem::setDataType" << endl;
// if(realDataItem() && !diffDataItem())
// {
// model()->insertItem<T>(this, -1, T_DIFF);
// qInfo() << "JobItem::diff inserted" << endl;
// }
return model()->insertItem<T>(this, -1, T_OUTPUT); return model()->insertItem<T>(this, -1, T_OUTPUT);
} }
......
...@@ -62,6 +62,7 @@ void IntensityDataWidget::setItem(SessionItem* job_Item) ...@@ -62,6 +62,7 @@ void IntensityDataWidget::setItem(SessionItem* job_Item)
#ifdef USE_MAPPERS #ifdef USE_MAPPERS
m_propertyWidget->setItem({intensityDataItem()}); m_propertyWidget->setItem({intensityDataItem()});
#else #else
qInfo() << intensityDataItem() << realIntensityDataItem() << diffIntensityDataItem() << endl;
m_propertyWidget->setItem({intensityDataItem(), m_propertyWidget->setItem({intensityDataItem(),
realIntensityDataItem(), realIntensityDataItem(),
diffIntensityDataItem()}); diffIntensityDataItem()});
......
...@@ -34,7 +34,6 @@ class FitComparisonController2D::DiffItemController : public QObject { ...@@ -34,7 +34,6 @@ class FitComparisonController2D::DiffItemController : public QObject {
public: public:
DiffItemController(QObject* parent); DiffItemController(QObject* parent);
~DiffItemController() override; ~DiffItemController() override;
SessionModel* model();
void setItem(JobItem* job_item); void setItem(JobItem* job_item);
void updateDiffData(); void updateDiffData();
DataItem* diffItem(); DataItem* diffItem();
...@@ -136,6 +135,7 @@ void DiffItemController::setItem(JobItem* job_item) ...@@ -136,6 +135,7 @@ void DiffItemController::setItem(JobItem* job_item)
{ {
ASSERT(job_item); ASSERT(job_item);
ASSERT(job_item->diffDataItem()); ASSERT(job_item->diffDataItem());
qInfo() << "diffDataItem asserted" << endl;
if (m_current_item) if (m_current_item)
unsubscribe(); unsubscribe();
...@@ -146,11 +146,6 @@ void DiffItemController::setItem(JobItem* job_item) ...@@ -146,11 +146,6 @@ void DiffItemController::setItem(JobItem* job_item)
updateDiffData(); updateDiffData();
} }
SessionModel* DiffItemController::model()
{
return m_diff_item->model();
}
void DiffItemController::updateDiffData() void DiffItemController::updateDiffData()
{ {
ASSERT(m_current_item); ASSERT(m_current_item);
...@@ -195,7 +190,7 @@ void DiffItemController::subscribe() ...@@ -195,7 +190,7 @@ void DiffItemController::subscribe()
}, },
this); this);
#else #else
connect(m_diff_item, &DataItem::axesUnitsChanged, this, [=](const ComboProperty&) { connect(m_diff_item, &DataItem::axesUnitsChanged, this, [=]() {
m_diff_item->updateCoords(m_current_item->instrumentItem()); m_diff_item->updateCoords(m_current_item->instrumentItem());
}); });
#endif #endif
......
...@@ -69,15 +69,12 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec) ...@@ -69,15 +69,12 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
if (!first_item) if (!first_item)
return; return;
for(IntensityDataItem* item : m_items_vec)
if(item)
item->createAxesUnitsDescriptor();
m_mainLayout->addRow("Axes units:", createComboBox(first_item->axesUnits(), m_mainLayout->addRow("Axes units:", createComboBox(first_item->axesUnits(),
[=](int newIndex){ [=](int newIndex){
for(IntensityDataItem* item : m_items_vec) for(IntensityDataItem* item : m_items_vec)
if(item) { if(item) {
qInfo() << "axesUnits" << item << endl;
item->axesUnits().setCurrentIndex(newIndex); item->axesUnits().setCurrentIndex(newIndex);
emit item->axesUnitsChanged();
} }
})); }));
m_mainLayout->addRow("Color scheme:", createComboBox(first_item->gradient(), m_mainLayout->addRow("Color scheme:", createComboBox(first_item->gradient(),
...@@ -148,23 +145,22 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec) ...@@ -148,23 +145,22 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
this); this);
#else #else
for(IntensityDataItem* item : m_items_vec) for(IntensityDataItem* item : m_items_vec)
if(item) if(item) {
connect(item, &IntensityDataItem::axesUnitsChanged, this, [=](const ComboProperty&){ connect(item, &IntensityDataItem::axesUnitsChanged, this, [=](){
if(jobItem()) { if(jobItem()) {
item->blockSignals(true); item->blockSignals(true);
item->updateCoords(jobItem()->instrumentItem()); item->updateCoords(jobItem()->instrumentItem());
item->blockSignals(false); item->blockSignals(false);
qInfo() << item << "replotRequested" << endl;
emit item->replotRequested(); emit item->replotRequested();
} }
}); });
}
#endif #endif
for(int i=0; i<itemsVec.size(); i++) for(int i=0; i<itemsVec.size(); i++)
if(itemsVec[i]) if(itemsVec[i])
#ifdef USE_MAPPERS #ifdef USE_MAPPERS
itemsVec[i]->mapper()->setOnItemDestroy([this](SessionItem*) { m_items_vec[i] = nullptr; }, this); itemsVec[i]->mapper()->setOnItemDestroy([this, i](SessionItem*) { m_items_vec[i] = nullptr; }, this);
#else #else
connect(itemsVec[i], &IntensityDataItem::destroyed, this, [=](){ m_items_vec[i] = nullptr; }); connect(itemsVec[i], &IntensityDataItem::destroyed, this, [=](){ m_items_vec[i] = nullptr; });
#endif #endif
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
// changing item (Datafield) // changing item (Datafield)
#ifdef USE_MAPPERS #ifdef USE_MAPPERS
emitDataChanged(); item->emitDataChanged();
#else #else
if (typeid(T) == typeid(SpecularDataItem)) { if (typeid(T) == typeid(SpecularDataItem)) {
std::vector<double> data = {1, 2, 3}; std::vector<double> data = {1, 2, 3};
......
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