Commit 4efa1b68 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

projections accepts 3 items

parent 9a3834ef
Pipeline #67102 canceled with stage
in 7 minutes and 10 seconds
......@@ -201,7 +201,6 @@ class GroupInfo;
//!
//! This code part again shows the (highly error-prone) string-based type checking.
//#define USE_MAPPERS
#include <QDebug>
class BA_CORE_API_ SessionItem {
friend class SessionModel;
......
......@@ -61,10 +61,6 @@ 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,7 +84,6 @@ QList<QAction*> FitComparisonWidget::actionList()
void FitComparisonWidget::subscribeToItem()
{
qInfo() << "FitComparisonWidget::subscribeToItem" << endl;
if (!jobItem()->isValidForFitting())
return;
......@@ -107,10 +106,6 @@ 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,7 +125,6 @@ void ColorMap::onPropertyChanged(const QString& property_name)
void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& propertyName)
{
#ifdef USE_MAPPERS
if (m_block_update)
return;
......@@ -163,7 +162,6 @@ void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& pro
replot();
}
}
#endif
}
//! Propagate zmin, zmax back to IntensityDataItem
......@@ -188,7 +186,6 @@ void ColorMap::onXaxisRangeChanged(QCPRange newRange)
//! 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);
......@@ -227,6 +224,10 @@ void ColorMap::subscribeToItem()
intensityItem()->mapper()->setOnValueChange([this]() { onIntensityModified(); }, this);
#else
// datafield
connect(intensityItem(), &IntensityDataItem::datafieldChanged, this, [=]() {
onIntensityModified();
});
// units
connect(intensityItem(), &IntensityDataItem::axesUnitsReplotRequested, this, [=]() {
setAxesRangeFromItem(intensityItem());
......@@ -299,11 +300,12 @@ void ColorMap::subscribeToItem()
void ColorMap::unsubscribeFromItem()
{
#ifndef USE_MAPPERS
disconnect(intensityItem(), nullptr, this, nullptr);
disconnect(intensityItem()->xAxisItem(), nullptr, this, nullptr);
disconnect(intensityItem()->yAxisItem(), nullptr, this, nullptr);
disconnect(intensityItem()->zAxisItem(), nullptr, this, nullptr);
#endif
setConnected(false);
}
......
......@@ -54,23 +54,21 @@ void IntensityDataPropertyWidget::unsubscribe()
#ifdef USE_MAPPERS
FOR_EACH_ITEM item->mapper()->unsubscribe(this);
#else
FOR_EACH_ITEM {
disconnect(item, nullptr, this, nullptr);
qInfo() << "disco" << item<< endl;
}
FOR_EACH_ITEM disconnect(item, nullptr, this, nullptr);
#endif
}
void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
{
m_items_vec = itemsVec;
if(itemsVec.size() == 0)
return;
unsubscribe();
GUI::Util::Layout::clearLayout(m_mainLayout);
m_updaters.clear();
m_items_vec = itemsVec;
IntensityDataItem* first_item = itemsVec.first();
if (!first_item)
return;
......@@ -162,23 +160,19 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
[&](SessionItem*) { item = nullptr; }, this);
#else
// update values on panel
FOR_EACH_ITEM
connect(item, &IntensityDataItem::axesRangeChangedFromPlot, this, [=](){
updateUIValues();
});
FOR_EACH_ITEM {
qInfo() << "connect" << item << this;
// sync view area between sumulated, real and difference plots
FOR_EACH_ITEM
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;
if(otherItem && otherItem!=item)
emit otherItem->updateThisPlot();
}
});
}
// update axes with new units
FOR_EACH_ITEM
connect(item, &IntensityDataItem::axesUnitsChanged, this, [=](){
if(jobItem()) {
......@@ -188,6 +182,7 @@ void IntensityDataPropertyWidget::setItem(QVector<IntensityDataItem*> itemsVec)
emit item->axesUnitsReplotRequested();
}
});
// on items destroy
FOR_EACH_ITEM
connect(item, &IntensityDataItem::destroyed, this,
[&]() { item = nullptr; });
......
......@@ -15,6 +15,8 @@
#include "GUI/View/Projection/ProjectionsEditor.h"
#include "GUI/Model/Data/IntensityDataItem.h"
#include "GUI/Model/Model/SessionModel.h"
#include "GUI/Model/Job/JobItem.h"
#include "GUI/Model/Data/RealDataItem.h"
#include "GUI/View/PlotUtil/IntensityDataPropertyWidget.h"
#include "GUI/View/Projection/ProjectionsEditorActions.h"
#include "GUI/View/Projection/ProjectionsEditorCanvas.h"
......@@ -34,6 +36,7 @@ ProjectionsEditor::ProjectionsEditor(SessionItemWidget* upperSessionItemWidget,
upperSessionItemWidget)) // here not "this", because IntensityDataPropertyWidget requires
// access to jobItem
, m_selectionModel(nullptr)
, upperSessionItemWidget(upperSessionItemWidget)
{
addToolBar(Qt::RightToolBarArea, m_toolbar);
......@@ -64,19 +67,13 @@ void ProjectionsEditor::setContext(SessionModel* model, const QModelIndex& shape
delete m_selectionModel;
m_selectionModel = new QItemSelectionModel(model, this);
//#ifdef USE_MAPPERS
#ifdef USE_MAPPERS
m_propertyPanel->setItem({intensityItem});
//#else
// qInfo() << endl
// << "simu" << intensityDataItem() << endl
// << "real" << realIntensityDataItem() << endl
// << "diff" << diffIntensityDataItem() << endl;
// m_propertyPanel->setItem({intensityDataItem(),
// realIntensityDataItem(),
// diffIntensityDataItem()});
//#endif
#else
m_propertyPanel->setItem({simulatedIntensity(),
realIntensityDataItem(),
diffIntensityDataItem()});
#endif
m_projectionsCanvas->setSelectionModel(m_selectionModel);
m_projectionsCanvas->setContext(model, shapeContainerIndex, intensityItem);
m_projectionsWidget->setItem(intensityItem);
......@@ -92,6 +89,37 @@ void ProjectionsEditor::resetContext()
m_projectionsWidget->setItem(nullptr);
}
JobItem* ProjectionsEditor::jobItem()
{
SessionItemWidget* sessionItemWidget =
dynamic_cast<SessionItemWidget*>(upperSessionItemWidget);
if (!sessionItemWidget)
return nullptr;
return dynamic_cast<JobItem*>(sessionItemWidget->currentItem());
}
IntensityDataItem* ProjectionsEditor::simulatedIntensity()
{
return dynamic_cast<IntensityDataItem*>(jobItem()->dataItem());
}
IntensityDataItem* ProjectionsEditor::realIntensityDataItem()
{
if(jobItem() && jobItem()->realDataItem())
return jobItem()->realDataItem()->intensityDataItem();
else
return nullptr;
}
IntensityDataItem* ProjectionsEditor::diffIntensityDataItem()
{
if(jobItem())
return dynamic_cast<IntensityDataItem*>(jobItem()->diffDataItem());
else
return nullptr;
}
QList<QAction*> ProjectionsEditor::topToolbarActions()
{
return m_editorActions->topToolbarActions();
......
......@@ -28,6 +28,7 @@ class ProjectionsWidget;
class QItemSelectionModel;
class IntensityDataPropertyWidget;
class SessionItemWidget;
class JobItem;
//! Editor to draw projections on top of intensity plot. Part of
......@@ -42,6 +43,10 @@ public:
IntensityDataItem* intensityItem);
void resetContext();
JobItem* jobItem();
IntensityDataItem* simulatedIntensity();
IntensityDataItem* diffIntensityDataItem();
IntensityDataItem* realIntensityDataItem();
QList<QAction*> topToolbarActions();
......@@ -54,6 +59,8 @@ private:
ProjectionsWidget* m_projectionsWidget; //! bottom widget to draw projections plot
IntensityDataPropertyWidget* m_propertyPanel; //! panel at the right with properties
QItemSelectionModel* m_selectionModel;
// TODO: change access to JobItem
SessionItemWidget* upperSessionItemWidget;
};
#endif // BORNAGAIN_GUI_VIEW_PROJECTION_PROJECTIONSEDITOR_H
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