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 xRegionRangeEnd MEMBER m_xRegionRangeEnd FINAL);
68 Q_PROPERTY(double yRegionRangeStart MEMBER m_yRegionRangeStart FINAL);
69 Q_PROPERTY(double yRegionRangeEnd MEMBER m_yRegionRangeEnd FINAL);
70 Q_PROPERTY(double xDelta MEMBER m_xDelta FINAL);
71 Q_PROPERTY(double yDelta MEMBER m_yDelta FINAL);
72 Q_PROPERTY(double pressedKeyCode MEMBER m_pressedKeyCode FINAL);
73 Q_PROPERTY(double releasedKeyCode MEMBER m_releasedKeyCode FINAL);
74 Q_PROPERTY(Qt::KeyboardModifiers keyboardModifiers MEMBER m_keyboardModifiers FINAL);
75 Q_PROPERTY(Qt::MouseButtons lastPressedMouseButton MEMBER m_lastPressedMouseButton FINAL);
76 Q_PROPERTY(Qt::MouseButtons lastReleasedMouseButton MEMBER m_lastReleasedMouseButton FINAL);
77 Q_PROPERTY(Qt::MouseButtons pressedMouseButtons MEMBER m_pressedMouseButtons FINAL);
78 Q_PROPERTY(Qt::MouseButtons mouseButtonsAtMousePress MEMBER m_mouseButtonsAtMousePress FINAL);
79 Q_PROPERTY(Qt::MouseButtons mouseButtonsAtMouseRelease MEMBER m_mouseButtonsAtMouseRelease FINAL);
80
81public:
82 Q_INVOKABLE explicit BasePlotContext(QObject *parent = nullptr);
83
84 virtual ~BasePlotContext();
85
86 Q_INVOKABLE BasePlotContext *clone(QObject *parent = nullptr);
87 Q_INVOKABLE void initialize(const BasePlotContext &other);
88
89 BasePlotContext(const BasePlotContext &other) = delete;
90 BasePlotContext &operator=(const BasePlotContext &other) = delete;
91
92 Enums::DataKind m_dataKind = Enums::DataKind::unset;
93
94 bool m_isMouseDragging = false;
95 bool m_wasMouseDragging = false;
96
101
106
111
112 // The effective range of the axes.
113 QCPRange m_xRange;
114 QCPRange m_yRange;
115
116 // Tell if the mouse move was started onto either axis, because that will
117 // condition if some calculations needs to be performed or not (for example,
118 // if the mouse cursor motion was started on an axis, there is no point to
119 // perform deconvolutions).
120 bool m_wasClickOnXAxis = false;
121 bool m_wasClickOnYAxis = false;
122
124
125 // The user-selected region over the plot.
126 // Note that we cannot use QCPRange structures because these are normalized by
127 // QCustomPlot in such a manner that lower is actually < upper. But we need
128 // for a number of our calculations (specifically for the deconvolutions) to
129 // actually have the lower value be start drag point.x even if the drag
130 // direction was from right to left.
131 double m_xRegionRangeStart = std::numeric_limits<double>::min();
132 double m_xRegionRangeEnd = std::numeric_limits<double>::min();
133
134 double m_yRegionRangeStart = std::numeric_limits<double>::min();
135 double m_yRegionRangeEnd = std::numeric_limits<double>::min();
136
137 double m_xDelta = 0;
138 double m_yDelta = 0;
139
142
143 Qt::KeyboardModifiers m_keyboardModifiers;
144
145 Qt::MouseButtons m_lastPressedMouseButton;
147
148 Qt::MouseButtons m_pressedMouseButtons;
149
152
158
160
161 Q_INVOKABLE QString toString() const;
162 Q_INVOKABLE QString dragDirectionsToString() const;
163
164 static void registerJsConstructor(QJSEngine *engine);
165};
166
168
169 /* END CLASS JS REFERENCE
170 * namespace: pappso
171 * class name: BasePlotContext
172 */
173
174} // 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