libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::BasePlotContext Class Reference

#include <baseplotcontext.h>

Inheritance diagram for pappso::BasePlotContext:
pappso::MassSpecTracePlotContext

Public Member Functions

Q_INVOKABLE BasePlotContext (QObject *parent=nullptr)
 
virtual ~BasePlotContext ()
 
Q_INVOKABLE BasePlotContextclone (QObject *parent=nullptr)
 
Q_INVOKABLE void initialize (const BasePlotContext &other)
 
 BasePlotContext (const BasePlotContext &other)=delete
 
BasePlotContextoperator= (const BasePlotContext &other)=delete
 
void updateIntegrationScope ()
 
void updateIntegrationScopeRect ()
 
void updateIntegrationScopeRhomb ()
 
void updateIntegrationScopeRhombHorizontal ()
 
void updateIntegrationScopeRhombVertical ()
 
DragDirections recordDragDirections ()
 
Q_INVOKABLE QString toString () const
 

Static Public Member Functions

static void registerJsConstructor (QJSEngine *engine)
 

Public Attributes

Enums::DataKind m_dataKind = Enums::DataKind::unset
 
bool m_isMouseDragging = false
 
bool m_wasMouseDragging = false
 
bool m_isKeyBoardDragging = false
 
bool m_isLeftPseudoButtonKeyPressed = false
 
bool m_isRightPseudoButtonKeyPressed = false
 
bool m_wasKeyBoardDragging = false
 
QPointF m_startDragPoint
 
QPointF m_currentDragPoint
 
QPointF m_lastCursorHoveredPoint
 
DragDirections m_dragDirections = DragDirections::NOT_SET
 
IntegrationScopeBaseCstSPtr msp_integrationScope = nullptr
 
SelectionPolygon m_selectionPolygon
 
double m_integrationScopeRhombWidth = 0
 
double m_integrationScopeRhombHeight = 0
 
QCPRange m_xRange
 
QCPRange m_yRange
 
bool m_wasClickOnXAxis = false
 
bool m_wasClickOnYAxis = false
 
bool m_isMeasuringDistance = false
 
double m_xRegionRangeStart = std::numeric_limits<double>::min()
 
double m_xRegionRangeEnd = std::numeric_limits<double>::min()
 
double m_yRegionRangeStart = std::numeric_limits<double>::min()
 
double m_yRegionRangeEnd = std::numeric_limits<double>::min()
 
double m_xDelta = 0
 
double m_yDelta = 0
 
int m_pressedKeyCode
 
int m_releasedKeyCode
 
Qt::KeyboardModifiers m_keyboardModifiers
 
Qt::MouseButtons m_lastPressedMouseButton
 
Qt::MouseButtons m_lastReleasedMouseButton
 
Qt::MouseButtons m_pressedMouseButtons
 
Qt::MouseButtons m_mouseButtonsAtMousePress
 
Qt::MouseButtons m_mouseButtonsAtMouseRelease
 

Properties

bool isMouseDragging
 
bool wasMouseDragging
 
bool isKeyBoardDragging
 
bool isLeftPseudoButtonKeyPressed
 
bool isRightPseudoButtonKeyPressed
 
bool wasKeyBoardDragging
 

Detailed Description

Definition at line 52 of file baseplotcontext.h.

Constructor & Destructor Documentation

◆ BasePlotContext() [1/2]

pappso::BasePlotContext::BasePlotContext ( QObject * parent = nullptr)

Definition at line 31 of file baseplotcontext.cpp.

31 : QObject(parent)
32{
33 // So we know it is never nullptr.
34 msp_integrationScope = std::make_shared<IntegrationScopeBase>();
35}
IntegrationScopeBaseCstSPtr msp_integrationScope

References msp_integrationScope.

Referenced by BasePlotContext(), pappso::MassSpecTracePlotContext::MassSpecTracePlotContext(), clone(), initialize(), pappso::MassSpecTracePlotContext::initialize(), operator=(), and pappso::MassSpecTracePlotContext::operator=().

◆ ~BasePlotContext()

pappso::BasePlotContext::~BasePlotContext ( )
virtual

Definition at line 103 of file baseplotcontext.cpp.

104{
105}

◆ BasePlotContext() [2/2]

pappso::BasePlotContext::BasePlotContext ( const BasePlotContext & other)
delete

References BasePlotContext().

Member Function Documentation

◆ clone()

BasePlotContext * pappso::BasePlotContext::clone ( QObject * parent = nullptr)

Definition at line 108 of file baseplotcontext.cpp.

109{
110 BasePlotContext *copy_p = new BasePlotContext(parent);
111
112 // copy_p->m_dataKind = m_dataKind;
113
114 copy_p->m_isMouseDragging = m_isMouseDragging;
115 copy_p->m_wasMouseDragging = m_wasMouseDragging;
116
117 copy_p->m_isKeyBoardDragging = m_isKeyBoardDragging;
118 copy_p->m_isLeftPseudoButtonKeyPressed = m_isLeftPseudoButtonKeyPressed;
119 copy_p->m_isRightPseudoButtonKeyPressed = m_isRightPseudoButtonKeyPressed;
120 copy_p->m_wasKeyBoardDragging = m_wasKeyBoardDragging;
121
122 copy_p->m_startDragPoint = m_startDragPoint;
123 copy_p->m_currentDragPoint = m_currentDragPoint;
124 copy_p->m_lastCursorHoveredPoint = m_lastCursorHoveredPoint;
125
126 copy_p->m_selectionPolygon = m_selectionPolygon;
127 copy_p->msp_integrationScope = msp_integrationScope;
128 copy_p->m_integrationScopeRhombWidth = m_integrationScopeRhombWidth;
129 copy_p->m_integrationScopeRhombHeight = m_integrationScopeRhombHeight;
130
131 // The effective range of the axes.
132 copy_p->m_xRange = m_xRange;
133 copy_p->m_yRange = m_yRange;
134
135 // Tell if the mouse move was started onto either axis, because that will
136 // condition if some calculations needs to be performed or not (for example,
137 // if the mouse cursor motion was started on an axis, there is no point to
138 // perform deconvolutions).
139 copy_p->m_wasClickOnXAxis = m_wasClickOnXAxis;
140 copy_p->m_wasClickOnYAxis = m_wasClickOnYAxis;
141
142 copy_p->m_isMeasuringDistance = m_isMeasuringDistance;
143
144 // The user-selected region over the plot.
145 // Note that we cannot use QCPRange structures because these are normalized by
146 // QCustomPlot in such a manner that lower is actually < upper. But we need
147 // for a number of our calculations (specifically for the deconvolutions) to
148 // actually have the lower value be start drag point.x even if the drag
149 // direction was from right to left.
150 copy_p->m_xRegionRangeStart = m_xRegionRangeStart;
151 copy_p->m_xRegionRangeEnd = m_xRegionRangeEnd;
152
153 copy_p->m_yRegionRangeStart = m_yRegionRangeStart;
154 copy_p->m_yRegionRangeEnd = m_yRegionRangeEnd;
155
156 copy_p->m_xDelta = m_xDelta;
157 copy_p->m_yDelta = m_yDelta;
158
159 copy_p->m_pressedKeyCode = m_pressedKeyCode;
160 copy_p->m_releasedKeyCode = m_releasedKeyCode;
161
162 copy_p->m_keyboardModifiers = m_keyboardModifiers;
163
164 copy_p->m_lastPressedMouseButton = m_lastPressedMouseButton;
165 copy_p->m_lastReleasedMouseButton = m_lastReleasedMouseButton;
166
167 copy_p->m_pressedMouseButtons = m_pressedMouseButtons;
168
169 copy_p->m_mouseButtonsAtMousePress = m_mouseButtonsAtMousePress;
170 copy_p->m_mouseButtonsAtMouseRelease = m_mouseButtonsAtMouseRelease;
171
172 return copy_p;
173}
Qt::MouseButtons m_mouseButtonsAtMousePress
SelectionPolygon m_selectionPolygon
Q_INVOKABLE BasePlotContext(QObject *parent=nullptr)
Qt::KeyboardModifiers m_keyboardModifiers
Qt::MouseButtons m_lastPressedMouseButton
Qt::MouseButtons m_pressedMouseButtons
Qt::MouseButtons m_mouseButtonsAtMouseRelease
Qt::MouseButtons m_lastReleasedMouseButton

References BasePlotContext(), m_currentDragPoint, m_integrationScopeRhombHeight, m_integrationScopeRhombWidth, m_isKeyBoardDragging, m_isLeftPseudoButtonKeyPressed, m_isMeasuringDistance, m_isMouseDragging, m_isRightPseudoButtonKeyPressed, m_keyboardModifiers, m_lastCursorHoveredPoint, m_lastPressedMouseButton, m_lastReleasedMouseButton, m_mouseButtonsAtMousePress, m_mouseButtonsAtMouseRelease, m_pressedKeyCode, m_pressedMouseButtons, m_releasedKeyCode, m_selectionPolygon, m_startDragPoint, m_wasClickOnXAxis, m_wasClickOnYAxis, m_wasKeyBoardDragging, m_wasMouseDragging, m_xDelta, m_xRange, m_xRegionRangeEnd, m_xRegionRangeStart, m_yDelta, m_yRange, m_yRegionRangeEnd, m_yRegionRangeStart, and msp_integrationScope.

◆ initialize()

void pappso::BasePlotContext::initialize ( const BasePlotContext & other)

Definition at line 176 of file baseplotcontext.cpp.

177{
178 // m_dataKind = other.m_dataKind;
179
180 m_isMouseDragging = other.m_isMouseDragging;
181 m_wasMouseDragging = other.m_wasMouseDragging;
182
183 m_isKeyBoardDragging = other.m_isKeyBoardDragging;
184 m_isLeftPseudoButtonKeyPressed = other.m_isLeftPseudoButtonKeyPressed;
185 m_isRightPseudoButtonKeyPressed = other.m_isRightPseudoButtonKeyPressed;
186 m_wasKeyBoardDragging = other.m_wasKeyBoardDragging;
187
188 m_startDragPoint = other.m_startDragPoint;
189 m_currentDragPoint = other.m_currentDragPoint;
190 m_lastCursorHoveredPoint = other.m_lastCursorHoveredPoint;
191
192 m_selectionPolygon = other.m_selectionPolygon;
193 msp_integrationScope = other.msp_integrationScope;
194 m_integrationScopeRhombWidth = other.m_integrationScopeRhombWidth;
195 m_integrationScopeRhombHeight = other.m_integrationScopeRhombHeight;
196
197 // The effective range of the axes.
198 m_xRange = other.m_xRange;
199 m_yRange = other.m_yRange;
200
201 // Tell if the mouse move was started onto either axis, because that will
202 // condition if some calculations needs to be performed or not (for example,
203 // if the mouse cursor motion was started on an axis, there is no point to
204 // perform deconvolutions).
205 m_wasClickOnXAxis = other.m_wasClickOnXAxis;
206 m_wasClickOnYAxis = other.m_wasClickOnYAxis;
207
208 m_isMeasuringDistance = other.m_isMeasuringDistance;
209
210 // The user-selected region over the plot.
211 // Note that we cannot use QCPRange structures because these are normalized by
212 // QCustomPlot in such a manner that lower is actually < upper. But we need
213 // for a number of our calculations (specifically for the deconvolutions) to
214 // actually have the lower value be start drag point.x even if the drag
215 // direction was from right to left.
216 m_xRegionRangeStart = other.m_xRegionRangeStart;
217 m_xRegionRangeEnd = other.m_xRegionRangeEnd;
218
219 m_yRegionRangeStart = other.m_yRegionRangeStart;
220 m_yRegionRangeEnd = other.m_yRegionRangeEnd;
221
222 m_xDelta = other.m_xDelta;
223 m_yDelta = other.m_yDelta;
224
225 m_pressedKeyCode = other.m_pressedKeyCode;
226 m_releasedKeyCode = other.m_releasedKeyCode;
227
228 m_keyboardModifiers = other.m_keyboardModifiers;
229
230 m_lastPressedMouseButton = other.m_lastPressedMouseButton;
231 m_lastReleasedMouseButton = other.m_lastReleasedMouseButton;
232
233 m_pressedMouseButtons = other.m_pressedMouseButtons;
234
235 m_mouseButtonsAtMousePress = other.m_mouseButtonsAtMousePress;
236 m_mouseButtonsAtMouseRelease = other.m_mouseButtonsAtMouseRelease;
237}

References BasePlotContext(), m_currentDragPoint, m_integrationScopeRhombHeight, m_integrationScopeRhombWidth, m_isKeyBoardDragging, m_isLeftPseudoButtonKeyPressed, m_isMeasuringDistance, m_isMouseDragging, m_isRightPseudoButtonKeyPressed, m_keyboardModifiers, m_lastCursorHoveredPoint, m_lastPressedMouseButton, m_lastReleasedMouseButton, m_mouseButtonsAtMousePress, m_mouseButtonsAtMouseRelease, m_pressedKeyCode, m_pressedMouseButtons, m_releasedKeyCode, m_selectionPolygon, m_startDragPoint, m_wasClickOnXAxis, m_wasClickOnYAxis, m_wasKeyBoardDragging, m_wasMouseDragging, m_xDelta, m_xRange, m_xRegionRangeEnd, m_xRegionRangeStart, m_yDelta, m_yRange, m_yRegionRangeEnd, m_yRegionRangeStart, and msp_integrationScope.

Referenced by pappso::MassSpecTracePlotContext::initialize(), and pappso::MassSpecTracePlotContext::initialize().

◆ operator=()

BasePlotContext & pappso::BasePlotContext::operator= ( const BasePlotContext & other)
delete

References BasePlotContext().

◆ recordDragDirections()

DragDirections pappso::BasePlotContext::recordDragDirections ( )

Definition at line 819 of file baseplotcontext.cpp.

820{
821 int drag_directions = static_cast<int>(DragDirections::NOT_SET);
822
824 drag_directions |= static_cast<int>(DragDirections::LEFT_TO_RIGHT);
825 else
826 drag_directions |= static_cast<int>(DragDirections::RIGHT_TO_LEFT);
827
829 drag_directions |= static_cast<int>(DragDirections::BOTTOM_TO_TOP);
830 else
831 drag_directions |= static_cast<int>(DragDirections::TOP_TO_BOTTOM);
832
833 // qDebug() << "DragDirections:" << drag_directions;
834
835 m_dragDirections = static_cast<DragDirections>(drag_directions);
836
837 return static_cast<DragDirections>(drag_directions);
838}
DragDirections m_dragDirections

References pappso::BOTTOM_TO_TOP, pappso::LEFT_TO_RIGHT, m_currentDragPoint, m_dragDirections, m_startDragPoint, pappso::NOT_SET, pappso::RIGHT_TO_LEFT, and pappso::TOP_TO_BOTTOM.

◆ registerJsConstructor()

void pappso::BasePlotContext::registerJsConstructor ( QJSEngine * engine)
static

Definition at line 921 of file baseplotcontext.cpp.

922{
923 if(!engine)
924 {
925 qWarning() << "Cannot register class: engine is null";
926 return;
927 }
928
929 // Register the meta object as a constructor
930 QJSValue jsMetaObject = engine->newQMetaObject(&BasePlotContext::staticMetaObject);
931 engine->globalObject().setProperty("BasePlotContext", jsMetaObject);
932
933 QJSValue enumObject = engine->newObject();
934 enumObject.setProperty("NOT_SET", static_cast<int>(pappso::DragDirections::NOT_SET));
935 enumObject.setProperty("LEFT_TO_RIGHT", static_cast<int>(pappso::DragDirections::LEFT_TO_RIGHT));
936 enumObject.setProperty("RIGHT_TO_LEFT", static_cast<int>(pappso::DragDirections::RIGHT_TO_LEFT));
937 enumObject.setProperty("TOP_TO_BOTTOM", static_cast<int>(pappso::DragDirections::TOP_TO_BOTTOM));
938 enumObject.setProperty("BOTTOM_TO_TOP", static_cast<int>(pappso::DragDirections::BOTTOM_TO_TOP));
939
940 // Make it available in the global JS scope
941 engine->globalObject().setProperty("DragDirections", enumObject);
942}

References pappso::BOTTOM_TO_TOP, pappso::LEFT_TO_RIGHT, pappso::NOT_SET, pappso::RIGHT_TO_LEFT, and pappso::TOP_TO_BOTTOM.

◆ toString()

QString pappso::BasePlotContext::toString ( ) const

Definition at line 842 of file baseplotcontext.cpp.

843{
844 QString text("Context:");
845
846 text += QString("data kind: %1").arg(static_cast<int>(m_dataKind));
847
848 text += QString(" isMouseDragging: %1 -- wasMouseDragging: %2")
849 .arg(m_isMouseDragging ? "true" : "false")
850 .arg(m_wasMouseDragging ? "true" : "false");
851
852 text +=
853 QString(" -- startDragPoint : (%1, %2)").arg(m_startDragPoint.x()).arg(m_startDragPoint.y());
854
855 text += QString(" -- currentDragPoint : (%1, %2)")
856 .arg(m_currentDragPoint.x())
857 .arg(m_currentDragPoint.y());
858
859 text += QString(" -- lastCursorHoveredPoint : (%1, %2)")
861 .arg(m_lastCursorHoveredPoint.y());
862
863 // Document how the mouse cursor is being dragged.
865 {
866 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT))
867 text += " -- dragging from left to right";
868 else if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
869 text += " -- dragging from right to left";
870 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
871 text += " -- dragging from top to bottom";
872 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
873 text += " -- dragging from bottom to top";
874 }
875
876 // The integration scope
877 text += " -- Integration scope: ";
878 text += msp_integrationScope->toString();
879 text += " -- ";
880
881 text += QString(" -- xRange: (%1, %2)").arg(m_xRange.lower).arg(m_xRange.upper);
882
883 text += QString(" -- yRange: (%1, %2)").arg(m_yRange.lower).arg(m_yRange.upper);
884
885 text += QString(" -- wasClickOnXAxis: %1").arg(m_wasClickOnXAxis ? "true" : "false");
886 text += QString(" -- wasClickOnYAxis: %1").arg(m_wasClickOnYAxis ? "true" : "false");
887 text += QString(" -- isMeasuringDistance: %1").arg(m_isMeasuringDistance ? "true" : "false");
888
889 text += QString(" -- xRegionRangeStart: %1 -- xRegionRangeEnd: %2")
891 .arg(m_xRegionRangeEnd);
892
893 text += QString(" -- yRegionRangeStart: %1 -- yRegionRangeEnd: %2")
895 .arg(m_yRegionRangeEnd);
896
897 text += QString(" -- xDelta: %1 -- yDelta: %2").arg(m_xDelta).arg(m_yDelta);
898
899 text += QString(" -- pressedKeyCode: %1").arg(m_pressedKeyCode);
900
901 text += QString(" -- keyboardModifiers: %1").arg(m_keyboardModifiers);
902
903 text +=
904 QString(" -- lastPressedMouseButton: %1").arg(qtMouseButtonsMap[m_lastPressedMouseButton]);
905
906 text +=
907 QString(" -- lastReleasedMouseButton: %1").arg(qtMouseButtonsMap[m_lastReleasedMouseButton]);
908
909 text += QString(" -- pressedMouseButtons: %1").arg(qtMouseButtonsMap[m_pressedMouseButtons]);
910
911 text +=
912 QString(" -- mouseButtonsAtMousePress: %1").arg(qtMouseButtonsMap[m_mouseButtonsAtMousePress]);
913
914 text += QString(" -- mouseButtonsAtMouseRelease: %1")
916
917 return text;
918}
Enums::DataKind m_dataKind
std::map< Qt::MouseButtons, QString > qtMouseButtonsMap

References pappso::BOTTOM_TO_TOP, pappso::LEFT_TO_RIGHT, m_currentDragPoint, m_dataKind, m_dragDirections, m_isMeasuringDistance, m_isMouseDragging, m_keyboardModifiers, m_lastCursorHoveredPoint, m_lastPressedMouseButton, m_lastReleasedMouseButton, m_mouseButtonsAtMousePress, m_mouseButtonsAtMouseRelease, m_pressedKeyCode, m_pressedMouseButtons, m_startDragPoint, m_wasClickOnXAxis, m_wasClickOnYAxis, m_wasMouseDragging, m_xDelta, m_xRange, m_xRegionRangeEnd, m_xRegionRangeStart, m_yDelta, m_yRange, m_yRegionRangeEnd, m_yRegionRangeStart, msp_integrationScope, pappso::qtMouseButtonsMap, pappso::RIGHT_TO_LEFT, and pappso::TOP_TO_BOTTOM.

Referenced by pappso::MassSpecTracePlotContext::toString().

◆ updateIntegrationScope()

void pappso::BasePlotContext::updateIntegrationScope ( )

Definition at line 241 of file baseplotcontext.cpp.

242{
243 // qDebug();
244
245 // By essence, IntegrationScope is 1D scope. The point of the scope is the
246 // left bottom point, and then we document the width.
247
248 double x_range_start = std::min(m_currentDragPoint.x(), m_startDragPoint.x());
249 double x_range_end = std::max(m_currentDragPoint.x(), m_startDragPoint.x());
250
251 double y_position = m_startDragPoint.y();
252
253 QPointF point(x_range_start, y_position);
254 double width = x_range_end - x_range_start;
255
256 // qDebug() << "Going to create an integration scope with point:" << point
257 // << "and width:" << width;
258 msp_integrationScope = std::make_shared<IntegrationScope>(point, width);
259 // qDebug() << "Created integration scope:" << msp_integrationScope->toString();
260}

References m_currentDragPoint, m_startDragPoint, and msp_integrationScope.

◆ updateIntegrationScopeRect()

void pappso::BasePlotContext::updateIntegrationScopeRect ( )

Definition at line 264 of file baseplotcontext.cpp.

265{
266 // qDebug();
267
268 // By essence, IntegrationScopeRect is a squared rectangle scope. The point of
269 // the scope is the left bottom point, and then we document the width and the
270 // height.
271
272 /* Like this:
273 *
274 +---------------------------+ -
275 | | |
276 | | |
277 | | m_height
278 | | |
279 | | |
280 P---------------------------+ -
281
282 |--------- m_width ---------|
283
284 */
285
286 // We need to find the point that is actually the left bottom point.
287
288 QPointF point;
289 double width = 0;
290 double height = 0;
291
292 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
293 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
294 {
295 point.rx() = m_startDragPoint.x();
296 point.ry() = m_startDragPoint.y();
297 width = m_currentDragPoint.x() - point.rx();
298 height = m_currentDragPoint.y() - point.ry();
299 // qDebug() << "left to right - bottom to top";
300 }
301
302 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
303 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
304 {
305 point.rx() = m_currentDragPoint.x();
306 point.ry() = m_currentDragPoint.y();
307 width = m_startDragPoint.x() - m_currentDragPoint.x();
308 height = m_startDragPoint.y() - m_currentDragPoint.y();
309 // qDebug() << "right to left - bottom to top";
310 }
311
312 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
313 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
314 {
315 point.rx() = m_startDragPoint.x();
316 point.ry() = m_currentDragPoint.y();
317 width = m_currentDragPoint.x() - m_startDragPoint.x();
318 height = m_startDragPoint.y() - m_currentDragPoint.y();
319 // qDebug() << "left to right - top to bottom";
320 }
321
322 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
323 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
324 {
325 point.rx() = m_currentDragPoint.x();
326 point.ry() = m_currentDragPoint.y();
327 width = m_startDragPoint.x() - m_currentDragPoint.x();
328 height = m_startDragPoint.y() - m_currentDragPoint.y();
329 // qDebug() << "right to left - top to bottom";
330 }
331
332 // qDebug() << "The data used to update the integration scope:";
333 // qDebug() << "Point:" << point << "width:" << width << "height:" << height;
334 //
335 // qDebug() << "The integration scope before update:" << mpa_integrationScope;
336 //
337 // qDebug() << "Will update IntegrationScopeRect with:" << point << "width"
338 // << width << "height" << height;
339 msp_integrationScope = std::make_shared<IntegrationScopeRect>(point, width, height);
340
341
342 // if(typeid(*mpa_integrationScope) == typeid(IntegrationScopeInterface))
343 // qDebug() << "The pointer is of type IntegrationScopeInterface";
344 // if(typeid(*mpa_integrationScope) == typeid(IntegrationScope))
345 // qDebug() << "The pointer is of type IntegrationScope";
346 // if(typeid(*mpa_integrationScope) == typeid(IntegrationScopeRect))
347 // qDebug() << "The pointer is of type IntegrationScopeRect";
348 // if(typeid(*mpa_integrationScope) == typeid(IntegrationScopeRhomb))
349 // qDebug() << "The pointer is of type IntegrationScopeRhomb";
350 //
351 // qDebug() << "The integration scope right after update:"
352 // << mpa_integrationScope;
353 //
354 // if(!mpa_integrationScope->getPoint(point))
355 // qFatal("Could not get point.");
356 // qDebug() << "The point:" << point;
357 // if(!mpa_integrationScope->getWidth(width))
358 // qFatal("Oh no!!!! width");
359 // if(!mpa_integrationScope->getWidth(height))
360 // qFatal("Oh no!!!! height");
361}

References pappso::BOTTOM_TO_TOP, pappso::LEFT_TO_RIGHT, m_currentDragPoint, m_dragDirections, m_startDragPoint, msp_integrationScope, pappso::RIGHT_TO_LEFT, and pappso::TOP_TO_BOTTOM.

◆ updateIntegrationScopeRhomb()

void pappso::BasePlotContext::updateIntegrationScopeRhomb ( )

Definition at line 666 of file baseplotcontext.cpp.

