libpappsomspp
Library for mass spectrometry
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. More...
 
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. More...
 
virtual void restorePreviousAxesRangeHistory ()
 Go up one history element in the axis history. More...
 
virtual void restoreAxesRangeHistory (std::size_t index)
 Get the axis histories at index index and update the plot ranges. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 KEYBOARD-related EVENTS. More...
 
virtual void keyReleaseEvent (QKeyEvent *event)
 Handle specific key codes and trigger respective actions. More...
 
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. More...
 
virtual void mouseReleaseHandler (QMouseEvent *event)
 
virtual void mouseReleaseHandlerLeftButton ()
 
virtual void mouseReleaseHandlerRightButton ()
 
virtual void mouseWheelHandler (QWheelEvent *event)
 
virtual void mouseMoveHandler (QMouseEvent *event)
 KEYBOARD-related EVENTS. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual void showTracers ()
 Show the traces (vertical and horizontal). More...
 
virtual void hideTracers ()
 Hide the traces (vertical and horizontal). More...
 
virtual void drawXDeltaFeatures ()
 
virtual void drawYDeltaFeatures ()
 
virtual void calculateDragDeltas ()
 
virtual bool isVerticalDisplacementAboveThreshold ()
 
virtual void drawSelectionRectangleAndPrepareZoom (bool as_line_segment=false, bool for_integration=false)
 
virtual void updateSelectionRectangle (bool as_line_segment=false, bool for_integration=false)
 
virtual void resetSelectionRectangle ()
 
virtual void hideSelectionRectangle (bool reset_values=false)
 
virtual bool isSelectionRectangleVisible ()
 
virtual PolygonType whatIsVisibleOfTheSelectionRectangle ()
 
virtual void setFocus ()
 PLOT ITEMS : TRACER TEXT ITEMS... More...
 
virtual void redrawPlotBackground (QWidget *focusedPlotWidget)
 Redraw the background of the focusedPlotWidget plot widget. More...
 
virtual void updateContextXandYAxisRanges ()
 
virtual const BasePlotContextgetContext () const
 

Protected Member Functions

virtual void createAllAncillaryItems ()
 
virtual void update1DSelectionRectangle (bool for_integration=false)
 
virtual void update2DSelectionRectangleSquare (bool for_integration=false)
 
