Loading...
Searching...
No Matches
pappso::MassSpecTracePlotWidget Class Reference

`#include <massspectraceplotwidget.h>`

Inheritance diagram for pappso::MassSpecTracePlotWidget:

## Signals

void | keyPressEventSignal (QKeyEvent *event, const pappso::MassSpecTracePlotContext &context)
void | keyReleaseEventSignal (QKeyEvent *event, const pappso::MassSpecTracePlotContext &context)
void | massDeconvolutionSignal (const pappso::MassSpecTracePlotContext &context)
void | resolvingPowerComputationSignal (const pappso::MassSpecTracePlotContext &context)
void | mousePressEventSignal (QMouseEvent *event, const pappso::MassSpecTracePlotContext &context)
void | mouseReleaseEventSignal (QMouseEvent *event, const pappso::MassSpecTracePlotContext &context)
Signals inherited from pappso::BasePlotWidget
void | setFocusSignal ()
void | lastCursorHoveredPointSignal (const QPointF &pointf)
void | plotRangesChangedSignal (QMouseEvent *event, const pappso::BasePlotContext &context)
void | plotRangesChangedWheelEventSignal (QWheelEvent *event, const pappso::BasePlotContext &context)
void | xAxisMeasurementSignal (const pappso::BasePlotContext &context, bool with_delta)
void | keyPressEventSignal (QKeyEvent *event, const pappso::BasePlotContext &context)
void | keyReleaseEventSignal (QKeyEvent *event, const pappso::BasePlotContext &context)
void | mousePressEventSignal (QMouseEvent *event, const pappso::BasePlotContext &context)
void | mouseReleaseEventSignal (QMouseEvent *event, const pappso::BasePlotContext &context)
void | mouseMoveDraggingCursorSignal (QMouseEvent *event, const pappso::BasePlotContext &context)
void | mouseWheelEventSignal (QWheelEvent *event, const pappso::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 pappso::BasePlotContext &context)
void | beforeReplotSignal ()
void | afterLayoutSignal ()
void | afterReplotSignal ()

## Public Member Functions

| MassSpecTracePlotWidget (QWidget *parent=0)
| MassSpecTracePlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
virtual | ~MassSpecTracePlotWidget ()
void | setChargeMinimalFractionalPart (double charge_fractional_part)
double | getChargeMinimalFractionalPart () const
void | setChargeStateEnvelopePeakSpan (int interval)
int | getChargeStateEnvelopePeakSpan () const
bool | deconvolute ()
| Deconvolute the mass peaks into charge and molecular mass.
bool | deconvoluteIsotopicCluster ()
| Deconvolute the mass peaks into charge and molecular mass.
bool | deconvoluteChargedState (int span=1)
| Deconvolute the mass peaks into charge and molecular mass.
bool | computeResolvingPower ()
virtual void | keyPressEvent (QKeyEvent *event) override
| Set the `m_pressedKeyCode` to the key code in `event`.
virtual void | keyReleaseEvent (QKeyEvent *event) override
| Handle specific key codes and trigger respective actions.
virtual void | mouseMoveHandler (QMouseEvent *event) override
| Handle mouse movements, in particular record all the last visited points.
virtual void | mousePressHandler (QMouseEvent *event) override
| Record the clicks of the mouse.
virtual void | mouseReleaseHandler (QMouseEvent *event) override
| React to the release of the mouse buttons.
virtual void | mouseMoveHandlerNotDraggingCursor (QMouseEvent *event) override
virtual void | mouseMoveHandlerDraggingCursor (QMouseEvent *event) override
const MassSpecTracePlotContext & | refreshBaseContext () const
Public Member Functions inherited from pappso::BaseTracePlotWidget
| BaseTracePlotWidget (QWidget *parent=0)
| BaseTracePlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
virtual | ~BaseTracePlotWidget ()
| Destruct `this` BaseTracePlotWidget instance.
virtual void | setGraphData (int graph_index, const std::vector< double > &keys, const std::vector< double > &values)
virtual void | setGraphData (QCPGraph *graph_p, const std::vector< double > &keys, const std::vector< double > &values)
virtual void | clearGraphData (int graph_index)
virtual void | axisDoubleClickHandler (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event) override
virtual void | axisRescale () override
| RANGE-related functions.
virtual void | axisReframe () override
virtual void | axisZoom () override
virtual void | axisPan () override
virtual QCPGraph * | addTrace (const pappso::Trace &trace, const QColor &color)
virtual QCPBars * | addBars (const pappso::Trace &bars, const QColor &color)
virtual bool | findIntegrationLowerRangeForKey (int index, double key, QCPRange &range)
| Find a minimal integration range starting at an existing data point.
std::vector< double > | getValuesX (int index) const
std::vector< double > | getValuesY (int index) const
QCPRange | getValueRangeOnKeyRange (QCPAbstractPlottable *plottable_p, bool &ok)
QCPRange | getValueRangeOnKeyRange (int index, bool &ok)
double | getYatX (double x, QCPGraph *graph_p)
double | getYatX (double x, int index=0)
pappso::Trace | toTrace (int index, bool only_visible_range=false) const
pappso::Trace | toTrace (const QCPGraph *graph_p, bool only_visible_range=false) const
pappso::Trace | toTrace (const QCPRange &x_axis_range, int index) const
pappso::Trace | toTrace (const QCPRange &x_axis_range, const QCPGraph *graph_p) const
pappso::Trace | toTrace (const QCPRange &x_axis_range, const QCPBars *bars_p) const
Public Member Functions inherited from pappso::BasePlotWidget
| BasePlotWidget (QWidget *parent)
| BasePlotWidget (QWidget *parent, const QString &x_axis_label, const QString &y_axis_label)
virtual | ~BasePlotWidget ()
| Destruct `this` BasePlotWidget instance.
virtual bool | setupWidget ()
virtual void | setPen (const QPen &pen)
virtual const QPen & | getPen () const
virtual void | setPlottingColor (QCPAbstractPlottable *plottable_p, const QColor &new_color)
virtual void | setPlottingColor (int index, const QColor &new_color)
virtual QColor | getPlottingColor (QCPAbstractPlottable *plottable_p) const
virtual QColor | getPlottingColor (int index=0) const
virtual void | setAxisLabelX (const QString &label)
virtual void | setAxisLabelY (const QString &label)
virtual void | resetAxesRangeHistory ()
virtual void | updateAxesRangeHistory ()
| Create new axis range history items and append them to the history.
virtual void | restorePreviousAxesRangeHistory ()
| Go up one history element in the axis history.
virtual void | restoreAxesRangeHistory (std::size_t index)
| Get the axis histories at index `index` and update the plot ranges.
virtual void | 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 | mouseReleaseHandlerLeftButton (QMouseEvent *event)
virtual void | mouseReleaseHandlerRightButton (QMouseEvent *event)
virtual void | mouseWheelHandler (QWheelEvent *event)
virtual void | mouseMoveHandlerLeftButtonDraggingCursor (QMouseEvent *event)
virtual void | mouseMoveHandlerRightButtonDraggingCursor (QMouseEvent *event)
bool | isClickOntoXAxis (const QPointF &mousePoint)
bool | isClickOntoYAxis (const QPointF &mousePoint)
int | dragDirection ()
| MOUSE-related EVENTS.
virtual void | moveMouseCursorGraphCoordToGlobal (QPointF plot_coordinates)
virtual void | moveMouseCursorPixelCoordToGlobal (QPointF local_coordinates)
virtual void | horizontalMoveMouseCursorCountPixels (int pixel_count)
virtual QPointF | horizontalGetGraphCoordNewPointCountPixels (int pixel_count)
virtual void | verticalMoveMouseCursorCountPixels (int pixel_count)
virtual QPointF | verticalGetGraphCoordNewPointCountPixels (int pixel_count)
virtual QCPRange | getRangeX (bool &found_range, int index) const
| MOUSE MOVEMENTS mouse/keyboard-triggered.
virtual QCPRange | getRangeY (bool &found_range, int index) const
QCPRange | getRange (Enums::Axis axis, RangeType range_type, bool &found_range) const
virtual QCPRange | getInnermostRangeX (bool &found_range) const
virtual QCPRange | getOutermostRangeX (bool &found_range) const
virtual QCPRange | getInnermostRangeY (bool &found_range) const
virtual QCPRange | getOutermostRangeY (bool &found_range) const
void | yMinMaxOnXAxisCurrentRange (double &min, double &max, QCPAbstractPlottable *plottable_p=nullptr)
void | yMinMaxOnXAxisCurrentRange (double &min, double &max, int index)
virtual void | replotWithAxesRanges (QCPRange xAxisRange, QCPRange yAxisRange, Enums::Axis axis)
virtual void | replotWithAxisRangeX (double lower, double upper)
virtual void | replotWithAxisRangeY (double lower, double upper)
virtual void | hideAllPlotItems ()
| PLOTTING / REPLOTTING functions.
virtual void | showTracers ()
| Show the traces (vertical and horizontal).
virtual void | hideTracers ()
| Hide the traces (vertical and horizontal).
virtual void | drawXScopeSpanFeatures ()
virtual void | drawYScopeSpanFeatures ()
virtual void | calculateDragDeltas ()
virtual bool | isVerticalDisplacementAboveThreshold ()
virtual void | drawSelectionRectangleAndPrepareZoom (bool as_line_segment=false, bool for_integration=false)
virtual void | updateIntegrationScopeDrawing (bool as_line_segment=false, bool for_integration=false)
virtual void | resetSelectionRectangle ()
virtual void | hideSelectionRectangle (bool reset_values=false)
virtual bool | isSelectionRectangleVisible ()
virtual SelectionDrawingLines | whatIsVisibleOfTheSelectionRectangle ()
virtual void | setFocus ()
| PLOT ITEMS : TRACER TEXT ITEMS...
virtual void | redrawPlotBackground (QWidget *focusedPlotWidget)
| Redraw the background of the `focusedPlotWidget` plot widget.
virtual void | updateContextXandYAxisRanges ()
virtual const BasePlotContext & | getContext () const

## Protected Attributes

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

## Additional Inherited Members

Protected Member Functions inherited from pappso::BasePlotWidget
virtual void | createAllAncillaryItems ()
virtual void | updateIntegrationScope (bool for_integration=false)
virtual void | updateIntegrationScopeRect (bool for_integration=false)
virtual void | updateIntegrationScopeHorizontalRhomb (bool for_integration=false)
virtual void | updateIntegrationScopeVerticalRhomb (bool for_integration=false)
virtual void | updateIntegrationScopeRhomb (bool for_integration=false)
virtual QString | allLayerNamesToString () const
virtual QString | layerableLayerName (QCPLayerable *layerable_p) const
virtual int | layerableLayerIndex (QCPLayerable *layerable_p) const

## Detailed Description

Definition at line 57 of file massspectraceplotwidget.h.

## Constructor & Destructor Documentation

## MassSpecTracePlotWidget() [1/2]

pappso::MassSpecTracePlotWidget::MassSpecTracePlotWidget | ( | QWidget * | parent = 0 | ) |

explicit

Definition at line 53 of file massspectraceplotwidget.cpp.

: BaseTracePlotWidget(parent)
{
BasePlotWidget::m_context.m_dataKind = Enums::DataKind::mz;
m_context.m_dataKind = Enums::DataKind::mz;
// qDebug() << "Data kind:" << static_cast<int>(m_context.m_dataKind);
}
pappso::BasePlotContext::m_dataKind
Enums::DataKind m_dataKind
Definition baseplotcontext.h:92
pappso::BasePlotWidget::m_context
BasePlotContext m_context
Definition baseplotwidget.h:283
pappso::BaseTracePlotWidget::BaseTracePlotWidget
BaseTracePlotWidget(QWidget *parent=0)
Definition basetraceplotwidget.cpp:43
pappso::MassSpecTracePlotWidget::m_context
MassSpecTracePlotContext m_context
Definition massspectraceplotwidget.h:115
pappso::Enums::DataKind::mz
@ mz
m/z
Definition types.h:253

References pappso::BaseTracePlotWidget::BaseTracePlotWidget(), pappso::BasePlotWidget::m_context, m_context, and pappso::Enums::mz.

## MassSpecTracePlotWidget() [2/2]

pappso::MassSpecTracePlotWidget::MassSpecTracePlotWidget | ( | QWidget * | parent,
|  | const QString & | x_axis_label,
|  | const QString & | y_axis_label )

explicit

Definition at line 61 of file massspectraceplotwidget.cpp.

: BaseTracePlotWidget(parent, x_axis_label, y_axis_label)
{
// Set the base context to be of kind Enums::DataKind::mz;
BasePlotWidget::m_context.m_dataKind = Enums::DataKind::mz;
m_context.m_dataKind = Enums::DataKind::mz;
// qDebug() << "Data kind:" << static_cast<int>(m_context.m_dataKind);
}

References pappso::BaseTracePlotWidget::BaseTracePlotWidget(), pappso::BasePlotWidget::m_context, m_context, and pappso::Enums::mz.

## ~MassSpecTracePlotWidget()

pappso::MassSpecTracePlotWidget::~MassSpecTracePlotWidget | ( |  | ) |

virtual

Definition at line 75 of file massspectraceplotwidget.cpp.

{
}

## Member Function Documentation

## computeResolvingPower()

bool pappso::MassSpecTracePlotWidget::computeResolvingPower | ( |  | ) |

Definition at line 607 of file massspectraceplotwidget.cpp.

{
// m_xRangeLower and m_xRangeUpper and m_xDelta (in fabs() form) have been set
// during mouve movement handling. Note that the range values *are
// sorted*.
if(!m_context.m_xDelta || m_context.m_xDelta > 1)
{
m_context.m_lastResolvingPower = std::numeric_limits<double>::min();
return false;
}
// Resolving power is m/z / Delta(m/z), for singly-charged species.
// qDebug() << "Calculating the resolving power with these data:"
//<< "m_context.m_xRegionRangeStart: " << m_context.m_xRegionRangeStart
//<< "m_context.m_xRegionRangeEnd: " << m_context.m_xRegionRangeEnd
//<< "m_context.m_xDelta / 2: " << m_context.m_xDelta / 2;
m_context.m_lastResolvingPower =
(std::min<double>(m_context.m_xRegionRangeStart, m_context.m_xRegionRangeStop) +
(m_context.m_xDelta / 2)) /
m_context.m_xDelta;
// The m_context was refreshed with the base class context in the calling
// chain.
emit resolvingPowerComputationSignal(m_context);
return true;
}
pappso::MassSpecTracePlotWidget::resolvingPowerComputationSignal
void resolvingPowerComputationSignal(const pappso::MassSpecTracePlotContext &context)

References m_context, and resolvingPowerComputationSignal().

Referenced by mouseMoveHandlerDraggingCursor().

## deconvolute()

bool pappso::MassSpecTracePlotWidget::deconvolute | ( |  | ) |

Deconvolute the mass peaks into charge and molecular mass.

Definition at line 288 of file massspectraceplotwidget.cpp.

{
// qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
// There are two situations: when the user is deconvoluting on the
// basis of the distance between two consecutive peaks of a same
// isotopic cluster or when the user deconvolutes on the basis of two
// different charged-stated peaks that belong to the same envelope.
// We can tell the difference because in the first case the xDelta
// should be less than 1. In the other case, of course the difference
// is much greater than 1.
// In order to do the deconvolutions, we need to know what is the tolerance
// on the fractional part of the deconvoluted charge value. This value is set
// in the parent window's double spin box.
if(fabs(m_context.m_xDelta) >= 0 && fabs(m_context.m_xDelta) <= 1.1)
{
// qDebug() << "m_xDelta:" << m_context.m_xDelta
//<< "trying isotope-based deconvolution.";
return deconvoluteIsotopicCluster();
}
// If not deconvoluting on the basis of the isotopic cluster, then:
return deconvoluteChargedState(m_chargeStateEnvelopePeakSpan);
}
pappso::MassSpecTracePlotWidget::deconvoluteChargedState
bool deconvoluteChargedState(int span=1)
Deconvolute the mass peaks into charge and molecular mass.
Definition massspectraceplotwidget.cpp:342
pappso::MassSpecTracePlotWidget::m_chargeStateEnvelopePeakSpan
int m_chargeStateEnvelopePeakSpan
Definition massspectraceplotwidget.h:129
pappso::MassSpecTracePlotWidget::deconvoluteIsotopicCluster
bool deconvoluteIsotopicCluster()
Deconvolute the mass peaks into charge and molecular mass.
Definition massspectraceplotwidget.cpp:487

References deconvoluteChargedState(), deconvoluteIsotopicCluster(), m_chargeStateEnvelopePeakSpan, and m_context.

Referenced by mouseMoveHandlerDraggingCursor().

## deconvoluteChargedState()

bool pappso::MassSpecTracePlotWidget::deconvoluteChargedState | ( | int | span = 1 | ) |

Deconvolute the mass peaks into charge and molecular mass.

This is one of two methods to deconvolute mass data into a charge value and a Mr value. The method implemented in this function is based on the charge state envelope offered by the mass spectrum (most often for polymers of a reasonable size).

Parameters

  span | value representing the number of peaks of the charge state envelope that are spanned by the user selection. Defaults to 1, that is, the span encompasses two consecutive mass peaks of a given charge state envelope.

The z charge that is computed is for the first peak that was clicked in the trace plot, and thus the Mr value that is returned is calculated from the m/z value under the peak that was clicked first.

Set m_lastMz, m_lastZ and m_lastMass.

Returns
  true if the deconvolution could be performed, false otherwise.

Definition at line 342 of file massspectraceplotwidget.cpp.

{
// We assume that we are dealing with two successive (if span is 1) mass
// peaks belonging to a given charge state family.
// We call span the number of intervals in a given charge state envelope
// that separate the initial peak (lowerMz) from the last peak (upperMz).
// That parameter defaults to 1, that is the two peaks are immediately
// consecutive, that is, there is only one interval.
// qDebug() << "The span is:" << span;
// The m_context ranges are inherently sorted. This is not something that
// is favorable to us because we need to know what is the direction of the
// drag. That should be configurable, but we can establish that by
// default, the z value will be calculated for the mass peak at which
// the mouse drag movement started.
// These two values reflect a m/z range:
// startMz and curMz are always sorted (startMz < curMz)
double startMz = m_context.m_xRegionRangeStart;
double curMz = m_context.m_xRegionRangeStop;
// qDebug() << "startMz:" << startMz << "curMz:" << curMz;
if(startMz == curMz)
{
m_context.m_lastZ = std::numeric_limits<quint16>::max();
m_context.m_lastMz = qQNaN();
m_context.m_lastTicIntensity = qQNaN();
m_context.m_lastMr = qQNaN();
// qDebug() << "Start and Cur are the same, no deconvolution possible.";
return false;
}
// After much discussing, the agreement we reached with users is that the
// m/z value that is reported has to be that of the clicked peak, that is
// the start point of the mouse cursor drag operation. The z charge value
// has to be related to that m/z value.
double chargeTemp = ((startMz * span) - span) / (curMz - startMz);
// This is the charge of the least charged peak, that is, by necessity
// the charge of the peak on the right (curMz, because the values
// are sorted).
// Make a judicious roundup.
double chargeIntPart;
double chargeFracPart = modf(chargeTemp, &chargeIntPart);
// When calculating the charge of the ion, very rarely does it provide a
// perfect integer value. Most often (if deconvolution is for bona fide
// peaks belonging to the same charge state envelope) that value is with
// either a large fractional part or a very small fractional part. What we
// test here, it that fractional part. If it is greater than
// m_chargeMinimalFractionalPart, then we simply round up to the next integer
// value (that is, chargeIntPart = 27 and chargeFracPart 0.995, then we
// set charge to 28). If it is lesser or equal to (1 -
// m_chargeMinimalFractionalPart /* that is >= 0.01 */, then we let
// chargeIntPart unmodified (that is, chargeIntPart = 29 and
// chargeFracPart 0.01, then we set charge to 29). If chargeFracPart is in
// between (1 - m_chargeMinimalFractionalPart) and
// m_chargeMinimalFractionalPart, then we consider that the peaks do not
// belong to the same charge state envelope.
// qDebug() << "Charge:" << chargeIntPart << "Charge fractional part: " << chargeFracPart;
if(chargeFracPart >= (1 - m_chargeMinimalFractionalPart /* that is >= 0.01 */) &&
chargeFracPart <= m_chargeMinimalFractionalPart /* that is <= 0.99 */)
{
m_context.m_lastZ = std::numeric_limits<quint16>::max();
m_context.m_lastMz = qQNaN();
m_context.m_lastTicIntensity = qQNaN();
m_context.m_lastMr = qQNaN();
// qDebug() << "Not a charge state family peak,"
// << "returning from deconvoluteChargeState";
return false;
}
if(chargeFracPart > m_chargeMinimalFractionalPart)
m_context.m_lastZ = chargeIntPart + 1;
else
m_context.m_lastZ = chargeIntPart;
// qDebug() << "Initially computed m_lastZ as " << m_context.m_lastZ;
// We know the that formula above computed the charge of the least charged
// ion, that corresponds to the greater m/z value of the range: curMz.
// Now, if the user did click on that least-charged peak, nothing is
// to be modified. But, if the user did click on the most-charged
// peak, that is on startMz, the we need to fix the values:
if(static_cast<int>(m_context.m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
{
// qDebug() << "Dragging from right to left, that is from higher m/z value.";
m_context.m_lastMz = curMz;
}
else if(static_cast<int>(m_context.m_dragDirections) &
static_cast<int>(DragDirections::LEFT_TO_RIGHT))
{
// qDebug() << "Dragging from left to right, we need to report"
// << "the mass for the left peak, that is for z+span and lower m/z value.";
m_context.m_lastZ += span;
m_context.m_lastMz = startMz;
}
// qDebug() << "Final m_lastZ is " << m_context.m_lastZ << "m/z: m_context.m_lastMz";
m_context.m_lastMr = (m_context.m_lastMz * m_context.m_lastZ) - (m_context.m_lastZ * MPROTON);
// qDebug() << "startMz:" << QString("%1").arg(startMz, 0, 'f', 6)
// << "curMz:" << QString("%1").arg(curMz, 0, 'f', 6)
// << "m_lastMz (make computation for this startMz):"
// << QString("%1").arg(m_context.m_lastMz, 0, 'f', 6)
// << "m_lastZ:" << QString("%1").arg(m_context.m_lastZ)
// << "m_lastMass:" << QString("%1").arg(m_context.m_lastMr, 0, 'f', 6);
// The m_context was refreshed with the base class context in the calling
// chain.
emit massDeconvolutionSignal(m_context);
return true;
}
pappso::MassSpecTracePlotWidget::massDeconvolutionSignal
void massDeconvolutionSignal(const pappso::MassSpecTracePlotContext &context)
pappso::MassSpecTracePlotWidget::m_chargeMinimalFractionalPart
double m_chargeMinimalFractionalPart
Definition massspectraceplotwidget.h:122
pappso::MPROTON
const pappso_double MPROTON(1.007276466879)
pappso::DragDirections::RIGHT_TO_LEFT
@ RIGHT_TO_LEFT
Definition baseplotcontext.h:34
pappso::DragDirections::LEFT_TO_RIGHT
@ LEFT_TO_RIGHT
Definition baseplotcontext.h:33

References pappso::LEFT_TO_RIGHT, m_chargeMinimalFractionalPart, m_context, massDeconvolutionSignal(), pappso::MPROTON(), and pappso::RIGHT_TO_LEFT.

Referenced by deconvolute().

## deconvoluteIsotopicCluster()

bool pappso::MassSpecTracePlotWidget::deconvoluteIsotopicCluster | ( |  | ) |

Deconvolute the mass peaks into charge and molecular mass.

This is one of two methods to deconvolute mass data into a charge value and a Mr value. The method implemented in this function is based on the distance that separates two immediately consecutive peaks of an isotopic cluster. This method can be used as long as the instrument produced data with a resolution sufficient to separate reasonably well the different peaks of an isotopic cluster.

Set m_lastMz, m_lastZ and m_lastMass.

Returns
  true if the deconvolution could be performed, false otherwise.

Definition at line 487 of file massspectraceplotwidget.cpp.

{
// The m_context ranges are inherently sorted. This is not something that
// is favorable to us because we need to know what is the direction of the
// drag. That should be configurable, but we can establish that by
// default, the z value will be calculated for the mass peak at which
// the mouse drag movement started.
double startMz = m_context.m_xRegionRangeStart;
double curMz = m_context.m_xRegionRangeStop;
// qDebug() << "startMz:" << startMz << "curMz:" << curMz;
if(startMz == curMz)
{
m_context.m_lastZ = std::numeric_limits<quint16>::max();
m_context.m_lastMz = qQNaN();
m_context.m_lastTicIntensity = qQNaN();
m_context.m_lastMr = qQNaN();
return false;
}
// After much discussion with people who perform mass data analysis for
// heavy isotope fully labelled analytes, it was decided that the Mr
// value thas is returned is for the peak from which the drag operation
// was performed. This is an analogous way of computing Mr as that used
// in the charge state envelope method.
double chargeTemp = 1 / fabs(m_context.m_xDelta);
// qDebug() << qSetRealNumberPrecision(6) << "curMz - startMz = " << fabs(curMz - startMz)
// << "while m_context.m_xDelta = " << m_context.m_xDelta;
// Sanity check
if(fabs(m_context.m_xDelta) != fabs(curMz - startMz))
qFatal() << "Programming error.";
// Make a judicious roundup.
double chargeIntPart;
double chargeFracPart = modf(chargeTemp, &chargeIntPart);
// qDebug() << "m_xDelta:" << m_context.m_xDelta
// << "chargeTemp:" << QString("%1").arg(chargeTemp, 0, 'f', 6)
// << "chargeIntPart:" << chargeIntPart
// << "chargeFracPart:" << QString("%1").arg(chargeFracPart, 0, 'f', 6)
// << "m_chargeMinimalFractionalPart:" << m_chargeMinimalFractionalPart;
if(chargeFracPart >= (1 - m_chargeMinimalFractionalPart /* that is >= 0.01 */) &&
chargeFracPart <= m_chargeMinimalFractionalPart /* that is <= 0.99 */)
{
m_context.m_lastZ = std::numeric_limits<quint16>::max();
m_context.m_lastMz = qQNaN();
m_context.m_lastTicIntensity = qQNaN();
m_context.m_lastMr = qQNaN();
// qDebug() << "Not in a isotopic cluster peak:"
// << "returning from deconvoluteIsotopicCluster";
return false;
}
if(chargeFracPart > m_chargeMinimalFractionalPart)
{
m_context.m_lastZ = chargeIntPart + 1;
// qDebug() << "chargeFracPart > m_chargeMinimalFractionalPart -> m_lastZ
// = "
//<< m_context.m_lastZ;
}
else
{
m_context.m_lastZ = chargeIntPart;
// qDebug()
//<< "chargeFracPart <= m_chargeMinimalFractionalPart -> m_lastZ = "
//<< m_context.m_lastZ;
}
// qDebug() << "Settled on m_lastZ: " << m_context.m_lastZ;
// Now that we have the charge in the form of an int, we can compute the
// Mr of the isotopic cluster peak that was under the cursor when the
// mouse drag started.
// If we know the drag direction, we would automatically know what is the
// peak that was under the cursor when the mouse drag mouvement was initiated.
// This is because the curMz is inherently larger than startMz because
// m_context.m_xRegionRangeStart and m_context.m_xRegionRangeEnd are inherently
// sorted (start < end).
if(static_cast<int>(m_context.m_dragDirections) & static_cast<int>(DragDirections::RIGHT_TO_LEFT))
{
// qDebug() << "Dragging from right to left, that is from higher m/z value.";
m_context.m_lastMz = curMz;
}
else if(static_cast<int>(m_context.m_dragDirections) &
static_cast<int>(DragDirections::LEFT_TO_RIGHT))
{
// qDebug() << "Dragging from left to right, we need to report"
// << "the mass for the left peak.";
m_context.m_lastMz = startMz;
}
m_context.m_lastMr = (m_context.m_lastMz * m_context.m_lastZ) - (m_context.m_lastZ * MPROTON);
// qDebug() << "m_lastMz :" << QString("%1").arg(m_context.m_lastMz, 0, 'f', 6)
// << "m_lastZ:" << QString("%1").arg(m_context.m_lastZ)
// << "m_lastMr:" << QString("%1").arg(m_context.m_lastMr, 0, 'f', 6);
// The m_context was refreshed with the base class context in the calling
// chain.
emit massDeconvolutionSignal(m_context);
return true;
}

References pappso::LEFT_TO_RIGHT, m_chargeMinimalFractionalPart, m_context, massDeconvolutionSignal(), pappso::MPROTON(), and pappso::RIGHT_TO_LEFT.

Referenced by deconvolute().

## getChargeMinimalFractionalPart()

double pappso::MassSpecTracePlotWidget::getChargeMinimalFractionalPart | ( |  | ) | const

Definition at line 266 of file massspectraceplotwidget.cpp.

{
return m_chargeMinimalFractionalPart;
}

References m_chargeMinimalFractionalPart.

## getChargeStateEnvelopePeakSpan()

int pappso::MassSpecTracePlotWidget::getChargeStateEnvelopePeakSpan | ( |  | ) | const

Definition at line 280 of file massspectraceplotwidget.cpp.

{
return m_chargeStateEnvelopePeakSpan;
}

References m_chargeStateEnvelopePeakSpan.

## keyPressEvent()

void pappso::MassSpecTracePlotWidget::keyPressEvent | ( | QKeyEvent * | event | ) |

override virtual

Set the `m_pressedKeyCode` to the key code in `event`.

Reimplemented from pappso::BasePlotWidget.

Definition at line 82 of file massspectraceplotwidget.cpp.

{
// qDebug() << "ENTER";
BasePlotWidget::keyPressEvent(event);
// Before working on the various data belonging to the base context, we need
// to get it from the base class and refresh our local context with it.
refreshBaseContext();
// qDebug() << "Going to emit keyPressEventSignal(m_context);";
emit keyPressEventSignal(event, m_context);
}
pappso::BasePlotWidget::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event)
KEYBOARD-related EVENTS.
Definition baseplotwidget.cpp:607
pappso::MassSpecTracePlotWidget::refreshBaseContext
const MassSpecTracePlotContext & refreshBaseContext() const
Definition massspectraceplotwidget.cpp:225
pappso::MassSpecTracePlotWidget::keyPressEventSignal
void keyPressEventSignal(QKeyEvent *event, const pappso::MassSpecTracePlotContext &context)

References pappso::BasePlotWidget::keyPressEvent(), keyPressEventSignal(), m_context, and refreshBaseContext().

## keyPressEventSignal

void pappso::MassSpecTracePlotWidget::keyPressEventSignal | ( | QKeyEvent * | event,
|  | const pappso::MassSpecTracePlotContext & | context )

signal

Referenced by keyPressEvent().

## keyReleaseEvent()

void pappso::MassSpecTracePlotWidget::keyReleaseEvent | ( | QKeyEvent * | event | ) |

override virtual

Handle specific key codes and trigger respective actions.

Reimplemented from pappso::BasePlotWidget.

Definition at line 99 of file massspectraceplotwidget.cpp.

{
// qDebug() << "ENTER";
BasePlotWidget::keyReleaseEvent(event);
// Before working on the various data belonging to the base context, we need
// to get it from the base class and refresh our local context with it.
refreshBaseContext();
emit keyReleaseEventSignal(event, m_context);
}
pappso::BasePlotWidget::keyReleaseEvent
virtual void keyReleaseEvent(QKeyEvent *event)
Handle specific key codes and trigger respective actions.
Definition baseplotwidget.cpp:646
pappso::MassSpecTracePlotWidget::keyReleaseEventSignal
void keyReleaseEventSignal(QKeyEvent *event, const pappso::MassSpecTracePlotContext &context)

References pappso::BasePlotWidget::keyReleaseEvent(), keyReleaseEventSignal(), m_context, and refreshBaseContext().

## keyReleaseEventSignal

void pappso::MassSpecTracePlotWidget::keyReleaseEventSignal | ( | QKeyEvent * | event,
|  | const pappso::MassSpecTracePlotContext & | context )

signal

Referenced by keyReleaseEvent().

## massDeconvolutionSignal

void pappso::MassSpecTracePlotWidget::massDeconvolutionSignal | ( | const pappso::MassSpecTracePlotContext & | context | ) |

signal

Referenced by deconvoluteChargedState(), and deconvoluteIsotopicCluster().

## mouseMoveHandler()

void pappso::MassSpecTracePlotWidget::mouseMoveHandler | ( | QMouseEvent * | event | ) |

override virtual

Handle mouse movements, in particular record all the last visited points.

This function is reponsible for storing at each time the last visited point in the graph. Here, point is intended as any x/y coordinate in the plot widget viewport, not a graph point.

The stored values are then the basis for a large set of calculations throughout all the plot widget.

Parameters

  pointer | to QMouseEvent from which to retrieve the coordinates of the visited viewport points.

Reimplemented from pappso::BasePlotWidget.

Definition at line 126 of file massspectraceplotwidget.cpp.

{
// Before working on the various data belonging to the base context, we need
// to get it from the base class and refresh our local context with it.
refreshBaseContext();
BasePlotWidget::mouseMoveHandler(event);
}
pappso::BasePlotWidget::mouseMoveHandler
virtual void mouseMoveHandler(QMouseEvent *event)
KEYBOARD-related EVENTS.
Definition baseplotwidget.cpp:947

References pappso::BasePlotWidget::mouseMoveHandler(), and refreshBaseContext().

## mouseMoveHandlerDraggingCursor()

void pappso::MassSpecTracePlotWidget::mouseMoveHandlerDraggingCursor | ( | QMouseEvent * | event | ) |

override virtual

Reimplemented from pappso::BasePlotWidget.

Definition at line 150 of file massspectraceplotwidget.cpp.

{
BasePlotWidget::mouseMoveHandlerDraggingCursor(event);
// Before working on the various data belonging to the base context, we need
// to get it from the base class and refresh our local context with it.
refreshBaseContext();
if(m_context.m_mouseButtonsAtMousePress & Qt::LeftButton)
{
if(!m_context.m_isMeasuringDistance)
return;
// qDebug() << "Mouse Buttons at Mouse press:" << m_context.m_mouseButtonsAtMousePress;
// qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
deconvolute();
computeResolvingPower();
}
}
pappso::BasePlotWidget::mouseMoveHandlerDraggingCursor
virtual void mouseMoveHandlerDraggingCursor(QMouseEvent *event)
Definition baseplotwidget.cpp:1058
pappso::MassSpecTracePlotWidget::computeResolvingPower
bool computeResolvingPower()
Definition massspectraceplotwidget.cpp:607
pappso::MassSpecTracePlotWidget::deconvolute
bool deconvolute()
Deconvolute the mass peaks into charge and molecular mass.
Definition massspectraceplotwidget.cpp:288

References computeResolvingPower(), deconvolute(), m_context, pappso::BasePlotWidget::mouseMoveHandlerDraggingCursor(), and refreshBaseContext().

## mouseMoveHandlerNotDraggingCursor()

void pappso::MassSpecTracePlotWidget::mouseMoveHandlerNotDraggingCursor | ( | QMouseEvent * | event | ) |

override virtual

Reimplemented from pappso::BasePlotWidget.

Definition at line 137 of file massspectraceplotwidget.cpp.

{
// Before working on the various data belonging to the base context, we need
// to get it from the base class and refresh our local context with it.
refreshBaseContext();
BasePlotWidget::mouseMoveHandlerNotDraggingCursor(event);
// qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
}
pappso::BasePlotWidget::mouseMoveHandlerNotDraggingCursor
virtual void mouseMoveHandlerNotDraggingCursor(QMouseEvent *event)
Definition baseplotwidget.cpp:994

References pappso::BasePlotWidget::mouseMoveHandlerNotDraggingCursor(), and refreshBaseContext().

## mousePressEventSignal

void pappso::MassSpecTracePlotWidget::mousePressEventSignal | ( | QMouseEvent * | event,
|  | const pappso::MassSpecTracePlotContext & | context )

signal

Referenced by mousePressHandler().

## mousePressHandler()

void pappso::MassSpecTracePlotWidget::mousePressHandler | ( | QMouseEvent * | event | ) |

override virtual

Record the clicks of the mouse.

Reimplemented from pappso::BasePlotWidget.

Definition at line 175 of file massspectraceplotwidget.cpp.

{
// qDebug() << "Entering";
// Before working on the various data belonging to the base context, we need
// to get it from the base class and refresh our local context with it.
refreshBaseContext();
BasePlotWidget::mousePressHandler(event);
// qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
emit mousePressEventSignal(event, m_context);
// qDebug() << "Exiting after having emitted mousePressEventSignal with context:"
// << m_context.toString();
}
pappso::BasePlotWidget::mousePressHandler
virtual void mousePressHandler(QMouseEvent *event)
KEYBOARD-related EVENTS.
Definition baseplotwidget.cpp:1330
pappso::MassSpecTracePlotWidget::mousePressEventSignal
void mousePressEventSignal(QMouseEvent *event, const pappso::MassSpecTracePlotContext &context)

References m_context, mousePressEventSignal(), pappso::BasePlotWidget::mousePressHandler(), and refreshBaseContext().

## mouseReleaseEventSignal

void pappso::MassSpecTracePlotWidget::mouseReleaseEventSignal | ( | QMouseEvent * | event,
|  | const pappso::MassSpecTracePlotContext & | context )

signal

Referenced by mouseReleaseHandler().

## mouseReleaseHandler()

void pappso::MassSpecTracePlotWidget::mouseReleaseHandler | ( | QMouseEvent * | event | ) |

override virtual

React to the release of the mouse buttons.

Reimplemented from pappso::BasePlotWidget.

Definition at line 196 of file massspectraceplotwidget.cpp.

{
// qDebug() << "Entering";
// Before working on the various data belonging to the base context, we need
// to get it from the base class and refresh our local context with it.
refreshBaseContext();
BasePlotWidget::mouseReleaseHandler(event);
// qDebug() << "The current m_lastZ value:" << m_context.m_lastZ;
if(!m_context.m_isMouseDragging)
{
// Since we were not dragging, by essence we were not measuring
// distances and _a fortiori_ we were not deconvoluting. So
// reset deconvolution data in the context.
m_context.resetDeconvolutionData();
}
emit mouseReleaseEventSignal(event, m_context);
// qDebug() << "Exiting after having emitted mouseReleaseEventSignal with context:"
// << m_context.toString();
}
pappso::BasePlotWidget::mouseReleaseHandler
virtual void mouseReleaseHandler(QMouseEvent *event)
Definition baseplotwidget.cpp:1445
pappso::MassSpecTracePlotWidget::mouseReleaseEventSignal
void mouseReleaseEventSignal(QMouseEvent *event, const pappso::MassSpecTracePlotContext &context)

References m_context, mouseReleaseEventSignal(), pappso::BasePlotWidget::mouseReleaseHandler(), and refreshBaseContext().

## refreshBaseContext()

const MassSpecTracePlotContext & pappso::MassSpecTracePlotWidget::refreshBaseContext | ( |  | ) | const

Definition at line 225 of file massspectraceplotwidget.cpp.

{
// BasePlotWidget has a member m_context of type BasePlotContext.
// Here we also have a m_context *distinct* member that is of type
// MassSpecTracePlotContext.
// While MassSpecTracePlotContext is derived from BasePlotContext, the two
// m_context members are distinct and there are lots of housekeeping data that
// are managed by the parent BasePlotWidget class in its m_context member
// *independently* of what we have in the ::BasePlotContext part of our
// m_context member that is of type MassSpecTracePlotContext. We thus need to
// resynchronize the data from BasePlotWidget::m_context to our m_context.
// qDebug().noquote() << "The base plot context:" <<
// BasePlotWidget::m_context.toString();
// qDebug() << "Right before refreshing the context, the current m_lastZ value:"
// << m_context.m_lastZ;
m_context.initialize(BasePlotWidget::m_context);
// qDebug() << "Right after refreshing the context, the current m_lastZ value:"
// << m_context.m_lastZ;
// qDebug().noquote() << "After refreshing the base context, base context:"
// << m_context.toString();
return m_context;
}

References pappso::BasePlotWidget::m_context, and m_context.

Referenced by keyPressEvent(), keyReleaseEvent(), mouseMoveHandler(), mouseMoveHandlerDraggingCursor(), mouseMoveHandlerNotDraggingCursor(), mousePressHandler(), and mouseReleaseHandler().

## resolvingPowerComputationSignal

void pappso::MassSpecTracePlotWidget::resolvingPowerComputationSignal | ( | const pappso::MassSpecTracePlotContext & | context | ) |

signal

Referenced by computeResolvingPower().

## setChargeMinimalFractionalPart()

void pappso::MassSpecTracePlotWidget::setChargeMinimalFractionalPart | ( | double | charge_fractional_part | ) |

Definition at line 259 of file massspectraceplotwidget.cpp.

{
m_chargeMinimalFractionalPart = charge_fractional_part;
}

References m_chargeMinimalFractionalPart.

## setChargeStateEnvelopePeakSpan()

void pappso::MassSpecTracePlotWidget::setChargeStateEnvelopePeakSpan | ( | int | interval | ) |

Definition at line 273 of file massspectraceplotwidget.cpp.

{
m_chargeStateEnvelopePeakSpan = interval;
}

References m_chargeStateEnvelopePeakSpan.

## Member Data Documentation

## m_chargeMinimalFractionalPart

double pappso::MassSpecTracePlotWidget::m_chargeMinimalFractionalPart = 0.990

protected

Definition at line 122 of file massspectraceplotwidget.h.

Referenced by deconvoluteChargedState(), deconvoluteIsotopicCluster(), getChargeMinimalFractionalPart(), and setChargeMinimalFractionalPart().

## m_chargeStateEnvelopePeakSpan

int pappso::MassSpecTracePlotWidget::m_chargeStateEnvelopePeakSpan = 1

protected

Definition at line 129 of file massspectraceplotwidget.h.

Referenced by deconvolute(), getChargeStateEnvelopePeakSpan(), and setChargeStateEnvelopePeakSpan().

## m_context

MassSpecTracePlotContext pappso::MassSpecTracePlotWidget::m_context

mutable protected

Definition at line 115 of file massspectraceplotwidget.h.

Referenced by MassSpecTracePlotWidget(), MassSpecTracePlotWidget(), computeResolvingPower(), deconvolute(), deconvoluteChargedState(), deconvoluteIsotopicCluster(), keyPressEvent(), keyReleaseEvent(), mouseMoveHandlerDraggingCursor(), mousePressHandler(), mouseReleaseHandler(), and refreshBaseContext().

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

- pappsomspp/gui/plotwidget/massspectraceplotwidget.h
- pappsomspp/gui/plotwidget/massspectraceplotwidget.cpp