Skip to content
Snippets Groups Projects
Commit b8ac5a82 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

Plot2DFram w/o data member and w/o ctor arg

parent ba41010d
No related branches found
No related tags found
1 merge request!2444Plot1|2DFrame are stateless, StackedDataFrame switches between widgets that have been created at start up
...@@ -29,14 +29,11 @@ ...@@ -29,14 +29,11 @@
#include <QSplitter> #include <QSplitter>
#include <QStackedWidget> #include <QStackedWidget>
Plot2DFrame::Plot2DFrame(Data2DItem* item) Plot2DFrame::Plot2DFrame()
: m_canvas2D(new MaskEditorCanvas) : m_canvas2D(new MaskEditorCanvas)
, m_canvas1D(new ProjectedGraphsCanvas) , m_canvas1D(new ProjectedGraphsCanvas)
, m_masks_panel(new MasksPanel) , m_masks_panel(new MasksPanel)
, m_data_item(item)
{ {
ASSERT(item);
auto* layout = new QHBoxLayout; auto* layout = new QHBoxLayout;
setLayout(layout); setLayout(layout);
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
...@@ -71,7 +68,7 @@ Plot2DFrame::Plot2DFrame(Data2DItem* item) ...@@ -71,7 +68,7 @@ Plot2DFrame::Plot2DFrame(Data2DItem* item)
[panels] { panels->setHidden(!panels->isHidden()); }); [panels] { panels->setHidden(!panels->isHidden()); });
connect(gActions->save_projections, &QAction::triggered, connect(gActions->save_projections, &QAction::triggered,
[this] { GUI::IO::saveProjections(m_data_item); }); [this] { GUI::IO::saveProjections(dataItem()); });
connect(gActions->delete_projection, &QAction::triggered, [this] { removeProjection(); }); connect(gActions->delete_projection, &QAction::triggered, [this] { removeProjection(); });
...@@ -97,10 +94,15 @@ Plot2DFrame::Plot2DFrame(Data2DItem* item) ...@@ -97,10 +94,15 @@ Plot2DFrame::Plot2DFrame(Data2DItem* item)
showEvent(nullptr); showEvent(nullptr);
} }
Data2DItem* Plot2DFrame::dataItem()
{
return m_data_source->realData2DItem();
}
void Plot2DFrame::updateFrame() void Plot2DFrame::updateFrame()
{ {
ASSERT(m_data_item); ASSERT(dataItem());
MasksQModel* masks_qmodel = m_data_item->getOrCreateModel(); MasksQModel* masks_qmodel = dataItem()->getOrCreateModel();
ASSERT(masks_qmodel); ASSERT(masks_qmodel);
m_masks_panel->updateMasksPanel(masks_qmodel); m_masks_panel->updateMasksPanel(masks_qmodel);
...@@ -108,22 +110,22 @@ void Plot2DFrame::updateFrame() ...@@ -108,22 +110,22 @@ void Plot2DFrame::updateFrame()
// It prevents problem with switching between datasets in projection mode. // It prevents problem with switching between datasets in projection mode.
m_canvas1D->disconnectItem(); m_canvas1D->disconnectItem();
m_canvas2D->updateCanvas(m_data_item); m_canvas2D->updateCanvas(dataItem());
m_canvas1D->setData2DItem(m_data_item); m_canvas1D->setData2DItem(dataItem());
} }
void Plot2DFrame::showEvent(QShowEvent*) void Plot2DFrame::showEvent(QShowEvent*)
{ {
ASSERT(m_data_item); ASSERT(dataItem());
updateFrame(); updateFrame();
} }
void Plot2DFrame::removeProjection() void Plot2DFrame::removeProjection()
{ {
if (!m_data_item) if (!dataItem())
return; return;
MasksQModel* masks_qmodel = m_data_item->getOrCreateProjectionModel(); MasksQModel* masks_qmodel = dataItem()->getOrCreateProjectionModel();
ASSERT(masks_qmodel); ASSERT(masks_qmodel);
masks_qmodel->deleteItem(); masks_qmodel->deleteItem();
gDoc->setModified(); gDoc->setModified();
......
...@@ -27,18 +27,18 @@ class ProjectedGraphsCanvas; ...@@ -27,18 +27,18 @@ class ProjectedGraphsCanvas;
class Plot2DFrame : public QWidget { class Plot2DFrame : public QWidget {
public: public:
Plot2DFrame(Data2DItem* item); Plot2DFrame();
private: private:
void updateFrame(); void updateFrame();
void showEvent(QShowEvent*) override; void showEvent(QShowEvent*) override;
void removeProjection(); void removeProjection();
Data2DItem* dataItem();
MaskEditorCanvas* m_canvas2D; //!< canvas with color map at the top MaskEditorCanvas* m_canvas2D; //!< canvas with color map at the top
ProjectedGraphsCanvas* m_canvas1D; //!< bottom widget to draw projections plot ProjectedGraphsCanvas* m_canvas1D; //!< bottom widget to draw projections plot
MasksPanel* m_masks_panel; //!< panel with mask list and properties of one mask MasksPanel* m_masks_panel; //!< panel with mask list and properties of one mask
Data2DItem* m_data_item;
std::unique_ptr<DataSource> m_data_source; std::unique_ptr<DataSource> m_data_source;
}; };
......
...@@ -73,8 +73,8 @@ QWidget* StackedDataFrames::newFrame(QObject* obj) const ...@@ -73,8 +73,8 @@ QWidget* StackedDataFrames::newFrame(QObject* obj) const
{ {
if (auto* item = dynamic_cast<Data1DItem*>(obj)) if (auto* item = dynamic_cast<Data1DItem*>(obj))
return new SpecularFrame(item); return new SpecularFrame(item);
if (auto* item = dynamic_cast<Data2DItem*>(obj)) if (dynamic_cast<Data2DItem*>(obj))
return new Plot2DFrame(item); return new Plot2DFrame;
ASSERT_NEVER; ASSERT_NEVER;
} }
...@@ -108,8 +108,8 @@ QWidget* StackedJobFrames::newFrame(QObject* obj) const ...@@ -108,8 +108,8 @@ QWidget* StackedJobFrames::newFrame(QObject* obj) const
{ {
if (auto* item = dynamic_cast<Data1DItem*>(obj)) if (auto* item = dynamic_cast<Data1DItem*>(obj))
return new SpecularFrame(item); return new SpecularFrame(item);
if (auto* item = dynamic_cast<Data2DItem*>(obj)) if (dynamic_cast<Data2DItem*>(obj))
return new Plot2DFrame(item); return new Plot2DFrame;
if (auto* item = dynamic_cast<JobItem*>(obj)) { if (auto* item = dynamic_cast<JobItem*>(obj)) {
if (item->rank() == 1) if (item->rank() == 1)
return new Fit1DFrame(item); return new Fit1DFrame(item);
......
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