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 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 (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, 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 +=
184 QString("Layer index %1: %2\n").arg(iter).arg(layer(iter)->name());
185 }
186
187 return text;
188}

◆ axisDoubleClickHandler()

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

Reimplemented in pappso::BaseTracePlotWidget.

Definition at line 1679 of file baseplotwidget.cpp.

1683{
1684 // qDebug();
1685
1686 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1687
1688 if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1689 {
1690 // qDebug();
1691
1692 // If the Ctrl modifiers is active, then both axes are to be reset. Also
1693 // the histories are reset also.
1694
1695 rescaleAxes();
1697 }
1698 else
1699 {
1700 // qDebug();
1701
1702 // Only the axis passed as parameter is to be rescaled.
1703 // Reset the range of that axis to the max view possible.
1704
1705 axis->rescale();
1706
1708
1709 event->accept();
1710 }
1711
1712 // The double-click event does not cancel the mouse press event. That is, if
1713 // left-double-clicking, at the end of the operation the button still
1714 // "pressed". We need to remove manually the button from the pressed buttons
1715 // context member.
1716
1717 m_context.m_pressedMouseButtons ^= event->button();
1718
1720
1722
1723 replot();
1724}
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 2167 of file baseplotwidget.cpp.

2168{
2169 // Sanity check
2171 qFatal(
2172 "This function can only be called if the mouse click was on one of the "
2173 "axes");
2174
2176 {
2177 xAxis->setRange(m_context.m_xRange.lower - m_context.m_xDelta,
2179 }
2180
2182 {
2183 yAxis->setRange(m_context.m_yRange.lower - m_context.m_yDelta,
2185 }
2186
2188
2189 // qDebug() << "The updated context:" << m_context.toString();
2190
2191 // We cannot store the new ranges in the history, because the pan operation
2192 // involved a huge quantity of micro-movements elicited upon each mouse move
2193 // cursor event so we would have a huge history.
2194 // updateAxesRangeHistory();
2195
2196 // Now that the context has the right range values, we can emit the
2197 // signal that will be used by this plot widget users, typically to
2198 // abide by the x/y range lock required by the user.
2199
2201
2202 replot();
2203}

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 2108 of file baseplotwidget.cpp.

2109{
2110
2111 // double sorted_start_drag_point_x =
2112 // std::min(m_context.m_startDragPoint.x(),
2113 // m_context.m_currentDragPoint.x());
2114
2115 // xAxis->setRange(sorted_start_drag_point_x,
2116 // sorted_start_drag_point_x + fabs(m_context.m_xDelta));
2117
2118 xAxis->setRange(
2120
2121 // Note that the y axis should be rescaled from current lower value to new
2122 // upper value matching the y-axis position of the cursor when the mouse
2123 // button was released.
2124
2125 yAxis->setRange(xAxis->range().lower,
2126 std::max<double>(m_context.m_yRegionRangeStart,
2128
2129 // qDebug() << "xaxis:" << xAxis->range().lower << "-" <<
2130 // xAxis->range().upper
2131 //<< "yaxis:" << yAxis->range().lower << "-" << yAxis->range().upper;
2132
2134
2137
2138 replot();
2139}

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 2052 of file baseplotwidget.cpp.

2053{
2054 // Get the current x lower/upper range, that is, leftmost/rightmost x
2055 // coordinate.
2056 double xLower = xAxis->range().lower;
2057 double xUpper = xAxis->range().upper;
2058
2059 // Get the current y lower/upper range, that is, bottommost/topmost y
2060 // coordinate.
2061 double yLower = yAxis->range().lower;
2062 double yUpper = yAxis->range().upper;
2063
2064 // This function is called only when the user has clicked on the x/y axis or
2065 // when the user has dragged the left mouse button with the Ctrl key
2066 // modifier. The m_context.m_wasClickOnXAxis is then simulated in the mouse
2067 // move handler. So we need to test which axis was clicked-on.
2068
2070 {
2071 // We are changing the range of the X axis.
2072
2073 // If xDelta is < 0, then we were dragging from right to left, we are
2074 // compressing the view on the x axis, by adding new data to the right
2075 // hand size of the graph. So we add xDelta to the upper bound of the
2076 // range. Otherwise we are uncompressing the view on the x axis and
2077 // remove the xDelta from the upper bound of the range. This is why we
2078 // have the
2079 // '-'
2080 // and not '+' below;
2081
2082 xAxis->setRange(xLower, xUpper - m_context.m_xDelta);
2083 }
2084 // End of
2085 // if(m_context.m_wasClickOnXAxis)
2086 else // that is, if(m_context.m_wasClickOnYAxis)
2087 {
2088 // We are changing the range of the Y axis.
2089
2090 // See above for an explanation of the computation (the - sign below).
2091
2092 yAxis->setRange(yLower, yUpper - m_context.m_yDelta);
2093 }
2094 // End of
2095 // else // that is, if(m_context.m_wasClickOnYAxis)
2096
2097 // Update the context with the current axes ranges
2098
2100
2102
2103 replot();
2104}

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 2143 of file baseplotwidget.cpp.

2144{
2145
2146 // Use the m_context.m_xRegionRangeStart/End values, but we need to sort the
2147 // values before using them, because now we want to really have the lower x
2148 // value. Simply craft a QCPRange that will swap the values if lower is not
2149 // < than upper QCustomPlot calls this normalization).
2150
2151 xAxis->setRange(
2153
2154 yAxis->setRange(
2156
2158
2161
2162 replot();
2163}

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 2591 of file baseplotwidget.cpp.

2592{
2593
2594 // We compute signed differentials. If the user does not want the sign,
2595 // fabs(double) is their friend.
2596
2597 // Compute the xAxis differential:
2598
2601
2602 // Same with the Y-axis range:
2603
2606
2607 return;
2608}

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 221 of file baseplotwidget.cpp.

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

818{
819 // qDebug() << "event key:" << event->key();
820
821 // The user is trying to move the positional cursor/markers. There are
822 // multiple way they can do that:
823 //
824 // 1.a. Hitting the arrow left/right keys alone will search for next pixel.
825 // 1.b. Hitting the arrow left/right keys with Alt modifier will search for
826 // a multiple of pixels that might be equivalent to one 20th of the pixel
827 // width of the plot widget. 1.c Hitting the left/right keys with Alt and
828 // Shift modifiers will search for a multiple of pixels that might be the
829 // equivalent to half of the pixel width.
830 //
831 // 2. Hitting the Control modifier will move the cursor to the next data
832 // point of the graph.
833
834 int pixel_increment = 0;
835
836 if(m_context.m_keyboardModifiers == Qt::NoModifier)
837 pixel_increment = 1;
838 else if(m_context.m_keyboardModifiers == Qt::AltModifier)
839 pixel_increment = 50;
840
841 // The user is moving the positional markers. This is equivalent to a
842 // non-dragging cursor movement to the next pixel. Note that the origin is
843 // located at the top left, so key down increments and key up decrements.
844
845 if(event->key() == Qt::Key_Left)
846 horizontalMoveMouseCursorCountPixels(-pixel_increment);
847 else if(event->key() == Qt::Key_Right)
849 else if(event->key() == Qt::Key_Up)
850 verticalMoveMouseCursorCountPixels(-pixel_increment);
851 else if(event->key() == Qt::Key_Down)
852 verticalMoveMouseCursorCountPixels(pixel_increment);
853
854 event->accept();
855}
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 859 of file baseplotwidget.cpp.

860{
861 // qDebug() << "event key:" << event->key();
862 event->accept();
863}

Referenced by keyReleaseEvent().

◆ dragDirection()

int pappso::BasePlotWidget::dragDirection ( )

MOUSE-related EVENTS.

MOUSE MOVEMENTS mouse/keyboard-triggered

Definition at line 1784 of file baseplotwidget.cpp.

1785{
1786 // The user is dragging the mouse, probably to rescale the axes, but we need
1787 // to sort out in which direction the drag is happening.
1788
1789 // This function should be called after calculateDragDeltas, so that
1790 // m_context has the proper x/y delta values that we'll compare.
1791
1792 // Note that we cannot compare simply x or y deltas because the y axis might
1793 // have a different scale that the x axis. So we first need to convert the
1794 // positions to pixels.
1795
1796 double x_delta_pixel =
1797 fabs(xAxis->coordToPixel(m_context.m_currentDragPoint.x()) -
1798 xAxis->coordToPixel(m_context.m_startDragPoint.x()));
1799
1800 double y_delta_pixel =
1801 fabs(yAxis->coordToPixel(m_context.m_currentDragPoint.y()) -
1802 yAxis->coordToPixel(m_context.m_startDragPoint.y()));
1803
1804 if(x_delta_pixel > y_delta_pixel)
1805 return Qt::Horizontal;
1806
1807 return Qt::Vertical;
1808}

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 2310 of file baseplotwidget.cpp.

2312{
2313 // The user has dragged the mouse left button on the graph, which means he
2314 // is willing to draw a selection rectangle, either for zooming-in or for
2315 // integration.
2316
2317 if(mp_xDeltaTextItem != nullptr)
2318 mp_xDeltaTextItem->setVisible(false);
2319 if(mp_yDeltaTextItem != nullptr)
2320 mp_yDeltaTextItem->setVisible(false);
2321
2322 // Ensure the right selection rectangle is drawn.
2323
2324 updateIntegrationScopeDrawing(as_line_segment, for_integration);
2325
2326 // Note that if we draw a zoom rectangle, then we are certainly not
2327 // measuring anything. So set the boolean value to false so that the user of
2328 // this widget or derived classes know that there is nothing to perform upon
2329 // (like deconvolution, for example).
2330
2332
2333 // Also remove the delta value from the pipeline by sending a simple
2334 // distance without measurement signal.
2335
2336 emit xAxisMeasurementSignal(m_context, false);
2337
2338 replot();
2339}
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 2343 of file baseplotwidget.cpp.

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

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 2485 of file baseplotwidget.cpp.

2486{
2487 // See drawXScopeSpanFeatures() for explanations.
2488
2489 // Check right away if there is height!
2490 double height;
2491 if(!m_context.msp_integrationScope->getHeight(height))
2492 qFatal("Could not get height.");
2493
2494 // If there is no height, we have nothing to do here.
2495 if(!height)
2496 return;
2497 // qDebug() << "height:" << height;
2498
2499 // FIXME: is this still true?
2500 //
2501 // We do not want to show the position markers because the only horiontal
2502 // line to be visible must be contained between the start and end vertical
2503 // tracer items.
2504 mp_hPosTracerItem->setVisible(false);
2505 mp_vPosTracerItem->setVisible(false);
2506
2507 // First the easy part: the vertical position: centered on the
2508 // scope Y span.
2509 QPointF bottom_most_point;
2510 if(!m_context.msp_integrationScope->getBottomMostPoint(bottom_most_point))
2511 qFatal("Could not get the bottom-most bottom point.");
2512
2513 double y_axis_center_position = bottom_most_point.y() + height / 2;
2514
2515 // We want to draw the text outside the rectangle (if normal rectangle)
2516 // at a small distance from the vertical limit of the scope at the
2517 // position of the current drag point. We need to check the horizontal
2518 // drag direction to put the text at the right place (left of
2519 // current drag point if dragging right to left, for example).
2520
2521 // What is the distance between the rectangle line at current drag point and
2522 // the text itself.
2523 int pixels_away_from_line = 15;
2524 double x_axis_coordinate;
2525 double x_axis_pixel_coordinate;
2526
2527 if(static_cast<int>(m_context.m_dragDirections) &
2528 static_cast<int>(DragDirections::RIGHT_TO_LEFT))
2529 {
2530 QPointF left_most_point;
2531
2532 if(!m_context.msp_integrationScope->getLeftMostPoint(left_most_point))
2533 qFatal("Failed to get left most point.");
2534
2535 x_axis_coordinate = left_most_point.x();
2536
2537 pixels_away_from_line *= -1;
2538 }
2539 else
2540 {
2541 QPointF right_most_point;
2542
2543 if(!m_context.msp_integrationScope->getRightMostPoint(right_most_point))
2544 qFatal("Failed to get right most point.");
2545
2546 x_axis_coordinate = right_most_point.x();
2547 }
2548 x_axis_pixel_coordinate = xAxis->coordToPixel(x_axis_coordinate);
2549
2550 double x_axis_modified_pixel_coordinate =
2551 x_axis_pixel_coordinate + pixels_away_from_line;
2552
2553 // Set aside a point instance to store the pixel coordinates of the text.
2554 QPointF pixel_coordinates;
2555
2556 pixel_coordinates.setX(x_axis_modified_pixel_coordinate);
2557 pixel_coordinates.setY(y_axis_center_position);
2558
2559 // Now convert back to graph coordinates.
2560
2561 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
2562 yAxis->pixelToCoord(pixel_coordinates.y()));
2563
2564 mp_yDeltaTextItem->position->setCoords(graph_coordinates.x(),
2565 y_axis_center_position);
2566
2567 int decimals = Utils::zeroDecimalsInValue(height) + 3;
2568
2569 QString label_text = QString("full y span %1 -- y drag delta %2")
2570 .arg(height, 0, 'f', decimals)
2571 .arg(fabs(m_context.m_yDelta), 0, 'f', decimals);
2572
2573 mp_yDeltaTextItem->setText(label_text);
2574 mp_yDeltaTextItem->setFont(QFont(font().family(), 9));
2575 mp_yDeltaTextItem->setVisible(true);
2576 mp_yDeltaTextItem->setRotation(90);
2577
2578 // Set the boolean to true so that derived widgets know that something is
2579 // being measured, and they can act accordingly, for example by computing
2580 // deconvolutions in a mass spectrum.
2582
2583 replot();
2584
2585 // Let the caller know that we were measuring something.
2587}

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 3336 of file baseplotwidget.cpp.

3337{
3338 return m_context;
3339}

References m_context.

◆ getInnermostRangeX()

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

Definition at line 2017 of file baseplotwidget.cpp.

2018{
2019
2020 return getRange(Axis::x, RangeType::innermost, found_range);
2021}
QCPRange getRange(Axis axis, RangeType range_type, bool &found_range) const

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

◆ getInnermostRangeY()

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

Definition at line 2032 of file baseplotwidget.cpp.

2033{
2034
2035 return getRange(Axis::y, RangeType::innermost, found_range);
2036}

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

◆ getOutermostRangeX()

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

Definition at line 2025 of file baseplotwidget.cpp.

2026{
2027 return getRange(Axis::x, RangeType::outermost, found_range);
2028}

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

◆ getOutermostRangeY()

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

Definition at line 2040 of file baseplotwidget.cpp.

2041{
2042 return getRange(Axis::y, RangeType::outermost, found_range);
2043}

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

◆ getPen()

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

Definition at line 408 of file baseplotwidget.cpp.

409{
410 return m_pen;
411}

References m_pen.

◆ getPlottingColor() [1/2]

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

Reimplemented in pappso::BaseColorMapPlotWidget.

Definition at line 458 of file baseplotwidget.cpp.

459{
460 QCPGraph *graph_p = graph(index);
461
462 if(graph_p == nullptr)
463 qFatal("Programming error.");
464
465 return getPlottingColor(graph_p);
466}
virtual QColor getPlottingColor(QCPAbstractPlottable *plottable_p) const

References getPlottingColor().

◆ getPlottingColor() [2/2]

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

Definition at line 448 of file baseplotwidget.cpp.

449{
450 if(plottable_p == nullptr)
451 qFatal("Programming error.");
452
453 return plottable_p->pen().color();
454}

Referenced by getPlottingColor().

◆ getRange()

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

Definition at line 1925 of file baseplotwidget.cpp.

1928{
1929
1930 // Iterate in all the graphs in this widget and return a QCPRange that has
1931 // its lower member as the greatest lower value of all
1932 // its upper member as the smallest upper value of all
1933
1934 if(!graphCount())
1935 {
1936 found_range = false;
1937
1938 return QCPRange(0, 1);
1939 }
1940
1941 if(graphCount() == 1)
1942 return graph()->getKeyRange(found_range);
1943
1944 bool found_at_least_one_range = false;
1945
1946 // Create an invalid range.
1947 QCPRange result_range(QCPRange::minRange + 1, QCPRange::maxRange + 1);
1948
1949 for(int iter = 0; iter < graphCount(); ++iter)
1950 {
1951 QCPRange temp_range;
1952
1953 bool found_range_for_iter = false;
1954
1955 QCPGraph *graph_p = graph(iter);
1956
1957 // Depending on the axis param, select the key or value range.
1958
1959 if(axis == Axis::x)
1960 temp_range = graph_p->getKeyRange(found_range_for_iter);
1961 else if(axis == Axis::y)
1962 temp_range = graph_p->getValueRange(found_range_for_iter);
1963 else
1964 qFatal("Cannot reach this point. Programming error.");
1965
1966 // Was a range found for the iterated graph ? If not skip this
1967 // iteration.
1968
1969 if(!found_range_for_iter)
1970 continue;
1971
1972 // While the innermost_range is invalid, we need to seed it with a good
1973 // one. So check this.
1974
1975 if(!QCPRange::validRange(result_range))
1976 qFatal("The obtained range is invalid !");
1977
1978 // At this point we know the obtained range is OK.
1979 result_range = temp_range;
1980
1981 // We found at least one valid range!
1982 found_at_least_one_range = true;
1983
1984 // At this point we have two valid ranges to compare. Depending on
1985 // range_type, we need to perform distinct comparisons.
1986
1987 if(range_type == RangeType::innermost)
1988 {
1989 if(temp_range.lower > result_range.lower)
1990 result_range.lower = temp_range.lower;
1991 if(temp_range.upper < result_range.upper)
1992 result_range.upper = temp_range.upper;
1993 }
1994 else if(range_type == RangeType::outermost)
1995 {
1996 if(temp_range.lower < result_range.lower)
1997 result_range.lower = temp_range.lower;
1998 if(temp_range.upper > result_range.upper)
1999 result_range.upper = temp_range.upper;
2000 }
2001 else
2002 qFatal("Cannot reach this point. Programming error.");
2003
2004 // Continue to next graph, if any.
2005 }
2006 // End of
2007 // for(int iter = 0; iter < graphCount(); ++iter)
2008
2009 // Let the caller know if we found at least one range.
2010 found_range = found_at_least_one_range;
2011
2012 return result_range;
2013}

References pappso::innermost, pappso::outermost, pappso::x, and pappso::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 1901 of file baseplotwidget.cpp.

1902{
1903 QCPGraph *graph_p = graph(index);
1904
1905 if(graph_p == nullptr)
1906 qFatal("Programming error.");
1907
1908 return graph_p->getKeyRange(found_range);
1909}

◆ getRangeY()

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

Definition at line 1913 of file baseplotwidget.cpp.

1914{
1915 QCPGraph *graph_p = graph(index);
1916
1917 if(graph_p == nullptr)
1918 qFatal("Programming error.");
1919
1920 return graph_p->getValueRange(found_range);
1921}

◆ 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 2260 of file baseplotwidget.cpp.

2261{
2262 mp_xDeltaTextItem->setVisible(false);
2263 mp_yDeltaTextItem->setVisible(false);
2264
2265 // mp_zoomRectItem->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}
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 3202 of file baseplotwidget.cpp.

3203{
3204 mp_selectionRectangeLine1->setVisible(false);
3205 mp_selectionRectangeLine2->setVisible(false);
3206 mp_selectionRectangeLine3->setVisible(false);
3207 mp_selectionRectangeLine4->setVisible(false);
3208
3209 if(reset_values)
3210 {
3212 }
3213}
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 2294 of file baseplotwidget.cpp.

2295{
2297 mp_hPosTracerItem->setVisible(false);
2298 mp_vPosTracerItem->setVisible(false);
2299
2300 mp_vStartTracerItem->setVisible(false);
2301 mp_vEndTracerItem->setVisible(false);
2302
2303 // Force a replot to make sure the action is immediately visible by the
2304 // user, even without moving the mouse.
2305 replot();
2306}
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 1848 of file baseplotwidget.cpp.

1849{
1850 QPointF pixel_coordinates(
1851 xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()) + pixel_count,
1852 yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()));
1853
1854 // Now convert back to local coordinates.
1855
1856 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1857 yAxis->pixelToCoord(pixel_coordinates.y()));
1858
1859 return graph_coordinates;
1860}

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

Referenced by horizontalMoveMouseCursorCountPixels().

◆ horizontalMoveMouseCursorCountPixels()

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

Definition at line 1832 of file baseplotwidget.cpp.

1833{
1834 QPointF graph_coord = horizontalGetGraphCoordNewPointCountPixels(pixel_count);
1835
1836 QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()),
1837 yAxis->coordToPixel(graph_coord.y()));
1838
1839 // Now we need ton convert the new coordinates to the global position system
1840 // and to move the cursor to that new position. That will create an event to
1841 // move the mouse cursor.
1842
1843 moveMouseCursorPixelCoordToGlobal(pixel_coord.toPoint());
1844}
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 1728 of file baseplotwidget.cpp.

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

Referenced by mousePressHandler().

◆ isClickOntoYAxis()

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

Definition at line 1754 of file baseplotwidget.cpp.

1755{
1756 QCPLayoutElement *layoutElement = layoutElementAt(mousePoint);
1757
1758 if(layoutElement &&
1759 layoutElement == dynamic_cast<QCPLayoutElement *>(axisRect()))
1760 {
1761 // The graph is *inside* the axisRect that is the outermost envelope of
1762 // the graph. Thus, if we want to know if the click was indeed on an
1763 // axis, we need to check what selectable part of the the axisRect we
1764 // were clicking:
1765 QCPAxis::SelectablePart selectablePart;
1766
1767 selectablePart = yAxis->getPartAt(mousePoint);
1768
1769 if(selectablePart == QCPAxis::spAxisLabel ||
1770 selectablePart == QCPAxis::spAxis ||
1771 selectablePart == QCPAxis::spTickLabels)
1772 return true;
1773 }
1774
1775 return false;
1776}

Referenced by mousePressHandler().

◆ isSelectionRectangleVisible()

bool pappso::BasePlotWidget::isSelectionRectangleVisible ( )
virtual

Definition at line 3268 of file baseplotwidget.cpp.

3269{
3270 // Sanity check
3271 int check = 0;
3272
3273 check += mp_selectionRectangeLine1->visible();
3274 check += mp_selectionRectangeLine2->visible();
3275 check += mp_selectionRectangeLine3->visible();
3276 check += mp_selectionRectangeLine4->visible();
3277
3278 if(check > 0)
3279 return true;
3280
3281 return false;
3282}

References mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, and mp_selectionRectangeLine4.

◆ isVerticalDisplacementAboveThreshold()

bool pappso::BasePlotWidget::isVerticalDisplacementAboveThreshold ( )
virtual

Definition at line 2612 of file baseplotwidget.cpp.

2613{
2614 // First get the height of the plot.
2615 double plotHeight = yAxis->range().upper - yAxis->range().lower;
2616
2617 double heightDiff =
2619
2620 double heightDiffRatio = (heightDiff / plotHeight) * 100;
2621
2622 if(heightDiffRatio > 10)
2623 {
2624 return true;
2625 }
2626
2627 return false;
2628}

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 619 of file baseplotwidget.cpp.

620{
621 // qDebug() << "ENTER";
622
623 // We need this because some keys modify our behaviour.
624 m_context.m_pressedKeyCode = event->key();
625 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
626
627 if(event->key() == Qt::Key_Left || event->key() == Qt::Key_Right ||
628 event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)
629 {
630 return directionKeyPressEvent(event);
631 }
632 else if(event->key() == m_leftMousePseudoButtonKey ||
633 event->key() == m_rightMousePseudoButtonKey)
634 {
635 return mousePseudoButtonKeyPressEvent(event);
636 }
637
638 // Do not do anything here, because this function is used by derived classes
639 // that will emit the signal below. Otherwise there are going to be multiple
640 // signals sent.
641 // qDebug() << "Going to emit keyPressEventSignal(m_context);";
642 // emit keyPressEventSignal(m_context);
643}
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 648 of file baseplotwidget.cpp.

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

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

◆ layerableLayerName()

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

Definition at line 192 of file baseplotwidget.cpp.

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

◆ 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 942 of file baseplotwidget.cpp.

943{
944
945 // If we have no focus, then get it. See setFocus() to understand why asking
946 // for focus is cosly and thus why we want to make this decision first.
947 if(!hasFocus())
948 setFocus();
949
950 // qDebug() << (graph() != nullptr);
951 // if(graph(0) != nullptr)
952 // { // check if the widget contains some graphs
953
954 // The event->button() must be by Qt instructions considered to be 0.
955
956 // Whatever happens, we want to store the plot coordinates of the current
957 // mouse cursor position (will be useful later for countless needs).
958
959 // Fix from Qt5 to Qt6
960#if QT_VERSION < 0x060000
961 QPointF mousePoint = event->localPos();
962#else
963 QPointF mousePoint = event->position();
964#endif
965 // qDebug() << "local mousePoint position in pixels:" << mousePoint;
966
967 m_context.m_lastCursorHoveredPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
968 m_context.m_lastCursorHoveredPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
969
970 // qDebug() << "lastCursorHoveredPoint coord:"
971 //<< m_context.m_lastCursorHoveredPoint;
972
973 // Now, depending on the button(s) (if any) that are pressed or not, we
974 // have a different processing.
975
976 // qDebug();
977
978 if(m_context.m_pressedMouseButtons & Qt::LeftButton ||
979 m_context.m_pressedMouseButtons & Qt::RightButton)
981 else
983 // }
984 // qDebug();
985 event->accept();
986}
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 1054 of file baseplotwidget.cpp.

1055{
1056 // qDebug();
1058
1059 // Now store the mouse position data into the the current drag point
1060 // member datum, that will be used in countless occasions later.
1062 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1063
1064 // When we drag (either keyboard or mouse), we hide the position markers
1065 // (black) and we show the start and end vertical markers for the region.
1066 // Then, we draw the horizontal region range marker that delimits
1067 // horizontally the dragged-over region.
1068
1069 if(mp_hPosTracerItem != nullptr)
1070 mp_hPosTracerItem->setVisible(false);
1071 if(mp_vPosTracerItem != nullptr)
1072 mp_vPosTracerItem->setVisible(false);
1073
1074 // Only bother with the tracers if the user wants them to be visible.
1076 {
1077
1078 // The vertical end tracer position must be refreshed.
1079 mp_vEndTracerItem->start->setCoords(m_context.m_currentDragPoint.x(),
1080 yAxis->range().upper);
1081
1083 yAxis->range().lower);
1084
1085 mp_vEndTracerItem->setVisible(true);
1086 }
1087
1088 // Whatever the button, when we are dealing with the axes, we do not
1089 // want to show any of the tracers.
1090
1092 {
1093 if(mp_hPosTracerItem != nullptr)
1094 mp_hPosTracerItem->setVisible(false);
1095 if(mp_vPosTracerItem != nullptr)
1096 mp_vPosTracerItem->setVisible(false);
1097
1098 if(mp_vStartTracerItem != nullptr)
1099 mp_vStartTracerItem->setVisible(false);
1100 if(mp_vEndTracerItem != nullptr)
1101 mp_vEndTracerItem->setVisible(false);
1102 }
1103 else
1104 {
1105 // Since we are not dragging the mouse cursor over the axes, make sure
1106 // we store the drag directions in the context, as this might be
1107 // useful for later operations.
1108
1110
1111 // qDebug() << m_context.toString();
1112 }
1113
1114 // Because when we drag the mouse button (whatever the button) we need to
1115 // know what is the drag delta (distance between start point and current
1116 // point of the drag operation) on both axes, ask that these x|y deltas be
1117 // computed.
1119
1120 // Now deal with the BUTTON-SPECIFIC CODE.
1121
1122 if(m_context.m_mouseButtonsAtMousePress & Qt::LeftButton)
1123 {
1125 }
1126 else if(m_context.m_mouseButtonsAtMousePress & Qt::RightButton)
1127 {
1129 }
1130}
Qt::MouseButtons m_mouseButtonsAtMousePress
DragDirections recordDragDirections()
virtual void mouseMoveHandlerLeftButtonDraggingCursor()
virtual void calculateDragDeltas()
virtual void mouseMoveHandlerRightButtonDraggingCursor()

References calculateDragDeltas(), 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 1134 of file baseplotwidget.cpp.

1135{
1136 // qDebug() << "The left button is dragging.";
1137
1138 // Set the context.m_isMeasuringDistance to false, which later might be set
1139 // to true if effectively we are measuring a distance. This is required
1140 // because the derived widget classes might want to know if they have to
1141 // perform some action on the basis that context is measuring a distance,
1142 // for example the mass spectrum-specific widget might want to compute
1143 // deconvolutions.
1144
1146
1147 // Let's first check if the mouse drag operation originated on either
1148 // axis. In that case, the user is performing axis reframing or rescaling.
1149
1151 {
1152 // qDebug() << "Click was on one of the axes.";
1153
1154 if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1155 {
1156 // The user is asking a rescale of the plot.
1157
1158 // We know that we do not want the tracers when we perform axis
1159 // rescaling operations.
1160
1161 if(mp_hPosTracerItem != nullptr)
1162 mp_hPosTracerItem->setVisible(false);
1163 if(mp_vPosTracerItem != nullptr)
1164 mp_vPosTracerItem->setVisible(false);
1165
1166 if(mp_vStartTracerItem != nullptr)
1167 mp_vStartTracerItem->setVisible(false);
1168 if(mp_vEndTracerItem != nullptr)
1169 mp_vEndTracerItem->setVisible(false);
1170
1171 // This operation is particularly intensive, thus we want to
1172 // reduce the number of calculations by skipping this calculation
1173 // a number of times. The user can ask for this feature by
1174 // clicking the 'Q' letter.
1175
1176 if(m_context.m_pressedKeyCode == Qt::Key_Q)
1177 {
1179 {
1181 return;
1182 }
1183 else
1184 {
1186 }
1187 }
1188
1189 // qDebug() << "Asking that the axes be rescaled.";
1190
1191 axisRescale();
1192 }
1193 else
1194 {
1195 // The user was simply dragging the axis. Just pan, that is slide
1196 // the plot in the same direction as the mouse movement and with the
1197 // same amplitude.
1198
1199 // qDebug() << "Asking that the axes be panned.";
1200
1201 axisPan();
1202 }
1203
1204 return;
1205 }
1206
1207 // At this point we understand that the user was not performing any
1208 // panning/rescaling operation by clicking on any one of the axes.. Go on
1209 // with other possibilities.
1210
1211 // Let's check if the user is actually drawing a rectangle (covering a
1212 // real area) or is drawing a line.
1213
1214 // qDebug() << "The mouse dragging did not originate on an axis.";
1215
1217 {
1218 // qDebug() << "Apparently the selection is two-dimensional.";
1219
1220 // When we draw a two-dimensional integration scope, the tracers are of no
1221 // use.
1222
1223 if(mp_hPosTracerItem != nullptr)
1224 mp_hPosTracerItem->setVisible(false);
1225 if(mp_vPosTracerItem != nullptr)
1226 mp_vPosTracerItem->setVisible(false);
1227
1228 if(mp_vStartTracerItem != nullptr)
1229 mp_vStartTracerItem->setVisible(false);
1230 if(mp_vEndTracerItem != nullptr)
1231 mp_vEndTracerItem->setVisible(false);
1232
1233 // Draw the rectangle, false, not as line segment and
1234 // false, not for integration
1236
1237 // Draw the selection width/height text
1240 }
1241 else
1242 {
1243 // qDebug() << "Apparently we are measuring a delta.";
1244
1245 // Draw the rectangle, true, as line segment and
1246 // false, not for integration
1248
1249 // The pure position tracers should be hidden.
1250 if(mp_hPosTracerItem != nullptr)
1251 mp_hPosTracerItem->setVisible(true);
1252 if(mp_vPosTracerItem != nullptr)
1253 mp_vPosTracerItem->setVisible(true);
1254
1255 // Then, make sure the region range vertical tracers are visible.
1256 if(mp_vStartTracerItem != nullptr)
1257 mp_vStartTracerItem->setVisible(true);
1258 if(mp_vEndTracerItem != nullptr)
1259 mp_vEndTracerItem->setVisible(true);
1260
1261 // Draw the selection width text
1263 }
1264}
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 990 of file baseplotwidget.cpp.

991{
992
993 // qDebug();
995
996 // qDebug();
997 // We are not dragging the mouse (no button pressed), simply let this
998 // widget's consumer know the position of the cursor and update the markers.
999 // The consumer of this widget will update mouse cursor position at
1000 // m_context.m_lastCursorHoveredPoint if so needed.
1001
1003
1004 // qDebug();
1005
1006 // We are not dragging, so we do not show the region end tracer we only
1007 // show the anchoring start trace that might be of use if the user starts
1008 // using the arrow keys to move the cursor.
1009 if(mp_vEndTracerItem != nullptr)
1010 mp_vEndTracerItem->setVisible(false);
1011
1012 // qDebug();
1013 // Only bother with the tracers if the user wants them to be visible.
1014 // Their crossing point must be exactly at the last cursor-hovered point.
1015
1017 {
1018 // We are not dragging, so only show the position markers (v and h);
1019
1020 // qDebug();
1021 if(mp_hPosTracerItem != nullptr)
1022 {
1023 // Horizontal position tracer.
1024 mp_hPosTracerItem->setVisible(true);
1025 mp_hPosTracerItem->start->setCoords(
1026 xAxis->range().lower, m_context.m_lastCursorHoveredPoint.y());
1027 mp_hPosTracerItem->end->setCoords(
1028 xAxis->range().upper, m_context.m_lastCursorHoveredPoint.y());
1029 }
1030
1031 // qDebug();
1032 // Vertical position tracer.
1033 if(mp_vPosTracerItem != nullptr)
1034 {
1035 mp_vPosTracerItem->setVisible(true);
1036
1037 mp_vPosTracerItem->setVisible(true);
1038 mp_vPosTracerItem->start->setCoords(
1039 m_context.m_lastCursorHoveredPoint.x(), yAxis->range().upper);
1040 mp_vPosTracerItem->end->setCoords(
1041 m_context.m_lastCursorHoveredPoint.x(), yAxis->range().lower);
1042 }
1043
1044 // qDebug();
1045 replot();
1046 }
1047
1048
1049 return;
1050}
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 1268 of file baseplotwidget.cpp.

1269{
1270 // qDebug() << "The right button is dragging.";
1271
1272 // Set the context.m_isMeasuringDistance to false, which later might be set
1273 // to true if effectively we are measuring a distance. This is required
1274 // because the derived widgets might want to know if they have to perform
1275 // some action on the basis that context is measuring a distance, for
1276 // example the mass spectrum-specific widget might want to compute
1277 // deconvolutions.
1278
1280
1282 {
1283 // qDebug() << "Apparently the selection has height.";
1284
1285 // When we draw a rectangle the tracers are of no use.
1286
1287 if(mp_hPosTracerItem != nullptr)
1288 mp_hPosTracerItem->setVisible(false);
1289 if(mp_vPosTracerItem != nullptr)
1290 mp_vPosTracerItem->setVisible(false);
1291
1292 if(mp_vStartTracerItem != nullptr)
1293 mp_vStartTracerItem->setVisible(false);
1294 if(mp_vEndTracerItem != nullptr)
1295 mp_vEndTracerItem->setVisible(false);
1296
1297 // Draw the rectangle, false for as_line_segment and true for
1298 // integration.
1300
1301 // Draw the selection width/height text
1304 }
1305 else
1306 {
1307 // qDebug() << "Apparently the selection is a not a rectangle.";
1308
1309 // Draw the rectangle, true as line segment and
1310 // true for integration
1312
1313 // Draw the selection width text
1315 }
1316}

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

Referenced by mouseMoveHandlerDraggingCursor().

◆ 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 1320 of file baseplotwidget.cpp.

1321{
1322 // When the user clicks this widget it has to take focus.
1323 setFocus();
1324
1325 // Fix from Qt5 to Qt6
1326 // QPointF mousePoint = event->localPos();
1327
1328#if QT_VERSION < 0x060000
1329 QPointF mousePoint = event->localPos();
1330#else
1331 QPointF mousePoint = event->position();
1332#endif
1333
1334 m_context.m_lastPressedMouseButton = event->button();
1335 m_context.m_mouseButtonsAtMousePress = event->buttons();
1336
1337 // The pressedMouseButtons must continually inform on the status of
1338 // pressed buttons so add the pressed button.
1339 m_context.m_pressedMouseButtons |= event->button();
1340
1341 // qDebug().noquote() << m_context.toString();
1342
1343 // In all the processing of the events, we need to know if the user is
1344 // clicking somewhere with the intent to change the plot ranges (reframing
1345 // or rescaling the plot).
1346 //
1347 // Reframing the plot means that the new x and y axes ranges are modified
1348 // so that they match the region that the user has encompassed by left
1349 // clicking the mouse and dragging it over the plot. That is we reframe
1350 // the plot so that it contains only the "selected" region.
1351 //
1352 // Rescaling the plot means the the new x|y axis range is modified such
1353 // that the lower axis range is constant and the upper axis range is moved
1354 // either left or right by the same amont as the x|y delta encompassed by
1355 // the user moving the mouse. The axis is thus either compressed (mouse
1356 // movement is leftwards) or un-compressed (mouse movement is rightwards).
1357
1358 // There are two ways to perform axis range modifications:
1359 //
1360 // 1. By clicking on any of the axes
1361 // 2. By clicking on the plot region but using keyboard key modifiers,
1362 // like Alt and Ctrl.
1363 //
1364 // We need to know both cases separately which is why we need to perform a
1365 // number of tests below.
1366
1367 // Let's check if the click is on the axes, either X or Y, because that
1368 // will allow us to take proper actions.
1369
1370 if(isClickOntoXAxis(mousePoint))
1371 {
1372 // The X axis was clicked upon, we need to document that:
1373 // qDebug() << __FILE__ << __LINE__
1374 //<< "Layout element is axisRect and actually on an X axis part.";
1375
1377
1378 // int currentInteractions = interactions();
1379 // currentInteractions |= QCP::iRangeDrag;
1380 // setInteractions((QCP::Interaction)currentInteractions);
1381 // axisRect()->setRangeDrag(xAxis->orientation());
1382 }
1383 else
1385
1386 if(isClickOntoYAxis(mousePoint))
1387 {
1388 // The Y axis was clicked upon, we need to document that:
1389 // qDebug() << __FILE__ << __LINE__
1390 //<< "Layout element is axisRect and actually on an Y axis part.";
1391
1393
1394 // int currentInteractions = interactions();
1395 // currentInteractions |= QCP::iRangeDrag;
1396 // setInteractions((QCP::Interaction)currentInteractions);
1397 // axisRect()->setRangeDrag(yAxis->orientation());
1398 }
1399 else
1401
1402 // At this point, let's see if we need to remove the QCP::iRangeDrag bit:
1403
1405 {
1406 // qDebug() << __FILE__ << __LINE__
1407 // << "Click outside of axes.";
1408
1409 // int currentInteractions = interactions();
1410 // currentInteractions = currentInteractions & ~QCP::iRangeDrag;
1411 // setInteractions((QCP::Interaction)currentInteractions);
1412 }
1413
1414 m_context.m_startDragPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
1415 m_context.m_startDragPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
1416
1417 // Now install the vertical start tracer at the last cursor hovered
1418 // position.
1419 if((m_shouldTracersBeVisible) && (mp_vStartTracerItem != nullptr))
1420 mp_vStartTracerItem->setVisible(true);
1421
1422 if(mp_vStartTracerItem != nullptr)
1423 {
1424 mp_vStartTracerItem->start->setCoords(
1425 m_context.m_lastCursorHoveredPoint.x(), yAxis->range().upper);
1426 mp_vStartTracerItem->end->setCoords(
1427 m_context.m_lastCursorHoveredPoint.x(), yAxis->range().lower);
1428 }
1429
1430 replot();
1431}
Qt::MouseButtons m_lastPressedMouseButton
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, 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 867 of file baseplotwidget.cpp.

869{
870 // qDebug();
871}

Referenced by keyPressEvent().

◆ mousePseudoButtonKeyReleaseEvent()

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

Definition at line 875 of file baseplotwidget.cpp.

876{
877
878 QPointF pixel_coordinates(
879 xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()),
880 yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()));
881
882 Qt::MouseButton button = Qt::NoButton;
883 QEvent::Type q_event_type = QEvent::MouseButtonPress;
884
885 if(event->key() == m_leftMousePseudoButtonKey)
886 {
887 // Toggles the left mouse button on/off
888
889 button = Qt::LeftButton;
890
893
895 q_event_type = QEvent::MouseButtonPress;
896 else
897 q_event_type = QEvent::MouseButtonRelease;
898 }
899 else if(event->key() == m_rightMousePseudoButtonKey)
900 {
901 // Toggles the right mouse button.
902
903 button = Qt::RightButton;
904
907
909 q_event_type = QEvent::MouseButtonPress;
910 else
911 q_event_type = QEvent::MouseButtonRelease;
912 }
913
914 // qDebug() << "pressed/released pseudo button:" << button
915 //<< "q_event_type:" << q_event_type;
916
917 // Synthesize a QMouseEvent and use it.
918
919 QMouseEvent *mouse_event_p =
920 new QMouseEvent(q_event_type,
921 pixel_coordinates,
922 mapToGlobal(pixel_coordinates.toPoint()),
923 mapToGlobal(pixel_coordinates.toPoint()),
924 button,
925 button,
927 Qt::MouseEventSynthesizedByApplication);
928
929 if(q_event_type == QEvent::MouseButtonPress)
930 mousePressHandler(mouse_event_p);
931 else
932 mouseReleaseHandler(mouse_event_p);
933
934 // event->accept();
935}
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 1435 of file baseplotwidget.cpp.

