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 
6 namespace pappso
7 {
8 
10 {
11 }
12 
13 
15 {
16  m_dataKind = other.m_dataKind;
17 
20 
25 
29 
32 
33  // The effective range of the axes.
34  m_xRange = other.m_xRange;
35  m_yRange = other.m_yRange;
36 
37  // Tell if the mouse move was started onto either axis, because that will
38  // condition if some calculations needs to be performed or not (for example,
39  // if the mouse cursor motion was started on an axis, there is no point to
40  // perform deconvolutions).
43 
45 
46  // The user-selected region over the plot.
47  // Note that we cannot use QCPRange structures because these are normalized by
48  // QCustomPlot in such a manner that lower is actually < upper. But we need
49  // for a number of our calculations (specifically for the deconvolutions) to
50  // actually have the lower value be start drag point.x even if the drag
51  // direction was from right to left.
54 
57 
58  m_xDelta = other.m_xDelta;
59  m_yDelta = other.m_yDelta;
60 
63 
65 
68 
70 
73 }
74 
75 
78 {
79  if(this == &other)
80  return *this;
81 
82  m_dataKind = other.m_dataKind;
83 
86 
91 
95 
98 
99  // The effective range of the axes.
100  m_xRange = other.m_xRange;
101  m_yRange = other.m_yRange;
102 
103  // Tell if the mouse move was started onto either axis, because that will
104  // condition if some calculations needs to be performed or not (for example,
105  // if the mouse cursor motion was started on an axis, there is no point to
106  // perform deconvolutions).
109 
111 
112  // The user-selected region over the plot.
113  // Note that we cannot use QCPRange structures because these are normalized by
114  // QCustomPlot in such a manner that lower is actually < upper. But we need
115  // for a number of our calculations (specifically for the deconvolutions) to
116  // actually have the lower value be start drag point.x even if the drag
117  // direction was from right to left.
120 
123 
124  m_xDelta = other.m_xDelta;
125  m_yDelta = other.m_yDelta;
126 
129 
131 
134 
136 
139 
140  return *this;
141 }
142 
143 
145 {
146 }
147 
148 
151 {
152  int drag_directions = static_cast<int>(DragDirections::NOT_SET);
153 
155  drag_directions |= static_cast<int>(DragDirections::LEFT_TO_RIGHT);
156  else
157  drag_directions |= static_cast<int>(DragDirections::RIGHT_TO_LEFT);
158 
160  drag_directions |= static_cast<int>(DragDirections::BOTTOM_TO_TOP);
161  else
162  drag_directions |= static_cast<int>(DragDirections::TOP_TO_BOTTOM);
163 
164  //qDebug() << "DragDirections:" << drag_directions;
165 
166  m_dragDirections = static_cast<DragDirections>(drag_directions);
167 
168  return static_cast<DragDirections>(drag_directions);
169 }
170 
171 
172 QString
174 {
175  QString text("Context:");
176 
177  text += QString("data kind: %1").arg(static_cast<int>(m_dataKind));
178 
179  text += QString(" isMouseDragging: %1 -- wasMouseDragging: %2")
180  .arg(m_isMouseDragging ? "true" : "false")
181  .arg(m_wasMouseDragging ? "true" : "false");
182 
183  text += QString(" -- startDragPoint : (%1, %2)")
184  .arg(m_startDragPoint.x())
185  .arg(m_startDragPoint.y());
186 
187  text += QString(" -- currentDragPoint : (%1, %2)")
188  .arg(m_currentDragPoint.x())
189  .arg(m_currentDragPoint.y());
190 
191  text += QString(" -- lastCursorHoveredPoint : (%1, %2)")
192  .arg(m_lastCursorHoveredPoint.x())
193  .arg(m_lastCursorHoveredPoint.y());
194 
195  // Document how the mouse cursor is being dragged.
197  {
198  if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT))
199  text += " -- dragging from left to right";
200  else if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
201  text += " -- dragging from right to left";
202  if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
203  text += " -- dragging from top to bottom";
204  if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
205  text += " -- dragging from bottom to top";
206  }
207 
208  // The selection polygon.
209  text += m_selectionPolygon.toString();
210 
211  text +=
212  QString(" -- xRange: (%1, %2)").arg(m_xRange.lower).arg(m_xRange.upper);
213 
214  text +=
215  QString(" -- yRange: (%1, %2)").arg(m_yRange.lower).arg(m_yRange.upper);
216 
217  text += QString(" -- wasClickOnXAxis: %1")
218  .arg(m_wasClickOnXAxis ? "true" : "false");
219  text += QString(" -- wasClickOnYAxis: %1")
220  .arg(m_wasClickOnYAxis ? "true" : "false");
221  text += QString(" -- isMeasuringDistance: %1")
222  .arg(m_isMeasuringDistance ? "true" : "false");
223 
224  text += QString(" -- xRegionRangeStart: %1 -- xRegionRangeEnd: %2")
225  .arg(m_xRegionRangeStart)
226  .arg(m_xRegionRangeEnd);
227 
228  text += QString(" -- yRegionRangeStart: %1 -- yRegionRangeEnd: %2")
229  .arg(m_yRegionRangeStart)
230  .arg(m_yRegionRangeEnd);
231 
232  text += QString(" -- xDelta: %1 -- yDelta: %2").arg(m_xDelta).arg(m_yDelta);
233 
234  text += QString(" -- pressedKeyCode: %1").arg(m_pressedKeyCode);
235 
236  text += QString(" -- keyboardModifiers: %1").arg(m_keyboardModifiers);
237 
238  text +=
239  QString(" -- lastPressedMouseButton: %1").arg(m_lastPressedMouseButton);
240 
241  text +=
242  QString(" -- lastReleasedMouseButton: %1").arg(m_lastReleasedMouseButton);
243 
244  text += QString(" -- pressedMouseButtons: %1").arg(m_pressedMouseButtons);
245 
246  text +=
247  QString(" -- mouseButtonsAtMousePress: %1").arg(m_mouseButtonsAtMousePress);
248 
249  text += QString(" -- mouseButtonsAtMouseRelease: %1")
251 
252  return text;
253 }
254 
255 
256 } // namespace pappso
257 
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