667{
668 // qDebug() << toString();
669
670 // By essence, IntegrationScopeRhomb is a rhomboid polygon. Just set the
671 // points. There are two kinds of rhomboid integration scopes: horizontal and
672 // vertical.
673
674 /*
675 +----------+
676 | |
677 | |
678 | |
679 | |
680 | |
681 | |
682 | |
683 +----------+
684 ----width---
685 */
686
687 // As visible here, the fixed size of the rhomboid (using the S key in the
688 // plot widget) is the *horizontal* side (that is, the rhomboid has a non-0
689 // width)..
690
691 // However, it might be useful to be able to draw rhomboid integration scopes
692 // like this, that would correspond to the rhomboid above after a transpose
693 // operation.
694
695 /*
696 +
697 . |
698 . |
699 . |
700 . +
701 . .
702 . .
703 . .
704 + .
705 | | .
706 height | | .
707 | | .
708 +
709
710*/
711
712 // As visible here, the fixed size of the rhomboid (using the S key in the
713 // plot widget) is the vertical side (that is, the rhomboid has a non-0
714 // height).
715
716 // The general rule is thus that when the m_integrationScopeRhombWidth is
717 // not-0, then the first shape is considered, while when the
718 // m_integrationScopeRhombHeight is non-0, then the second shape is
719 // considered.
720
721 // This function is called when the user has dragged the cursor (left or right
722 // button, not for or for integration, respectively) with the 'Alt' modifier
723 // key pressed, so that they want to perform a rhomboid integration scope
724 // calculation.
725
726 // Of course, the integration scope in the context might not be a rhomboid
727 // scope, because we might enter this function as a very firt switch from
728 // scope or scopeRect to scopeRhomb. The only indication we have to direct the
729 // creation of a horizontal or vertical rhomboid is the
730 // m_integrationScopeRhombWidth/m_integrationScopeRhombHeight recorded in the
731 // plot widget that owns this plot context.
732
733 // qDebug() << "In updateIntegrationScopeRhomb, m_integrationScopeRhombWidth:"
734 // << m_integrationScopeRhombWidth
735 // << "and m_integrationScopeRhombHeight:"
736 // << m_integrationScopeRhombHeight;
737
739 qFatal(
740 "Both m_integrationScopeRhombWidth and m_integrationScopeRhombHeight of "
741 "rhomboid integration scope cannot be 0.");
742
747}

References m_integrationScopeRhombHeight, m_integrationScopeRhombWidth, updateIntegrationScopeRhombHorizontal(), and updateIntegrationScopeRhombVertical().

◆ updateIntegrationScopeRhombHorizontal()

void pappso::BasePlotContext::updateIntegrationScopeRhombHorizontal ( )

Definition at line 365 of file baseplotcontext.cpp.

366{
367 // qDebug() << toString();
368
369 /*
370 4+----------+3
371 | |
372 | |
373 | |
374 | |
375 | |
376 | |
377 | |
378 1+----------+2
379 ----width---
380 */
381
382 // As visible here, the fixed size of the rhomboid (using the S key in the
383 // plot widget) is the horizontal side.
384
385 // The points are numbered in a counterclockwise manner, starting from the
386 // starting drag point. The width side is right of the start drag point if
387 // the user drags from left to right and left of the start drag point if
388 // the user drags from left to right. In the figure above, the user
389 // has dragged the mouse from point 1 and to the right and upwards.
390 // Thus the width side is right of point 1. Because the numbering
391 // is counterclockwise, that point happens to be numbered 2.
392
393 // If the user had draggged the mouse starting at point 3 and to the left
394 // and to the bottom, then point 3 above would be point 1, point 4
395 // would be point 2 because the width side is left of the start
396 // drag point; point 1 would be point 3 and finally the last point
397 // would be at point 2.
398
399 // Sanity check
401 qFatal(
402 "The m_integrationScopeRhombWidth of the fixed rhomboid side cannot be "
403 "0.");
404
405 QPointF point;
406 std::vector<QPointF> points;
407
408 // Fill-in the points in the vector in the order they are created
409 // while drawing the rhomboid shape. Thus, the first point (start of the
410 // mouse click & drag operation is always the same.
411
412 point.rx() = m_startDragPoint.x();
413 point.ry() = m_startDragPoint.y();
414 points.push_back(point);
415 // qDebug() << "Start point:" << point;
416
417 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
418 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
419 {
420 // Second point.
422 point.ry() = m_startDragPoint.y();
423 points.push_back(point);
424 // qDebug() << "Second point:" << point;
425
426 // Third point.
428 point.ry() = m_currentDragPoint.ry();
429 points.push_back(point);
430 // qDebug() << "Third point:" << point;
431
432 // Fourth point.
433 point.rx() = m_currentDragPoint.rx();
434 point.ry() = m_currentDragPoint.ry();
435 points.push_back(point);
436 // qDebug() << "Last point:" << point;
437 }
438
439 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
440 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
441 {
442 // Second point.
443 point.rx() = m_currentDragPoint.rx();
444 point.ry() = m_currentDragPoint.ry();
445 points.push_back(point);
446 // qDebug() << "Second point:" << point;
447
448 // Third point.
450 point.ry() = m_currentDragPoint.ry();
451 points.push_back(point);
452 // qDebug() << "Third point:" << point;
453
454 // Fourth point.
456 point.ry() = m_startDragPoint.ry();
457 points.push_back(point);
458 // qDebug() << "Last point:" << point;
459 }
460
461 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
462 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
463 {
464 // Second point.
465 point.rx() = m_currentDragPoint.rx();
466 point.ry() = m_currentDragPoint.ry();
467 points.push_back(point);
468 // qDebug() << "Second point:" << point;
469
470 // Third point.
472 point.ry() = m_currentDragPoint.ry();
473 points.push_back(point);
474 // qDebug() << "Third point:" << point;
475
476 // Fourth point.
478 point.ry() = m_startDragPoint.y();
479 points.push_back(point);
480 // qDebug() << "Last point:" << point;
481 }
482
483 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
484 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
485 {
486 // Second point.
488 point.ry() = m_startDragPoint.y();
489 points.push_back(point);
490 // qDebug() << "Second point:" << point;
491
492 // Third point.
494 point.ry() = m_currentDragPoint.ry();
495 points.push_back(point);
496 // qDebug() << "Third point:" << point;
497
498 // Fourth point.
499 point.rx() = m_currentDragPoint.rx();
500 point.ry() = m_currentDragPoint.ry();
501 points.push_back(point);
502 // qDebug() << "Last point:" << point;
503 }
504
505
506 msp_integrationScope = std::make_shared<IntegrationScopeRhomb>(points);
507
508 // qDebug() << "Created an integration scope horizontal rhomboid with"
509 // << points.size() << "points:" << msp_integrationScope->toString();
510}

References pappso::BOTTOM_TO_TOP, pappso::LEFT_TO_RIGHT, m_currentDragPoint, m_dragDirections, m_integrationScopeRhombWidth, m_startDragPoint, msp_integrationScope, pappso::RIGHT_TO_LEFT, and pappso::TOP_TO_BOTTOM.

Referenced by updateIntegrationScopeRhomb().

◆ updateIntegrationScopeRhombVertical()

void pappso::BasePlotContext::updateIntegrationScopeRhombVertical ( )

Definition at line 514 of file baseplotcontext.cpp.

515{
516 // qDebug() << toString();
517
518 /*
519 * +3
520 * . |
521 * . |
522 * . |
523 * . +2
524 * . .
525 * . .
526 * . .
527 * 4+ .
528 * | | .
529 * height | | .
530 * | | .
531 * 1+
532 *
533 */
534
535 // As visible here, the fixed size of the rhomboid (using the S key in the
536 // plot widget) is the vertical side.
537
538 // The points are numbered in a counterclockwise manner, starting from the
539 // starting drag point. The height side is below the start drag point if
540 // the user drags from top to bottom and above the start drag point if
541 // the user drags from bottom to top. In the figure above, the user
542 // has dragged the mouse from point 1 and to the right and upwards.
543 // Thus the height side is above the point 1. Because the numbering
544 // is counterclockwise, that point happens to be numbered 4.
545
546 // If the user had draggged the mouse starting at point 3 and to the left
547 // and to the bottom, then point 3 above would be point 1, point 4
548 // would be ponit 2, point 1 would be point 3 and finally, because
549 // the dragging is from top to bottom, the last point would be at point 2
550 // above, because the height side of the rhomboid is below the start
551 // drag point.
552
553 // Sanity check
555 qFatal("The height of the fixed rhomboid side cannot be 0.");
556
557 QPointF point;
558 std::vector<QPointF> points;
559
560 // Fill-in the points in the vector in the order they are created
561 // while drawing the rhomboid shape. Thus, the first point (start of the
562 // mouse click & drag operation is always the same, the leftmost bottom point
563 // of the drawing above (point 1).
564
565 point.rx() = m_startDragPoint.x();
566 point.ry() = m_startDragPoint.y();
567 points.push_back(point);
568 qDebug() << "Start point:" << point;
569
570 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
571 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
572 {
573 // Second point.
574 point.rx() = m_currentDragPoint.rx();
575 point.ry() = m_currentDragPoint.ry();
576 points.push_back(point);
577 // qDebug() << "Second point:" << point;
578
579 // Third point.
580 point.rx() = m_currentDragPoint.rx();
582 points.push_back(point);
583 // qDebug() << "Third point:" << point;
584
585 // Fourth point.
586 point.rx() = m_startDragPoint.x();
588 points.push_back(point);
589 // qDebug() << "Last point:" << point;
590 }
591
592 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
593 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
594 {
595 // Second point.
596 point.rx() = m_startDragPoint.rx();
598 points.push_back(point);
599 // qDebug() << "Second point:" << point;
600
601 // Third point.
602 point.rx() = m_currentDragPoint.rx();
604 points.push_back(point);
605 // qDebug() << "Third point:" << point;
606
607 // Fourth point.
608 point.rx() = m_currentDragPoint.x();
609 point.ry() = m_currentDragPoint.y();
610 points.push_back(point);
611 // qDebug() << "Last point:" << point;
612 }
613
614 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
615 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
616 {
617 // Second point.
618 point.rx() = m_startDragPoint.x();
620 points.push_back(point);
621 // qDebug() << "Second point:" << point;
622
623 // Third point.
624 point.rx() = m_currentDragPoint.rx();
626 points.push_back(point);
627 // qDebug() << "Third point:" << point;
628
629 // Fourth point.
630 point.rx() = m_currentDragPoint.rx();
631 point.ry() = m_currentDragPoint.ry();
632 points.push_back(point);
633 // qDebug() << "Last point:" << point;
634 }
635
636 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
637 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
638 {
639 // Second point.
640 point.rx() = m_currentDragPoint.rx();
641 point.ry() = m_currentDragPoint.ry();
642 points.push_back(point);
643 // qDebug() << "Second point:" << point;
644
645 // Third point.
646 point.rx() = m_currentDragPoint.rx();
648 points.push_back(point);
649 // qDebug() << "Third point:" << point;
650
651 // Fourth point.
652 point.rx() = m_startDragPoint.rx();
654 points.push_back(point);
655 // qDebug() << "Last point:" << point;
656 }
657
658 msp_integrationScope = std::make_shared<IntegrationScopeRhomb>(points);
659
660 // qDebug() << "Created an integration scope vertical rhomboid with"
661 // << points.size() << "points:" << msp_integrationScope->toString();
662}

References pappso::BOTTOM_TO_TOP, pappso::LEFT_TO_RIGHT, m_currentDragPoint, m_dragDirections, m_integrationScopeRhombHeight, m_startDragPoint, msp_integrationScope, pappso::RIGHT_TO_LEFT, and pappso::TOP_TO_BOTTOM.

Referenced by updateIntegrationScopeRhomb().

Member Data Documentation

◆ m_currentDragPoint

◆ m_dataKind

Enums::DataKind pappso::BasePlotContext::m_dataKind = Enums::DataKind::unset

Definition at line 75 of file baseplotcontext.h.

Referenced by toString().

◆ m_dragDirections

◆ m_integrationScopeRhombHeight

double pappso::BasePlotContext::m_integrationScopeRhombHeight = 0

◆ m_integrationScopeRhombWidth

double pappso::BasePlotContext::m_integrationScopeRhombWidth = 0

◆ m_isKeyBoardDragging

bool pappso::BasePlotContext::m_isKeyBoardDragging = false

Definition at line 80 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_isLeftPseudoButtonKeyPressed

bool pappso::BasePlotContext::m_isLeftPseudoButtonKeyPressed = false

Definition at line 81 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_isMeasuringDistance

bool pappso::BasePlotContext::m_isMeasuringDistance = false

Definition at line 106 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_isMouseDragging

bool pappso::BasePlotContext::m_isMouseDragging = false

Definition at line 77 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_isRightPseudoButtonKeyPressed

bool pappso::BasePlotContext::m_isRightPseudoButtonKeyPressed = false

Definition at line 82 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_keyboardModifiers

Qt::KeyboardModifiers pappso::BasePlotContext::m_keyboardModifiers

Definition at line 126 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_lastCursorHoveredPoint

QPointF pappso::BasePlotContext::m_lastCursorHoveredPoint

Definition at line 87 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_lastPressedMouseButton

Qt::MouseButtons pappso::BasePlotContext::m_lastPressedMouseButton

Definition at line 128 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_lastReleasedMouseButton

Qt::MouseButtons pappso::BasePlotContext::m_lastReleasedMouseButton

Definition at line 129 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_mouseButtonsAtMousePress

Qt::MouseButtons pappso::BasePlotContext::m_mouseButtonsAtMousePress

Definition at line 133 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_mouseButtonsAtMouseRelease

Qt::MouseButtons pappso::BasePlotContext::m_mouseButtonsAtMouseRelease

Definition at line 134 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_pressedKeyCode

int pappso::BasePlotContext::m_pressedKeyCode

Definition at line 123 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_pressedMouseButtons

Qt::MouseButtons pappso::BasePlotContext::m_pressedMouseButtons

Definition at line 131 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_releasedKeyCode

int pappso::BasePlotContext::m_releasedKeyCode

Definition at line 124 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_selectionPolygon

SelectionPolygon pappso::BasePlotContext::m_selectionPolygon

Definition at line 91 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_startDragPoint

◆ m_wasClickOnXAxis

bool pappso::BasePlotContext::m_wasClickOnXAxis = false

Definition at line 103 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_wasClickOnYAxis

bool pappso::BasePlotContext::m_wasClickOnYAxis = false

Definition at line 104 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_wasKeyBoardDragging

bool pappso::BasePlotContext::m_wasKeyBoardDragging = false

Definition at line 83 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_wasMouseDragging

bool pappso::BasePlotContext::m_wasMouseDragging = false

Definition at line 78 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_xDelta

double pappso::BasePlotContext::m_xDelta = 0

Definition at line 120 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_xRange

QCPRange pappso::BasePlotContext::m_xRange

Definition at line 96 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_xRegionRangeEnd

double pappso::BasePlotContext::m_xRegionRangeEnd = std::numeric_limits<double>::min()

Definition at line 115 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_xRegionRangeStart

double pappso::BasePlotContext::m_xRegionRangeStart = std::numeric_limits<double>::min()

Definition at line 114 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_yDelta

double pappso::BasePlotContext::m_yDelta = 0

Definition at line 121 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_yRange

QCPRange pappso::BasePlotContext::m_yRange

Definition at line 97 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_yRegionRangeEnd

double pappso::BasePlotContext::m_yRegionRangeEnd = std::numeric_limits<double>::min()

Definition at line 118 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ m_yRegionRangeStart

double pappso::BasePlotContext::m_yRegionRangeStart = std::numeric_limits<double>::min()

Definition at line 117 of file baseplotcontext.h.

Referenced by clone(), initialize(), and toString().

◆ msp_integrationScope

Property Documentation

◆ isKeyBoardDragging

bool pappso::BasePlotContext::isKeyBoardDragging

Definition at line 57 of file baseplotcontext.h.

◆ isLeftPseudoButtonKeyPressed

bool pappso::BasePlotContext::isLeftPseudoButtonKeyPressed

Definition at line 58 of file baseplotcontext.h.

◆ isMouseDragging

bool pappso::BasePlotContext::isMouseDragging

Definition at line 55 of file baseplotcontext.h.

◆ isRightPseudoButtonKeyPressed

bool pappso::BasePlotContext::isRightPseudoButtonKeyPressed

Definition at line 59 of file baseplotcontext.h.

◆ wasKeyBoardDragging

bool pappso::BasePlotContext::wasKeyBoardDragging

Definition at line 60 of file baseplotcontext.h.

◆ wasMouseDragging

bool pappso::BasePlotContext::wasMouseDragging

Definition at line 56 of file baseplotcontext.h.


The documentation for this class was generated from the following files: