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

#include <baseplotwidget.h>

Inheritance diagram for pappso::BasePlotWidget:
pappso::BaseColorMapPlotWidget pappso::BaseTracePlotWidget pappso::DriftSpecMassSpecColorMapPlotWidget pappso::TicXicChromDriftSpecColorMapPlotWidget pappso::TicXicChromMassSpecColorMapPlotWidget pappso::DriftSpecTracePlotWidget pappso::MassSpecTracePlotWidget pappso::TicXicChromTracePlotWidget

Signals

void setFocusSignal ()
 
void lastCursorHoveredPointSignal (const QPointF &pointf)
 
void plotRangesChangedSignal (const BasePlotContext &context)
 
void xAxisMeasurementSignal (const BasePlotContext &context, bool with_delta)
 
void keyPressEventSignal (const BasePlotContext &context)
 
void keyReleaseEventSignal (const BasePlotContext &context)
 
void mousePressEventSignal (const BasePlotContext &context)
 
void mouseReleaseEventSignal (const BasePlotContext &context)
 
void mouseWheelEventSignal (const BasePlotContext &context)
 
void plottableSelectionChangedSignal (QCPAbstractPlottable *plottable_p, bool selected)
 
void integrationRequestedSignal (const BasePlotContext &context)
 
void plottableDestructionRequestedSignal (BasePlotWidget *base_plot_widget_p, QCPAbstractPlottable *plottable_p, const BasePlotContext &context)
 

Public Member Functions

 BasePlotWidget (QWidget *parent)
 
 BasePlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
 
virtual ~BasePlotWidget ()
 Destruct this BasePlotWidget instance.
 
virtual bool setupWidget ()
 
virtual void setPen (const QPen &pen)
 
virtual const QPen & getPen () const
 
virtual void setPlottingColor (QCPAbstractPlottable *plottable_p, const QColor &new_color)
 
virtual void setPlottingColor (int index, const QColor &new_color)
 
virtual QColor getPlottingColor (QCPAbstractPlottable *plottable_p) const
 
virtual QColor getPlottingColor (int index=0) const
 
virtual void setAxisLabelX (const QString &label)
 
virtual void setAxisLabelY (const QString &label)
 
virtual void resetAxesRangeHistory ()
 
virtual void updateAxesRangeHistory ()
 Create new axis range history items and append them to the history.
 
virtual void restorePreviousAxesRangeHistory ()
 Go up one history element in the axis history.
 
virtual void restoreAxesRangeHistory (std::size_t index)
 Get the axis histories at index index and update the plot ranges.
 
virtual void keyPressEvent (QKeyEvent *event)
 KEYBOARD-related EVENTS.
 
virtual void keyReleaseEvent (QKeyEvent *event)
 Handle specific key codes and trigger respective actions.
 
virtual void spaceKeyReleaseEvent (QKeyEvent *event)
 
virtual void directionKeyPressEvent (QKeyEvent *event)
 
virtual void directionKeyReleaseEvent (QKeyEvent *event)
 
virtual void mousePseudoButtonKeyPressEvent (QKeyEvent *event)
 
virtual void mousePseudoButtonKeyReleaseEvent (QKeyEvent *event)
 
virtual void mousePressHandler (QMouseEvent *event)
 KEYBOARD-related EVENTS.
 
virtual void mouseReleaseHandler (QMouseEvent *event)
 
virtual void mouseReleaseHandlerLeftButton ()
 
virtual void mouseReleaseHandlerRightButton ()
 
virtual void mouseWheelHandler (QWheelEvent *event)
 
virtual void mouseMoveHandler (QMouseEvent *event)
 KEYBOARD-related EVENTS.
 
virtual void mouseMoveHandlerNotDraggingCursor ()
 
virtual void mouseMoveHandlerDraggingCursor ()
 
virtual void mouseMoveHandlerLeftButtonDraggingCursor ()
 
virtual void mouseMoveHandlerRightButtonDraggingCursor ()
 
virtual void axisDoubleClickHandler (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
 
bool isClickOntoXAxis (const QPointF &mousePoint)
 
bool isClickOntoYAxis (const QPointF &mousePoint)
 
int dragDirection ()
 MOUSE-related EVENTS.
 
virtual void moveMouseCursorGraphCoordToGlobal (QPointF plot_coordinates)
 
virtual void moveMouseCursorPixelCoordToGlobal (QPointF local_coordinates)
 
virtual void horizontalMoveMouseCursorCountPixels (int pixel_count)
 
virtual QPointF horizontalGetGraphCoordNewPointCountPixels (int pixel_count)
 
virtual void verticalMoveMouseCursorCountPixels (int pixel_count)
 
virtual QPointF verticalGetGraphCoordNewPointCountPixels (int pixel_count)
 
virtual QCPRange getRangeX (bool &found_range, int index) const
 MOUSE MOVEMENTS mouse/keyboard-triggered.
 
virtual QCPRange getRangeY (bool &found_range, int index) const
 
QCPRange getRange (Enums::Axis axis, RangeType range_type, bool &found_range) const
 
virtual QCPRange getInnermostRangeX (bool &found_range) const
 
virtual QCPRange getOutermostRangeX (bool &found_range) const
 
virtual QCPRange getInnermostRangeY (bool &found_range) const
 
virtual QCPRange getOutermostRangeY (bool &found_range) const
 
void yMinMaxOnXAxisCurrentRange (double &min, double &max, QCPAbstractPlottable *plottable_p=nullptr)
 
void yMinMaxOnXAxisCurrentRange (double &min, double &max, int index)
 
virtual void axisRescale ()
 RANGE-related functions.
 
virtual void axisReframe ()
 
virtual void axisZoom ()
 
virtual void axisPan ()
 
virtual void replotWithAxesRanges (QCPRange xAxisRange, QCPRange yAxisRange, Enums::Axis axis)
 
virtual void replotWithAxisRangeX (double lower, double upper)
 
virtual void replotWithAxisRangeY (double lower, double upper)
 
virtual void hideAllPlotItems ()
 PLOTTING / REPLOTTING functions.
 
virtual void showTracers ()
 Show the traces (vertical and horizontal).
 
virtual void hideTracers ()
 Hide the traces (vertical and horizontal).
 
virtual void drawXScopeSpanFeatures ()
 
virtual void drawYScopeSpanFeatures ()
 
virtual void calculateDragDeltas ()
 
virtual bool isVerticalDisplacementAboveThreshold ()
 
virtual void drawSelectionRectangleAndPrepareZoom (bool as_line_segment=false, bool for_integration=false)
 
virtual void updateIntegrationScopeDrawing (bool as_line_segment=false, bool for_integration=false)
 
virtual void resetSelectionRectangle ()
 
virtual void hideSelectionRectangle (bool reset_values=false)
 
virtual bool isSelectionRectangleVisible ()
 
virtual SelectionDrawingLines whatIsVisibleOfTheSelectionRectangle ()
 
virtual void setFocus ()
 PLOT ITEMS : TRACER TEXT ITEMS...
 
virtual void redrawPlotBackground (QWidget *focusedPlotWidget)
 Redraw the background of the focusedPlotWidget plot widget.
 
virtual void updateContextXandYAxisRanges ()
 
virtual const BasePlotContextgetContext () const
 

Protected Member Functions

virtual void createAllAncillaryItems ()
 
virtual void updateIntegrationScope (bool for_integration=false)
 
virtual void updateIntegrationScopeRect (bool for_integration=false)
 
virtual void updateIntegrationScopeHorizontalRhomb (bool for_integration=false)
 
virtual void updateIntegrationScopeVerticalRhomb (bool for_integration=false)
 
virtual void updateIntegrationScopeRhomb (bool for_integration=false)
 
virtual QString allLayerNamesToString () const
 
virtual QString layerableLayerName (QCPLayerable *layerable_p) const
 
virtual int layerableLayerIndex (QCPLayerable *layerable_p) const
 

Protected Attributes

QString m_name = "NOT_SET"
 Name of the plot widget.
 
QString m_desc = "NOT_SET"
 Description of the plot widget.
 
QString m_fileName
 The name of the data file from which the mass data were read.
 
QString m_axisLabelX
 
QString m_axisLabelY
 
BasePlotContext m_context
 
int m_leftMousePseudoButtonKey = Qt::Key_Less
 
int m_rightMousePseudoButtonKey = Qt::Key_Greater
 
QCPItemLine * mp_selectionRectangeLine1 = nullptr
 Rectangle defining the borders of zoomed-in/out data.
 
QCPItemLine * mp_selectionRectangeLine2 = nullptr
 
QCPItemLine * mp_selectionRectangeLine3 = nullptr
 
QCPItemLine * mp_selectionRectangeLine4 = nullptr
 
QCPItemText * mp_xDeltaTextItem = nullptr
 Text describing the x-axis delta value during a drag operation.
 
QCPItemText * mp_yDeltaTextItem = nullptr
 
bool m_shouldTracersBeVisible = true
 Tells if the tracers should be visible.
 
QCPItemLine * mp_hPosTracerItem = nullptr
 Horizontal position tracer.
 
QCPItemLine * mp_vPosTracerItem = nullptr
 Vertical position tracer.
 
QCPItemLine * mp_vStartTracerItem = nullptr
 Vertical selection start tracer (typically in green).
 
QCPItemLine * mp_vEndTracerItem = nullptr
 Vertical selection end tracer (typically in red).
 
std::size_t m_lastAxisRangeHistoryIndex = 0
 Index of the last axis range history item.
 
std::vector< QCPRange * > m_xAxisRangeHistory
 List of x axis ranges occurring during the panning zooming actions.
 
std::vector< QCPRange * > m_yAxisRangeHistory
 List of y axis ranges occurring during the panning zooming actions.
 
int m_mouseMoveHandlerSkipAmount = 10
 How many mouse move events must be skipped *‍/.
 
int m_mouseMoveHandlerSkipCount = 0
 Counter to handle the "fat data" mouse move event handling.
 
QColor m_unfocusedColor = QColor("lightgray")
 Color used for the background of unfocused plot.
 
QBrush m_unfocusedBrush = QBrush(m_unfocusedColor)
 Color used for the background of unfocused plot.
 
QColor m_focusedColor = QColor(Qt::transparent)
 Color used for the background of focused plot.
 
QBrush m_focusedBrush = QBrush(m_focusedColor)
 Color used for the background of focused plot.
 
QPen m_pen
 Pen used to draw the graph and textual elements in the plot widget.
 

Detailed Description

Definition at line 83 of file baseplotwidget.h.

Constructor & Destructor Documentation

◆ BasePlotWidget() [1/2]

pappso::BasePlotWidget::BasePlotWidget ( QWidget *  parent)
explicit

Definition at line 50 of file baseplotwidget.cpp.

50 : QCustomPlot(parent)
51{
52 if(parent == nullptr)
53 qFatal("Programming error.");
54
55 // Default settings for the pen used to graph the data.
56 m_pen.setStyle(Qt::SolidLine);
57 m_pen.setBrush(Qt::black);
58 m_pen.setWidth(1);
59
60 // qDebug() << "Created new BasePlotWidget with" << layerCount()
61 //<< "layers before setting up widget.";
62 // qDebug().noquote() << "All layer names:\n" << allLayerNamesToString();
63
64 // As of today 20210313, the QCustomPlot is created with the following 6
65 // layers:
66 //
67 // All layers' name:
68 //
69 // Layer index 0 name: background
70 // Layer index 1 name: grid
71 // Layer index 2 name: main
72 // Layer index 3 name: axes
73 // Layer index 4 name: legend
74 // Layer index 5 name: overlay
75
76 if(!setupWidget())
77 qFatal("Programming error.");
78
79 // Do not call createAllAncillaryItems() in this base class because all the
80 // items will have been created *before* the addition of plots and then the
81 // rendering order will hide them to the viewer, since the rendering order is
82 // according to the order in which the items have been created.
83 //
84 // The fact that the ancillary items are created before trace plots is not a
85 // problem because the trace plots are sparse and do not effectively hide the
86 // data.
87 //
88 // But, in the color map plot widgets, we cannot afford to create the
89 // ancillary items *before* the plot itself because then, the rendering of the
90 // plot (created after) would screen off the ancillary items (created before).
91 //
92 // So, the createAllAncillaryItems() function needs to be called in the
93 // derived classes at the most appropriate moment in the setting up of the
94 // widget.
95 //
96 // All this is only a workaround of a bug in QCustomPlot. See
97 // https://www.qcustomplot.com/index.php/support/forum/2283.
98 //
99 // I initially wanted to have a plots layer on top of the default background
100 // layer and a items layer on top of it. But that setting prevented the
101 // selection of graphs.
102
103 // qDebug() << "Created new BasePlotWidget with" << layerCount()
104 //<< "layers after setting up widget.";
105 // qDebug().noquote() << "All layer names:\n" << allLayerNamesToString();
106
107 show();
108}
QPen m_pen
Pen used to draw the graph and textual elements in the plot widget.

References m_pen, and setupWidget().

◆ BasePlotWidget() [2/2]

pappso::BasePlotWidget::BasePlotWidget ( QWidget *  parent,
const QString &  x_axis_label,
const QString &  y_axis_label 
)
explicit

Definition at line 111 of file baseplotwidget.cpp.

114 : QCustomPlot(parent), m_axisLabelX(x_axis_label), m_axisLabelY(y_axis_label)
115{
116 // qDebug();
117
118 if(parent == nullptr)
119 qFatal("Programming error.");
120
121 // Default settings for the pen used to graph the data.
122 m_pen.setStyle(Qt::SolidLine);
123 m_pen.setBrush(Qt::black);
124 m_pen.setWidth(1);
125
126 xAxis->setLabel(x_axis_label);
127 yAxis->setLabel(y_axis_label);
128
129 // qDebug() << "Created new BasePlotWidget with" << layerCount()
130 //<< "layers before setting up widget.";
131 // qDebug().noquote() << "All layer names:\n" << allLayerNamesToString();
132
133 // As of today 20210313, the QCustomPlot is created with the following 6
134 // layers:
135 //
136 // All layers' name:
137 //
138 // Layer index 0 name: background
139 // Layer index 1 name: grid
140 // Layer index 2 name: main
141 // Layer index 3 name: axes
142 // Layer index 4 name: legend
143 // Layer index 5 name: overlay
144
145 if(!setupWidget())
146 qFatal("Programming error.");
147
148 // qDebug() << "Created new BasePlotWidget with" << layerCount()
149 //<< "layers after setting up widget.";
150 // qDebug().noquote() << "All layer names:\n" << allLayerNamesToString();
151
152 show();
153}

References m_pen, and setupWidget().

◆ ~BasePlotWidget()

pappso::BasePlotWidget::~BasePlotWidget ( )
virtual

Destruct this BasePlotWidget instance.

The destruction involves clearing the history, deleting all the axis range history items for x and y axes.

Definition at line 163 of file baseplotwidget.cpp.

164{
165 // qDebug() << "In the destructor of plot widget:" << this;
166
167 m_xAxisRangeHistory.clear();
168 m_yAxisRangeHistory.clear();
169
170 // Note that the QCustomPlot xxxItem objects are allocated with (this) which
171 // means their destruction is automatically handled upon *this' destruction.
172}
std::vector< QCPRange * > m_yAxisRangeHistory
List of y axis ranges occurring during the panning zooming actions.
std::vector< QCPRange * > m_xAxisRangeHistory
List of x axis ranges occurring during the panning zooming actions.

References m_xAxisRangeHistory, and m_yAxisRangeHistory.

Member Function Documentation

◆ allLayerNamesToString()

QString pappso::BasePlotWidget::allLayerNamesToString ( ) const
protectedvirtual

Definition at line 176 of file baseplotwidget.cpp.

177{
178
179 QString text;
180
181 for(int iter = 0; iter < layerCount(); ++iter)
182 {
183 text += QString("Layer index %1: %2\n").arg(iter).arg(layer(iter)->name());
184 }
185
186 return text;
187}

◆ axisDoubleClickHandler()

void pappso::BasePlotWidget::axisDoubleClickHandler ( QCPAxis *  axis,
QCPAxis::SelectablePart  part,
QMouseEvent *  event 
)
virtual

Reimplemented in pappso::BaseTracePlotWidget.

Definition at line 1661 of file baseplotwidget.cpp.

1664{
1665 // qDebug();
1666
1667 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1668
1669 if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1670 {
1671 // qDebug();
1672
1673 // If the Ctrl modifiers is active, then both axes are to be reset. Also
1674 // the histories are reset also.
1675
1676 rescaleAxes();
1678 }
1679 else
1680 {
1681 // qDebug();
1682
1683 // Only the axis passed as parameter is to be rescaled.
1684 // Reset the range of that axis to the max view possible.
1685
1686 axis->rescale();
1687
1689
1690 event->accept();
1691 }
1692
1693 // The double-click event does not cancel the mouse press event. That is, if
1694 // left-double-clicking, at the end of the operation the button still
1695 // "pressed". We need to remove manually the button from the pressed buttons
1696 // context member.
1697
1698 m_context.m_pressedMouseButtons ^= event->button();
1699
1701
1703
1704 replot();
1705}
Qt::KeyboardModifiers m_keyboardModifiers
Qt::MouseButtons m_pressedMouseButtons
virtual void updateAxesRangeHistory()
Create new axis range history items and append them to the history.
virtual void resetAxesRangeHistory()
virtual void updateContextXandYAxisRanges()
void plotRangesChangedSignal(const BasePlotContext &context)
BasePlotContext m_context

References m_context, pappso::BasePlotContext::m_keyboardModifiers, pappso::BasePlotContext::m_pressedMouseButtons, plotRangesChangedSignal(), resetAxesRangeHistory(), updateAxesRangeHistory(), and updateContextXandYAxisRanges().

Referenced by setupWidget().

◆ axisPan()

void pappso::BasePlotWidget::axisPan ( )
virtual

Reimplemented in pappso::BaseTracePlotWidget.

Definition at line 2134 of file baseplotwidget.cpp.

2135{
2136 // Sanity check
2138 qFatal(
2139 "This function can only be called if the mouse click was on one of the "
2140 "axes");
2141
2143 {
2144 xAxis->setRange(m_context.m_xRange.lower - m_context.m_xDelta,
2146 }
2147
2149 {
2150 yAxis->setRange(m_context.m_yRange.lower - m_context.m_yDelta,
2152 }
2153
2155
2156 // qDebug() << "The updated context:" << m_context.toString();
2157
2158 // We cannot store the new ranges in the history, because the pan operation
2159 // involved a huge quantity of micro-movements elicited upon each mouse move
2160 // cursor event so we would have a huge history.
2161 // updateAxesRangeHistory();
2162
2163 // Now that the context has the right range values, we can emit the
2164 // signal that will be used by this plot widget users, typically to
2165 // abide by the x/y range lock required by the user.
2166
2168
2169 replot();
2170}

References m_context, pappso::BasePlotContext::m_wasClickOnXAxis, pappso::BasePlotContext::m_wasClickOnYAxis, pappso::BasePlotContext::m_xDelta, pappso::BasePlotContext::m_xRange, pappso::BasePlotContext::m_yDelta, pappso::BasePlotContext::m_yRange, plotRangesChangedSignal(), and updateContextXandYAxisRanges().

Referenced by mouseMoveHandlerLeftButtonDraggingCursor().

◆ axisReframe()

void pappso::BasePlotWidget::axisReframe ( )
virtual

Reimplemented in pappso::BaseTracePlotWidget.

Definition at line 2079 of file baseplotwidget.cpp.

2080{
2081
2082 // double sorted_start_drag_point_x =
2083 // std::min(m_context.m_startDragPoint.x(),
2084 // m_context.m_currentDragPoint.x());
2085
2086 // xAxis->setRange(sorted_start_drag_point_x,
2087 // sorted_start_drag_point_x + fabs(m_context.m_xDelta));
2088
2089 xAxis->setRange(QCPRange(m_context.m_xRegionRangeStart, m_context.m_xRegionRangeEnd));
2090
2091 // Note that the y axis should be rescaled from current lower value to new
2092 // upper value matching the y-axis position of the cursor when the mouse
2093 // button was released.
2094
2095 yAxis->setRange(xAxis->range().lower,
2097
2098 // qDebug() << "xaxis:" << xAxis->range().lower << "-" <<
2099 // xAxis->range().upper
2100 //<< "yaxis:" << yAxis->range().lower << "-" << yAxis->range().upper;
2101
2103
2106
2107 replot();
2108}

References m_context, pappso::BasePlotContext::m_xRegionRangeEnd, pappso::BasePlotContext::m_xRegionRangeStart, pappso::BasePlotContext::m_yRegionRangeEnd, pappso::BasePlotContext::m_yRegionRangeStart, plotRangesChangedSignal(), updateAxesRangeHistory(), and updateContextXandYAxisRanges().

Referenced by mouseReleaseHandlerLeftButton().

◆ axisRescale()

void pappso::BasePlotWidget::axisRescale ( )
virtual

RANGE-related functions.

PLOTTING / REPLOTTING functions

Reimplemented in pappso::BaseTracePlotWidget.

Definition at line 2023 of file baseplotwidget.cpp.

2024{
2025 // Get the current x lower/upper range, that is, leftmost/rightmost x
2026 // coordinate.
2027 double xLower = xAxis->range().lower;
2028 double xUpper = xAxis->range().upper;
2029
2030 // Get the current y lower/upper range, that is, bottommost/topmost y
2031 // coordinate.
2032 double yLower = yAxis->range().lower;
2033 double yUpper = yAxis->range().upper;
2034
2035 // This function is called only when the user has clicked on the x/y axis or
2036 // when the user has dragged the left mouse button with the Ctrl key
2037 // modifier. The m_context.m_wasClickOnXAxis is then simulated in the mouse
2038 // move handler. So we need to test which axis was clicked-on.
2039
2041 {
2042 // We are changing the range of the X axis.
2043
2044 // If xDelta is < 0, then we were dragging from right to left, we are
2045 // compressing the view on the x axis, by adding new data to the right
2046 // hand size of the graph. So we add xDelta to the upper bound of the
2047 // range. Otherwise we are uncompressing the view on the x axis and
2048 // remove the xDelta from the upper bound of the range. This is why we
2049 // have the
2050 // '-'
2051 // and not '+' below;
2052
2053 xAxis->setRange(xLower, xUpper - m_context.m_xDelta);
2054 }
2055 // End of
2056 // if(m_context.m_wasClickOnXAxis)
2057 else // that is, if(m_context.m_wasClickOnYAxis)
2058 {
2059 // We are changing the range of the Y axis.
2060
2061 // See above for an explanation of the computation (the - sign below).
2062
2063 yAxis->setRange(yLower, yUpper - m_context.m_yDelta);
2064 }
2065 // End of
2066 // else // that is, if(m_context.m_wasClickOnYAxis)
2067
2068 // Update the context with the current axes ranges
2069
2071
2073
2074 replot();
2075}

References m_context, pappso::BasePlotContext::m_wasClickOnXAxis, pappso::BasePlotContext::m_xDelta, pappso::BasePlotContext::m_yDelta, plotRangesChangedSignal(), and updateContextXandYAxisRanges().

Referenced by mouseMoveHandlerLeftButtonDraggingCursor().

◆ axisZoom()

void pappso::BasePlotWidget::axisZoom ( )
virtual

Reimplemented in pappso::BaseTracePlotWidget.

Definition at line 2112 of file baseplotwidget.cpp.

2113{
2114
2115 // Use the m_context.m_xRegionRangeStart/End values, but we need to sort the
2116 // values before using them, because now we want to really have the lower x
2117 // value. Simply craft a QCPRange that will swap the values if lower is not
2118 // < than upper QCustomPlot calls this normalization).
2119
2120 xAxis->setRange(QCPRange(m_context.m_xRegionRangeStart, m_context.m_xRegionRangeEnd));
2121
2122 yAxis->setRange(QCPRange(m_context.m_yRegionRangeStart, m_context.m_yRegionRangeEnd));
2123
2125
2128
2129 replot();
2130}

References m_context, pappso::BasePlotContext::m_xRegionRangeEnd, pappso::BasePlotContext::m_xRegionRangeStart, pappso::BasePlotContext::m_yRegionRangeEnd, pappso::BasePlotContext::m_yRegionRangeStart, plotRangesChangedSignal(), updateAxesRangeHistory(), and updateContextXandYAxisRanges().

Referenced by mouseReleaseHandlerLeftButton().

◆ calculateDragDeltas()

void pappso::BasePlotWidget::calculateDragDeltas ( )
virtual

Definition at line 2549 of file baseplotwidget.cpp.

2550{
2551
2552 // We compute signed differentials. If the user does not want the sign,
2553 // fabs(double) is their friend.
2554
2555 // Compute the xAxis differential:
2556
2558
2559 // Same with the Y-axis range:
2560
2562
2563 return;
2564}

References m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_startDragPoint, pappso::BasePlotContext::m_xDelta, and pappso::BasePlotContext::m_yDelta.

Referenced by mouseMoveHandlerDraggingCursor().

◆ createAllAncillaryItems()

void pappso::BasePlotWidget::createAllAncillaryItems ( )
protectedvirtual

Definition at line 220 of file baseplotwidget.cpp.

221{
222 // Make a copy of the pen to just change its color and set that color to
223 // the tracer line.
224 QPen pen = m_pen;
225
226 // Create the lines that will act as tracers for position and selection of
227 // regions.
228 //
229 // We have the cross hair that serves as the cursor. That crosshair cursor is
230 // made of a vertical line (green, because when click-dragging the mouse it
231 // becomes the tracer that is being anchored at the region start. The second
232 // line i horizontal and is always black.
233
234 pen.setColor(QColor("steelblue"));
235
236 // The set of tracers (horizontal and vertical) that track the position of the
237 // mouse cursor.
238
239 mp_vPosTracerItem = new QCPItemLine(this);
240 mp_vPosTracerItem->setLayer("plotsLayer");
241 mp_vPosTracerItem->setPen(pen);
242 mp_vPosTracerItem->start->setType(QCPItemPosition::ptPlotCoords);
243 mp_vPosTracerItem->end->setType(QCPItemPosition::ptPlotCoords);
244 mp_vPosTracerItem->start->setCoords(0, 0);
245 mp_vPosTracerItem->end->setCoords(0, 0);
246
247 mp_hPosTracerItem = new QCPItemLine(this);
248 mp_hPosTracerItem->setLayer("plotsLayer");
249 mp_hPosTracerItem->setPen(pen);
250 mp_hPosTracerItem->start->setType(QCPItemPosition::ptPlotCoords);
251 mp_hPosTracerItem->end->setType(QCPItemPosition::ptPlotCoords);
252 mp_hPosTracerItem->start->setCoords(0, 0);
253 mp_hPosTracerItem->end->setCoords(0, 0);
254
255 // The set of tracers (horizontal only) that track the region
256 // spanning/selection regions.
257 //
258 // The start vertical tracer is colored in greeen.
259 pen.setColor(QColor("green"));
260
261 mp_vStartTracerItem = new QCPItemLine(this);
262 mp_vStartTracerItem->setLayer("plotsLayer");
263 mp_vStartTracerItem->setPen(pen);
264 mp_vStartTracerItem->start->setType(QCPItemPosition::ptPlotCoords);
265 mp_vStartTracerItem->end->setType(QCPItemPosition::ptPlotCoords);
266 mp_vStartTracerItem->start->setCoords(0, 0);
267 mp_vStartTracerItem->end->setCoords(0, 0);
268
269 // The end vertical tracer is colored in red.
270 pen.setColor(QColor("red"));
271
272 mp_vEndTracerItem = new QCPItemLine(this);
273 mp_vEndTracerItem->setLayer("plotsLayer");
274 mp_vEndTracerItem->setPen(pen);
275 mp_vEndTracerItem->start->setType(QCPItemPosition::ptPlotCoords);
276 mp_vEndTracerItem->end->setType(QCPItemPosition::ptPlotCoords);
277 mp_vEndTracerItem->start->setCoords(0, 0);
278 mp_vEndTracerItem->end->setCoords(0, 0);
279
280 // When the user click-drags the mouse, the X distance between the drag start
281 // point and the drag end point (current point) is the xDelta.
282 mp_xDeltaTextItem = new QCPItemText(this);
283 mp_xDeltaTextItem->setLayer("plotsLayer");
284 mp_xDeltaTextItem->setColor(QColor("steelblue"));
285 mp_xDeltaTextItem->setPositionAlignment(Qt::AlignBottom | Qt::AlignCenter);
286 mp_xDeltaTextItem->position->setType(QCPItemPosition::ptPlotCoords);
287 mp_xDeltaTextItem->setVisible(false);
288
289 // Same for the y delta
290 mp_yDeltaTextItem = new QCPItemText(this);
291 mp_yDeltaTextItem->setLayer("plotsLayer");
292 mp_yDeltaTextItem->setColor(QColor("steelblue"));
293 mp_yDeltaTextItem->setPositionAlignment(Qt::AlignBottom | Qt::AlignCenter);
294 mp_yDeltaTextItem->position->setType(QCPItemPosition::ptPlotCoords);
295 mp_yDeltaTextItem->setVisible(false);
296
297 // Make sure we prepare the four lines that will be needed to
298 // draw the selection rectangle.
299 pen = m_pen;
300
301 pen.setColor("steelblue");
302
303 mp_selectionRectangeLine1 = new QCPItemLine(this);
304 mp_selectionRectangeLine1->setLayer("plotsLayer");
305 mp_selectionRectangeLine1->setPen(pen);
306 mp_selectionRectangeLine1->start->setType(QCPItemPosition::ptPlotCoords);
307 mp_selectionRectangeLine1->end->setType(QCPItemPosition::ptPlotCoords);
308 mp_selectionRectangeLine1->start->setCoords(0, 0);
309 mp_selectionRectangeLine1->end->setCoords(0, 0);
310 mp_selectionRectangeLine1->setVisible(false);
311
312 mp_selectionRectangeLine2 = new QCPItemLine(this);
313 mp_selectionRectangeLine2->setLayer("plotsLayer");
314 mp_selectionRectangeLine2->setPen(pen);
315 mp_selectionRectangeLine2->start->setType(QCPItemPosition::ptPlotCoords);
316 mp_selectionRectangeLine2->end->setType(QCPItemPosition::ptPlotCoords);
317 mp_selectionRectangeLine2->start->setCoords(0, 0);
318 mp_selectionRectangeLine2->end->setCoords(0, 0);
319 mp_selectionRectangeLine2->setVisible(false);
320
321 mp_selectionRectangeLine3 = new QCPItemLine(this);
322 mp_selectionRectangeLine3->setLayer("plotsLayer");
323 mp_selectionRectangeLine3->setPen(pen);
324 mp_selectionRectangeLine3->start->setType(QCPItemPosition::ptPlotCoords);
325 mp_selectionRectangeLine3->end->setType(QCPItemPosition::ptPlotCoords);
326 mp_selectionRectangeLine3->start->setCoords(0, 0);
327 mp_selectionRectangeLine3->end->setCoords(0, 0);
328 mp_selectionRectangeLine3->setVisible(false);
329
330 mp_selectionRectangeLine4 = new QCPItemLine(this);
331 mp_selectionRectangeLine4->setLayer("plotsLayer");
332 mp_selectionRectangeLine4->setPen(pen);
333 mp_selectionRectangeLine4->start->setType(QCPItemPosition::ptPlotCoords);
334 mp_selectionRectangeLine4->end->setType(QCPItemPosition::ptPlotCoords);
335 mp_selectionRectangeLine4->start->setCoords(0, 0);
336 mp_selectionRectangeLine4->end->setCoords(0, 0);
337 mp_selectionRectangeLine4->setVisible(false);
338}
QCPItemText * mp_yDeltaTextItem
QCPItemLine * mp_selectionRectangeLine1
Rectangle defining the borders of zoomed-in/out data.
QCPItemLine * mp_selectionRectangeLine2
QCPItemText * mp_xDeltaTextItem
Text describing the x-axis delta value during a drag operation.
QCPItemLine * mp_hPosTracerItem
Horizontal position tracer.
QCPItemLine * mp_vPosTracerItem
Vertical position tracer.
QCPItemLine * mp_selectionRectangeLine4
QCPItemLine * mp_vStartTracerItem
Vertical selection start tracer (typically in green).
QCPItemLine * mp_selectionRectangeLine3
QCPItemLine * mp_vEndTracerItem
Vertical selection end tracer (typically in red).

References m_pen, mp_hPosTracerItem, mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, mp_vEndTracerItem, mp_vPosTracerItem, mp_vStartTracerItem, mp_xDeltaTextItem, and mp_yDeltaTextItem.

Referenced by pappso::BaseTracePlotWidget::BaseTracePlotWidget(), pappso::BaseTracePlotWidget::BaseTracePlotWidget(), pappso::BaseColorMapPlotWidget::addColorMap(), and pappso::BaseColorMapPlotWidget::addColorMap().

◆ directionKeyPressEvent()

void pappso::BasePlotWidget::directionKeyPressEvent ( QKeyEvent *  event)
virtual

Definition at line 803 of file baseplotwidget.cpp.

804{
805 // qDebug() << "event key:" << event->key();
806
807 // The user is trying to move the positional cursor/markers. There are
808 // multiple way they can do that:
809 //
810 // 1.a. Hitting the arrow left/right keys alone will search for next pixel.
811 // 1.b. Hitting the arrow left/right keys with Alt modifier will search for
812 // a multiple of pixels that might be equivalent to one 20th of the pixel
813 // width of the plot widget. 1.c Hitting the left/right keys with Alt and
814 // Shift modifiers will search for a multiple of pixels that might be the
815 // equivalent to half of the pixel width.
816 //
817 // 2. Hitting the Control modifier will move the cursor to the next data
818 // point of the graph.
819
820 int pixel_increment = 0;
821
822 if(m_context.m_keyboardModifiers == Qt::NoModifier)
823 pixel_increment = 1;
824 else if(m_context.m_keyboardModifiers == Qt::AltModifier)
825 pixel_increment = 50;
826
827 // The user is moving the positional markers. This is equivalent to a
828 // non-dragging cursor movement to the next pixel. Note that the origin is
829 // located at the top left, so key down increments and key up decrements.
830
831 if(event->key() == Qt::Key_Left)
832 horizontalMoveMouseCursorCountPixels(-pixel_increment);
833 else if(event->key() == Qt::Key_Right)
835 else if(event->key() == Qt::Key_Up)
836 verticalMoveMouseCursorCountPixels(-pixel_increment);
837 else if(event->key() == Qt::Key_Down)
838 verticalMoveMouseCursorCountPixels(pixel_increment);
839
840 event->accept();
841}
virtual void verticalMoveMouseCursorCountPixels(int pixel_count)
virtual void horizontalMoveMouseCursorCountPixels(int pixel_count)

References horizontalMoveMouseCursorCountPixels(), m_context, pappso::BasePlotContext::m_keyboardModifiers, and verticalMoveMouseCursorCountPixels().

Referenced by keyPressEvent().

◆ directionKeyReleaseEvent()

void pappso::BasePlotWidget::directionKeyReleaseEvent ( QKeyEvent *  event)
virtual

Definition at line 845 of file baseplotwidget.cpp.

846{
847 // qDebug() << "event key:" << event->key();
848 event->accept();
849}

Referenced by keyReleaseEvent().

◆ dragDirection()

int pappso::BasePlotWidget::dragDirection ( )

MOUSE-related EVENTS.

MOUSE MOVEMENTS mouse/keyboard-triggered

Definition at line 1761 of file baseplotwidget.cpp.

1762{
1763 // The user is dragging the mouse, probably to rescale the axes, but we need
1764 // to sort out in which direction the drag is happening.
1765
1766 // This function should be called after calculateDragDeltas, so that
1767 // m_context has the proper x/y delta values that we'll compare.
1768
1769 // Note that we cannot compare simply x or y deltas because the y axis might
1770 // have a different scale that the x axis. So we first need to convert the
1771 // positions to pixels.
1772
1773 double x_delta_pixel = fabs(xAxis->coordToPixel(m_context.m_currentDragPoint.x()) -
1774 xAxis->coordToPixel(m_context.m_startDragPoint.x()));
1775
1776 double y_delta_pixel = fabs(yAxis->coordToPixel(m_context.m_currentDragPoint.y()) -
1777 yAxis->coordToPixel(m_context.m_startDragPoint.y()));
1778
1779 if(x_delta_pixel > y_delta_pixel)
1780 return Qt::Horizontal;
1781
1782 return Qt::Vertical;
1783}

References m_context, pappso::BasePlotContext::m_currentDragPoint, and pappso::BasePlotContext::m_startDragPoint.

◆ drawSelectionRectangleAndPrepareZoom()

void pappso::BasePlotWidget::drawSelectionRectangleAndPrepareZoom ( bool  as_line_segment = false,
bool  for_integration = false 
)
virtual

Definition at line 2275 of file baseplotwidget.cpp.

2276{
2277 // The user has dragged the mouse left button on the graph, which means he
2278 // is willing to draw a selection rectangle, either for zooming-in or for
2279 // integration.
2280
2281 if(mp_xDeltaTextItem != nullptr)
2282 mp_xDeltaTextItem->setVisible(false);
2283 if(mp_yDeltaTextItem != nullptr)
2284 mp_yDeltaTextItem->setVisible(false);
2285
2286 // Ensure the right selection rectangle is drawn.
2287
2288 updateIntegrationScopeDrawing(as_line_segment, for_integration);
2289
2290 // Note that if we draw a zoom rectangle, then we are certainly not
2291 // measuring anything. So set the boolean value to false so that the user of
2292 // this widget or derived classes know that there is nothing to perform upon
2293 // (like deconvolution, for example).
2294
2296
2297 // Also remove the delta value from the pipeline by sending a simple
2298 // distance without measurement signal.
2299
2300 emit xAxisMeasurementSignal(m_context, false);
2301
2302 replot();
2303}
virtual void updateIntegrationScopeDrawing(bool as_line_segment=false, bool for_integration=false)
void xAxisMeasurementSignal(const BasePlotContext &context, bool with_delta)

References m_context, pappso::BasePlotContext::m_isMeasuringDistance, mp_xDeltaTextItem, mp_yDeltaTextItem, updateIntegrationScopeDrawing(), and xAxisMeasurementSignal().

Referenced by mouseMoveHandlerLeftButtonDraggingCursor(), and mouseMoveHandlerRightButtonDraggingCursor().

◆ drawXScopeSpanFeatures()

void pappso::BasePlotWidget::drawXScopeSpanFeatures ( )
virtual

Definition at line 2307 of file baseplotwidget.cpp.

2308{
2309 // Depending on the kind of integration scope, we will have to display
2310 // differently calculated values. We want to provide the user with
2311 // the horizontal span of the integration scope. There are different
2312 // situations.
2313
2314 // 1. The scope is mono-dimensional across the x axis: the span
2315 // is thus simply the width.
2316
2317 // 2. The scope is bi-dimensional and is a rectangle: the span is
2318 // thus simply the width.
2319
2320 // 3. The socpe is bi-dimensional and is a rhomboid: the span is
2321 // the width.
2322
2323 // In the first and second cases above, the width is equal to the
2324 // m_context.m_xDelta.
2325
2326 // In the case of the rhomboid, the span is not m_context.m_xDelta,
2327 // it is more than that if the rhomboid is horizontal because it is
2328 // the m_context.m_xDelta plus the rhomboid's horizontal size.
2329
2330 // FIXME: is this still true?
2331 //
2332 // We do not want to show the position markers because the only horiontal
2333 // line to be visible must be contained between the start and end vertical
2334 // tracer items.
2335 mp_hPosTracerItem->setVisible(false);
2336 mp_vPosTracerItem->setVisible(false);
2337
2338 // We want to draw the text in the middle position of the leftmost-rightmost
2339 // point, even with rhomboid scopes.
2340
2341 QPointF leftmost_point;
2342 if(!m_context.msp_integrationScope->getLeftMostPoint(leftmost_point))
2343 qFatal("Could not get the left-most point.");
2344
2345 double width;
2346 if(!m_context.msp_integrationScope->getWidth(width))
2347 qFatal("Could not get width.");
2348 // qDebug() << "width:" << width;
2349
2350 double x_axis_center_position = leftmost_point.x() + width / 2;
2351
2352 // We want the text to print inside the rectangle, always at the current
2353 // drag point so the eye can follow the delta value while looking where to
2354 // drag the mouse. To position the text inside the rectangle, we need to
2355 // know what is the drag direction.
2356
2357 // What is the distance between the rectangle line at current drag point and
2358 // the text itself. Think of this as a margin distance between the
2359 // point of interest and the actual position of the text.
2360 int pixels_away_from_line = 15;
2361
2362 QPointF reference_point_for_y_axis_label_position;
2363
2364 // ATTENTION: the pixel coordinates for the vertical direction go in reverse
2365 // order with respect to the y axis values !!! That is, pixel(0,0) is top
2366 // left of the graph.
2367 if(static_cast<int>(m_context.m_dragDirections) & static_cast<int>(DragDirections::BOTTOM_TO_TOP))
2368 {
2369 // We need to print outside the rectangle, that is pixels_away_from_line
2370 // pixels to the top, so with pixel y value decremented of that
2371 // pixels_above_line value (one would have expected to increment that
2372 // value, along the y axis, but the coordinates in pixel go in reverse
2373 // order).
2374
2375 pixels_away_from_line *= -1;
2376
2377 if(!m_context.msp_integrationScope->getTopMostPoint(
2378 reference_point_for_y_axis_label_position))
2379 qFatal("Failed to get top most point.");
2380 }
2381 else
2382 {
2383 if(!m_context.msp_integrationScope->getBottomMostPoint(
2384 reference_point_for_y_axis_label_position))
2385 qFatal("Failed to get bottom most point.");
2386 }
2387
2388 // double y_axis_pixel_coordinate =
2389 // yAxis->coordToPixel(m_context.m_currentDragPoint.y());
2390 double y_axis_pixel_coordinate =
2391 yAxis->coordToPixel(reference_point_for_y_axis_label_position.y());
2392
2393 // Now that we have the coordinate in pixel units, we can correct
2394 // it by the value of the margin we want to give.
2395 double y_axis_modified_pixel_coordinate = y_axis_pixel_coordinate + pixels_away_from_line;
2396
2397 // Set aside a point instance to store the pixel coordinates of the text.
2398 QPointF pixel_coordinates;
2399
2400 pixel_coordinates.setX(x_axis_center_position);
2401 pixel_coordinates.setY(y_axis_modified_pixel_coordinate);
2402
2403 // Now convert back to graph coordinates.
2404 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
2405 yAxis->pixelToCoord(pixel_coordinates.y()));
2406
2407 // qDebug() << "Should print the label at point:" << graph_coordinates;
2408
2409 if(mp_xDeltaTextItem != nullptr)
2410 {
2411 mp_xDeltaTextItem->position->setCoords(x_axis_center_position, graph_coordinates.y());
2412
2413 // Dynamically set the number of decimals to ensure we can read
2414 // a meaning full delta value even if it is very very very small.
2415 // That is, allow one to read 0.00333, 0.000333, 1.333 and so on.
2416
2417 // The computation below only works properly when the passed
2418 // value is fabs() (not negative !!!).
2419
2420 int decimals = Utils::zeroDecimalsInValue(width) + 3;
2421
2422 QString label_text = QString("full x span %1 -- x drag delta %2")
2423 .arg(width, 0, 'f', decimals)
2424 .arg(fabs(m_context.m_xDelta), 0, 'f', decimals);
2425
2426 mp_xDeltaTextItem->setText(label_text);
2427
2428 mp_xDeltaTextItem->setFont(QFont(font().family(), 9));
2429 mp_xDeltaTextItem->setVisible(true);
2430 }
2431
2432 // Set the boolean to true so that derived widgets know that something is
2433 // being measured, and they can act accordingly, for example by computing
2434 // deconvolutions in a mass spectrum.
2436
2437 replot();
2438
2439 // Let the caller know that we were measuring something.
2441
2442 return;
2443}
IntegrationScopeBaseCstSPtr msp_integrationScope
DragDirections m_dragDirections
static int zeroDecimalsInValue(pappso_double value)
0.11 would return 0 (no empty decimal) 2.001 would return 2 1000.0001254 would return 3
Definition utils.cpp:102

References pappso::BOTTOM_TO_TOP, m_context, pappso::BasePlotContext::m_dragDirections, pappso::BasePlotContext::m_isMeasuringDistance, pappso::BasePlotContext::m_xDelta, mp_hPosTracerItem, mp_vPosTracerItem, mp_xDeltaTextItem, pappso::BasePlotContext::msp_integrationScope, xAxisMeasurementSignal(), and pappso::Utils::zeroDecimalsInValue().

Referenced by mouseMoveHandlerLeftButtonDraggingCursor(), mouseMoveHandlerRightButtonDraggingCursor(), and updateIntegrationScopeDrawing().

◆ drawYScopeSpanFeatures()

void pappso::BasePlotWidget::drawYScopeSpanFeatures ( )
virtual

Definition at line 2446 of file baseplotwidget.cpp.

2447{
2448 // See drawXScopeSpanFeatures() for explanations.
2449
2450 // Check right away if there is height!
2451 double height;
2452 if(!m_context.msp_integrationScope->getHeight(height))
2453 qFatal("Could not get height.");
2454
2455 // If there is no height, we have nothing to do here.
2456 if(!height)
2457 return;
2458 // qDebug() << "height:" << height;
2459
2460 // FIXME: is this still true?
2461 //
2462 // We do not want to show the position markers because the only horiontal
2463 // line to be visible must be contained between the start and end vertical
2464 // tracer items.
2465 mp_hPosTracerItem->setVisible(false);
2466 mp_vPosTracerItem->setVisible(false);
2467
2468 // First the easy part: the vertical position: centered on the
2469 // scope Y span.
2470 QPointF bottom_most_point;
2471 if(!m_context.msp_integrationScope->getBottomMostPoint(bottom_most_point))
2472 qFatal("Could not get the bottom-most bottom point.");
2473
2474 double y_axis_center_position = bottom_most_point.y() + height / 2;
2475
2476 // We want to draw the text outside the rectangle (if normal rectangle)
2477 // at a small distance from the vertical limit of the scope at the
2478 // position of the current drag point. We need to check the horizontal
2479 // drag direction to put the text at the right place (left of
2480 // current drag point if dragging right to left, for example).
2481
2482 // What is the distance between the rectangle line at current drag point and
2483 // the text itself.
2484 int pixels_away_from_line = 15;
2485 double x_axis_coordinate;
2486 double x_axis_pixel_coordinate;
2487
2488 if(static_cast<int>(m_context.m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
2489 {
2490 QPointF left_most_point;
2491
2492 if(!m_context.msp_integrationScope->getLeftMostPoint(left_most_point))
2493 qFatal("Failed to get left most point.");
2494
2495 x_axis_coordinate = left_most_point.x();
2496
2497 pixels_away_from_line *= -1;
2498 }
2499 else
2500 {
2501 QPointF right_most_point;
2502
2503 if(!m_context.msp_integrationScope->getRightMostPoint(right_most_point))
2504 qFatal("Failed to get right most point.");
2505
2506 x_axis_coordinate = right_most_point.x();
2507 }
2508 x_axis_pixel_coordinate = xAxis->coordToPixel(x_axis_coordinate);
2509
2510 double x_axis_modified_pixel_coordinate = x_axis_pixel_coordinate + pixels_away_from_line;
2511
2512 // Set aside a point instance to store the pixel coordinates of the text.
2513 QPointF pixel_coordinates;
2514
2515 pixel_coordinates.setX(x_axis_modified_pixel_coordinate);
2516 pixel_coordinates.setY(y_axis_center_position);
2517
2518 // Now convert back to graph coordinates.
2519
2520 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
2521 yAxis->pixelToCoord(pixel_coordinates.y()));
2522
2523 mp_yDeltaTextItem->position->setCoords(graph_coordinates.x(), y_axis_center_position);
2524
2525 int decimals = Utils::zeroDecimalsInValue(height) + 3;
2526
2527 QString label_text = QString("full y span %1 -- y drag delta %2")
2528 .arg(height, 0, 'f', decimals)
2529 .arg(fabs(m_context.m_yDelta), 0, 'f', decimals);
2530
2531 mp_yDeltaTextItem->setText(label_text);
2532 mp_yDeltaTextItem->setFont(QFont(font().family(), 9));
2533 mp_yDeltaTextItem->setVisible(true);
2534 mp_yDeltaTextItem->setRotation(90);
2535
2536 // Set the boolean to true so that derived widgets know that something is
2537 // being measured, and they can act accordingly, for example by computing
2538 // deconvolutions in a mass spectrum.
2540
2541 replot();
2542
2543 // Let the caller know that we were measuring something.
2545}

References m_context, pappso::BasePlotContext::m_dragDirections, pappso::BasePlotContext::m_isMeasuringDistance, pappso::BasePlotContext::m_yDelta, mp_hPosTracerItem, mp_vPosTracerItem, mp_yDeltaTextItem, pappso::BasePlotContext::msp_integrationScope, pappso::RIGHT_TO_LEFT, xAxisMeasurementSignal(), and pappso::Utils::zeroDecimalsInValue().

Referenced by mouseMoveHandlerLeftButtonDraggingCursor(), and mouseMoveHandlerRightButtonDraggingCursor().

◆ getContext()

const BasePlotContext & pappso::BasePlotWidget::getContext ( ) const
virtual

Definition at line 3285 of file baseplotwidget.cpp.

3286{
3287 return m_context;
3288}

References m_context.

◆ getInnermostRangeX()

QCPRange pappso::BasePlotWidget::getInnermostRangeX ( bool &  found_range) const
virtual

Definition at line 1988 of file baseplotwidget.cpp.

1989{
1990
1991 return getRange(Enums::Axis::x, RangeType::innermost, found_range);
1992}
QCPRange getRange(Enums::Axis axis, RangeType range_type, bool &found_range) const

References getRange(), pappso::innermost, and pappso::Enums::x.

◆ getInnermostRangeY()

QCPRange pappso::BasePlotWidget::getInnermostRangeY ( bool &  found_range) const
virtual

Definition at line 2003 of file baseplotwidget.cpp.

2004{
2005
2006 return getRange(Enums::Axis::y, RangeType::innermost, found_range);
2007}

References getRange(), pappso::innermost, and pappso::Enums::y.

◆ getOutermostRangeX()

QCPRange pappso::BasePlotWidget::getOutermostRangeX ( bool &  found_range) const
virtual

Definition at line 1996 of file baseplotwidget.cpp.

1997{
1998 return getRange(Enums::Axis::x, RangeType::outermost, found_range);
1999}

References getRange(), pappso::outermost, and pappso::Enums::x.

◆ getOutermostRangeY()

QCPRange pappso::BasePlotWidget::getOutermostRangeY ( bool &  found_range) const
virtual

Definition at line 2011 of file baseplotwidget.cpp.

2012{
2013 return getRange(Enums::Axis::y, RangeType::outermost, found_range);
2014}

References getRange(), pappso::outermost, and pappso::Enums::y.

◆ getPen()

const QPen & pappso::BasePlotWidget::getPen ( ) const
virtual

Definition at line 397 of file baseplotwidget.cpp.

398{
399 return m_pen;
400}

References m_pen.

◆ getPlottingColor() [1/2]

QColor pappso::BasePlotWidget::getPlottingColor ( int  index = 0) const
virtual

Reimplemented in pappso::BaseColorMapPlotWidget.

Definition at line 446 of file baseplotwidget.cpp.

447{
448 QCPGraph *graph_p = graph(index);
449
450 if(graph_p == nullptr)
451 qFatal("Programming error.");
452
453 return getPlottingColor(graph_p);
454}
virtual QColor getPlottingColor(QCPAbstractPlottable *plottable_p) const

References getPlottingColor().

◆ getPlottingColor() [2/2]

QColor pappso::BasePlotWidget::getPlottingColor ( QCPAbstractPlottable *  plottable_p) const
virtual

Definition at line 436 of file baseplotwidget.cpp.

437{
438 if(plottable_p == nullptr)
439 qFatal("Programming error.");
440
441 return plottable_p->pen().color();
442}

Referenced by getPlottingColor().

◆ getRange()

QCPRange pappso::BasePlotWidget::getRange ( Enums::Axis  axis,
RangeType  range_type,
bool &  found_range 
) const

Definition at line 1898 of file baseplotwidget.cpp.

1899{
1900
1901 // Iterate in all the graphs in this widget and return a QCPRange that has
1902 // its lower member as the greatest lower value of all
1903 // its upper member as the smallest upper value of all
1904
1905 if(!graphCount())
1906 {
1907 found_range = false;
1908
1909 return QCPRange(0, 1);
1910 }
1911
1912 if(graphCount() == 1)
1913 return graph()->getKeyRange(found_range);
1914
1915 bool found_at_least_one_range = false;
1916
1917 // Create an invalid range.
1918 QCPRange result_range(QCPRange::minRange + 1, QCPRange::maxRange + 1);
1919
1920 for(int iter = 0; iter < graphCount(); ++iter)
1921 {
1922 QCPRange temp_range;
1923
1924 bool found_range_for_iter = false;
1925
1926 QCPGraph *graph_p = graph(iter);
1927
1928 // Depending on the axis param, select the key or value range.
1929
1930 if(axis == Enums::Axis::x)
1931 temp_range = graph_p->getKeyRange(found_range_for_iter);
1932 else if(axis == Enums::Axis::y)
1933 temp_range = graph_p->getValueRange(found_range_for_iter);
1934 else
1935 qFatal("Cannot reach this point. Programming error.");
1936
1937 // Was a range found for the iterated graph ? If not skip this
1938 // iteration.
1939
1940 if(!found_range_for_iter)
1941 continue;
1942
1943 // While the innermost_range is invalid, we need to seed it with a good
1944 // one. So check this.
1945
1946 if(!QCPRange::validRange(result_range))
1947 qFatal("The obtained range is invalid !");
1948
1949 // At this point we know the obtained range is OK.
1950 result_range = temp_range;
1951
1952 // We found at least one valid range!
1953 found_at_least_one_range = true;
1954
1955 // At this point we have two valid ranges to compare. Depending on
1956 // range_type, we need to perform distinct comparisons.
1957
1958 if(range_type == RangeType::innermost)
1959 {
1960 if(temp_range.lower > result_range.lower)
1961 result_range.lower = temp_range.lower;
1962 if(temp_range.upper < result_range.upper)
1963 result_range.upper = temp_range.upper;
1964 }
1965 else if(range_type == RangeType::outermost)
1966 {
1967 if(temp_range.lower < result_range.lower)
1968 result_range.lower = temp_range.lower;
1969 if(temp_range.upper > result_range.upper)
1970 result_range.upper = temp_range.upper;
1971 }
1972 else
1973 qFatal("Cannot reach this point. Programming error.");
1974
1975 // Continue to next graph, if any.
1976 }
1977 // End of
1978 // for(int iter = 0; iter < graphCount(); ++iter)
1979
1980 // Let the caller know if we found at least one range.
1981 found_range = found_at_least_one_range;
1982
1983 return result_range;
1984}

References pappso::innermost, pappso::outermost, pappso::Enums::x, and pappso::Enums::y.

Referenced by getInnermostRangeX(), getInnermostRangeY(), getOutermostRangeX(), and getOutermostRangeY().

◆ getRangeX()

QCPRange pappso::BasePlotWidget::getRangeX ( bool &  found_range,
int  index 
) const
virtual

MOUSE MOVEMENTS mouse/keyboard-triggered.

RANGE-related functions

Definition at line 1874 of file baseplotwidget.cpp.

1875{
1876 QCPGraph *graph_p = graph(index);
1877
1878 if(graph_p == nullptr)
1879 qFatal("Programming error.");
1880
1881 return graph_p->getKeyRange(found_range);
1882}

◆ getRangeY()

QCPRange pappso::BasePlotWidget::getRangeY ( bool &  found_range,
int  index 
) const
virtual

Definition at line 1886 of file baseplotwidget.cpp.

1887{
1888 QCPGraph *graph_p = graph(index);
1889
1890 if(graph_p == nullptr)
1891 qFatal("Programming error.");
1892
1893 return graph_p->getValueRange(found_range);
1894}

◆ hideAllPlotItems()

void pappso::BasePlotWidget::hideAllPlotItems ( )
virtual

PLOTTING / REPLOTTING functions.

PLOT ITEMS : TRACER TEXT ITEMS...

PLOT ITEMS : TRACER TEXT ITEMS... Hide the selection line, the xDelta text and the zoom rectangle items.

Definition at line 2225 of file baseplotwidget.cpp.

2226{
2227 mp_xDeltaTextItem->setVisible(false);
2228 mp_yDeltaTextItem->setVisible(false);
2229
2230 // mp_zoomRectItem->setVisible(false);
2232
2233 // Force a replot to make sure the action is immediately visible by the
2234 // user, even without moving the mouse.
2235 replot();
2236}
virtual void hideSelectionRectangle(bool reset_values=false)

References hideSelectionRectangle(), mp_xDeltaTextItem, and mp_yDeltaTextItem.

Referenced by restoreAxesRangeHistory().

◆ hideSelectionRectangle()

void pappso::BasePlotWidget::hideSelectionRectangle ( bool  reset_values = false)
virtual

Definition at line 3157 of file baseplotwidget.cpp.

3158{
3159 mp_selectionRectangeLine1->setVisible(false);
3160 mp_selectionRectangeLine2->setVisible(false);
3161 mp_selectionRectangeLine3->setVisible(false);
3162 mp_selectionRectangeLine4->setVisible(false);
3163
3164 if(reset_values)
3165 {
3167 }
3168}
virtual void resetSelectionRectangle()

References mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, and resetSelectionRectangle().

Referenced by hideAllPlotItems(), mouseReleaseHandlerLeftButton(), and mouseReleaseHandlerRightButton().

◆ hideTracers()

void pappso::BasePlotWidget::hideTracers ( )
virtual

Hide the traces (vertical and horizontal).

Definition at line 2259 of file baseplotwidget.cpp.

2260{
2262 mp_hPosTracerItem->setVisible(false);
2263 mp_vPosTracerItem->setVisible(false);
2264
2265 mp_vStartTracerItem->setVisible(false);
2266 mp_vEndTracerItem->setVisible(false);
2267
2268 // Force a replot to make sure the action is immediately visible by the
2269 // user, even without moving the mouse.
2270 replot();
2271}
bool m_shouldTracersBeVisible
Tells if the tracers should be visible.

References m_shouldTracersBeVisible, mp_hPosTracerItem, mp_vEndTracerItem, mp_vPosTracerItem, and mp_vStartTracerItem.

Referenced by keyReleaseEvent().

◆ horizontalGetGraphCoordNewPointCountPixels()

QPointF pappso::BasePlotWidget::horizontalGetGraphCoordNewPointCountPixels ( int  pixel_count)
virtual

Definition at line 1822 of file baseplotwidget.cpp.

1823{
1824 QPointF pixel_coordinates(xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()) +
1825 pixel_count,
1826 yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()));
1827
1828 // Now convert back to local coordinates.
1829
1830 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1831 yAxis->pixelToCoord(pixel_coordinates.y()));
1832
1833 return graph_coordinates;
1834}

References m_context, and pappso::BasePlotContext::m_lastCursorHoveredPoint.

Referenced by horizontalMoveMouseCursorCountPixels().

◆ horizontalMoveMouseCursorCountPixels()

void pappso::BasePlotWidget::horizontalMoveMouseCursorCountPixels ( int  pixel_count)
virtual

Definition at line 1807 of file baseplotwidget.cpp.

1808{
1809 QPointF graph_coord = horizontalGetGraphCoordNewPointCountPixels(pixel_count);
1810
1811 QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()), yAxis->coordToPixel(graph_coord.y()));
1812
1813 // Now we need ton convert the new coordinates to the global position system
1814 // and to move the cursor to that new position. That will create an event to
1815 // move the mouse cursor.
1816
1817 moveMouseCursorPixelCoordToGlobal(pixel_coord.toPoint());
1818}
virtual void moveMouseCursorPixelCoordToGlobal(QPointF local_coordinates)
virtual QPointF horizontalGetGraphCoordNewPointCountPixels(int pixel_count)

References horizontalGetGraphCoordNewPointCountPixels(), and moveMouseCursorPixelCoordToGlobal().

Referenced by directionKeyPressEvent().

◆ integrationRequestedSignal

void pappso::BasePlotWidget::integrationRequestedSignal ( const BasePlotContext context)
signal

◆ isClickOntoXAxis()

bool pappso::BasePlotWidget::isClickOntoXAxis ( const QPointF &  mousePoint)

Definition at line 1709 of file baseplotwidget.cpp.

1710{
1711 QCPLayoutElement *layoutElement = layoutElementAt(mousePoint);
1712
1713 if(layoutElement && layoutElement == dynamic_cast<QCPLayoutElement *>(axisRect()))
1714 {
1715 // The graph is *inside* the axisRect that is the outermost envelope of
1716 // the graph. Thus, if we want to know if the click was indeed on an
1717 // axis, we need to check what selectable part of the the axisRect we
1718 // were clicking:
1719 QCPAxis::SelectablePart selectablePart;
1720
1721 selectablePart = xAxis->getPartAt(mousePoint);
1722
1723 if(selectablePart == QCPAxis::spAxisLabel || selectablePart == QCPAxis::spAxis ||
1724 selectablePart == QCPAxis::spTickLabels)
1725 return true;
1726 }
1727
1728 return false;
1729}

Referenced by mousePressHandler().

◆ isClickOntoYAxis()

bool pappso::BasePlotWidget::isClickOntoYAxis ( const QPointF &  mousePoint)

Definition at line 1733 of file baseplotwidget.cpp.

1734{
1735 QCPLayoutElement *layoutElement = layoutElementAt(mousePoint);
1736
1737 if(layoutElement && layoutElement == dynamic_cast<QCPLayoutElement *>(axisRect()))
1738 {
1739 // The graph is *inside* the axisRect that is the outermost envelope of
1740 // the graph. Thus, if we want to know if the click was indeed on an
1741 // axis, we need to check what selectable part of the the axisRect we
1742 // were clicking:
1743 QCPAxis::SelectablePart selectablePart;
1744
1745 selectablePart = yAxis->getPartAt(mousePoint);
1746
1747 if(selectablePart == QCPAxis::spAxisLabel || selectablePart == QCPAxis::spAxis ||
1748 selectablePart == QCPAxis::spTickLabels)
1749 return true;
1750 }
1751
1752 return false;
1753}

Referenced by mousePressHandler().

◆ isSelectionRectangleVisible()

bool pappso::BasePlotWidget::isSelectionRectangleVisible ( )
virtual

Definition at line 3217 of file baseplotwidget.cpp.

3218{
3219 // Sanity check
3220 int check = 0;
3221
3222 check += mp_selectionRectangeLine1->visible();
3223 check += mp_selectionRectangeLine2->visible();
3224 check += mp_selectionRectangeLine3->visible();
3225 check += mp_selectionRectangeLine4->visible();
3226
3227 if(check > 0)
3228 return true;
3229
3230 return false;
3231}

References mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, and mp_selectionRectangeLine4.

◆ isVerticalDisplacementAboveThreshold()

bool pappso::BasePlotWidget::isVerticalDisplacementAboveThreshold ( )
virtual

Definition at line 2568 of file baseplotwidget.cpp.

2569{
2570 // First get the height of the plot.
2571 double plotHeight = yAxis->range().upper - yAxis->range().lower;
2572
2573 double heightDiff = fabs(m_context.m_startDragPoint.y() - m_context.m_currentDragPoint.y());
2574
2575 double heightDiffRatio = (heightDiff / plotHeight) * 100;
2576
2577 if(heightDiffRatio > 10)
2578 {
2579 return true;
2580 }
2581
2582 return false;
2583}

References m_context, pappso::BasePlotContext::m_currentDragPoint, and pappso::BasePlotContext::m_startDragPoint.

Referenced by keyReleaseEvent(), mouseMoveHandlerLeftButtonDraggingCursor(), and mouseMoveHandlerRightButtonDraggingCursor().

◆ keyPressEvent()

void pappso::BasePlotWidget::keyPressEvent ( QKeyEvent *  event)
virtual

KEYBOARD-related EVENTS.

Reimplemented in pappso::DriftSpecMassSpecColorMapPlotWidget, pappso::DriftSpecTracePlotWidget, pappso::MassSpecTracePlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, and pappso::TicXicChromTracePlotWidget.

Definition at line 607 of file baseplotwidget.cpp.

608{
609 // qDebug() << "ENTER";
610
611 // We need this because some keys modify our behaviour.
612 m_context.m_pressedKeyCode = event->key();
613 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
614
615 if(event->key() == Qt::Key_Left || event->key() == Qt::Key_Right || event->key() == Qt::Key_Up ||
616 event->key() == Qt::Key_Down)
617 {
618 return directionKeyPressEvent(event);
619 }
620 else if(event->key() == m_leftMousePseudoButtonKey || event->key() == m_rightMousePseudoButtonKey)
621 {
622 return mousePseudoButtonKeyPressEvent(event);
623 }
624
625 // Do not do anything here, because this function is used by derived classes
626 // that will emit the signal below. Otherwise there are going to be multiple
627 // signals sent.
628 // qDebug() << "Going to emit keyPressEventSignal(m_context);";
629 // emit keyPressEventSignal(m_context);
630}
virtual void mousePseudoButtonKeyPressEvent(QKeyEvent *event)
virtual void directionKeyPressEvent(QKeyEvent *event)

References directionKeyPressEvent(), m_context, pappso::BasePlotContext::m_keyboardModifiers, m_leftMousePseudoButtonKey, pappso::BasePlotContext::m_pressedKeyCode, m_rightMousePseudoButtonKey, and mousePseudoButtonKeyPressEvent().

Referenced by pappso::DriftSpecMassSpecColorMapPlotWidget::keyPressEvent(), pappso::DriftSpecTracePlotWidget::keyPressEvent(), pappso::MassSpecTracePlotWidget::keyPressEvent(), pappso::TicXicChromDriftSpecColorMapPlotWidget::keyPressEvent(), pappso::TicXicChromMassSpecColorMapPlotWidget::keyPressEvent(), and pappso::TicXicChromTracePlotWidget::keyPressEvent().

◆ keyPressEventSignal

void pappso::BasePlotWidget::keyPressEventSignal ( const BasePlotContext context)
signal

◆ keyReleaseEvent()

void pappso::BasePlotWidget::keyReleaseEvent ( QKeyEvent *  event)
virtual

Handle specific key codes and trigger respective actions.

Reimplemented in pappso::DriftSpecMassSpecColorMapPlotWidget, pappso::DriftSpecTracePlotWidget, pappso::MassSpecTracePlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, and pappso::TicXicChromTracePlotWidget.

Definition at line 635 of file baseplotwidget.cpp.

636{
637 m_context.m_releasedKeyCode = event->key();
638
639 // The keyboard key is being released, set the key code to 0.
641
642 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
643
644 // Now test if the key that was released is one of the housekeeping keys.
645 if(event->key() == Qt::Key_Backspace)
646 {
647 // qDebug();
648
649 // The user wants to iterate back in the x/y axis range history.
651
652 event->accept();
653 }
654 else if(event->key() == Qt::Key_Space)
655 {
656 return spaceKeyReleaseEvent(event);
657 }
658 else if(event->key() == Qt::Key_Delete)
659 {
660 // The user wants to delete a graph. What graph is to be determined
661 // programmatically:
662
663 // If there is a single graph, then that is the graph to be removed.
664 // If there are more than one graph, then only the ones that are selected
665 // are to be removed.
666
667 // Note that the user of this widget might want to provide the user with
668 // the ability to specify if all the children graph needs to be removed
669 // also. This can be coded in key modifiers. So provide the context.
670
671 int graph_count = plottableCount();
672
673 if(!graph_count)
674 {
675 // qDebug() << "Not a single graph in the plot widget. Doing
676 // nothing.";
677
678 event->accept();
679 return;
680 }
681
682 if(graph_count == 1)
683 {
684 // qDebug() << "A single graph is in the plot widget. Emitting a graph
685 // " "destruction requested signal for it:"
686 //<< graph();
687
689 }
690 else
691 {
692 // At this point we know there are more than one graph in the plot
693 // widget. We need to get the selected one (if any).
694 QList<QCPGraph *> selected_graph_list;
695
696 selected_graph_list = selectedGraphs();
697
698 if(!selected_graph_list.size())
699 {
700 event->accept();
701 return;
702 }
703
704 // qDebug() << "Number of selected graphs to be destrobyed:"
705 //<< selected_graph_list.size();
706
707 for(int iter = 0; iter < selected_graph_list.size(); ++iter)
708 {
709 // qDebug()
710 //<< "Emitting a graph destruction requested signal for graph:"
711 //<< selected_graph_list.at(iter);
712
714 this, selected_graph_list.at(iter), m_context);
715
716 // We do not do this, because we want the slot called by the
717 // signal above to handle that removal. Remember that it is not
718 // possible to delete graphs manually.
719 //
720 // removeGraph(selected_graph_list.at(iter));
721 }
722 event->accept();
723 }
724 }
725 // End of
726 // else if(event->key() == Qt::Key_Delete)
727 else if(event->key() == Qt::Key_T)
728 {
729 // The user wants to toggle the visibiity of the tracers.
731
733 hideTracers();
734 else
735 showTracers();
736
737 event->accept();
738 }
739 else if(event->key() == Qt::Key_Left || event->key() == Qt::Key_Right ||
740 event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)
741 {
742 return directionKeyReleaseEvent(event);
743 }
744 else if(event->key() == m_leftMousePseudoButtonKey || event->key() == m_rightMousePseudoButtonKey)
745 {
747 }
748 else if(event->key() == Qt::Key_S)
749 {
750 // The user is defining the size of the rhomboid fixed side. That could be
751 // either a vertical side (less intuitive) or a horizontal size (more
752 // intuitive, first exclusive implementation). But, in order to be able to
753 // perform identical integrations starting from non-transposed color maps
754 // and transposed color maps, the ability to define a vertical fixed size
755 // side of the rhomboid integration scope has become necessary.
756
757 // Check if the vertical displacement is significant (>= 10% of the color
758 // map height.
759
761 {
762 // The user is dragging the cursor vertically in a sufficient delta to
763 // consider that they are willing to define a vertical fixed size
764 // of the rhomboid integration scope.
765
769
770 // qDebug() << "Set m_context.m_integrationScopePolyHeight to"
771 // << m_context.m_integrationScopeRhombHeight
772 // << "upon release of S key";
773 }
774 else
775 {
776 // The user is dragging the cursor horiontally to define a horizontal
777 // fixed size of the rhomboid integration scope.
778
782
783 // qDebug() << "Set m_context.m_integrationScopePolyWidth to"
784 // << m_context.m_integrationScopeRhombWidth
785 // << "upon release of S key";
786 }
787 }
788 // At this point emit the signal, since we did not treat it. Maybe the
789 // consumer widget wants to know that the keyboard key was released.
790
792}
virtual void directionKeyReleaseEvent(QKeyEvent *event)
void plottableDestructionRequestedSignal(BasePlotWidget *base_plot_widget_p, QCPAbstractPlottable *plottable_p, const BasePlotContext &context)
virtual void spaceKeyReleaseEvent(QKeyEvent *event)
virtual bool isVerticalDisplacementAboveThreshold()
virtual void showTracers()
Show the traces (vertical and horizontal).
void keyReleaseEventSignal(const BasePlotContext &context)
virtual void restorePreviousAxesRangeHistory()
Go up one history element in the axis history.
virtual void hideTracers()
Hide the traces (vertical and horizontal).
virtual void mousePseudoButtonKeyReleaseEvent(QKeyEvent *event)

References directionKeyReleaseEvent(), hideTracers(), isVerticalDisplacementAboveThreshold(), keyReleaseEventSignal(), m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_integrationScopeRhombHeight, pappso::BasePlotContext::m_integrationScopeRhombWidth, pappso::BasePlotContext::m_keyboardModifiers, m_leftMousePseudoButtonKey, pappso::BasePlotContext::m_pressedKeyCode, pappso::BasePlotContext::m_releasedKeyCode, m_rightMousePseudoButtonKey, m_shouldTracersBeVisible, pappso::BasePlotContext::m_startDragPoint, mousePseudoButtonKeyReleaseEvent(), plottableDestructionRequestedSignal(), restorePreviousAxesRangeHistory(), showTracers(), and spaceKeyReleaseEvent().

Referenced by pappso::DriftSpecMassSpecColorMapPlotWidget::keyReleaseEvent(), pappso::DriftSpecTracePlotWidget::keyReleaseEvent(), pappso::MassSpecTracePlotWidget::keyReleaseEvent(), pappso::TicXicChromDriftSpecColorMapPlotWidget::keyReleaseEvent(), pappso::TicXicChromMassSpecColorMapPlotWidget::keyReleaseEvent(), and pappso::TicXicChromTracePlotWidget::keyReleaseEvent().

◆ keyReleaseEventSignal

void pappso::BasePlotWidget::keyReleaseEventSignal ( const BasePlotContext context)
signal

Referenced by keyReleaseEvent().

◆ lastCursorHoveredPointSignal

void pappso::BasePlotWidget::lastCursorHoveredPointSignal ( const QPointF &  pointf)
signal

◆ layerableLayerIndex()

int pappso::BasePlotWidget::layerableLayerIndex ( QCPLayerable *  layerable_p) const
protectedvirtual

Definition at line 203 of file baseplotwidget.cpp.

204{
205 if(layerable_p == nullptr)
206 qFatal("Programming error.");
207
208 QCPLayer *layer_p = layerable_p->layer();
209
210 for(int iter = 0; iter < layerCount(); ++iter)
211 {
212 if(layer(iter) == layer_p)
213 return iter;
214 }
215
216 return -1;
217}

◆ layerableLayerName()

QString pappso::BasePlotWidget::layerableLayerName ( QCPLayerable *  layerable_p) const
protectedvirtual

Definition at line 191 of file baseplotwidget.cpp.

192{
193 if(layerable_p == nullptr)
194 qFatal("Programming error.");
195
196 QCPLayer *layer_p = layerable_p->layer();
197
198 return layer_p->name();
199}

◆ mouseMoveHandler()

void pappso::BasePlotWidget::mouseMoveHandler ( QMouseEvent *  event)
virtual

KEYBOARD-related EVENTS.

MOUSE-related EVENTS

Reimplemented in pappso::DriftSpecMassSpecColorMapPlotWidget, pappso::DriftSpecTracePlotWidget, pappso::MassSpecTracePlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, and pappso::TicXicChromTracePlotWidget.

Definition at line 923 of file baseplotwidget.cpp.

924{
925
926 // If we have no focus, then get it. See setFocus() to understand why asking
927 // for focus is cosly and thus why we want to make this decision first.
928 if(!hasFocus())
929 setFocus();
930
931 // qDebug() << (graph() != nullptr);
932 // if(graph(0) != nullptr)
933 // { // check if the widget contains some graphs
934
935 // The event->button() must be by Qt instructions considered to be 0.
936
937 // Whatever happens, we want to store the plot coordinates of the current
938 // mouse cursor position (will be useful later for countless needs).
939
940 QPointF mousePoint = event->position();
941
942 // qDebug() << "local mousePoint position in pixels:" << mousePoint;
943
944 m_context.m_lastCursorHoveredPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
945 m_context.m_lastCursorHoveredPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
946
947 // qDebug() << "lastCursorHoveredPoint coord:"
948 //<< m_context.m_lastCursorHoveredPoint;
949
950 // Now, depending on the button(s) (if any) that are pressed or not, we
951 // have a different processing.
952
953 // qDebug();
954
955 if(m_context.m_pressedMouseButtons & Qt::LeftButton ||
956 m_context.m_pressedMouseButtons & Qt::RightButton)
958 else
960 // }
961 // qDebug();
962 event->accept();
963}
virtual void mouseMoveHandlerDraggingCursor()
virtual void mouseMoveHandlerNotDraggingCursor()
virtual void setFocus()
PLOT ITEMS : TRACER TEXT ITEMS...

References m_context, pappso::BasePlotContext::m_lastCursorHoveredPoint, pappso::BasePlotContext::m_pressedMouseButtons, mouseMoveHandlerDraggingCursor(), mouseMoveHandlerNotDraggingCursor(), and setFocus().

Referenced by pappso::DriftSpecMassSpecColorMapPlotWidget::mouseMoveHandler(), pappso::DriftSpecTracePlotWidget::mouseMoveHandler(), pappso::MassSpecTracePlotWidget::mouseMoveHandler(), pappso::TicXicChromDriftSpecColorMapPlotWidget::mouseMoveHandler(), pappso::TicXicChromMassSpecColorMapPlotWidget::mouseMoveHandler(), pappso::TicXicChromTracePlotWidget::mouseMoveHandler(), and setupWidget().

◆ mouseMoveHandlerDraggingCursor()

void pappso::BasePlotWidget::mouseMoveHandlerDraggingCursor ( )
virtual

Reimplemented in pappso::DriftSpecMassSpecColorMapPlotWidget, pappso::DriftSpecTracePlotWidget, pappso::MassSpecTracePlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, and pappso::TicXicChromTracePlotWidget.

Definition at line 1031 of file baseplotwidget.cpp.

1032{
1033 qDebug();
1034
1036
1037 // Now store the mouse position data into the the current drag point
1038 // member datum, that will be used in countless occasions later.
1040 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1041
1042 // When we drag (either keyboard or mouse), we hide the position markers
1043 // (black) and we show the start and end vertical markers for the region.
1044 // Then, we draw the horizontal region range marker that delimits
1045 // horizontally the dragged-over region.
1046
1047 if(mp_hPosTracerItem != nullptr)
1048 mp_hPosTracerItem->setVisible(false);
1049 if(mp_vPosTracerItem != nullptr)
1050 mp_vPosTracerItem->setVisible(false);
1051
1052 // Only bother with the tracers if the user wants them to be visible.
1054 {
1055
1056 // The vertical end tracer position must be refreshed.
1057 mp_vEndTracerItem->start->setCoords(m_context.m_currentDragPoint.x(), yAxis->range().upper);
1058
1059 mp_vEndTracerItem->end->setCoords(m_context.m_currentDragPoint.x(), yAxis->range().lower);
1060
1061 mp_vEndTracerItem->setVisible(true);
1062 }
1063
1064 // Whatever the button, when we are dealing with the axes, we do not
1065 // want to show any of the tracers.
1066
1068 {
1069 if(mp_hPosTracerItem != nullptr)
1070 mp_hPosTracerItem->setVisible(false);
1071 if(mp_vPosTracerItem != nullptr)
1072 mp_vPosTracerItem->setVisible(false);
1073
1074 if(mp_vStartTracerItem != nullptr)
1075 mp_vStartTracerItem->setVisible(false);
1076 if(mp_vEndTracerItem != nullptr)
1077 mp_vEndTracerItem->setVisible(false);
1078 }
1079 else
1080 {
1081 qDebug() << "Not moving the mouse cursor over any of the axes.";
1082
1083 // Since we are not dragging the mouse cursor over the axes, make sure
1084 // we store the drag directions in the context, as this might be
1085 // useful for later operations.
1086 qDebug() << "Recording the drag direction(s).";
1087
1089
1090 qDebug() << "Drag direction(s): " << m_context.dragDirectionsToString();
1091 }
1092
1093 // Because when we drag the mouse button (whatever the button) we need to
1094 // know what is the drag delta (distance between start point and current
1095 // point of the drag operation) on both axes, ask that these x|y deltas be
1096 // computed.
1098
1099 // Now deal with the BUTTON-SPECIFIC CODE.
1100
1101 if(m_context.m_mouseButtonsAtMousePress & Qt::LeftButton)
1102 {
1104 }
1105 else if(m_context.m_mouseButtonsAtMousePress & Qt::RightButton)
1106 {
1108 }
1109}
Qt::MouseButtons m_mouseButtonsAtMousePress
Q_INVOKABLE QString dragDirectionsToString() const
DragDirections recordDragDirections()
virtual void mouseMoveHandlerLeftButtonDraggingCursor()
virtual void calculateDragDeltas()
virtual void mouseMoveHandlerRightButtonDraggingCursor()

References calculateDragDeltas(), pappso::BasePlotContext::dragDirectionsToString(), m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_isMouseDragging, pappso::BasePlotContext::m_keyboardModifiers, pappso::BasePlotContext::m_lastCursorHoveredPoint, pappso::BasePlotContext::m_mouseButtonsAtMousePress, m_shouldTracersBeVisible, pappso::BasePlotContext::m_wasClickOnXAxis, pappso::BasePlotContext::m_wasClickOnYAxis, mouseMoveHandlerLeftButtonDraggingCursor(), mouseMoveHandlerRightButtonDraggingCursor(), mp_hPosTracerItem, mp_vEndTracerItem, mp_vPosTracerItem, mp_vStartTracerItem, and pappso::BasePlotContext::recordDragDirections().

Referenced by mouseMoveHandler(), pappso::DriftSpecMassSpecColorMapPlotWidget::mouseMoveHandlerDraggingCursor(), pappso::DriftSpecTracePlotWidget::mouseMoveHandlerDraggingCursor(), pappso::MassSpecTracePlotWidget::mouseMoveHandlerDraggingCursor(), pappso::TicXicChromDriftSpecColorMapPlotWidget::mouseMoveHandlerDraggingCursor(), pappso::TicXicChromMassSpecColorMapPlotWidget::mouseMoveHandlerDraggingCursor(), and pappso::TicXicChromTracePlotWidget::mouseMoveHandlerDraggingCursor().

◆ mouseMoveHandlerLeftButtonDraggingCursor()

void pappso::BasePlotWidget::mouseMoveHandlerLeftButtonDraggingCursor ( )
virtual

Definition at line 1113 of file baseplotwidget.cpp.

1114{
1115 qDebug() << "The left button is dragging.";
1116
1117 // Set the context.m_isMeasuringDistance to false, which later might be set
1118 // to true if effectively we are measuring a distance. This is required
1119 // because the derived widget classes might want to know if they have to
1120 // perform some action on the basis that context is measuring a distance,
1121 // for example the mass spectrum-specific widget might want to compute
1122 // deconvolutions.
1123
1125
1126 // Let's first check if the mouse drag operation originated on either
1127 // axis. In that case, the user is performing axis reframing or rescaling.
1128
1130 {
1131 // qDebug() << "Click was on one of the axes.";
1132
1133 if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1134 {
1135 // The user is asking a rescale of the plot.
1136
1137 // We know that we do not want the tracers when we perform axis
1138 // rescaling operations.
1139
1140 if(mp_hPosTracerItem != nullptr)
1141 mp_hPosTracerItem->setVisible(false);
1142 if(mp_vPosTracerItem != nullptr)
1143 mp_vPosTracerItem->setVisible(false);
1144
1145 if(mp_vStartTracerItem != nullptr)
1146 mp_vStartTracerItem->setVisible(false);
1147 if(mp_vEndTracerItem != nullptr)
1148 mp_vEndTracerItem->setVisible(false);
1149
1150 // This operation is particularly intensive, thus we want to
1151 // reduce the number of calculations by skipping this calculation
1152 // a number of times. The user can ask for this feature by
1153 // clicking the 'Q' letter.
1154
1155 if(m_context.m_pressedKeyCode == Qt::Key_Q)
1156 {
1158 {
1160 return;
1161 }
1162 else
1163 {
1165 }
1166 }
1167
1168 // qDebug() << "Asking that the axes be rescaled.";
1169
1170 axisRescale();
1171 }
1172 else
1173 {
1174 // The user was simply dragging the axis. Just pan, that is slide
1175 // the plot in the same direction as the mouse movement and with the
1176 // same amplitude.
1177
1178 // qDebug() << "Asking that the axes be panned.";
1179
1180 axisPan();
1181 }
1182
1183 return;
1184 }
1185
1186 // At this point we understand that the user was not performing any
1187 // panning/rescaling operation by clicking on any one of the axes.. Go on
1188 // with other possibilities.
1189
1190 // Let's check if the user is actually drawing a rectangle (covering a
1191 // real area) or is drawing a line.
1192
1193 qDebug() << "The mouse dragging did not originate on an axis.";
1194
1196 {
1197 // qDebug() << "Apparently the selection is two-dimensional.";
1198
1199 // When we draw a two-dimensional integration scope, the tracers are of no
1200 // use.
1201
1202 if(mp_hPosTracerItem != nullptr)
1203 mp_hPosTracerItem->setVisible(false);
1204 if(mp_vPosTracerItem != nullptr)
1205 mp_vPosTracerItem->setVisible(false);
1206
1207 if(mp_vStartTracerItem != nullptr)
1208 mp_vStartTracerItem->setVisible(false);
1209 if(mp_vEndTracerItem != nullptr)
1210 mp_vEndTracerItem->setVisible(false);
1211
1212 // Draw the rectangle, false, not as line segment and
1213 // false, not for integration
1214 drawSelectionRectangleAndPrepareZoom(false /*as_line_segment*/, false /* for_integration*/);
1215
1216 // Draw the selection width/height text
1219 }
1220 else
1221 {
1222 // qDebug() << "Apparently we are measuring a delta.";
1223
1224 // Draw the rectangle, true, as line segment and
1225 // false, not for integration
1227
1228 // The pure position tracers should be hidden.
1229 if(mp_hPosTracerItem != nullptr)
1230 mp_hPosTracerItem->setVisible(true);
1231 if(mp_vPosTracerItem != nullptr)
1232 mp_vPosTracerItem->setVisible(true);
1233
1234 // Then, make sure the region range vertical tracers are visible.
1235 if(mp_vStartTracerItem != nullptr)
1236 mp_vStartTracerItem->setVisible(true);
1237 if(mp_vEndTracerItem != nullptr)
1238 mp_vEndTracerItem->setVisible(true);
1239
1240 // Draw the selection width text
1242 }
1243}
int m_mouseMoveHandlerSkipAmount
How many mouse move events must be skipped *‍/.
virtual void drawSelectionRectangleAndPrepareZoom(bool as_line_segment=false, bool for_integration=false)
int m_mouseMoveHandlerSkipCount
Counter to handle the "fat data" mouse move event handling.
virtual void drawXScopeSpanFeatures()
virtual void drawYScopeSpanFeatures()
virtual void axisRescale()
RANGE-related functions.

References axisPan(), axisRescale(), drawSelectionRectangleAndPrepareZoom(), drawXScopeSpanFeatures(), drawYScopeSpanFeatures(), isVerticalDisplacementAboveThreshold(), m_context, pappso::BasePlotContext::m_isMeasuringDistance, pappso::BasePlotContext::m_keyboardModifiers, m_mouseMoveHandlerSkipAmount, m_mouseMoveHandlerSkipCount, pappso::BasePlotContext::m_pressedKeyCode, pappso::BasePlotContext::m_wasClickOnXAxis, pappso::BasePlotContext::m_wasClickOnYAxis, mp_hPosTracerItem, mp_vEndTracerItem, mp_vPosTracerItem, and mp_vStartTracerItem.

Referenced by mouseMoveHandlerDraggingCursor().

◆ mouseMoveHandlerNotDraggingCursor()

void pappso::BasePlotWidget::mouseMoveHandlerNotDraggingCursor ( )
virtual

Reimplemented in pappso::DriftSpecMassSpecColorMapPlotWidget, pappso::DriftSpecTracePlotWidget, pappso::MassSpecTracePlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, and pappso::TicXicChromTracePlotWidget.

Definition at line 967 of file baseplotwidget.cpp.

968{
969
970 // qDebug();
972
973 // qDebug();
974 // We are not dragging the mouse (no button pressed), simply let this
975 // widget's consumer know the position of the cursor and update the markers.
976 // The consumer of this widget will update mouse cursor position at
977 // m_context.m_lastCursorHoveredPoint if so needed.
978
980
981 // qDebug();
982
983 // We are not dragging, so we do not show the region end tracer we only
984 // show the anchoring start trace that might be of use if the user starts
985 // using the arrow keys to move the cursor.
986 if(mp_vEndTracerItem != nullptr)
987 mp_vEndTracerItem->setVisible(false);
988
989 // qDebug();
990 // Only bother with the tracers if the user wants them to be visible.
991 // Their crossing point must be exactly at the last cursor-hovered point.
992
994 {
995 // We are not dragging, so only show the position markers (v and h);
996
997 // qDebug();
998 if(mp_hPosTracerItem != nullptr)
999 {
1000 // Horizontal position tracer.
1001 mp_hPosTracerItem->setVisible(true);
1002 mp_hPosTracerItem->start->setCoords(xAxis->range().lower,
1004 mp_hPosTracerItem->end->setCoords(xAxis->range().upper,
1006 }
1007
1008 // qDebug();
1009 // Vertical position tracer.
1010 if(mp_vPosTracerItem != nullptr)
1011 {
1012 mp_vPosTracerItem->setVisible(true);
1013
1014 mp_vPosTracerItem->setVisible(true);
1016 yAxis->range().upper);
1018 yAxis->range().lower);
1019 }
1020
1021 // qDebug();
1022 replot();
1023 }
1024
1025
1026 return;
1027}
void lastCursorHoveredPointSignal(const QPointF &pointf)

References lastCursorHoveredPointSignal(), m_context, pappso::BasePlotContext::m_isMouseDragging, pappso::BasePlotContext::m_lastCursorHoveredPoint, m_shouldTracersBeVisible, mp_hPosTracerItem, mp_vEndTracerItem, and mp_vPosTracerItem.

Referenced by mouseMoveHandler(), pappso::DriftSpecMassSpecColorMapPlotWidget::mouseMoveHandlerNotDraggingCursor(), pappso::DriftSpecTracePlotWidget::mouseMoveHandlerNotDraggingCursor(), pappso::MassSpecTracePlotWidget::mouseMoveHandlerNotDraggingCursor(), pappso::TicXicChromDriftSpecColorMapPlotWidget::mouseMoveHandlerNotDraggingCursor(), pappso::TicXicChromMassSpecColorMapPlotWidget::mouseMoveHandlerNotDraggingCursor(), and pappso::TicXicChromTracePlotWidget::mouseMoveHandlerNotDraggingCursor().

◆ mouseMoveHandlerRightButtonDraggingCursor()

void pappso::BasePlotWidget::mouseMoveHandlerRightButtonDraggingCursor ( )
virtual

Definition at line 1247 of file baseplotwidget.cpp.

1248{
1249 // qDebug() << "The right button is dragging.";
1250
1251 // Set the context.m_isMeasuringDistance to false, which later might be set
1252 // to true if effectively we are measuring a distance. This is required
1253 // because the derived widgets might want to know if they have to perform
1254 // some action on the basis that context is measuring a distance, for
1255 // example the mass spectrum-specific widget might want to compute
1256 // deconvolutions.
1257
1259
1261 {
1262 // qDebug() << "Apparently the selection has height.";
1263
1264 // When we draw a rectangle the tracers are of no use.
1265
1266 if(mp_hPosTracerItem != nullptr)
1267 mp_hPosTracerItem->setVisible(false);
1268 if(mp_vPosTracerItem != nullptr)
1269 mp_vPosTracerItem->setVisible(false);
1270
1271 if(mp_vStartTracerItem != nullptr)
1272 mp_vStartTracerItem->setVisible(false);
1273 if(mp_vEndTracerItem != nullptr)
1274 mp_vEndTracerItem->setVisible(false);
1275
1276 // Draw the rectangle, false for as_line_segment and true for
1277 // integration.
1279
1280 // Draw the selection width/height text
1283 }
1284 else
1285 {
1286 // qDebug() << "Apparently the selection is a not a rectangle.";
1287
1288 // Draw the rectangle, true as line segment and
1289 // true for integration
1291
1292 // Draw the selection width text
1294 }
1295}

References drawSelectionRectangleAndPrepareZoom(), drawXScopeSpanFeatures(), drawYScopeSpanFeatures(), isVerticalDisplacementAboveThreshold(), m_context, pappso::BasePlotContext::m_isMeasuringDistance, mp_hPosTracerItem, mp_vEndTracerItem, mp_vPosTracerItem, and mp_vStartTracerItem.

Referenced by mouseMoveHandlerDraggingCursor().

◆ mousePressEventSignal

void pappso::BasePlotWidget::mousePressEventSignal ( const BasePlotContext context)
signal

Referenced by mousePressHandler().

◆ mousePressHandler()

void pappso::BasePlotWidget::mousePressHandler ( QMouseEvent *  event)
virtual

KEYBOARD-related EVENTS.

MOUSE-related EVENTS

Reimplemented in pappso::DriftSpecMassSpecColorMapPlotWidget, pappso::DriftSpecTracePlotWidget, pappso::MassSpecTracePlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, and pappso::TicXicChromTracePlotWidget.

Definition at line 1299 of file baseplotwidget.cpp.

1300{
1301 // qDebug() << "Entering";
1302
1303 // When the user clicks this widget it has to take focus.
1304 setFocus();
1305
1306 QPointF mousePoint = event->position();
1307
1308 m_context.m_lastPressedMouseButton = event->button();
1309 m_context.m_mouseButtonsAtMousePress = event->buttons();
1310
1311 // The pressedMouseButtons must continually inform on the status of
1312 // pressed buttons so add the pressed button.
1313 m_context.m_pressedMouseButtons |= event->button();
1314
1315 // qDebug().noquote() << m_context.toString();
1316
1317 // In all the processing of the events, we need to know if the user is
1318 // clicking somewhere with the intent to change the plot ranges (reframing
1319 // or rescaling the plot).
1320 //
1321 // Reframing the plot means that the new x and y axes ranges are modified
1322 // so that they match the region that the user has encompassed by left
1323 // clicking the mouse and dragging it over the plot. That is we reframe
1324 // the plot so that it contains only the "selected" region.
1325 //
1326 // Rescaling the plot means the the new x|y axis range is modified such
1327 // that the lower axis range is constant and the upper axis range is moved
1328 // either left or right by the same amont as the x|y delta encompassed by
1329 // the user moving the mouse. The axis is thus either compressed (mouse
1330 // movement is leftwards) or un-compressed (mouse movement is rightwards).
1331
1332 // There are two ways to perform axis range modifications:
1333 //
1334 // 1. By clicking on any of the axes
1335 // 2. By clicking on the plot region but using keyboard key modifiers,
1336 // like Alt and Ctrl.
1337 //
1338 // We need to know both cases separately which is why we need to perform a
1339 // number of tests below.
1340
1341 // Let's check if the click is on the axes, either X or Y, because that
1342 // will allow us to take proper actions.
1343
1344 if(isClickOntoXAxis(mousePoint))
1345 {
1346 // The X axis was clicked upon, we need to document that:
1347 // qDebug() << __FILE__ << __LINE__
1348 //<< "Layout element is axisRect and actually on an X axis part.";
1349
1351
1352 // int currentInteractions = interactions();
1353 // currentInteractions |= QCP::iRangeDrag;
1354 // setInteractions((QCP::Interaction)currentInteractions);
1355 // axisRect()->setRangeDrag(xAxis->orientation());
1356 }
1357 else
1359
1360 if(isClickOntoYAxis(mousePoint))
1361 {
1362 // The Y axis was clicked upon, we need to document that:
1363 // qDebug() << __FILE__ << __LINE__
1364 //<< "Layout element is axisRect and actually on an Y axis part.";
1365
1367
1368 // int currentInteractions = interactions();
1369 // currentInteractions |= QCP::iRangeDrag;
1370 // setInteractions((QCP::Interaction)currentInteractions);
1371 // axisRect()->setRangeDrag(yAxis->orientation());
1372 }
1373 else
1375
1376 // At this point, let's see if we need to remove the QCP::iRangeDrag bit:
1377
1379 {
1380 // qDebug() << __FILE__ << __LINE__
1381 // << "Click outside of axes.";
1382
1383 // int currentInteractions = interactions();
1384 // currentInteractions = currentInteractions & ~QCP::iRangeDrag;
1385 // setInteractions((QCP::Interaction)currentInteractions);
1386 }
1387
1388 m_context.m_startDragPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
1389 m_context.m_startDragPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
1390
1391 // Now install the vertical start tracer at the last cursor hovered
1392 // position.
1393 if((m_shouldTracersBeVisible) && (mp_vStartTracerItem != nullptr))
1394 mp_vStartTracerItem->setVisible(true);
1395
1396 if(mp_vStartTracerItem != nullptr)
1397 {
1399 yAxis->range().upper);
1401 yAxis->range().lower);
1402 }
1403
1404 replot();
1405
1407
1408 // qDebug() << "Exiting after having emitted mousePressEventSignal with base context:"
1409 // << m_context.toString();
1410}
Qt::MouseButtons m_lastPressedMouseButton
void mousePressEventSignal(const BasePlotContext &context)
bool isClickOntoYAxis(const QPointF &mousePoint)
bool isClickOntoXAxis(const QPointF &mousePoint)

References isClickOntoXAxis(), isClickOntoYAxis(), m_context, pappso::BasePlotContext::m_lastCursorHoveredPoint, pappso::BasePlotContext::m_lastPressedMouseButton, pappso::BasePlotContext::m_mouseButtonsAtMousePress, pappso::BasePlotContext::m_pressedMouseButtons, m_shouldTracersBeVisible, pappso::BasePlotContext::m_startDragPoint, pappso::BasePlotContext::m_wasClickOnXAxis, pappso::BasePlotContext::m_wasClickOnYAxis, mousePressEventSignal(), mp_vStartTracerItem, and setFocus().

Referenced by pappso::DriftSpecMassSpecColorMapPlotWidget::mousePressHandler(), pappso::DriftSpecTracePlotWidget::mousePressHandler(), pappso::MassSpecTracePlotWidget::mousePressHandler(), pappso::TicXicChromDriftSpecColorMapPlotWidget::mousePressHandler(), pappso::TicXicChromMassSpecColorMapPlotWidget::mousePressHandler(), pappso::TicXicChromTracePlotWidget::mousePressHandler(), mousePseudoButtonKeyReleaseEvent(), and setupWidget().

◆ mousePseudoButtonKeyPressEvent()

void pappso::BasePlotWidget::mousePseudoButtonKeyPressEvent ( QKeyEvent *  event)
virtual

Definition at line 853 of file baseplotwidget.cpp.

854{
855 // qDebug();
856}

Referenced by keyPressEvent().

◆ mousePseudoButtonKeyReleaseEvent()

void pappso::BasePlotWidget::mousePseudoButtonKeyReleaseEvent ( QKeyEvent *  event)
virtual

Definition at line 860 of file baseplotwidget.cpp.

861{
862
863 QPointF pixel_coordinates(xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()),
864 yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()));
865
866 Qt::MouseButton button = Qt::NoButton;
867 QEvent::Type q_event_type = QEvent::MouseButtonPress;
868
869 if(event->key() == m_leftMousePseudoButtonKey)
870 {
871 // Toggles the left mouse button on/off
872
873 button = Qt::LeftButton;
874
876
878 q_event_type = QEvent::MouseButtonPress;
879 else
880 q_event_type = QEvent::MouseButtonRelease;
881 }
882 else if(event->key() == m_rightMousePseudoButtonKey)
883 {
884 // Toggles the right mouse button.
885
886 button = Qt::RightButton;
887
889
891 q_event_type = QEvent::MouseButtonPress;
892 else
893 q_event_type = QEvent::MouseButtonRelease;
894 }
895
896 // qDebug() << "pressed/released pseudo button:" << button
897 //<< "q_event_type:" << q_event_type;
898
899 // Synthesize a QMouseEvent and use it.
900
901 QMouseEvent *mouse_event_p = new QMouseEvent(q_event_type,
902 pixel_coordinates,
903 mapToGlobal(pixel_coordinates.toPoint()),
904 mapToGlobal(pixel_coordinates.toPoint()),
905 button,
906 button,
908 Qt::MouseEventSynthesizedByApplication);
909
910 if(q_event_type == QEvent::MouseButtonPress)
911 mousePressHandler(mouse_event_p);
912 else
913 mouseReleaseHandler(mouse_event_p);
914
915 // event->accept();
916}
virtual void mousePressHandler(QMouseEvent *event)
KEYBOARD-related EVENTS.
virtual void mouseReleaseHandler(QMouseEvent *event)

References m_context, pappso::BasePlotContext::m_isLeftPseudoButtonKeyPressed, pappso::BasePlotContext::m_isRightPseudoButtonKeyPressed, pappso::BasePlotContext::m_keyboardModifiers, pappso::BasePlotContext::m_lastCursorHoveredPoint, m_leftMousePseudoButtonKey, m_rightMousePseudoButtonKey, mousePressHandler(), and mouseReleaseHandler().

Referenced by keyReleaseEvent().

◆ mouseReleaseEventSignal

void pappso::BasePlotWidget::mouseReleaseEventSignal ( const BasePlotContext context)
signal

Referenced by mouseReleaseHandler().

◆ mouseReleaseHandler()

void pappso::BasePlotWidget::mouseReleaseHandler ( QMouseEvent *  event)
virtual

Reimplemented in pappso::DriftSpecMassSpecColorMapPlotWidget, pappso::DriftSpecTracePlotWidget, pappso::MassSpecTracePlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, and pappso::TicXicChromTracePlotWidget.

Definition at line 1414 of file baseplotwidget.cpp.

1415{
1416 // qDebug() << "Entering";
1417
1418 // Now the real code of this function.
1419
1420 m_context.m_lastReleasedMouseButton = event->button();
1421
1422 // The event->buttons() is the description of the buttons that are pressed
1423 // at the moment the handler is invoked, that is now. If left and right were
1424 // pressed, and left was released, event->buttons() would be right.
1425 m_context.m_mouseButtonsAtMouseRelease = event->buttons();
1426
1427 // The pressedMouseButtons must continually inform on the status of pressed
1428 // buttons so remove the released button.
1429 m_context.m_pressedMouseButtons ^= event->button();
1430
1431 // qDebug().noquote() << m_context.toString();
1432
1433 // We'll need to know if modifiers were pressed a the moment the user
1434 // released the mouse button.
1435 m_context.m_keyboardModifiers = QGuiApplication::keyboardModifiers();
1436
1438 {
1439 // Let the user know that the mouse was *not* being dragged.
1441
1442 event->accept();
1443
1444 return;
1445 }
1446
1447 // Let the user know that the mouse was being dragged.
1449
1450 // We cannot hide all items in one go because we rely on their visibility
1451 // to know what kind of dragging operation we need to perform (line-only
1452 // X-based zoom or rectangle-based X- and Y-based zoom, for example). The
1453 // only thing we know is that we can make the text invisible.
1454
1455 // Same for the x delta text item
1456 mp_xDeltaTextItem->setVisible(false);
1457 mp_yDeltaTextItem->setVisible(false);
1458
1459 // We do not show the end vertical region range marker.
1460 mp_vEndTracerItem->setVisible(false);
1461
1462 // Horizontal position tracer.
1463 mp_hPosTracerItem->setVisible(true);
1464 mp_hPosTracerItem->start->setCoords(xAxis->range().lower, m_context.m_lastCursorHoveredPoint.y());
1465 mp_hPosTracerItem->end->setCoords(xAxis->range().upper, m_context.m_lastCursorHoveredPoint.y());
1466
1467 // Vertical position tracer.
1468 mp_vPosTracerItem->setVisible(true);
1469
1470 mp_vPosTracerItem->setVisible(true);
1471 mp_vPosTracerItem->start->setCoords(m_context.m_lastCursorHoveredPoint.x(), yAxis->range().upper);
1472 mp_vPosTracerItem->end->setCoords(m_context.m_lastCursorHoveredPoint.x(), yAxis->range().lower);
1473
1474 // Force replot now because later that call might not be performed.
1475 replot();
1476
1477 // If we were using the "quantum" display for the rescale of the axes
1478 // using the Ctrl-modified left button click drag in the axes, then reset
1479 // the count to 0.
1481
1482 // By definition we are stopping the drag operation by releasing the mouse
1483 // button. Whatever that mouse button was pressed before and if there was
1484 // one pressed before. We cannot set that boolean value to false before
1485 // this place, because we call a number of routines above that need to know
1486 // that dragging was occurring. Like mouseReleaseHandledEvent(event) for
1487 // example.
1488
1490
1491 // Now that we have computed the useful ranges, we need to check what to do
1492 // depending on the button that was pressed.
1493
1494 if(m_context.m_lastReleasedMouseButton == Qt::LeftButton)
1495 {
1497 }
1498 else if(m_context.m_lastReleasedMouseButton == Qt::RightButton)
1499 {
1501 }
1502
1503 event->accept();
1504
1505 // Before returning, emit the signal for the user of
1506 // this class consumption.
1507 // qDebug() << "Emitting mouseReleaseEventSignal.";
1509
1510 // qDebug() << "Exiting after having emitted mouseReleaseEventSignal with base context:"
1511 // << m_context.toString();
1512
1513 return;
1514}
Qt::MouseButtons m_mouseButtonsAtMouseRelease
Qt::MouseButtons m_lastReleasedMouseButton
virtual void mouseReleaseHandlerRightButton()
virtual void mouseReleaseHandlerLeftButton()
void mouseReleaseEventSignal(const BasePlotContext &context)

References m_context, pappso::BasePlotContext::m_isMouseDragging, pappso::BasePlotContext::m_keyboardModifiers, pappso::BasePlotContext::m_lastCursorHoveredPoint, pappso::BasePlotContext::m_lastReleasedMouseButton, pappso::BasePlotContext::m_mouseButtonsAtMouseRelease, m_mouseMoveHandlerSkipCount, pappso::BasePlotContext::m_pressedMouseButtons, pappso::BasePlotContext::m_wasMouseDragging, mouseReleaseEventSignal(), mouseReleaseHandlerLeftButton(), mouseReleaseHandlerRightButton(), mp_hPosTracerItem, mp_vEndTracerItem, mp_vPosTracerItem, mp_xDeltaTextItem, and mp_yDeltaTextItem.

Referenced by mousePseudoButtonKeyReleaseEvent(), pappso::DriftSpecMassSpecColorMapPlotWidget::mouseReleaseHandler(), pappso::DriftSpecTracePlotWidget::mouseReleaseHandler(), pappso::MassSpecTracePlotWidget::mouseReleaseHandler(), pappso::TicXicChromDriftSpecColorMapPlotWidget::mouseReleaseHandler(), pappso::TicXicChromMassSpecColorMapPlotWidget::mouseReleaseHandler(), pappso::TicXicChromTracePlotWidget::mouseReleaseHandler(), and setupWidget().

◆ mouseReleaseHandlerLeftButton()

void pappso::BasePlotWidget::mouseReleaseHandlerLeftButton ( )
virtual

Definition at line 1518 of file baseplotwidget.cpp.

1519{
1520 // qDebug();
1521
1523 {
1524
1525 // When the mouse move handler pans the plot, we cannot store each axes
1526 // range history element that would mean store a huge amount of such
1527 // elements, as many element as there are mouse move event handled by
1528 // the Qt event queue. But we can store an axis range history element
1529 // for the last situation of the mouse move: when the button is
1530 // released:
1531
1533
1534 // qDebug() << "emit plotRangesChangedSignal(m_context);"
1535
1537
1538 replot();
1539
1540 // Nothing else to do.
1541 return;
1542 }
1543
1544 // There are two possibilities:
1545 //
1546 // 1. The full integration scope (four lines) were currently drawn, which
1547 // means the user was willing to perform a zoom operation.
1548 //
1549 // 2. Only the first top line was drawn, which means the user was dragging
1550 // the cursor horizontally. That might have two ends, as shown below.
1551
1552 // So, first check what is drawn of the selection polygon.
1553
1555
1556 // Now that we know what was currently drawn of the selection polygon, we
1557 // can remove it. true to reset the values to 0.
1559
1560 // Force replot now because later that call might not be performed.
1561 replot();
1562
1563 if(selection_drawing_lines == SelectionDrawingLines::FULL_POLYGON)
1564 {
1565 // qDebug() << "Yes, the full polygon was visible";
1566
1567 // If we were dragging with the left button pressed and could draw a
1568 // rectangle, then we were preparing a zoom operation. Let's bring that
1569 // operation to its accomplishment.
1570
1571 axisZoom();
1572
1573 return;
1574 }
1575 else if(selection_drawing_lines == SelectionDrawingLines::TOP_LINE)
1576 {
1577 // qDebug() << "No, only the top line of the full polygon was visible";
1578
1579 // The user was dragging the left mouse cursor and that may mean they
1580 // were measuring a distance or willing to perform a special zoom
1581 // operation if the Ctrl key was down.
1582
1583 // If the user started by clicking in the plot region, dragged the mouse
1584 // cursor with the left button and pressed the Ctrl modifier, then that
1585 // means that they wanted to do a rescale over the x-axis in the form of
1586 // a reframing.
1587
1588 if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1589 {
1590 return axisReframe();
1591 }
1592 }
1593 // else
1594 // qDebug() << "Another possibility.";
1595}
virtual SelectionDrawingLines whatIsVisibleOfTheSelectionRectangle()
SelectionDrawingLines

References axisReframe(), axisZoom(), pappso::FULL_POLYGON, hideSelectionRectangle(), m_context, pappso::BasePlotContext::m_keyboardModifiers, pappso::BasePlotContext::m_wasClickOnXAxis, pappso::BasePlotContext::m_wasClickOnYAxis, plotRangesChangedSignal(), pappso::TOP_LINE, updateAxesRangeHistory(), and whatIsVisibleOfTheSelectionRectangle().

Referenced by mouseReleaseHandler().

◆ mouseReleaseHandlerRightButton()

void pappso::BasePlotWidget::mouseReleaseHandlerRightButton ( )
virtual

Definition at line 1599 of file baseplotwidget.cpp.

1600{
1601 // qDebug();
1602 // The right button is used for the integrations. Not for axis range
1603 // operations. So all we have to do is remove the various graphics items and
1604 // send a signal with the context that contains all the data required by the
1605 // user to perform the integrations over the right plot regions.
1606
1607 // Whatever we were doing we need to make the selection line invisible:
1608
1609 if(mp_xDeltaTextItem->visible())
1610 mp_xDeltaTextItem->setVisible(false);
1611 if(mp_yDeltaTextItem->visible())
1612 mp_yDeltaTextItem->setVisible(false);
1613
1614 // Also make the vertical end tracer invisible.
1615 mp_vEndTracerItem->setVisible(false);
1616
1617 // Once the integration is asked for, then the selection rectangle if of no
1618 // more use.
1620
1621 // Force replot now because later that call might not be performed.
1622 replot();
1623
1624 // Note that we only request an integration if the x-axis delta is enough.
1625
1626 double x_delta_pixel = fabs(xAxis->coordToPixel(m_context.m_currentDragPoint.x()) -
1627 xAxis->coordToPixel(m_context.m_startDragPoint.x()));
1628
1629 if(x_delta_pixel > 3)
1630 {
1631 // qDebug() << "Emitting integrationRequestedSignal(m_context)";
1633 }
1634 // else
1635 // qDebug() << "Not asking for integration.";
1636}
void integrationRequestedSignal(const BasePlotContext &context)

References hideSelectionRectangle(), integrationRequestedSignal(), m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_startDragPoint, mp_vEndTracerItem, mp_xDeltaTextItem, and mp_yDeltaTextItem.

Referenced by mouseReleaseHandler().

◆ mouseWheelEventSignal

void pappso::BasePlotWidget::mouseWheelEventSignal ( const BasePlotContext context)
signal

Referenced by mouseWheelHandler().

◆ mouseWheelHandler()

void pappso::BasePlotWidget::mouseWheelHandler ( QWheelEvent *  event)
virtual

Definition at line 1640 of file baseplotwidget.cpp.

1641{
1642 // We should record the new range values each time the wheel is used to
1643 // zoom/unzoom.
1644
1645 m_context.m_xRange = QCPRange(xAxis->range());
1646 m_context.m_yRange = QCPRange(yAxis->range());
1647
1648 // qDebug() << "New x range: " << m_context.m_xRange;
1649 // qDebug() << "New y range: " << m_context.m_yRange;
1650
1652
1655
1656 event->accept();
1657}
void mouseWheelEventSignal(const BasePlotContext &context)

References m_context, pappso::BasePlotContext::m_xRange, pappso::BasePlotContext::m_yRange, mouseWheelEventSignal(), plotRangesChangedSignal(), and updateAxesRangeHistory().

Referenced by setupWidget().

◆ moveMouseCursorGraphCoordToGlobal()

void pappso::BasePlotWidget::moveMouseCursorGraphCoordToGlobal ( QPointF  plot_coordinates)
virtual

Definition at line 1787 of file baseplotwidget.cpp.

1788{
1789 // First convert the graph coordinates to pixel coordinates.
1790
1791 QPointF pixels_coordinates(xAxis->coordToPixel(graph_coordinates.x()),
1792 yAxis->coordToPixel(graph_coordinates.y()));
1793
1794 moveMouseCursorPixelCoordToGlobal(pixels_coordinates.toPoint());
1795}

References moveMouseCursorPixelCoordToGlobal().

◆ moveMouseCursorPixelCoordToGlobal()

void pappso::BasePlotWidget::moveMouseCursorPixelCoordToGlobal ( QPointF  local_coordinates)
virtual

Definition at line 1799 of file baseplotwidget.cpp.

1800{
1801 // qDebug() << "Calling set pos with new cursor position.";
1802 QCursor::setPos(mapToGlobal(pixel_coordinates.toPoint()));
1803}

Referenced by horizontalMoveMouseCursorCountPixels(), moveMouseCursorGraphCoordToGlobal(), and verticalMoveMouseCursorCountPixels().

◆ plotRangesChangedSignal

◆ plottableDestructionRequestedSignal

void pappso::BasePlotWidget::plottableDestructionRequestedSignal ( BasePlotWidget base_plot_widget_p,
QCPAbstractPlottable *  plottable_p,
const BasePlotContext context 
)
signal

Referenced by keyReleaseEvent().

◆ plottableSelectionChangedSignal

void pappso::BasePlotWidget::plottableSelectionChangedSignal ( QCPAbstractPlottable *  plottable_p,
bool  selected 
)
signal

◆ redrawPlotBackground()

void pappso::BasePlotWidget::redrawPlotBackground ( QWidget *  focusedPlotWidget)
virtual

Redraw the background of the focusedPlotWidget plot widget.

Definition at line 3249 of file baseplotwidget.cpp.

3250{
3251 if(focusedPlotWidget == nullptr)
3252 throw ExceptionNotPossible(
3253 "baseplotwidget.cpp @ redrawPlotBackground(QWidget *focusedPlotWidget "
3254 "-- "
3255 "ERROR focusedPlotWidget cannot be nullptr.");
3256
3257 if(dynamic_cast<QWidget *>(this) != focusedPlotWidget)
3258 {
3259 // The focused widget is not *this widget. We should make sure that
3260 // we were not the one that had the focus, because in this case we
3261 // need to redraw an unfocused background.
3262
3263 axisRect()->setBackground(m_unfocusedBrush);
3264 }
3265 else
3266 {
3267 axisRect()->setBackground(m_focusedBrush);
3268 }
3269
3270 replot();
3271}
QBrush m_focusedBrush
Color used for the background of focused plot.
QBrush m_unfocusedBrush
Color used for the background of unfocused plot.

References m_focusedBrush, and m_unfocusedBrush.

◆ replotWithAxesRanges()

void pappso::BasePlotWidget::replotWithAxesRanges ( QCPRange  xAxisRange,
QCPRange  yAxisRange,
Enums::Axis  axis 
)
virtual

Definition at line 2174 of file baseplotwidget.cpp.

2175{
2176 // qDebug() << "With axis:" << (int)axis;
2177
2178 if(static_cast<int>(axis) & static_cast<int>(Enums::Axis::x))
2179 {
2180 xAxis->setRange(xAxisRange.lower, xAxisRange.upper);
2181 }
2182
2183 if(static_cast<int>(axis) & static_cast<int>(Enums::Axis::y))
2184 {
2185 yAxis->setRange(yAxisRange.lower, yAxisRange.upper);
2186 }
2187
2188 // We do not want to update the history, because there would be way too
2189 // much history items, since this function is called upon mouse moving
2190 // handling and not only during mouse release events.
2191 // updateAxesRangeHistory();
2192
2193 replot();
2194}

References pappso::Enums::x, and pappso::Enums::y.

◆ replotWithAxisRangeX()

void pappso::BasePlotWidget::replotWithAxisRangeX ( double  lower,
double  upper 
)
virtual

Definition at line 2198 of file baseplotwidget.cpp.

2199{
2200 // qDebug();
2201
2202 xAxis->setRange(lower, upper);
2203
2204 replot();
2205}

◆ replotWithAxisRangeY()

void pappso::BasePlotWidget::replotWithAxisRangeY ( double  lower,
double  upper 
)
virtual

Definition at line 2209 of file baseplotwidget.cpp.

2210{
2211 // qDebug();
2212
2213 yAxis->setRange(lower, upper);
2214
2215 replot();
2216}

◆ resetAxesRangeHistory()

void pappso::BasePlotWidget::resetAxesRangeHistory ( )
virtual

Definition at line 473 of file baseplotwidget.cpp.

474{
475 m_xAxisRangeHistory.clear();
476 m_yAxisRangeHistory.clear();
477
478 m_xAxisRangeHistory.push_back(new QCPRange(xAxis->range()));
479 m_yAxisRangeHistory.push_back(new QCPRange(yAxis->range()));
480
481 // qDebug() << "size of history:" << m_xAxisRangeHistory.size()
482 //<< "setting index to 0";
483
484 // qDebug() << "resetting axes history to values:" << xAxis->range().lower
485 //<< "--" << xAxis->range().upper << "and" << yAxis->range().lower
486 //<< "--" << yAxis->range().upper;
487
489}
std::size_t m_lastAxisRangeHistoryIndex
Index of the last axis range history item.

References m_lastAxisRangeHistoryIndex, m_xAxisRangeHistory, and m_yAxisRangeHistory.

Referenced by pappso::BaseColorMapPlotWidget::addColorMap(), pappso::BaseColorMapPlotWidget::addColorMap(), pappso::BaseTracePlotWidget::addTrace(), axisDoubleClickHandler(), pappso::BaseTracePlotWidget::axisDoubleClickHandler(), pappso::BaseTracePlotWidget::clearGraphData(), and pappso::BaseTracePlotWidget::setGraphData().

◆ resetSelectionRectangle()

void pappso::BasePlotWidget::resetSelectionRectangle ( )
virtual

Definition at line 3172 of file baseplotwidget.cpp.

3173{
3174 std::const_pointer_cast<IntegrationScopeBase>(m_context.msp_integrationScope)->reset();
3175}

References m_context, and pappso::BasePlotContext::msp_integrationScope.

Referenced by hideSelectionRectangle().

◆ restoreAxesRangeHistory()

void pappso::BasePlotWidget::restoreAxesRangeHistory ( std::size_t  index)
virtual

Get the axis histories at index index and update the plot ranges.

Parameters
indexindex at which to select the axis history item.
See also
updateAxesRangeHistory().

Definition at line 550 of file baseplotwidget.cpp.

551{
552 // qDebug() << "Axes history size:" << m_xAxisRangeHistory.size()
553 //<< "current index:" << m_lastAxisRangeHistoryIndex
554 //<< "asking to restore index:" << index;
555
556 if(index >= m_xAxisRangeHistory.size())
557 {
558 // qDebug() << "index >= history size. Returning.";
559 return;
560 }
561
562 // We want to go back to the range history item at index, which means we want
563 // to pop back all the items between index+1 and size-1.
564
565 while(m_xAxisRangeHistory.size() > index + 1)
566 m_xAxisRangeHistory.pop_back();
567
568 if(m_xAxisRangeHistory.size() - 1 != index)
569 qFatal("Programming error.");
570
571 xAxis->setRange(*(m_xAxisRangeHistory.at(index)));
572 yAxis->setRange(*(m_yAxisRangeHistory.at(index)));
573
575
576 mp_vPosTracerItem->setVisible(false);
577 mp_hPosTracerItem->setVisible(false);
578
579 mp_vStartTracerItem->setVisible(false);
580 mp_vEndTracerItem->setVisible(false);
581
582
583 // The start tracer will keep beeing represented at the last position and last
584 // size even if we call this function repetitively. So actually do not show,
585 // it will reappare as soon as the mouse is moved.
586 // if(m_shouldTracersBeVisible)
587 //{
588 // mp_vStartTracerItem->setVisible(true);
589 //}
590
591 replot();
592
594
595 // qDebug() << "restored axes history to index:" << index
596 //<< "with values:" << xAxis->range().lower << "--"
597 //<< xAxis->range().upper << "and" << yAxis->range().lower << "--"
598 //<< yAxis->range().upper;
599
601}
virtual void hideAllPlotItems()
PLOTTING / REPLOTTING functions.

References hideAllPlotItems(), m_context, m_xAxisRangeHistory, m_yAxisRangeHistory, mp_hPosTracerItem, mp_vEndTracerItem, mp_vPosTracerItem, mp_vStartTracerItem, plotRangesChangedSignal(), and updateContextXandYAxisRanges().

Referenced by restorePreviousAxesRangeHistory().

◆ restorePreviousAxesRangeHistory()

void pappso::BasePlotWidget::restorePreviousAxesRangeHistory ( )
virtual

Go up one history element in the axis history.

If possible, back up one history item in the axis histories and update the plot's x/y-axis ranges to match that history item.

Definition at line 522 of file baseplotwidget.cpp.

523{
524 // qDebug() << "axes history size:" << m_xAxisRangeHistory.size()
525 //<< "current index:" << m_lastAxisRangeHistoryIndex;
526
528 {
529 // qDebug() << "current index is 0 returning doing nothing";
530
531 return;
532 }
533
534 // qDebug() << "Setting index to:" << m_lastAxisRangeHistoryIndex - 1
535 //<< "and restoring axes history to that index";
536
538}
virtual void restoreAxesRangeHistory(std::size_t index)
Get the axis histories at index index and update the plot ranges.

References m_lastAxisRangeHistoryIndex, and restoreAxesRangeHistory().

Referenced by keyReleaseEvent().

◆ setAxisLabelX()

void pappso::BasePlotWidget::setAxisLabelX ( const QString &  label)
virtual

Definition at line 458 of file baseplotwidget.cpp.

459{
460 xAxis->setLabel(label);
461}

◆ setAxisLabelY()

void pappso::BasePlotWidget::setAxisLabelY ( const QString &  label)
virtual

Definition at line 465 of file baseplotwidget.cpp.

466{
467 yAxis->setLabel(label);
468}

◆ setFocus()

void pappso::BasePlotWidget::setFocus ( )
virtual

PLOT ITEMS : TRACER TEXT ITEMS...

Definition at line 3235 of file baseplotwidget.cpp.

3236{
3237 // qDebug() << "Setting focus to the QCustomPlot:" << this;
3238
3239 QCustomPlot::setFocus();
3240
3241 // qDebug() << "Emitting setFocusSignal().";
3242
3243 emit setFocusSignal();
3244}

References setFocusSignal().

Referenced by mouseMoveHandler(), and mousePressHandler().

◆ setFocusSignal

void pappso::BasePlotWidget::setFocusSignal ( )
signal

Referenced by setFocus().

◆ setPen()

void pappso::BasePlotWidget::setPen ( const QPen &  pen)
virtual

Definition at line 390 of file baseplotwidget.cpp.

391{
392 m_pen = pen;
393}

References m_pen.

◆ setPlottingColor() [1/2]

void pappso::BasePlotWidget::setPlottingColor ( int  index,
const QColor &  new_color 
)
virtual

Definition at line 421 of file baseplotwidget.cpp.

422{
423 if(!new_color.isValid())
424 return;
425
426 QCPGraph *graph_p = graph(index);
427
428 if(graph_p == nullptr)
429 qFatal("Programming error.");
430
431 return setPlottingColor(graph_p, new_color);
432}
virtual void setPlottingColor(QCPAbstractPlottable *plottable_p, const QColor &new_color)

References setPlottingColor().

◆ setPlottingColor() [2/2]

void pappso::BasePlotWidget::setPlottingColor ( QCPAbstractPlottable *  plottable_p,
const QColor &  new_color 
)
virtual

Reimplemented in pappso::BaseColorMapPlotWidget.

Definition at line 404 of file baseplotwidget.cpp.

405{
406 if(plottable_p == nullptr)
407 qFatal("Pointer cannot be nullptr.");
408
409 // First this single-graph widget
410 QPen pen;
411
412 pen = plottable_p->pen();
413 pen.setColor(new_color);
414 plottable_p->setPen(pen);
415
416 replot();
417}

Referenced by setPlottingColor().

◆ setupWidget()

bool pappso::BasePlotWidget::setupWidget ( )
virtual

Definition at line 342 of file baseplotwidget.cpp.

343{
344 // qDebug();
345
346 // By default the widget comes with a graph. Remove it.
347
348 if(graphCount())
349 {
350 // QCPLayer *layer_p = graph(0)->layer();
351 // qDebug() << "The graph was on layer:" << layer_p->name();
352
353 // As of today 20210313, the graph is created on the currentLayer(), that
354 // is "main".
355
356 removeGraph(0);
357 }
358
359 // The general idea is that we do want custom layers for the trace|colormap
360 // plots.
361
362 // qDebug().noquote() << "Right before creating the new layer, layers:\n"
363 //<< allLayerNamesToString();
364
365 // Add the layer that will store all the plots and all the ancillary items.
366 addLayer("plotsLayer", layer("background"), QCustomPlot::LayerInsertMode::limAbove);
367 // qDebug().noquote() << "Added new plotsLayer, layers:\n"
368 //<< allLayerNamesToString();
369
370 // This is required so that we get the keyboard events.
371 setFocusPolicy(Qt::StrongFocus);
372 setInteractions(QCP::iRangeZoom | QCP::iSelectPlottables | QCP::iMultiSelect);
373
374 // We want to capture the signals emitted by the QCustomPlot base class.
375 connect(this, &QCustomPlot::mouseMove, this, &BasePlotWidget::mouseMoveHandler);
376
377 connect(this, &QCustomPlot::mousePress, this, &BasePlotWidget::mousePressHandler);
378
379 connect(this, &QCustomPlot::mouseRelease, this, &BasePlotWidget::mouseReleaseHandler);
380
381 connect(this, &QCustomPlot::mouseWheel, this, &BasePlotWidget::mouseWheelHandler);
382
383 connect(this, &QCustomPlot::axisDoubleClick, this, &BasePlotWidget::axisDoubleClickHandler);
384
385 return true;
386}
virtual void mouseWheelHandler(QWheelEvent *event)
virtual void axisDoubleClickHandler(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
virtual void mouseMoveHandler(QMouseEvent *event)
KEYBOARD-related EVENTS.

References axisDoubleClickHandler(), mouseMoveHandler(), mousePressHandler(), mouseReleaseHandler(), and mouseWheelHandler().

Referenced by BasePlotWidget(), and BasePlotWidget().

◆ showTracers()

void pappso::BasePlotWidget::showTracers ( )
virtual

Show the traces (vertical and horizontal).

Definition at line 2241 of file baseplotwidget.cpp.

2242{
2244
2245 mp_vPosTracerItem->setVisible(true);
2246 mp_hPosTracerItem->setVisible(true);
2247
2248 mp_vStartTracerItem->setVisible(true);
2249 mp_vEndTracerItem->setVisible(true);
2250
2251 // Force a replot to make sure the action is immediately visible by the
2252 // user, even without moving the mouse.
2253 replot();
2254}

References m_shouldTracersBeVisible, mp_hPosTracerItem, mp_vEndTracerItem, mp_vPosTracerItem, and mp_vStartTracerItem.

Referenced by keyReleaseEvent().

◆ spaceKeyReleaseEvent()

void pappso::BasePlotWidget::spaceKeyReleaseEvent ( QKeyEvent *  event)
virtual

Definition at line 796 of file baseplotwidget.cpp.

797{
798 // qDebug();
799}

Referenced by keyReleaseEvent().

◆ updateAxesRangeHistory()

void pappso::BasePlotWidget::updateAxesRangeHistory ( )
virtual

Create new axis range history items and append them to the history.

The plot widget is queried to get the current x/y-axis ranges and the current ranges are appended to the history for x-axis and for y-axis.

Definition at line 500 of file baseplotwidget.cpp.

501{
502 m_xAxisRangeHistory.push_back(new QCPRange(xAxis->range()));
503 m_yAxisRangeHistory.push_back(new QCPRange(yAxis->range()));
504
506
507 // qDebug() << "axes history size:" << m_xAxisRangeHistory.size()
508 //<< "current index:" << m_lastAxisRangeHistoryIndex
509 //<< xAxis->range().lower << "--" << xAxis->range().upper << "and"
510 //<< yAxis->range().lower << "--" << yAxis->range().upper;
511}

References m_lastAxisRangeHistoryIndex, m_xAxisRangeHistory, and m_yAxisRangeHistory.

Referenced by axisDoubleClickHandler(), pappso::BaseTracePlotWidget::axisDoubleClickHandler(), axisReframe(), pappso::BaseTracePlotWidget::axisReframe(), axisZoom(), pappso::BaseTracePlotWidget::axisZoom(), mouseReleaseHandlerLeftButton(), and mouseWheelHandler().

◆ updateContextXandYAxisRanges()

void pappso::BasePlotWidget::updateContextXandYAxisRanges ( )
virtual

Definition at line 3275 of file baseplotwidget.cpp.

3276{
3277 m_context.m_xRange = QCPRange(xAxis->range().lower, xAxis->range().upper);
3278 m_context.m_yRange = QCPRange(yAxis->range().lower, yAxis->range().upper);
3279
3280 // qDebug() << "The new updated context: " << m_context.toString();
3281}

References m_context, pappso::BasePlotContext::m_xRange, and pappso::BasePlotContext::m_yRange.

Referenced by axisDoubleClickHandler(), pappso::BaseTracePlotWidget::axisDoubleClickHandler(), axisPan(), pappso::BaseTracePlotWidget::axisPan(), axisReframe(), pappso::BaseTracePlotWidget::axisReframe(), axisRescale(), pappso::BaseTracePlotWidget::axisRescale(), axisZoom(), pappso::BaseTracePlotWidget::axisZoom(), and restoreAxesRangeHistory().

◆ updateIntegrationScope()

void pappso::BasePlotWidget::updateIntegrationScope ( bool  for_integration = false)
protectedvirtual

Definition at line 2587 of file baseplotwidget.cpp.

2588{
2589
2590 // if(for_integration)
2591 // qDebug() << "for_integration:" << for_integration;
2592
2593 // By essence, the one-dimension IntegrationScope is characterized
2594 // by the left-most point and the width. Using these two data bits
2595 // it is possible to compute the x value of the right-most point.
2596
2597 double x_range_start = std::min(m_context.m_currentDragPoint.x(), m_context.m_startDragPoint.x());
2598 double x_range_end = std::max(m_context.m_currentDragPoint.x(), m_context.m_startDragPoint.x());
2599
2600 // qDebug() << "x_range_start:" << x_range_start << "-" << "x_range_end:" << x_range_end;
2601
2602 double y_position = m_context.m_startDragPoint.y();
2603
2605
2606 // Top line
2607 mp_selectionRectangeLine1->start->setCoords(QPointF(x_range_start, y_position));
2608 mp_selectionRectangeLine1->end->setCoords(QPointF(x_range_end, y_position));
2609
2610 // Only if we are drawing a selection rectangle for integration, do we set
2611 // arrow heads to the line.
2612 if(for_integration)
2613 {
2614 mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2615 mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2616 }
2617 else
2618 {
2619 mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2620 mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2621 }
2622 mp_selectionRectangeLine1->setVisible(true);
2623
2624 // Right line: does not exist, start and end are the same end point of the
2625 // top line.
2626 mp_selectionRectangeLine2->start->setCoords(QPointF(x_range_end, y_position));
2627 mp_selectionRectangeLine2->end->setCoords(QPointF(x_range_end, y_position));
2628 mp_selectionRectangeLine2->setVisible(false);
2629
2630 // Bottom line: identical to the top line, but invisible
2631 mp_selectionRectangeLine3->start->setCoords(QPointF(x_range_start, y_position));
2632 mp_selectionRectangeLine3->end->setCoords(QPointF(x_range_end, y_position));
2633 mp_selectionRectangeLine3->setVisible(false);
2634
2635 // Left line: does not exist: start and end are the same end point of the
2636 // top line.
2637 mp_selectionRectangeLine4->start->setCoords(QPointF(x_range_end, y_position));
2638 mp_selectionRectangeLine4->end->setCoords(QPointF(x_range_end, y_position));
2639 mp_selectionRectangeLine4->setVisible(false);
2640}

References m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_startDragPoint, mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, and pappso::BasePlotContext::updateIntegrationScope().

Referenced by updateIntegrationScopeDrawing().

◆ updateIntegrationScopeDrawing()

void pappso::BasePlotWidget::updateIntegrationScopeDrawing ( bool  as_line_segment = false,
bool  for_integration = false 
)
virtual

Definition at line 3039 of file baseplotwidget.cpp.

3040{
3041 // qDebug() << "as_line_segment:" << as_line_segment;
3042 // qDebug() << "for_integration:" << for_integration;
3043
3044 // We now need to construct the selection rectangle, either for zoom or for
3045 // integration.
3046
3047 // There are two situations :
3048 //
3049 // 1. if the rectangle should look like a line segment
3050 //
3051 // 2. if the rectangle should actually look like a rectangle. In this case,
3052 // there are two sub-situations:
3053 //
3054 // a. if the Alt modifier key is down, then the rectangle is rhomboid.
3055 //
3056 // b. otherwise the rectangle is conventional.
3057
3058 if(as_line_segment)
3059 {
3060 // qDebug() << "Updating the integration scope to an IntegrationScope.";
3061 updateIntegrationScope(for_integration);
3062 }
3063 else
3064 {
3065 if(!(m_context.m_keyboardModifiers & Qt::AltModifier))
3066 {
3067 // qDebug()
3068 // << "Updating the integration scope to an IntegrationScopeRect.";
3069 updateIntegrationScopeRect(for_integration);
3070 }
3071 else if(m_context.m_keyboardModifiers & Qt::AltModifier)
3072 {
3073 // The user might use the Alt modifier, but if no rhomboid side has
3074 // been defined using the S key, then we do not do any rhomboid
3075 // selection because we do not know the side size of that rhomboid.
3076
3078 updateIntegrationScopeRect(for_integration);
3079 else
3080 // qDebug()
3081 // << "Updating the integration scope to an
3082 // IntegrationScopeRhomb.";
3083 updateIntegrationScopeRhomb(for_integration);
3084 }
3085 }
3086
3087 // Depending on the kind of IntegrationScope, (normal, rect or rhomb)
3088 // we have to measure things in different ways. We now set in the context
3089 // a number of parameters that will be used by its user.
3090
3091 QPointF point;
3092 double height;
3093 std::vector<QPointF> points;
3094
3095 // Integration scope values are sorted:
3096 // Line scope: point is left and width is right.x - left.x
3097 // Rect scope: point is bottom left.
3098 // Rhomb scope: points 1->4 are bottom left->bottom right->top right->top left
3099 // width is 2.x - 1.x.
3100
3101 if(m_context.msp_integrationScope->getPoints(points))
3102 {
3103 // We have defined a IntegrationScopeRhomb.
3104
3105 if(!m_context.msp_integrationScope->getLeftMostPoint(point))
3106 qFatal("Failed to get LeftMost point.");
3107 m_context.m_xRegionRangeStart = point.x();
3108
3109 if(!m_context.msp_integrationScope->getRightMostPoint(point))
3110 qFatal("Failed to get RightMost point.");
3111 m_context.m_xRegionRangeEnd = point.x();
3112 }
3113 else if(m_context.msp_integrationScope->getHeight(height))
3114 {
3115 // We have defined a IntegrationScopeRect.
3116
3117 if(!m_context.msp_integrationScope->getPoint(point))
3118 qFatal("Failed to get point.");
3119 m_context.m_xRegionRangeStart = point.x();
3120
3121 double width;
3122
3123 if(!m_context.msp_integrationScope->getWidth(width))
3124 qFatal("Failed to get width.");
3125
3127
3128 m_context.m_yRegionRangeStart = point.y();
3129
3130 m_context.m_yRegionRangeEnd = point.y() + height;
3131 }
3132 else
3133 {
3134 // We have defined a IntegrationScope.
3135
3136 if(!m_context.msp_integrationScope->getPoint(point))
3137 qFatal("Failed to get point.");
3138 m_context.m_xRegionRangeStart = point.x();
3139
3140 double width;
3141
3142 if(!m_context.msp_integrationScope->getWidth(width))
3143 qFatal("Failed to get width.");
3145 }
3146
3147 // At this point, draw the text describing the widths.
3148
3149 // We want the x-delta on the bottom of the rectangle, inside it
3150 // and the y-delta on the vertical side of the rectangle, inside it.
3151
3152 // Draw the selection width text
3154}
virtual void updateIntegrationScopeRect(bool for_integration=false)
virtual void updateIntegrationScope(bool for_integration=false)
virtual void updateIntegrationScopeRhomb(bool for_integration=false)

References drawXScopeSpanFeatures(), m_context, pappso::BasePlotContext::m_integrationScopeRhombHeight, pappso::BasePlotContext::m_integrationScopeRhombWidth, pappso::BasePlotContext::m_keyboardModifiers, pappso::BasePlotContext::m_xRegionRangeEnd, pappso::BasePlotContext::m_xRegionRangeStart, pappso::BasePlotContext::m_yRegionRangeEnd, pappso::BasePlotContext::m_yRegionRangeStart, pappso::BasePlotContext::msp_integrationScope, updateIntegrationScope(), updateIntegrationScopeRect(), and updateIntegrationScopeRhomb().

Referenced by drawSelectionRectangleAndPrepareZoom().

◆ updateIntegrationScopeHorizontalRhomb()

void pappso::BasePlotWidget::updateIntegrationScopeHorizontalRhomb ( bool  for_integration = false)
protectedvirtual

Definition at line 2727 of file baseplotwidget.cpp.

2728{
2729 // We are handling a rhomboid scope, that is, a rectangle that
2730 // is tilted either to the left or to the right.
2731
2732 // There are two kinds of rhomboid integration scopes: horizontal and
2733 // vertical.
2734
2735 /*
2736 * +----------+
2737 * | |
2738 * | |
2739 * | |
2740 * | |
2741 * | |
2742 * | |
2743 * | |
2744 * +----------+
2745 * ----width---
2746 */
2747
2748 // As visible here, the fixed size of the rhomboid (using the S key in the
2749 // plot widget) is the *horizontal* side (this is the plot context's
2750 // m_integrationScopeRhombWidth).
2751
2752 IntegrationScopeFeatures scope_features;
2753
2754 // Top horizontal line
2755 QPointF point_1;
2756 scope_features = m_context.msp_integrationScope->getLeftMostTopPoint(point_1);
2757
2758 // When the user rotates the horizontal rhomboid, at some point, if the
2759 // current drag point has the same y axis value as the start drag point, then
2760 // we say that the rhomboid is flattened on the x axis. In this case, we do
2761 // not draw anything as this is a purely unusable situation.
2762
2763 if(scope_features & IntegrationScopeFeatures::FLAT_ON_X_AXIS)
2764 {
2765 // qDebug() << "The horizontal rhomboid is flattened on the x axis.";
2766
2767 mp_selectionRectangeLine1->setVisible(false);
2768 mp_selectionRectangeLine2->setVisible(false);
2769 mp_selectionRectangeLine3->setVisible(false);
2770 mp_selectionRectangeLine4->setVisible(false);
2771
2772 return;
2773 }
2774
2776 qFatal("The rhomboid should be horizontal!");
2777
2778 // At this point we can draw the rhomboid fine.
2779
2780 if(!m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2781 qFatal("Failed to getLeftMostTopPoint.");
2782 QPointF point_2;
2783 if(!m_context.msp_integrationScope->getRightMostTopPoint(point_2))
2784 qFatal("Failed to getRightMostTopPoint.");
2785
2786 // qDebug() << "For top line, two points:" << point_1 << "--" << point_2;
2787
2788 mp_selectionRectangeLine1->start->setCoords(point_1);
2789 mp_selectionRectangeLine1->end->setCoords(point_2);
2790
2791 // Only if we are drawing a selection rectangle for integration, do we set
2792 // arrow heads to the line.
2793 if(for_integration)
2794 {
2795 mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2796 mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2797 }
2798 else
2799 {
2800 mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2801 mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2802 }
2803
2804 mp_selectionRectangeLine1->setVisible(true);
2805
2806 // Right line
2807 if(!m_context.msp_integrationScope->getRightMostBottomPoint(point_1))
2808 qFatal("Failed to getRightMostBottomPoint.");
2809 mp_selectionRectangeLine2->start->setCoords(point_2);
2810 mp_selectionRectangeLine2->end->setCoords(point_1);
2811 mp_selectionRectangeLine2->setVisible(true);
2812
2813 // qDebug() << "For right line, two points:" << point_2 << "--" << point_1;
2814
2815 // Bottom horizontal line
2816 if(!m_context.msp_integrationScope->getLeftMostBottomPoint(point_2))
2817 qFatal("Failed to getLeftMostBottomPoint.");
2818 mp_selectionRectangeLine3->start->setCoords(point_1);
2819 mp_selectionRectangeLine3->end->setCoords(point_2);
2820 mp_selectionRectangeLine3->setVisible(true);
2821
2822 // qDebug() << "For bottom line, two points:" << point_1 << "--" << point_2;
2823
2824 // Left line
2825 if(!m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2826 qFatal("Failed to getLeftMostTopPoint.");
2827 mp_selectionRectangeLine4->end->setCoords(point_2);
2828 mp_selectionRectangeLine4->start->setCoords(point_1);
2829 mp_selectionRectangeLine4->setVisible(true);
2830
2831 // qDebug() << "For left line, two points:" << point_2 << "--" << point_1;
2832}

References pappso::FLAT_ON_X_AXIS, m_context, mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, pappso::BasePlotContext::msp_integrationScope, and pappso::RHOMBOID_VERTICAL.

Referenced by updateIntegrationScopeRhomb().

◆ updateIntegrationScopeRect()

void pappso::BasePlotWidget::updateIntegrationScopeRect ( bool  for_integration = false)
protectedvirtual

Definition at line 2644 of file baseplotwidget.cpp.

2645{
2646 // qDebug();
2647
2648 // if(for_integration)
2649 // qDebug() << "for_integration:" << for_integration;
2650
2651 // We are handling a conventional rectangle. Just create four points
2652 // from top left to bottom right. But we want the top left point to be
2653 // effectively the top left point and the bottom point to be the bottom
2654 // point. So we need to try all four direction combinations, left to right
2655 // or converse versus top to bottom or converse.
2656
2658
2659 // Now that the integration scope has been updated as a rectangle,
2660 // use these newly set data to actually draw the integration
2661 // scope lines.
2662
2663 QPointF bottom_left_point;
2664 if(!m_context.msp_integrationScope->getPoint(bottom_left_point))
2665 qFatal("Failed to get point.");
2666 // qDebug() << "Starting point is left bottom point:" << bottom_left_point;
2667
2668 double width;
2669 if(!m_context.msp_integrationScope->getWidth(width))
2670 qFatal("Failed to get width.");
2671 // qDebug() << "Width:" << width;
2672
2673 double height;
2674 if(!m_context.msp_integrationScope->getHeight(height))
2675 qFatal("Failed to get height.");
2676 // qDebug() << "Height:" << height;
2677
2678 QPointF bottom_right_point(bottom_left_point.x() + width, bottom_left_point.y());
2679 // qDebug() << "bottom_right_point:" << bottom_right_point;
2680
2681 QPointF top_right_point(bottom_left_point.x() + width, bottom_left_point.y() + height);
2682 // qDebug() << "top_right_point:" << top_right_point;
2683
2684 QPointF top_left_point(bottom_left_point.x(), bottom_left_point.y() + height);
2685
2686 // qDebug() << "top_left_point:" << top_left_point;
2687
2688 // Start by drawing the bottom line because the IntegrationScopeRect has the
2689 // left bottom point and the width and the height to fully characterize it.
2690
2691 // Bottom line (left to right)
2692 mp_selectionRectangeLine3->start->setCoords(bottom_left_point);
2693 mp_selectionRectangeLine3->end->setCoords(bottom_right_point);
2694 mp_selectionRectangeLine3->setVisible(true);
2695
2696 // Right line (bottom to top)
2697 mp_selectionRectangeLine2->start->setCoords(bottom_right_point);
2698 mp_selectionRectangeLine2->end->setCoords(top_right_point);
2699 mp_selectionRectangeLine2->setVisible(true);
2700
2701 // Top line (right to left)
2702 mp_selectionRectangeLine1->start->setCoords(top_right_point);
2703 mp_selectionRectangeLine1->end->setCoords(top_left_point);
2704 mp_selectionRectangeLine1->setVisible(true);
2705
2706 // Left line (top to bottom)
2707 mp_selectionRectangeLine4->start->setCoords(top_left_point);
2708 mp_selectionRectangeLine4->end->setCoords(bottom_left_point);
2709 mp_selectionRectangeLine4->setVisible(true);
2710
2711 // Only if we are drawing a selection rectangle for integration, do we
2712 // set arrow heads to the line.
2713 if(for_integration)
2714 {
2715 mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2716 mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2717 }
2718 else
2719 {
2720 mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2721 mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2722 }
2723}

References m_context, mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, pappso::BasePlotContext::msp_integrationScope, and pappso::BasePlotContext::updateIntegrationScopeRect().

Referenced by updateIntegrationScopeDrawing().

◆ updateIntegrationScopeRhomb()

void pappso::BasePlotWidget::updateIntegrationScopeRhomb ( bool  for_integration = false)
protectedvirtual

Definition at line 2951 of file baseplotwidget.cpp.

2952{
2953 // qDebug();
2954
2955 // if(for_integration)
2956 // qDebug() << "for_integration:" << for_integration;
2957
2958 // We are handling a skewed rectangle (rhomboid), that is a rectangle that
2959 // is tilted either to the left or to the right.
2960
2961 // There are two kinds of rhomboid integration scopes:
2962
2963 /*
2964 4+----------+3
2965 | |
2966 | |
2967 | |
2968 | |
2969 | |
2970 | |
2971 | |
2972 1+----------+2
2973 ----width---
2974 */
2975
2976 // As visible here, the fixed size of the rhomboid (using the S key in the
2977 // plot widget) is the *horizontal* side (this is the plot context's
2978 // m_integrationScopeRhombWidth).
2979
2980 // and
2981
2982
2983 /*
2984 * +3
2985 * . |
2986 * . |
2987 * . |
2988 * . +2
2989 * . .
2990 * . .
2991 * . .
2992 * 4+ .
2993 * | | .
2994 * height | | .
2995 * | | .
2996 * 1+
2997 *
2998 */
2999
3000 // As visible here, the fixed size of the rhomboid (using the S key in the
3001 // plot widget) is the *vertical* side (this is the plot context's
3002 // m_integrationScopeRhombHeight).
3003
3004 // qDebug() << "Before calling updateIntegrationScopeRhomb(), "
3005 // "m_integrationScopeRhombWidth:"
3006 // << m_context.m_integrationScopeRhombWidth
3007 // << "and m_integrationScopeRhombHeight:"
3008 // << m_context.m_integrationScopeRhombHeight;
3009
3011
3012 // qDebug() << "After, m_integrationScopeRhombWidth:"
3013 // << m_context.m_integrationScopeRhombWidth
3014 // << "and m_integrationScopeRhombHeight:"
3015 // << m_context.m_integrationScopeRhombHeight;
3016
3017 // Now that the integration scope has been updated as a rhomboid,
3018 // use these newly set data to actually draw the integration
3019 // scope lines.
3020
3021 // We thus need to first establish if we have a horiontal or a vertical
3022 // rhomboid scope. This information is located in
3023 // m_context.m_integrationScopeRhombWidth and
3024 // m_context.m_integrationScopeRhombHeight. If width > 0, height *has to be
3025 // 0*, which indicates a horizontal rhomb.Conversely, if height is > 0, then
3026 // the rhomb is vertical.
3027
3029 // We are dealing with a horizontal scope.
3032 // We are dealing with a vertical scope.
3033 updateIntegrationScopeVerticalRhomb(for_integration);
3034 else
3035 qFatal("Cannot be both the width or height of rhomboid scope be 0.");
3036}
virtual void updateIntegrationScopeHorizontalRhomb(bool for_integration=false)
virtual void updateIntegrationScopeVerticalRhomb(bool for_integration=false)

References m_context, pappso::BasePlotContext::m_integrationScopeRhombHeight, pappso::BasePlotContext::m_integrationScopeRhombWidth, updateIntegrationScopeHorizontalRhomb(), pappso::BasePlotContext::updateIntegrationScopeRhomb(), and updateIntegrationScopeVerticalRhomb().

Referenced by updateIntegrationScopeDrawing().

◆ updateIntegrationScopeVerticalRhomb()

void pappso::BasePlotWidget::updateIntegrationScopeVerticalRhomb ( bool  for_integration = false)
protectedvirtual

Definition at line 2836 of file baseplotwidget.cpp.

2837{
2838 // We are handling a rhomboid scope, that is, a rectangle that
2839 // is tilted either to the left or to the right.
2840
2841 // There are two kinds of rhomboid integration scopes: horizontal and
2842 // vertical.
2843
2844 /*
2845 * +3
2846 * . |
2847 * . |
2848 * . |
2849 * . +2
2850 * . .
2851 * . .
2852 * . .
2853 * 4+ .
2854 * | | .
2855 * height | | .
2856 * | | .
2857 * 1+
2858 *
2859 */
2860
2861 // As visible here, the fixed size of the rhomboid (using the S key in the
2862 // plot widget) is the *vertical* side (this is the plot context's
2863 // m_integrationScopeRhombHeight).
2864
2865 IntegrationScopeFeatures scope_features;
2866
2867 // Left vertical line
2868 QPointF point_1;
2869 scope_features = m_context.msp_integrationScope->getLeftMostTopPoint(point_1);
2870
2871 // When the user rotates the vertical rhomboid, at some point, if the current
2872 // drag point is on the same x axis value as the start drag point, then we say
2873 // that the rhomboid is flattened on the y axis. In this case, we do not draw
2874 // anything as this is a purely unusable situation.
2875
2876 if(scope_features & IntegrationScopeFeatures::FLAT_ON_Y_AXIS)
2877 {
2878 // qDebug() << "The vertical rhomboid is flattened on the y axis.";
2879
2880 mp_selectionRectangeLine1->setVisible(false);
2881 mp_selectionRectangeLine2->setVisible(false);
2882 mp_selectionRectangeLine3->setVisible(false);
2883 mp_selectionRectangeLine4->setVisible(false);
2884
2885 return;
2886 }
2887
2889 qFatal("The rhomboid should be vertical!");
2890
2891 // At this point we can draw the rhomboid fine.
2892
2893 QPointF point_2;
2894 if(!m_context.msp_integrationScope->getLeftMostBottomPoint(point_2))
2895 qFatal("Failed to getLeftMostBottomPoint.");
2896
2897 // qDebug() << "For left vertical line, two points:" << point_1 << "--"
2898 // << point_2;
2899
2900 mp_selectionRectangeLine1->start->setCoords(point_1);
2901 mp_selectionRectangeLine1->end->setCoords(point_2);
2902
2903 // Only if we are drawing a selection rectangle for integration, do we set
2904 // arrow heads to the line.
2905 if(for_integration)
2906 {
2907 mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2908 mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2909 }
2910 else
2911 {
2912 mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2913 mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2914 }
2915
2916 mp_selectionRectangeLine1->setVisible(true);
2917
2918 // Lower oblique line
2919 if(!m_context.msp_integrationScope->getRightMostBottomPoint(point_1))
2920 qFatal("Failed to getRightMostBottomPoint.");
2921 mp_selectionRectangeLine2->start->setCoords(point_2);
2922 mp_selectionRectangeLine2->end->setCoords(point_1);
2923 mp_selectionRectangeLine2->setVisible(true);
2924
2925 // qDebug() << "For lower oblique line, two points:" << point_2 << "--"
2926 // << point_1;
2927
2928 // Right vertical line
2929 if(!m_context.msp_integrationScope->getRightMostTopPoint(point_2))
2930 qFatal("Failed to getRightMostTopPoint.");
2931 mp_selectionRectangeLine3->start->setCoords(point_1);
2932 mp_selectionRectangeLine3->end->setCoords(point_2);
2933 mp_selectionRectangeLine3->setVisible(true);
2934
2935 // qDebug() << "For right vertical line, two points:" << point_1 << "--"
2936 // << point_2;
2937
2938 // Upper oblique line
2939 if(!m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2940 qFatal("Failed to get the LeftMostTopPoint.");
2941 mp_selectionRectangeLine4->end->setCoords(point_2);
2942 mp_selectionRectangeLine4->start->setCoords(point_1);
2943 mp_selectionRectangeLine4->setVisible(true);
2944
2945 // qDebug() << "For upper oblique line, two points:" << point_2 << "--"
2946 // << point_1;
2947}

References pappso::FLAT_ON_Y_AXIS, m_context, mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, pappso::BasePlotContext::msp_integrationScope, and pappso::RHOMBOID_HORIZONTAL.

Referenced by updateIntegrationScopeRhomb().

◆ verticalGetGraphCoordNewPointCountPixels()

QPointF pappso::BasePlotWidget::verticalGetGraphCoordNewPointCountPixels ( int  pixel_count)
virtual

Definition at line 1854 of file baseplotwidget.cpp.

1855{
1856 QPointF pixel_coordinates(xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()),
1857 yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()) +
1858 pixel_count);
1859
1860 // Now convert back to local coordinates.
1861
1862 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1863 yAxis->pixelToCoord(pixel_coordinates.y()));
1864
1865 return graph_coordinates;
1866}

References m_context, and pappso::BasePlotContext::m_lastCursorHoveredPoint.

Referenced by verticalMoveMouseCursorCountPixels().

◆ verticalMoveMouseCursorCountPixels()

void pappso::BasePlotWidget::verticalMoveMouseCursorCountPixels ( int  pixel_count)
virtual

Definition at line 1838 of file baseplotwidget.cpp.

1839{
1840
1841 QPointF graph_coord = verticalGetGraphCoordNewPointCountPixels(pixel_count);
1842
1843 QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()), yAxis->coordToPixel(graph_coord.y()));
1844
1845 // Now we need ton convert the new coordinates to the global position system
1846 // and to move the cursor to that new position. That will create an event to
1847 // move the mouse cursor.
1848
1849 moveMouseCursorPixelCoordToGlobal(pixel_coord.toPoint());
1850}
virtual QPointF verticalGetGraphCoordNewPointCountPixels(int pixel_count)

References moveMouseCursorPixelCoordToGlobal(), and verticalGetGraphCoordNewPointCountPixels().

Referenced by directionKeyPressEvent().

◆ whatIsVisibleOfTheSelectionRectangle()

SelectionDrawingLines pappso::BasePlotWidget::whatIsVisibleOfTheSelectionRectangle ( )
virtual

Definition at line 3178 of file baseplotwidget.cpp.

3179{
3180 // There are four lines that make the selection polygon. We want to know
3181 // which lines are visible.
3182
3183 int current_selection_polygon = static_cast<int>(SelectionDrawingLines::NOT_SET);
3184
3185 if(mp_selectionRectangeLine1->visible())
3186 {
3187 current_selection_polygon |= static_cast<int>(SelectionDrawingLines::TOP_LINE);
3188 // qDebug() << "current_selection_polygon:" <<
3189 // current_selection_polygon;
3190 }
3191 if(mp_selectionRectangeLine2->visible())
3192 {
3193 current_selection_polygon |= static_cast<int>(SelectionDrawingLines::RIGHT_LINE);
3194 // qDebug() << "current_selection_polygon:" <<
3195 // current_selection_polygon;
3196 }
3197 if(mp_selectionRectangeLine3->visible())
3198 {
3199 current_selection_polygon |= static_cast<int>(SelectionDrawingLines::BOTTOM_LINE);
3200 // qDebug() << "current_selection_polygon:" <<
3201 // current_selection_polygon;
3202 }
3203 if(mp_selectionRectangeLine4->visible())
3204 {
3205 current_selection_polygon |= static_cast<int>(SelectionDrawingLines::LEFT_LINE);
3206 // qDebug() << "current_selection_polygon:" <<
3207 // current_selection_polygon;
3208 }
3209
3210 // qDebug() << "returning visibility:" << current_selection_polygon;
3211
3212 return static_cast<SelectionDrawingLines>(current_selection_polygon);
3213}

References pappso::BOTTOM_LINE, pappso::LEFT_LINE, mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, pappso::NOT_SET, pappso::RIGHT_LINE, and pappso::TOP_LINE.

Referenced by mouseReleaseHandlerLeftButton().

◆ xAxisMeasurementSignal

void pappso::BasePlotWidget::xAxisMeasurementSignal ( const BasePlotContext context,
bool  with_delta 
)
signal

◆ yMinMaxOnXAxisCurrentRange() [1/2]

void pappso::BasePlotWidget::yMinMaxOnXAxisCurrentRange ( double &  min,
double &  max,
int  index 
)

◆ yMinMaxOnXAxisCurrentRange() [2/2]

void pappso::BasePlotWidget::yMinMaxOnXAxisCurrentRange ( double &  min,
double &  max,
QCPAbstractPlottable *  plottable_p = nullptr 
)

Member Data Documentation

◆ m_axisLabelX

QString pappso::BasePlotWidget::m_axisLabelX
protected

Definition at line 270 of file baseplotwidget.h.

◆ m_axisLabelY

QString pappso::BasePlotWidget::m_axisLabelY
protected

Definition at line 271 of file baseplotwidget.h.

◆ m_context

BasePlotContext pappso::BasePlotWidget::m_context
protected

Definition at line 273 of file baseplotwidget.h.

Referenced by pappso::DriftSpecTracePlotWidget::DriftSpecTracePlotWidget(), pappso::MassSpecTracePlotWidget::MassSpecTracePlotWidget(), pappso::MassSpecTracePlotWidget::MassSpecTracePlotWidget(), pappso::TicXicChromTracePlotWidget::TicXicChromTracePlotWidget(), axisDoubleClickHandler(), pappso::BaseTracePlotWidget::axisDoubleClickHandler(), axisPan(), pappso::BaseTracePlotWidget::axisPan(), axisReframe(), pappso::BaseTracePlotWidget::axisReframe(), axisRescale(), pappso::BaseTracePlotWidget::axisRescale(), axisZoom(), pappso::BaseTracePlotWidget::axisZoom(), calculateDragDeltas(), pappso::BaseColorMapPlotWidget::currentXaxisRangeIndices(), pappso::BaseColorMapPlotWidget::currentYaxisRangeIndices(), directionKeyPressEvent(), dragDirection(), drawSelectionRectangleAndPrepareZoom(), drawXScopeSpanFeatures(), drawYScopeSpanFeatures(), getContext(), horizontalGetGraphCoordNewPointCountPixels(), isVerticalDisplacementAboveThreshold(), keyPressEvent(), pappso::DriftSpecTracePlotWidget::keyPressEvent(), pappso::TicXicChromTracePlotWidget::keyPressEvent(), keyReleaseEvent(), mouseMoveHandler(), mouseMoveHandlerDraggingCursor(), mouseMoveHandlerLeftButtonDraggingCursor(), mouseMoveHandlerNotDraggingCursor(), mouseMoveHandlerRightButtonDraggingCursor(), mousePressHandler(), pappso::TicXicChromTracePlotWidget::mousePressHandler(), mousePseudoButtonKeyReleaseEvent(), mouseReleaseHandler(), pappso::TicXicChromTracePlotWidget::mouseReleaseHandler(), mouseReleaseHandlerLeftButton(), mouseReleaseHandlerRightButton(), mouseWheelHandler(), pappso::MassSpecTracePlotWidget::refreshBaseContext(), resetSelectionRectangle(), restoreAxesRangeHistory(), updateContextXandYAxisRanges(), updateIntegrationScope(), updateIntegrationScopeDrawing(), updateIntegrationScopeHorizontalRhomb(), updateIntegrationScopeRect(), updateIntegrationScopeRhomb(), updateIntegrationScopeVerticalRhomb(), and verticalGetGraphCoordNewPointCountPixels().

◆ m_desc

QString pappso::BasePlotWidget::m_desc = "NOT_SET"
protected

Description of the plot widget.

Definition at line 265 of file baseplotwidget.h.

◆ m_fileName

QString pappso::BasePlotWidget::m_fileName
protected

The name of the data file from which the mass data were read.

Definition at line 268 of file baseplotwidget.h.

◆ m_focusedBrush

QBrush pappso::BasePlotWidget::m_focusedBrush = QBrush(m_focusedColor)
protected

Color used for the background of focused plot.

Definition at line 354 of file baseplotwidget.h.

Referenced by redrawPlotBackground().

◆ m_focusedColor

QColor pappso::BasePlotWidget::m_focusedColor = QColor(Qt::transparent)
protected

Color used for the background of focused plot.

Definition at line 352 of file baseplotwidget.h.

◆ m_lastAxisRangeHistoryIndex

std::size_t pappso::BasePlotWidget::m_lastAxisRangeHistoryIndex = 0
protected

Index of the last axis range history item.

Each time the user modifies the ranges (x/y axis) during panning or zooming of the graph, the new axis ranges are stored in a axis ranges history list. This index allows to point to the last range of that history.

Definition at line 315 of file baseplotwidget.h.

Referenced by resetAxesRangeHistory(), restorePreviousAxesRangeHistory(), and updateAxesRangeHistory().

◆ m_leftMousePseudoButtonKey

int pappso::BasePlotWidget::m_leftMousePseudoButtonKey = Qt::Key_Less
protected

◆ m_mouseMoveHandlerSkipAmount

int pappso::BasePlotWidget::m_mouseMoveHandlerSkipAmount = 10
protected

How many mouse move events must be skipped *‍/.

when the data are so massive that the graph panning becomes sluggish. By default, the value is 10 events to be skipped before accounting one. The "fat data" mouse movement handler mechanism is actuated by using a keyboard key combination. There is no automatic shift between normal processing and "fat data" processing.

Definition at line 333 of file baseplotwidget.h.

Referenced by mouseMoveHandlerLeftButtonDraggingCursor().

◆ m_mouseMoveHandlerSkipCount

int pappso::BasePlotWidget::m_mouseMoveHandlerSkipCount = 0
protected

Counter to handle the "fat data" mouse move event handling.

See also
m_mouseMoveHandlerSkipAmount.

Definition at line 341 of file baseplotwidget.h.

Referenced by mouseMoveHandlerLeftButtonDraggingCursor(), and mouseReleaseHandler().

◆ m_name

QString pappso::BasePlotWidget::m_name = "NOT_SET"
protected

Name of the plot widget.

Definition at line 262 of file baseplotwidget.h.

◆ m_pen

QPen pappso::BasePlotWidget::m_pen
protected

Pen used to draw the graph and textual elements in the plot widget.

Definition at line 357 of file baseplotwidget.h.

Referenced by BasePlotWidget(), BasePlotWidget(), createAllAncillaryItems(), getPen(), pappso::BaseTracePlotWidget::setGraphData(), and setPen().

◆ m_rightMousePseudoButtonKey

int pappso::BasePlotWidget::m_rightMousePseudoButtonKey = Qt::Key_Greater
protected

◆ m_shouldTracersBeVisible

bool pappso::BasePlotWidget::m_shouldTracersBeVisible = true
protected

Tells if the tracers should be visible.

Definition at line 292 of file baseplotwidget.h.

Referenced by hideTracers(), keyReleaseEvent(), mouseMoveHandlerDraggingCursor(), mouseMoveHandlerNotDraggingCursor(), mousePressHandler(), and showTracers().

◆ m_unfocusedBrush

QBrush pappso::BasePlotWidget::m_unfocusedBrush = QBrush(m_unfocusedColor)
protected

Color used for the background of unfocused plot.

Definition at line 349 of file baseplotwidget.h.

Referenced by redrawPlotBackground().

◆ m_unfocusedColor

QColor pappso::BasePlotWidget::m_unfocusedColor = QColor("lightgray")
protected

Color used for the background of unfocused plot.

Definition at line 347 of file baseplotwidget.h.

◆ m_xAxisRangeHistory

std::vector<QCPRange *> pappso::BasePlotWidget::m_xAxisRangeHistory
protected

List of x axis ranges occurring during the panning zooming actions.

Definition at line 318 of file baseplotwidget.h.

Referenced by ~BasePlotWidget(), resetAxesRangeHistory(), restoreAxesRangeHistory(), and updateAxesRangeHistory().

◆ m_yAxisRangeHistory

std::vector<QCPRange *> pappso::BasePlotWidget::m_yAxisRangeHistory
protected

List of y axis ranges occurring during the panning zooming actions.

Definition at line 321 of file baseplotwidget.h.

Referenced by ~BasePlotWidget(), resetAxesRangeHistory(), restoreAxesRangeHistory(), and updateAxesRangeHistory().

◆ mp_hPosTracerItem

◆ mp_selectionRectangeLine1

QCPItemLine* pappso::BasePlotWidget::mp_selectionRectangeLine1 = nullptr
protected

◆ mp_selectionRectangeLine2

◆ mp_selectionRectangeLine3

◆ mp_selectionRectangeLine4

◆ mp_vEndTracerItem

◆ mp_vPosTracerItem

◆ mp_vStartTracerItem

QCPItemLine* pappso::BasePlotWidget::mp_vStartTracerItem = nullptr
protected

◆ mp_xDeltaTextItem

QCPItemText* pappso::BasePlotWidget::mp_xDeltaTextItem = nullptr
protected

Text describing the x-axis delta value during a drag operation.

Definition at line 288 of file baseplotwidget.h.

Referenced by createAllAncillaryItems(), drawSelectionRectangleAndPrepareZoom(), drawXScopeSpanFeatures(), hideAllPlotItems(), mouseReleaseHandler(), and mouseReleaseHandlerRightButton().

◆ mp_yDeltaTextItem

QCPItemText* pappso::BasePlotWidget::mp_yDeltaTextItem = nullptr
protected

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