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 <QString>
11#include <QPointF>
12#include <QtQml>
13
14
15/////////////////////// Local includes
16#include "pappsomspp/config.h"
17#include "../../core/types.h"
22
23
24////////////////////// Other includes
25#include "qcustomplot.h"
26
27
28
29namespace pappso
30{
31
32Q_NAMESPACE
33
35{
36 NOT_SET = 0x0000,
37 LEFT_TO_RIGHT = 1 << 0,
38 RIGHT_TO_LEFT = 1 << 1,
39 TOP_TO_BOTTOM = 1 << 2,
40 BOTTOM_TO_TOP = 1 << 3
41};
42Q_ENUM_NS(DragDirections)
43
44extern std::map<Qt::MouseButton, QString> qtMouseButtonMap;
45extern std::map<Qt::MouseButtons, QString> qtMouseButtonsMap;
46
47extern std::map<Qt::KeyboardModifier, QString> qtKeyboardModifierMap;
48
49 /* END CLASS JS REFERENCE
50 * namespace: pappso
51 * class name: BasePlotContext
52 */
53
54class PMSPP_LIB_DECL BasePlotContext : public QObject
55{
56 Q_OBJECT
57 Q_PROPERTY(bool isMouseDragging MEMBER m_isMouseDragging)
58 Q_PROPERTY(bool wasMouseDragging MEMBER m_wasMouseDragging)
59 Q_PROPERTY(bool isKeyBoardDragging MEMBER m_isKeyBoardDragging)
60 Q_PROPERTY(bool isLeftPseudoButtonKeyPressed MEMBER m_isLeftPseudoButtonKeyPressed)
61 Q_PROPERTY(bool isRightPseudoButtonKeyPressed MEMBER m_isRightPseudoButtonKeyPressed)
62 Q_PROPERTY(bool wasKeyBoardDragging MEMBER m_wasKeyBoardDragging)
63
64 QML_ELEMENT
65
66 public:
67 Q_INVOKABLE BasePlotContext(QObject *parent = nullptr);
68
69 virtual ~BasePlotContext();
70
71 Q_INVOKABLE BasePlotContext *clone(QObject *parent = nullptr);
72 Q_INVOKABLE void initialize(const BasePlotContext &other);
73
74 BasePlotContext(const BasePlotContext &other) = delete;
75 BasePlotContext &operator=(const BasePlotContext &other) = delete;
76
77
78 Enums::DataKind m_dataKind = Enums::DataKind::unset;
79
80 bool m_isMouseDragging = false;
81 bool m_wasMouseDragging = false;
82
83 bool m_isKeyBoardDragging = false;
84 bool m_isLeftPseudoButtonKeyPressed = false;
85 bool m_isRightPseudoButtonKeyPressed = false;
86 bool m_wasKeyBoardDragging = false;
87
88 QPointF m_startDragPoint;
89 QPointF m_currentDragPoint;
90 QPointF m_lastCursorHoveredPoint;
91 DragDirections m_dragDirections = DragDirections::NOT_SET;
92
93 IntegrationScopeBaseCstSPtr msp_integrationScope = nullptr;
94 SelectionPolygon m_selectionPolygon;
95 double m_integrationScopeRhombWidth = 0;
96 double m_integrationScopeRhombHeight = 0;
97
98 // The effective range of the axes.
99 QCPRange m_xRange;
100 QCPRange m_yRange;
101
102 // Tell if the mouse move was started onto either axis, because that will
103 // condition if some calculations needs to be performed or not (for example,
104 // if the mouse cursor motion was started on an axis, there is no point to
105 // perform deconvolutions).
106 bool m_wasClickOnXAxis = false;
107 bool m_wasClickOnYAxis = false;
108
109 bool m_isMeasuringDistance = false;
110
111 // The user-selected region over the plot.
112 // Note that we cannot use QCPRange structures because these are normalized by
113 // QCustomPlot in such a manner that lower is actually < upper. But we need
114 // for a number of our calculations (specifically for the deconvolutions) to
115 // actually have the lower value be start drag point.x even if the drag
116 // direction was from right to left.
117 double m_xRegionRangeStart = std::numeric_limits<double>::min();
118 double m_xRegionRangeEnd = std::numeric_limits<double>::min();
119
120 double m_yRegionRangeStart = std::numeric_limits<double>::min();
121 double m_yRegionRangeEnd = std::numeric_limits<double>::min();
122
123 double m_xDelta = 0;
124 double m_yDelta = 0;
125
126 int m_pressedKeyCode;
127 int m_releasedKeyCode;
128
129 Qt::KeyboardModifiers m_keyboardModifiers;
130
131 Qt::MouseButtons m_lastPressedMouseButton;
132 Qt::MouseButtons m_lastReleasedMouseButton;
133
134 Qt::MouseButtons m_pressedMouseButtons;
135
136 Qt::MouseButtons m_mouseButtonsAtMousePress;
137 Qt::MouseButtons m_mouseButtonsAtMouseRelease;
138
139 void updateIntegrationScope();
140 void updateIntegrationScopeRect();
141 void updateIntegrationScopeRhomb();
142 void updateIntegrationScopeRhombHorizontal();
143 void updateIntegrationScopeRhombVertical();
144
145 DragDirections recordDragDirections();
146
147 Q_INVOKABLE QString toString() const;
148 Q_INVOKABLE QString dragDirectionsToString() const;
149
150 static void registerJsConstructor(QJSEngine *engine);
151};
152
154
155 /* END CLASS JS REFERENCE
156 * namespace: pappso
157 * class name: BasePlotContext
158 */
159
160} // namespace pappso
#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