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
 
Q_INVOKABLE QString dragDirectionsToString () 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 54 of file baseplotcontext.h.

Constructor & Destructor Documentation

◆ BasePlotContext() [1/2]

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

Definition at line 41 of file baseplotcontext.cpp.

41 : QObject(parent)
42{
43 // So we know it is never nullptr.
44 msp_integrationScope = std::make_shared<IntegrationScopeBase>();
45}
IntegrationScopeBaseCstSPtr msp_integrationScope

References msp_integrationScope.

◆ ~BasePlotContext()

pappso::BasePlotContext::~BasePlotContext ( )
virtual

Definition at line 113 of file baseplotcontext.cpp.

114{
115}

◆ BasePlotContext() [2/2]

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

Member Function Documentation

◆ clone()

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

Definition at line 118 of file baseplotcontext.cpp.

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

References m_currentDragPoint, m_dragDirections, 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.

◆ dragDirectionsToString()

QString pappso::BasePlotContext::dragDirectionsToString ( ) const

Definition at line 953 of file baseplotcontext.cpp.

954{
955 QString text;
956
957 // Document how the mouse cursor is being dragged.
959 {
960 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT))
961 text += " -- dragging from left to right";
962 else if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
963 text += " -- dragging from right to left";
964 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
965 text += " -- dragging from top to bottom";
966 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
967 text += " -- dragging from bottom to top";
968 }
969
970 return text;
971}

References pappso::BOTTOM_TO_TOP, pappso::LEFT_TO_RIGHT, m_dragDirections, m_isMouseDragging, pappso::RIGHT_TO_LEFT, and pappso::TOP_TO_BOTTOM.

Referenced by pappso::BasePlotWidget::mouseMoveHandlerDraggingCursor(), and toString().

◆ initialize()

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

Definition at line 187 of file baseplotcontext.cpp.

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

References m_currentDragPoint, m_dragDirections, 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

◆ recordDragDirections()

DragDirections pappso::BasePlotContext::recordDragDirections ( )

Definition at line 831 of file baseplotcontext.cpp.

832{
833 int drag_directions = static_cast<int>(DragDirections::NOT_SET);
834
836 drag_directions |= static_cast<int>(DragDirections::LEFT_TO_RIGHT);
837 else
838 drag_directions |= static_cast<int>(DragDirections::RIGHT_TO_LEFT);
839
841 drag_directions |= static_cast<int>(DragDirections::BOTTOM_TO_TOP);
842 else
843 drag_directions |= static_cast<int>(DragDirections::TOP_TO_BOTTOM);
844
845 // qDebug() << "DragDirections:" << drag_directions;
846
847 m_dragDirections = static_cast<DragDirections>(drag_directions);
848
849 return static_cast<DragDirections>(drag_directions);
850}

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.

Referenced by pappso::BasePlotWidget::mouseMoveHandlerDraggingCursor().

◆ registerJsConstructor()

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

Definition at line 974 of file baseplotcontext.cpp.

975{
976 if(!engine)
977 {
978 qWarning() << "Cannot register class: engine is null";
979 return;
980 }
981
982 // Register the meta object as a constructor
983 QJSValue jsMetaObject = engine->newQMetaObject(&BasePlotContext::staticMetaObject);
984 engine->globalObject().setProperty("BasePlotContext", jsMetaObject);
985
986 QJSValue enumObject = engine->newObject();
987 enumObject.setProperty("NOT_SET", static_cast<int>(pappso::DragDirections::NOT_SET));
988 enumObject.setProperty("LEFT_TO_RIGHT", static_cast<int>(pappso::DragDirections::LEFT_TO_RIGHT));
989 enumObject.setProperty("RIGHT_TO_LEFT", static_cast<int>(pappso::DragDirections::RIGHT_TO_LEFT));
990 enumObject.setProperty("TOP_TO_BOTTOM", static_cast<int>(pappso::DragDirections::TOP_TO_BOTTOM));
991 enumObject.setProperty("BOTTOM_TO_TOP", static_cast<int>(pappso::DragDirections::BOTTOM_TO_TOP));
992
993 // Make it available in the global JS scope
994 engine->globalObject().setProperty("DragDirections", enumObject);
995}

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 854 of file baseplotcontext.cpp.

855{
856 QString text("Context:");
857
858 text += QString(" data kind: %1").arg(static_cast<int>(m_dataKind));
859
860 text += QString(" -- isMouseDragging: %1 -- wasMouseDragging: %2")
861 .arg(m_isMouseDragging ? "true" : "false")
862 .arg(m_wasMouseDragging ? "true" : "false");
863
864 text +=
865 QString(" -- startDragPoint : (%1, %2)").arg(m_startDragPoint.x()).arg(m_startDragPoint.y());
866
867 text += QString(" -- currentDragPoint : (%1, %2)")
868 .arg(m_currentDragPoint.x())
869 .arg(m_currentDragPoint.y());
870
871 text += QString(" -- lastCursorHoveredPoint : (%1, %2)")
873 .arg(m_lastCursorHoveredPoint.y());
874
875 text += dragDirectionsToString();
876
877 // The integration scope
878 text += " -- Integration scope: ";
879 text += msp_integrationScope->toString();
880 text += " -- ";
881
882 text += QString(" -- xRange: (%1, %2)").arg(m_xRange.lower).arg(m_xRange.upper);
883
884 text += QString(" -- yRange: (%1, %2)").arg(m_yRange.lower).arg(m_yRange.upper);
885
886 text += QString(" -- wasClickOnXAxis: %1").arg(m_wasClickOnXAxis ? "true" : "false");
887 text += QString(" -- wasClickOnYAxis: %1").arg(m_wasClickOnYAxis ? "true" : "false");
888 text += QString(" -- isMeasuringDistance: %1").arg(m_isMeasuringDistance ? "true" : "false");
889
890 text += QString(" -- xRegionRangeStart: %1 -- xRegionRangeEnd: %2")
892 .arg(m_xRegionRangeEnd);
893
894 text += QString(" -- yRegionRangeStart: %1 -- yRegionRangeEnd: %2")
896 .arg(m_yRegionRangeEnd);
897
898 text += QString(" -- xDelta: %1 -- yDelta: %2").arg(m_xDelta).arg(m_yDelta);
899
900 text += QString(" -- pressedKeyCode: %1").arg(m_pressedKeyCode);
901
902 // Qt::NoModifier0x00000000No modifier key is pressed.
903 // Qt::ShiftModifier0x02000000A Shift key on the keyboard is pressed.
904 // Qt::ControlModifier0x04000000A Ctrl key on the keyboard is pressed.
905 // Qt::AltModifier0x08000000An Alt key on the keyboard is pressed.
906 // Qt::MetaModifier0x10000000A Meta key on the keyboard is pressed.
907 // Qt::KeypadModifier0x20000000A keypad button is pressed.
908 // Qt::GroupSwitchModifier0x40000000X11 only (unless activated on Windows by a command line argument).
909 // A Mode_switch key on the keyboard is pressed.
910
911 text += QString(" -- keyboardModifiers: ");
912
913 if(m_keyboardModifiers == Qt::NoModifier)
914 text += QString("%1 - ").arg(qtKeyboardModifierMap[Qt::NoModifier]);
915
916 if(static_cast<int>(m_keyboardModifiers) & Qt::ShiftModifier)
917 text += QString("%1 - ").arg(qtKeyboardModifierMap[Qt::ShiftModifier]);
918
919 if(static_cast<int>(m_keyboardModifiers) & Qt::ControlModifier)
920 text += QString("%1 - ").arg(qtKeyboardModifierMap[Qt::ControlModifier]);
921
922 if(static_cast<int>(m_keyboardModifiers) & Qt::AltModifier)
923 text += QString("%1 - ").arg(qtKeyboardModifierMap[Qt::AltModifier]);
924
925 if(static_cast<int>(m_keyboardModifiers) & Qt::MetaModifier)
926 text += QString("%1 - ").arg(qtKeyboardModifierMap[Qt::MetaModifier]);
927
928 if(static_cast<int>(m_keyboardModifiers) & Qt::KeypadModifier)
929 text += QString("%1 - ").arg(qtKeyboardModifierMap[Qt::KeypadModifier]);
930
931 if(static_cast<int>(m_keyboardModifiers) & Qt::GroupSwitchModifier)
932 text += QString("%1 - ").arg(qtKeyboardModifierMap[Qt::GroupSwitchModifier]);
933
934 text +=
935 QString(" -- lastPressedMouseButton: %1").arg(qtMouseButtonsMap[m_lastPressedMouseButton]);
936
937 text +=
938 QString(" -- lastReleasedMouseButton: %1").arg(qtMouseButtonsMap[m_lastReleasedMouseButton]);
939
940 text += QString(" -- pressedMouseButtons: %1").arg(qtMouseButtonsMap[m_pressedMouseButtons]);
941
942 text +=
943 QString(" -- mouseButtonsAtMousePress: %1").arg(qtMouseButtonsMap[m_mouseButtonsAtMousePress]);
944
945 text += QString(" -- mouseButtonsAtMouseRelease: %1")
947
948 return text;
949}
Q_INVOKABLE QString dragDirectionsToString() const
Enums::DataKind m_dataKind
std::map< Qt::MouseButtons, QString > qtMouseButtonsMap
std::map< Qt::KeyboardModifier, QString > qtKeyboardModifierMap

References dragDirectionsToString(), m_currentDragPoint, m_dataKind, 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::qtKeyboardModifierMap, and pappso::qtMouseButtonsMap.

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

◆ updateIntegrationScope()

void pappso::BasePlotContext::updateIntegrationScope ( )

Definition at line 253 of file baseplotcontext.cpp.

254{
255 // qDebug();
256
257 // By essence, IntegrationScope is 1D scope. The point of the scope is the
258 // left bottom point, and then we document the width.
259
260 double x_range_start = std::min(m_currentDragPoint.x(), m_startDragPoint.x());
261 double x_range_end = std::max(m_currentDragPoint.x(), m_startDragPoint.x());
262
263 double y_position = m_startDragPoint.y();
264
265 QPointF point(x_range_start, y_position);
266 double width = x_range_end - x_range_start;
267
268 // qDebug() << "Going to create an integration scope with point:" << point
269 // << "and width:" << width;
270 msp_integrationScope = std::make_shared<IntegrationScope>(point, width);
271 // qDebug() << "Created integration scope:" << msp_integrationScope->toString();
272}

References m_currentDragPoint, m_startDragPoint, and msp_integrationScope.

Referenced by pappso::BasePlotWidget::updateIntegrationScope().

◆ updateIntegrationScopeRect()

void pappso::BasePlotContext::updateIntegrationScopeRect ( )

Definition at line 276 of file baseplotcontext.cpp.

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

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.

Referenced by pappso::BasePlotWidget::updateIntegrationScopeRect().

◆ updateIntegrationScopeRhomb()

void pappso::BasePlotContext::updateIntegrationScopeRhomb ( )

Definition at line 678 of file baseplotcontext.cpp.

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

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

Referenced by pappso::BasePlotWidget::updateIntegrationScopeRhomb().

◆ updateIntegrationScopeRhombHorizontal()

void pappso::BasePlotContext::updateIntegrationScopeRhombHorizontal ( )

Definition at line 377 of file baseplotcontext.cpp.

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

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 526 of file baseplotcontext.cpp.

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

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

◆ m_dragDirections

◆ m_integrationScopeRhombHeight

◆ m_integrationScopeRhombWidth

◆ m_isKeyBoardDragging

bool pappso::BasePlotContext::m_isKeyBoardDragging = false

Definition at line 83 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_isLeftPseudoButtonKeyPressed

bool pappso::BasePlotContext::m_isLeftPseudoButtonKeyPressed = false

◆ m_isMeasuringDistance

◆ m_isMouseDragging

◆ m_isRightPseudoButtonKeyPressed

bool pappso::BasePlotContext::m_isRightPseudoButtonKeyPressed = false

◆ m_keyboardModifiers

◆ m_lastCursorHoveredPoint

◆ m_lastPressedMouseButton

Qt::MouseButtons pappso::BasePlotContext::m_lastPressedMouseButton

◆ m_lastReleasedMouseButton

Qt::MouseButtons pappso::BasePlotContext::m_lastReleasedMouseButton

◆ m_mouseButtonsAtMousePress

◆ m_mouseButtonsAtMouseRelease

Qt::MouseButtons pappso::BasePlotContext::m_mouseButtonsAtMouseRelease

◆ m_pressedKeyCode

◆ m_pressedMouseButtons

◆ m_releasedKeyCode

int pappso::BasePlotContext::m_releasedKeyCode

Definition at line 127 of file baseplotcontext.h.

Referenced by clone(), initialize(), and pappso::BasePlotWidget::keyReleaseEvent().

◆ m_selectionPolygon

SelectionPolygon pappso::BasePlotContext::m_selectionPolygon

Definition at line 94 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_startDragPoint

◆ m_wasClickOnXAxis

◆ m_wasClickOnYAxis

◆ m_wasKeyBoardDragging

bool pappso::BasePlotContext::m_wasKeyBoardDragging = false

Definition at line 86 of file baseplotcontext.h.

Referenced by clone(), and initialize().

◆ m_wasMouseDragging

bool pappso::BasePlotContext::m_wasMouseDragging = false

◆ m_xDelta

◆ m_xRange

◆ m_xRegionRangeEnd

◆ m_xRegionRangeStart

◆ m_yDelta

◆ m_yRange

◆ m_yRegionRangeEnd

◆ m_yRegionRangeStart

◆ msp_integrationScope

Property Documentation

◆ isKeyBoardDragging

bool pappso::BasePlotContext::isKeyBoardDragging

Definition at line 59 of file baseplotcontext.h.

◆ isLeftPseudoButtonKeyPressed

bool pappso::BasePlotContext::isLeftPseudoButtonKeyPressed

Definition at line 60 of file baseplotcontext.h.

◆ isMouseDragging

bool pappso::BasePlotContext::isMouseDragging

Definition at line 57 of file baseplotcontext.h.

◆ isRightPseudoButtonKeyPressed

bool pappso::BasePlotContext::isRightPseudoButtonKeyPressed

Definition at line 61 of file baseplotcontext.h.

◆ wasKeyBoardDragging

bool pappso::BasePlotContext::wasKeyBoardDragging

Definition at line 62 of file baseplotcontext.h.

◆ wasMouseDragging

bool pappso::BasePlotContext::wasMouseDragging

Definition at line 58 of file baseplotcontext.h.


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