1436{
1437 // qDebug();
1438
1439 // Now the real code of this function.
1440
1441 m_context.m_lastReleasedMouseButton = event->button();
1442
1443 // The event->buttons() is the description of the buttons that are pressed
1444 // at the moment the handler is invoked, that is now. If left and right were
1445 // pressed, and left was released, event->buttons() would be right.
1446 m_context.m_mouseButtonsAtMouseRelease = event->buttons();
1447
1448 // The pressedMouseButtons must continually inform on the status of pressed
1449 // buttons so remove the released button.
1450 m_context.m_pressedMouseButtons ^= event->button();
1451
1452 // qDebug().noquote() << m_context.toString();
1453
1454 // We'll need to know if modifiers were pressed a the moment the user
1455 // released the mouse button.
1456 m_context.m_keyboardModifiers = QGuiApplication::keyboardModifiers();
1457
1459 {
1460 // Let the user know that the mouse was *not* being dragged.
1462
1463 event->accept();
1464
1465 return;
1466 }
1467
1468 // Let the user know that the mouse was being dragged.
1470
1471 // We cannot hide all items in one go because we rely on their visibility
1472 // to know what kind of dragging operation we need to perform (line-only
1473 // X-based zoom or rectangle-based X- and Y-based zoom, for example). The
1474 // only thing we know is that we can make the text invisible.
1475
1476 // Same for the x delta text item
1477 mp_xDeltaTextItem->setVisible(false);
1478 mp_yDeltaTextItem->setVisible(false);
1479
1480 // We do not show the end vertical region range marker.
1481 mp_vEndTracerItem->setVisible(false);
1482
1483 // Horizontal position tracer.
1484 mp_hPosTracerItem->setVisible(true);
1485 mp_hPosTracerItem->start->setCoords(xAxis->range().lower,
1487 mp_hPosTracerItem->end->setCoords(xAxis->range().upper,
1489
1490 // Vertical position tracer.
1491 mp_vPosTracerItem->setVisible(true);
1492
1493 mp_vPosTracerItem->setVisible(true);
1495 yAxis->range().upper);
1497 yAxis->range().lower);
1498
1499 // Force replot now because later that call might not be performed.
1500 replot();
1501
1502 // If we were using the "quantum" display for the rescale of the axes
1503 // using the Ctrl-modified left button click drag in the axes, then reset
1504 // the count to 0.
1506
1507 // By definition we are stopping the drag operation by releasing the mouse
1508 // button. Whatever that mouse button was pressed before and if there was
1509 // one pressed before. We cannot set that boolean value to false before
1510 // this place, because we call a number of routines above that need to know
1511 // that dragging was occurring. Like mouseReleaseHandledEvent(event) for
1512 // example.
1513
1515
1516 // Before returning, emit the signal for the user of
1517 // this class consumption.
1518 // qDebug() << "Emitting mouseReleaseEventSignal.";
1520
1521 // Now that we have computed the useful ranges, we need to check what to do
1522 // depending on the button that was pressed.
1523
1524 if(m_context.m_lastReleasedMouseButton == Qt::LeftButton)
1525 {
1527 }
1528 else if(m_context.m_lastReleasedMouseButton == Qt::RightButton)
1529 {
1531 }
1532
1533 event->accept();
1534
1535 return;
1536}
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 1540 of file baseplotwidget.cpp.