virtual void update2DSelectionRectangleSkewed (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. More...
 
QString m_desc = "NOT_SET"
 Description of the plot widget. More...
 
QString m_fileName
 The name of the data file from which the mass data were read. More...
 
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. More...
 
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. More...
 
QCPItemText * mp_yDeltaTextItem = nullptr
 
bool m_shouldTracersBeVisible = true
 Tells if the tracers should be visible. More...
 
QCPItemLine * mp_hPosTracerItem = nullptr
 Horizontal position tracer. More...
 
QCPItemLine * mp_vPosTracerItem = nullptr
 Vertical position tracer. More...
 
QCPItemLine * mp_vStartTracerItem = nullptr
 Vertical selection start tracer (typically in green). More...
 
QCPItemLine * mp_vEndTracerItem = nullptr
 Vertical selection end tracer (typically in red). More...
 
std::size_t m_lastAxisRangeHistoryIndex = 0
 Index of the last axis range history item. More...
 
std::vector< QCPRange * > m_xAxisRangeHistory
 List of x axis ranges occurring during the panning zooming actions. More...
 
std::vector< QCPRange * > m_yAxisRangeHistory
 List of y axis ranges occurring during the panning zooming actions. More...
 
int m_mouseMoveHandlerSkipAmount = 10
 How many mouse move events must be skipped *‍/. More...
 
int m_mouseMoveHandlerSkipCount = 0
 Counter to handle the "fat data" mouse move event handling. More...
 
QColor m_unfocusedColor = QColor("lightgray")
 Color used for the background of unfocused plot. More...
 
QBrush m_unfocusedBrush = QBrush(m_unfocusedColor)
 Color used for the background of unfocused plot. More...
 
QColor m_focusedColor = QColor(Qt::transparent)
 Color used for the background of focused plot. More...
 
QBrush m_focusedBrush = QBrush(m_focusedColor)
 Color used for the background of focused plot. More...
 
QPen m_pen
 Pen used to draw the graph and textual elements in the plot widget. More...
 

Detailed Description

Definition at line 66 of file baseplotwidget.h.

Constructor & Destructor Documentation

◆ BasePlotWidget() [1/2]

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

Definition at line 49 of file baseplotwidget.cpp.

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

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

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

163 {
164  // qDebug() << "In the destructor of plot widget:" << this;
165 
166  m_xAxisRangeHistory.clear();
167  m_yAxisRangeHistory.clear();
168 
169  // Note that the QCustomPlot xxxItem objects are allocated with (this) which
170  // means their destruction is automatically handled upon *this' destruction.
171 }
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 175 of file baseplotwidget.cpp.

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

◆ axisDoubleClickHandler()

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

Reimplemented in pappso::BaseTracePlotWidget.

Definition at line 1594 of file baseplotwidget.cpp.

1598 {
1599  //qDebug();
1600 
1601  m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1602 
1603  if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1604  {
1605  //qDebug();
1606 
1607  // If the Ctrl modifiers is active, then both axes are to be reset. Also
1608  // the histories are reset also.
1609 
1610  rescaleAxes();
1612  }
1613  else
1614  {
1615  //qDebug();
1616  // Only the axis passed as parameter is to be rescaled.
1617  // Reset the range of that axis to the max view possible.
1618 
1619  axis->rescale();
1620 
1622 
1623  event->accept();
1624  }
1625 
1626  // The double-click event does not cancel the mouse press event. That is, if
1627  // left-double-clicking, at the end of the operation the button still
1628  // "pressed". We need to remove manually the button from the pressed buttons
1629  // context member.
1630 
1631  m_context.m_pressedMouseButtons ^= event->button();
1632 
1634 
1636 
1637  replot();
1638 }
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 2111 of file baseplotwidget.cpp.

2112 {
2113  // Sanity check
2115  qFatal(
2116  "This function can only be called if the mouse click was on one of the "
2117  "axes");
2118 
2119  // First update the x&y axis ranges that we'll need for panning.
2121 
2123  {
2124  xAxis->setRange(m_context.m_xRange.lower - m_context.m_xDelta,
2126  }
2127 
2129  {
2130  yAxis->setRange(m_context.m_yRange.lower - m_context.m_yDelta,
2132  }
2133 
2134  // We cannot store the new ranges in the history, because the pan operation
2135  // involved a huge quantity of micro-movements elicited upon each mouse move
2136  // cursor event so we would have a huge history.
2137  // updateAxesRangeHistory();
2138 
2139  // Now that the context has the right range values, we can emit the
2140  // signal that will be used by this plot widget users, typically to
2141  // abide by the x/y range lock required by the user.
2142 
2144 
2145  replot();
2146 }

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

2054 {
2055 
2056  // double sorted_start_drag_point_x =
2057  // std::min(m_context.m_startDragPoint.x(), m_context.m_currentDragPoint.x());
2058 
2059  // xAxis->setRange(sorted_start_drag_point_x,
2060  // sorted_start_drag_point_x + fabs(m_context.m_xDelta));
2061 
2062  xAxis->setRange(
2064 
2065  // Note that the y axis should be rescaled from current lower value to new
2066  // upper value matching the y-axis position of the cursor when the mouse
2067  // button was released.
2068 
2069  yAxis->setRange(xAxis->range().lower,
2070  std::max<double>(m_context.m_yRegionRangeStart,
2072 
2073  // qDebug() << "xaxis:" << xAxis->range().lower << "-" <<
2074  // xAxis->range().upper
2075  //<< "yaxis:" << yAxis->range().lower << "-" << yAxis->range().upper;
2076 
2078 
2081 
2082  replot();
2083 }

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

1969 {
1970  // Get the current x lower/upper range, that is, leftmost/rightmost x
1971  // coordinate.
1972  double xLower = xAxis->range().lower;
1973  double xUpper = xAxis->range().upper;
1974 
1975  // Get the current y lower/upper range, that is, bottommost/topmost y
1976  // coordinate.
1977  double yLower = yAxis->range().lower;
1978  double yUpper = yAxis->range().upper;
1979 
1980  // This function is called only when the user has clicked on the x/y axis or
1981  // when the user has dragged the left mouse button with the Ctrl key
1982  // modifier. The m_context.m_wasClickOnXAxis is then simulated in the mouse
1983  // move handler. So we need to test which axis was clicked-on.
1984 
1986  {
1987 
1988  // We are changing the range of the X axis.
1989 
1990  // What is the x delta ?
1991  double xDelta =
1993 
1994  // If xDelta is < 0, the we were dragging from right to left, we are
1995  // compressing the view on the x axis, by adding new data to the right
1996  // hand size of the graph. So we add xDelta to the upper bound of the
1997  // range. Otherwise we are uncompressing the view on the x axis and
1998  // remove the xDelta from the upper bound of the range. This is why we
1999  // have the
2000  // '-'
2001  // and not '+' below;
2002 
2003  // qDebug() << "Setting xaxis:" << xLower << "--" << xUpper - xDelta;
2004 
2005  xAxis->setRange(xLower, xUpper - xDelta);
2006  }
2007  // End of
2008  // if(m_context.m_wasClickOnXAxis)
2009  else // that is, if(m_context.m_wasClickOnYAxis)
2010  {
2011  // We are changing the range of the Y axis.
2012 
2013  // What is the y delta ?
2014  double yDelta =
2016 
2017  // See above for an explanation of the computation.
2018 
2019  yAxis->setRange(yLower, yUpper - yDelta);
2020 
2021  // Old version
2022  // if(yDelta < 0)
2023  //{
2024  //// The dragging operation was from top to bottom, we are enlarging
2025  //// the range (thus, we are unzooming the view, since the widget
2026  //// always has the same size).
2027 
2028  // yAxis->setRange(yLower, yUpper + fabs(yDelta));
2029  //}
2030  // else
2031  //{
2032  //// The dragging operation was from bottom to top, we are reducing
2033  //// the range (thus, we are zooming the view, since the widget
2034  //// always has the same size).
2035 
2036  // yAxis->setRange(yLower, yUpper - fabs(yDelta));
2037  //}
2038  }
2039  // End of
2040  // else // that is, if(m_context.m_wasClickOnYAxis)
2041 
2042  // Update the context with the current axes ranges
2043 
2045 
2047 
2048  replot();
2049 }

References m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_startDragPoint, pappso::BasePlotContext::m_wasClickOnXAxis, plotRangesChangedSignal(), and updateContextXandYAxisRanges().

Referenced by mouseMoveHandlerLeftButtonDraggingCursor().

◆ axisZoom()

void pappso::BasePlotWidget::axisZoom ( )
virtual

Reimplemented in pappso::BaseTracePlotWidget.

Definition at line 2087 of file baseplotwidget.cpp.

2088 {
2089 
2090  // Use the m_context.m_xRegionRangeStart/End values, but we need to sort the
2091  // values before using them, because now we want to really have the lower x
2092  // value. Simply craft a QCPRange that will swap the values if lower is not
2093  // < than upper QCustomPlot calls this normalization).
2094 
2095  xAxis->setRange(
2097 
2098  yAxis->setRange(
2100 
2102 
2105 
2106  replot();
2107 }

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

2432 {
2433 
2434  // We compute signed differentials. If the user does not want the sign,
2435  // fabs(double) is their friend.
2436 
2437  // Compute the xAxis differential:
2438 
2441 
2442  // Same with the Y-axis range:
2443 
2446 
2447  // qDebug() << "xDelta:" << m_context.m_xDelta
2448  //<< "and yDelta:" << m_context.m_yDelta;
2449 
2450  return;
2451 }

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(), and pappso::BaseColorMapPlotWidget::addColorMap().

◆ directionKeyPressEvent()

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

Definition at line 788 of file baseplotwidget.cpp.

789 {
790  // qDebug() << "event key:" << event->key();
791 
792  // The user is trying to move the positional cursor/markers. There are
793  // multiple way they can do that:
794  //
795  // 1.a. Hitting the arrow left/right keys alone will search for next pixel.
796  // 1.b. Hitting the arrow left/right keys with Alt modifier will search for a
797  // multiple of pixels that might be equivalent to one 20th of the pixel width
798  // of the plot widget.
799  // 1.c Hitting the left/right keys with Alt and Shift modifiers will search
800  // for a multiple of pixels that might be the equivalent to half of the pixel
801  // width.
802  //
803  // 2. Hitting the Control modifier will move the cursor to the next data point
804  // of the graph.
805 
806  int pixel_increment = 0;
807 
808  if(m_context.m_keyboardModifiers == Qt::NoModifier)
809  pixel_increment = 1;
810  else if(m_context.m_keyboardModifiers == Qt::AltModifier)
811  pixel_increment = 50;
812 
813  // The user is moving the positional markers. This is equivalent to a
814  // non-dragging cursor movement to the next pixel. Note that the origin is
815  // located at the top left, so key down increments and key up decrements.
816 
817  if(event->key() == Qt::Key_Left)
818  horizontalMoveMouseCursorCountPixels(-pixel_increment);
819  else if(event->key() == Qt::Key_Right)
820  horizontalMoveMouseCursorCountPixels(pixel_increment);
821  else if(event->key() == Qt::Key_Up)
822  verticalMoveMouseCursorCountPixels(-pixel_increment);
823  else if(event->key() == Qt::Key_Down)
824  verticalMoveMouseCursorCountPixels(pixel_increment);
825 
826  event->accept();
827 }
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 831 of file baseplotwidget.cpp.

832 {
833  // qDebug() << "event key:" << event->key();
834  event->accept();
835 }

Referenced by keyReleaseEvent().

◆ dragDirection()

int pappso::BasePlotWidget::dragDirection ( )

MOUSE-related EVENTS.

MOUSE MOVEMENTS mouse/keyboard-triggered

Definition at line 1700 of file baseplotwidget.cpp.

1701 {
1702  // The user is dragging the mouse, probably to rescale the axes, but we need
1703  // to sort out in which direction the drag is happening.
1704 
1705  // This function should be called after calculateDragDeltas, so that
1706  // m_context has the proper x/y delta values that we'll compare.
1707 
1708  // Note that we cannot compare simply x or y deltas because the y axis might
1709  // have a different scale that the x axis. So we first need to convert the
1710  // positions to pixels.
1711 
1712  double x_delta_pixel =
1713  fabs(xAxis->coordToPixel(m_context.m_currentDragPoint.x()) -
1714  xAxis->coordToPixel(m_context.m_startDragPoint.x()));
1715 
1716  double y_delta_pixel =
1717  fabs(yAxis->coordToPixel(m_context.m_currentDragPoint.y()) -
1718  yAxis->coordToPixel(m_context.m_startDragPoint.y()));
1719 
1720  if(x_delta_pixel > y_delta_pixel)
1721  return Qt::Horizontal;
1722 
1723  return Qt::Vertical;
1724 }

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

2253 {
2254  // The user has dragged the mouse left button on the graph, which means he
2255  // is willing to draw a selection rectangle, either for zooming-in or for
2256  // integration.
2257 
2258  mp_xDeltaTextItem->setVisible(false);
2259  mp_yDeltaTextItem->setVisible(false);
2260 
2261  // Ensure the right selection rectangle is drawn.
2262 
2263  updateSelectionRectangle(as_line_segment, for_integration);
2264 
2265  // Note that if we draw a zoom rectangle, then we are certainly not
2266  // measuring anything. So set the boolean value to false so that the user of
2267  // this widget or derived classes know that there is nothing to perform upon
2268  // (like deconvolution, for example).
2269 
2271 
2272  // Also remove the delta value from the pipeline by sending a simple
2273  // distance without measurement signal.
2274 
2275  emit xAxisMeasurementSignal(m_context, false);
2276 
2277  replot();
2278 }
virtual void updateSelectionRectangle(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, updateSelectionRectangle(), and xAxisMeasurementSignal().

Referenced by mouseMoveHandlerLeftButtonDraggingCursor(), and mouseMoveHandlerRightButtonDraggingCursor().

◆ drawXDeltaFeatures()

void pappso::BasePlotWidget::drawXDeltaFeatures ( )
virtual

Definition at line 2282 of file baseplotwidget.cpp.

2283 {
2284  // The user is dragging the mouse over the graph and we want them to know what
2285  // is the x delta value, that is the span between the point at the start of
2286  // the drag and the current drag position.
2287 
2288  // FIXME: is this still true?
2289  //
2290  // We do not want to show the position markers because the only horiontal
2291  // line to be visible must be contained between the start and end vertiacal
2292  // tracer items.
2293  mp_hPosTracerItem->setVisible(false);
2294  mp_vPosTracerItem->setVisible(false);
2295 
2296  // We want to draw the text in the middle position of the leftmost-rightmost
2297  // point, even with skewed rectangle selection.
2298 
2299  QPointF leftmost_point = m_context.m_selectionPolygon.getLeftMostPoint();
2300 
2301  // qDebug() << "leftmost_point:" << leftmost_point;
2302 
2303  QPointF rightmost_point = m_context.m_selectionPolygon.getRightMostPoint();
2304 
2305  // qDebug() << "rightmost_point:" << rightmost_point;
2306 
2307  double x_axis_center_position =
2308  leftmost_point.x() + (rightmost_point.x() - leftmost_point.x()) / 2;
2309 
2310  // qDebug() << "x_axis_center_position:" << x_axis_center_position;
2311 
2312  // We want the text to print inside the rectangle, always at the current drag
2313  // point so the eye can follow the delta value while looking where to drag the
2314  // mouse. To position the text inside the rectangle, we need to know what is
2315  // the drag direction.
2316 
2317  // Set aside a point instance to store the pixel coordinates of the text.
2318  QPointF pixel_coordinates;
2319 
2320  // What is the distance between the rectangle line at current drag point and
2321  // the text itself.
2322  int pixels_away_from_line = 15;
2323 
2324  // ATTENTION: the pixel coordinates for the vertical direction go in reverse
2325  // order with respect to the y axis values !!! That is pixel(0,0) is top left
2326  // of the graph.
2327  if(static_cast<int>(m_context.m_dragDirections) &
2328  static_cast<int>(DragDirections::TOP_TO_BOTTOM))
2329  {
2330  // We need to print inside the rectangle, that is pixels_above_line pixels
2331  // to the bottom, so with pixel y value decremented of that
2332  // pixels_above_line value (one would have expected to increment that
2333  // value, along the y axis, but the coordinates in pixel go in reverse
2334  // order).
2335 
2336  pixels_away_from_line *= -1;
2337  }
2338 
2339  double y_axis_pixel_coordinate =
2340  yAxis->coordToPixel(m_context.m_currentDragPoint.y());
2341 
2342  double y_axis_modified_pixel_coordinate =
2343  y_axis_pixel_coordinate + pixels_away_from_line;
2344 
2345  pixel_coordinates.setX(x_axis_center_position);
2346  pixel_coordinates.setY(y_axis_modified_pixel_coordinate);
2347 
2348  // Now convert back to graph coordinates.
2349 
2350  QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
2351  yAxis->pixelToCoord(pixel_coordinates.y()));
2352  mp_xDeltaTextItem->position->setCoords(x_axis_center_position,
2353  graph_coordinates.y());
2354  mp_xDeltaTextItem->setText(QString("%1").arg(m_context.m_xDelta, 0, 'f', 3));
2355  mp_xDeltaTextItem->setFont(QFont(font().family(), 9));
2356  mp_xDeltaTextItem->setVisible(true);
2357 
2358  // Set the boolean to true so that derived widgets know that something is
2359  // being measured, and they can act accordingly, for example by computing
2360  // deconvolutions in a mass spectrum.
2362 
2363  replot();
2364 
2365  // Let the caller know that we were measuring something.
2366  emit xAxisMeasurementSignal(m_context, true);
2367 
2368  return;
2369 }
SelectionPolygon m_selectionPolygon
DragDirections m_dragDirections
QPointF getRightMostPoint() const
QPointF getLeftMostPoint() const

References pappso::SelectionPolygon::getLeftMostPoint(), pappso::SelectionPolygon::getRightMostPoint(), m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_dragDirections, pappso::BasePlotContext::m_isMeasuringDistance, pappso::BasePlotContext::m_selectionPolygon, pappso::BasePlotContext::m_xDelta, mp_hPosTracerItem, mp_vPosTracerItem, mp_xDeltaTextItem, pappso::TOP_TO_BOTTOM, and xAxisMeasurementSignal().

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

◆ drawYDeltaFeatures()

void pappso::BasePlotWidget::drawYDeltaFeatures ( )
virtual

Definition at line 2373 of file baseplotwidget.cpp.

2374 {
2376  return;
2377 
2378  // The user is dragging the mouse over the graph and we want them to know what
2379  // is the y delta value, that is the span between the point at the top of
2380  // the selection polygon and the point at its bottom.
2381 
2382  // FIXME: is this still true?
2383  //
2384  // We do not want to show the position markers because the only horiontal
2385  // line to be visible must be contained between the start and end vertiacal
2386  // tracer items.
2387  mp_hPosTracerItem->setVisible(false);
2388  mp_vPosTracerItem->setVisible(false);
2389 
2390  // We want to draw the text in the middle position of the leftmost-rightmost
2391  // point, even with skewed rectangle selection.
2392 
2393  QPointF leftmost_point = m_context.m_selectionPolygon.getLeftMostPoint();
2394  QPointF topmost_point = m_context.m_selectionPolygon.getTopMostPoint();
2395 
2396  // qDebug() << "leftmost_point:" << leftmost_point;
2397 
2398  QPointF rightmost_point = m_context.m_selectionPolygon.getRightMostPoint();
2399  QPointF bottommost_point = m_context.m_selectionPolygon.getBottomMostPoint();
2400 
2401  // qDebug() << "rightmost_point:" << rightmost_point;
2402 
2403  double x_axis_center_position =
2404  leftmost_point.x() + (rightmost_point.x() - leftmost_point.x()) / 2;
2405 
2406  double y_axis_center_position =
2407  bottommost_point.y() + (topmost_point.y() - bottommost_point.y()) / 2;
2408 
2409  // qDebug() << "x_axis_center_position:" << x_axis_center_position;
2410 
2411  mp_yDeltaTextItem->position->setCoords(x_axis_center_position,
2412  y_axis_center_position);
2413  mp_yDeltaTextItem->setText(QString("%1").arg(m_context.m_yDelta, 0, 'f', 3));
2414  mp_yDeltaTextItem->setFont(QFont(font().family(), 9));
2415  mp_yDeltaTextItem->setVisible(true);
2416  mp_yDeltaTextItem->setRotation(90);
2417 
2418  // Set the boolean to true so that derived widgets know that something is
2419  // being measured, and they can act accordingly, for example by computing
2420  // deconvolutions in a mass spectrum.
2422 
2423  replot();
2424 
2425  // Let the caller know that we were measuring something.
2426  emit xAxisMeasurementSignal(m_context, true);
2427 }
QPointF getBottomMostPoint() const

References pappso::SelectionPolygon::getBottomMostPoint(), pappso::SelectionPolygon::getLeftMostPoint(), pappso::SelectionPolygon::getRightMostPoint(), pappso::SelectionPolygon::getTopMostPoint(), pappso::SelectionPolygon::is1D(), m_context, pappso::BasePlotContext::m_isMeasuringDistance, pappso::BasePlotContext::m_selectionPolygon, pappso::BasePlotContext::m_yDelta, mp_hPosTracerItem, mp_vPosTracerItem, mp_yDeltaTextItem, and xAxisMeasurementSignal().

Referenced by mouseMoveHandlerLeftButtonDraggingCursor(), and mouseMoveHandlerRightButtonDraggingCursor().

◆ getContext()

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

Definition at line 3180 of file baseplotwidget.cpp.

3181 {
3182  return m_context;
3183 }

References m_context.

◆ getInnermostRangeX()

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

Definition at line 1933 of file baseplotwidget.cpp.

1934 {
1935 
1936  return getRange(Axis::x, RangeType::innermost, found_range);
1937 }
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 1948 of file baseplotwidget.cpp.

1949 {
1950 
1951  return getRange(Axis::y, RangeType::innermost, found_range);
1952 }

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

◆ getOutermostRangeX()

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

Definition at line 1941 of file baseplotwidget.cpp.

1942 {
1943  return getRange(Axis::x, RangeType::outermost, found_range);
1944 }

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

◆ getOutermostRangeY()

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

Definition at line 1956 of file baseplotwidget.cpp.

1957 {
1958  return getRange(Axis::y, RangeType::outermost, found_range);
1959 }

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

1844 {
1845 
1846  // Iterate in all the graphs in this widget and return a QCPRange that has
1847  // its lower member as the greatest lower value of all
1848  // its upper member as the smallest upper value of all
1849 
1850  if(!graphCount())
1851  {
1852  found_range = false;
1853 
1854  return QCPRange(0, 1);
1855  }
1856 
1857  if(graphCount() == 1)
1858  return graph()->getKeyRange(found_range);
1859 
1860  bool found_at_least_one_range = false;
1861 
1862  // Create an invalid range.
1863  QCPRange result_range(QCPRange::minRange + 1, QCPRange::maxRange + 1);
1864 
1865  for(int iter = 0; iter < graphCount(); ++iter)
1866  {
1867  QCPRange temp_range;
1868 
1869  bool found_range_for_iter = false;
1870 
1871  QCPGraph *graph_p = graph(iter);
1872 
1873  // Depending on the axis param, select the key or value range.
1874 
1875  if(axis == Axis::x)
1876  temp_range = graph_p->getKeyRange(found_range_for_iter);
1877  else if(axis == Axis::y)
1878  temp_range = graph_p->getValueRange(found_range_for_iter);
1879  else
1880  qFatal("Cannot reach this point. Programming error.");
1881 
1882  // Was a range found for the iterated graph ? If not skip this
1883  // iteration.
1884 
1885  if(!found_range_for_iter)
1886  continue;
1887 
1888  // While the innermost_range is invalid, we need to seed it with a good
1889  // one. So check this.
1890 
1891  if(!QCPRange::validRange(result_range))
1892  qFatal("The obtained range is invalid !");
1893 
1894  // At this point we know the obtained range is OK.
1895  result_range = temp_range;
1896 
1897  // We found at least one valid range!
1898  found_at_least_one_range = true;
1899 
1900  // At this point we have two valid ranges to compare. Depending on
1901  // range_type, we need to perform distinct comparisons.
1902 
1903  if(range_type == RangeType::innermost)
1904  {
1905  if(temp_range.lower > result_range.lower)
1906  result_range.lower = temp_range.lower;
1907  if(temp_range.upper < result_range.upper)
1908  result_range.upper = temp_range.upper;
1909  }
1910  else if(range_type == RangeType::outermost)
1911  {
1912  if(temp_range.lower < result_range.lower)
1913  result_range.lower = temp_range.lower;
1914  if(temp_range.upper > result_range.upper)
1915  result_range.upper = temp_range.upper;
1916  }
1917  else
1918  qFatal("Cannot reach this point. Programming error.");
1919 
1920  // Continue to next graph, if any.
1921  }
1922  // End of
1923  // for(int iter = 0; iter < graphCount(); ++iter)
1924 
1925  // Let the caller know if we found at least one range.
1926  found_range = found_at_least_one_range;
1927 
1928  return result_range;
1929 }

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

1818 {
1819  QCPGraph *graph_p = graph(index);
1820 
1821  if(graph_p == nullptr)
1822  qFatal("Programming error.");
1823 
1824  return graph_p->getKeyRange(found_range);
1825 }

◆ getRangeY()

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

Definition at line 1829 of file baseplotwidget.cpp.

1830 {
1831  QCPGraph *graph_p = graph(index);
1832 
1833  if(graph_p == nullptr)
1834  qFatal("Programming error.");
1835 
1836  return graph_p->getValueRange(found_range);
1837 }

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

2202 {
2203  mp_xDeltaTextItem->setVisible(false);
2204  mp_yDeltaTextItem->setVisible(false);
2205 
2206  // mp_zoomRectItem->setVisible(false);
2208 
2209  // Force a replot to make sure the action is immediately visible by the
2210  // user, even without moving the mouse.
2211  replot();
2212 }
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 3057 of file baseplotwidget.cpp.

3058 {
3059  mp_selectionRectangeLine1->setVisible(false);
3060  mp_selectionRectangeLine2->setVisible(false);
3061  mp_selectionRectangeLine3->setVisible(false);
3062  mp_selectionRectangeLine4->setVisible(false);
3063 
3064  if(reset_values)
3065  {
3067  }
3068 }
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 2235 of file baseplotwidget.cpp.

2236 {
2237  m_shouldTracersBeVisible = false;
2238  mp_hPosTracerItem->setVisible(false);
2239  mp_vPosTracerItem->setVisible(false);
2240 
2241  mp_vStartTracerItem->setVisible(false);
2242  mp_vEndTracerItem->setVisible(false);
2243 
2244  // Force a replot to make sure the action is immediately visible by the
2245  // user, even without moving the mouse.
2246  replot();
2247 }
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 1764 of file baseplotwidget.cpp.

1765 {
1766  QPointF pixel_coordinates(
1767  xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()) + pixel_count,
1768  yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()));
1769 
1770  // Now convert back to local coordinates.
1771 
1772  QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1773  yAxis->pixelToCoord(pixel_coordinates.y()));
1774 
1775  return graph_coordinates;
1776 }

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

Referenced by horizontalMoveMouseCursorCountPixels().

◆ horizontalMoveMouseCursorCountPixels()

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

Definition at line 1748 of file baseplotwidget.cpp.

1749 {
1750  QPointF graph_coord = horizontalGetGraphCoordNewPointCountPixels(pixel_count);
1751 
1752  QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()),
1753  yAxis->coordToPixel(graph_coord.y()));
1754 
1755  // Now we need ton convert the new coordinates to the global position system
1756  // and to move the cursor to that new position. That will create an event to
1757  // move the mouse cursor.
1758 
1759  moveMouseCursorPixelCoordToGlobal(pixel_coord.toPoint());
1760 }
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 1642 of file baseplotwidget.cpp.

1643 {
1644  QCPLayoutElement *layoutElement = layoutElementAt(mousePoint);
1645 
1646  if(layoutElement &&
1647  layoutElement == dynamic_cast<QCPLayoutElement *>(axisRect()))
1648  {
1649  // The graph is *inside* the axisRect that is the outermost envelope of
1650  // the graph. Thus, if we want to know if the click was indeed on an
1651  // axis, we need to check what selectable part of the the axisRect we
1652  // were
1653  // clicking:
1654  QCPAxis::SelectablePart selectablePart;
1655 
1656  selectablePart = xAxis->getPartAt(mousePoint);
1657 
1658  if(selectablePart == QCPAxis::spAxisLabel ||
1659  selectablePart == QCPAxis::spAxis ||
1660  selectablePart == QCPAxis::spTickLabels)
1661  return true;
1662  }
1663 
1664  return false;
1665 }

Referenced by mousePressHandler().

◆ isClickOntoYAxis()

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

Definition at line 1669 of file baseplotwidget.cpp.

1670 {
1671  QCPLayoutElement *layoutElement = layoutElementAt(mousePoint);
1672 
1673  if(layoutElement &&
1674  layoutElement == dynamic_cast<QCPLayoutElement *>(axisRect()))
1675  {
1676  // The graph is *inside* the axisRect that is the outermost envelope of
1677  // the graph. Thus, if we want to know if the click was indeed on an
1678  // axis, we need to check what selectable part of the the axisRect we
1679  // were
1680  // clicking:
1681  QCPAxis::SelectablePart selectablePart;
1682 
1683  selectablePart = yAxis->getPartAt(mousePoint);
1684 
1685  if(selectablePart == QCPAxis::spAxisLabel ||
1686  selectablePart == QCPAxis::spAxis ||
1687  selectablePart == QCPAxis::spTickLabels)
1688  return true;
1689  }
1690 
1691  return false;
1692 }

Referenced by mousePressHandler().

◆ isSelectionRectangleVisible()

bool pappso::BasePlotWidget::isSelectionRectangleVisible ( )
virtual

Definition at line 3114 of file baseplotwidget.cpp.

3115 {
3116  // Sanity check
3117  int check = 0;
3118 
3119  check += mp_selectionRectangeLine1->visible();
3120  check += mp_selectionRectangeLine2->visible();
3121  check += mp_selectionRectangeLine3->visible();
3122  check += mp_selectionRectangeLine4->visible();
3123 
3124  if(check > 0)
3125  return true;
3126 
3127  return false;
3128 }

References mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, and mp_selectionRectangeLine4.

◆ isVerticalDisplacementAboveThreshold()

bool pappso::BasePlotWidget::isVerticalDisplacementAboveThreshold ( )
virtual

Definition at line 2455 of file baseplotwidget.cpp.

2456 {
2457  // First get the height of the plot.
2458  double plotHeight = yAxis->range().upper - yAxis->range().lower;
2459 
2460  double heightDiff =
2462 
2463  double heightDiffRatio = (heightDiff / plotHeight) * 100;
2464 
2465  if(heightDiffRatio > 10)
2466  {
2467  // qDebug() << "isVerticalDisplacementAboveThreshold: true";
2468  return true;
2469  }
2470 
2471  // qDebug() << "isVerticalDisplacementAboveThreshold: false";
2472  return false;
2473 }

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

Referenced by mouseMoveHandlerLeftButtonDraggingCursor(), and mouseMoveHandlerRightButtonDraggingCursor().

◆ keyPressEvent()

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

KEYBOARD-related EVENTS.

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

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::TicXicChromTracePlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::MassSpecTracePlotWidget, pappso::DriftSpecTracePlotWidget, and pappso::DriftSpecMassSpecColorMapPlotWidget.

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 
701  emit plottableDestructionRequestedSignal(this, graph(), m_context);
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  {
760  return mousePseudoButtonKeyReleaseEvent(event);
761  }
762  else if(event->key() == Qt::Key_S)
763  {
764  // The user has asked to measure the horizontal size of the rectangle and
765  // to start making a skewed selection rectangle.
766 
769 
770  // qDebug() << "Set m_context.selectRectangleWidth to"
771  //<< m_context.m_selectRectangleWidth << "upon release of S key";
772  }
773  // At this point emit the signal, since we did not treat it. Maybe the
774  // consumer widget wants to know that the keyboard key was released.
775 
777 }
virtual void directionKeyReleaseEvent(QKeyEvent *event)
void plottableDestructionRequestedSignal(BasePlotWidget *base_plot_widget_p, QCPAbstractPlottable *plottable_p, const BasePlotContext &context)
virtual void spaceKeyReleaseEvent(QKeyEvent *event)
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(), keyReleaseEventSignal(), m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_keyboardModifiers, m_leftMousePseudoButtonKey, pappso::BasePlotContext::m_pressedKeyCode, pappso::BasePlotContext::m_releasedKeyCode, m_rightMousePseudoButtonKey, pappso::BasePlotContext::m_selectRectangleWidth, m_shouldTracersBeVisible, pappso::BasePlotContext::m_startDragPoint, mousePseudoButtonKeyReleaseEvent(), plottableDestructionRequestedSignal(), restorePreviousAxesRangeHistory(), showTracers(), and spaceKeyReleaseEvent().

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

◆ keyReleaseEventSignal

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

Referenced by keyReleaseEvent().

◆ lastCursorHoveredPointSignal

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

◆ layerableLayerIndex()

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

Definition at line 203 of file baseplotwidget.cpp.

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

◆ layerableLayerName()

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

Definition at line 191 of file baseplotwidget.cpp.

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

◆ mouseMoveHandler()

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

KEYBOARD-related EVENTS.

MOUSE-related EVENTS

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

Definition at line 914 of file baseplotwidget.cpp.

915 {
916 
917  // If we have no focus, then get it. See setFocus() to understand why asking
918  // for focus is cosly and thus why we want to make this decision first.
919  if(!hasFocus())
920  setFocus();
921 
922  // The event->button() must be by Qt instructions considered to be 0.
923 
924  // Whatever happens, we want to store the plot coordinates of the current
925  // mouse cursor position (will be useful later for countless needs).
926 
927  QPointF mousePoint = event->localPos();
928 
929  // qDebug() << "local mousePoint position in pixels:" << mousePoint;
930 
931  m_context.m_lastCursorHoveredPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
932  m_context.m_lastCursorHoveredPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
933 
934  // qDebug() << "lastCursorHoveredPoint coord:"
935  //<< m_context.lastCursorHoveredPoint;
936 
937  // Now, depending on the button(s) (if any) that are pressed or not, we have
938  // a different processing.
939 
940  if(m_context.m_pressedMouseButtons & Qt::LeftButton ||
941  m_context.m_pressedMouseButtons & Qt::RightButton)
943  else
945 
946  event->accept();
947 }
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::TicXicChromTracePlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::MassSpecTracePlotWidget, pappso::DriftSpecTracePlotWidget, and pappso::DriftSpecMassSpecColorMapPlotWidget.

Definition at line 999 of file baseplotwidget.cpp.

1000 {
1002 
1003  // Now store the mouse position data into the the current drag point
1004  // member datum, that will be used in countless occasions later.
1006  m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1007 
1008  // When we drag (either keyboard or mouse), we hide the position markers
1009  // (black) and we show the start and end vertical markers for the region.
1010  // Then, we draw the horizontal region range marker that delimits
1011  // horizontally the dragged-over region.
1012 
1013  mp_hPosTracerItem->setVisible(false);
1014  mp_vPosTracerItem->setVisible(false);
1015 
1016  // Only bother with the tracers if the user wants them to be visible.
1018  {
1019 
1020  // The vertical end tracer position must be refreshed.
1021  mp_vEndTracerItem->start->setCoords(m_context.m_currentDragPoint.x(),
1022  yAxis->range().upper);
1023 
1024  mp_vEndTracerItem->end->setCoords(m_context.m_currentDragPoint.x(),
1025  yAxis->range().lower);
1026 
1027  mp_vEndTracerItem->setVisible(true);
1028  }
1029 
1030  // Whatever the button, when we are dealing with the axes, we do not
1031  // want to show any of the tracers.
1032 
1034  {
1035  mp_hPosTracerItem->setVisible(false);
1036  mp_vPosTracerItem->setVisible(false);
1037 
1038  mp_vStartTracerItem->setVisible(false);
1039  mp_vEndTracerItem->setVisible(false);
1040  }
1041  else
1042  {
1043  // Since we are not dragging the mouse cursor over the axes, make sure we
1044  // store the drag directions in the context, as this might be useful for
1045  // later operations.
1046 
1048 
1049  // qDebug() << m_context.toString();
1050  }
1051 
1052  // Because when we drag the mouse button (whatever the button) we need to know
1053  // what is the drag delta (distance between start point and current point of
1054  // the drag operation) on both axes, ask that these x|y deltas be computed.
1056 
1057  // Now deal with the BUTTON-SPECIFIC CODE.
1058 
1059  if(m_context.m_mouseButtonsAtMousePress & Qt::LeftButton)
1060  {
1062  }
1063  else if(m_context.m_mouseButtonsAtMousePress & Qt::RightButton)
1064  {
1066  }
1067 }
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 1071 of file baseplotwidget.cpp.

1072 {
1073  // qDebug() << "the left button is dragging.";
1074 
1075  // Set the context.m_isMeasuringDistance to false, which later might be set to
1076  // true if effectively we are measuring a distance. This is required because
1077  // the derived widget classes might want to know if they have to perform
1078  // some action on the basis that context is measuring a distance, for
1079  // example the mass spectrum-specific widget might want to compute
1080  // deconvolutions.
1081 
1083 
1084  // Let's first check if the mouse drag operation originated on either
1085  // axis. In that case, the user is performing axis reframing or rescaling.
1086 
1088  {
1089  // qDebug() << __FILE__ << __LINE__ << "Click was on one of the axes.";
1090 
1091  if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1092  {
1093  // The user is asking a rescale of the plot.
1094 
1095  // We know that we do not want the tracers when we perform axis
1096  // rescaling operations.
1097 
1098  mp_hPosTracerItem->setVisible(false);
1099  mp_vPosTracerItem->setVisible(false);
1100 
1101  mp_vStartTracerItem->setVisible(false);
1102  mp_vEndTracerItem->setVisible(false);
1103 
1104  // This operation is particularly intensive, thus we want to
1105  // reduce the number of calculations by skipping this calculation
1106  // a number of times. The user can ask for this feature by
1107  // clicking the 'Q' letter.
1108 
1109  if(m_context.m_pressedKeyCode == Qt::Key_Q)
1110  {
1112  {
1114  return;
1115  }
1116  else
1117  {
1119  }
1120  }
1121 
1122  // qDebug() << "Asking that the axes be rescaled.";
1123 
1124  axisRescale();
1125  }
1126  else
1127  {
1128  // The user was simply dragging the axis. Just pan, that is slide
1129  // the plot in the same direction as the mouse movement and with the
1130  // same amplitude.
1131 
1132  // qDebug() << "Asking that the axes be panned.";
1133 
1134  axisPan();
1135  }
1136 
1137  return;
1138  }
1139 
1140  // At this point we understand that the user was not performing any
1141  // panning/rescaling operation by clicking on any one of the axes.. Go on
1142  // with other possibilities.
1143 
1144  // Let's check if the user is actually drawing a rectangle (covering a
1145  // real area) or is drawing a line.
1146 
1147  // qDebug() << "The mouse dragging did not originate on an axis.";
1148 
1150  {
1151  // qDebug() << "Apparently the selection is a real rectangle.";
1152 
1153  // When we draw a rectangle the tracers are of no use.
1154 
1155  mp_hPosTracerItem->setVisible(false);
1156  mp_vPosTracerItem->setVisible(false);
1157 
1158  mp_vStartTracerItem->setVisible(false);
1159  mp_vEndTracerItem->setVisible(false);
1160 
1161  // Draw the rectangle, false, not as line segment and
1162  // false, not for integration
1164 
1165  // Draw the selection width/height text
1168 
1169  // qDebug() << "The selection polygon:"
1170  //<< m_context.m_selectionPolygon.toString();
1171  }
1172  else
1173  {
1174  // qDebug() << "Apparently we are measuring a delta.";
1175 
1176  // Draw the rectangle, true, as line segment and
1177  // false, not for integration
1179 
1180  // qDebug() << "The selection polygon:"
1181  //<< m_context.m_selectionPolygon.toString();
1182 
1183  // The pure position tracers should be hidden.
1184  mp_hPosTracerItem->setVisible(true);
1185  mp_vPosTracerItem->setVisible(true);
1186 
1187  // Then, make sure the region range vertical tracers are visible.
1188  mp_vStartTracerItem->setVisible(true);
1189  mp_vEndTracerItem->setVisible(true);
1190 
1191  // Draw the selection width text
1193  }
1194 }
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 drawYDeltaFeatures()
virtual bool isVerticalDisplacementAboveThreshold()
virtual void drawXDeltaFeatures()
virtual void axisRescale()
RANGE-related functions.

References axisPan(), axisRescale(), drawSelectionRectangleAndPrepareZoom(), drawXDeltaFeatures(), drawYDeltaFeatures(), 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::TicXicChromTracePlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::MassSpecTracePlotWidget, pappso::DriftSpecTracePlotWidget, and pappso::DriftSpecMassSpecColorMapPlotWidget.

Definition at line 951 of file baseplotwidget.cpp.

952 {
953 
955 
956  // We are not dragging the mouse (no button pressed), simply let this
957  // widget's consumer know the position of the cursor and update the markers.
958  // The consumer of this widget will update mouse cursor position at
959  // m_context.m_lastCursorHoveredPoint if so needed.
960 
962 
963  // We are not dragging, so we do not show the region end tracer we only show
964  // the anchoring start trace that might be of use if the user starts using
965  // the arrow keys to move the cursor.
966  mp_vEndTracerItem->setVisible(false);
967 
968  // Only bother with the tracers if the user wants them to be visible. Their
969  // crossing point must be exactly at the last cursor-hovered point.
970 
972  {
973  // We are not dragging, so only show the position markers (v and h);
974 
975  // Horizontal position tracer.
976  mp_hPosTracerItem->setVisible(true);
977  mp_hPosTracerItem->start->setCoords(
978  xAxis->range().lower, m_context.m_lastCursorHoveredPoint.y());
979  mp_hPosTracerItem->end->setCoords(xAxis->range().upper,
981 
982  // Vertical position tracer.
983  mp_vPosTracerItem->setVisible(true);
984 
985  mp_vPosTracerItem->setVisible(true);
986  mp_vPosTracerItem->start->setCoords(
987  m_context.m_lastCursorHoveredPoint.x(), yAxis->range().upper);
989  yAxis->range().lower);
990 
991  replot();
992  }
993 
994  return;
995 }
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 1198 of file baseplotwidget.cpp.

1199 {
1200  // qDebug() << "the right button is dragging.";
1201 
1202  // Set the context.m_isMeasuringDistance to false, which later might be set to
1203  // true if effectively we are measuring a distance. This is required because
1204  // the derived widgets might want to know if they have to perform some
1205  // action on the basis that context is measuring a distance, for example the
1206  // mass spectrum-specific widget might want to compute deconvolutions.
1207 
1209 
1211  {
1212  // qDebug() << "Apparently the selection is a real rectangle.";
1213 
1214  // When we draw a rectangle the tracers are of no use.
1215 
1216  mp_hPosTracerItem->setVisible(false);
1217  mp_vPosTracerItem->setVisible(false);
1218 
1219  mp_vStartTracerItem->setVisible(false);
1220  mp_vEndTracerItem->setVisible(false);
1221 
1222  // Draw the rectangle, false for as_line_segment and true, for
1223  // integration.
1225 
1226  // Draw the selection width/height text
1229  }
1230  else
1231  {
1232  // Draw the rectangle, true, as line segment and
1233  // false, true for integration
1235 
1236  // Draw the selection width text
1238  }
1239 
1240  // Draw the selection width text
1242 }

References drawSelectionRectangleAndPrepareZoom(), drawXDeltaFeatures(), drawYDeltaFeatures(), 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::TicXicChromTracePlotWidget, pappso::TicXicChromMassSpecColorMapPlotWidget, pappso::TicXicChromDriftSpecColorMapPlotWidget, pappso::MassSpecTracePlotWidget, pappso::DriftSpecTracePlotWidget, and pappso::DriftSpecMassSpecColorMapPlotWidget.

Definition at line 1246 of file baseplotwidget.cpp.

1247 {
1248  // When the user clicks this widget it has to take focus.
1249  setFocus();
1250 
1251  QPointF mousePoint = event->localPos();
1252 
1253  m_context.m_lastPressedMouseButton = event->button();
1254  m_context.m_mouseButtonsAtMousePress = event->buttons();
1255 
1256  // The pressedMouseButtons must continually inform on the status of pressed
1257  // buttons so add the pressed button.
1258  m_context.m_pressedMouseButtons |= event->button();
1259 
1260  // qDebug().noquote() << m_context.toString();
1261 
1262  // In all the processing of the events, we need to know if the user is
1263  // clicking somewhere with the intent to change the plot ranges (reframing
1264  // or rescaling the plot).
1265  //
1266  // Reframing the plot means that the new x and y axes ranges are modified so
1267  // that they match the region that the user has encompassed by left clicking
1268  // the mouse and dragging it over the plot. That is we reframe the plot so
1269  // that it contains only the "selected" region.
1270  //
1271  // Rescaling the plot means the the new x|y axis range is modified such that
1272  // the lower axis range is constant and the upper axis range is moved either
1273  // left or right by the same amont as the x|y delta encompassed by the user
1274  // moving the mouse. The axis is thus either compressed (mouse movement is
1275  // leftwards) or un-compressed (mouse movement is rightwards).
1276 
1277  // There are two ways to perform axis range modifications:
1278  //
1279  // 1. By clicking on any of the axes
1280  // 2. By clicking on the plot region but using keyboard key modifiers, like
1281  // Alt and Ctrl.
1282  //
1283  // We need to know both cases separately which is why we need to perform a
1284  // number of tests below.
1285 
1286  // Let's check if the click is on the axes, either X or Y, because that
1287  // will allow us to take proper actions.
1288 
1289  if(isClickOntoXAxis(mousePoint))
1290  {
1291  // The X axis was clicked upon, we need to document that:
1292  // qDebug() << __FILE__ << __LINE__
1293  //<< "Layout element is axisRect and actually on an X axis part.";
1294 
1296 
1297  // int currentInteractions = interactions();
1298  // currentInteractions |= QCP::iRangeDrag;
1299  // setInteractions((QCP::Interaction)currentInteractions);
1300  // axisRect()->setRangeDrag(xAxis->orientation());
1301  }
1302  else
1303  m_context.m_wasClickOnXAxis = false;
1304 
1305  if(isClickOntoYAxis(mousePoint))
1306  {
1307  // The Y axis was clicked upon, we need to document that:
1308  // qDebug() << __FILE__ << __LINE__
1309  //<< "Layout element is axisRect and actually on an Y axis part.";
1310 
1312 
1313  // int currentInteractions = interactions();
1314  // currentInteractions |= QCP::iRangeDrag;
1315  // setInteractions((QCP::Interaction)currentInteractions);
1316  // axisRect()->setRangeDrag(yAxis->orientation());
1317  }
1318  else
1319  m_context.m_wasClickOnYAxis = false;
1320 
1321  // At this point, let's see if we need to remove the QCP::iRangeDrag bit:
1322 
1324  {
1325  // qDebug() << __FILE__ << __LINE__
1326  // << "Click outside of axes.";
1327 
1328  // int currentInteractions = interactions();
1329  // currentInteractions = currentInteractions & ~QCP::iRangeDrag;
1330  // setInteractions((QCP::Interaction)currentInteractions);
1331  }
1332 
1333  m_context.m_startDragPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
1334  m_context.m_startDragPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
1335 
1336  // Now install the vertical start tracer at the last cursor hovered
1337  // position.
1339  mp_vStartTracerItem->setVisible(true);
1340 
1342  yAxis->range().upper);
1344  yAxis->range().lower);
1345 
1346  replot();
1347 }
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 839 of file baseplotwidget.cpp.

841 {
842  // qDebug();
843 }

Referenced by keyPressEvent().

◆ mousePseudoButtonKeyReleaseEvent()

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

Definition at line 847 of file baseplotwidget.cpp.

848 {
849 
850  QPointF pixel_coordinates(
851  xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()),
852  yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()));
853 
854  Qt::MouseButton button = Qt::NoButton;
855  QEvent::Type q_event_type = QEvent::MouseButtonPress;
856 
857  if(event->key() == m_leftMousePseudoButtonKey)
858  {
859  // Toggles the left mouse button on/off
860 
861  button = Qt::LeftButton;
862 
865 
867  q_event_type = QEvent::MouseButtonPress;
868  else
869  q_event_type = QEvent::MouseButtonRelease;
870  }
871  else if(event->key() == m_rightMousePseudoButtonKey)
872  {
873  // Toggles the right mouse button.
874 
875  button = Qt::RightButton;
876 
879 
881  q_event_type = QEvent::MouseButtonPress;
882  else
883  q_event_type = QEvent::MouseButtonRelease;
884  }
885 
886  // qDebug() << "pressed/released pseudo button:" << button
887  //<< "q_event_type:" << q_event_type;
888 
889  // Synthesize a QMouseEvent and use it.
890 
891  QMouseEvent *mouse_event_p =
892  new QMouseEvent(q_event_type,
893  pixel_coordinates,
894  mapToGlobal(pixel_coordinates.toPoint()),
895  mapToGlobal(pixel_coordinates.toPoint()),
896  button,
897  button,
899  Qt::MouseEventSynthesizedByApplication);
900 
901  if(q_event_type == QEvent::MouseButtonPress)
902  mousePressHandler(mouse_event_p);
903  else
904  mouseReleaseHandler(mouse_event_p);
905 
906  // event->accept();
907 }
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

