Commit 7129e900 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov Committed by Mikhail Svechnikov
Browse files

gradient change works

parent d5e41ac8
...@@ -104,14 +104,9 @@ void DataItem::setAxesUnits(const ComboProperty& units) ...@@ -104,14 +104,9 @@ void DataItem::setAxesUnits(const ComboProperty& units)
setItemValue(P_AXES_UNITS, units.variant()); setItemValue(P_AXES_UNITS, units.variant());
} }
SessionItem* DataItem::getAxesUnitsItem() const
{
return getItem(P_AXES_UNITS);
}
SelectionDescriptor<QString> DataItem::axesUnits() const SelectionDescriptor<QString> DataItem::axesUnits() const
{ {
return SelectionDescriptor<QString>(getAxesUnitsItem()); return SelectionDescriptor<QString>(getItem(P_AXES_UNITS));
} }
bool DataItem::isAxesUnitsPropertyName(const QString& name) bool DataItem::isAxesUnitsPropertyName(const QString& name)
......
...@@ -61,8 +61,6 @@ public: ...@@ -61,8 +61,6 @@ public:
QString selectedCoords() const; QString selectedCoords() const;
void setAxesUnits(const ComboProperty& units); void setAxesUnits(const ComboProperty& units);
SessionItem* getAxesUnitsItem() const;
void createAxesUnitsDescriptor();
SelectionDescriptor<QString> axesUnits() const; SelectionDescriptor<QString> axesUnits() const;
static bool isAxesUnitsPropertyName(const QString& name); static bool isAxesUnitsPropertyName(const QString& name);
static void updateAxesUnits(SessionItem* item, const QString& name, static void updateAxesUnits(SessionItem* item, const QString& name,
...@@ -82,7 +80,7 @@ signals: ...@@ -82,7 +80,7 @@ signals:
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(); void axesUnitsChanged();
void replotRequested(); void axesUnitsReplotRequested();
protected: protected:
explicit DataItem(const QString& modelType); explicit DataItem(const QString& modelType);
......
...@@ -161,7 +161,6 @@ ComboProperty IntensityDataItem::getGradient() const ...@@ -161,7 +161,6 @@ ComboProperty IntensityDataItem::getGradient() const
void IntensityDataItem::setGradient(const ComboProperty& gradient) void IntensityDataItem::setGradient(const ComboProperty& gradient)
{ {
setItemValue(P_GRADIENT, gradient.variant()); setItemValue(P_GRADIENT, gradient.variant());
emit gradientChanged(gradient);
} }
SelectionDescriptor<QString> IntensityDataItem::gradient() const SelectionDescriptor<QString> IntensityDataItem::gradient() const
...@@ -329,7 +328,7 @@ void IntensityDataItem::setLogz(bool logz) ...@@ -329,7 +328,7 @@ void IntensityDataItem::setLogz(bool logz)
void IntensityDataItem::setInterpolated(bool interp) void IntensityDataItem::setInterpolated(bool interp)
{ {
setItemValue(P_IS_INTERPOLATED, interp); setItemValue(P_IS_INTERPOLATED, interp);
emit interpolationChanged(interp); emit interpolationChanged();
} }
//! Sets zoom range of X,Y axes, if it was not yet defined. //! Sets zoom range of X,Y axes, if it was not yet defined.
......
...@@ -122,7 +122,7 @@ public: ...@@ -122,7 +122,7 @@ public:
static bool isZaxisPropertyName(const QString& name); static bool isZaxisPropertyName(const QString& name);
signals: signals:
void gradientChanged(const ComboProperty& gradient); void gradientChanged();
void zAxisLockChanged(bool isLocked); void zAxisLockChanged(bool isLocked);
void xAxisTitleChanged(const QString& title); void xAxisTitleChanged(const QString& title);
void yAxisTitleChanged(const QString& title); void yAxisTitleChanged(const QString& title);
...@@ -134,7 +134,7 @@ signals: ...@@ -134,7 +134,7 @@ signals:
void zAxisLowerChanged(double value); void zAxisLowerChanged(double value);
void zAxisUpperChanged(double value); void zAxisUpperChanged(double value);
void zLogChanged(bool isLog); void zLogChanged(bool isLog);
void interpolationChanged(bool isInterpolated); void interpolationChanged();
public slots: public slots:
void setLowerX(double value); void setLowerX(double value);
......
...@@ -290,16 +290,26 @@ RealDataItem* JobItem::realDataItem() ...@@ -290,16 +290,26 @@ RealDataItem* JobItem::realDataItem()
RealDataItem* JobItem::copyRealDataIntoJob(const RealDataItem* real_data) RealDataItem* JobItem::copyRealDataIntoJob(const RealDataItem* real_data)
{ {
qInfo() << "copyRealDataIntoJob" << endl; // create diffDataItem together with realDataItem
if(!diffDataItem()) { if(!diffDataItem()) {
if(real_data->isIntensityData()) if(real_data->isIntensityData())
model()->insertItem<IntensityDataItem>(this, -1, T_DIFF); model()->insertItem<IntensityDataItem>(this, -1, T_DIFF);
else else if(real_data->isSpecularData())
model()->insertItem<SpecularDataItem>(this, -1, T_DIFF); model()->insertItem<SpecularDataItem>(this, -1, T_DIFF);
qInfo() << "JobItem::diff inserted in copy" << endl; else
} ASSERT(0)
return model()->copyItem(real_data, this, T_REALDATA); // immediately create coordinate system and axes units
if (instrumentItem()) {
GUI::Model::JobItemUtils::setIntensityItemCoords(diffDataItem(), instrumentItem());
diffDataItem()->updateCoords(instrumentItem());
}
}
RealDataItem* realDataCopy = model()->copyItem(real_data, this, T_REALDATA);
if(!isSpecularJob()) {
realDataCopy->intensityDataItem()->setGradient(intensityDataItem()->getGradient());
}
return realDataCopy;
} }
RealDataItem* JobItem::createRealDataItem() RealDataItem* JobItem::createRealDataItem()
......
...@@ -171,13 +171,6 @@ T* JobItem::setDataType() ...@@ -171,13 +171,6 @@ 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");
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);
} }
......
...@@ -175,32 +175,32 @@ void IntensityDataCanvas::initRotation() ...@@ -175,32 +175,32 @@ void IntensityDataCanvas::initRotation()
void IntensityDataCanvas::onPropertyChanged(const QString& name) void IntensityDataCanvas::onPropertyChanged(const QString& name)
{ {
if (IntensityDataItem::isGradientPropertyName(name)) { // if (IntensityDataItem::isGradientPropertyName(name)) {
QSettings settings; // QSettings settings;
settings.setValue(SettingsKeyGradient, intensityDataItem()->getGradientValue()); // settings.setValue(SettingsKeyGradient, intensityDataItem()->getGradientValue());
} else if (IntensityDataItem::isInterpolatedPropertyName(name)) { // } else if (IntensityDataItem::isInterpolatedPropertyName(name)) {
QSettings settings; // QSettings settings;
settings.setValue(SettingsKeyInterpolation, intensityDataItem()->isInterpolated()); // settings.setValue(SettingsKeyInterpolation, intensityDataItem()->isInterpolated());
} // }
} }
//! Apply persistent settings (gradient, interpolation) to IntensityDataItem. //! Apply persistent settings (gradient, interpolation) to IntensityDataItem.
void IntensityDataCanvas::applyPersistentSettings() void IntensityDataCanvas::applyPersistentSettings()
{ {
QSettings settings; // QSettings settings;
if (settings.contains(SettingsKeyGradient)) { // if (settings.contains(SettingsKeyGradient)) {
ComboProperty combo = intensityDataItem()->getGradient(); // ComboProperty combo = intensityDataItem()->getGradient();
QString persistentGradient = settings.value(SettingsKeyGradient).toString(); // QString persistentGradient = settings.value(SettingsKeyGradient).toString();
if (combo.getValue() != persistentGradient) { // if (combo.getValue() != persistentGradient) {
combo.setValue(persistentGradient); // combo.setValue(persistentGradient);
intensityDataItem()->setGradient(combo); // intensityDataItem()->setGradient(combo);
} // }
} // }
if (settings.contains(SettingsKeyInterpolation)) { // if (settings.contains(SettingsKeyInterpolation)) {
bool value = settings.value(SettingsKeyInterpolation).toBool(); // bool value = settings.value(SettingsKeyInterpolation).toBool();
intensityDataItem()->setInterpolated(value); // intensityDataItem()->setInterpolated(value);
} // }
} }
...@@ -55,14 +55,16 @@ IntensityDataWidget::IntensityDataWidget(QWidget* parent) ...@@ -55,14 +55,16 @@ IntensityDataWidget::IntensityDataWidget(QWidget* parent)
void IntensityDataWidget::setItem(SessionItem* job_Item) void IntensityDataWidget::setItem(SessionItem* job_Item)
{ {
SessionItemWidget::setItem(job_Item); SessionItemWidget::setItem(job_Item); // now we can access to jobItem()
// now we can access to JobItem
m_intensityCanvas->setItem(intensityDataItem()); m_intensityCanvas->setItem(intensityDataItem());
#ifdef USE_MAPPERS #ifdef USE_MAPPERS
m_propertyWidget->setItem({intensityDataItem()}); m_propertyWidget->setItem({intensityDataItem()});
#else #else
qInfo() << intensityDataItem() << realIntensityDataItem() << diffIntensityDataItem() << endl; qInfo() << endl
<< "simu" << intensityDataItem() << endl
<< "real" << realIntensityDataItem() << endl
<< "diff" << diffIntensityDataItem() << endl;
m_propertyWidget->setItem({intensityDataItem(), m_propertyWidget->setItem({intensityDataItem(),
realIntensityDataItem(), realIntensityDataItem(),
diffIntensityDataItem()}); diffIntensityDataItem()});
......
...@@ -135,7 +135,6 @@ void DiffItemController::setItem(JobItem* job_item) ...@@ -135,7 +135,6 @@ 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();
......
...@@ -106,7 +106,10 @@ void FitComparisonWidget::subscribeToItem() ...@@ -106,7 +106,10 @@ void FitComparisonWidget::subscribeToItem()
#ifdef USE_MAPPERS #ifdef USE_MAPPERS
m_propertyWidget->setItem({simulatedDataItem()}); m_propertyWidget->setItem({simulatedDataItem()});
#else #else
qInfo() << simulatedDataItem() << realDataItem() << diffItem() << endl; qInfo() << endl
<< "simu" << simulatedDataItem() << endl
<< "real" << realDataItem() << endl
<< "diff" << diffItem() << endl;
m_propertyWidget->setItem({simulatedDataItem(), realDataItem(), diffItem()}); m_propertyWidget->setItem({simulatedDataItem(), realDataItem(), diffItem()});
#endif #endif
} }
......
...@@ -221,14 +221,14 @@ void ColorMap::subscribeToItem() ...@@ -221,14 +221,14 @@ void ColorMap::subscribeToItem()
intensityItem()->mapper()->setOnValueChange([this]() { onIntensityModified(); }, this); intensityItem()->mapper()->setOnValueChange([this]() { onIntensityModified(); }, this);
#else #else
connect(intensityItem(), &IntensityDataItem::replotRequested, this, [=]() { connect(intensityItem(), &IntensityDataItem::axesUnitsReplotRequested, this, [=]() {
setAxesRangeConnected(false);
m_customPlot->xAxis->setRange(GUI::View::RangeUtils::itemZoomX(intensityItem()));
m_customPlot->yAxis->setRange(GUI::View::RangeUtils::itemZoomY(intensityItem()));
setAxesRangeConnected(true);
setAxesRangeFromItem(intensityItem()); setAxesRangeFromItem(intensityItem());
setDataFromItem(intensityItem()); setAxesZoomFromItem(intensityItem());
setAxesLabelsFromItem(intensityItem());
replot();
});
connect(intensityItem(), &IntensityDataItem::gradientChanged, this, [=]() {
m_colorMap->setGradient(GUI::View::RangeUtils::itemGradient(intensityItem()));
replot(); replot();
}); });
#endif #endif
......
...@@ -80,8 +80,10 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec) ...@@ -80,8 +80,10 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
m_mainLayout->addRow("Color scheme:", createComboBox(first_item->gradient(), m_mainLayout->addRow("Color scheme:", createComboBox(first_item->gradient(),
[=](int newIndex){ [=](int newIndex){
for(IntensityDataItem* item : m_items_vec) for(IntensityDataItem* item : m_items_vec)
if(item) if(item) {
item->gradient().setCurrentIndex(newIndex); item->gradient().setCurrentIndex(newIndex);
emit item->gradientChanged();
}
})); }));
m_mainLayout->addRow(createCheckBox("Interpolate", m_mainLayout->addRow(createCheckBox("Interpolate",
...@@ -151,7 +153,7 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec) ...@@ -151,7 +153,7 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
item->blockSignals(true); item->blockSignals(true);
item->updateCoords(jobItem()->instrumentItem()); item->updateCoords(jobItem()->instrumentItem());
item->blockSignals(false); item->blockSignals(false);
emit item->replotRequested(); emit item->axesUnitsReplotRequested();
} }
}); });
} }
......
...@@ -64,8 +64,19 @@ void ProjectionsEditor::setContext(SessionModel* model, const QModelIndex& shape ...@@ -64,8 +64,19 @@ void ProjectionsEditor::setContext(SessionModel* model, const QModelIndex& shape
delete m_selectionModel; delete m_selectionModel;
m_selectionModel = new QItemSelectionModel(model, this); m_selectionModel = new QItemSelectionModel(model, this);
//#ifdef USE_MAPPERS
m_propertyPanel->setItem({intensityItem}); m_propertyPanel->setItem({intensityItem});
//#else
// qInfo() << endl
// << "simu" << intensityDataItem() << endl
// << "real" << realIntensityDataItem() << endl
// << "diff" << diffIntensityDataItem() << endl;
// m_propertyPanel->setItem({intensityDataItem(),
// realIntensityDataItem(),
// diffIntensityDataItem()});
//#endif
m_projectionsCanvas->setSelectionModel(m_selectionModel); m_projectionsCanvas->setSelectionModel(m_selectionModel);
m_projectionsCanvas->setContext(model, shapeContainerIndex, intensityItem); m_projectionsCanvas->setContext(model, shapeContainerIndex, intensityItem);
m_projectionsWidget->setItem(intensityItem); m_projectionsWidget->setItem(intensityItem);
......
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