libpappsomspp
Library for mass spectrometry
pappso::BasePlotContext Class Reference

#include <baseplotcontext.h>

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

Public Member Functions

 BasePlotContext ()
 
 BasePlotContext (const BasePlotContext &other)
 
virtual ~BasePlotContext ()
 
void updateIntegrationScope ()
 
void updateIntegrationScopeRect ()
 
void updateIntegrationScopeRhomb ()
 
void updateIntegrationScopeRhombHorizontal ()
 
void updateIntegrationScopeRhombVertical ()
 
BasePlotContextoperator= (const BasePlotContext &other)
 
DragDirections recordDragDirections ()
 
QString toString () const
 

Public Attributes

DataKind m_dataKind = DataKind::unset
 
bool m_isMouseDragging = false
 
bool m_wasMouseDragging = false
 
bool m_isKeyBoardDragging = false
 
bool m_isLeftPseudoButtonKeyPressed = false
 
bool m_isRightPseudoButtonKeyPressed = false
 
bool m_wassKeyBoardDragging = 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
 

Detailed Description

Definition at line 39 of file baseplotcontext.h.

Constructor & Destructor Documentation

◆ BasePlotContext() [1/2]

pappso::BasePlotContext::BasePlotContext ( )

Definition at line 30 of file baseplotcontext.cpp.

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

References msp_integrationScope.

◆ BasePlotContext() [2/2]

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

Definition at line 37 of file baseplotcontext.cpp.

38{
39 // qDebug() << "Constructing BasePlotContext by copy.";
40
41 m_dataKind = other.m_dataKind;
42
43 m_isMouseDragging = other.m_isMouseDragging;
44 m_wasMouseDragging = other.m_wasMouseDragging;
45
46 m_isKeyBoardDragging = other.m_isKeyBoardDragging;
47 m_isLeftPseudoButtonKeyPressed = other.m_isLeftPseudoButtonKeyPressed;
48 m_isRightPseudoButtonKeyPressed = other.m_isRightPseudoButtonKeyPressed;
49 m_wassKeyBoardDragging = other.m_wassKeyBoardDragging;
50
51 m_startDragPoint = other.m_startDragPoint;
52 m_currentDragPoint = other.m_currentDragPoint;
53 m_lastCursorHoveredPoint = other.m_lastCursorHoveredPoint;
54
55 m_selectionPolygon = other.m_selectionPolygon;
56 msp_integrationScope = other.msp_integrationScope;
57 m_integrationScopeRhombWidth = other.m_integrationScopeRhombWidth;
58 m_integrationScopeRhombHeight = other.m_integrationScopeRhombHeight;
59
60 // The effective range of the axes.
61 m_xRange = other.m_xRange;
62 m_yRange = other.m_yRange;
63
64 // Tell if the mouse move was started onto either axis, because that will
65 // condition if some calculations needs to be performed or not (for example,
66 // if the mouse cursor motion was started on an axis, there is no point to
67 // perform deconvolutions).
68 m_wasClickOnXAxis = other.m_wasClickOnXAxis;
69 m_wasClickOnYAxis = other.m_wasClickOnYAxis;
70
71 m_isMeasuringDistance = other.m_isMeasuringDistance;
72
73 // The user-selected region over the plot.
74 // Note that we cannot use QCPRange structures because these are normalized by
75 // QCustomPlot in such a manner that lower is actually < upper. But we need
76 // for a number of our calculations (specifically for the deconvolutions) to
77 // actually have the lower value be start drag point.x even if the drag
78 // direction was from right to left.
79 m_xRegionRangeStart = other.m_xRegionRangeStart;
80 m_xRegionRangeEnd = other.m_xRegionRangeEnd;
81
82 m_yRegionRangeStart = other.m_yRegionRangeStart;
83 m_yRegionRangeEnd = other.m_yRegionRangeEnd;
84
85 m_xDelta = other.m_xDelta;
86 m_yDelta = other.m_yDelta;
87
88 m_pressedKeyCode = other.m_pressedKeyCode;
89 m_releasedKeyCode = other.m_releasedKeyCode;
90
91 m_keyboardModifiers = other.m_keyboardModifiers;
92
93 m_lastPressedMouseButton = other.m_lastPressedMouseButton;
94 m_lastReleasedMouseButton = other.m_lastReleasedMouseButton;
95
96 m_pressedMouseButtons = other.m_pressedMouseButtons;
97
98 m_mouseButtonsAtMousePress = other.m_mouseButtonsAtMousePress;
99 m_mouseButtonsAtMouseRelease = other.m_mouseButtonsAtMouseRelease;
100}
Qt::MouseButtons m_mouseButtonsAtMousePress
SelectionPolygon m_selectionPolygon
Qt::KeyboardModifiers m_keyboardModifiers
Qt::MouseButtons m_lastPressedMouseButton
Qt::MouseButtons m_pressedMouseButtons
Qt::MouseButtons m_mouseButtonsAtMouseRelease
Qt::MouseButtons m_lastReleasedMouseButton

