Canvas for visualization of one or several spectra. More...
#include <OpenMS/VISUAL/Spectrum1DCanvas.h>
Public Types | |
| enum | LabelMode { LM_XABSOLUTE_YABSOLUTE, LM_XPERCENT_YABSOLUTE, LM_XABSOLUTE_YPERCENT, LM_XPERCENT_YPERCENT } |
Label modes (percentage or absolut) of x axis and y axis. More... | |
| enum | DrawModes { DM_PEAKS, DM_CONNECTEDLINES } |
Enumerate all avaiable paint styles. More... | |
Public Slots | |
| void | activateLayer (Size layer_index) |
| change the active layer (the one that is used for selecting and so on) | |
| void | removeLayer (Size layer_index) |
removes the layer with index layer_index | |
| virtual void | updateLayer (Size i) |
Updates layer i when the data in the corresponding file changes. | |
| void | setVisibleArea (DRange< 2 > range) |
| Sets the visible area. | |
| virtual void | horizontalScrollBarChange (int value) |
| Notifies the canvas that the horizontal scollbar has been moved. | |
Signals | |
| void | showCurrentPeaksAs2D () |
| Requests to display all spectra in 2D plot. | |
| void | showCurrentPeaksAs3D () |
| Requests to display all spectra in 3D plot. | |
Public Member Functions | |
| Spectrum1DCanvas (const Param &preferences, QWidget *parent=0) | |
| Default constructor. | |
| virtual | ~Spectrum1DCanvas () |
| Destructor. | |
| DrawModes | getDrawMode () const |
| Returns the draw mode of the current layer. | |
| void | setDrawMode (DrawModes mode) |
| Sets draw mode of the current layer. | |
| virtual void | showCurrentLayerPreferences () |
| Shows the preferences dialog of the active layer. | |
| virtual void | saveCurrentLayer (bool visible) |
| Saves the current layer data. | |
| bool | flippedLayersExist () |
| Returns whether flipped layers exist or not. | |
| void | flipLayer (Size index) |
Flips the layer with index up/downwards. | |
| bool | mirrorModeActive () |
| Returns whether this widget is currently in mirror mode. | |
| void | setMirrorModeActive (bool b) |
| Sets whether this widget is currently in mirror mode. | |
| void | dataToWidget (const PeakType &peak, QPoint &point, bool flipped=false, bool percentage=true) |
| For convenience - calls dataToWidget. | |
| void | dataToWidget (DoubleReal x, DoubleReal y, QPoint &point, bool flipped=false, bool percentage=false) |
| Calls SpectrumCanvas::dataToWidget_(), takes mirror mode into account. | |
| PointType | widgetToData (const QPoint &pos, bool percentage=false) |
| For convenience - calls widgetToData. | |
| PointType | widgetToData (DoubleReal x, DoubleReal y, bool percentage=false) |
| Calls SpectrumCanvas::widgetToData_(), takes mirror mode into account. | |
| Annotation1DItem * | addPeakAnnotation (PeakIndex peak_index, QString text, QColor color) |
| ----- Annotations | |
| void | drawAnnotations (Size layer_index, QPainter &painter) |
Draws all annotation items of layer_index on painter. | |
| void | performAlignment (Size layer_index_1, Size layer_index_2, const Param ¶m) |
| ----- Alignment | |
| void | resetAlignment () |
| Resets alignment_. | |
| void | drawAlignment (QPainter &painter) |
Draws the alignment on painter. | |
| Size | getAlignmentSize () |
| Returns the number of aligned pairs of peaks. | |
| DoubleReal | getAlignmentScore () |
| Returns the score of the alignment. | |
| std::vector< std::pair< Size, Size > > | getAlignedPeaksIndices () |
| Returns aligned_peaks_indices_. | |
| void | activateSpectrum (Size index, bool repaint=true) |
Sets current spectrum index of current layer to index. | |
| void | setSwappedAxis (bool swapped) |
| is the widget shown vertically? (for projections) | |
| void | setCurrentLayerPeakPenStyle (Qt::PenStyle ps) |
| Set's the Qt PenStyle of the active layer. | |
| void | paint (QPainter *paint_device, QPaintEvent *e) |
| Actual painting takes place here. | |
Protected Slots | |
| void | currentLayerParamtersChanged_ () |
| Reacts on changed layer paramters. | |
Protected Member Functions | |
| bool | finishAdding_ () |
| Method that is called when a new layer has been added. | |
| void | drawCoordinates_ (QPainter &painter, const PeakIndex &peak) |
| Draws the coordinates (or coordinate deltas) to the widget's upper left corner. | |
| void | drawDeltas_ (QPainter &painter, const PeakIndex &start, const PeakIndex &end) |
| Draws the coordinates (or coordinate deltas) to the widget's upper left corner. | |
| void | changeVisibleArea_ (double lo, double hi, bool repaint=true, bool add_to_stack=false) |
| Changes visible area interval. | |
| 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). | |
| void | drawDashedLine_ (const QPoint &from, const QPoint &to, QPainter &painter) |
| Draws a dashed line using the highlighted peak color parameter. | |
| void | updatePercentageFactor_ (Size layer_index) |
| Recalculates the current scale factor based on the specified layer (= 1.0 if intensity mode != IM_PERCENTAGE). | |
| virtual void | changeVisibleArea_ (const AreaType &new_area, bool repaint=true, bool add_to_stack=false) |
| Sets the visible area. | |
| virtual void | recalculateSnapFactor_ () |
| REcalculates the intensity scaling factor for 'snap to maximum intensity mode'. | |
| virtual void | updateScrollbars_ () |
| Updates the scroll bars. | |
| virtual void | intensityModeChange_ () |
| This method is called whenever the intensity mode changes. Reimplement if you need to react on such changes. | |
| PeakIndex | findPeakAtPosition_ (QPoint) |
| Find peak next to the given position. | |
| void | addUserLabelAnnotation_ (const QPoint &screen_position) |
| Shows dialog and calls addLabelAnnotation_. | |
| void | addLabelAnnotation_ (const QPoint &screen_position, QString label_text) |
| Adds an annotation item at the given screen position. | |
| void | addUserPeakAnnotation_ (PeakIndex near_peak) |
| Shows dialog and calls addPeakAnnotation_. | |
| void | ensureAnnotationsWithinDataRange_ () |
| Ensure that all annotations are within data range. | |
| virtual void | zoomForward_ () |
| Go forward in zoom history. | |
| virtual void | translateLeft_ () |
| Translation bound to the 'Left' key. | |
| virtual void | translateRight_ () |
| Translation bound to the 'Rightt' key. | |
| virtual void | paintGridLines_ (QPainter &painter) |
| Helper function to paint grid lines. | |
Reimplemented QT events | |
| void | paintEvent (QPaintEvent *e) |
| void | mousePressEvent (QMouseEvent *e) |
| void | mouseReleaseEvent (QMouseEvent *e) |
| void | mouseMoveEvent (QMouseEvent *e) |
| void | keyPressEvent (QKeyEvent *e) |
| void | contextMenuEvent (QContextMenuEvent *e) |
Protected Attributes | |
| std::vector< DrawModes > | draw_modes_ |
| Draw modes (for each spectrum). | |
| std::vector< Qt::PenStyle > | peak_penstyle_ |
| Draw style. | |
| QPoint | measurement_start_point_ |
| start point of "ruler" for measure mode | |
| bool | mirror_mode_ |
| Indicates whether this widget is currently in mirror mode. | |
| bool | moving_annotations_ |
| Indicates whether annotation items are just being moved on the canvas. | |
| bool | show_alignment_ |
| Indicates whether an alignment is currently visualized. | |
| Size | alignment_layer_1_ |
| Layer index of the first alignment layer. | |
| Size | alignment_layer_2_ |
| Layer index of the second alignment layer. | |
| std::vector< std::pair < DoubleReal, DoubleReal > > | aligned_peaks_mz_delta_ |
| Stores the alignment as MZ values of pairs of aligned peaks in both spectra. | |
| std::vector< std::pair< Size, Size > > | aligned_peaks_indices_ |
| Stores the peak indizes of pairs of aligned peaks in both spectra. | |
| DoubleReal | alignment_score_ |
| Stores the score of the last alignment. | |
| bool | is_swapped_ |
| is this widget showing data with swapped m/z and RT axis? (for drawCoordinates_ only) | |
Canvas for visualization of one or several spectra.
The example image shows Spectrum1DCanvas displaying a raw data layer and a peak data layer.
| Name | Type | Default | Restrictions | Description |
|---|---|---|---|---|
| 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. | |
| show_legend | string | false | Annotate each layer with its name on the canvas. |
| enum DrawModes |
| enum LabelMode |
| Spectrum1DCanvas | ( | const Param & | preferences, | |
| QWidget * | parent = 0 | |||
| ) |
Default constructor.
| virtual ~Spectrum1DCanvas | ( | ) | [virtual] |
Destructor.
| void activateLayer | ( | Size | layer_index | ) | [virtual, slot] |
change the active layer (the one that is used for selecting and so on)
Implements SpectrumCanvas.
| void activateSpectrum | ( | Size | index, | |
| bool | repaint = true | |||
| ) |
Sets current spectrum index of current layer to index.
Referenced by TOPPViewBase::addData().
| void addLabelAnnotation_ | ( | const QPoint & | screen_position, | |
| QString | label_text | |||
| ) | [protected] |
Adds an annotation item at the given screen position.
| Annotation1DItem* addPeakAnnotation | ( | PeakIndex | peak_index, | |
| QString | text, | |||
| QColor | color | |||
| ) |
----- Annotations
Add an annotation item for the given peak
| void addUserLabelAnnotation_ | ( | const QPoint & | screen_position | ) | [protected] |
Shows dialog and calls addLabelAnnotation_.
| void addUserPeakAnnotation_ | ( | PeakIndex | near_peak | ) | [protected] |
Shows dialog and calls addPeakAnnotation_.
| void changeVisibleArea_ | ( | double | lo, | |
| double | hi, | |||
| bool | repaint = true, |
|||
| bool | add_to_stack = false | |||
| ) | [protected] |
Changes visible area interval.
This method is for convenience only. It calls changeVisibleArea_(const AreaType&, bool, bool) .
| virtual void changeVisibleArea_ | ( | const AreaType & | new_area, | |
| bool | repaint = true, |
|||
| bool | add_to_stack = false | |||
| ) | [protected, virtual] |
Sets the visible area.
Changes the visible area, adjustes the zoom stack and notifies interested clients about the change. If parts of the area are outside of the data area, the new area will be adjusted.
| new_area | The new visible area. | |
| repaint | if repainting of the widget should ne triggered | |
| add_to_stack | If the new area is to add to the zoom_stack_ |
Reimplemented from SpectrumCanvas.
| void contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected] |
| void currentLayerParamtersChanged_ | ( | ) | [protected, slot] |
Reacts on changed layer paramters.
| void dataToWidget | ( | DoubleReal | x, | |
| DoubleReal | y, | |||
| QPoint & | point, | |||
| bool | flipped = false, |
|||
| bool | percentage = false | |||
| ) |
Calls SpectrumCanvas::dataToWidget_(), takes mirror mode into account.
| void dataToWidget | ( | const PeakType & | peak, | |
| QPoint & | point, | |||
| bool | flipped = false, |
|||
| bool | percentage = true | |||
| ) |
For convenience - calls dataToWidget.
| void drawAlignment | ( | QPainter & | painter | ) |
Draws the alignment on painter.
| void drawAnnotations | ( | Size | layer_index, | |
| QPainter & | painter | |||
| ) |
Draws all annotation items of layer_index on painter.
| void drawCoordinates_ | ( | QPainter & | painter, | |
| const PeakIndex & | peak | |||
| ) | [protected] |
Draws the coordinates (or coordinate deltas) to the widget's upper left corner.
| void drawDashedLine_ | ( | const QPoint & | from, | |
| const QPoint & | to, | |||
| QPainter & | painter | |||
| ) | [protected] |
Draws a dashed line using the highlighted peak color parameter.
Draws the coordinates (or coordinate deltas) to the widget's upper left corner.
| 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).
| void ensureAnnotationsWithinDataRange_ | ( | ) | [protected] |
Ensure that all annotations are within data range.
| PeakIndex findPeakAtPosition_ | ( | QPoint | ) | [protected] |
Find peak next to the given position.
| bool finishAdding_ | ( | ) | [protected, virtual] |
Method that is called when a new layer has been added.
Implements SpectrumCanvas.
| void flipLayer | ( | Size | index | ) |
Flips the layer with index up/downwards.
Referenced by TOPPViewBase::layerContextMenu().
| bool flippedLayersExist | ( | ) |
Returns whether flipped layers exist or not.
Referenced by TOPPViewBase::layerContextMenu().
| DoubleReal getAlignmentScore | ( | ) |
Returns the score of the alignment.
Referenced by TOPPViewBase::showSpectrumAlignmentDialog().
| Size getAlignmentSize | ( | ) |
Returns the number of aligned pairs of peaks.
Referenced by TOPPViewBase::showSpectrumAlignmentDialog().
| DrawModes getDrawMode | ( | ) | const |
Returns the draw mode of the current layer.
Referenced by TOPPViewBase::updateToolBar().
| virtual void horizontalScrollBarChange | ( | int | value | ) | [virtual, slot] |
Notifies the canvas that the horizontal scollbar has been moved.
Reimplement this slot to react on scrollbar events.
Reimplemented from SpectrumCanvas.
| virtual void intensityModeChange_ | ( | ) | [protected, virtual] |
This method is called whenever the intensity mode changes. Reimplement if you need to react on such changes.
Reimplemented from SpectrumCanvas.
| void keyPressEvent | ( | QKeyEvent * | e | ) | [protected] |
Reimplemented from SpectrumCanvas.
| bool mirrorModeActive | ( | ) |
Returns whether this widget is currently in mirror mode.
Referenced by TOPPViewBase::showSpectrumAlignmentDialog(), and TOPPViewBase::updateMenu().
| void mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected] |
| void mousePressEvent | ( | QMouseEvent * | e | ) | [protected] |
| void mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected] |
| void paint | ( | QPainter * | paint_device, | |
| QPaintEvent * | e | |||
| ) |
Actual painting takes place here.
| void paintEvent | ( | QPaintEvent * | e | ) | [protected] |
| virtual void paintGridLines_ | ( | QPainter & | painter | ) | [protected, virtual] |
Helper function to paint grid lines.
Reimplemented from SpectrumCanvas.
----- Alignment
Performs an alignment of the layers with layer_index_1 and layer_index_2
| virtual void recalculateSnapFactor_ | ( | ) | [protected, virtual] |
REcalculates the intensity scaling factor for 'snap to maximum intensity mode'.
Reimplemented from SpectrumCanvas.
| void removeLayer | ( | Size | layer_index | ) | [virtual, slot] |
removes the layer with index layer_index
Implements SpectrumCanvas.
| void resetAlignment | ( | ) |
Resets alignment_.
| virtual void saveCurrentLayer | ( | bool | visible | ) | [virtual] |
Saves the current layer data.
| visible | If true, only the visible data is stored. Otherwise the whole data is stored. |
Implements SpectrumCanvas.
| void setCurrentLayerPeakPenStyle | ( | Qt::PenStyle | ps | ) |
Set's the Qt PenStyle of the active layer.
| void setDrawMode | ( | DrawModes | mode | ) |
Sets draw mode of the current layer.
Referenced by TOPPViewBase::setDrawMode1D().
| void setMirrorModeActive | ( | bool | b | ) |
Sets whether this widget is currently in mirror mode.
Referenced by TOPPViewBase::layerContextMenu().
| void setSwappedAxis | ( | bool | swapped | ) |
is the widget shown vertically? (for projections)
| void setVisibleArea | ( | DRange< 2 > | range | ) | [slot] |
Sets the visible area.
Sets the visible area to a new value. Note that it does not emit visibleAreaChanged()
| range | the new visible area |
Reimplemented from SpectrumCanvas.
Referenced by IDEvaluationBase::setVisibleArea().
| virtual void showCurrentLayerPreferences | ( | ) | [virtual] |
Shows the preferences dialog of the active layer.
Implements SpectrumCanvas.
| void showCurrentPeaksAs2D | ( | ) | [signal] |
Requests to display all spectra in 2D plot.
| void showCurrentPeaksAs3D | ( | ) | [signal] |
Requests to display all spectra in 3D plot.
| virtual void translateLeft_ | ( | ) | [protected, virtual] |
Translation bound to the 'Left' key.
Reimplemented from SpectrumCanvas.
| virtual void translateRight_ | ( | ) | [protected, virtual] |
Translation bound to the 'Rightt' key.
Reimplemented from SpectrumCanvas.
| virtual void updateLayer | ( | Size | i | ) | [virtual, slot] |
Updates layer i when the data in the corresponding file changes.
Implements SpectrumCanvas.
| void updatePercentageFactor_ | ( | Size | layer_index | ) | [protected] |
Recalculates the current scale factor based on the specified layer (= 1.0 if intensity mode != IM_PERCENTAGE).
| virtual void updateScrollbars_ | ( | ) | [protected, virtual] |
Updates the scroll bars.
Updates the scrollbars after a change of the visible area.
Reimplemented from SpectrumCanvas.
| PointType widgetToData | ( | DoubleReal | x, | |
| DoubleReal | y, | |||
| bool | percentage = false | |||
| ) |
Calls SpectrumCanvas::widgetToData_(), takes mirror mode into account.
| PointType widgetToData | ( | const QPoint & | pos, | |
| bool | percentage = false | |||
| ) |
For convenience - calls widgetToData.
| virtual void zoomForward_ | ( | ) | [protected, virtual] |
Go forward in zoom history.
Reimplemented from SpectrumCanvas.
std::vector<std::pair<Size, Size> > aligned_peaks_indices_ [protected] |
Stores the peak indizes of pairs of aligned peaks in both spectra.
std::vector<std::pair<DoubleReal, DoubleReal> > aligned_peaks_mz_delta_ [protected] |
Stores the alignment as MZ values of pairs of aligned peaks in both spectra.
Size alignment_layer_1_ [protected] |
Layer index of the first alignment layer.
Size alignment_layer_2_ [protected] |
Layer index of the second alignment layer.
DoubleReal alignment_score_ [protected] |
Stores the score of the last alignment.
std::vector<DrawModes> draw_modes_ [protected] |
Draw modes (for each spectrum).
bool is_swapped_ [protected] |
is this widget showing data with swapped m/z and RT axis? (for drawCoordinates_ only)
QPoint measurement_start_point_ [protected] |
start point of "ruler" for measure mode
bool mirror_mode_ [protected] |
Indicates whether this widget is currently in mirror mode.
bool moving_annotations_ [protected] |
Indicates whether annotation items are just being moved on the canvas.
std::vector<Qt::PenStyle> peak_penstyle_ [protected] |
Draw style.
bool show_alignment_ [protected] |
Indicates whether an alignment is currently visualized.
| OpenMS / TOPP release 1.10.0 | Documentation generated on Thu Mar 7 2013 09:42:58 using doxygen 1.7.1 |