1541{
1542
1544 {
1545
1546 // When the mouse move handler pans the plot, we cannot store each axes
1547 // range history element that would mean store a huge amount of such
1548 // elements, as many element as there are mouse move event handled by
1549 // the Qt event queue. But we can store an axis range history element
1550 // for the last situation of the mouse move: when the button is
1551 // released:
1552
1554
1556
1557 replot();
1558
1559 // Nothing else to do.
1560 return;
1561 }
1562
1563 // There are two possibilities:
1564 //
1565 // 1. The full integration scope (four lines) were currently drawn, which
1566 // means the user was willing to perform a zoom operation.
1567 //
1568 // 2. Only the first top line was drawn, which means the user was dragging
1569 // the cursor horizontally. That might have two ends, as shown below.
1570
1571 // So, first check what is drawn of the selection polygon.
1572
1573 SelectionDrawingLines selection_drawing_lines =
1575
1576 // Now that we know what was currently drawn of the selection polygon, we
1577 // can remove it. true to reset the values to 0.
1579
1580 // Force replot now because later that call might not be performed.
1581 replot();
1582
1583 if(selection_drawing_lines == SelectionDrawingLines::FULL_POLYGON)
1584 {
1585 // qDebug() << "Yes, the full polygon was visible";
1586
1587 // If we were dragging with the left button pressed and could draw a
1588 // rectangle, then we were preparing a zoom operation. Let's bring that
1589 // operation to its accomplishment.
1590
1591 axisZoom();
1592
1593 return;
1594 }
1595 else if(selection_drawing_lines == SelectionDrawingLines::TOP_LINE)
1596 {
1597 // qDebug() << "No, only the top line of the full polygon was visible";
1598
1599 // The user was dragging the left mouse cursor and that may mean they
1600 // were measuring a distance or willing to perform a special zoom
1601 // operation if the Ctrl key was down.
1602
1603 // If the user started by clicking in the plot region, dragged the mouse
1604 // cursor with the left button and pressed the Ctrl modifier, then that
1605 // means that they wanted to do a rescale over the x-axis in the form of
1606 // a reframing.
1607
1608 if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1609 {
1610 return axisReframe();
1611 }
1612 }
1613 // else
1614 // qDebug() << "Another possibility.";
1615}
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 1619 of file baseplotwidget.cpp.