◆ mouseReleaseHandler()

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

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

Definition at line 1351 of file baseplotwidget.cpp.

1352 {
1353  // Now the real code of this function.
1354 
1355  m_context.m_lastReleasedMouseButton = event->button();
1356 
1357  // The event->buttons() is the description of the buttons that are pressed at
1358  // the moment the handler is invoked, that is now. If left and right were
1359  // pressed, and left was released, event->buttons() would be right.
1360  m_context.m_mouseButtonsAtMouseRelease = event->buttons();
1361 
1362  // The pressedMouseButtons must continually inform on the status of pressed
1363  // buttons so remove the released button.
1364  m_context.m_pressedMouseButtons ^= event->button();
1365 
1366  // qDebug().noquote() << m_context.toString();
1367 
1368  // We'll need to know if modifiers were pressed a the moment the user
1369  // released the mouse button.
1370  m_context.m_keyboardModifiers = QGuiApplication::keyboardModifiers();
1371 
1373  {
1374  // Let the user know that the mouse was *not* being dragged.
1375  m_context.m_wasMouseDragging = false;
1376 
1377  event->accept();
1378 
1379  return;
1380  }
1381 
1382  // Let the user know that the mouse was being dragged.
1384 
1385  // We cannot hide all items in one go because we rely on their visibility
1386  // to know what kind of dragging operation we need to perform (line-only
1387  // X-based zoom or rectangle-based X- and Y-based zoom, for example). The
1388  // only thing we know is that we can make the text invisible.
1389 
1390  // Same for the x delta text item
1391  mp_xDeltaTextItem->setVisible(false);
1392  mp_yDeltaTextItem->setVisible(false);
1393 
1394  // We do not show the end vertical region range marker.
1395  mp_vEndTracerItem->setVisible(false);
1396 
1397  // Horizontal position tracer.
1398  mp_hPosTracerItem->setVisible(true);
1399  mp_hPosTracerItem->start->setCoords(xAxis->range().lower,
1401  mp_hPosTracerItem->end->setCoords(xAxis->range().upper,
1403 
1404  // Vertical position tracer.
1405  mp_vPosTracerItem->setVisible(true);
1406 
1407  mp_vPosTracerItem->setVisible(true);
1409  yAxis->range().upper);
1411  yAxis->range().lower);
1412 
1413  // Force replot now because later that call might not be performed.
1414  replot();
1415 
1416  // If we were using the "quantum" display for the rescale of the axes
1417  // using the Ctrl-modified left button click drag in the axes, then reset
1418  // the count to 0.
1420 
1421  // Now that we have computed the useful ranges, we need to check what to do
1422  // depending on the button that was pressed.
1423 
1424  if(m_context.m_lastReleasedMouseButton == Qt::LeftButton)
1425  {
1427  }
1428  else if(m_context.m_lastReleasedMouseButton == Qt::RightButton)
1429  {
1431  }
1432 
1433  // By definition we are stopping the drag operation by releasing the mouse
1434  // button. Whatever that mouse button was pressed before and if there was
1435  // one pressed before. We cannot set that boolean value to false before
1436  // this place, because we call a number of routines above that need to know
1437  // that dragging was occurring. Like mouseReleaseHandledEvent(event) for
1438  // example.
1439 
1440  m_context.m_isMouseDragging = false;
1441 
1442  event->accept();
1443 
1444  return;
1445 }
Qt::MouseButtons m_mouseButtonsAtMouseRelease
Qt::MouseButtons m_lastReleasedMouseButton
virtual void mouseReleaseHandlerRightButton()
virtual void mouseReleaseHandlerLeftButton()

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

1450 {
1451 
1453  {
1454 
1455  // When the mouse move handler pans the plot, we cannot store each axes
1456  // range history element that would mean store a huge amount of such
1457  // elements, as many element as there are mouse move event handled by
1458  // the Qt event queue. But we can store an axis range history element
1459  // for the last situation of the mouse move: when the button is
1460  // released:
1461 
1463 
1465 
1466  replot();
1467 
1468  // Nothing else to do.
1469  return;
1470  }
1471 
1472  // There are two possibilities:
1473  //
1474  // 1. The full selection polygon (four lines) were currently drawn, which
1475  // means the user was willing to perform a zoom operation
1476  //
1477  // 2. Only the first top line was drawn, which means the user was dragging
1478  // the cursor horizontally. That might have two ends, as shown below.
1479 
1480  // So, first check what is drawn of the selection polygon.
1481 
1482  PolygonType current_selection_polygon_type =
1484 
1485  // Now that we know what was currently drawn of the selection polygon, we can
1486  // remove it. true to reset the values to 0.
1487  hideSelectionRectangle(true);
1488 
1489  // Force replot now because later that call might not be performed.
1490  replot();
1491 
1492  if(current_selection_polygon_type == PolygonType::FULL_POLYGON)
1493  {
1494  // qDebug() << "Yes, the full polygon was visible";
1495 
1496  // If we were dragging with the left button pressed and could draw a
1497  // rectangle, then we were preparing a zoom operation. Let's bring that
1498  // operation to its accomplishment.
1499 
1500  axisZoom();
1501 
1502  // qDebug() << "The selection polygon:"
1503  //<< m_context.m_selectionPolygon.toString();
1504 
1505  return;
1506  }
1507  else if(current_selection_polygon_type == PolygonType::TOP_LINE)
1508  {
1509  // qDebug() << "No, only the top line of the full polygon was visible";
1510 
1511  // The user was dragging the left mouse cursor and that may mean they were
1512  // measuring a distance or willing to perform a special zoom operation if
1513  // the Ctrl key was down.
1514 
1515  // If the user started by clicking in the plot region, dragged the mouse
1516  // cursor with the left button and pressed the Ctrl modifier, then that
1517  // means that they wanted to do a rescale over the x-axis in the form of a
1518  // reframing.
1519 
1520  if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1521  {
1522  return axisReframe();
1523 
1524  // qDebug() << "The selection polygon:"
1525  //<< m_context.m_selectionPolygon.toString();
1526  }
1527  }
1528  else
1529  qDebug() << "Another possibility.";
1530 }
virtual PolygonType whatIsVisibleOfTheSelectionRectangle()

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

1535 {
1536 
1537  // The right button is used for the integrations. Not for axis range
1538  // operations. So all we have to do is remove the various graphics items and
1539  // send a signal with the context that contains all the data required by the
1540  // user to perform the integrations over the right plot regions.
1541 
1542  // Whatever we were doing we need to make the selection line invisible:
1543 
1544  if(mp_xDeltaTextItem->visible())
1545  mp_xDeltaTextItem->setVisible(false);
1546  if(mp_yDeltaTextItem->visible())
1547  mp_yDeltaTextItem->setVisible(false);
1548 
1549  // Also make the vertical end tracer invisible.
1550  mp_vEndTracerItem->setVisible(false);
1551 
1552  // Once the integration is asked for, then the selection rectangle if of no
1553  // more use.
1555 
1556  // Force replot now because later that call might not be performed.
1557  replot();
1558 
1559  // Note that we only request an integration if the x-axis delta is enough.
1560 
1561  double x_delta_pixel =
1562  fabs(xAxis->coordToPixel(m_context.m_currentDragPoint.x()) -
1563  xAxis->coordToPixel(m_context.m_startDragPoint.x()));
1564 
1565  if(x_delta_pixel > 3)
1567  // else
1568  // qDebug() << "Not asking for integration.";
1569 }
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 1573 of file baseplotwidget.cpp.

1574 {
1575  // We should record the new range values each time the wheel is used to
1576  // zoom/unzoom.
1577 
1578  m_context.m_xRange = QCPRange(xAxis->range());
1579  m_context.m_yRange = QCPRange(yAxis->range());
1580 
1581  // qDebug() << "New x range: " << m_context.m_xRange;
1582  // qDebug() << "New y range: " << m_context.m_yRange;
1583 
1585 
1588 
1589  event->accept();
1590 }
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 1728 of file baseplotwidget.cpp.

1729 {
1730  // First convert the graph coordinates to pixel coordinates.
1731 
1732  QPointF pixels_coordinates(xAxis->coordToPixel(graph_coordinates.x()),
1733  yAxis->coordToPixel(graph_coordinates.y()));
1734 
1735  moveMouseCursorPixelCoordToGlobal(pixels_coordinates.toPoint());
1736 }

References moveMouseCursorPixelCoordToGlobal().

◆ moveMouseCursorPixelCoordToGlobal()

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

Definition at line 1740 of file baseplotwidget.cpp.

1741 {
1742  // qDebug() << "Calling set pos with new cursor position.";
1743  QCursor::setPos(mapToGlobal(pixel_coordinates.toPoint()));
1744 }

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

3147 {
3148  if(focusedPlotWidget == nullptr)
3149  throw ExceptionNotPossible(
3150  "baseplotwidget.cpp @ redrawPlotBackground(QWidget *focusedPlotWidget "
3151  "-- "
3152  "ERROR focusedPlotWidget cannot be nullptr.");
3153 
3154  if(dynamic_cast<QWidget *>(this) != focusedPlotWidget)
3155  {
3156  // The focused widget is not *this widget. We should make sure that
3157  // we were not the one that had the focus, because in this case we
3158  // need to redraw an unfocused background.
3159 
3160  axisRect()->setBackground(m_unfocusedBrush);
3161  }
3162  else
3163  {
3164  axisRect()->setBackground(m_focusedBrush);
3165  }
3166 
3167  replot();
3168 }
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 2150 of file baseplotwidget.cpp.

2153 {
2154  if(static_cast<int>(axis) & static_cast<int>(Axis::x))
2155  {
2156  xAxis->setRange(xAxisRange.lower, xAxisRange.upper);
2157  }
2158 
2159  if(static_cast<int>(axis) & static_cast<int>(Axis::y))
2160  {
2161  yAxis->setRange(yAxisRange.lower, yAxisRange.upper);
2162  }
2163 
2164  // We do not want to update the history, because there would be way too
2165  // much history items, since this function is called upon mouse moving
2166  // handling and not only during mouse release events.
2167  // updateAxesRangeHistory();
2168 
2169  replot();
2170 }

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

◆ replotWithAxisRangeX()

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

Definition at line 2174 of file baseplotwidget.cpp.

2175 {
2176  // qDebug();
2177 
2178  xAxis->setRange(lower, upper);
2179 
2180  replot();
2181 }

◆ replotWithAxisRangeY()

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

Definition at line 2185 of file baseplotwidget.cpp.

2186 {
2187  // qDebug();
2188 
2189  yAxis->setRange(lower, upper);
2190 
2191  replot();
2192 }

◆ 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::BaseTracePlotWidget::addTrace(), axisDoubleClickHandler(), pappso::BaseTracePlotWidget::axisDoubleClickHandler(), pappso::BaseTracePlotWidget::clearGraphData(), and pappso::BaseTracePlotWidget::setGraphData().

◆ resetSelectionRectangle()

void pappso::BasePlotWidget::resetSelectionRectangle ( )
virtual

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

3133 {
3134  // qDebug() << "Setting focus to the QCustomPlot:" << this;
3135 
3136  QCustomPlot::setFocus();
3137 
3138  // qDebug() << "Emitting setFocusSignal().";
3139 
3140  emit setFocusSignal();
3141 }

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().

◆ showTracers()

void pappso::BasePlotWidget::showTracers ( )
virtual

Show the traces (vertical and horizontal).

Definition at line 2217 of file baseplotwidget.cpp.

2218 {
2219  m_shouldTracersBeVisible = true;
2220 
2221  mp_vPosTracerItem->setVisible(true);
2222  mp_hPosTracerItem->setVisible(true);
2223 
2224  mp_vStartTracerItem->setVisible(true);
2225  mp_vEndTracerItem->setVisible(true);
2226 
2227  // Force a replot to make sure the action is immediately visible by the
2228  // user, even without moving the mouse.
2229  replot();
2230 }

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

782 {
783  // qDebug();
784 }

Referenced by keyReleaseEvent().

◆ update1DSelectionRectangle()

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

Definition at line 2477 of file baseplotwidget.cpp.

2478 {
2479 
2480  // if(for_integration)
2481  // qDebug() << "for_integration:" << for_integration;
2482 
2483  // When we make a linear selection, the selection polygon is a polygon that
2484  // has the following characteristics:
2485  //
2486  // the x range is the linear selection span
2487  //
2488  // the y range is the widest std::min -> std::max possible.
2489 
2490  // This is how the selection polygon logic knows if its is mono-
2491  // two-dimensional.
2492 
2493  // We want the top left point to effectively be the top left point, so check
2494  // the direction of the mouse cursor drag.
2495 
2496  double x_range_start =
2498  double x_range_end =
2500 
2501  double y_position = m_context.m_startDragPoint.y();
2502 
2503  m_context.m_selectionPolygon.set1D(x_range_start, x_range_end);
2504 
2505  // Top line
2506  mp_selectionRectangeLine1->start->setCoords(
2507  QPointF(x_range_start, y_position));
2508  mp_selectionRectangeLine1->end->setCoords(QPointF(x_range_end, y_position));
2509 
2510  // Only if we are drawing a selection rectangle for integration, do we set
2511  // arrow heads to the line.
2512  if(for_integration)
2513  {
2514  mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2515  mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2516  }
2517  else
2518  {
2519  mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2520  mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2521  }
2522  mp_selectionRectangeLine1->setVisible(true);
2523 
2524  // Right line: does not exist, start and end are the same end point of the top
2525  // line.
2526  mp_selectionRectangeLine2->start->setCoords(QPointF(x_range_end, y_position));
2527  mp_selectionRectangeLine2->end->setCoords(QPointF(x_range_end, y_position));
2528  mp_selectionRectangeLine2->setVisible(false);
2529 
2530  // Bottom line: identical to the top line, but invisible
2531  mp_selectionRectangeLine3->start->setCoords(
2532  QPointF(x_range_start, y_position));
2533  mp_selectionRectangeLine3->end->setCoords(QPointF(x_range_end, y_position));
2534  mp_selectionRectangeLine3->setVisible(false);
2535 
2536  // Left line: does not exist: start and end are the same end point of the top
2537  // line.
2538  mp_selectionRectangeLine4->start->setCoords(QPointF(x_range_end, y_position));
2539  mp_selectionRectangeLine4->end->setCoords(QPointF(x_range_end, y_position));
2540  mp_selectionRectangeLine4->setVisible(false);
2541 }
void set1D(double x_range_start, double x_range_end)

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

Referenced by updateSelectionRectangle().

◆ update2DSelectionRectangleSkewed()

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

Definition at line 2730 of file baseplotwidget.cpp.

2731 {
2732 
2733  // if(for_integration)
2734  // qDebug() << "for_integration:" << for_integration;
2735 
2736  // We are handling a skewed rectangle, that is a rectangle that is
2737  // tilted either to the left or to the right.
2738 
2739  // qDebug() << "m_context.m_selectRectangleWidth: "
2740  //<< m_context.m_selectRectangleWidth;
2741 
2742  // Top line
2743  // start
2744 
2745  // qDebug() << "m_context.m_startDragPoint: " <<
2746  // m_context.m_startDragPoint.x()
2747  //<< "-" << m_context.m_startDragPoint.y();
2748 
2749  // qDebug() << "m_context.m_currentDragPoint: "
2750  //<< m_context.m_currentDragPoint.x() << "-"
2751  //<< m_context.m_currentDragPoint.y();
2752 
2754 
2756  {
2757  // qDebug() << "Dragging from right to left";
2758 
2760  {
2761  // qDebug() << "Dragging from top to bottom";
2762 
2767 
2768  // m_context.m_selRectTopLeftPoint.setX(
2769  // m_context.m_startDragPoint.x() -
2770  // m_context.m_selectRectangleWidth);
2771  // m_context.m_selRectTopLeftPoint.setY(m_context.m_startDragPoint.y());
2772 
2776 
2777  // m_context.m_selRectTopRightPoint.setX(m_context.m_startDragPoint.x());
2778  // m_context.m_selRectTopRightPoint.setY(m_context.m_startDragPoint.y());
2779 
2784 
2785  // m_context.m_selRectBottomRightPoint.setX(
2786  // m_context.m_currentDragPoint.x() +
2787  // m_context.m_selectRectangleWidth);
2788  // m_context.m_selRectBottomRightPoint.setY(
2789  // m_context.m_currentDragPoint.y());
2790 
2795 
2796  // m_context.m_selRectBottomLeftPoint.setX(
2797  // m_context.m_currentDragPoint.x());
2798  // m_context.m_selRectBottomLeftPoint.setY(
2799  // m_context.m_currentDragPoint.y());
2800  }
2801  else
2802  {
2803  // qDebug() << "Dragging from bottom to top";
2804 
2809 
2810  // m_context.m_selRectTopLeftPoint.setX(
2811  // m_context.m_currentDragPoint.x());
2812  // m_context.m_selRectTopLeftPoint.setY(
2813  // m_context.m_currentDragPoint.y());
2814 
2819 
2820  // m_context.m_selRectTopRightPoint.setX(
2821  // m_context.m_currentDragPoint.x() +
2822  // m_context.m_selectRectangleWidth);
2823  // m_context.m_selRectTopRightPoint.setY(
2824  // m_context.m_currentDragPoint.y());
2825 
2826 
2830 
2831  // m_context.m_selRectBottomRightPoint.setX(
2832  // m_context.m_startDragPoint.x());
2833  // m_context.m_selRectBottomRightPoint.setY(
2834  // m_context.m_startDragPoint.y());
2835 
2840 
2841  // m_context.m_selRectBottomLeftPoint.setX(
2842  // m_context.m_startDragPoint.x() -
2843  // m_context.m_selectRectangleWidth);
2844  // m_context.m_selRectBottomLeftPoint.setY(
2845  // m_context.m_startDragPoint.y());
2846  }
2847  }
2848  // End of
2849  // Dragging from right to left.
2850  else
2851  {
2852  // qDebug() << "Dragging from left to right";
2853 
2855  {
2856  // qDebug() << "Dragging from top to bottom";
2857 
2861 
2862  // m_context.m_selRectTopLeftPoint.setX(m_context.m_startDragPoint.x());
2863  // m_context.m_selRectTopLeftPoint.setY(m_context.m_startDragPoint.y());
2864 
2869 
2870  // m_context.m_selRectTopRightPoint.setX(
2871  // m_context.m_startDragPoint.x() +
2872  // m_context.m_selectRectangleWidth);
2873  // m_context.m_selRectTopRightPoint.setY(m_context.m_startDragPoint.y());
2874 
2879 
2880  // m_context.m_selRectBottomRightPoint.setX(
2881  // m_context.m_currentDragPoint.x());
2882  // m_context.m_selRectBottomRightPoint.setY(
2883  // m_context.m_currentDragPoint.y());
2884 
2889 
2890  // m_context.m_selRectBottomLeftPoint.setX(
2891  // m_context.m_currentDragPoint.x() -
2892  // m_context.m_selectRectangleWidth);
2893  // m_context.m_selRectBottomLeftPoint.setY(
2894  // m_context.m_currentDragPoint.y());
2895  }
2896  else
2897  {
2898  // qDebug() << "Dragging from bottom to top";
2899 
2904 
2905  // m_context.m_selRectTopLeftPoint.setX(
2906  // m_context.m_currentDragPoint.x() -
2907  // m_context.m_selectRectangleWidth);
2908  // m_context.m_selRectTopLeftPoint.setY(
2909  // m_context.m_currentDragPoint.y());
2910 
2915 
2916  // m_context.m_selRectTopRightPoint.setX(
2917  // m_context.m_currentDragPoint.x());
2918  // m_context.m_selRectTopRightPoint.setY(
2919  // m_context.m_currentDragPoint.y());
2920 
2925 
2926  // m_context.m_selRectBottomRightPoint.setX(
2927  // m_context.m_startDragPoint.x() +
2928  // m_context.m_selectRectangleWidth);
2929  // m_context.m_selRectBottomRightPoint.setY(
2930  // m_context.m_startDragPoint.y());
2931 
2935 
2936  // m_context.m_selRectBottomLeftPoint.setX(
2937  // m_context.m_startDragPoint.x());
2938  // m_context.m_selRectBottomLeftPoint.setY(
2939  // m_context.m_startDragPoint.y());
2940  }
2941  }
2942  // End of Dragging from left to right.
2943 
2944  // qDebug() << "Now draw the lines with points:"
2945  //<< m_context.m_selectionPolygon.toString();
2946 
2947  // Top line
2948  mp_selectionRectangeLine1->start->setCoords(
2950  mp_selectionRectangeLine1->end->setCoords(
2952 
2953  // Only if we are drawing a selection rectangle for integration, do we set
2954  // arrow heads to the line.
2955  if(for_integration)
2956  {
2957  mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2958  mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2959  }
2960  else
2961  {
2962  mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2963  mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2964  }
2965 
2966  mp_selectionRectangeLine1->setVisible(true);
2967 
2968  // Right line
2969  mp_selectionRectangeLine2->start->setCoords(
2971  mp_selectionRectangeLine2->end->setCoords(
2973  mp_selectionRectangeLine2->setVisible(true);
2974 
2975  // Bottom line
2976  mp_selectionRectangeLine3->start->setCoords(
2978  mp_selectionRectangeLine3->end->setCoords(
2980  mp_selectionRectangeLine3->setVisible(true);
2981 
2982  // Left line
2983  mp_selectionRectangeLine4->end->setCoords(
2985  mp_selectionRectangeLine4->start->setCoords(
2987  mp_selectionRectangeLine4->setVisible(true);
2988 }
void setPoint(PointSpecs point_spec, double x, double y)
QPointF getPoint(PointSpecs point_spec) const

References pappso::BOTTOM_LEFT_POINT, pappso::BOTTOM_RIGHT_POINT, pappso::SelectionPolygon::getPoint(), m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_selectionPolygon, pappso::BasePlotContext::m_selectRectangleWidth, pappso::BasePlotContext::m_startDragPoint, mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, pappso::SelectionPolygon::resetPoints(), pappso::SelectionPolygon::setPoint(), pappso::TOP_LEFT_POINT, and pappso::TOP_RIGHT_POINT.

Referenced by updateSelectionRectangle().

◆ update2DSelectionRectangleSquare()

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

Definition at line 2545 of file baseplotwidget.cpp.

2546 {
2547 
2548  // if(for_integration)
2549  // qDebug() << "for_integration:" << for_integration;
2550 
2551  // We are handling a conventional rectangle. Just create four points
2552  // from top left to bottom right. But we want the top left point to be
2553  // effectively the top left point and the bottom point to be the bottom point.
2554  // So we need to try all four direction combinations, left to right or
2555  // converse versus top to bottom or converse.
2556 
2558 
2560  {
2561  // qDebug() << "Dragging from right to left";
2562 
2564  {
2565  // qDebug() << "Dragging from top to bottom";
2566 
2567  // TOP_LEFT_POINT
2572 
2573  // TOP_RIGHT_POINT
2577 
2578  // BOTTOM_RIGHT_POINT
2583 
2584  // BOTTOM_LEFT_POINT
2589  }
2590  // End of
2591  // if(m_context.m_currentDragPoint.y() < m_context.m_startDragPoint.y())
2592  else
2593  {
2594  // qDebug() << "Dragging from bottom to top";
2595 
2596  // TOP_LEFT_POINT
2601 
2602  // TOP_RIGHT_POINT
2607 
2608  // BOTTOM_RIGHT_POINT
2612 
2613  // BOTTOM_LEFT_POINT
2618  }
2619  }
2620  // End of
2621  // if(m_context.m_currentDragPoint.x() < m_context.m_startDragPoint.x())
2622  else
2623  {
2624  // qDebug() << "Dragging from left to right";
2625 
2627  {
2628  // qDebug() << "Dragging from top to bottom";
2629 
2630  // TOP_LEFT_POINT
2634 
2635  // TOP_RIGHT_POINT
2640 
2641  // BOTTOM_RIGHT_POINT
2646 
2647  // BOTTOM_LEFT_POINT
2652  }
2653  else
2654  {
2655  // qDebug() << "Dragging from bottom to top";
2656 
2657  // TOP_LEFT_POINT
2662 
2663  // TOP_RIGHT_POINT
2668 
2669  // BOTTOM_RIGHT_POINT
2674 
2675  // BOTTOM_LEFT_POINT
2679  }
2680  }
2681 
2682  // qDebug() << "Now draw the lines with points:"
2683  //<< m_context.m_selectionPolygon.toString();
2684 
2685  // Top line
2686  mp_selectionRectangeLine1->start->setCoords(
2688  mp_selectionRectangeLine1->end->setCoords(
2690 
2691  // Only if we are drawing a selection rectangle for integration, do we
2692  // set arrow heads to the line.
2693  if(for_integration)
2694  {
2695  mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2696  mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2697  }
2698  else
2699  {
2700  mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2701  mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2702  }
2703 
2704  mp_selectionRectangeLine1->setVisible(true);
2705 
2706  // Right line
2707  mp_selectionRectangeLine2->start->setCoords(
2709  mp_selectionRectangeLine2->end->setCoords(
2711  mp_selectionRectangeLine2->setVisible(true);
2712 
2713  // Bottom line
2714  mp_selectionRectangeLine3->start->setCoords(
2716  mp_selectionRectangeLine3->end->setCoords(
2718  mp_selectionRectangeLine3->setVisible(true);
2719 
2720  // Left line
2721  mp_selectionRectangeLine4->start->setCoords(
2723  mp_selectionRectangeLine4->end->setCoords(
2725  mp_selectionRectangeLine4->setVisible(true);
2726 }

References pappso::BOTTOM_LEFT_POINT, pappso::BOTTOM_RIGHT_POINT, pappso::SelectionPolygon::getPoint(), m_context, pappso::BasePlotContext::m_currentDragPoint, pappso::BasePlotContext::m_selectionPolygon, pappso::BasePlotContext::m_startDragPoint, mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, mp_selectionRectangeLine4, pappso::SelectionPolygon::resetPoints(), pappso::SelectionPolygon::setPoint(), pappso::TOP_LEFT_POINT, and pappso::TOP_RIGHT_POINT.

Referenced by updateSelectionRectangle().

◆ 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

◆ updateSelectionRectangle()

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

Definition at line 2992 of file baseplotwidget.cpp.

2994 {
2995 
2996  // qDebug() << "as_line_segment:" << as_line_segment;
2997  // qDebug() << "for_integration:" << for_integration;
2998 
2999  // We now need to construct the selection rectangle, either for zoom or for
3000  // integration.
3001 
3002  // There are two situations :
3003  //
3004  // 1. if the rectangle should look like a line segment
3005  //
3006  // 2. if the rectangle should actually look like a rectangle. In this case,
3007  // there are two sub-situations:
3008  //
3009  // a. if the S key is down, then the rectangle is
3010  // skewed, that is its vertical sides are not parallel to the y axis.
3011  //
3012  // b. otherwise the rectangle is conventional.
3013 
3014  if(as_line_segment)
3015  {
3016  update1DSelectionRectangle(for_integration);
3017  }
3018  else
3019  {
3020  if(!(m_context.m_keyboardModifiers & Qt::AltModifier))
3021  {
3022  update2DSelectionRectangleSquare(for_integration);
3023  }
3024  else if(m_context.m_keyboardModifiers & Qt::AltModifier)
3025  {
3026  update2DSelectionRectangleSkewed(for_integration);
3027  }
3028  }
3029 
3030  // This code automatically sorts the ranges (range start is always less than
3031  // range end) even if the user actually selects from high to low (right to
3032  // left or bottom to top). This has implications in code that uses the
3033  // m_context data to perform some computations. This is why it is important
3034  // that m_dragDirections be set correctly to establish where the current drag
3035  // point is actually located (at which point).
3036 
3041 
3046 
3047  // At this point, draw the text describing the widths.
3048 
3049  // We want the x-delta on the bottom of the rectangle, inside it
3050  // and the y-delta on the vertical side of the rectangle, inside it.
3051 
3052  // Draw the selection width text
3054 }
virtual void update2DSelectionRectangleSquare(bool for_integration=false)
virtual void update1DSelectionRectangle(bool for_integration=false)
virtual void update2DSelectionRectangleSkewed(bool for_integration=false)

References drawXDeltaFeatures(), pappso::SelectionPolygon::getBottomMostPoint(), pappso::SelectionPolygon::getLeftMostPoint(), pappso::SelectionPolygon::getRightMostPoint(), pappso::SelectionPolygon::getTopMostPoint(), m_context, pappso::BasePlotContext::m_keyboardModifiers, pappso::BasePlotContext::m_selectionPolygon, pappso::BasePlotContext::m_xRegionRangeEnd, pappso::BasePlotContext::m_xRegionRangeStart, pappso::BasePlotContext::m_yRegionRangeEnd, pappso::BasePlotContext::m_yRegionRangeStart, update1DSelectionRectangle(), update2DSelectionRectangleSkewed(), and update2DSelectionRectangleSquare().

Referenced by drawSelectionRectangleAndPrepareZoom().

◆ verticalGetGraphCoordNewPointCountPixels()

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

Definition at line 1797 of file baseplotwidget.cpp.

1798 {
1799  QPointF pixel_coordinates(
1800  xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()),
1801  yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()) + pixel_count);
1802 
1803  // Now convert back to local coordinates.
1804 
1805  QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1806  yAxis->pixelToCoord(pixel_coordinates.y()));
1807 
1808  return graph_coordinates;
1809 }

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

Referenced by verticalMoveMouseCursorCountPixels().

◆ verticalMoveMouseCursorCountPixels()

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

Definition at line 1780 of file baseplotwidget.cpp.

1781 {
1782 
1783  QPointF graph_coord = verticalGetGraphCoordNewPointCountPixels(pixel_count);
1784 
1785  QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()),
1786  yAxis->coordToPixel(graph_coord.y()));
1787 
1788  // Now we need ton convert the new coordinates to the global position system
1789  // and to move the cursor to that new position. That will create an event to
1790  // move the mouse cursor.
1791 
1792  moveMouseCursorPixelCoordToGlobal(pixel_coord.toPoint());
1793 }
virtual QPointF verticalGetGraphCoordNewPointCountPixels(int pixel_count)

References moveMouseCursorPixelCoordToGlobal(), and verticalGetGraphCoordNewPointCountPixels().

Referenced by directionKeyPressEvent().

◆ whatIsVisibleOfTheSelectionRectangle()

PolygonType pappso::BasePlotWidget::whatIsVisibleOfTheSelectionRectangle ( )
virtual

Definition at line 3079 of file baseplotwidget.cpp.

3080 {
3081  // There are four lines that make the selection polygon. We want to know
3082  // which lines are visible.
3083 
3084  int current_selection_polygon = static_cast<int>(PolygonType::NOT_SET);
3085 
3086  if(mp_selectionRectangeLine1->visible())
3087  {
3088  current_selection_polygon |= static_cast<int>(PolygonType::TOP_LINE);
3089  // qDebug() << "current_selection_polygon:" << current_selection_polygon;
3090  }
3091  if(mp_selectionRectangeLine2->visible())
3092  {
3093  current_selection_polygon |= static_cast<int>(PolygonType::RIGHT_LINE);
3094  // qDebug() << "current_selection_polygon:" << current_selection_polygon;
3095  }
3096  if(mp_selectionRectangeLine3->visible())
3097  {
3098  current_selection_polygon |= static_cast<int>(PolygonType::BOTTOM_LINE);
3099  // qDebug() << "current_selection_polygon:" << current_selection_polygon;
3100  }
3101  if(mp_selectionRectangeLine4->visible())
3102  {
3103  current_selection_polygon |= static_cast<int>(PolygonType::LEFT_LINE);
3104  // qDebug() << "current_selection_polygon:" << current_selection_polygon;
3105  }
3106 
3107  // qDebug() << "returning visibility:" << current_selection_polygon;
3108 
3109  return static_cast<PolygonType>(current_selection_polygon);
3110 }

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

◆ m_axisLabelY

QString pappso::BasePlotWidget::m_axisLabelY
protected

Definition at line 254 of file baseplotwidget.h.

◆ m_context

BasePlotContext pappso::BasePlotWidget::m_context
protected

Definition at line 256 of file baseplotwidget.h.

Referenced by pappso::DriftSpecTracePlotWidget::DriftSpecTracePlotWidget(), 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(), directionKeyPressEvent(), dragDirection(), drawSelectionRectangleAndPrepareZoom(), drawXDeltaFeatures(), drawYDeltaFeatures(), 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(), update1DSelectionRectangle(), update2DSelectionRectangleSkewed(), update2DSelectionRectangleSquare(), updateContextXandYAxisRanges(), updateSelectionRectangle(), and verticalGetGraphCoordNewPointCountPixels().

◆ m_desc

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

Description of the plot widget.

Definition at line 248 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 251 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 337 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 335 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 298 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 316 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 324 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 245 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 340 of file baseplotwidget.h.

Referenced by 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 275 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 332 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 330 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 301 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 304 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 271 of file baseplotwidget.h.

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

◆ mp_yDeltaTextItem

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

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