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

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

2115 {
2116  //qDebug();
2117 
2118  // Sanity check
2120  qFatal(
2121  "This function can only be called if the mouse click was on one of the "
2122  "axes");
2123 
2125  {
2126  xAxis->setRange(m_context.m_xRange.lower - m_context.m_xDelta,
2128  }
2129 
2131  {
2132  yAxis->setRange(m_context.m_yRange.lower - m_context.m_yDelta,
2134  }
2135 
2137 
2138  //qDebug() << "The updated context:" << m_context.toString();
2139 
2140  // We cannot store the new ranges in the history, because the pan operation
2141  // involved a huge quantity of micro-movements elicited upon each mouse move
2142  // cursor event so we would have a huge history.
2143  // updateAxesRangeHistory();
2144 
2145  // Now that the context has the right range values, we can emit the
2146  // signal that will be used by this plot widget users, typically to
2147  // abide by the x/y range lock required by the user.
2148 
2150 
2151  replot();
2152 }

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

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

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

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

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

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

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

2440 {
2441 
2442  // We compute signed differentials. If the user does not want the sign,
2443  // fabs(double) is their friend.
2444 
2445  // Compute the xAxis differential:
2446 
2449 
2450  // Same with the Y-axis range:
2451 
2454 
2455  // qDebug() << "xDelta:" << m_context.m_xDelta
2456  //<< "and yDelta:" << m_context.m_yDelta;
2457 
2458  return;
2459 }

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

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

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

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

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

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

3191 {
3192  return m_context;
3193 }

References m_context.

◆ getInnermostRangeX()

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

Definition at line 1936 of file baseplotwidget.cpp.

1937 {
1938 
1939  return getRange(Axis::x, RangeType::innermost, found_range);
1940 }
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 1951 of file baseplotwidget.cpp.

1952 {
1953 
1954  return getRange(Axis::y, RangeType::innermost, found_range);
1955 }

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

◆ getOutermostRangeX()

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

Definition at line 1944 of file baseplotwidget.cpp.

1945 {
1946  return getRange(Axis::x, RangeType::outermost, found_range);
1947 }

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

◆ getOutermostRangeY()

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

Definition at line 1959 of file baseplotwidget.cpp.

1960 {
1961  return getRange(Axis::y, RangeType::outermost, found_range);
1962 }

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

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

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

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

◆ getRangeY()

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

Definition at line 1832 of file baseplotwidget.cpp.

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

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

2210 {
2211  mp_xDeltaTextItem->setVisible(false);
2212  mp_yDeltaTextItem->setVisible(false);
2213 
2214  // mp_zoomRectItem->setVisible(false);
2216 
2217  // Force a replot to make sure the action is immediately visible by the
2218  // user, even without moving the mouse.
2219  replot();
2220 }
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 3065 of file baseplotwidget.cpp.

3066 {
3067  mp_selectionRectangeLine1->setVisible(false);
3068  mp_selectionRectangeLine2->setVisible(false);
3069  mp_selectionRectangeLine3->setVisible(false);
3070  mp_selectionRectangeLine4->setVisible(false);
3071 
3072  if(reset_values)
3073  {
3075  }
3076 }
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 2243 of file baseplotwidget.cpp.

2244 {
2245  m_shouldTracersBeVisible = false;
2246  mp_hPosTracerItem->setVisible(false);
2247  mp_vPosTracerItem->setVisible(false);
2248 
2249  mp_vStartTracerItem->setVisible(false);
2250  mp_vEndTracerItem->setVisible(false);
2251 
2252  // Force a replot to make sure the action is immediately visible by the
2253  // user, even without moving the mouse.
2254  replot();
2255 }
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 1767 of file baseplotwidget.cpp.

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

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

Referenced by horizontalMoveMouseCursorCountPixels().

◆ horizontalMoveMouseCursorCountPixels()

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

Definition at line 1751 of file baseplotwidget.cpp.

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

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

Referenced by mousePressHandler().

◆ isClickOntoYAxis()

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

Definition at line 1672 of file baseplotwidget.cpp.

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

Referenced by mousePressHandler().

◆ isSelectionRectangleVisible()

bool pappso::BasePlotWidget::isSelectionRectangleVisible ( )
virtual

Definition at line 3122 of file baseplotwidget.cpp.

3123 {
3124  // Sanity check
3125  int check = 0;
3126 
3127  check += mp_selectionRectangeLine1->visible();
3128  check += mp_selectionRectangeLine2->visible();
3129  check += mp_selectionRectangeLine3->visible();
3130  check += mp_selectionRectangeLine4->visible();
3131 
3132  if(check > 0)
3133  return true;
3134 
3135  return false;
3136 }

References mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, and mp_selectionRectangeLine4.

◆ isVerticalDisplacementAboveThreshold()

bool pappso::BasePlotWidget::isVerticalDisplacementAboveThreshold ( )
virtual

Definition at line 2463 of file baseplotwidget.cpp.

2464 {
2465  // First get the height of the plot.
2466  double plotHeight = yAxis->range().upper - yAxis->range().lower;
2467 
2468  double heightDiff =
2470 
2471  double heightDiffRatio = (heightDiff / plotHeight) * 100;
2472 
2473  if(heightDiffRatio > 10)
2474  {
2475  // qDebug() << "isVerticalDisplacementAboveThreshold: true";
2476  return true;
2477  }
2478 
2479  // qDebug() << "isVerticalDisplacementAboveThreshold: false";
2480  return false;
2481 }

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() << "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  //qDebug() << "Apparently the selection is a not a rectangle.";
1233 
1234  // Draw the rectangle, true, as line segment and
1235  // false, true for integration
1237 
1238  // Draw the selection width text
1240  }
1241 
1242  // Draw the selection width text
1244 }

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

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

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

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

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

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

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

References moveMouseCursorPixelCoordToGlobal().

◆ moveMouseCursorPixelCoordToGlobal()

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

Definition at line 1743 of file baseplotwidget.cpp.

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

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

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

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

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

◆ replotWithAxisRangeX()

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

Definition at line 2182 of file baseplotwidget.cpp.

2183 {
2184  // qDebug();
2185 
2186  xAxis->setRange(lower, upper);
2187 
2188  replot();
2189 }

◆ replotWithAxisRangeY()

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

Definition at line 2193 of file baseplotwidget.cpp.

2194 {
2195  // qDebug();
2196 
2197  yAxis->setRange(lower, upper);
2198 
2199  replot();
2200 }

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

3141 {
3142  // qDebug() << "Setting focus to the QCustomPlot:" << this;
3143 
3144  QCustomPlot::setFocus();
3145 
3146  // qDebug() << "Emitting setFocusSignal().";
3147 
3148  emit setFocusSignal();
3149 }

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

2226 {
2227  m_shouldTracersBeVisible = true;
2228 
2229  mp_vPosTracerItem->setVisible(true);
2230  mp_hPosTracerItem->setVisible(true);
2231 
2232  mp_vStartTracerItem->setVisible(true);
2233  mp_vEndTracerItem->setVisible(true);
2234 
2235  // Force a replot to make sure the action is immediately visible by the
2236  // user, even without moving the mouse.
2237  replot();
2238 }

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

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

2739 {
2740 
2741  // if(for_integration)
2742  // qDebug() << "for_integration:" << for_integration;
2743 
2744  // We are handling a skewed rectangle, that is a rectangle that is
2745  // tilted either to the left or to the right.
2746 
2747  // qDebug() << "m_context.m_selectRectangleWidth: "
2748  //<< m_context.m_selectRectangleWidth;
2749 
2750  // Top line
2751  // start
2752 
2753  // qDebug() << "m_context.m_startDragPoint: " <<
2754  // m_context.m_startDragPoint.x()
2755  //<< "-" << m_context.m_startDragPoint.y();
2756 
2757  // qDebug() << "m_context.m_currentDragPoint: "
2758  //<< m_context.m_currentDragPoint.x() << "-"
2759  //<< m_context.m_currentDragPoint.y();
2760 
2762 
2764  {
2765  // qDebug() << "Dragging from right to left";
2766 
2768  {
2769  // qDebug() << "Dragging from top to bottom";
2770 
2775 
2776  // m_context.m_selRectTopLeftPoint.setX(
2777  // m_context.m_startDragPoint.x() -
2778  // m_context.m_selectRectangleWidth);
2779  // m_context.m_selRectTopLeftPoint.setY(m_context.m_startDragPoint.y());
2780 
2784 
2785  // m_context.m_selRectTopRightPoint.setX(m_context.m_startDragPoint.x());
2786  // m_context.m_selRectTopRightPoint.setY(m_context.m_startDragPoint.y());
2787 
2792 
2793  // m_context.m_selRectBottomRightPoint.setX(
2794  // m_context.m_currentDragPoint.x() +
2795  // m_context.m_selectRectangleWidth);
2796  // m_context.m_selRectBottomRightPoint.setY(
2797  // m_context.m_currentDragPoint.y());
2798 
2803 
2804  // m_context.m_selRectBottomLeftPoint.setX(
2805  // m_context.m_currentDragPoint.x());
2806  // m_context.m_selRectBottomLeftPoint.setY(
2807  // m_context.m_currentDragPoint.y());
2808  }
2809  else
2810  {
2811  // qDebug() << "Dragging from bottom to top";
2812 
2817 
2818  // m_context.m_selRectTopLeftPoint.setX(
2819  // m_context.m_currentDragPoint.x());
2820  // m_context.m_selRectTopLeftPoint.setY(
2821  // m_context.m_currentDragPoint.y());
2822 
2827 
2828  // m_context.m_selRectTopRightPoint.setX(
2829  // m_context.m_currentDragPoint.x() +
2830  // m_context.m_selectRectangleWidth);
2831  // m_context.m_selRectTopRightPoint.setY(
2832  // m_context.m_currentDragPoint.y());
2833 
2834 
2838 
2839  // m_context.m_selRectBottomRightPoint.setX(
2840  // m_context.m_startDragPoint.x());
2841  // m_context.m_selRectBottomRightPoint.setY(
2842  // m_context.m_startDragPoint.y());
2843 
2848 
2849  // m_context.m_selRectBottomLeftPoint.setX(
2850  // m_context.m_startDragPoint.x() -
2851  // m_context.m_selectRectangleWidth);
2852  // m_context.m_selRectBottomLeftPoint.setY(
2853  // m_context.m_startDragPoint.y());
2854  }
2855  }
2856  // End of
2857  // Dragging from right to left.
2858  else
2859  {
2860  // qDebug() << "Dragging from left to right";
2861 
2863  {
2864  // qDebug() << "Dragging from top to bottom";
2865 
2869 
2870  // m_context.m_selRectTopLeftPoint.setX(m_context.m_startDragPoint.x());
2871  // m_context.m_selRectTopLeftPoint.setY(m_context.m_startDragPoint.y());
2872 
2877 
2878  // m_context.m_selRectTopRightPoint.setX(
2879  // m_context.m_startDragPoint.x() +
2880  // m_context.m_selectRectangleWidth);
2881  // m_context.m_selRectTopRightPoint.setY(m_context.m_startDragPoint.y());
2882 
2887 
2888  // m_context.m_selRectBottomRightPoint.setX(
2889  // m_context.m_currentDragPoint.x());
2890  // m_context.m_selRectBottomRightPoint.setY(
2891  // m_context.m_currentDragPoint.y());
2892 
2897 
2898  // m_context.m_selRectBottomLeftPoint.setX(
2899  // m_context.m_currentDragPoint.x() -
2900  // m_context.m_selectRectangleWidth);
2901  // m_context.m_selRectBottomLeftPoint.setY(
2902  // m_context.m_currentDragPoint.y());
2903  }
2904  else
2905  {
2906  // qDebug() << "Dragging from bottom to top";
2907 
2912 
2913  // m_context.m_selRectTopLeftPoint.setX(
2914  // m_context.m_currentDragPoint.x() -
2915  // m_context.m_selectRectangleWidth);
2916  // m_context.m_selRectTopLeftPoint.setY(
2917  // m_context.m_currentDragPoint.y());
2918 
2923 
2924  // m_context.m_selRectTopRightPoint.setX(
2925  // m_context.m_currentDragPoint.x());
2926  // m_context.m_selRectTopRightPoint.setY(
2927  // m_context.m_currentDragPoint.y());
2928 
2933 
2934  // m_context.m_selRectBottomRightPoint.setX(
2935  // m_context.m_startDragPoint.x() +
2936  // m_context.m_selectRectangleWidth);
2937  // m_context.m_selRectBottomRightPoint.setY(
2938  // m_context.m_startDragPoint.y());
2939 
2943 
2944  // m_context.m_selRectBottomLeftPoint.setX(
2945  // m_context.m_startDragPoint.x());
2946  // m_context.m_selRectBottomLeftPoint.setY(
2947  // m_context.m_startDragPoint.y());
2948  }
2949  }
2950  // End of Dragging from left to right.
2951 
2952  // qDebug() << "Now draw the lines with points:"
2953  //<< m_context.m_selectionPolygon.toString();
2954 
2955  // Top line
2956  mp_selectionRectangeLine1->start->setCoords(
2958  mp_selectionRectangeLine1->end->setCoords(
2960 
2961  // Only if we are drawing a selection rectangle for integration, do we set
2962  // arrow heads to the line.
2963  if(for_integration)
2964  {
2965  mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2966  mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2967  }
2968  else
2969  {
2970  mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2971  mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2972  }
2973 
2974  mp_selectionRectangeLine1->setVisible(true);
2975 
2976  // Right line
2977  mp_selectionRectangeLine2->start->setCoords(
2979  mp_selectionRectangeLine2->end->setCoords(
2981  mp_selectionRectangeLine2->setVisible(true);
2982 
2983  // Bottom line
2984  mp_selectionRectangeLine3->start->setCoords(
2986  mp_selectionRectangeLine3->end->setCoords(
2988  mp_selectionRectangeLine3->setVisible(true);
2989 
2990  // Left line
2991  mp_selectionRectangeLine4->end->setCoords(
2993  mp_selectionRectangeLine4->start->setCoords(
2995  mp_selectionRectangeLine4->setVisible(true);
2996 }
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 2553 of file baseplotwidget.cpp.

2554 {
2555 
2556  // if(for_integration)
2557  // qDebug() << "for_integration:" << for_integration;
2558 
2559  // We are handling a conventional rectangle. Just create four points
2560  // from top left to bottom right. But we want the top left point to be
2561  // effectively the top left point and the bottom point to be the bottom point.
2562  // So we need to try all four direction combinations, left to right or
2563  // converse versus top to bottom or converse.
2564 
2566 
2568  {
2569  // qDebug() << "Dragging from right to left";
2570 
2572  {
2573  // qDebug() << "Dragging from top to bottom";
2574 
2575  // TOP_LEFT_POINT
2580 
2581  // TOP_RIGHT_POINT
2585 
2586  // BOTTOM_RIGHT_POINT
2591 
2592  // BOTTOM_LEFT_POINT
2597  }
2598  // End of
2599  // if(m_context.m_currentDragPoint.y() < m_context.m_startDragPoint.y())
2600  else
2601  {
2602  // qDebug() << "Dragging from bottom to top";
2603 
2604  // TOP_LEFT_POINT
2609 
2610  // TOP_RIGHT_POINT
2615 
2616  // BOTTOM_RIGHT_POINT
2620 
2621  // BOTTOM_LEFT_POINT
2626  }
2627  }
2628  // End of
2629  // if(m_context.m_currentDragPoint.x() < m_context.m_startDragPoint.x())
2630  else
2631  {
2632  // qDebug() << "Dragging from left to right";
2633 
2635  {
2636  // qDebug() << "Dragging from top to bottom";
2637 
2638  // TOP_LEFT_POINT
2642 
2643  // TOP_RIGHT_POINT
2648 
2649  // BOTTOM_RIGHT_POINT
2654 
2655  // BOTTOM_LEFT_POINT
2660  }
2661  else
2662  {
2663  // qDebug() << "Dragging from bottom to top";
2664 
2665  // TOP_LEFT_POINT
2670 
2671  // TOP_RIGHT_POINT
2676 
2677  // BOTTOM_RIGHT_POINT
2682 
2683  // BOTTOM_LEFT_POINT
2687  }
2688  }
2689 
2690  // qDebug() << "Now draw the lines with points:"
2691  //<< m_context.m_selectionPolygon.toString();
2692 
2693  // Top line
2694  mp_selectionRectangeLine1->start->setCoords(
2696  mp_selectionRectangeLine1->end->setCoords(
2698 
2699  // Only if we are drawing a selection rectangle for integration, do we
2700  // set arrow heads to the line.
2701  if(for_integration)
2702  {
2703  mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2704  mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2705  }
2706  else
2707  {
2708  mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2709  mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2710  }
2711 
2712  mp_selectionRectangeLine1->setVisible(true);
2713 
2714  // Right line
2715  mp_selectionRectangeLine2->start->setCoords(
2717  mp_selectionRectangeLine2->end->setCoords(
2719  mp_selectionRectangeLine2->setVisible(true);
2720 
2721  // Bottom line
2722  mp_selectionRectangeLine3->start->setCoords(
2724  mp_selectionRectangeLine3->end->setCoords(
2726  mp_selectionRectangeLine3->setVisible(true);
2727 
2728  // Left line
2729  mp_selectionRectangeLine4->start->setCoords(
2731  mp_selectionRectangeLine4->end->setCoords(
2733  mp_selectionRectangeLine4->setVisible(true);
2734 }

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

Definition at line 3180 of file baseplotwidget.cpp.

3181 {
3182  m_context.m_xRange = QCPRange(xAxis->range().lower, xAxis->range().upper);
3183  m_context.m_yRange = QCPRange(yAxis->range().lower, yAxis->range().upper);
3184 
3185  //qDebug() << "The new updated context: " << m_context.toString();
3186 }

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

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

◆ updateSelectionRectangle()

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

Definition at line 3000 of file baseplotwidget.cpp.

3002 {
3003 
3004  // qDebug() << "as_line_segment:" << as_line_segment;
3005  // qDebug() << "for_integration:" << for_integration;
3006 
3007  // We now need to construct the selection rectangle, either for zoom or for
3008  // integration.
3009 
3010  // There are two situations :
3011  //
3012  // 1. if the rectangle should look like a line segment
3013  //
3014  // 2. if the rectangle should actually look like a rectangle. In this case,
3015  // there are two sub-situations:
3016  //
3017  // a. if the S key is down, then the rectangle is
3018  // skewed, that is its vertical sides are not parallel to the y axis.
3019  //
3020  // b. otherwise the rectangle is conventional.
3021 
3022  if(as_line_segment)
3023  {
3024  update1DSelectionRectangle(for_integration);
3025  }
3026  else
3027  {
3028  if(!(m_context.m_keyboardModifiers & Qt::AltModifier))
3029  {
3030  update2DSelectionRectangleSquare(for_integration);
3031  }
3032  else if(m_context.m_keyboardModifiers & Qt::AltModifier)
3033  {
3034  update2DSelectionRectangleSkewed(for_integration);
3035  }
3036  }
3037 
3038  // This code automatically sorts the ranges (range start is always less than
3039  // range end) even if the user actually selects from high to low (right to
3040  // left or bottom to top). This has implications in code that uses the
3041  // m_context data to perform some computations. This is why it is important
3042  // that m_dragDirections be set correctly to establish where the current drag
3043  // point is actually located (at which point).
3044 
3049 
3054 
3055  // At this point, draw the text describing the widths.
3056 
3057  // We want the x-delta on the bottom of the rectangle, inside it
3058  // and the y-delta on the vertical side of the rectangle, inside it.
3059 
3060  // Draw the selection width text
3062 }
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 1800 of file baseplotwidget.cpp.

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

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

Referenced by verticalMoveMouseCursorCountPixels().

◆ verticalMoveMouseCursorCountPixels()

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

Definition at line 1783 of file baseplotwidget.cpp.

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

References moveMouseCursorPixelCoordToGlobal(), and verticalGetGraphCoordNewPointCountPixels().

Referenced by directionKeyPressEvent().

◆ whatIsVisibleOfTheSelectionRectangle()

PolygonType pappso::BasePlotWidget::whatIsVisibleOfTheSelectionRectangle ( )
virtual

Definition at line 3087 of file baseplotwidget.cpp.

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

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: