Loading...
Searching...
No Matches
baseplotcontext.h
Go to the documentation of this file.
// Copyright 2021 Filippo Rusconi
// GPL3+
#pragma once
/////////////////////// StdLib includes
/////////////////////// Qt includes
#include <QJSEngine>
#include <QPointF>
#include <QString>
/////////////////////// Local includes
#include "../../core/types.h"
#include "pappsomspp/export-import-config.h"
#include "pappsomspp/core/js_qml/jsclassregistrar.h"
#include "pappsomspp/core/processing/combiners/integrationscopebase.h"
#include "pappsomspp/core/processing/combiners/selectionpolygon.h"
////////////////////// Other includes
#include "qcustomplot.h"
namespace pappso
{
Q_NAMESPACE
enum class DragDirections
{
NOT_SET = 0x0000,
LEFT_TO_RIGHT = 1 << 0,
RIGHT_TO_LEFT = 1 << 1,
TOP_TO_BOTTOM = 1 << 2,
BOTTOM_TO_TOP = 1 << 3
};
Q_ENUM_NS(DragDirections)
extern std::map<Qt::MouseButton, QString> qtMouseButtonMap;
extern std::map<Qt::MouseButtons, QString> qtMouseButtonsMap;
extern std::map<Qt::KeyboardModifier, QString> qtKeyboardModifierMap;
/* END CLASS JS REFERENCE
* namespace: pappso
* class name: BasePlotContext
*/
class PMSPP_LIB_DECL BasePlotContext : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isMouseDragging MEMBER m_isMouseDragging)
Q_PROPERTY(bool wasMouseDragging MEMBER m_wasMouseDragging)
Q_PROPERTY(bool isKeyBoardDragging MEMBER m_isKeyBoardDragging)
Q_PROPERTY(bool isLeftPseudoButtonKeyPressed MEMBER m_isLeftPseudoButtonKeyPressed)
Q_PROPERTY(bool isRightPseudoButtonKeyPressed MEMBER m_isRightPseudoButtonKeyPressed)
Q_PROPERTY(bool wasKeyBoardDragging MEMBER m_wasKeyBoardDragging)
Q_PROPERTY(QPointF startDragPoint MEMBER m_startDragPoint FINAL)
Q_PROPERTY(QPointF currentDragPoint MEMBER m_currentDragPoint FINAL)
Q_PROPERTY(QPointF lastCursorHoveredPoint MEMBER m_lastCursorHoveredPoint FINAL);
Q_PROPERTY(DragDirections dragDirections MEMBER m_dragDirections FINAL);
Q_PROPERTY(double xRegionRangeStart MEMBER m_xRegionRangeStart FINAL);
Q_PROPERTY(double xRegionRangeEnd MEMBER m_xRegionRangeEnd FINAL);
Q_PROPERTY(double yRegionRangeStart MEMBER m_yRegionRangeStart FINAL);
Q_PROPERTY(double yRegionRangeEnd MEMBER m_yRegionRangeEnd FINAL);
Q_PROPERTY(double xDelta MEMBER m_xDelta FINAL);
Q_PROPERTY(double yDelta MEMBER m_yDelta FINAL);
Q_PROPERTY(double pressedKeyCode MEMBER m_pressedKeyCode FINAL);
Q_PROPERTY(double releasedKeyCode MEMBER m_releasedKeyCode FINAL);
Q_PROPERTY(Qt::KeyboardModifiers keyboardModifiers MEMBER m_keyboardModifiers FINAL);
Q_PROPERTY(Qt::MouseButtons lastPressedMouseButton MEMBER m_lastPressedMouseButton FINAL);
Q_PROPERTY(Qt::MouseButtons lastReleasedMouseButton MEMBER m_lastReleasedMouseButton FINAL);
Q_PROPERTY(Qt::MouseButtons pressedMouseButtons MEMBER m_pressedMouseButtons FINAL);
Q_PROPERTY(Qt::MouseButtons mouseButtonsAtMousePress MEMBER m_mouseButtonsAtMousePress FINAL);
Q_PROPERTY(Qt::MouseButtons mouseButtonsAtMouseRelease MEMBER m_mouseButtonsAtMouseRelease FINAL);
public:
Q_INVOKABLE explicit BasePlotContext(QObject *parent = nullptr);
virtual ~BasePlotContext();
Q_INVOKABLE BasePlotContext *clone(QObject *parent = nullptr);
Q_INVOKABLE void initialize(const BasePlotContext &other);
BasePlotContext(const BasePlotContext &other) = delete;
BasePlotContext &operator=(const BasePlotContext &other) = delete;
Enums::DataKind m_dataKind = Enums::DataKind::unset;
bool m_isMouseDragging = false;
bool m_wasMouseDragging = false;
bool m_isKeyBoardDragging = false;
bool m_isLeftPseudoButtonKeyPressed = false;
bool m_isRightPseudoButtonKeyPressed = false;
bool m_wasKeyBoardDragging = false;
QPointF m_startDragPoint;
QPointF m_currentDragPoint;
QPointF m_lastCursorHoveredPoint;
DragDirections m_dragDirections = DragDirections::NOT_SET;
IntegrationScopeBaseCstSPtr msp_integrationScope = nullptr;
SelectionPolygon m_selectionPolygon;
double m_integrationScopeRhombWidth = 0;
double m_integrationScopeRhombHeight = 0;
// The effective range of the axes.
QCPRange m_xRange;
QCPRange m_yRange;
// Tell if the mouse move was started onto either axis, because that will
// condition if some calculations needs to be performed or not (for example,
// if the mouse cursor motion was started on an axis, there is no point to
// perform deconvolutions).
bool m_wasClickOnXAxis = false;
bool m_wasClickOnYAxis = false;
bool m_isMeasuringDistance = false;
// The user-selected region over the plot.
// Note that we cannot use QCPRange structures because these are normalized by
// QCustomPlot in such a manner that lower is actually < upper. But we need
// for a number of our calculations (specifically for the deconvolutions) to
// actually have the lower value be start drag point.x even if the drag
// direction was from right to left.
double m_xRegionRangeStart = std::numeric_limits<double>::min();
double m_xRegionRangeEnd = std::numeric_limits<double>::min();
double m_yRegionRangeStart = std::numeric_limits<double>::min();
double m_yRegionRangeEnd = std::numeric_limits<double>::min();
double m_xDelta = 0;
double m_yDelta = 0;
int m_pressedKeyCode;
int m_releasedKeyCode;
Qt::KeyboardModifiers m_keyboardModifiers;
Qt::MouseButtons m_lastPressedMouseButton;
Qt::MouseButtons m_lastReleasedMouseButton;
Qt::MouseButtons m_pressedMouseButtons;
Qt::MouseButtons m_mouseButtonsAtMousePress;
Qt::MouseButtons m_mouseButtonsAtMouseRelease;
void updateIntegrationScope();
void updateIntegrationScopeRect();
void updateIntegrationScopeRhomb();
void updateIntegrationScopeRhombHorizontal();
void updateIntegrationScopeRhombVertical();
DragDirections recordDragDirections();
Q_INVOKABLE QString toString() const;
Q_INVOKABLE QString dragDirectionsToString() const;
static void registerJsConstructor(QJSEngine *engine);
};
PAPPSO_REGISTER_JS_CLASS(pappso, BasePlotContext)
/* END CLASS JS REFERENCE
* namespace: pappso
* class name: BasePlotContext
*/
} // namespace pappso
pappso::BasePlotContext::m_xRegionRangeStart
double m_xRegionRangeStart
Definition baseplotcontext.h:131
pappso::BasePlotContext::isRightPseudoButtonKeyPressed
bool isRightPseudoButtonKeyPressed
Definition baseplotcontext.h:60
pappso::BasePlotContext::registerJsConstructor
static void registerJsConstructor(QJSEngine *engine)
Definition baseplotcontext.cpp:1007
pappso::BasePlotContext::m_startDragPoint
QPointF m_startDragPoint
Definition baseplotcontext.h:102
pappso::BasePlotContext::keyboardModifiers
Qt::KeyboardModifiers keyboardModifiers
Definition baseplotcontext.h:74
pappso::BasePlotContext::m_xDelta
double m_xDelta
Definition baseplotcontext.h:137
pappso::BasePlotContext::m_mouseButtonsAtMousePress
Qt::MouseButtons m_mouseButtonsAtMousePress
Definition baseplotcontext.h:150
pappso::BasePlotContext::mouseButtonsAtMousePress
Qt::MouseButtons mouseButtonsAtMousePress
Definition baseplotcontext.h:78
pappso::BasePlotContext::m_selectionPolygon
SelectionPolygon m_selectionPolygon
Definition baseplotcontext.h:108
pappso::BasePlotContext::BasePlotContext
Q_INVOKABLE BasePlotContext(QObject *parent=nullptr)
Definition baseplotcontext.cpp:38
pappso::BasePlotContext::wasKeyBoardDragging
bool wasKeyBoardDragging
Definition baseplotcontext.h:61
pappso::BasePlotContext::dragDirectionsToString
Q_INVOKABLE QString dragDirectionsToString() const
Definition baseplotcontext.cpp:982
pappso::BasePlotContext::pressedKeyCode
double pressedKeyCode
Definition baseplotcontext.h:72
pappso::BasePlotContext::lastReleasedMouseButton
Qt::MouseButtons lastReleasedMouseButton
Definition baseplotcontext.h:76
pappso::BasePlotContext::msp_integrationScope
IntegrationScopeBaseCstSPtr msp_integrationScope
Definition baseplotcontext.h:107
pappso::BasePlotContext::recordDragDirections
DragDirections recordDragDirections()
Definition baseplotcontext.cpp:852
pappso::BasePlotContext::m_dataKind
Enums::DataKind m_dataKind
Definition baseplotcontext.h:92
pappso::BasePlotContext::clone
Q_INVOKABLE BasePlotContext * clone(QObject *parent=nullptr)
Definition baseplotcontext.cpp:117
pappso::BasePlotContext::m_wasClickOnXAxis
bool m_wasClickOnXAxis
Definition baseplotcontext.h:120
pappso::BasePlotContext::m_keyboardModifiers
Qt::KeyboardModifiers m_keyboardModifiers
Definition baseplotcontext.h:143
pappso::BasePlotContext::m_pressedKeyCode
int m_pressedKeyCode
Definition baseplotcontext.h:140
pappso::BasePlotContext::lastPressedMouseButton
Qt::MouseButtons lastPressedMouseButton
Definition baseplotcontext.h:75
pappso::BasePlotContext::xDelta
double xDelta
Definition baseplotcontext.h:70
pappso::BasePlotContext::updateIntegrationScope
void updateIntegrationScope()
Definition baseplotcontext.cpp:251
pappso::BasePlotContext::m_lastPressedMouseButton
Qt::MouseButtons m_lastPressedMouseButton
Definition baseplotcontext.h:145
pappso::BasePlotContext::updateIntegrationScopeRhombVertical
void updateIntegrationScopeRhombVertical()
Definition baseplotcontext.cpp:537
pappso::BasePlotContext::dragDirections
DragDirections dragDirections
Definition baseplotcontext.h:65
pappso::BasePlotContext::m_isMouseDragging
bool m_isMouseDragging
Definition baseplotcontext.h:94
pappso::BasePlotContext::m_xRange
QCPRange m_xRange
Definition baseplotcontext.h:113
pappso::BasePlotContext::updateIntegrationScopeRhombHorizontal
void updateIntegrationScopeRhombHorizontal()
Definition baseplotcontext.cpp:382
pappso::BasePlotContext::currentDragPoint
QPointF currentDragPoint
Definition baseplotcontext.h:63
pappso::BasePlotContext::m_isMeasuringDistance
bool m_isMeasuringDistance
Definition baseplotcontext.h:123
pappso::BasePlotContext::m_dragDirections
DragDirections m_dragDirections
Definition baseplotcontext.h:105
pappso::BasePlotContext::m_integrationScopeRhombHeight
double m_integrationScopeRhombHeight
Definition baseplotcontext.h:110
pappso::BasePlotContext::m_lastCursorHoveredPoint
QPointF m_lastCursorHoveredPoint
Definition baseplotcontext.h:104
pappso::BasePlotContext::m_currentDragPoint
QPointF m_currentDragPoint
Definition baseplotcontext.h:103
pappso::BasePlotContext::initialize
Q_INVOKABLE void initialize(const BasePlotContext &other)
Definition baseplotcontext.cpp:186
pappso::BasePlotContext::startDragPoint
QPointF startDragPoint
Definition baseplotcontext.h:62
pappso::BasePlotContext::xRegionRangeEnd
double xRegionRangeEnd
Definition baseplotcontext.h:67
pappso::BasePlotContext::wasMouseDragging
bool wasMouseDragging
Definition baseplotcontext.h:57
pappso::BasePlotContext::m_yDelta
double m_yDelta
Definition baseplotcontext.h:138
pappso::BasePlotContext::isKeyBoardDragging
bool isKeyBoardDragging
Definition baseplotcontext.h:58
pappso::BasePlotContext::yRegionRangeStart
double yRegionRangeStart
Definition baseplotcontext.h:68
pappso::BasePlotContext::updateIntegrationScopeRect
void updateIntegrationScopeRect()
Definition baseplotcontext.cpp:274
pappso::BasePlotContext::yDelta
double yDelta
Definition baseplotcontext.h:71
pappso::BasePlotContext::isLeftPseudoButtonKeyPressed
bool isLeftPseudoButtonKeyPressed
Definition baseplotcontext.h:59
pappso::BasePlotContext::m_yRegionRangeStart
double m_yRegionRangeStart
Definition baseplotcontext.h:134
pappso::BasePlotContext::xRegionRangeStart
double xRegionRangeStart
Definition baseplotcontext.h:66
pappso::BasePlotContext::pressedMouseButtons
Qt::MouseButtons pressedMouseButtons
Definition baseplotcontext.h:77
pappso::BasePlotContext::updateIntegrationScopeRhomb
void updateIntegrationScopeRhomb()
Definition baseplotcontext.cpp:696
pappso::BasePlotContext::m_isRightPseudoButtonKeyPressed
bool m_isRightPseudoButtonKeyPressed
Definition baseplotcontext.h:99
pappso::BasePlotContext::m_pressedMouseButtons
Qt::MouseButtons m_pressedMouseButtons
Definition baseplotcontext.h:148
pappso::BasePlotContext::m_yRange
QCPRange m_yRange
Definition baseplotcontext.h:114
pappso::BasePlotContext::m_mouseButtonsAtMouseRelease
Qt::MouseButtons m_mouseButtonsAtMouseRelease
Definition baseplotcontext.h:151
pappso::BasePlotContext::m_releasedKeyCode
int m_releasedKeyCode
Definition baseplotcontext.h:141
pappso::BasePlotContext::m_isLeftPseudoButtonKeyPressed
bool m_isLeftPseudoButtonKeyPressed
Definition baseplotcontext.h:98
pappso::BasePlotContext::releasedKeyCode
double releasedKeyCode
Definition baseplotcontext.h:73
pappso::BasePlotContext::lastCursorHoveredPoint
QPointF lastCursorHoveredPoint
Definition baseplotcontext.h:64
pappso::BasePlotContext::m_integrationScopeRhombWidth
double m_integrationScopeRhombWidth
Definition baseplotcontext.h:109
pappso::BasePlotContext::m_lastReleasedMouseButton
Qt::MouseButtons m_lastReleasedMouseButton
Definition baseplotcontext.h:146
pappso::BasePlotContext::yRegionRangeEnd
double yRegionRangeEnd
Definition baseplotcontext.h:69
pappso::BasePlotContext::toString
Q_INVOKABLE QString toString() const
Definition baseplotcontext.cpp:874
pappso::BasePlotContext::isMouseDragging
bool isMouseDragging
Definition baseplotcontext.h:56
pappso::BasePlotContext::m_wasKeyBoardDragging
bool m_wasKeyBoardDragging
Definition baseplotcontext.h:100
pappso::BasePlotContext::m_wasMouseDragging
bool m_wasMouseDragging
Definition baseplotcontext.h:95
pappso::BasePlotContext::m_yRegionRangeEnd
double m_yRegionRangeEnd
Definition baseplotcontext.h:135
pappso::BasePlotContext::m_xRegionRangeEnd
double m_xRegionRangeEnd
Definition baseplotcontext.h:132
pappso::BasePlotContext::mouseButtonsAtMouseRelease
Qt::MouseButtons mouseButtonsAtMouseRelease
Definition baseplotcontext.h:79
pappso::BasePlotContext::m_wasClickOnYAxis
bool m_wasClickOnYAxis
Definition baseplotcontext.h:121
pappso::BasePlotContext::m_isKeyBoardDragging
bool m_isKeyBoardDragging
Definition baseplotcontext.h:97
pappso::SelectionPolygon
Definition selectionpolygon.h:44
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
integrationscopebase.h
jsclassregistrar.h
PAPPSO_REGISTER_JS_CLASS
#define PAPPSO_REGISTER_JS_CLASS(NS_IDENT, CLASS_NAME)
Definition jsclassregistrar.h:35
pappso::Enums
Definition types.h:71
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::qtMouseButtonMap
std::map< Qt::MouseButton, QString > qtMouseButtonMap
Definition baseplotcontext.cpp:12
pappso::DataDimension::NOT_SET
@ NOT_SET
Definition selectionpolygon.h:36
pappso::DragDirections
DragDirections
Definition baseplotcontext.h:33
pappso::DragDirections::RIGHT_TO_LEFT
@ RIGHT_TO_LEFT
Definition baseplotcontext.h:36
pappso::DragDirections::LEFT_TO_RIGHT
@ LEFT_TO_RIGHT
Definition baseplotcontext.h:35
pappso::DragDirections::BOTTOM_TO_TOP
@ BOTTOM_TO_TOP
Definition baseplotcontext.h:38
pappso::DragDirections::TOP_TO_BOTTOM
@ TOP_TO_BOTTOM
Definition baseplotcontext.h:37
pappso::IntegrationScopeBaseCstSPtr
std::shared_ptr< const IntegrationScopeBase > IntegrationScopeBaseCstSPtr
Definition integrationscopebase.h:117
pappso::qtMouseButtonsMap
std::map< Qt::MouseButtons, QString > qtMouseButtonsMap
Definition baseplotcontext.cpp:18
pappso::qtKeyboardModifierMap
std::map< Qt::KeyboardModifier, QString > qtKeyboardModifierMap
Definition baseplotcontext.cpp:29
selectionpolygon.h
types.h