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

mv-src GUI/View/PlotUtil/ScientificPlotEvent GUI/View/PlotUtil/PlotEventHelper

parent d8acc2b1
No related branches found
No related tags found
1 merge request!2101cleanup of GUI/Masks ctd; decouple MaskGraphicsProxy from SceneAdaptor
Pipeline #118977 failed
......@@ -2,8 +2,8 @@
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/PlotUtil/ScientificPlotEvent.cpp
//! @brief Implements class ScientificPlotEvent
//! @file GUI/View/PlotUtil/PlotEventHelper.cpp
//! @brief Implements class PlotEventHelpert
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
......@@ -12,39 +12,39 @@
//
// ************************************************************************************************
#include "GUI/View/PlotUtil/ScientificPlotEvent.h"
#include "GUI/View/PlotUtil/PlotEventHelper.h"
#include <QMouseEvent>
#include <qcustomplot.h>
ScientificPlotEvent::ScientificPlotEvent(ScientificPlot* scientific_plot)
PlotEventHelpert::PlotEventHelpert(ScientificPlot* scientific_plot)
: QObject(scientific_plot)
, m_plot(scientific_plot)
, m_prevPos(scientific_plot->plotType())
{
}
ScientificPlotEvent::~ScientificPlotEvent() = default;
PlotEventHelpert::~PlotEventHelpert() = default;
//! Sets tracking of the mouse for parent DescriptedPlot
void ScientificPlotEvent::setMouseTrackingEnabled(bool enable)
void PlotEventHelpert::setMouseTrackingEnabled(bool enable)
{
m_plot->setMouseTracking(enable);
m_plot->customPlot()->setMouseTracking(enable);
if (enable)
connect(m_plot->customPlot(), &QCustomPlot::mouseMove, this,
&ScientificPlotEvent::onCustomMouseMove, Qt::UniqueConnection);
&PlotEventHelpert::onCustomMouseMove, Qt::UniqueConnection);
else
disconnect(m_plot->customPlot(), &QCustomPlot::mouseMove, this,
&ScientificPlotEvent::onCustomMouseMove);
&PlotEventHelpert::onCustomMouseMove);
}
//! Constructs status string on mouse move event coming from QCustomPlot. String is emitted
//! if mouse is in axes's viewport rectangle. Once mouse goes out of it, an
//! empty string is emitted once again.
void ScientificPlotEvent::onCustomMouseMove(QMouseEvent* event)
void PlotEventHelpert::onCustomMouseMove(QMouseEvent* event)
{
auto currentPos = currentPlotDescriptor(event);
......@@ -65,7 +65,7 @@ void ScientificPlotEvent::onCustomMouseMove(QMouseEvent* event)
//! Constructs current position of the data.
PlotEventInfo ScientificPlotEvent::currentPlotDescriptor(QMouseEvent* event) const
PlotEventInfo PlotEventHelpert::currentPlotDescriptor(QMouseEvent* event) const
{
double x = m_plot->customPlot()->xAxis->pixelToCoord(event->pos().x());
double y = m_plot->customPlot()->yAxis->pixelToCoord(event->pos().y());
......
......@@ -2,8 +2,8 @@
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/PlotUtil/ScientificPlotEvent.h
//! @brief Defines class ScientificPlotEvent
//! @file GUI/View/PlotUtil/PlotEventHelper.h
//! @brief Defines class PlotEventHelpert
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
......@@ -12,8 +12,8 @@
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_VIEW_PLOTUTIL_SCIENTIFICPLOTEVENT_H
#define BORNAGAIN_GUI_VIEW_PLOTUTIL_SCIENTIFICPLOTEVENT_H
#ifndef BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTHELPER_H
#define BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTHELPER_H
#include "GUI/View/PlotUtil/PlotEventInfo.h"
#include <QObject>
......@@ -26,11 +26,11 @@ class QCustomPlot;
//! Helps ScientificPlot to handle mouse events. Particularly, it constructs a valid
//! status string. Can be extended to play a role of event filter.
class ScientificPlotEvent : public QObject {
class PlotEventHelpert : public QObject {
Q_OBJECT
public:
explicit ScientificPlotEvent(ScientificPlot* scientific_plot);
~ScientificPlotEvent() override;
explicit PlotEventHelpert(ScientificPlot* scientific_plot);
~PlotEventHelpert() override;
void setMouseTrackingEnabled(bool enable);
......@@ -49,4 +49,4 @@ private:
PlotEventInfo m_prevPos;
};
#endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_SCIENTIFICPLOTEVENT_H
#endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTEVENTHELPER_H
......@@ -12,14 +12,14 @@
//
// ************************************************************************************************
#include "GUI/View/PlotUtil/ScientificPlotEvent.h"
#include "GUI/View/PlotUtil/PlotEventHelper.h"
#include <qcustomplot.h>
ScientificPlot::ScientificPlot(QWidget* parent, PLOT_TYPE plot_type)
: QWidget(parent)
, m_plot(new QCustomPlot)
, m_plot_type(plot_type)
, m_event(new ScientificPlotEvent(this))
, m_event(new PlotEventHelpert(this))
{
}
......
......@@ -20,7 +20,7 @@
class PlotEventInfo;
class QCustomPlot;
class ScientificPlotEvent;
class PlotEventHelpert;
//! Common interface for plot-descriptor interaction
......@@ -38,7 +38,7 @@ public:
QCustomPlot* customPlot() { return m_plot; }
const QCustomPlot* customPlot() const { return m_plot; }
ScientificPlotEvent* plotEvent() { return m_event; }
PlotEventHelpert* plotEvent() { return m_event; }
//! Tracks move events (used when showing profile histograms and printing status string)
void setMouseTrackingEnabled(bool enable);
......@@ -57,7 +57,7 @@ protected:
private:
PLOT_TYPE m_plot_type;
ScientificPlotEvent* m_event;
PlotEventHelpert* m_event;
};
#endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_SCIENTIFICPLOT_H
......@@ -21,7 +21,7 @@
#include "GUI/View/Mask/MaskGraphicsView.h"
#include "GUI/View/PlotUtil/ColorMap.h"
#include "GUI/View/PlotUtil/PlotStatusLabel.h"
#include "GUI/View/PlotUtil/ScientificPlotEvent.h"
#include "GUI/View/PlotUtil/PlotEventHelper.h"
#include <QItemSelectionModel>
#include <QVBoxLayout>
......@@ -183,22 +183,22 @@ void ProjectionsEditorCanvas::setConnected(bool isConnected)
return;
if (isConnected) {
connect(m_colorMap->plotEvent(), &ScientificPlotEvent::enteringPlot, this,
connect(m_colorMap->plotEvent(), &PlotEventHelpert::enteringPlot, this,
&ProjectionsEditorCanvas::onEnteringColorMap, Qt::UniqueConnection);
connect(m_colorMap->plotEvent(), &ScientificPlotEvent::leavingPlot, this,
connect(m_colorMap->plotEvent(), &PlotEventHelpert::leavingPlot, this,
&ProjectionsEditorCanvas::onLeavingColorMap, Qt::UniqueConnection);
connect(m_colorMap->plotEvent(), &ScientificPlotEvent::positionChanged, this,
connect(m_colorMap->plotEvent(), &PlotEventHelpert::positionChanged, this,
&ProjectionsEditorCanvas::onPositionChanged, Qt::UniqueConnection);
connect(m_colorMap, &ColorMap::marginsChanged, this,
&ProjectionsEditorCanvas::marginsChanged, Qt::UniqueConnection);
}
else {
disconnect(m_colorMap->plotEvent(), &ScientificPlotEvent::enteringPlot, this,
disconnect(m_colorMap->plotEvent(), &PlotEventHelpert::enteringPlot, this,
&ProjectionsEditorCanvas::onEnteringColorMap);
disconnect(m_colorMap->plotEvent(), &ScientificPlotEvent::leavingPlot, this,
disconnect(m_colorMap->plotEvent(), &PlotEventHelpert::leavingPlot, this,
&ProjectionsEditorCanvas::onLeavingColorMap);
disconnect(m_colorMap->plotEvent(), &ScientificPlotEvent::positionChanged, this,
disconnect(m_colorMap->plotEvent(), &PlotEventHelpert::positionChanged, this,
&ProjectionsEditorCanvas::onPositionChanged);
disconnect(m_colorMap, &ColorMap::marginsChanged, this,
&ProjectionsEditorCanvas::marginsChanged);
......
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