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
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 Q_PROPERTY(bool isMouseDragging MEMBER m_isMouseDragging)
56 Q_PROPERTY(bool wasMouseDragging MEMBER m_wasMouseDragging)
57 Q_PROPERTY(bool isKeyBoardDragging MEMBER m_isKeyBoardDragging)
58 Q_PROPERTY(bool isLeftPseudoButtonKeyPressed MEMBER m_isLeftPseudoButtonKeyPressed)
59 Q_PROPERTY(bool isRightPseudoButtonKeyPressed MEMBER m_isRightPseudoButtonKeyPressed)
60 Q_PROPERTY(bool wasKeyBoardDragging MEMBER m_wasKeyBoardDragging)
61
62 QML_ELEMENT
63
64 public:
65 Q_INVOKABLE BasePlotContext(QObject *parent = nullptr);
66
67 virtual ~BasePlotContext();
68
69 Q_INVOKABLE BasePlotContext *clone(QObject *parent = nullptr);
70 Q_INVOKABLE void initialize(const BasePlotContext &other);
71
72 BasePlotContext(const BasePlotContext &other) = delete;
73 BasePlotContext &operator=(const BasePlotContext &other) = delete;
74
75 Enums::DataKind m_dataKind = Enums::DataKind::unset;
76
77 bool m_isMouseDragging = false;
78 bool m_wasMouseDragging = false;
79
80 bool m_isKeyBoardDragging = false;
81 bool m_isLeftPseudoButtonKeyPressed = false;
82 bool m_isRightPseudoButtonKeyPressed = false;
83 bool m_wasKeyBoardDragging = false;
84
85 QPointF m_startDragPoint;
86 QPointF m_currentDragPoint;
87 QPointF m_lastCursorHoveredPoint;
88 DragDirections m_dragDirections = DragDirections::NOT_SET;
89
90 IntegrationScopeBaseCstSPtr msp_integrationScope = nullptr;
91 SelectionPolygon m_selectionPolygon;
92 double m_integrationScopeRhombWidth = 0;
93 double m_integrationScopeRhombHeight = 0;
94
95 // The effective range of the axes.
96 QCPRange m_xRange;
97 QCPRange m_yRange;
98
99 // Tell if the mouse move was started onto either axis, because that will
100 // condition if some calculations needs to be performed or not (for example,
101 // if the mouse cursor motion was started on an axis, there is no point to
102 // perform deconvolutions).
103 bool m_wasClickOnXAxis = false;
104 bool m_wasClickOnYAxis = false;
105
106 bool m_isMeasuringDistance = false;
107
108 // The user-selected region over the plot.
109 // Note that we cannot use QCPRange structures because these are normalized by
110 // QCustomPlot in such a manner that lower is actually < upper. But we need
111 // for a number of our calculations (specifically for the deconvolutions) to
112 // actually have the lower value be start drag point.x even if the drag
113 // direction was from right to left.
114 double m_xRegionRangeStart = std::numeric_limits<double>::min();
115 double m_xRegionRangeEnd = std::numeric_limits<double>::min();
116
117 double m_yRegionRangeStart = std::numeric_limits<double>::min();
118 double m_yRegionRangeEnd = std::numeric_limits<double>::min();
119
120 double m_xDelta = 0;
121 double m_yDelta = 0;
122
123 int m_pressedKeyCode;
124 int m_releasedKeyCode;
125
126 Qt::KeyboardModifiers m_keyboardModifiers;
127
128 Qt::MouseButtons m_lastPressedMouseButton;
129 Qt::MouseButtons m_lastReleasedMouseButton;
130
131 Qt::MouseButtons m_pressedMouseButtons;
132
133 Qt::MouseButtons m_mouseButtonsAtMousePress;
134 Qt::MouseButtons m_mouseButtonsAtMouseRelease;
135
136 void updateIntegrationScope();
137 void updateIntegrationScopeRect();
138 void updateIntegrationScopeRhomb();
139 void updateIntegrationScopeRhombHorizontal();
140 void updateIntegrationScopeRhombVertical();
141
142 static void registerJsConstructor(QJSEngine *engine);
143
144 DragDirections recordDragDirections();
145
146 Q_INVOKABLE QString toString() const;
147};
148
150
151 /* END CLASS JS REFERENCE
152 * namespace: pappso
153 * class name: BasePlotContext
154 */
155
156} // 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