libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
baseplotcontext.h
Go to the documentation of this file.
1// Copyright 2021 Filippo Rusconi
2// GPL3+
3
4#pragma once
5
6/////////////////////// StdLib includes
7
8
9/////////////////////// Qt includes
10#include <QJSEngine>
11#include <QPointF>
12#include <QString>
13
14/////////////////////// Local includes
15#include "../../core/types.h"
20
21
22////////////////////// Other includes
23#include "qcustomplot.h"
24
25
26
27namespace pappso
28{
29
30Q_NAMESPACE
31
33{
34 NOT_SET = 0x0000,
35 LEFT_TO_RIGHT = 1 << 0,
36 RIGHT_TO_LEFT = 1 << 1,
37 TOP_TO_BOTTOM = 1 << 2,
39};
40Q_ENUM_NS(DragDirections)
41
42extern std::map<Qt::MouseButton, QString> qtMouseButtonMap;
43extern std::map<Qt::MouseButtons, QString> qtMouseButtonsMap;
44
45extern std::map<Qt::KeyboardModifier, QString> qtKeyboardModifierMap;
46
47 /* END CLASS JS REFERENCE
48 * namespace: pappso
49 * class name: BasePlotContext
50 */
51
52class PMSPP_LIB_DECL BasePlotContext : public QObject
53{
54 Q_OBJECT
55
56 Q_PROPERTY(bool isMouseDragging MEMBER m_isMouseDragging)
57 Q_PROPERTY(bool wasMouseDragging MEMBER m_wasMouseDragging)
62 Q_PROPERTY(QPointF startDragPoint MEMBER m_startDragPoint FINAL)
63 Q_PROPERTY(QPointF currentDragPoint MEMBER m_currentDragPoint FINAL)
64 Q_PROPERTY(QPointF lastCursorHoveredPoint MEMBER m_lastCursorHoveredPoint FINAL);
66 Q_PROPERTY(double xRegionRangeStart MEMBER m_xRegionRangeStart FINAL);
67 Q_PROPERTY(double xRegionRangeStop MEMBER m_xRegionRangeStop FINAL);
68 Q_PROPERTY(double yRegionRangeStart MEMBER m_yRegionRangeStart FINAL);
69 Q_PROPERTY(double yRegionRangeStop MEMBER m_yRegionRangeStop FINAL);
70 Q_PROPERTY(double xDelta MEMBER m_xDelta FINAL);
71 Q_PROPERTY(double yDelta MEMBER m_yDelta FINAL);
72 Q_PROPERTY(int pressedKeyCode MEMBER m_pressedKeyCode FINAL);
73 Q_PROPERTY(QString pressedKeyText MEMBER m_pressedKeyText FINAL);
74 Q_PROPERTY(int releasedKeyCode MEMBER m_releasedKeyCode FINAL);
75 Q_PROPERTY(QString releasedKeyText MEMBER m_releasedKeyText FINAL);
76 Q_PROPERTY(Qt::KeyboardModifiers keyboardModifiers MEMBER m_keyboardModifiers FINAL);
77 Q_PROPERTY(Qt::MouseButtons lastPressedMouseButton MEMBER m_lastPressedMouseButton FINAL);
78 Q_PROPERTY(Qt::MouseButtons lastReleasedMouseButton MEMBER m_lastReleasedMouseButton FINAL);
79 Q_PROPERTY(Qt::MouseButtons pressedMouseButtons MEMBER m_pressedMouseButtons FINAL);
80 Q_PROPERTY(Qt::MouseButtons mouseButtonsAtMousePress MEMBER m_mouseButtonsAtMousePress FINAL);
81 Q_PROPERTY(Qt::MouseButtons mouseButtonsAtMouseRelease MEMBER m_mouseButtonsAtMouseRelease FINAL);
82
83public:
84 Q_INVOKABLE explicit BasePlotContext(QObject *parent = nullptr);
85
86 virtual ~BasePlotContext();
87
88 Q_INVOKABLE BasePlotContext *clone(QObject *parent = nullptr);
89 Q_INVOKABLE void initialize(const BasePlotContext &other);
90
91 BasePlotContext(const BasePlotContext &other) = delete;
92 BasePlotContext &operator=(const BasePlotContext &other) = delete;
93
94 Enums::DataKind m_dataKind = Enums::DataKind::unset;
95
96 bool m_isMouseDragging = false;
97 bool m_wasMouseDragging = false;
98
103
108
113
114 // The effective range of the axes.
115 QCPRange m_xRange;
116 QCPRange m_yRange;
117
118 // Tell if the mouse move was started onto either axis, because that will
119 // condition if some calculations needs to be performed or not (for example,
120 // if the mouse cursor motion was started on an axis, there is no point to
121 // perform deconvolutions).
122 bool m_wasClickOnXAxis = false;
123 bool m_wasClickOnYAxis = false;
124
126
127 // The user-selected region over the plot.
128 // Note that we cannot use QCPRange structures because these are normalized by
129 // QCustomPlot in such a manner that lower is actually < upper. But we need
130 // for a number of our calculations (specifically for the deconvolutions) to
131 // actually have the lower value be start drag point.x even if the drag
132 // direction was from right to left.
133 double m_xRegionRangeStart = std::numeric_limits<double>::min();
134 double m_xRegionRangeStop = std::numeric_limits<double>::min();
135
136 double m_yRegionRangeStart = std::numeric_limits<double>::min();
137 double m_yRegionRangeStop = std::numeric_limits<double>::min();
138
139 double m_xDelta = 0;
140 double m_yDelta = 0;
141
146
147 Qt::KeyboardModifiers m_keyboardModifiers;
148
149 Qt::MouseButtons m_lastPressedMouseButton;
151
152 Qt::MouseButtons m_pressedMouseButtons;
153
156
162
164
165 Q_INVOKABLE QString toString() const;
166 Q_INVOKABLE QString dragDirectionsToString() const;
167
168 static void registerJsConstructor(QJSEngine *engine);
169};
170
172
173 /* END CLASS JS REFERENCE
174 * namespace: pappso
175 * class name: BasePlotContext
176 */
177
178} // namespace pappso
static void registerJsConstructor(QJSEngine *engine)
Qt::KeyboardModifiers keyboardModifiers
Qt::MouseButtons m_mouseButtonsAtMousePress
Qt::MouseButtons mouseButtonsAtMousePress
SelectionPolygon m_selectionPolygon
Q_INVOKABLE BasePlotContext(QObject *parent=nullptr)
Q_INVOKABLE QString dragDirectionsToString() const
Qt::MouseButtons lastReleasedMouseButton
IntegrationScopeBaseCstSPtr msp_integrationScope
DragDirections recordDragDirections()
Enums::DataKind m_dataKind
Q_INVOKABLE BasePlotContext * clone(QObject *parent=nullptr)
Qt::KeyboardModifiers m_keyboardModifiers
Qt::MouseButtons lastPressedMouseButton
Qt::MouseButtons m_lastPressedMouseButton
DragDirections dragDirections
DragDirections m_dragDirections
Q_INVOKABLE void initialize(const BasePlotContext &other)
Qt::MouseButtons pressedMouseButtons
Qt::MouseButtons m_pressedMouseButtons
Qt::MouseButtons m_mouseButtonsAtMouseRelease
Qt::MouseButtons m_lastReleasedMouseButton
Q_INVOKABLE QString toString() const
Qt::MouseButtons mouseButtonsAtMouseRelease
#define PMSPP_LIB_DECL
#define PAPPSO_REGISTER_JS_CLASS(NS_IDENT, CLASS_NAME)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::map< Qt::MouseButton, QString > qtMouseButtonMap
std::shared_ptr< const IntegrationScopeBase > IntegrationScopeBaseCstSPtr
std::map< Qt::MouseButtons, QString > qtMouseButtonsMap
std::map< Qt::KeyboardModifier, QString > qtKeyboardModifierMap