libpappsomspp
Library for mass spectrometry
baseplotcontext.cpp
Go to the documentation of this file.
1// Copyright 2021 Filippo Rusconi
2// GPL3+
3
4#include "baseplotcontext.h"
5
6namespace pappso
7{
8
10{
11}
12
13
15{
16 //qDebug() << "Constructing BasePlotContext by copy.";
17
18 m_dataKind = other.m_dataKind;
19
22
27
31
34
35 // The effective range of the axes.
36 m_xRange = other.m_xRange;
37 m_yRange = other.m_yRange;
38
39 // Tell if the mouse move was started onto either axis, because that will
40 // condition if some calculations needs to be performed or not (for example,
41 // if the mouse cursor motion was started on an axis, there is no point to
42 // perform deconvolutions).
45
47
48 // The user-selected region over the plot.
49 // Note that we cannot use QCPRange structures because these are normalized by
50 // QCustomPlot in such a manner that lower is actually < upper. But we need
51 // for a number of our calculations (specifically for the deconvolutions) to
52 // actually have the lower value be start drag point.x even if the drag
53 // direction was from right to left.
56
59
60 m_xDelta = other.m_xDelta;
61 m_yDelta = other.m_yDelta;
62
65
67
70
72
75}
76
77
80{
81 if(this == &other)
82 return *this;
83
84 m_dataKind = other.m_dataKind;
85
88
93
97
100
101 // The effective range of the axes.
102 m_xRange = other.m_xRange;
103 m_yRange = other.m_yRange;
104
105 // Tell if the mouse move was started onto either axis, because that will
106 // condition if some calculations needs to be performed or not (for example,
107 // if the mouse cursor motion was started on an axis, there is no point to
108 // perform deconvolutions).
111
113
114 // The user-selected region over the plot.
115 // Note that we cannot use QCPRange structures because these are normalized by
116 // QCustomPlot in such a manner that lower is actually < upper. But we need
117 // for a number of our calculations (specifically for the deconvolutions) to
118 // actually have the lower value be start drag point.x even if the drag
119 // direction was from right to left.
122
125
126 m_xDelta = other.m_xDelta;
127 m_yDelta = other.m_yDelta;
128
131
133
136
138
141
142 return *this;
143}
144
145
147{
148}
149
150
153{
154 int drag_directions = static_cast<int>(DragDirections::NOT_SET);
155
157 drag_directions |= static_cast<int>(DragDirections::LEFT_TO_RIGHT);
158 else
159 drag_directions |= static_cast<int>(DragDirections::RIGHT_TO_LEFT);
160
162 drag_directions |= static_cast<int>(DragDirections::BOTTOM_TO_TOP);
163 else
164 drag_directions |= static_cast<int>(DragDirections::TOP_TO_BOTTOM);
165
166 // qDebug() << "DragDirections:" << drag_directions;
167
168 m_dragDirections = static_cast<DragDirections>(drag_directions);
169
170 return static_cast<DragDirections>(drag_directions);
171}
172
173
174QString
176{
177 QString text("Context:");
178
179 text += QString("data kind: %1").arg(static_cast<int>(m_dataKind));
180
181 text += QString(" isMouseDragging: %1 -- wasMouseDragging: %2")
182 .arg(m_isMouseDragging ? "true" : "false")
183 .arg(m_wasMouseDragging ? "true" : "false");
184
185 text += QString(" -- startDragPoint : (%1, %2)")
186 .arg(m_startDragPoint.x())
187 .arg(m_startDragPoint.y());
188
189 text += QString(" -- currentDragPoint : (%1, %2)")
190 .arg(m_currentDragPoint.x())
191 .arg(m_currentDragPoint.y());
192
193 text += QString(" -- lastCursorHoveredPoint : (%1, %2)")
195 .arg(m_lastCursorHoveredPoint.y());
196
197 // Document how the mouse cursor is being dragged.
199 {
200 if(static_cast<int>(m_dragDirections) &
201 static_cast<int>(DragDirections::LEFT_TO_RIGHT))
202 text += " -- dragging from left to right";
203 else if(static_cast<int>(m_dragDirections) &
204 static_cast<int>(DragDirections::RIGHT_TO_LEFT))
205 text += " -- dragging from right to left";
206 if(static_cast<int>(m_dragDirections) &
207 static_cast<int>(DragDirections::TOP_TO_BOTTOM))
208 text += " -- dragging from top to bottom";
209 if(static_cast<int>(m_dragDirections) &
210 static_cast<int>(DragDirections::BOTTOM_TO_TOP))
211 text += " -- dragging from bottom to top";
212 }
213
214 // The selection polygon.
215 text += " -- ";
217
218 text +=
219 QString(" -- xRange: (%1, %2)").arg(m_xRange.lower).arg(m_xRange.upper);
220
221 text +=
222 QString(" -- yRange: (%1, %2)").arg(m_yRange.lower).arg(m_yRange.upper);
223
224 text += QString(" -- wasClickOnXAxis: %1")
225 .arg(m_wasClickOnXAxis ? "true" : "false");
226 text += QString(" -- wasClickOnYAxis: %1")
227 .arg(m_wasClickOnYAxis ? "true" : "false");
228 text += QString(" -- isMeasuringDistance: %1")
229 .arg(m_isMeasuringDistance ? "true" : "false");
230
231 text += QString(" -- xRegionRangeStart: %1 -- xRegionRangeEnd: %2")
233 .arg(m_xRegionRangeEnd);
234
235 text += QString(" -- yRegionRangeStart: %1 -- yRegionRangeEnd: %2")
237 .arg(m_yRegionRangeEnd);
238
239 text += QString(" -- xDelta: %1 -- yDelta: %2").arg(m_xDelta).arg(m_yDelta);
240
241 text += QString(" -- pressedKeyCode: %1").arg(m_pressedKeyCode);
242
243 text += QString(" -- keyboardModifiers: %1").arg(m_keyboardModifiers);
244
245 text +=
246 QString(" -- lastPressedMouseButton: %1").arg(m_lastPressedMouseButton);
247
248 text +=
249 QString(" -- lastReleasedMouseButton: %1").arg(m_lastReleasedMouseButton);
250
251 text += QString(" -- pressedMouseButtons: %1").arg(m_pressedMouseButtons);
252
253 text +=
254 QString(" -- mouseButtonsAtMousePress: %1").arg(m_mouseButtonsAtMousePress);
255
256 text += QString(" -- mouseButtonsAtMouseRelease: %1")
258
259 return text;
260}
261
262
263} // namespace pappso
264
Qt::MouseButtons m_mouseButtonsAtMousePress
SelectionPolygon m_selectionPolygon
DragDirections recordDragDirections()
Qt::KeyboardModifiers m_keyboardModifiers
Qt::MouseButtons m_lastPressedMouseButton
DragDirections m_dragDirections
Qt::MouseButtons m_pressedMouseButtons
Qt::MouseButtons m_mouseButtonsAtMouseRelease
BasePlotContext & operator=(const BasePlotContext &other)
Qt::MouseButtons m_lastReleasedMouseButton
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39