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

1659 {
1660  // qDebug();
1661 
1662  m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1663 
1664  if(m_context.m_keyboardModifiers & Qt::ControlModifier)
1665  {
1666  // qDebug();
1667 
1668  // If the Ctrl modifiers is active, then both axes are to be reset. Also
1669  // the histories are reset also.
1670 
1671  rescaleAxes();
1673  }
1674  else
1675  {
1676  // qDebug();
1677 
1678  // Only the axis passed as parameter is to be rescaled.
1679  // Reset the range of that axis to the max view possible.
1680 
1681  axis->rescale();
1682 
1684 
1685  event->accept();
1686  }
1687 
1688  // The double-click event does not cancel the mouse press event. That is, if
1689  // left-double-clicking, at the end of the operation the button still
1690  // "pressed". We need to remove manually the button from the pressed buttons
1691  // context member.
1692 
1693  m_context.m_pressedMouseButtons ^= event->button();
1694 
1696 
1698 
1699  replot();
1700 }
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 2173 of file baseplotwidget.cpp.

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

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

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

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

2031 {
2032  // Get the current x lower/upper range, that is, leftmost/rightmost x
2033  // coordinate.
2034  double xLower = xAxis->range().lower;
2035  double xUpper = xAxis->range().upper;
2036 
2037  // Get the current y lower/upper range, that is, bottommost/topmost y
2038  // coordinate.
2039  double yLower = yAxis->range().lower;
2040  double yUpper = yAxis->range().upper;
2041 
2042  // This function is called only when the user has clicked on the x/y axis or
2043  // when the user has dragged the left mouse button with the Ctrl key
2044  // modifier. The m_context.m_wasClickOnXAxis is then simulated in the mouse
2045  // move handler. So we need to test which axis was clicked-on.
2046 
2048  {
2049 
2050  // We are changing the range of the X axis.
2051 
2052  // What is the x delta ?
2053  double xDelta =
2055 
2056  // If xDelta is < 0, the we were dragging from right to left, we are
2057  // compressing the view on the x axis, by adding new data to the right
2058  // hand size of the graph. So we add xDelta to the upper bound of the
2059  // range. Otherwise we are uncompressing the view on the x axis and
2060  // remove the xDelta from the upper bound of the range. This is why we
2061  // have the
2062  // '-'
2063  // and not '+' below;
2064 
2065  // qDebug() << "Setting xaxis:" << xLower << "--" << xUpper - xDelta;
2066 
2067  xAxis->setRange(xLower, xUpper - xDelta);
2068  }
2069  // End of
2070  // if(m_context.m_wasClickOnXAxis)
2071  else // that is, if(m_context.m_wasClickOnYAxis)
2072  {
2073  // We are changing the range of the Y axis.
2074 
2075  // What is the y delta ?
2076  double yDelta =
2078 
2079  // See above for an explanation of the computation.
2080 
2081  yAxis->setRange(yLower, yUpper - yDelta);
2082 
2083  // Old version
2084  // if(yDelta < 0)
2085  //{
2086  //// The dragging operation was from top to bottom, we are enlarging
2087  //// the range (thus, we are unzooming the view, since the widget
2088  //// always has the same size).
2089 
2090  // yAxis->setRange(yLower, yUpper + fabs(yDelta));
2091  //}
2092  // else
2093  //{
2094  //// The dragging operation was from bottom to top, we are reducing
2095  //// the range (thus, we are zooming the view, since the widget
2096  //// always has the same size).
2097 
2098  // yAxis->setRange(yLower, yUpper - fabs(yDelta));
2099  //}
2100  }
2101  // End of
2102  // else // that is, if(m_context.m_wasClickOnYAxis)
2103 
2104  // Update the context with the current axes ranges
2105 
2107 
2109 
2110  replot();
2111 }

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

2150 {
2151 
2152  // Use the m_context.m_xRegionRangeStart/End values, but we need to sort the
2153  // values before using them, because now we want to really have the lower x
2154  // value. Simply craft a QCPRange that will swap the values if lower is not
2155  // < than upper QCustomPlot calls this normalization).
2156 
2157  xAxis->setRange(
2159 
2160  yAxis->setRange(
2162 
2164 
2167 
2168  replot();
2169 }

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

2507 {
2508 
2509  // We compute signed differentials. If the user does not want the sign,
2510  // fabs(double) is their friend.
2511 
2512  // Compute the xAxis differential:
2513 
2516 
2517  // Same with the Y-axis range:
2518 
2521 
2522  // qDebug() << "xDelta:" << m_context.m_xDelta
2523  //<< "and yDelta:" << m_context.m_yDelta;
2524 
2525  return;
2526 }

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

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

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

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

2352 {
2353  // The user is dragging the mouse over the graph and we want them to know what
2354  // is the x delta value, that is the span between the point at the start of
2355  // the drag and the current drag position.
2356 
2357  // FIXME: is this still true?
2358  //
2359  // We do not want to show the position markers because the only horiontal
2360  // line to be visible must be contained between the start and end vertiacal
2361  // tracer items.
2362  if(mp_hPosTracerItem != nullptr)
2363  mp_hPosTracerItem->setVisible(false);
2364  if(mp_vPosTracerItem != nullptr)
2365  mp_vPosTracerItem->setVisible(false);
2366 
2367  // We want to draw the text in the middle position of the leftmost-rightmost
2368  // point, even with skewed rectangle selection.
2369 
2370  QPointF leftmost_point = m_context.m_selectionPolygon.getLeftMostPoint();
2371 
2372  // qDebug() << "leftmost_point:" << leftmost_point;
2373 
2374  QPointF rightmost_point = m_context.m_selectionPolygon.getRightMostPoint();
2375 
2376  // qDebug() << "rightmost_point:" << rightmost_point;
2377 
2378  double x_axis_center_position =
2379  leftmost_point.x() + (rightmost_point.x() - leftmost_point.x()) / 2;
2380 
2381  // qDebug() << "x_axis_center_position:" << x_axis_center_position;
2382 
2383  // We want the text to print inside the rectangle, always at the current drag
2384  // point so the eye can follow the delta value while looking where to drag the
2385  // mouse. To position the text inside the rectangle, we need to know what is
2386  // the drag direction.
2387 
2388  // Set aside a point instance to store the pixel coordinates of the text.
2389  QPointF pixel_coordinates;
2390 
2391  // What is the distance between the rectangle line at current drag point and
2392  // the text itself.
2393  int pixels_away_from_line = 15;
2394 
2395  // ATTENTION: the pixel coordinates for the vertical direction go in reverse
2396  // order with respect to the y axis values !!! That is pixel(0,0) is top left
2397  // of the graph.
2398  if(static_cast<int>(m_context.m_dragDirections) &
2399  static_cast<int>(DragDirections::TOP_TO_BOTTOM))
2400  {
2401  // We need to print inside the rectangle, that is pixels_above_line pixels
2402  // to the bottom, so with pixel y value decremented of that
2403  // pixels_above_line value (one would have expected to increment that
2404  // value, along the y axis, but the coordinates in pixel go in reverse
2405  // order).
2406 
2407  pixels_away_from_line *= -1;
2408  }
2409 
2410  double y_axis_pixel_coordinate =
2411  yAxis->coordToPixel(m_context.m_currentDragPoint.y());
2412 
2413  double y_axis_modified_pixel_coordinate =
2414  y_axis_pixel_coordinate + pixels_away_from_line;
2415 
2416  pixel_coordinates.setX(x_axis_center_position);
2417  pixel_coordinates.setY(y_axis_modified_pixel_coordinate);
2418 
2419  // Now convert back to graph coordinates.
2420 
2421  QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
2422  yAxis->pixelToCoord(pixel_coordinates.y()));
2423  if(mp_xDeltaTextItem != nullptr)
2424  {
2425  mp_xDeltaTextItem->position->setCoords(x_axis_center_position,
2426  graph_coordinates.y());
2427  mp_xDeltaTextItem->setText(
2428  QString("%1").arg(m_context.m_xDelta, 0, 'f', 3));
2429  mp_xDeltaTextItem->setFont(QFont(font().family(), 9));
2430  mp_xDeltaTextItem->setVisible(true);
2431  }
2432 
2433  // Set the boolean to true so that derived widgets know that something is
2434  // being measured, and they can act accordingly, for example by computing
2435  // deconvolutions in a mass spectrum.
2437 
2438  replot();
2439 
2440  // Let the caller know that we were measuring something.
2441  emit xAxisMeasurementSignal(m_context, true);
2442 
2443  return;
2444 }
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 2448 of file baseplotwidget.cpp.

2449 {
2451  return;
2452 
2453  // The user is dragging the mouse over the graph and we want them to know what
2454  // is the y delta value, that is the span between the point at the top of
2455  // the selection polygon and the point at its bottom.
2456 
2457  // FIXME: is this still true?
2458  //
2459  // We do not want to show the position markers because the only horiontal
2460  // line to be visible must be contained between the start and end vertiacal
2461  // tracer items.
2462  mp_hPosTracerItem->setVisible(false);
2463  mp_vPosTracerItem->setVisible(false);
2464 
2465  // We want to draw the text in the middle position of the leftmost-rightmost
2466  // point, even with skewed rectangle selection.
2467 
2468  QPointF leftmost_point = m_context.m_selectionPolygon.getLeftMostPoint();
2469  QPointF topmost_point = m_context.m_selectionPolygon.getTopMostPoint();
2470 
2471  // qDebug() << "leftmost_point:" << leftmost_point;
2472 
2473  QPointF rightmost_point = m_context.m_selectionPolygon.getRightMostPoint();
2474  QPointF bottommost_point = m_context.m_selectionPolygon.getBottomMostPoint();
2475 
2476  // qDebug() << "rightmost_point:" << rightmost_point;
2477 
2478  double x_axis_center_position =
2479  leftmost_point.x() + (rightmost_point.x() - leftmost_point.x()) / 2;
2480 
2481  double y_axis_center_position =
2482  bottommost_point.y() + (topmost_point.y() - bottommost_point.y()) / 2;
2483 
2484  // qDebug() << "x_axis_center_position:" << x_axis_center_position;
2485 
2486  mp_yDeltaTextItem->position->setCoords(x_axis_center_position,
2487  y_axis_center_position);
2488  mp_yDeltaTextItem->setText(QString("%1").arg(m_context.m_yDelta, 0, 'f', 3));
2489  mp_yDeltaTextItem->setFont(QFont(font().family(), 9));
2490  mp_yDeltaTextItem->setVisible(true);
2491  mp_yDeltaTextItem->setRotation(90);
2492 
2493  // Set the boolean to true so that derived widgets know that something is
2494  // being measured, and they can act accordingly, for example by computing
2495  // deconvolutions in a mass spectrum.
2497 
2498  replot();
2499 
2500  // Let the caller know that we were measuring something.
2501  emit xAxisMeasurementSignal(m_context, true);
2502 }
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 3257 of file baseplotwidget.cpp.

3258 {
3259  return m_context;
3260 }

References m_context.

◆ getInnermostRangeX()

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

Definition at line 1995 of file baseplotwidget.cpp.

1996 {
1997 
1998  return getRange(Axis::x, RangeType::innermost, found_range);
1999 }
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 2010 of file baseplotwidget.cpp.

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

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

◆ getOutermostRangeX()

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

Definition at line 2003 of file baseplotwidget.cpp.

2004 {
2005  return getRange(Axis::x, RangeType::outermost, found_range);
2006 }

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

◆ getOutermostRangeY()

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

Definition at line 2018 of file baseplotwidget.cpp.

2019 {
2020  return getRange(Axis::y, RangeType::outermost, found_range);
2021 }

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

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

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

1880 {
1881  QCPGraph *graph_p = graph(index);
1882 
1883  if(graph_p == nullptr)
1884  qFatal("Programming error.");
1885 
1886  return graph_p->getKeyRange(found_range);
1887 }

◆ getRangeY()

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

Definition at line 1891 of file baseplotwidget.cpp.

1892 {
1893  QCPGraph *graph_p = graph(index);
1894 
1895  if(graph_p == nullptr)
1896  qFatal("Programming error.");
1897 
1898  return graph_p->getValueRange(found_range);
1899 }

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

2269 {
2270  mp_xDeltaTextItem->setVisible(false);
2271  mp_yDeltaTextItem->setVisible(false);
2272 
2273  // mp_zoomRectItem->setVisible(false);
2275 
2276  // Force a replot to make sure the action is immediately visible by the
2277  // user, even without moving the mouse.
2278  replot();
2279 }
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 3132 of file baseplotwidget.cpp.

3133 {
3134  mp_selectionRectangeLine1->setVisible(false);
3135  mp_selectionRectangeLine2->setVisible(false);
3136  mp_selectionRectangeLine3->setVisible(false);
3137  mp_selectionRectangeLine4->setVisible(false);
3138 
3139  if(reset_values)
3140  {
3142  }
3143 }
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 2302 of file baseplotwidget.cpp.

2303 {
2304  m_shouldTracersBeVisible = false;
2305  mp_hPosTracerItem->setVisible(false);
2306  mp_vPosTracerItem->setVisible(false);
2307 
2308  mp_vStartTracerItem->setVisible(false);
2309  mp_vEndTracerItem->setVisible(false);
2310 
2311  // Force a replot to make sure the action is immediately visible by the
2312  // user, even without moving the mouse.
2313  replot();
2314 }
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 1826 of file baseplotwidget.cpp.

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

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

Referenced by horizontalMoveMouseCursorCountPixels().

◆ horizontalMoveMouseCursorCountPixels()

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

Definition at line 1810 of file baseplotwidget.cpp.

1811 {
1812  QPointF graph_coord = horizontalGetGraphCoordNewPointCountPixels(pixel_count);
1813 
1814  QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()),
1815  yAxis->coordToPixel(graph_coord.y()));
1816 
1817  // Now we need ton convert the new coordinates to the global position system
1818  // and to move the cursor to that new position. That will create an event to
1819  // move the mouse cursor.
1820 
1821  moveMouseCursorPixelCoordToGlobal(pixel_coord.toPoint());
1822 }
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 1704 of file baseplotwidget.cpp.

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

Referenced by mousePressHandler().

◆ isClickOntoYAxis()

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

Definition at line 1731 of file baseplotwidget.cpp.

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

Referenced by mousePressHandler().

◆ isSelectionRectangleVisible()

bool pappso::BasePlotWidget::isSelectionRectangleVisible ( )
virtual

Definition at line 3189 of file baseplotwidget.cpp.

3190 {
3191  // Sanity check
3192  int check = 0;
3193 
3194  check += mp_selectionRectangeLine1->visible();
3195  check += mp_selectionRectangeLine2->visible();
3196  check += mp_selectionRectangeLine3->visible();
3197  check += mp_selectionRectangeLine4->visible();
3198 
3199  if(check > 0)
3200  return true;
3201 
3202  return false;
3203 }

References mp_selectionRectangeLine1, mp_selectionRectangeLine2, mp_selectionRectangeLine3, and mp_selectionRectangeLine4.

◆ isVerticalDisplacementAboveThreshold()

bool pappso::BasePlotWidget::isVerticalDisplacementAboveThreshold ( )
virtual

Definition at line 2530 of file baseplotwidget.cpp.

2531 {
2532  // First get the height of the plot.
2533  double plotHeight = yAxis->range().upper - yAxis->range().lower;
2534 
2535  double heightDiff =
2537 
2538  double heightDiffRatio = (heightDiff / plotHeight) * 100;
2539 
2540  if(heightDiffRatio > 10)
2541  {
2542  // qDebug() << "isVerticalDisplacementAboveThreshold: true";
2543  return true;
2544  }
2545 
2546  // qDebug() << "isVerticalDisplacementAboveThreshold: false";
2547  return false;
2548 }

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  qDebug() << (graph() != nullptr);
923  // if(graph(0) != nullptr)
924  // { // check if the widget contains some graphs
925 
926  // The event->button() must be by Qt instructions considered to be 0.
927 
928  // Whatever happens, we want to store the plot coordinates of the current
929  // mouse cursor position (will be useful later for countless needs).
930 
931  QPointF mousePoint = event->localPos();
932  qDebug();
933  qDebug() << "local mousePoint position in pixels:" << mousePoint;
934 
935  m_context.m_lastCursorHoveredPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
936  qDebug();
937  m_context.m_lastCursorHoveredPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
938  qDebug();
939 
940  // qDebug() << "lastCursorHoveredPoint coord:"
941  //<< m_context.lastCursorHoveredPoint;
942 
943  // Now, depending on the button(s) (if any) that are pressed or not, we
944  // have a different processing.
945 
946  qDebug();
947  if(m_context.m_pressedMouseButtons & Qt::LeftButton ||
948  m_context.m_pressedMouseButtons & Qt::RightButton)
950  else
952  // }
953  qDebug();
954  event->accept();
955 }
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 1023 of file baseplotwidget.cpp.

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

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

960 {
961 
962  qDebug();
964 
965  qDebug();
966  // We are not dragging the mouse (no button pressed), simply let this
967  // widget's consumer know the position of the cursor and update the markers.
968  // The consumer of this widget will update mouse cursor position at
969  // m_context.m_lastCursorHoveredPoint if so needed.
970 
972 
973  qDebug();
974 
975  // We are not dragging, so we do not show the region end tracer we only
976  // show the anchoring start trace that might be of use if the user starts
977  // using the arrow keys to move the cursor.
978  if(mp_vEndTracerItem != nullptr)
979  mp_vEndTracerItem->setVisible(false);
980 
981  qDebug();
982  // Only bother with the tracers if the user wants them to be visible.
983  // Their crossing point must be exactly at the last cursor-hovered point.
984 
986  {
987  // We are not dragging, so only show the position markers (v and h);
988 
989  qDebug();
990  if(mp_hPosTracerItem != nullptr)
991  {
992  // Horizontal position tracer.
993  mp_hPosTracerItem->setVisible(true);
994  mp_hPosTracerItem->start->setCoords(
995  xAxis->range().lower, m_context.m_lastCursorHoveredPoint.y());
996  mp_hPosTracerItem->end->setCoords(
997  xAxis->range().upper, m_context.m_lastCursorHoveredPoint.y());
998  }
999 
1000  qDebug();
1001  // Vertical position tracer.
1002  if(mp_vPosTracerItem != nullptr)
1003  {
1004  mp_vPosTracerItem->setVisible(true);
1005 
1006  mp_vPosTracerItem->setVisible(true);
1007  mp_vPosTracerItem->start->setCoords(
1008  m_context.m_lastCursorHoveredPoint.x(), yAxis->range().upper);
1009  mp_vPosTracerItem->end->setCoords(
1010  m_context.m_lastCursorHoveredPoint.x(), yAxis->range().lower);
1011  }
1012 
1013  qDebug();
1014  replot();
1015  }
1016 
1017 
1018  return;
1019 }
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 1250 of file baseplotwidget.cpp.

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

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

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

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

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

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

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

1635 {
1636  // We should record the new range values each time the wheel is used to
1637  // zoom/unzoom.
1638 
1639  m_context.m_xRange = QCPRange(xAxis->range());
1640  m_context.m_yRange = QCPRange(yAxis->range());
1641 
1642  // qDebug() << "New x range: " << m_context.m_xRange;
1643  // qDebug() << "New y range: " << m_context.m_yRange;
1644 
1646 
1649 
1650  event->accept();
1651 }
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 1790 of file baseplotwidget.cpp.

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

References moveMouseCursorPixelCoordToGlobal().

◆ moveMouseCursorPixelCoordToGlobal()

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

Definition at line 1802 of file baseplotwidget.cpp.

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

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

3222 {
3223  if(focusedPlotWidget == nullptr)
3224  throw ExceptionNotPossible(
3225  "baseplotwidget.cpp @ redrawPlotBackground(QWidget *focusedPlotWidget "
3226  "-- "
3227  "ERROR focusedPlotWidget cannot be nullptr.");
3228 
3229  if(dynamic_cast<QWidget *>(this) != focusedPlotWidget)
3230  {
3231  // The focused widget is not *this widget. We should make sure that
3232  // we were not the one that had the focus, because in this case we
3233  // need to redraw an unfocused background.
3234 
3235  axisRect()->setBackground(m_unfocusedBrush);
3236  }
3237  else
3238  {
3239  axisRect()->setBackground(m_focusedBrush);
3240  }
3241 
3242  replot();
3243 }
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 2215 of file baseplotwidget.cpp.

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

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

◆ replotWithAxisRangeX()

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

Definition at line 2241 of file baseplotwidget.cpp.

2242 {
2243  // qDebug();
2244 
2245  xAxis->setRange(lower, upper);
2246 
2247  replot();
2248 }

◆ replotWithAxisRangeY()

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

Definition at line 2252 of file baseplotwidget.cpp.

2253 {
2254  // qDebug();
2255 
2256  yAxis->setRange(lower, upper);
2257 
2258  replot();
2259 }

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

3208 {
3209  // qDebug() << "Setting focus to the QCustomPlot:" << this;
3210 
3211  QCustomPlot::setFocus();
3212 
3213  // qDebug() << "Emitting setFocusSignal().";
3214 
3215  emit setFocusSignal();
3216 }

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

2285 {
2286  m_shouldTracersBeVisible = true;
2287 
2288  mp_vPosTracerItem->setVisible(true);
2289  mp_hPosTracerItem->setVisible(true);
2290 
2291  mp_vStartTracerItem->setVisible(true);
2292  mp_vEndTracerItem->setVisible(true);
2293 
2294  // Force a replot to make sure the action is immediately visible by the
2295  // user, even without moving the mouse.
2296  replot();
2297 }

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

2553 {
2554 
2555  // if(for_integration)
2556  // qDebug() << "for_integration:" << for_integration;
2557 
2558  // When we make a linear selection, the selection polygon is a polygon that
2559  // has the following characteristics:
2560  //
2561  // the x range is the linear selection span
2562  //
2563  // the y range is the widest std::min -> std::max possible.
2564 
2565  // This is how the selection polygon logic knows if its is mono-
2566  // two-dimensional.
2567 
2568  // We want the top left point to effectively be the top left point, so check
2569  // the direction of the mouse cursor drag.
2570 
2571  double x_range_start =
2573  double x_range_end =
2575 
2576  double y_position = m_context.m_startDragPoint.y();
2577 
2578  m_context.m_selectionPolygon.set1D(x_range_start, x_range_end);
2579 
2580  // Top line
2581  mp_selectionRectangeLine1->start->setCoords(
2582  QPointF(x_range_start, y_position));
2583  mp_selectionRectangeLine1->end->setCoords(QPointF(x_range_end, y_position));
2584 
2585  // Only if we are drawing a selection rectangle for integration, do we set
2586  // arrow heads to the line.
2587  if(for_integration)
2588  {
2589  mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2590  mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2591  }
2592  else
2593  {
2594  mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2595  mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2596  }
2597  mp_selectionRectangeLine1->setVisible(true);
2598 
2599  // Right line: does not exist, start and end are the same end point of the top
2600  // line.
2601  mp_selectionRectangeLine2->start->setCoords(QPointF(x_range_end, y_position));
2602  mp_selectionRectangeLine2->end->setCoords(QPointF(x_range_end, y_position));
2603  mp_selectionRectangeLine2->setVisible(false);
2604 
2605  // Bottom line: identical to the top line, but invisible
2606  mp_selectionRectangeLine3->start->setCoords(
2607  QPointF(x_range_start, y_position));
2608  mp_selectionRectangeLine3->end->setCoords(QPointF(x_range_end, y_position));
2609  mp_selectionRectangeLine3->setVisible(false);
2610 
2611  // Left line: does not exist: start and end are the same end point of the top
2612  // line.
2613  mp_selectionRectangeLine4->start->setCoords(QPointF(x_range_end, y_position));
2614  mp_selectionRectangeLine4->end->setCoords(QPointF(x_range_end, y_position));
2615  mp_selectionRectangeLine4->setVisible(false);
2616 }
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 2805 of file baseplotwidget.cpp.

2806 {
2807 
2808  // if(for_integration)
2809  // qDebug() << "for_integration:" << for_integration;
2810 
2811  // We are handling a skewed rectangle, that is a rectangle that is
2812  // tilted either to the left or to the right.
2813 
2814  // qDebug() << "m_context.m_selectRectangleWidth: "
2815  //<< m_context.m_selectRectangleWidth;
2816 
2817  // Top line
2818  // start
2819 
2820  // qDebug() << "m_context.m_startDragPoint: " <<
2821  // m_context.m_startDragPoint.x()
2822  //<< "-" << m_context.m_startDragPoint.y();
2823 
2824  // qDebug() << "m_context.m_currentDragPoint: "
2825  //<< m_context.m_currentDragPoint.x() << "-"
2826  //<< m_context.m_currentDragPoint.y();
2827 
2829 
2831  {
2832  // qDebug() << "Dragging from right to left";
2833 
2835  {
2836  // qDebug() << "Dragging from top to bottom";
2837 
2842 
2843  // m_context.m_selRectTopLeftPoint.setX(
2844  // m_context.m_startDragPoint.x() -
2845  // m_context.m_selectRectangleWidth);
2846  // m_context.m_selRectTopLeftPoint.setY(m_context.m_startDragPoint.y());
2847 
2851 
2852  // m_context.m_selRectTopRightPoint.setX(m_context.m_startDragPoint.x());
2853  // m_context.m_selRectTopRightPoint.setY(m_context.m_startDragPoint.y());
2854 
2859 
2860  // m_context.m_selRectBottomRightPoint.setX(
2861  // m_context.m_currentDragPoint.x() +
2862  // m_context.m_selectRectangleWidth);
2863  // m_context.m_selRectBottomRightPoint.setY(
2864  // m_context.m_currentDragPoint.y());
2865 
2870 
2871  // m_context.m_selRectBottomLeftPoint.setX(
2872  // m_context.m_currentDragPoint.x());
2873  // m_context.m_selRectBottomLeftPoint.setY(
2874  // m_context.m_currentDragPoint.y());
2875  }
2876  else
2877  {
2878  // qDebug() << "Dragging from bottom to top";
2879 
2884 
2885  // m_context.m_selRectTopLeftPoint.setX(
2886  // m_context.m_currentDragPoint.x());
2887  // m_context.m_selRectTopLeftPoint.setY(
2888  // m_context.m_currentDragPoint.y());
2889 
2894 
2895  // m_context.m_selRectTopRightPoint.setX(
2896  // m_context.m_currentDragPoint.x() +
2897  // m_context.m_selectRectangleWidth);
2898  // m_context.m_selRectTopRightPoint.setY(
2899  // m_context.m_currentDragPoint.y());
2900 
2901 
2905 
2906  // m_context.m_selRectBottomRightPoint.setX(
2907  // m_context.m_startDragPoint.x());
2908  // m_context.m_selRectBottomRightPoint.setY(
2909  // m_context.m_startDragPoint.y());
2910 
2915 
2916  // m_context.m_selRectBottomLeftPoint.setX(
2917  // m_context.m_startDragPoint.x() -
2918  // m_context.m_selectRectangleWidth);
2919  // m_context.m_selRectBottomLeftPoint.setY(
2920  // m_context.m_startDragPoint.y());
2921  }
2922  }
2923  // End of
2924  // Dragging from right to left.
2925  else
2926  {
2927  // qDebug() << "Dragging from left to right";
2928 
2930  {
2931  // qDebug() << "Dragging from top to bottom";
2932 
2936 
2937  // m_context.m_selRectTopLeftPoint.setX(m_context.m_startDragPoint.x());
2938  // m_context.m_selRectTopLeftPoint.setY(m_context.m_startDragPoint.y());
2939 
2944 
2945  // m_context.m_selRectTopRightPoint.setX(
2946  // m_context.m_startDragPoint.x() +
2947  // m_context.m_selectRectangleWidth);
2948  // m_context.m_selRectTopRightPoint.setY(m_context.m_startDragPoint.y());
2949 
2954 
2955  // m_context.m_selRectBottomRightPoint.setX(
2956  // m_context.m_currentDragPoint.x());
2957  // m_context.m_selRectBottomRightPoint.setY(
2958  // m_context.m_currentDragPoint.y());
2959 
2964 
2965  // m_context.m_selRectBottomLeftPoint.setX(
2966  // m_context.m_currentDragPoint.x() -
2967  // m_context.m_selectRectangleWidth);
2968  // m_context.m_selRectBottomLeftPoint.setY(
2969  // m_context.m_currentDragPoint.y());
2970  }
2971  else
2972  {
2973  // qDebug() << "Dragging from bottom to top";
2974 
2979 
2980  // m_context.m_selRectTopLeftPoint.setX(
2981  // m_context.m_currentDragPoint.x() -
2982  // m_context.m_selectRectangleWidth);
2983  // m_context.m_selRectTopLeftPoint.setY(
2984  // m_context.m_currentDragPoint.y());
2985 
2990 
2991  // m_context.m_selRectTopRightPoint.setX(
2992  // m_context.m_currentDragPoint.x());
2993  // m_context.m_selRectTopRightPoint.setY(
2994  // m_context.m_currentDragPoint.y());
2995 
3000 
3001  // m_context.m_selRectBottomRightPoint.setX(
3002  // m_context.m_startDragPoint.x() +
3003  // m_context.m_selectRectangleWidth);
3004  // m_context.m_selRectBottomRightPoint.setY(
3005  // m_context.m_startDragPoint.y());
3006 
3010 
3011  // m_context.m_selRectBottomLeftPoint.setX(
3012  // m_context.m_startDragPoint.x());
3013  // m_context.m_selRectBottomLeftPoint.setY(
3014  // m_context.m_startDragPoint.y());
3015  }
3016  }
3017  // End of Dragging from left to right.
3018 
3019  // qDebug() << "Now draw the lines with points:"
3020  //<< m_context.m_selectionPolygon.toString();
3021 
3022  // Top line
3023  mp_selectionRectangeLine1->start->setCoords(
3025  mp_selectionRectangeLine1->end->setCoords(
3027 
3028  // Only if we are drawing a selection rectangle for integration, do we set
3029  // arrow heads to the line.
3030  if(for_integration)
3031  {
3032  mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
3033  mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
3034  }
3035  else
3036  {
3037  mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
3038  mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
3039  }
3040 
3041  mp_selectionRectangeLine1->setVisible(true);
3042 
3043  // Right line
3044  mp_selectionRectangeLine2->start->setCoords(
3046  mp_selectionRectangeLine2->end->setCoords(
3048  mp_selectionRectangeLine2->setVisible(true);
3049 
3050  // Bottom line
3051  mp_selectionRectangeLine3->start->setCoords(
3053  mp_selectionRectangeLine3->end->setCoords(
3055  mp_selectionRectangeLine3->setVisible(true);
3056 
3057  // Left line
3058  mp_selectionRectangeLine4->end->setCoords(
3060  mp_selectionRectangeLine4->start->setCoords(
3062  mp_selectionRectangeLine4->setVisible(true);
3063 }
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 2620 of file baseplotwidget.cpp.

2621 {
2622 
2623  // if(for_integration)
2624  // qDebug() << "for_integration:" << for_integration;
2625 
2626  // We are handling a conventional rectangle. Just create four points
2627  // from top left to bottom right. But we want the top left point to be
2628  // effectively the top left point and the bottom point to be the bottom point.
2629  // So we need to try all four direction combinations, left to right or
2630  // converse versus top to bottom or converse.
2631 
2633 
2635  {
2636  // qDebug() << "Dragging from right to left";
2637 
2639  {
2640  // qDebug() << "Dragging from top to bottom";
2641 
2642  // TOP_LEFT_POINT
2647 
2648  // TOP_RIGHT_POINT
2652 
2653  // BOTTOM_RIGHT_POINT
2658 
2659  // BOTTOM_LEFT_POINT
2664  }
2665  // End of
2666  // if(m_context.m_currentDragPoint.y() < m_context.m_startDragPoint.y())
2667  else
2668  {
2669  // qDebug() << "Dragging from bottom to top";
2670 
2671  // TOP_LEFT_POINT
2676 
2677  // TOP_RIGHT_POINT
2682 
2683  // BOTTOM_RIGHT_POINT
2687 
2688  // BOTTOM_LEFT_POINT
2693  }
2694  }
2695  // End of
2696  // if(m_context.m_currentDragPoint.x() < m_context.m_startDragPoint.x())
2697  else
2698  {
2699  // qDebug() << "Dragging from left to right";
2700 
2702  {
2703  // qDebug() << "Dragging from top to bottom";
2704 
2705  // TOP_LEFT_POINT
2709 
2710  // TOP_RIGHT_POINT
2715 
2716  // BOTTOM_RIGHT_POINT
2721 
2722  // BOTTOM_LEFT_POINT
2727  }
2728  else
2729  {
2730  // qDebug() << "Dragging from bottom to top";
2731 
2732  // TOP_LEFT_POINT
2737 
2738  // TOP_RIGHT_POINT
2743 
2744  // BOTTOM_RIGHT_POINT
2749 
2750  // BOTTOM_LEFT_POINT
2754  }
2755  }
2756 
2757  // qDebug() << "Now draw the lines with points:"
2758  //<< m_context.m_selectionPolygon.toString();
2759 
2760  // Top line
2761  mp_selectionRectangeLine1->start->setCoords(
2763  mp_selectionRectangeLine1->end->setCoords(
2765 
2766  // Only if we are drawing a selection rectangle for integration, do we
2767  // set arrow heads to the line.
2768  if(for_integration)
2769  {
2770  mp_selectionRectangeLine1->setHead(QCPLineEnding::esSpikeArrow);
2771  mp_selectionRectangeLine1->setTail(QCPLineEnding::esSpikeArrow);
2772  }
2773  else
2774  {
2775  mp_selectionRectangeLine1->setHead(QCPLineEnding::esNone);
2776  mp_selectionRectangeLine1->setTail(QCPLineEnding::esNone);
2777  }
2778 
2779  mp_selectionRectangeLine1->setVisible(true);
2780 
2781  // Right line
2782  mp_selectionRectangeLine2->start->setCoords(
2784  mp_selectionRectangeLine2->end->setCoords(
2786  mp_selectionRectangeLine2->setVisible(true);
2787 
2788  // Bottom line
2789  mp_selectionRectangeLine3->start->setCoords(
2791  mp_selectionRectangeLine3->end->setCoords(
2793  mp_selectionRectangeLine3->setVisible(true);
2794 
2795  // Left line
2796  mp_selectionRectangeLine4->start->setCoords(
2798  mp_selectionRectangeLine4->end->setCoords(
2800  mp_selectionRectangeLine4->setVisible(true);
2801 }

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

3248 {
3249  m_context.m_xRange = QCPRange(xAxis->range().lower, xAxis->range().upper);
3250  m_context.m_yRange = QCPRange(yAxis->range().lower, yAxis->range().upper);
3251 
3252  // qDebug() << "The new updated context: " << m_context.toString();
3253 }

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

3069 {
3070 
3071  // qDebug() << "as_line_segment:" << as_line_segment;
3072  // qDebug() << "for_integration:" << for_integration;
3073 
3074  // We now need to construct the selection rectangle, either for zoom or for
3075  // integration.
3076 
3077  // There are two situations :
3078  //
3079  // 1. if the rectangle should look like a line segment
3080  //
3081  // 2. if the rectangle should actually look like a rectangle. In this case,
3082  // there are two sub-situations:
3083  //
3084  // a. if the S key is down, then the rectangle is
3085  // skewed, that is its vertical sides are not parallel to the y axis.
3086  //
3087  // b. otherwise the rectangle is conventional.
3088 
3089  if(as_line_segment)
3090  {
3091  update1DSelectionRectangle(for_integration);
3092  }
3093  else
3094  {
3095  if(!(m_context.m_keyboardModifiers & Qt::AltModifier))
3096  {
3097  update2DSelectionRectangleSquare(for_integration);
3098  }
3099  else if(m_context.m_keyboardModifiers & Qt::AltModifier)
3100  {
3101  update2DSelectionRectangleSkewed(for_integration);
3102  }
3103  }
3104 
3105  // This code automatically sorts the ranges (range start is always less than
3106  // range end) even if the user actually selects from high to low (right to
3107  // left or bottom to top). This has implications in code that uses the
3108  // m_context data to perform some computations. This is why it is important
3109  // that m_dragDirections be set correctly to establish where the current drag
3110  // point is actually located (at which point).
3111 
3116 
3121 
3122  // At this point, draw the text describing the widths.
3123 
3124  // We want the x-delta on the bottom of the rectangle, inside it
3125  // and the y-delta on the vertical side of the rectangle, inside it.
3126 
3127  // Draw the selection width text
3129 }
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 1859 of file baseplotwidget.cpp.

1860 {
1861  QPointF pixel_coordinates(
1862  xAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.x()),
1863  yAxis->coordToPixel(m_context.m_lastCursorHoveredPoint.y()) + pixel_count);
1864 
1865  // Now convert back to local coordinates.
1866 
1867  QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1868  yAxis->pixelToCoord(pixel_coordinates.y()));
1869 
1870  return graph_coordinates;
1871 }

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

Referenced by verticalMoveMouseCursorCountPixels().

◆ verticalMoveMouseCursorCountPixels()

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

Definition at line 1842 of file baseplotwidget.cpp.

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

References moveMouseCursorPixelCoordToGlobal(), and verticalGetGraphCoordNewPointCountPixels().

Referenced by directionKeyPressEvent().

◆ whatIsVisibleOfTheSelectionRectangle()

PolygonType pappso::BasePlotWidget::whatIsVisibleOfTheSelectionRectangle ( )
virtual

Definition at line 3154 of file baseplotwidget.cpp.

3155 {
3156  // There are four lines that make the selection polygon. We want to know
3157  // which lines are visible.
3158 
3159  int current_selection_polygon = static_cast<int>(PolygonType::NOT_SET);
3160 
3161  if(mp_selectionRectangeLine1->visible())
3162  {
3163  current_selection_polygon |= static_cast<int>(PolygonType::TOP_LINE);
3164  // qDebug() << "current_selection_polygon:" << current_selection_polygon;
3165  }
3166  if(mp_selectionRectangeLine2->visible())
3167  {
3168  current_selection_polygon |= static_cast<int>(PolygonType::RIGHT_LINE);
3169  // qDebug() << "current_selection_polygon:" << current_selection_polygon;
3170  }
3171  if(mp_selectionRectangeLine3->visible())
3172  {
3173  current_selection_polygon |= static_cast<int>(PolygonType::BOTTOM_LINE);
3174  // qDebug() << "current_selection_polygon:" << current_selection_polygon;
3175  }
3176  if(mp_selectionRectangeLine4->visible())
3177  {
3178  current_selection_polygon |= static_cast<int>(PolygonType::LEFT_LINE);
3179  // qDebug() << "current_selection_polygon:" << current_selection_polygon;
3180  }
3181 
3182  // qDebug() << "returning visibility:" << current_selection_polygon;
3183 
3184  return static_cast<PolygonType>(current_selection_polygon);
3185 }

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(), pappso::BaseColorMapPlotWidget::currentXaxisRangeIndices(), pappso::BaseColorMapPlotWidget::currentYaxisRangeIndices(), 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: