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,
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)
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
84
89
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
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
125
126 Qt::KeyboardModifiers m_keyboardModifiers;
127
128 Qt::MouseButtons m_lastPressedMouseButton;
130
131 Qt::MouseButtons m_pressedMouseButtons;
132
135
141
142 static void registerJsConstructor(QJSEngine *engine);
143
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
static void registerJsConstructor(QJSEngine *engine)
Qt::MouseButtons m_mouseButtonsAtMousePress
SelectionPolygon m_selectionPolygon
Q_INVOKABLE BasePlotContext(QObject *parent=nullptr)
IntegrationScopeBaseCstSPtr msp_integrationScope
DragDirections recordDragDirections()
Enums::DataKind m_dataKind
Q_INVOKABLE BasePlotContext * clone(QObject *parent=nullptr)
Qt::KeyboardModifiers m_keyboardModifiers
Qt::MouseButtons m_lastPressedMouseButton
DragDirections m_dragDirections
Q_INVOKABLE void initialize(const BasePlotContext &other)
Qt::MouseButtons m_pressedMouseButtons
Qt::MouseButtons m_mouseButtonsAtMouseRelease
Qt::MouseButtons m_lastReleasedMouseButton
Q_INVOKABLE QString toString() const
#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