Skip to content
Snippets Groups Projects
Commit a7267a2e authored by Yurov, Dmitry's avatar Yurov, Dmitry
Browse files

Renamed SpecularPlotWithDataView --> Plot1D

Redmine: #2106
parent 82fdbde6
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// //
// BornAgain: simulate and fit scattering at grazing incidence // BornAgain: simulate and fit scattering at grazing incidence
// //
//! @file GUI/coregui/Views/SpecularDataWidgets/SpecularPlotWithDataView.cpp //! @file GUI/coregui/Views/SpecularDataWidgets/Plot1D.cpp
//! @brief Implements class SpecularPlotWithDataView //! @brief Implements class Plot1D
//! //!
//! @homepage http://www.bornagainproject.org //! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING) //! @license GNU General Public License v3 or higher (see COPYING)
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// //
// ************************************************************************** // // ************************************************************************** //
#include "SpecularPlotWithDataView.h" #include "Plot1D.h"
#include "AxesItems.h" #include "AxesItems.h"
#include "ColorMapUtils.h" #include "ColorMapUtils.h"
#include "DataItem.h" #include "DataItem.h"
...@@ -30,7 +30,7 @@ const int replot_update_interval = 10; ...@@ -30,7 +30,7 @@ const int replot_update_interval = 10;
int getBin(double x, const QCPGraph* graph); int getBin(double x, const QCPGraph* graph);
} }
SpecularPlotWithDataView::SpecularPlotWithDataView(QWidget* parent) Plot1D::Plot1D(QWidget* parent)
: ScientificPlot(parent, PLOT_TYPE::Plot1D), m_custom_plot(new QCustomPlot), : ScientificPlot(parent, PLOT_TYPE::Plot1D), m_custom_plot(new QCustomPlot),
m_update_timer(new UpdateTimer(replot_update_interval, this)), m_block_update(true) m_update_timer(new UpdateTimer(replot_update_interval, this)), m_block_update(true)
{ {
...@@ -48,7 +48,7 @@ SpecularPlotWithDataView::SpecularPlotWithDataView(QWidget* parent) ...@@ -48,7 +48,7 @@ SpecularPlotWithDataView::SpecularPlotWithDataView(QWidget* parent)
setMouseTrackingEnabled(true); setMouseTrackingEnabled(true);
} }
PlotEventInfo SpecularPlotWithDataView::eventInfo(double xpos, double ypos) const PlotEventInfo Plot1D::eventInfo(double xpos, double ypos) const
{ {
PlotEventInfo result(plotType()); PlotEventInfo result(plotType());
if (!viewItem()) if (!viewItem())
...@@ -63,18 +63,18 @@ PlotEventInfo SpecularPlotWithDataView::eventInfo(double xpos, double ypos) cons ...@@ -63,18 +63,18 @@ PlotEventInfo SpecularPlotWithDataView::eventInfo(double xpos, double ypos) cons
return result; return result;
} }
void SpecularPlotWithDataView::setLog(bool log) void Plot1D::setLog(bool log)
{ {
ColorMapUtils::setLogz(m_custom_plot->yAxis, log); ColorMapUtils::setLogz(m_custom_plot->yAxis, log);
ColorMapUtils::setLogz(m_custom_plot->yAxis2, log); ColorMapUtils::setLogz(m_custom_plot->yAxis2, log);
} }
void SpecularPlotWithDataView::resetView() void Plot1D::resetView()
{ {
viewItem()->resetView(); viewItem()->resetView();
} }
void SpecularPlotWithDataView::onPropertyChanged(const QString& property_name) void Plot1D::onPropertyChanged(const QString& property_name)
{ {
if (m_block_update) if (m_block_update)
return; return;
...@@ -85,7 +85,7 @@ void SpecularPlotWithDataView::onPropertyChanged(const QString& property_name) ...@@ -85,7 +85,7 @@ void SpecularPlotWithDataView::onPropertyChanged(const QString& property_name)
} }
} }
void SpecularPlotWithDataView::onXaxisRangeChanged(QCPRange newRange) void Plot1D::onXaxisRangeChanged(QCPRange newRange)
{ {
m_block_update = true; m_block_update = true;
viewItem()->setLowerX(newRange.lower); viewItem()->setLowerX(newRange.lower);
...@@ -93,7 +93,7 @@ void SpecularPlotWithDataView::onXaxisRangeChanged(QCPRange newRange) ...@@ -93,7 +93,7 @@ void SpecularPlotWithDataView::onXaxisRangeChanged(QCPRange newRange)
m_block_update = false; m_block_update = false;
} }
void SpecularPlotWithDataView::onYaxisRangeChanged(QCPRange newRange) void Plot1D::onYaxisRangeChanged(QCPRange newRange)
{ {
m_block_update = true; m_block_update = true;
viewItem()->setLowerY(newRange.lower); viewItem()->setLowerY(newRange.lower);
...@@ -101,12 +101,12 @@ void SpecularPlotWithDataView::onYaxisRangeChanged(QCPRange newRange) ...@@ -101,12 +101,12 @@ void SpecularPlotWithDataView::onYaxisRangeChanged(QCPRange newRange)
m_block_update = false; m_block_update = false;
} }
void SpecularPlotWithDataView::onTimeToReplot() void Plot1D::onTimeToReplot()
{ {
m_custom_plot->replot(); m_custom_plot->replot();
} }
void SpecularPlotWithDataView::subscribeToItem() void Plot1D::subscribeToItem()
{ {
initPlots(); initPlots();
refreshPlotData(); refreshPlotData();
...@@ -127,14 +127,14 @@ void SpecularPlotWithDataView::subscribeToItem() ...@@ -127,14 +127,14 @@ void SpecularPlotWithDataView::subscribeToItem()
setConnected(true); setConnected(true);
} }
void SpecularPlotWithDataView::unsubscribeFromItem() void Plot1D::unsubscribeFromItem()
{ {
m_custom_plot->clearGraphs(); m_custom_plot->clearGraphs();
m_graph_map.clear(); m_graph_map.clear();
setConnected(false); setConnected(false);
} }
void SpecularPlotWithDataView::initPlots() void Plot1D::initPlots()
{ {
auto property_items = viewItem()->propertyItems<Data1DProperties>(); auto property_items = viewItem()->propertyItems<Data1DProperties>();
std::for_each( std::for_each(
...@@ -146,45 +146,45 @@ void SpecularPlotWithDataView::initPlots() ...@@ -146,45 +146,45 @@ void SpecularPlotWithDataView::initPlots()
}); });
} }
void SpecularPlotWithDataView::setConnected(bool isConnected) void Plot1D::setConnected(bool isConnected)
{ {
setAxesRangeConnected(isConnected); setAxesRangeConnected(isConnected);
setUpdateTimerConnected(isConnected); setUpdateTimerConnected(isConnected);
} }
void SpecularPlotWithDataView::setAxesRangeConnected(bool isConnected) void Plot1D::setAxesRangeConnected(bool isConnected)
{ {
if (isConnected) { if (isConnected) {
connect(m_custom_plot->xAxis, connect(m_custom_plot->xAxis,
static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
&SpecularPlotWithDataView::onXaxisRangeChanged, Qt::UniqueConnection); &Plot1D::onXaxisRangeChanged, Qt::UniqueConnection);
connect(m_custom_plot->yAxis, connect(m_custom_plot->yAxis,
static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
&SpecularPlotWithDataView::onYaxisRangeChanged, Qt::UniqueConnection); &Plot1D::onYaxisRangeChanged, Qt::UniqueConnection);
} else { } else {
disconnect(m_custom_plot->xAxis, disconnect(m_custom_plot->xAxis,
static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
&SpecularPlotWithDataView::onXaxisRangeChanged); &Plot1D::onXaxisRangeChanged);
disconnect(m_custom_plot->yAxis, disconnect(m_custom_plot->yAxis,
static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this, static_cast<void (QCPAxis::*)(const QCPRange&)>(&QCPAxis::rangeChanged), this,
&SpecularPlotWithDataView::onYaxisRangeChanged); &Plot1D::onYaxisRangeChanged);
} }
} }
void SpecularPlotWithDataView::setUpdateTimerConnected(bool isConnected) void Plot1D::setUpdateTimerConnected(bool isConnected)
{ {
if (isConnected) if (isConnected)
connect(m_update_timer, &UpdateTimer::timeToUpdate, this, connect(m_update_timer, &UpdateTimer::timeToUpdate, this,
&SpecularPlotWithDataView::onTimeToReplot, Qt::UniqueConnection); &Plot1D::onTimeToReplot, Qt::UniqueConnection);
else else
disconnect(m_update_timer, &UpdateTimer::timeToUpdate, this, disconnect(m_update_timer, &UpdateTimer::timeToUpdate, this,
&SpecularPlotWithDataView::onTimeToReplot); &Plot1D::onTimeToReplot);
} }
void SpecularPlotWithDataView::refreshPlotData() void Plot1D::refreshPlotData()
{ {
auto view_item = viewItem(); auto view_item = viewItem();
assert(view_item); assert(view_item);
...@@ -201,7 +201,7 @@ void SpecularPlotWithDataView::refreshPlotData() ...@@ -201,7 +201,7 @@ void SpecularPlotWithDataView::refreshPlotData()
m_block_update = false; m_block_update = false;
} }
void SpecularPlotWithDataView::setAxesRangeFromItem(DataItem1DView* item) void Plot1D::setAxesRangeFromItem(DataItem1DView* item)
{ {
m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); m_custom_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
m_custom_plot->axisRect()->setupFullAxesBox(true); m_custom_plot->axisRect()->setupFullAxesBox(true);
...@@ -213,13 +213,13 @@ void SpecularPlotWithDataView::setAxesRangeFromItem(DataItem1DView* item) ...@@ -213,13 +213,13 @@ void SpecularPlotWithDataView::setAxesRangeFromItem(DataItem1DView* item)
setAxesRangeConnected(true); setAxesRangeConnected(true);
} }
void SpecularPlotWithDataView::setAxesLabelsFromItem(DataItem1DView* item) void Plot1D::setAxesLabelsFromItem(DataItem1DView* item)
{ {
setLabel(item->xAxisItem(), m_custom_plot->xAxis, item->getXaxisTitle()); setLabel(item->xAxisItem(), m_custom_plot->xAxis, item->getXaxisTitle());
setLabel(item->yAxisItem(), m_custom_plot->yAxis, item->getYaxisTitle()); setLabel(item->yAxisItem(), m_custom_plot->yAxis, item->getYaxisTitle());
} }
void SpecularPlotWithDataView::setLabel(const BasicAxisItem* item, QCPAxis* axis, QString label) void Plot1D::setLabel(const BasicAxisItem* item, QCPAxis* axis, QString label)
{ {
assert(item && axis); assert(item && axis);
if (item->getItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE).toBool()) if (item->getItemValue(BasicAxisItem::P_TITLE_IS_VISIBLE).toBool())
...@@ -228,7 +228,7 @@ void SpecularPlotWithDataView::setLabel(const BasicAxisItem* item, QCPAxis* axis ...@@ -228,7 +228,7 @@ void SpecularPlotWithDataView::setLabel(const BasicAxisItem* item, QCPAxis* axis
axis->setLabel(QString()); axis->setLabel(QString());
} }
void SpecularPlotWithDataView::setDataFromItem(DataItem1DView* item) void Plot1D::setDataFromItem(DataItem1DView* item)
{ {
assert(item); assert(item);
auto property_items = item->propertyItems<Data1DProperties>(); auto property_items = item->propertyItems<Data1DProperties>();
...@@ -247,20 +247,20 @@ void SpecularPlotWithDataView::setDataFromItem(DataItem1DView* item) ...@@ -247,20 +247,20 @@ void SpecularPlotWithDataView::setDataFromItem(DataItem1DView* item)
}); });
} }
DataItem1DView* SpecularPlotWithDataView::viewItem() DataItem1DView* Plot1D::viewItem()
{ {
return const_cast<DataItem1DView*>( return const_cast<DataItem1DView*>(
static_cast<const SpecularPlotWithDataView*>(this)->viewItem()); static_cast<const Plot1D*>(this)->viewItem());
} }
const DataItem1DView* SpecularPlotWithDataView::viewItem() const const DataItem1DView* Plot1D::viewItem() const
{ {
const auto result = dynamic_cast<const DataItem1DView*>(currentItem()); const auto result = dynamic_cast<const DataItem1DView*>(currentItem());
Q_ASSERT(result); Q_ASSERT(result);
return result; return result;
} }
void SpecularPlotWithDataView::modifyAxesProperties(const QString& axisName, void Plot1D::modifyAxesProperties(const QString& axisName,
const QString& propertyName) const QString& propertyName)
{ {
if (m_block_update) if (m_block_update)
...@@ -292,7 +292,7 @@ void SpecularPlotWithDataView::modifyAxesProperties(const QString& axisName, ...@@ -292,7 +292,7 @@ void SpecularPlotWithDataView::modifyAxesProperties(const QString& axisName,
} }
} }
void SpecularPlotWithDataView::replot() void Plot1D::replot()
{ {
m_update_timer->scheduleUpdate(); m_update_timer->scheduleUpdate();
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// //
// BornAgain: simulate and fit scattering at grazing incidence // BornAgain: simulate and fit scattering at grazing incidence
// //
//! @file GUI/coregui/Views/SpecularDataWidgets/SpecularPlotWithDataView.h //! @file GUI/coregui/Views/SpecularDataWidgets/Plot1D.h
//! @brief Defines class SpecularPlotWithDataView //! @brief Defines class Plot1D
//! //!
//! @homepage http://www.bornagainproject.org //! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING) //! @license GNU General Public License v3 or higher (see COPYING)
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
// //
// ************************************************************************** // // ************************************************************************** //
#ifndef SPECULARPLOTWITHDATAVIEW_H #ifndef PLOT1D_H
#define SPECULARPLOTWITHDATAVIEW_H #define PLOT1D_H
#include "ScientificPlot.h" #include "ScientificPlot.h"
#include "qcustomplot.h" #include "qcustomplot.h"
...@@ -29,12 +29,12 @@ class UpdateTimer; ...@@ -29,12 +29,12 @@ class UpdateTimer;
//! DataItem1DView. Provides minimal functionality for data plotting and axes interaction. Should be //! DataItem1DView. Provides minimal functionality for data plotting and axes interaction. Should be
//! a component for more complicated plotting widgets. //! a component for more complicated plotting widgets.
class SpecularPlotWithDataView : public ScientificPlot class Plot1D : public ScientificPlot
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SpecularPlotWithDataView(QWidget* parent = nullptr); explicit Plot1D(QWidget* parent = nullptr);
QSize sizeHint() const override { return QSize(500, 400); } QSize sizeHint() const override { return QSize(500, 400); }
QSize minimumSizeHint() const override { return QSize(128, 128); } QSize minimumSizeHint() const override { return QSize(128, 128); }
...@@ -110,4 +110,4 @@ private: ...@@ -110,4 +110,4 @@ private:
bool m_block_update; bool m_block_update;
}; };
#endif // SPECULARPLOTWITHDATAVIEW_H #endif // PLOT1D_H
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "TestView.h" #include "TestView.h"
#include "AccordionWidget.h" #include "AccordionWidget.h"
#include "ApplicationModels.h"
#include "DataItem1DView.h" #include "DataItem1DView.h"
#include "JobModel.h" #include "JobModel.h"
#include "JobItem.h" #include "JobItem.h"
...@@ -21,11 +22,10 @@ ...@@ -21,11 +22,10 @@
#include "MaterialEditor.h" #include "MaterialEditor.h"
#include "MinimizerItem.h" #include "MinimizerItem.h"
#include "MinimizerSettingsWidget.h" #include "MinimizerSettingsWidget.h"
#include "ApplicationModels.h" #include "Plot1D.h"
#include "RealDataItem.h" #include "RealDataItem.h"
#include "SampleModel.h" #include "SampleModel.h"
#include "SpecularDataItem.h" #include "SpecularDataItem.h"
#include "SpecularPlotWithDataView.h"
#include "TestComponentView.h" #include "TestComponentView.h"
#include "mainwindow.h" #include "mainwindow.h"
#include <QTreeView> #include <QTreeView>
...@@ -215,7 +215,7 @@ void TestView::test_specular_data_widget() ...@@ -215,7 +215,7 @@ void TestView::test_specular_data_widget()
QVBoxLayout* layout = new QVBoxLayout; QVBoxLayout* layout = new QVBoxLayout;
layout->setMargin(0); layout->setMargin(0);
layout->setSpacing(0); layout->setSpacing(0);
auto widget = new SpecularPlotWithDataView(this); auto widget = new Plot1D(this);
widget->setItem(job_item->dataItemView()); widget->setItem(job_item->dataItemView());
layout->addWidget(widget); layout->addWidget(widget);
setLayout(layout); setLayout(layout);
......
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