OpenMS
Plot1DCanvas Class Reference

Canvas for visualization of one or several spectra. More...

#include <OpenMS/VISUAL/Plot1DCanvas.h>

Inheritance diagram for Plot1DCanvas:
[legend]
Collaboration diagram for Plot1DCanvas:
[legend]

Public Types

enum  LabelMode { LM_XABSOLUTE_YABSOLUTE , LM_XPERCENT_YABSOLUTE , LM_XABSOLUTE_YPERCENT , LM_XPERCENT_YPERCENT }
 Label modes (percentage or absolute) of x axis and y axis. More...
 
enum  DrawModes { DM_PEAKS , DM_CONNECTEDLINES }
 Enumerate all available paint styles. More...
 
- Public Types inherited from PlotCanvas
enum  ActionModes { AM_TRANSLATE , AM_ZOOM , AM_MEASURE }
 Mouse action modes. More...
 
enum  IntensityModes { IM_NONE , IM_PERCENTAGE , IM_SNAP , IM_LOG }
 Display modes of intensity. More...
 
typedef LayerDataBase::ExperimentType ExperimentType
 Main data type (experiment) More...
 
typedef LayerDataBase::ExperimentSharedPtrType ExperimentSharedPtrType
 Main managed data type (experiment) More...
 
typedef LayerDataBase::ConstExperimentSharedPtrType ConstExperimentSharedPtrType
 
typedef LayerDataBase::ODExperimentSharedPtrType ODExperimentSharedPtrType
 
typedef LayerDataBase::FeatureMapType FeatureMapType
 Main data type (features) More...
 
typedef LayerDataBase::FeatureMapSharedPtrType FeatureMapSharedPtrType
 Main managed data type (features) More...
 
typedef LayerDataBase::ConsensusMapType ConsensusMapType
 Main data type (consensus features) More...
 
typedef LayerDataBase::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
 Main managed data type (consensus features) More...
 
typedef ExperimentType::SpectrumType SpectrumType
 Spectrum type. More...
 
typedef SpectrumType::ConstIterator SpectrumConstIteratorType
 Spectrum iterator type (iterates over peaks) More...
 
typedef SpectrumType::PeakType PeakType
 Peak type. More...
 
using RangeType = RangeAllType
 a generic range for the most common units More...
 
using AreaXYType = Area< 2 >::AreaXYType
 The range of data shown on the X and Y axis (unit depends on runtime config) More...
 
using VisibleArea = Area< 2 >
 The visible range of data on X and Y axis as shown on plot axis (not necessarily the range of actual data, e.g. no data to show). More...
 
using GenericArea = Area< 2 >
 A generic range of data on X and Y axis as shown on plot axis. More...
 
using PixelArea = Area< 2 >
 
using UnitRange = RangeAllType
 
using PointOnAxis = DimMapper< 2 >::Point
 

Public Slots

void activateLayer (Size layer_index) override
 
void removeLayer (Size layer_index) override
 
void updateLayer (Size i) override
 
void horizontalScrollBarChange (int value) override
 
- Public Slots inherited from PlotCanvas
void changeVisibility (Size i, bool b)
 change the visibility of a layer More...
 
void changeLayerFilterState (Size i, bool b)
 change if the defined data filters are used More...
 
void showGridLines (bool show)
 Whether or not to show grid lines. More...
 
void setVisibleArea (const VisibleArea &area)
 Sets the visible area. More...
 
void setVisibleArea (const RangeAllType &area)
 Sets the visible area. More...
 
void setVisibleArea (const AreaXYType &area)
 Sets the visible area. More...
 
void setVisibleAreaX (double min, double max)
 Set only the visible area for the x axis; other axes are untouched. More...
 
void setVisibleAreaY (double min, double max)
 Set only the visible area for the y axis; other axes are untouched. More...
 
void saveCurrentLayer (bool visible)
 Saves the current layer data. More...
 
virtual void horizontalScrollBarChange (int value)
 Notifies the canvas that the horizontal scrollbar has been moved. More...
 
virtual void verticalScrollBarChange (int value)
 Notifies the canvas that the vertical scrollbar has been moved. More...
 
void setAdditionalContextMenu (QMenu *menu)
 Sets the additional context menu. If not 0, this menu is added to the context menu of the canvas. More...
 
virtual void updateLayer (Size i)=0
 Updates layer i when the data in the corresponding file changes. More...
 
AreaXYType canvasPixelArea () const
 Get the Area in pixel coordinates of the current canvas for X and Y axis. More...
 
const DimMapper< 2 > & getMapper () const
 Get Mapper to translate between values for axis (X/Y) and units (m/z, RT, intensity, ...) More...
 
void setMapper (const DimMapper< 2 > &mapper)
 Set a new mapper for the canvas. More...
 

Signals

void showCurrentPeaksAs2D ()
 Requests to display all spectra in 2D plot. More...
 
void showCurrentPeaksAs3D ()
 Requests to display all spectra in 3D plot. More...
 
void showCurrentPeaksAsIonMobility (const MSSpectrum &spec)
 Requests to display this spectrum (=frame) in ion mobility plot. More...
 
void showCurrentPeaksAsDIA (const Precursor &pc, const MSExperiment &exp)
 Requests to display all spectra as DIA. More...
 
- Signals inherited from PlotCanvas
void layerModficationChange (Size layer, bool modified)
 Signal emitted whenever the modification status of a layer changes (editing and storing) More...
 
void layerActivated (QWidget *w)
 Signal emitted whenever a new layer is activated within the current window. More...
 
void layerZoomChanged (QWidget *w)
 Signal emitted whenever the zoom changed. More...
 
void visibleAreaChanged (const VisibleArea &area)
 Change of the visible area. More...
 
void sendCursorStatus (const String &x_value, const String &y_value)
 Emitted when the cursor position changes (for displaying e.g. in status bar) More...
 
void sendStatusMessage (std::string message, OpenMS::UInt time)
 Emits a status message that should be displayed for time ms. If time is 0 the message should be displayed until the next message is emitted. More...
 
void recalculateAxes ()
 Forces recalculation of axis ticks in the connected widget. More...
 
void updateVScrollbar (float f_min, float disp_min, float disp_max, float f_max)
 Triggers the update of the vertical scrollbar. More...
 
void updateHScrollbar (float f_min, float disp_min, float disp_max, float f_max)
 Triggers the update of the horizontal scrollbar. More...
 
void changeLegendVisibility ()
 Toggle axis legend visibility change. More...
 
void actionModeChange ()
 Emitted when the action mode changes. More...
 
void preferencesChange ()
 Emitted when the layer preferences have changed. More...
 

Public Member Functions

 Plot1DCanvas (const Param &preferences, const DIM gravity_axis=DIM::Y, QWidget *parent=nullptr)
 Default constructor. More...
 
 ~Plot1DCanvas () override
 Destructor. More...
 
const LayerData1DBasegetLayer (Size index) const
 
LayerData1DBasegetLayer (Size index)
 
const LayerData1DBasegetCurrentLayer () const
 
LayerData1DBasegetCurrentLayer ()
 
const DimBasegetGravityDim () const
 Get the dimension on which gravity is currently acting upon (usually it's the Y axis' unit) More...
 
const DimBasegetNonGravityDim () const
 Get the dimension on which gravity is currently not acting upon (the orthogonal axis; usually it's the X axis' unit) More...
 
bool addChromLayer (ExperimentSharedPtrType chrom_exp_sptr, ODExperimentSharedPtrType ondisc_sptr, OSWDataSharedPtrType chrom_annotation, const int index, const String &filename, const String &basename, const String &basename_extra)
 
DrawModes getDrawMode () const
 Returns the draw mode of the current layer. More...
 
void setDrawMode (DrawModes mode)
 Sets draw mode of the current layer. More...
 
void showCurrentLayerPreferences () override
 Shows the preferences dialog of the active layer. More...
 
bool flippedLayersExist ()
 Returns whether flipped layers exist or not. More...
 
void flipLayer (Size index)
 Flips the layer with index up/downwards. More...
 
bool mirrorModeActive () const
 Returns whether this widget is currently in mirror mode. More...
 
void setMirrorModeActive (bool b)
 Sets whether this widget is currently in mirror mode. More...
 
void dataToWidget (const DPosition< 2 > &peak, QPoint &point, bool flipped=false)
 For convenience - calls dataToWidget. More...
 
void dataToWidget (const DPosition< 2 > &xy_point, DPosition< 2 > &point, bool flipped)
 For convenience - calls dataToWidget. More...
 
void dataToWidget (double x, double y, QPoint &point, bool flipped=false)
 Calls PlotCanvas::dataToWidget_(), takes mirror mode into account. More...
 
PointXYType widgetToData (const QPoint &pos)
 For convenience - calls widgetToData. More...
 
PointXYType widgetToData (double x, double y)
 Calls PlotCanvas::widgetToData_(), takes mirror mode into account. More...
 
void dataToWidgetDistance (double x, double y, QPoint &point)
 converts a distance in axis values to pixel values More...
 
PointXYType widgetToDataDistance (double x, double y)
 compute distance in data coordinates (unit axis as shown) when moving x/y pixel in chart/widget coordinates More...
 
virtual const RangeTypegetDataRange () const override
 overload to call the 1D version (which has min-intensity of '0') More...
 
template<class T >
void pushIntoDataRange (T &data_point, const int layer_index)
 Pushes a data point back into the valid data range of the current layer area. Useful for annotation items which were mouse-dragged outside the range by the user. More...
 
void pushIntoDataRange (PointXYType &xy_unit, const int layer_index)
 Pushes a data point back into the valid data range of the current layer area. Useful for annotation items which were mouse-dragged outside the range by the user. More...
 
void setTextBox (const QString &html)
 Display a static text box on the top right. More...
 
Annotation1DItemaddPeakAnnotation (const PeakIndex &peak_index, const QString &text, const QColor &color)
 --— Annotations More...
 
void performAlignment (Size layer_index_1, Size layer_index_2, const Param &param)
 
void resetAlignment ()
 Resets alignment_. More...
 
Size getAlignmentSize ()
 Returns the number of aligned pairs of peaks. More...
 
double getAlignmentScore () const
 Returns the score of the alignment. More...
 
std::vector< std::pair< Size, Size > > getAlignedPeaksIndices ()
 Returns aligned_peaks_indices_. More...
 
void activateSpectrum (Size index, bool repaint=true)
 Sets current spectrum index of current layer to index. More...
 
void setCurrentLayerPeakPenStyle (Qt::PenStyle ps)
 Set's the Qt PenStyle of the active layer. More...
 
void paint (QPainter *paint_device, QPaintEvent *e)
 Actual painting takes place here. More...
 
void setDrawInterestingMZs (bool enable)
 interesting (e.g., high-intensity) get live annotated with m/s's More...
 
bool isDrawInterestingMZs () const
 Return true if interesting m/s are annotated. More...
 
void setIonLadderVisible (bool show)
 
bool isIonLadderVisible () const
 
const GravitatorgetGravitator () const
 Get gravity manipulation object to apply gravity to points. More...
 
- Public Member Functions inherited from PlotCanvas
 PlotCanvas (const Param &preferences, QWidget *parent=nullptr)
 Default constructor. More...
 
 ~PlotCanvas () override
 Destructor. More...
 
void setPlotWidget (PlotWidget *widget)
 Sets the spectrum widget. More...
 
PlotWidgetgetPlotWidget () const
 Returns the spectrum widget. More...
 
Int getActionMode () const
 Returns the action mode. More...
 
IntensityModes getIntensityMode () const
 Returns the intensity mode. More...
 
void setIntensityMode (IntensityModes mod)
 Sets the intensity mode. More...
 
bool gridLinesShown () const
 Returns if the grid is currently shown. More...
 
const LayerDataBasegetLayer (Size index) const
 returns the layer data with index index More...
 
LayerDataBasegetLayer (Size index)
 returns the layer data with index index More...
 
const LayerDataBasegetCurrentLayer () const
 returns the layer data of the active layer More...
 
LayerDataBasegetCurrentLayer ()
 returns the layer data of the active layer More...
 
Size getCurrentLayerIndex () const
 returns the index of the active layer More...
 
bool getLayerFlag (LayerDataBase::Flags f) const
 returns a layer flag of the current layer More...
 
void setLayerFlag (LayerDataBase::Flags f, bool value)
 sets a layer flag of the current layer More...
 
bool getLayerFlag (Size layer, LayerDataBase::Flags f) const
 returns a layer flag of the layer layer More...
 
void setLayerFlag (Size layer, LayerDataBase::Flags f, bool value)
 sets a layer flag of the layer layer More...
 
void setLabel (LayerDataBase::LabelType label)
 
const VisibleAreagetVisibleArea () const
 Returns the currently visible area. This is the authority which determines the X and Y axis' scale. More...
 
bool isVisible (const PointOnAxis &p) const
 
PixelArea getPixelRange () const
 
virtual void setFilters (const DataFilters &filters)
 Sets the filters applied to the data before drawing (for the current layer) More...
 
Size getLayerCount () const
 Returns the number of layers. More...
 
virtual void activateLayer (Size layer_index)=0
 change the active layer (the one that is used for selecting and so on) More...
 
virtual void removeLayer (Size layer_index)=0
 removes the layer with index layer_index More...
 
void removeLayers ()
 removes all layers by calling removeLayer() for all layer indices (from highest to lowest) More...
 
bool addLayer (std::unique_ptr< LayerData1DBase > layer)
 Add an already constructed layer (e.g. for projections) More...
 
bool addPeakLayer (const ExperimentSharedPtrType &map, ODExperimentSharedPtrType od_map, const String &filename="", const String &caption="", const bool use_noise_cutoff=false)
 Add a peak data layer. More...
 
bool addChromLayer (const ExperimentSharedPtrType &map, ODExperimentSharedPtrType od_map, const String &filename="", const String &caption="")
 Add a chrom data layer. More...
 
bool addLayer (FeatureMapSharedPtrType map, const String &filename="", const String &caption="")
 Add a feature data layer. More...
 
bool addLayer (ConsensusMapSharedPtrType map, const String &filename="", const String &caption="")
 Add a consensus feature data layer. More...
 
bool addLayer (std::vector< PeptideIdentification > &peptides, const String &filename="", const String &caption="")
 Add an identification data layer. More...
 
float getCurrentMinIntensity () const
 Returns the minimum intensity of the active layer. More...
 
float getCurrentMaxIntensity () const
 Returns the maximum intensity of the active layer. More...
 
float getMinIntensity (Size index) const
 Returns the minimum intensity of the layer with index index. More...
 
float getMaxIntensity (Size index) const
 Returns the maximum intensity of the layer with index index. More...
 
void setLayerName (Size i, const String &name)
 Sets the name of layer i. More...
 
String getLayerName (Size i)
 Gets the name of layer i. More...
 
void setCurrentLayerParameters (const Param &param)
 Sets the parameters of the current layer. More...
 
double getSnapFactor ()
 Returns the first intensity scaling factor for 'snap to maximum intensity mode' (for the currently visible data range). More...
 
double getPercentageFactor () const
 Returns the percentage factor. More...
 
virtual void showMetaData (bool modifiable=false, Int index=-1)
 Shows a dialog with the meta data. More...
 
- Public Member Functions inherited from DefaultParamHandler
 DefaultParamHandler (const String &name)
 Constructor with name that is displayed in error messages. More...
 
 DefaultParamHandler (const DefaultParamHandler &rhs)
 Copy constructor. More...
 
virtual ~DefaultParamHandler ()
 Destructor. More...
 
DefaultParamHandleroperator= (const DefaultParamHandler &rhs)
 Assignment operator. More...
 
virtual bool operator== (const DefaultParamHandler &rhs) const
 Equality operator. More...
 
void setParameters (const Param &param)
 Sets the parameters. More...
 
const ParamgetParameters () const
 Non-mutable access to the parameters. More...
 
const ParamgetDefaults () const
 Non-mutable access to the default parameters. More...
 
const StringgetName () const
 Non-mutable access to the name. More...
 
void setName (const String &name)
 Mutable access to the name. More...
 
const std::vector< String > & getSubsections () const
 Non-mutable access to the registered subsections. More...
 

Static Public Attributes

constexpr static double TOP_MARGIN {1.09}
 extra empty margin added on top to ensure annotations and 100% y-axis label are properly drawn More...
 

Protected Slots

void currentLayerParamtersChanged_ ()
 Reacts on changed layer parameters. More...
 
- Protected Slots inherited from PlotCanvas
void updateCursor_ ()
 Updates the cursor according to the current action mode. More...
 

Protected Member Functions

void dataToWidget_ (double x, double y, QPoint &point)
 Convert chart to widget coordinates. More...
 
void dataToWidget_ (const DPosition< 2 > &xy, QPoint &point)
 
QPoint dataToWidget_ (const DPosition< 2 > &xy)
 
bool finishAdding_ () override
 Method that is called when a new layer has been added. More...
 
void drawCoordinates_ (QPainter &painter, const PeakIndex &peak)
 Draws the coordinates (or coordinate deltas) to the widget's upper left corner. More...
 
void drawDeltas_ (QPainter &painter, const PeakIndex &start, const PeakIndex &end)
 Draws the coordinates (or coordinate deltas) to the widget's upper left corner. More...
 
void drawAlignment_ (QPainter &painter)
 Draws the alignment on painter. More...
 
void changeVisibleArea1D_ (const UnitRange &new_area, bool repaint, bool add_to_stack)
 internal method, called before calling parent function PlotCanvas::changeVisibleArea_ More...
 
void changeVisibleArea_ (VisibleArea new_area, bool repaint=true, bool add_to_stack=false) override
 Sets the visible area. More...
 
void changeVisibleArea_ (const AreaXYType &new_area, bool repaint=true, bool add_to_stack=false)
 Changes visible area interval. More...
 
void changeVisibleArea_ (const UnitRange &new_area, bool repaint=true, bool add_to_stack=false)
 Changes visible area interval. More...
 
void drawHighlightedPeak_ (Size layer_index, const PeakIndex &peak, QPainter &painter, bool draw_elongation=false)
 Draws a highlighted peak; if draw_elongation is true, the elongation line is drawn (for measuring) More...
 
void resetZoom (bool repaint=true) override
 Zooms fully out and resets the zoom stack. More...
 
void recalculatePercentageFactor_ (Size layer_index)
 Recalculates the current scale factor based on the specified layer (= 1.0 if intensity mode != IM_PERCENTAGE) More...
 
void recalculateRanges_ () override
 Recalculates the overall_data_range_ (by calling PlotCanvas::recalculateRanges_) plus the overall_data_range_1d_ (which only takes into account the current spec/chrom/.. of all layers) More...
 
void updateScrollbars_ () override
 Updates the scroll bars. More...
 
void intensityModeChange_ () override
 This method is called whenever the intensity mode changes. Reimplement if you need to react on such changes. More...
 
RangeAllType correctGravityAxisOfVisibleArea_ (UnitRange area)
 
- Protected Member Functions inherited from PlotCanvas
void resizeEvent (QResizeEvent *e) override
 
void wheelEvent (QWheelEvent *e) override
 
void keyPressEvent (QKeyEvent *e) override
 
void keyReleaseEvent (QKeyEvent *e) override
 
void focusOutEvent (QFocusEvent *e) override
 
void leaveEvent (QEvent *e) override
 
void enterEvent (QEvent *e) override
 
void dimensionsChanged_ ()
 Call this whenever the DimMapper receives new dimensions; will update the axes and scrollbars. More...
 
virtual void recalculateSnapFactor_ ()
 Recalculates the intensity scaling factor for 'snap to maximum intensity mode'. More...
 
void zoomBack_ ()
 Go backward in zoom history. More...
 
void zoomAdd_ (const VisibleArea &area)
 Add a visible area to the zoom stack. More...
 
void zoomClear_ ()
 Clears the zoom stack and invalidates the current zoom position. After calling this, a valid zoom position has to be added immediately. More...
 
PointXYType widgetToData_ (double x, double y)
 Convert widget (pixel) to chart (unit) coordinates. More...
 
PointXYType widgetToData_ (const QPoint &pos)
 Calls widgetToData_ with x and y position of pos. More...
 
virtual void update_ (const char *caller_name)
 Updates the displayed data. More...
 
void modificationStatus_ (Size layer_index, bool modified)
 Takes all actions necessary when the modification status of a layer changes (signals etc.) More...
 
void addDataProcessing_ (PeakMap &map, DataProcessing::ProcessingAction action) const
 Data processing setter for peak maps. More...
 
void drawText_ (QPainter &painter, const QStringList &text)
 Draws several lines of text to the upper right corner of the widget. More...
 
double getIdentificationMZ_ (const Size layer_index, const PeptideIdentification &peptide) const
 Returns the m/z value of an identification depending on the m/z source of the layer (precursor mass/theoretical peptide mass) More...
 
void popIncompleteLayer_ (const QString &error_message="")
 
- Protected Member Functions inherited from DefaultParamHandler
virtual void updateMembers_ ()
 This method is used to update extra member variables at the end of the setParameters() method. More...
 
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor. More...
 

Reimplemented QT events

class Painter1DChrom
 
class Painter1DPeak
 
class Painter1DIonMobility
 
RangeType overall_data_range_1d_
 The data range (m/z, RT and intensity) of the current(!) spec/chrom for all layers. More...
 
std::vector< DrawModesdraw_modes_
 Draw modes (for each layer) - sticks or connected lines. More...
 
std::vector< Qt::PenStyle > peak_penstyle_
 Draw style (for each layer) More...
 
QPoint measurement_start_point_px_
 start point of "ruler" in pixel coordinates for measure mode More...
 
bool mirror_mode_ = false
 Indicates whether this widget is currently in mirror mode. More...
 
bool moving_annotations_ = false
 Indicates whether annotation items are just being moved on the canvas. More...
 
bool show_alignment_ = false
 Indicates whether an alignment is currently visualized. More...
 
Size alignment_layer_1_
 Layer index of the first alignment layer. More...
 
Size alignment_layer_2_
 Layer index of the second alignment layer. More...
 
std::vector< std::pair< double, double > > aligned_peaks_mz_delta_
 Stores the alignment as MZ values of pairs of aligned peaks in both spectra. More...
 
std::vector< std::pair< Size, Size > > aligned_peaks_indices_
 Stores the peak indices of pairs of aligned peaks in both spectra. More...
 
double alignment_score_ = 0.0
 Stores the score of the last alignment. More...
 
bool ion_ladder_visible_ = true
 whether the ion ladder is displayed on the top right corner in ID view More...
 
bool draw_interesting_MZs_ = false
 annotate interesting peaks with m/z's More...
 
QTextDocument text_box_content_
 The text box in the upper left corner with the current data coordinates of the cursor. More...
 
Gravitator gr_
 handles pulling/pushing of points to the edges of the widget More...
 
void paintEvent (QPaintEvent *e) override
 
void mousePressEvent (QMouseEvent *e) override
 
void mouseReleaseEvent (QMouseEvent *e) override
 
void mouseMoveEvent (QMouseEvent *e) override
 
void keyPressEvent (QKeyEvent *e) override
 
void contextMenuEvent (QContextMenuEvent *e) override
 
void zoomForward_ () override
 Go forward in zoom history. More...
 
void zoom_ (int x, int y, bool zoom_in) override
 Zooms such that screen point x, y would still point to the same data point. More...
 
void translateLeft_ (Qt::KeyboardModifiers m) override
 Translation bound to the 'Left' key. More...
 
void translateRight_ (Qt::KeyboardModifiers m) override
 Translation bound to the 'Right' key. More...
 
void translateForward_ () override
 Translation bound to the 'Up' key. More...
 
void translateBackward_ () override
 Translation bound to the 'Down' key. More...
 
void paintGridLines_ (QPainter &painter) override
 Helper function to paint grid lines. More...
 
PeakIndex findPeakAtPosition_ (QPoint)
 Find peak next to the given position. More...
 
void addUserLabelAnnotation_ (const QPoint &screen_position)
 Shows dialog and calls addLabelAnnotation_. More...
 
void addLabelAnnotation_ (const QPoint &screen_position, const QString &label_text)
 Adds an annotation item at the given screen position. More...
 
void addUserPeakAnnotation_ (PeakIndex near_peak)
 Shows dialog and calls addPeakAnnotation_. More...
 
void ensureAnnotationsWithinDataRange_ ()
 Ensure that all annotations are within data range. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DefaultParamHandler
static void writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const String &key_prefix="")
 Writes all parameters to meta values. More...
 
- Protected Attributes inherited from PlotCanvas
QImage buffer_
 Buffer that stores the actual peak information. More...
 
DimMapper< 2 > unit_mapper_
 Mapper for X and Y axis. More...
 
ActionModes action_mode_ = AM_TRANSLATE
 Stores the current action mode (Pick, Zoom, Translate) More...
 
IntensityModes intensity_mode_ = IM_NONE
 Stores the used intensity mode function. More...
 
LayerStack layers_
 Layer data. More...
 
VisibleArea visible_area_
 Stores the currently visible area in data units (e.g. seconds, m/z, intensity etc) and axis (X,Y) area. More...
 
RangeType overall_data_range_
 Stores the data range (m/z, RT and intensity) of all layers. More...
 
bool show_grid_ = true
 Stores whether or not to show a grid. More...
 
std::vector< VisibleAreazoom_stack_
 The zoom stack. More...
 
std::vector< VisibleArea >::iterator zoom_pos_ = zoom_stack_.end()
 The current position in the zoom stack. More...
 
bool update_buffer_ = false
 Whether to recalculate the data in the buffer when repainting. More...
 
PlotWidgetspectrum_widget_ = nullptr
 Back-pointer to the enclosing spectrum widget. More...
 
QPoint last_mouse_pos_
 start position of mouse actions More...
 
double percentage_factor_ = 1.0
 Intensity scaling factor for relative scale with multiple layers. More...
 
std::vector< double > snap_factors_
 Intensity scaling factor for 'snap to maximum intensity mode'. More...
 
QRubberBand rubber_band_
 Rubber band for selected area. More...
 
QMenu * context_add_ = nullptr
 External context menu extension. More...
 
bool show_timing_ = false
 Flag that determines if timing data is printed to the command line. More...
 
PeakIndex selected_peak_
 selected peak More...
 
PeakIndex measurement_start_
 start peak of measuring mode More...
 
- Protected Attributes inherited from DefaultParamHandler
Param param_
 Container for current parameters. More...
 
Param defaults_
 Container for default parameters. This member should be filled in the constructor of derived classes! More...
 
std::vector< Stringsubsections_
 Container for registered subsections. This member should be filled in the constructor of derived classes! More...
 
String error_name_
 Name that is displayed in error messages during the parameter checking. More...
 
bool check_defaults_
 If this member is set to false no checking if parameters in done;. More...
 
bool warn_empty_defaults_
 If this member is set to false no warning is emitted when defaults are empty;. More...
 

Detailed Description

Canvas for visualization of one or several spectra.

The example image shows Plot1DCanvas displaying a raw data layer and a peak data layer.

Parameters of this class are:

NameTypeDefaultRestrictionsDescription
default_path string.  Default path for loading/storing data.
highlighted_peak_color string@#ff0000  Highlighted peak color.
icon_color string@#000000  Peak icon color.
peak_color string@#0000ff  Peak color.
annotation_color string@#000055  Annotation color.
background_color string@#ffffff  Background color.

Note:
  • If a section name is documented, the documentation is displayed as tooltip.
  • Advanced parameter names are italic.

Member Enumeration Documentation

◆ DrawModes

enum DrawModes

Enumerate all available paint styles.

Enumerator
DM_PEAKS 

draw data as peak

DM_CONNECTEDLINES 

draw as connected lines

◆ LabelMode

enum LabelMode

Label modes (percentage or absolute) of x axis and y axis.

Enumerator
LM_XABSOLUTE_YABSOLUTE 
LM_XPERCENT_YABSOLUTE 
LM_XABSOLUTE_YPERCENT 
LM_XPERCENT_YPERCENT 

Constructor & Destructor Documentation

◆ Plot1DCanvas()

Plot1DCanvas ( const Param preferences,
const DIM  gravity_axis = DIM::Y,
QWidget parent = nullptr 
)

Default constructor.

◆ ~Plot1DCanvas()

~Plot1DCanvas ( )
override

Destructor.

Member Function Documentation

◆ activateLayer

void activateLayer ( Size  layer_index)
overrideslot

◆ activateSpectrum()

void activateSpectrum ( Size  index,
bool  repaint = true 
)

Sets current spectrum index of current layer to index.

Referenced by TOPPViewBase::addData().

◆ addChromLayer()

bool addChromLayer ( ExperimentSharedPtrType  chrom_exp_sptr,
ODExperimentSharedPtrType  ondisc_sptr,
OSWDataSharedPtrType  chrom_annotation,
const int  index,
const String filename,
const String basename,
const String basename_extra 
)

add a chromatogram layer

Parameters
chrom_exp_sptrAn MSExperiment with chromatograms
ondisc_sptrOnDisk experiment, as fallback to read the chromatogram from, should chrom_exp_sptr.getChromatograms(index) be empty
chrom_annotationIf OSWData was loaded, pass the shared_pointer from the LayerData. Otherwise leave empty.
indexIndex of the chromatogram to show
filenameFor file change watcher (can be empty, if need be)
basenameName of layer (usually the basename of the file)
basename_extraOptional suffix of the layer name (e.g. a peptide sequence, or an index '[39]).
Returns
true on success, false if data was missing etc
Note
: this does NOT trigger layerActivated signal for efficiency-reasons. Do it manually afterwards!

◆ addLabelAnnotation_()

void addLabelAnnotation_ ( const QPoint &  screen_position,
const QString &  label_text 
)
protected

Adds an annotation item at the given screen position.

◆ addPeakAnnotation()

Annotation1DItem* addPeakAnnotation ( const PeakIndex peak_index,
const QString &  text,
const QColor &  color 
)

--— Annotations

Add an annotation item for the given peak

◆ addUserLabelAnnotation_()

void addUserLabelAnnotation_ ( const QPoint &  screen_position)
protected

Shows dialog and calls addLabelAnnotation_.

◆ addUserPeakAnnotation_()

void addUserPeakAnnotation_ ( PeakIndex  near_peak)
protected

Shows dialog and calls addPeakAnnotation_.

◆ changeVisibleArea1D_()

void changeVisibleArea1D_ ( const UnitRange new_area,
bool  repaint,
bool  add_to_stack 
)
protected

internal method, called before calling parent function PlotCanvas::changeVisibleArea_

◆ changeVisibleArea_() [1/3]

void changeVisibleArea_ ( const AreaXYType new_area,
bool  repaint = true,
bool  add_to_stack = false 
)
protected

Changes visible area interval.

This method is for convenience only. It calls changeVisibleArea_(const VisibleArea&, bool, bool) .

◆ changeVisibleArea_() [2/3]

void changeVisibleArea_ ( const UnitRange new_area,
bool  repaint = true,
bool  add_to_stack = false 
)
protected

Changes visible area interval.

This method is for convenience only. It calls changeVisibleArea_(const VisibleArea&, bool, bool) .

◆ changeVisibleArea_() [3/3]

void changeVisibleArea_ ( VisibleArea  new_area,
bool  repaint = true,
bool  add_to_stack = false 
)
overrideprotectedvirtual

Sets the visible area.

Changes the visible area, adjusts the zoom stack and notifies interested clients about the change. If the area is outside the overall data range, the new area is pushed back into the overall range.

Parameters
new_areaThe new visible area.
repaintIf true, a complete repaint is forced.
add_to_stackIf true the new area is to add to the zoom_stack_.

Reimplemented from PlotCanvas.

◆ contextMenuEvent()

void contextMenuEvent ( QContextMenuEvent *  e)
overrideprotected

◆ correctGravityAxisOfVisibleArea_()

RangeAllType correctGravityAxisOfVisibleArea_ ( UnitRange  area)
protected

Adjust the gravity axis (usually y-axis with intensity) according to the given range on the x-axis (since the user cannot freely choose the limits of this axis in 1D View)

◆ currentLayerParamtersChanged_

void currentLayerParamtersChanged_ ( )
protectedslot

Reacts on changed layer parameters.

◆ dataToWidget() [1/3]

void dataToWidget ( const DPosition< 2 > &  peak,
QPoint &  point,
bool  flipped = false 
)

For convenience - calls dataToWidget.

Referenced by Annotation1DCaret< DataPoint >::draw(), and Annotation1DPeakItem< DataPoint >::draw().

◆ dataToWidget() [2/3]

void dataToWidget ( const DPosition< 2 > &  xy_point,
DPosition< 2 > &  point,
bool  flipped 
)

For convenience - calls dataToWidget.

◆ dataToWidget() [3/3]

void dataToWidget ( double  x,
double  y,
QPoint &  point,
bool  flipped = false 
)

Calls PlotCanvas::dataToWidget_(), takes mirror mode into account.

◆ dataToWidget_() [1/3]

QPoint dataToWidget_ ( const DPosition< 2 > &  xy)
inlineprotected

◆ dataToWidget_() [2/3]

void dataToWidget_ ( const DPosition< 2 > &  xy,
QPoint &  point 
)
inlineprotected

◆ dataToWidget_() [3/3]

void dataToWidget_ ( double  x,
double  y,
QPoint &  point 
)
inlineprotected

Convert chart to widget coordinates.

Translates chart (unit) coordinates to widget (pixel) coordinates.

Parameters
xthe chart coordinate x
ythe chart coordinate y
pointreturned widget coordinates

References PlotCanvas::IM_LOG.

◆ dataToWidgetDistance()

void dataToWidgetDistance ( double  x,
double  y,
QPoint &  point 
)
inline

converts a distance in axis values to pixel values

◆ drawAlignment_()

void drawAlignment_ ( QPainter &  painter)
protected

Draws the alignment on painter.

◆ drawCoordinates_()

void drawCoordinates_ ( QPainter &  painter,
const PeakIndex peak 
)
protected

Draws the coordinates (or coordinate deltas) to the widget's upper left corner.

◆ drawDeltas_()

void drawDeltas_ ( QPainter &  painter,
const PeakIndex start,
const PeakIndex end 
)
protected

Draws the coordinates (or coordinate deltas) to the widget's upper left corner.

◆ drawHighlightedPeak_()

void drawHighlightedPeak_ ( Size  layer_index,
const PeakIndex peak,
QPainter &  painter,
bool  draw_elongation = false 
)
protected

Draws a highlighted peak; if draw_elongation is true, the elongation line is drawn (for measuring)

◆ ensureAnnotationsWithinDataRange_()

void ensureAnnotationsWithinDataRange_ ( )
protected

Ensure that all annotations are within data range.

◆ findPeakAtPosition_()

PeakIndex findPeakAtPosition_ ( QPoint  )
protected

Find peak next to the given position.

◆ finishAdding_()

bool finishAdding_ ( )
overrideprotectedvirtual

Method that is called when a new layer has been added.

Implements PlotCanvas.

◆ flipLayer()

void flipLayer ( Size  index)

Flips the layer with index up/downwards.

◆ flippedLayersExist()

bool flippedLayersExist ( )

Returns whether flipped layers exist or not.

◆ getAlignedPeaksIndices()

std::vector<std::pair<Size, Size> > getAlignedPeaksIndices ( )

Returns aligned_peaks_indices_.

◆ getAlignmentScore()

double getAlignmentScore ( ) const

Returns the score of the alignment.

Referenced by TOPPViewBase::showSpectrumAlignmentDialog().

◆ getAlignmentSize()

Size getAlignmentSize ( )

Returns the number of aligned pairs of peaks.

Referenced by TOPPViewBase::showSpectrumAlignmentDialog().

◆ getCurrentLayer() [1/2]

LayerData1DBase& getCurrentLayer ( )

returns the layer data of the active layer

Exceptions
std::bad_castexception if the current layer is not a LayerData1DBase

◆ getCurrentLayer() [2/2]

const LayerData1DBase& getCurrentLayer ( ) const

returns the layer data of the active layer

Exceptions
std::bad_castexception if the current layer is not a LayerData1DBase

◆ getDataRange()

virtual const RangeType& getDataRange ( ) const
inlineoverridevirtual

overload to call the 1D version (which has min-intensity of '0')

Reimplemented from PlotCanvas.

◆ getDrawMode()

DrawModes getDrawMode ( ) const

Returns the draw mode of the current layer.

Referenced by TOPPViewBase::updateToolBar().

◆ getGravitator()

const Gravitator& getGravitator ( ) const
inline

Get gravity manipulation object to apply gravity to points.

Returns
Gravitator

Referenced by Annotation1DPeakItem< DataPoint >::draw().

◆ getGravityDim()

const DimBase& getGravityDim ( ) const

Get the dimension on which gravity is currently acting upon (usually it's the Y axis' unit)

◆ getLayer() [1/2]

LayerData1DBase& getLayer ( Size  index)

returns the layer data of the layer index

Exceptions
std::bad_castexception if the current layer is not a LayerData1DBase

◆ getLayer() [2/2]

const LayerData1DBase& getLayer ( Size  index) const

returns the layer data of the layer index

Exceptions
std::bad_castexception if the current layer is not a LayerData1DBase

◆ getNonGravityDim()

const DimBase& getNonGravityDim ( ) const

Get the dimension on which gravity is currently not acting upon (the orthogonal axis; usually it's the X axis' unit)

◆ horizontalScrollBarChange

void horizontalScrollBarChange ( int  value)
overrideslot

◆ intensityModeChange_()

void intensityModeChange_ ( )
overrideprotectedvirtual

This method is called whenever the intensity mode changes. Reimplement if you need to react on such changes.

Reimplemented from PlotCanvas.

◆ isDrawInterestingMZs()

bool isDrawInterestingMZs ( ) const

Return true if interesting m/s are annotated.

◆ isIonLadderVisible()

bool isIonLadderVisible ( ) const

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent *  e)
overrideprotected

◆ mirrorModeActive()

bool mirrorModeActive ( ) const

Returns whether this widget is currently in mirror mode.

Referenced by TOPPViewBase::showSpectrumAlignmentDialog().

◆ mouseMoveEvent()

void mouseMoveEvent ( QMouseEvent *  e)
overrideprotected

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent *  e)
overrideprotected

◆ mouseReleaseEvent()

void mouseReleaseEvent ( QMouseEvent *  e)
overrideprotected

◆ paint()

void paint ( QPainter *  paint_device,
QPaintEvent *  e 
)

Actual painting takes place here.

◆ paintEvent()

void paintEvent ( QPaintEvent *  e)
overrideprotected

◆ paintGridLines_()

void paintGridLines_ ( QPainter &  painter)
overrideprotectedvirtual

Helper function to paint grid lines.

Reimplemented from PlotCanvas.

◆ performAlignment()

void performAlignment ( Size  layer_index_1,
Size  layer_index_2,
const Param param 
)

--— Alignment Performs an alignment of the layers with layer_index_1 and layer_index_2

◆ pushIntoDataRange() [1/2]

void pushIntoDataRange ( PointXYType xy_unit,
const int  layer_index 
)
inline

Pushes a data point back into the valid data range of the current layer area. Useful for annotation items which were mouse-dragged outside the range by the user.

Parameters
xy_unitA pair (X and Y coordinate) with values in the units currently used on the axis
layer_indexThe layer of the above data_point (to obtain the data range of the layer)

◆ pushIntoDataRange() [2/2]

void pushIntoDataRange ( T &  data_point,
const int  layer_index 
)
inline

Pushes a data point back into the valid data range of the current layer area. Useful for annotation items which were mouse-dragged outside the range by the user.

Template Parameters
TA data point, e.g. Peak1D, which may be outside the data area
Parameters
data_point
layer_indexThe layer of the above data_point (to obtain the data range of the layer)

Referenced by Annotation1DCaret< DataPoint >::ensureWithinDataRange(), and Annotation1DPeakItem< DataPoint >::ensureWithinDataRange().

◆ recalculatePercentageFactor_()

void recalculatePercentageFactor_ ( Size  layer_index)
protected

Recalculates the current scale factor based on the specified layer (= 1.0 if intensity mode != IM_PERCENTAGE)

◆ recalculateRanges_()

void recalculateRanges_ ( )
inlineoverrideprotectedvirtual

Recalculates the overall_data_range_ (by calling PlotCanvas::recalculateRanges_) plus the overall_data_range_1d_ (which only takes into account the current spec/chrom/.. of all layers)

A small margin is added to each side of the range in order to display all data.

Reimplemented from PlotCanvas.

References RangeManager< RangeBases >::clearRanges(), RangeManager< RangeBases >::extend(), RangeManager< RangeBases >::minSpanIfSingular(), PlotCanvas::recalculateRanges_(), and RangeManager< RangeBases >::scaleBy().

◆ removeLayer

void removeLayer ( Size  layer_index)
overrideslot

◆ resetAlignment()

void resetAlignment ( )

Resets alignment_.

◆ resetZoom()

void resetZoom ( bool  repaint = true)
inlineoverrideprotectedvirtual

Zooms fully out and resets the zoom stack.

Sets the visible area to the initial value, such that all data (for the current spec/chrom/...) is shown.

Parameters
repaintIf true a repaint is forced. Otherwise only the new area is set.

Reimplemented from PlotCanvas.

References PlotCanvas::changeVisibleArea_().

◆ setCurrentLayerPeakPenStyle()

void setCurrentLayerPeakPenStyle ( Qt::PenStyle  ps)

Set's the Qt PenStyle of the active layer.

◆ setDrawInterestingMZs()

void setDrawInterestingMZs ( bool  enable)

interesting (e.g., high-intensity) get live annotated with m/s's

◆ setDrawMode()

void setDrawMode ( DrawModes  mode)

Sets draw mode of the current layer.

Referenced by TOPPViewBase::setDrawMode1D().

◆ setIonLadderVisible()

void setIonLadderVisible ( bool  show)

◆ setMirrorModeActive()

void setMirrorModeActive ( bool  b)

Sets whether this widget is currently in mirror mode.

◆ setTextBox()

void setTextBox ( const QString &  html)

Display a static text box on the top right.

◆ showCurrentLayerPreferences()

void showCurrentLayerPreferences ( )
overridevirtual

Shows the preferences dialog of the active layer.

Implements PlotCanvas.

◆ showCurrentPeaksAs2D

void showCurrentPeaksAs2D ( )
signal

Requests to display all spectra in 2D plot.

◆ showCurrentPeaksAs3D

void showCurrentPeaksAs3D ( )
signal

Requests to display all spectra in 3D plot.

◆ showCurrentPeaksAsDIA

void showCurrentPeaksAsDIA ( const Precursor pc,
const MSExperiment exp 
)
signal

Requests to display all spectra as DIA.

◆ showCurrentPeaksAsIonMobility

void showCurrentPeaksAsIonMobility ( const MSSpectrum spec)
signal

Requests to display this spectrum (=frame) in ion mobility plot.

◆ translateBackward_()

void translateBackward_ ( )
overrideprotectedvirtual

Translation bound to the 'Down' key.

Reimplemented from PlotCanvas.

◆ translateForward_()

void translateForward_ ( )
overrideprotectedvirtual

Translation bound to the 'Up' key.

Reimplemented from PlotCanvas.

◆ translateLeft_()

void translateLeft_ ( Qt::KeyboardModifiers  m)
overrideprotectedvirtual

Translation bound to the 'Left' key.

Reimplemented from PlotCanvas.

◆ translateRight_()

void translateRight_ ( Qt::KeyboardModifiers  m)
overrideprotectedvirtual

Translation bound to the 'Right' key.

Reimplemented from PlotCanvas.

◆ updateLayer

void updateLayer ( Size  i)
overrideslot

◆ updateScrollbars_()

void updateScrollbars_ ( )
overrideprotectedvirtual

Updates the scroll bars.

Updates the scrollbars after a change of the visible area.

Reimplemented from PlotCanvas.

◆ widgetToData() [1/2]

PointXYType widgetToData ( const QPoint &  pos)

For convenience - calls widgetToData.

Referenced by Plot1DCanvas::widgetToDataDistance().

◆ widgetToData() [2/2]

PointXYType widgetToData ( double  x,
double  y 
)

Calls PlotCanvas::widgetToData_(), takes mirror mode into account.

◆ widgetToDataDistance()

PointXYType widgetToDataDistance ( double  x,
double  y 
)
inline

compute distance in data coordinates (unit axis as shown) when moving x/y pixel in chart/widget coordinates

References Plot1DCanvas::widgetToData().

Referenced by Annotation1DPeakItem< DataPoint >::draw().

◆ zoom_()

void zoom_ ( int  x,
int  y,
bool  zoom_in 
)
overrideprotectedvirtual

Zooms such that screen point x, y would still point to the same data point.

Reimplemented from PlotCanvas.

◆ zoomForward_()

void zoomForward_ ( )
overrideprotectedvirtual

Go forward in zoom history.

Reimplemented from PlotCanvas.

Friends And Related Function Documentation

◆ Painter1DChrom

friend class Painter1DChrom
friend

◆ Painter1DIonMobility

friend class Painter1DIonMobility
friend

◆ Painter1DPeak

friend class Painter1DPeak
friend

Member Data Documentation

◆ aligned_peaks_indices_

std::vector<std::pair<Size, Size> > aligned_peaks_indices_
protected

Stores the peak indices of pairs of aligned peaks in both spectra.

◆ aligned_peaks_mz_delta_

std::vector<std::pair<double, double> > aligned_peaks_mz_delta_
protected

Stores the alignment as MZ values of pairs of aligned peaks in both spectra.

◆ alignment_layer_1_

Size alignment_layer_1_
protected

Layer index of the first alignment layer.

◆ alignment_layer_2_

Size alignment_layer_2_
protected

Layer index of the second alignment layer.

◆ alignment_score_

double alignment_score_ = 0.0
protected

Stores the score of the last alignment.

◆ draw_interesting_MZs_

bool draw_interesting_MZs_ = false
protected

annotate interesting peaks with m/z's

◆ draw_modes_

std::vector<DrawModes> draw_modes_
protected

Draw modes (for each layer) - sticks or connected lines.

◆ gr_

Gravitator gr_
protected

handles pulling/pushing of points to the edges of the widget

◆ ion_ladder_visible_

bool ion_ladder_visible_ = true
protected

whether the ion ladder is displayed on the top right corner in ID view

◆ measurement_start_point_px_

QPoint measurement_start_point_px_
protected

start point of "ruler" in pixel coordinates for measure mode

◆ mirror_mode_

bool mirror_mode_ = false
protected

Indicates whether this widget is currently in mirror mode.

◆ moving_annotations_

bool moving_annotations_ = false
protected

Indicates whether annotation items are just being moved on the canvas.

◆ overall_data_range_1d_

RangeType overall_data_range_1d_
protected

The data range (m/z, RT and intensity) of the current(!) spec/chrom for all layers.

◆ peak_penstyle_

std::vector<Qt::PenStyle> peak_penstyle_
protected

Draw style (for each layer)

◆ show_alignment_

bool show_alignment_ = false
protected

Indicates whether an alignment is currently visualized.

◆ text_box_content_

QTextDocument text_box_content_
protected

The text box in the upper left corner with the current data coordinates of the cursor.

◆ TOP_MARGIN

constexpr static double TOP_MARGIN {1.09}
staticconstexpr

extra empty margin added on top to ensure annotations and 100% y-axis label are properly drawn