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

rm PlotEventInfo

parent 3b527803
No related branches found
No related tags found
1 merge request!2113rm PlotEventInfo
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "GUI/Support/Tool/UpdateTimer.h" #include "GUI/Support/Tool/UpdateTimer.h"
#include "GUI/Support/Util/QCP_Util.h" #include "GUI/Support/Util/QCP_Util.h"
#include "GUI/View/PlotUtil/PlotConstants.h" #include "GUI/View/PlotUtil/PlotConstants.h"
#include "GUI/View/PlotUtil/PlotEventInfo.h"
namespace { namespace {
...@@ -80,19 +79,6 @@ Data1DItem* SpecularPlot::currentData1DItem() const ...@@ -80,19 +79,6 @@ Data1DItem* SpecularPlot::currentData1DItem() const
return data1DItems().first(); return data1DItems().first();
} }
PlotEventInfo SpecularPlot::eventInfo(double xpos, double ypos) const
{
PlotEventInfo result(plotType());
result.setX(xpos);
result.setValue(ypos);
result.setInAxesRange(axesRangeContains(xpos, ypos));
result.setNx(bin(result.x(), m_plot->graph()));
return result;
}
QString SpecularPlot::infoString(const QPointF& pos) const QString SpecularPlot::infoString(const QPointF& pos) const
{ {
double x = m_plot->xAxis->pixelToCoord(pos.x()); double x = m_plot->xAxis->pixelToCoord(pos.x());
...@@ -108,7 +94,6 @@ QString SpecularPlot::infoString(const QPointF& pos) const ...@@ -108,7 +94,6 @@ QString SpecularPlot::infoString(const QPointF& pos) const
.arg(ix, 2); .arg(ix, 2);
} }
void SpecularPlot::setLog() void SpecularPlot::setLog()
{ {
if (!currentData1DItem()) if (!currentData1DItem())
......
...@@ -44,9 +44,6 @@ public: ...@@ -44,9 +44,6 @@ public:
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); }
//! Returns PlotEventInfo corresponding to given axes coordinates.
PlotEventInfo eventInfo(double xpos, double ypos) const override;
//! sets logarithmic scale //! sets logarithmic scale
void setLog(); void setLog();
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "GUI/Support/Tool/UpdateTimer.h" #include "GUI/Support/Tool/UpdateTimer.h"
#include "GUI/Support/Util/QCP_Util.h" #include "GUI/Support/Util/QCP_Util.h"
#include "GUI/View/PlotUtil/PlotConstants.h" #include "GUI/View/PlotUtil/PlotConstants.h"
#include "GUI/View/PlotUtil/PlotEventInfo.h"
#include <qcustomplot.h> #include <qcustomplot.h>
namespace { namespace {
...@@ -149,28 +148,6 @@ QRectF ColorMap::viewportRectangleInWidgetCoordinates() // only used by Mask/Sce ...@@ -149,28 +148,6 @@ QRectF ColorMap::viewportRectangleInWidgetCoordinates() // only used by Mask/Sce
return {left, top, right - left, bottom - top}; return {left, top, right - left, bottom - top};
} }
PlotEventInfo ColorMap::eventInfo(double xpos, double ypos) const
{
PlotEventInfo result(plotType());
const Data2DItem* ii = data2DItem();
if (!ii)
return result;
int nx(0), ny(0);
m_colorMap->data()->coordToCell(xpos, ypos, &nx, &ny);
result.setX(xpos);
result.setY(ypos);
result.setNx(nx);
result.setNy(ny);
result.setInAxesRange(axesRangeContains(xpos, ypos));
result.setValue(m_colorMap->data()->cell(result.nx(), result.ny()));
result.setLogValueAxis(ii->isLog());
return result;
}
QString ColorMap::infoString(const QPointF& pos) const QString ColorMap::infoString(const QPointF& pos) const
{ {
double x = m_plot->xAxis->pixelToCoord(pos.x()); double x = m_plot->xAxis->pixelToCoord(pos.x());
......
...@@ -44,9 +44,6 @@ public: ...@@ -44,9 +44,6 @@ public:
//! Returns rectangle representing current axes zoom state in widget coordinates //! Returns rectangle representing current axes zoom state in widget coordinates
QRectF viewportRectangleInWidgetCoordinates(); QRectF viewportRectangleInWidgetCoordinates();
//! Returns PlotEventInfo corresponding to given axes coordinates.
PlotEventInfo eventInfo(double xpos, double ypos) const override;
QString infoString(const QPointF& pos) const override; QString infoString(const QPointF& pos) const override;
signals: signals:
......
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/PlotUtil/PlotEventInfo.cpp
//! @brief Implementation of the class PlotEventInfo
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/View/PlotUtil/PlotEventInfo.h"
#include "Base/Py/PyFmt.h"
PlotEventInfo::PlotEventInfo(PLOT_TYPE type)
: m_in_axes_range(false)
, m_log_valued_axis(false)
, m_x(0.0)
, m_y(0.0)
, m_value(0.0)
, m_nx(0)
, m_ny(0)
, m_info_type(type)
{
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/PlotUtil/PlotEventInfo.h
//! @brief Defines the class PlotEventInfo
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTINFO_H
#define BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTINFO_H
#include "GUI/View/PlotUtil/ScientificPlot.h"
#include <QString>
//! Contains parameters of mouse position in 1D or 2D plot.
class PlotEventInfo {
using PLOT_TYPE = ScientificPlot::PLOT_TYPE;
public:
PlotEventInfo(PLOT_TYPE type);
// setters, getters
void setInAxesRange(bool flag) { m_in_axes_range = flag; }
bool inAxesRange() const { return m_in_axes_range; }
void setLogValueAxis(bool flag) { m_log_valued_axis = flag; }
bool isLogValueAxis() const { return m_log_valued_axis; }
void setX(double x) { m_x = x; }
double x() const { return m_x; }
void setY(double y) { m_y = y; }
double y() const { return m_y; }
void setValue(double value) { m_value = value; }
double value() const { return m_value; }
void setNx(int nx) { m_nx = nx; }
int nx() const { return m_nx; }
void setNy(int ny) { m_ny = ny; }
int ny() const { return m_ny; }
private:
bool m_in_axes_range, m_log_valued_axis;
double m_x, m_y, m_value;
int m_nx, m_ny;
PLOT_TYPE m_info_type;
};
#endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTINFO_H
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <QWidget> #include <QWidget>
class PlotEventHelper; class PlotEventHelper;
class PlotEventInfo;
class QCustomPlot; class QCustomPlot;
class QMouseEvent; class QMouseEvent;
...@@ -32,9 +31,6 @@ public: ...@@ -32,9 +31,6 @@ public:
explicit ScientificPlot(QWidget* parent, PLOT_TYPE plot_type); explicit ScientificPlot(QWidget* parent, PLOT_TYPE plot_type);
~ScientificPlot() override; ~ScientificPlot() override;
//! Returns plot descriptor corresponding to given axes coordinates.
virtual PlotEventInfo eventInfo(double xpos, double ypos) const = 0;
QCustomPlot* customPlot() { return m_plot; } QCustomPlot* customPlot() { return m_plot; }
const QCustomPlot* customPlot() const { return m_plot; } const QCustomPlot* customPlot() const { return m_plot; }
......
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