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