1620{
1621 // qDebug();
1622 // The right button is used for the integrations. Not for axis range
1623 // operations. So all we have to do is remove the various graphics items and
1624 // send a signal with the context that contains all the data required by the
1625 // user to perform the integrations over the right plot regions.
1626
1627 // Whatever we were doing we need to make the selection line invisible:
1628
1629 if(mp_xDeltaTextItem->visible())
1630 mp_xDeltaTextItem->setVisible(false);
1631 if(mp_yDeltaTextItem->visible())
1632 mp_yDeltaTextItem->setVisible(false);
1633
1634 // Also make the vertical end tracer invisible.
1635 mp_vEndTracerItem->setVisible(false);
1636
1637 // Once the integration is asked for, then the selection rectangle if of no
1638 // more use.
1640
1641 // Force replot now because later that call might not be performed.
1642 replot();
1643
1644 // Note that we only request an integration if the x-axis delta is enough.
1645
1646 double x_delta_pixel =
1647 fabs(xAxis->coordToPixel(m_context.m_currentDragPoint.x()) -
1648 xAxis->coordToPixel(m_context.m_startDragPoint.x()));
1649
1650 if(x_delta_pixel > 3)
1652 // else
1653 // qDebug() << "Not asking for integration.";
1654}
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 1658 of file baseplotwidget.cpp.