References m_currentDragPoint, m_dataKind, 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_wasMouseDragging, m_wassKeyBoardDragging, m_xDelta, m_xRange, m_xRegionRangeEnd, m_xRegionRangeStart, m_yDelta, m_yRange, m_yRegionRangeEnd, m_yRegionRangeStart, and msp_integrationScope.

◆ ~BasePlotContext()

pappso::BasePlotContext::~BasePlotContext ( )
virtual

Definition at line 102 of file baseplotcontext.cpp.

103{
104}

Member Function Documentation

◆ operator=()

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

Definition at line 615 of file baseplotcontext.cpp.

616{
617 if(this == &other)
618 return *this;
619
620 m_dataKind = other.m_dataKind;
621
622 m_isMouseDragging = other.m_isMouseDragging;
623 m_wasMouseDragging = other.m_wasMouseDragging;
624
625 m_isKeyBoardDragging = other.m_isKeyBoardDragging;
626 m_isLeftPseudoButtonKeyPressed = other.m_isLeftPseudoButtonKeyPressed;
627 m_isRightPseudoButtonKeyPressed = other.m_isRightPseudoButtonKeyPressed;
628 m_wassKeyBoardDragging = other.m_wassKeyBoardDragging;
629
630 m_startDragPoint = other.m_startDragPoint;
631 m_currentDragPoint = other.m_currentDragPoint;
632 m_lastCursorHoveredPoint = other.m_lastCursorHoveredPoint;
633
634 m_selectionPolygon = other.m_selectionPolygon;
635 msp_integrationScope = other.msp_integrationScope;
636 m_integrationScopeRhombWidth = other.m_integrationScopeRhombWidth;
637 m_integrationScopeRhombHeight = other.m_integrationScopeRhombHeight;
638
639 // The effective range of the axes.
640 m_xRange = other.m_xRange;
641 m_yRange = other.m_yRange;
642
643 // Tell if the mouse move was started onto either axis, because that will
644 // condition if some calculations needs to be performed or not (for example,
645 // if the mouse cursor motion was started on an axis, there is no point to
646 // perform deconvolutions).
647 m_wasClickOnXAxis = other.m_wasClickOnXAxis;
648 m_wasClickOnYAxis = other.m_wasClickOnYAxis;
649
650 m_isMeasuringDistance = other.m_isMeasuringDistance;
651
652 // The user-selected region over the plot.
653 // Note that we cannot use QCPRange structures because these are normalized by
654 // QCustomPlot in such a manner that lower is actually < upper. But we need
655 // for a number of our calculations (specifically for the deconvolutions) to
656 // actually have the lower value be start drag point.x even if the drag
657 // direction was from right to left.
658 m_xRegionRangeStart = other.m_xRegionRangeStart;
659 m_xRegionRangeEnd = other.m_xRegionRangeEnd;
660
661 m_yRegionRangeStart = other.m_yRegionRangeStart;
662 m_yRegionRangeEnd = other.m_yRegionRangeEnd;
663
664 m_xDelta = other.m_xDelta;
665 m_yDelta = other.m_yDelta;
666
667 m_pressedKeyCode = other.m_pressedKeyCode;
668 m_releasedKeyCode = other.m_releasedKeyCode;
669
670 m_keyboardModifiers = other.m_keyboardModifiers;
671
672 m_lastPressedMouseButton = other.m_lastPressedMouseButton;
673 m_lastReleasedMouseButton = other.m_lastReleasedMouseButton;
674
675 m_pressedMouseButtons = other.m_pressedMouseButtons;
676
677 m_mouseButtonsAtMousePress = other.m_mouseButtonsAtMousePress;
678 m_mouseButtonsAtMouseRelease = other.m_mouseButtonsAtMouseRelease;
679
680 return *this;
681}

References m_currentDragPoint, m_dataKind, 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_wasMouseDragging, m_wassKeyBoardDragging, m_xDelta, m_xRange, m_xRegionRangeEnd, m_xRegionRangeStart, m_yDelta, m_yRange, m_yRegionRangeEnd, m_yRegionRangeStart, and msp_integrationScope.

Referenced by pappso::MassSpecTracePlotContext::operator=().

◆ recordDragDirections()

DragDirections pappso::BasePlotContext::recordDragDirections ( )

Definition at line 684 of file baseplotcontext.cpp.

685{
686 int drag_directions = static_cast<int>(DragDirections::NOT_SET);
687
689 drag_directions |= static_cast<int>(DragDirections::LEFT_TO_RIGHT);
690 else
691 drag_directions |= static_cast<int>(DragDirections::RIGHT_TO_LEFT);
692
694 drag_directions |= static_cast<int>(DragDirections::BOTTOM_TO_TOP);
695 else
696 drag_directions |= static_cast<int>(DragDirections::TOP_TO_BOTTOM);
697
698 // qDebug() << "DragDirections:" << drag_directions;
699
700 m_dragDirections = static_cast<DragDirections>(drag_directions);
701
702 return static_cast<DragDirections>(drag_directions);
703}
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.

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

◆ toString()

QString pappso::BasePlotContext::toString ( ) const

Definition at line 707 of file baseplotcontext.cpp.

708{
709 QString text("Context:");
710
711 text += QString("data kind: %1").arg(static_cast<int>(m_dataKind));
712
713 text += QString(" isMouseDragging: %1 -- wasMouseDragging: %2")
714 .arg(m_isMouseDragging ? "true" : "false")
715 .arg(m_wasMouseDragging ? "true" : "false");
716
717 text +=
718 QString(" -- startDragPoint : (%1, %2)").arg(m_startDragPoint.x()).arg(m_startDragPoint.y());
719
720 text += QString(" -- currentDragPoint : (%1, %2)")
721 .arg(m_currentDragPoint.x())
722 .arg(m_currentDragPoint.y());
723
724 text += QString(" -- lastCursorHoveredPoint : (%1, %2)")
726 .arg(m_lastCursorHoveredPoint.y());
727
728 // Document how the mouse cursor is being dragged.
730 {
731 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT))
732 text += " -- dragging from left to right";
733 else if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
734 text += " -- dragging from right to left";
735 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
736 text += " -- dragging from top to bottom";
737 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
738 text += " -- dragging from bottom to top";
739 }
740
741 // The integration scope
742 text += " -- ";
743 text += msp_integrationScope->toString();
744
745 text += QString(" -- xRange: (%1, %2)").arg(m_xRange.lower).arg(m_xRange.upper);
746
747 text += QString(" -- yRange: (%1, %2)").arg(m_yRange.lower).arg(m_yRange.upper);
748
749 text += QString(" -- wasClickOnXAxis: %1").arg(m_wasClickOnXAxis ? "true" : "false");
750 text += QString(" -- wasClickOnYAxis: %1").arg(m_wasClickOnYAxis ? "true" : "false");
751 text += QString(" -- isMeasuringDistance: %1").arg(m_isMeasuringDistance ? "true" : "false");
752
753 text += QString(" -- xRegionRangeStart: %1 -- xRegionRangeEnd: %2")
755 .arg(m_xRegionRangeEnd);
756
757 text += QString(" -- yRegionRangeStart: %1 -- yRegionRangeEnd: %2")
759 .arg(m_yRegionRangeEnd);
760
761 text += QString(" -- xDelta: %1 -- yDelta: %2").arg(m_xDelta).arg(m_yDelta);
762
763 text += QString(" -- pressedKeyCode: %1").arg(m_pressedKeyCode);
764
765 text += QString(" -- keyboardModifiers: %1").arg(m_keyboardModifiers);
766
767 text += QString(" -- lastPressedMouseButton: %1").arg(qtMouseButtonsMap[m_lastPressedMouseButton]);
768
769 text += QString(" -- lastReleasedMouseButton: %1").arg(qtMouseButtonsMap[m_lastReleasedMouseButton]);
770
771 text += QString(" -- pressedMouseButtons: %1").arg(qtMouseButtonsMap[m_pressedMouseButtons]);
772
773 text += QString(" -- mouseButtonsAtMousePress: %1").arg(qtMouseButtonsMap[m_mouseButtonsAtMousePress]);
774
775 text += QString(" -- mouseButtonsAtMouseRelease: %1").arg(qtMouseButtonsMap[m_mouseButtonsAtMouseRelease]);
776
777 return text;
778}
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 107 of file baseplotcontext.cpp.

108{
109 // qDebug();
110
111 // By essence, IntegrationScope is 1D scope. The point of the scope is the
112 // left bottom point, and then we document the width.
113
114 double x_range_start = std::min(m_currentDragPoint.x(), m_startDragPoint.x());
115 double x_range_end = std::max(m_currentDragPoint.x(), m_startDragPoint.x());
116
117 double y_position = m_startDragPoint.y();
118
119 QPointF point(x_range_start, y_position);
120 double width = x_range_end - x_range_start;
121
122 // qDebug() << "Going to create an integration scope with point:"
123 // << point << "and width:" << width;
124 msp_integrationScope = std::make_shared<IntegrationScope>(point, width);
125}

References m_currentDragPoint, m_startDragPoint, and msp_integrationScope.

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

◆ updateIntegrationScopeRect()

void pappso::BasePlotContext::updateIntegrationScopeRect ( )

Definition at line 129 of file baseplotcontext.cpp.

130{
131 // qDebug();
132
133 // By essence, IntegrationScopeRect is a squared rectangle scope. The point of
134 // the scope is the left bottom point, and then we document the width and the
135 // height.
136
137 /* Like this:
138 *
139 +---------------------------+ -
140 | | |
141 | | |
142 | | m_height
143 | | |
144 | | |
145 P---------------------------+ -
146
147 |--------- m_width ---------|
148
149 */
150
151 // We need to find the point that is actually the left bottom point.
152
153 QPointF point;
154 double width = 0;
155 double height = 0;
156
157 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
158 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
159 {
160 point.rx() = m_startDragPoint.x();
161 point.ry() = m_startDragPoint.y();
162 width = m_currentDragPoint.x() - point.rx();
163 height = m_currentDragPoint.y() - point.ry();
164 // qDebug() << "left to right - bottom to top";
165 }
166
167 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
168 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
169 {
170 point.rx() = m_currentDragPoint.x();
171 point.ry() = m_currentDragPoint.y();
172 width = m_startDragPoint.x() - m_currentDragPoint.x();
173 height = m_startDragPoint.y() - m_currentDragPoint.y();
174 // qDebug() << "right to left - bottom to top";
175 }
176
177 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
178 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
179 {
180 point.rx() = m_startDragPoint.x();
181 point.ry() = m_currentDragPoint.y();
182 width = m_currentDragPoint.x() - m_startDragPoint.x();
183 height = m_startDragPoint.y() - m_currentDragPoint.y();
184 // qDebug() << "left to right - top to bottom";
185 }
186
187 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
188 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
189 {
190 point.rx() = m_currentDragPoint.x();
191 point.ry() = m_currentDragPoint.y();
192 width = m_startDragPoint.x() - m_currentDragPoint.x();
193 height = m_startDragPoint.y() - m_currentDragPoint.y();
194 // qDebug() << "right to left - top to bottom";
195 }
196
197 // qDebug() << "The data used to update the integration scope:";
198 // qDebug() << "Point:" << point << "width:" << width << "height:" << height;
199 //
200 // qDebug() << "The integration scope before update:" << mpa_integrationScope;
201 //
202 // qDebug() << "Will update IntegrationScopeRect with:" << point << "width"
203 // << width << "height" << height;
204 msp_integrationScope = std::make_shared<IntegrationScopeRect>(point, width, height);
205
206
207 // if(typeid(*mpa_integrationScope) == typeid(IntegrationScopeInterface))
208 // qDebug() << "The pointer is of type IntegrationScopeInterface";
209 // if(typeid(*mpa_integrationScope) == typeid(IntegrationScope))
210 // qDebug() << "The pointer is of type IntegrationScope";
211 // if(typeid(*mpa_integrationScope) == typeid(IntegrationScopeRect))
212 // qDebug() << "The pointer is of type IntegrationScopeRect";
213 // if(typeid(*mpa_integrationScope) == typeid(IntegrationScopeRhomb))
214 // qDebug() << "The pointer is of type IntegrationScopeRhomb";
215 //
216 // qDebug() << "The integration scope right after update:"
217 // << mpa_integrationScope;
218 //
219 // if(!mpa_integrationScope->getPoint(point))
220 // qFatal("Could not get point.");
221 // qDebug() << "The point:" << point;
222 // if(!mpa_integrationScope->getWidth(width))
223 // qFatal("Oh no!!!! width");
224 // if(!mpa_integrationScope->getWidth(height))
225 // qFatal("Oh no!!!! height");
226}

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

532{
533 // qDebug() << toString();
534
535 // By essence, IntegrationScopeRhomb is a rhomboid polygon. Just set the
536 // points. There are two kinds of rhomboid integration scopes: horizontal and
537 // vertical.
538
539 /*
540 +----------+
541 | |
542 | |
543 | |
544 | |
545 | |
546 | |
547 | |
548 +----------+
549 ----width---
550 */
551
552 // As visible here, the fixed size of the rhomboid (using the S key in the
553 // plot widget) is the *horizontal* side (that is, the rhomboid has a non-0
554 // width)..
555
556 // However, it might be useful to be able to draw rhomboid integration scopes
557 // like this, that would correspond to the rhomboid above after a transpose
558 // operation.
559
560 /*
561 +
562 . |
563 . |
564 . |
565 . +
566 . .
567 . .
568 . .
569 + .
570 | | .
571 height | | .
572 | | .
573 +
574
575*/
576
577 // As visible here, the fixed size of the rhomboid (using the S key in the
578 // plot widget) is the vertical side (that is, the rhomboid has a non-0
579 // height).
580
581 // The general rule is thus that when the m_integrationScopeRhombWidth is
582 // not-0, then the first shape is considered, while when the
583 // m_integrationScopeRhombHeight is non-0, then the second shape is
584 // considered.
585
586 // This function is called when the user has dragged the cursor (left or right
587 // button, not for or for integration, respectively) with the 'Alt' modifier
588 // key pressed, so that they want to perform a rhomboid integration scope
589 // calculation.
590
591 // Of course, the integration scope in the context might not be a rhomboid
592 // scope, because we might enter this function as a very firt switch from
593 // scope or scopeRect to scopeRhomb. The only indication we have to direct the
594 // creation of a horizontal or vertical rhomboid is the
595 // m_integrationScopeRhombWidth/m_integrationScopeRhombHeight recorded in the
596 // plot widget that owns this plot context.
597
598 // qDebug() << "In updateIntegrationScopeRhomb, m_integrationScopeRhombWidth:"
599 // << m_integrationScopeRhombWidth
600 // << "and m_integrationScopeRhombHeight:"
601 // << m_integrationScopeRhombHeight;
602
604 qFatal(
605 "Both m_integrationScopeRhombWidth and m_integrationScopeRhombHeight of "
606 "rhomboid integration scope cannot be 0.");
607
612}

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

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

◆ updateIntegrationScopeRhombHorizontal()

void pappso::BasePlotContext::updateIntegrationScopeRhombHorizontal ( )

Definition at line 230 of file baseplotcontext.cpp.

231{
232 // qDebug() << toString();
233
234 /*
235 4+----------+3
236 | |
237 | |
238 | |
239 | |
240 | |
241 | |
242 | |
243 1+----------+2
244 ----width---
245 */
246
247 // As visible here, the fixed size of the rhomboid (using the S key in the
248 // plot widget) is the horizontal side.
249
250 // The points are numbered in a counterclockwise manner, starting from the
251 // starting drag point. The width side is right of the start drag point if
252 // the user drags from left to right and left of the start drag point if
253 // the user drags from left to right. In the figure above, the user
254 // has dragged the mouse from point 1 and to the right and upwards.
255 // Thus the width side is right of point 1. Because the numbering
256 // is counterclockwise, that point happens to be numbered 2.
257
258 // If the user had draggged the mouse starting at point 3 and to the left
259 // and to the bottom, then point 3 above would be point 1, point 4
260 // would be point 2 because the width side is left of the start
261 // drag point; point 1 would be point 3 and finally the last point
262 // would be at point 2.
263
264 // Sanity check
266 qFatal(
267 "The m_integrationScopeRhombWidth of the fixed rhomboid side cannot be "
268 "0.");
269
270 QPointF point;
271 std::vector<QPointF> points;
272
273 // Fill-in the points in the vector in the order they are created
274 // while drawing the rhomboid shape. Thus, the first point (start of the
275 // mouse click & drag operation is always the same.
276
277 point.rx() = m_startDragPoint.x();
278 point.ry() = m_startDragPoint.y();
279 points.push_back(point);
280 // qDebug() << "Start point:" << point;
281
282 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
283 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
284 {
285 // Second point.
287 point.ry() = m_startDragPoint.y();
288 points.push_back(point);
289 // qDebug() << "Second point:" << point;
290
291 // Third point.
293 point.ry() = m_currentDragPoint.ry();
294 points.push_back(point);
295 // qDebug() << "Third point:" << point;
296
297 // Fourth point.
298 point.rx() = m_currentDragPoint.rx();
299 point.ry() = m_currentDragPoint.ry();
300 points.push_back(point);
301 // qDebug() << "Last point:" << point;
302 }
303
304 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
305 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
306 {
307 // Second point.
308 point.rx() = m_currentDragPoint.rx();
309 point.ry() = m_currentDragPoint.ry();
310 points.push_back(point);
311 // qDebug() << "Second point:" << point;
312
313 // Third point.
315 point.ry() = m_currentDragPoint.ry();
316 points.push_back(point);
317 // qDebug() << "Third point:" << point;
318
319 // Fourth point.
321 point.ry() = m_startDragPoint.ry();
322 points.push_back(point);
323 // qDebug() << "Last point:" << point;
324 }
325
326 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::LEFT_TO_RIGHT) &&
327 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
328 {
329 // Second point.
330 point.rx() = m_currentDragPoint.rx();
331 point.ry() = m_currentDragPoint.ry();
332 points.push_back(point);
333 // qDebug() << "Second point:" << point;
334
335 // Third point.
337 point.ry() = m_currentDragPoint.ry();
338 points.push_back(point);
339 // qDebug() << "Third point:" << point;
340
341 // Fourth point.
343 point.ry() = m_startDragPoint.y();
344 points.push_back(point);
345 // qDebug() << "Last point:" << point;
346 }
347
348 if(static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT) &&
349 static_cast<int>(m_dragDirections) & static_cast<int>(DragDirections::TOP_TO_BOTTOM))
350 {
351 // Second point.
353 point.ry() = m_startDragPoint.y();
354 points.push_back(point);
355 // qDebug() << "Second point:" << point;
356
357 // Third point.
359 point.ry() = m_currentDragPoint.ry();
360 points.push_back(point);
361 // qDebug() << "Third point:" << point;
362
363 // Fourth point.
364 point.rx() = m_currentDragPoint.rx();
365 point.ry() = m_currentDragPoint.ry();
366 points.push_back(point);
367 // qDebug() << "Last point:" << point;
368 }
369
370
371 msp_integrationScope = std::make_shared<IntegrationScopeRhomb>(points);
372
373 // qDebug() << "Created an integration scope horizontal rhomboid with"
374 // << points.size() << "points:" << msp_integrationScope->toString();
375}

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

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

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 51 of file baseplotcontext.h.

Referenced by BasePlotContext(), and operator=().

◆ 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

◆ m_selectionPolygon

SelectionPolygon pappso::BasePlotContext::m_selectionPolygon

Definition at line 62 of file baseplotcontext.h.

Referenced by BasePlotContext(), and operator=().

◆ m_startDragPoint

◆ m_wasClickOnXAxis

◆ m_wasClickOnYAxis

◆ m_wasMouseDragging

bool pappso::BasePlotContext::m_wasMouseDragging = false

◆ m_wassKeyBoardDragging

bool pappso::BasePlotContext::m_wassKeyBoardDragging = false

Definition at line 54 of file baseplotcontext.h.

Referenced by BasePlotContext(), and operator=().

◆ m_xDelta

◆ m_xRange

◆ m_xRegionRangeEnd

◆ m_xRegionRangeStart

◆ m_yDelta

◆ m_yRange

◆ m_yRegionRangeEnd

◆ m_yRegionRangeStart

◆ msp_integrationScope


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