1659{
1660 // We should record the new range values each time the wheel is used to
1661 // zoom/unzoom.
1662
1663 m_context.m_xRange = QCPRange(xAxis->range());
1664 m_context.m_yRange = QCPRange(yAxis->range());
1665
1666 // qDebug() << "New x range: " << m_context.m_xRange;
1667 // qDebug() << "New y range: " << m_context.m_yRange;
1668
1670
1673
1674 event->accept();
1675}
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 1812 of file baseplotwidget.cpp.

1813{
1814 // First convert the graph coordinates to pixel coordinates.
1815
1816 QPointF pixels_coordinates(xAxis->coordToPixel(graph_coordinates.x()),
1817 yAxis->coordToPixel(graph_coordinates.y()));
1818
1819 moveMouseCursorPixelCoordToGlobal(pixels_coordinates.toPoint());
1820}

References moveMouseCursorPixelCoordToGlobal().

◆ moveMouseCursorPixelCoordToGlobal()

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

Definition at line 1824 of file baseplotwidget.cpp.

1825{
1826 // qDebug() << "Calling set pos with new cursor position.";
1827 QCursor::setPos(mapToGlobal(pixel_coordinates.toPoint()));
1828}

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 3300 of file baseplotwidget.cpp.

3301{
3302 if(focusedPlotWidget == nullptr)
3303 throw ExceptionNotPossible(
3304 "baseplotwidget.cpp @ redrawPlotBackground(QWidget *focusedPlotWidget "
3305 "-- "
3306 "ERROR focusedPlotWidget cannot be nullptr.");
3307
3308 if(dynamic_cast<QWidget *>(this) != focusedPlotWidget)
3309 {
3310 // The focused widget is not *this widget. We should make sure that
3311 // we were not the one that had the focus, because in this case we
3312 // need to redraw an unfocused background.
3313
3314 axisRect()->setBackground(m_unfocusedBrush);
3315 }
3316 else
3317 {
3318 axisRect()->setBackground(m_focusedBrush);
3319 }
3320
3321 replot();
3322}
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,
Axis  axis 
)
virtual

Definition at line 2207 of file baseplotwidget.cpp.

2210{
2211 // qDebug() << "With axis:" << (int)axis;
2212
2213 if(static_cast<int>(axis) & static_cast<int>(Axis::x))
2214 {
2215 xAxis->setRange(xAxisRange.lower, xAxisRange.upper);
2216 }
2217
2218 if(static_cast<int>(axis) & static_cast<int>(Axis::y))
2219 {
2220 yAxis->setRange(yAxisRange.lower, yAxisRange.upper);
2221 }
2222
2223 // We do not want to update the history, because there would be way too
2224 // much history items, since this function is called upon mouse moving
2225 // handling and not only during mouse release events.
2226 // updateAxesRangeHistory();
2227
2228 replot();
2229}

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

◆ replotWithAxisRangeX()

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

Definition at line 2233 of file baseplotwidget.cpp.

2234{
2235 // qDebug();
2236
2237 xAxis->setRange(lower, upper);
2238
2239 replot();
2240}

◆ replotWithAxisRangeY()

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

Definition at line 2244 of file baseplotwidget.cpp.

2245{
2246 // qDebug();
2247
2248 yAxis->setRange(lower, upper);
2249
2250 replot();
2251}

◆ resetAxesRangeHistory()

void pappso::BasePlotWidget::resetAxesRangeHistory ( )
virtual

Definition at line 485 of file baseplotwidget.cpp.

486{
487 m_xAxisRangeHistory.clear();
488 m_yAxisRangeHistory.clear();
489
490 m_xAxisRangeHistory.push_back(new QCPRange(xAxis->range()));
491 m_yAxisRangeHistory.push_back(new QCPRange(yAxis->range()));
492
493 // qDebug() << "size of history:" << m_xAxisRangeHistory.size()
494 //<< "setting index to 0";
495
496 // qDebug() << "resetting axes history to values:" << xAxis->range().lower
497 //<< "--" << xAxis->range().upper << "and" << yAxis->range().lower
498 //<< "--" << yAxis->range().upper;
499
501}
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 3217 of file baseplotwidget.cpp.

3218{
3219 std::const_pointer_cast<IntegrationScopeBase>(m_context.msp_integrationScope)
3220 ->reset();
3221}

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 562 of file baseplotwidget.cpp.

563{
564 // qDebug() << "Axes history size:" << m_xAxisRangeHistory.size()
565 //<< "current index:" << m_lastAxisRangeHistoryIndex
566 //<< "asking to restore index:" << index;
567
568 if(index >= m_xAxisRangeHistory.size())
569 {
570 // qDebug() << "index >= history size. Returning.";
571 return;
572 }
573
574 // We want to go back to the range history item at index, which means we want
575 // to pop back all the items between index+1 and size-1.
576
577 while(m_xAxisRangeHistory.size() > index + 1)
578 m_xAxisRangeHistory.pop_back();
579
580 if(m_xAxisRangeHistory.size() - 1 != index)
581 qFatal("Programming error.");
582
583 xAxis->setRange(*(m_xAxisRangeHistory.at(index)));
584 yAxis->setRange(*(m_yAxisRangeHistory.at(index)));
585
587
588 mp_vPosTracerItem->setVisible(false);
589 mp_hPosTracerItem->setVisible(false);
590
591 mp_vStartTracerItem->setVisible(false);
592 mp_vEndTracerItem->setVisible(false);
593
594
595 // The start tracer will keep beeing represented at the last position and last
596 // size even if we call this function repetitively. So actually do not show,
597 // it will reappare as soon as the mouse is moved.
598 // if(m_shouldTracersBeVisible)
599 //{
600 // mp_vStartTracerItem->setVisible(true);
601 //}
602
603 replot();
604
606
607 // qDebug() << "restored axes history to index:" << index
608 //<< "with values:" << xAxis->range().lower << "--"
609 //<< xAxis->range().upper << "and" << yAxis->range().lower << "--"
610 //<< yAxis->range().upper;
611
613}
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 534 of file baseplotwidget.cpp.

535{
536 // qDebug() << "axes history size:" << m_xAxisRangeHistory.size()
537 //<< "current index:" << m_lastAxisRangeHistoryIndex;
538
540 {
541 // qDebug() << "current index is 0 returning doing nothing";
542
543 return;
544 }
545
546 // qDebug() << "Setting index to:" << m_lastAxisRangeHistoryIndex - 1
547 //<< "and restoring axes history to that index";
548
550}
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 470 of file baseplotwidget.cpp.

471{
472 xAxis->setLabel(label);
473}

◆ setAxisLabelY()

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

Definition at line 477 of file baseplotwidget.cpp.

478{
479 yAxis->setLabel(label);
480}

◆ setFocus()

void pappso::BasePlotWidget::setFocus ( )
virtual

PLOT ITEMS : TRACER TEXT ITEMS...

Definition at line 3286 of file baseplotwidget.cpp.

3287{
3288 // qDebug() << "Setting focus to the QCustomPlot:" << this;
3289
3290 QCustomPlot::setFocus();
3291
3292 // qDebug() << "Emitting setFocusSignal().";
3293
3294 emit setFocusSignal();
3295}

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 401 of file baseplotwidget.cpp.

402{
403 m_pen = pen;
404}

References m_pen.

◆ setPlottingColor() [1/2]

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

Definition at line 433 of file baseplotwidget.cpp.

434{
435 if(!new_color.isValid())
436 return;
437
438 QCPGraph *graph_p = graph(index);
439
440 if(graph_p == nullptr)
441 qFatal("Programming error.");
442
443 return setPlottingColor(graph_p, new_color);
444}
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 415 of file baseplotwidget.cpp.

417{
418 if(plottable_p == nullptr)
419 qFatal("Pointer cannot be nullptr.");
420
421 // First this single-graph widget
422 QPen pen;
423
424 pen = plottable_p->pen();
425 pen.setColor(new_color);
426 plottable_p->setPen(pen);
427
428 replot();
429}

Referenced by setPlottingColor().

◆ setupWidget()

bool pappso::BasePlotWidget::setupWidget ( )
virtual

Definition at line 343 of file baseplotwidget.cpp.

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

2277{
2279
2280 mp_vPosTracerItem->setVisible(true);
2281 mp_hPosTracerItem->setVisible(true);
2282
2283 mp_vStartTracerItem->setVisible(true);
2284 mp_vEndTracerItem->setVisible(true);
2285
2286 // Force a replot to make sure the action is immediately visible by the
2287 // user, even without moving the mouse.
2288 replot();
2289}

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 810 of file baseplotwidget.cpp.

811{
812 // qDebug();
813}

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 512 of file baseplotwidget.cpp.

513{
514 m_xAxisRangeHistory.push_back(new QCPRange(xAxis->range()));
515 m_yAxisRangeHistory.push_back(new QCPRange(yAxis->range()));
516
518
519 // qDebug() << "axes history size:" << m_xAxisRangeHistory.size()
520 //<< "current index:" << m_lastAxisRangeHistoryIndex
521 //<< xAxis->range().lower << "--" << xAxis->range().upper << "and"
522 //<< yAxis->range().lower << "--" << yAxis->range().upper;
523}

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 3326 of file baseplotwidget.cpp.

3327{
3328 m_context.m_xRange = QCPRange(xAxis->range().lower, xAxis->range().upper);
3329 m_context.m_yRange = QCPRange(yAxis->range().lower, yAxis->range().upper);
3330
3331 // qDebug() << "The new updated context: " << m_context.toString();
3332}

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 2632 of file baseplotwidget.cpp.

2633{
2634
2635 // if(for_integration)
2636 // qDebug() << "for_integration:" << for_integration;
2637
2638 // By essence, the one-dimension IntegrationScope is characterized
2639 // by the left-most point and the width. Using these two data bits
2640 // it is possible to compute the x value of the right-most point.
2641
2642 double x_range_start =
2644 double x_range_end =
2646
2647 double y_position = m_context.m_startDragPoint.y();
2648
2650
2651 // Top line
2652 mp_selectionRectangeLine1->start->setCoords(
2653 QPointF(x_range_start, y_position));
2654 mp_selectionRectangeLine1->end->setCoords(QPointF(x_range_end, y_position));
2655
2656 // Only if we are drawing a selection rectangle for integration, do we set
2657 // arrow heads to the line.
2658 if(for_integration)
2659 {
2660 mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2661 mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2662 }
2663 else
2664 {
2665 mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2666 mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2667 }
2668 mp_selectionRectangeLine1->setVisible(true);
2669
2670 // Right line: does not exist, start and end are the same end point of the
2671 // top line.
2672 mp_selectionRectangeLine2->start->setCoords(QPointF(x_range_end, y_position));
2673 mp_selectionRectangeLine2->end->setCoords(QPointF(x_range_end, y_position));
2674 mp_selectionRectangeLine2->setVisible(false);
2675
2676 // Bottom line: identical to the top line, but invisible
2677 mp_selectionRectangeLine3->start->setCoords(
2678 QPointF(x_range_start, y_position));
2679 mp_selectionRectangeLine3->end->setCoords(QPointF(x_range_end, y_position));
2680 mp_selectionRectangeLine3->setVisible(false);
2681
2682 // Left line: does not exist: start and end are the same end point of the
2683 // top line.
2684 mp_selectionRectangeLine4->start->setCoords(QPointF(x_range_end, y_position));
2685 mp_selectionRectangeLine4->end->setCoords(QPointF(x_range_end, y_position));
2686 mp_selectionRectangeLine4->setVisible(false);
2687}

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 3088 of file baseplotwidget.cpp.

3090{
3091 // qDebug() << "as_line_segment:" << as_line_segment;
3092 // qDebug() << "for_integration:" << for_integration;
3093
3094 // We now need to construct the selection rectangle, either for zoom or for
3095 // integration.
3096
3097 // There are two situations :
3098 //
3099 // 1. if the rectangle should look like a line segment
3100 //
3101 // 2. if the rectangle should actually look like a rectangle. In this case,
3102 // there are two sub-situations:
3103 //
3104 // a. if the Alt modifier key is down, then the rectangle is rhomboid.
3105 //
3106 // b. otherwise the rectangle is conventional.
3107
3108 if(as_line_segment)
3109 {
3110 // qDebug() << "Updating the integration scope to an IntegrationScope.";
3111 updateIntegrationScope(for_integration);
3112 }
3113 else
3114 {
3115 if(!(m_context.m_keyboardModifiers & Qt::AltModifier))
3116 {
3117 // qDebug()
3118 // << "Updating the integration scope to an IntegrationScopeRect.";
3119 updateIntegrationScopeRect(for_integration);
3120 }
3121 else if(m_context.m_keyboardModifiers & Qt::AltModifier)
3122 {
3123 // The user might use the Alt modifier, but if no rhomboid side has
3124 // been defined using the S key, then we do not do any rhomboid
3125 // selection because we do not know the side size of that rhomboid.
3126
3129 updateIntegrationScopeRect(for_integration);
3130 else
3131 // qDebug()
3132 // << "Updating the integration scope to an
3133 // IntegrationScopeRhomb.";
3134 updateIntegrationScopeRhomb(for_integration);
3135 }
3136 }
3137
3138 // Depending on the kind of IntegrationScope, (normal, rect or rhomb)
3139 // we have to measure things in different ways. We now set in the context
3140 // a number of parameters that will be used by its user.
3141
3142 QPointF point;
3143 double height;
3144 std::vector<QPointF> points;
3145
3146 if(m_context.msp_integrationScope->getPoints(points))
3147 {
3148 // We have defined a IntegrationScopeRhomb.
3149
3150 if(!m_context.msp_integrationScope->getLeftMostPoint(point))
3151 qFatal("Failed to get LeftMost point.");
3152 m_context.m_xRegionRangeStart = point.x();
3153
3154 if(!m_context.msp_integrationScope->getRightMostPoint(point))
3155 qFatal("Failed to get RightMost point.");
3156 m_context.m_xRegionRangeEnd = point.x();
3157 }
3158 else if(m_context.msp_integrationScope->getHeight(height))
3159 {
3160 // We have defined a IntegrationScopeRect.
3161
3162 if(!m_context.msp_integrationScope->getPoint(point))
3163 qFatal("Failed to get point.");
3164 m_context.m_xRegionRangeStart = point.x();
3165
3166 double width;
3167
3168 if(!m_context.msp_integrationScope->getWidth(width))
3169 qFatal("Failed to get width.");
3170
3172
3173 m_context.m_yRegionRangeStart = point.y();
3174
3175 m_context.m_yRegionRangeEnd = point.y() + height;
3176 }
3177 else
3178 {
3179 // We have defined a IntegrationScope.
3180
3181 if(!m_context.msp_integrationScope->getPoint(point))
3182 qFatal("Failed to get point.");
3183 m_context.m_xRegionRangeStart = point.x();
3184
3185 double width;
3186
3187 if(!m_context.msp_integrationScope->getWidth(width))
3188 qFatal("Failed to get width.");
3190 }
3191
3192 // At this point, draw the text describing the widths.
3193
3194 // We want the x-delta on the bottom of the rectangle, inside it
3195 // and the y-delta on the vertical side of the rectangle, inside it.
3196
3197 // Draw the selection width text
3199}
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 2776 of file baseplotwidget.cpp.

2777{
2778 // We are handling a rhomboid scope, that is, a rectangle that
2779 // is tilted either to the left or to the right.
2780
2781 // There are two kinds of rhomboid integration scopes: horizontal and
2782 // vertical.
2783
2784 /*
2785 * +----------+
2786 * | |
2787 * | |
2788 * | |
2789 * | |
2790 * | |
2791 * | |
2792 * | |
2793 * +----------+
2794 * ----width---
2795 */
2796
2797 // As visible here, the fixed size of the rhomboid (using the S key in the
2798 // plot widget) is the *horizontal* side (this is the plot context's
2799 // m_integrationScopeRhombWidth).
2800
2801 IntegrationScopeFeatures scope_features;
2802
2803 // Top horizontal line
2804 QPointF point_1;
2805 scope_features = m_context.msp_integrationScope->getLeftMostTopPoint(point_1);
2806
2807 // When the user rotates the horizontal rhomboid, at some point, if the
2808 // current drag point has the same y axis value as the start drag point, then
2809 // we say that the rhomboid is flattened on the x axis. In this case, we do
2810 // not draw anything as this is a purely unusable situation.
2811
2812 if(scope_features & IntegrationScopeFeatures::FLAT_ON_X_AXIS)
2813 {
2814 // qDebug() << "The horizontal rhomboid is flattened on the x axis.";
2815
2816 mp_selectionRectangeLine1->setVisible(false);
2817 mp_selectionRectangeLine2->setVisible(false);
2818 mp_selectionRectangeLine3->setVisible(false);
2819 mp_selectionRectangeLine4->setVisible(false);
2820
2821 return;
2822 }
2823
2825 qFatal("The rhomboid should be horizontal!");
2826
2827 // At this point we can draw the rhomboid fine.
2828
2829 if(!m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2830 qFatal("Failed to getLeftMostTopPoint.");
2831 QPointF point_2;
2832 if(!m_context.msp_integrationScope->getRightMostTopPoint(point_2))
2833 qFatal("Failed to getRightMostTopPoint.");
2834
2835 // qDebug() << "For top line, two points:" << point_1 << "--" << point_2;
2836
2837 mp_selectionRectangeLine1->start->setCoords(point_1);
2838 mp_selectionRectangeLine1->end->setCoords(point_2);
2839
2840 // Only if we are drawing a selection rectangle for integration, do we set
2841 // arrow heads to the line.
2842 if(for_integration)
2843 {
2844 mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2845 mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2846 }
2847 else
2848 {
2849 mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2850 mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2851 }
2852
2853 mp_selectionRectangeLine1->setVisible(true);
2854
2855 // Right line
2856 if(!m_context.msp_integrationScope->getRightMostBottomPoint(point_1))
2857 qFatal("Failed to getRightMostBottomPoint.");
2858 mp_selectionRectangeLine2->start->setCoords(point_2);
2859 mp_selectionRectangeLine2->end->setCoords(point_1);
2860 mp_selectionRectangeLine2->setVisible(true);
2861
2862 // qDebug() << "For right line, two points:" << point_2 << "--" << point_1;
2863
2864 // Bottom horizontal line
2865 if(!m_context.msp_integrationScope->getLeftMostBottomPoint(point_2))
2866 qFatal("Failed to getLeftMostBottomPoint.");
2867 mp_selectionRectangeLine3->start->setCoords(point_1);
2868 mp_selectionRectangeLine3->end->setCoords(point_2);
2869 mp_selectionRectangeLine3->setVisible(true);
2870
2871 // qDebug() << "For bottom line, two points:" << point_1 << "--" << point_2;
2872
2873 // Left line
2874 if(!m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2875 qFatal("Failed to getLeftMostTopPoint.");
2876 mp_selectionRectangeLine4->end->setCoords(point_2);
2877 mp_selectionRectangeLine4->start->setCoords(point_1);
2878 mp_selectionRectangeLine4->setVisible(true);
2879
2880 // qDebug() << "For left line, two points:" << point_2 << "--" << point_1;
2881}

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 2691 of file baseplotwidget.cpp.

2692{
2693 // qDebug();
2694
2695 // if(for_integration)
2696 // qDebug() << "for_integration:" << for_integration;
2697
2698 // We are handling a conventional rectangle. Just create four points
2699 // from top left to bottom right. But we want the top left point to be
2700 // effectively the top left point and the bottom point to be the bottom
2701 // point. So we need to try all four direction combinations, left to right
2702 // or converse versus top to bottom or converse.
2703
2705
2706 // Now that the integration scope has been updated as a rectangle,
2707 // use these newly set data to actually draw the integration
2708 // scope lines.
2709
2710 QPointF bottom_left_point;
2711 if(!m_context.msp_integrationScope->getPoint(bottom_left_point))
2712 qFatal("Failed to get point.");
2713 // qDebug() << "Starting point is left bottom point:" << bottom_left_point;
2714
2715 double width;
2716 if(!m_context.msp_integrationScope->getWidth(width))
2717 qFatal("Failed to get width.");
2718 // qDebug() << "Width:" << width;
2719
2720 double height;
2721 if(!m_context.msp_integrationScope->getHeight(height))
2722 qFatal("Failed to get height.");
2723 // qDebug() << "Height:" << height;
2724
2725 QPointF bottom_right_point(bottom_left_point.x() + width,
2726 bottom_left_point.y());
2727 // qDebug() << "bottom_right_point:" << bottom_right_point;
2728
2729 QPointF top_right_point(bottom_left_point.x() + width,
2730 bottom_left_point.y() + height);
2731 // qDebug() << "top_right_point:" << top_right_point;
2732
2733 QPointF top_left_point(bottom_left_point.x(), bottom_left_point.y() + height);
2734
2735 // qDebug() << "top_left_point:" << top_left_point;
2736
2737 // Start by drawing the bottom line because the IntegrationScopeRect has the
2738 // left bottom point and the width and the height to fully characterize it.
2739
2740 // Bottom line (left to right)
2741 mp_selectionRectangeLine3->start->setCoords(bottom_left_point);
2742 mp_selectionRectangeLine3->end->setCoords(bottom_right_point);
2743 mp_selectionRectangeLine3->setVisible(true);
2744
2745 // Right line (bottom to top)
2746 mp_selectionRectangeLine2->start->setCoords(bottom_right_point);
2747 mp_selectionRectangeLine2->end->setCoords(top_right_point);
2748 mp_selectionRectangeLine2->setVisible(true);
2749
2750 // Top line (right to left)
2751 mp_selectionRectangeLine1->start->setCoords(top_right_point);
2752 mp_selectionRectangeLine1->end->setCoords(top_left_point);
2753 mp_selectionRectangeLine1->setVisible(true);
2754
2755 // Left line (top to bottom)
2756 mp_selectionRectangeLine4->start->setCoords(top_left_point);
2757 mp_selectionRectangeLine4->end->setCoords(bottom_left_point);
2758 mp_selectionRectangeLine4->setVisible(true);
2759
2760 // Only if we are drawing a selection rectangle for integration, do we
2761 // set arrow heads to the line.
2762 if(for_integration)
2763 {
2764 mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2765 mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2766 }
2767 else
2768 {
2769 mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2770 mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2771 }
2772}

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 3000 of file baseplotwidget.cpp.

3001{
3002 // qDebug();
3003
3004 // if(for_integration)
3005 // qDebug() << "for_integration:" << for_integration;
3006
3007 // We are handling a skewed rectangle (rhomboid), that is a rectangle that
3008 // is tilted either to the left or to the right.
3009
3010 // There are two kinds of rhomboid integration scopes:
3011
3012 /*
3013 4+----------+3
3014 | |
3015 | |
3016 | |
3017 | |
3018 | |
3019 | |
3020 | |
3021 1+----------+2
3022 ----width---
3023 */
3024
3025 // As visible here, the fixed size of the rhomboid (using the S key in the
3026 // plot widget) is the *horizontal* side (this is the plot context's
3027 // m_integrationScopeRhombWidth).
3028
3029 // and
3030
3031
3032 /*
3033 * +3
3034 * . |
3035 * . |
3036 * . |
3037 * . +2
3038 * . .
3039 * . .
3040 * . .
3041 * 4+ .
3042 * | | .
3043 * height | | .
3044 * | | .
3045 * 1+
3046 *
3047 */
3048
3049 // As visible here, the fixed size of the rhomboid (using the S key in the
3050 // plot widget) is the *vertical* side (this is the plot context's
3051 // m_integrationScopeRhombHeight).
3052
3053 // qDebug() << "Before calling updateIntegrationScopeRhomb(), "
3054 // "m_integrationScopeRhombWidth:"
3055 // << m_context.m_integrationScopeRhombWidth
3056 // << "and m_integrationScopeRhombHeight:"
3057 // << m_context.m_integrationScopeRhombHeight;
3058
3060
3061 // qDebug() << "After, m_integrationScopeRhombWidth:"
3062 // << m_context.m_integrationScopeRhombWidth
3063 // << "and m_integrationScopeRhombHeight:"
3064 // << m_context.m_integrationScopeRhombHeight;
3065
3066 // Now that the integration scope has been updated as a rhomboid,
3067 // use these newly set data to actually draw the integration
3068 // scope lines.
3069
3070 // We thus need to first establish if we have a horiontal or a vertical
3071 // rhomboid scope. This information is located in
3072 // m_context.m_integrationScopeRhombWidth and
3073 // m_context.m_integrationScopeRhombHeight. If width > 0, height *has to be
3074 // 0*, which indicates a horizontal rhomb.Conversely, if height is > 0, then
3075 // the rhomb is vertical.
3076
3078 // We are dealing with a horizontal scope.
3081 // We are dealing with a vertical scope.
3082 updateIntegrationScopeVerticalRhomb(for_integration);
3083 else
3084 qFatal("Cannot be both the width or height of rhomboid scope be 0.");
3085}
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 2885 of file baseplotwidget.cpp.

2886{
2887 // We are handling a rhomboid scope, that is, a rectangle that
2888 // is tilted either to the left or to the right.
2889
2890 // There are two kinds of rhomboid integration scopes: horizontal and
2891 // vertical.
2892
2893 /*
2894 * +3
2895 * . |
2896 * . |
2897 * . |
2898 * . +2
2899 * . .
2900 * . .
2901 * . .
2902 * 4+ .
2903 * | | .
2904 * height | | .
2905 * | | .
2906 * 1+
2907 *
2908 */
2909
2910 // As visible here, the fixed size of the rhomboid (using the S key in the
2911 // plot widget) is the *vertical* side (this is the plot context's
2912 // m_integrationScopeRhombHeight).
2913
2914 IntegrationScopeFeatures scope_features;
2915
2916 // Left vertical line
2917 QPointF point_1;
2918 scope_features = m_context.msp_integrationScope->getLeftMostTopPoint(point_1);
2919
2920 // When the user rotates the vertical rhomboid, at some point, if the current
2921 // drag point is on the same x axis value as the start drag point, then we say
2922 // that the rhomboid is flattened on the y axis. In this case, we do not draw
2923 // anything as this is a purely unusable situation.
2924
2925 if(scope_features & IntegrationScopeFeatures::FLAT_ON_Y_AXIS)
2926 {
2927 // qDebug() << "The vertical rhomboid is flattened on the y axis.";
2928
2929 mp_selectionRectangeLine1->setVisible(false);
2930 mp_selectionRectangeLine2->setVisible(false);
2931 mp_selectionRectangeLine3->setVisible(false);
2932 mp_selectionRectangeLine4->setVisible(false);
2933
2934 return;
2935 }
2936
2938 qFatal("The rhomboid should be vertical!");
2939
2940 // At this point we can draw the rhomboid fine.
2941
2942 QPointF point_2;
2943 if(!m_context.msp_integrationScope->getLeftMostBottomPoint(point_2))
2944 qFatal("Failed to getLeftMostBottomPoint.");
2945
2946 // qDebug() << "For left vertical line, two points:" << point_1 << "--"
2947 // << point_2;
2948
2949 mp_selectionRectangeLine1->start->setCoords(point_1);
2950 mp_selectionRectangeLine1->end->setCoords(point_2);
2951
2952 // Only if we are drawing a selection rectangle for integration, do we set
2953 // arrow heads to the line.
2954 if(for_integration)
2955 {
2956 mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2957 mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2958 }
2959 else
2960 {
2961 mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2962 mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2963 }
2964
2965 mp_selectionRectangeLine1->setVisible(true);
2966
2967 // Lower oblique line
2968 if(!m_context.msp_integrationScope->getRightMostBottomPoint(point_1))
2969 qFatal("Failed to getRightMostBottomPoint.");
2970 mp_selectionRectangeLine2->start->setCoords(point_2);
2971 mp_selectionRectangeLine2->end->setCoords(point_1);
2972 mp_selectionRectangeLine2->setVisible(true);
2973
2974 // qDebug() << "For lower oblique line, two points:" << point_2 << "--"
2975 // << point_1;
2976
2977 // Right vertical line
2978 if(!m_context.msp_integrationScope->getRightMostTopPoint(point_2))
2979 qFatal("Failed to getRightMostTopPoint.");
2980 mp_selectionRectangeLine3->start->setCoords(point_1);
2981 mp_selectionRectangeLine3->end->setCoords(point_2);
2982 mp_selectionRectangeLine3->setVisible(true);
2983
2984 // qDebug() << "For right vertical line, two points:" << point_1 << "--"
2985 // << point_2;
2986
2987 // Upper oblique line
2988 if(!m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2989 qFatal("Failed to get the LeftMostTopPoint.");
2990 mp_selectionRectangeLine4->end->setCoords(point_2);
2991 mp_selectionRectangeLine4->start->setCoords(point_1);
2992 mp_selectionRectangeLine4->setVisible(true);
2993
2994 // qDebug() << "For upper oblique line, two points:" << point_2 << "--"
2995 // << point_1;
2996}

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 1881 of file baseplotwidget.cpp.

1882{
1883 QPointF pixel_coordinates(
1884 xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()),
1885 yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()) + pixel_count);
1886
1887 // Now convert back to local coordinates.
1888
1889 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1890 yAxis->pixelToCoord(pixel_coordinates.y()));
1891
1892 return graph_coordinates;
1893}

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

Referenced by verticalMoveMouseCursorCountPixels().

◆ verticalMoveMouseCursorCountPixels()

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

Definition at line 1864 of file baseplotwidget.cpp.

1865{
1866
1867 QPointF graph_coord = verticalGetGraphCoordNewPointCountPixels(pixel_count);
1868
1869 QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()),
1870 yAxis->coordToPixel(graph_coord.y()));
1871
1872 // Now we need ton convert the new coordinates to the global position system
1873 // and to move the cursor to that new position. That will create an event to
1874 // move the mouse cursor.
1875
1876 moveMouseCursorPixelCoordToGlobal(pixel_coord.toPoint());
1877}
virtual QPointF verticalGetGraphCoordNewPointCountPixels(int pixel_count)

References moveMouseCursorPixelCoordToGlobal(), and verticalGetGraphCoordNewPointCountPixels().

Referenced by directionKeyPressEvent().

◆ whatIsVisibleOfTheSelectionRectangle()

SelectionDrawingLines pappso::BasePlotWidget::whatIsVisibleOfTheSelectionRectangle ( )
virtual

Definition at line 3224 of file baseplotwidget.cpp.

3225{
3226 // There are four lines that make the selection polygon. We want to know
3227 // which lines are visible.
3228
3229 int current_selection_polygon =
3230 static_cast<int>(SelectionDrawingLines::NOT_SET);
3231
3232 if(mp_selectionRectangeLine1->visible())
3233 {
3234 current_selection_polygon |=
3235 static_cast<int>(SelectionDrawingLines::TOP_LINE);
3236 // qDebug() << "current_selection_polygon:" <<
3237 // current_selection_polygon;
3238 }
3239 if(mp_selectionRectangeLine2->visible())
3240 {
3241 current_selection_polygon |=
3242 static_cast<int>(SelectionDrawingLines::RIGHT_LINE);
3243 // qDebug() << "current_selection_polygon:" <<
3244 // current_selection_polygon;
3245 }
3246 if(mp_selectionRectangeLine3->visible())
3247 {
3248 current_selection_polygon |=
3249 static_cast<int>(SelectionDrawingLines::BOTTOM_LINE);
3250 // qDebug() << "current_selection_polygon:" <<
3251 // current_selection_polygon;
3252 }
3253 if(mp_selectionRectangeLine4->visible())
3254 {
3255 current_selection_polygon |=
3256 static_cast<int>(SelectionDrawingLines::LEFT_LINE);
3257 // qDebug() << "current_selection_polygon:" <<
3258 // current_selection_polygon;
3259 }
3260
3261 // qDebug() << "returning visibility:" << current_selection_polygon;
3262
3263 return static_cast<SelectionDrawingLines>(current_selection_polygon);
3264}

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 269 of file baseplotwidget.h.

◆ m_axisLabelY

QString pappso::BasePlotWidget::m_axisLabelY
protected

Definition at line 270 of file baseplotwidget.h.

◆ m_context

BasePlotContext pappso::BasePlotWidget::m_context
protected

Definition at line 272 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(), mousePseudoButtonKeyReleaseEvent(), 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 264 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 267 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 353 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 351 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 314 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 332 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 340 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 261 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 356 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 291 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 348 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 346 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 317 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 320 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 287 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: