#include <OpenMS/VISUAL/SpectrumCanvas.h>
This class is the base class for the spectrum data views.
It also provides commonly used constants such as ActionModes or IntensityModes.
To provide additional spectrum views, you can derive from this class. You should also create a subclass from SpectrumWidget which encloses your class derived from SpectrumCanvas. To integrate your class into TOPPView, you also need to derive a class from SpectrumWidget.
Public Types | |
Type definitions | |
enum | ActionModes { AM_SELECT, AM_ZOOM } |
Mouse action modes. More... | |
enum | IntensityModes { IM_NONE, IM_PERCENTAGE, IM_SNAP } |
Display modes of intensity. More... | |
typedef LayerData::ExperimentType | ExperimentType |
Main data type (experiment). | |
typedef LayerData::FeatureMapType | FeatureMapType |
Main data type (features). | |
typedef ExperimentType::SpectrumType | SpectrumType |
Spectrum type. | |
typedef SpectrumType::Iterator | SpectrumIteratorType |
Spectrum iterator type (iterates over peaks). | |
typedef SpectrumType::PeakType | PeakType |
Peak type. | |
typedef FeatureMapType::FeatureType | FeatureType |
Feature type. | |
typedef DPosition< 2 > | PointType |
Type of the Points. | |
typedef DRange< 2 > | AreaType |
Types of Ranges/Areas. | |
Public Slots | |
void | changeVisibility (int i, bool b) |
change the visibility of a layer | |
void | showGridLines (bool show) |
Whether or not to show grid lines. | |
void | resetZoom () |
Zooms fully out. | |
void | setVisibleArea (AreaType area) |
Sets the visible area. | |
virtual void | horizontalScrollBarChange (int value) |
Notifies the canvas that the horizontal scollbar has been moved. | |
virtual void | verticalScrollBarChange (int value) |
Notifies the canvas that the vertical scollbar has been moved. | |
Signals | |
void | layerActivated (QWidget *w) |
Signal emitted whenever a new Layer is activated within the current window. | |
void | visibleAreaChanged (DRange< 2 > area) |
Change of the visible area. | |
void | sendCursorStatus (double mz=-1.0, double intens=-1.0, double rt=-1.0) |
Emited when the cursor position changes (for displaying in status bar). | |
void | sendStatusMessage (std::string, OpenMS::UInt) |
Displays a status message. See TOPPViewBase::showStatusMessage . | |
void | recalculateAxes () |
Forces recalculation of axis ticks in the connected widget. | |
void | updateVScrollbar (float, float, float, float) |
Triggers the update of the vertical scrollbar. | |
void | updateHScrollbar (float, float, float, float) |
Triggers the update of the horizontal scrollbar. | |
void | changeLegendVisibility () |
Toggle axis legend visibility change. | |
Public Member Functions | |
SpectrumCanvas (const Param &preferences, QWidget *parent=0) | |
Default constructor. | |
~SpectrumCanvas () | |
Destructor. | |
void | setSpectrumWidget (SpectrumWidget *widget) |
Sets the spectrum widget. | |
SpectrumWidget * | getSpectrumWidget () const |
Returns the spectrum widget. | |
Int | getActionMode () const |
Returns the action mode. | |
void | setActionMode (ActionModes mode) |
Sets the action mode. | |
Int | getIntensityMode () const |
Returns the intensity mode. | |
void | setIntensityMode (IntensityModes mod) |
Sets the intensity mode. | |
bool | gridLinesShown () const |
Returns if the grid is currently shown. | |
const LayerData & | getLayer (UInt index) const |
returns the layer data with index index | |
const LayerData & | getCurrentLayer () const |
returns the layer data of the active layer | |
bool | getLayerFlag (LayerData::Flags f) const |
returns a layer flag of the current layer | |
void | setLayerFlag (LayerData::Flags f, bool value) |
sets a layer flag of the current layer | |
bool | getLayerFlag (UInt layer, LayerData::Flags f) const |
returns a layer flag of the layer layer | |
void | setLayerFlag (UInt layer, LayerData::Flags f, bool value) |
sets a layer flag of the layer layer | |
const AreaType & | getVisibleArea () |
Returns the currently visible area. | |
virtual void | setFilters (const DataFilters &filters) |
Sets the filters applied to the data before drawing (for the current layer). | |
bool | isMzToXAxis () |
Returns the mapping of m/z to axes. | |
void | mzToXAxis (bool mz_to_x_axis) |
Sets the mapping of m/z to axes. | |
double | getCurrentMinIntensity () const |
Returns the minimum intensity of the active layer. | |
double | getCurrentMaxIntensity () const |
Returns the maximum intensity of the active layer. | |
double | getMinIntensity (UInt index) const |
Returns the minimum intensity of the layer with index index . | |
void | setLayerName (UInt i, const String &name) |
Sets the name of layer i . | |
void | setCurrentLayerParameters (const Param ¶m) |
Sets the parameters of the current layer. | |
double | getMaxIntensity (UInt index) const |
Returns the maximum intensity of the layer with index index . | |
const DRange< 3 > & | getDataRange () |
Returns the area which encloses all data points. | |
double | getSnapFactor () |
Returns the intensity scaling factor for 'snap to maximum intensity mode'. | |
virtual void | showCurrentLayerPreferences ()=0 |
Shows the preferences dialog of the active layer. | |
virtual void | saveCurrentLayer (bool visible)=0 |
Saves the current layer data. | |
Dataset handling methods | |
| |
UInt | getLayerCount () const |
Returns the number of layers. | |
UInt | activeLayerIndex () const |
Returns the index of the active layer. | |
virtual void | activateLayer (int layer_index)=0 |
change the active layer (the one that is used for selecting and so on) | |
virtual void | removeLayer (int layer_index)=0 |
removes the layer with index layer_index | |
ExperimentType & | addEmptyPeakLayer () |
Adds another peak layer to fill afterwards. | |
virtual Int | finishAdding ()=0 |
Finish adding data after call to addEmptyPeakLayer(). | |
Int | addLayer (const ExperimentType &) |
Add a peak data layer (data is copied). | |
Int | addLayer (const FeatureMapType &map, bool pairs) |
Add a feature data layer (data is copied). | |
Protected Member Functions | |
LayerData & | getLayer_ (UInt index) |
LayerData & | getCurrentLayer_ () |
ExperimentType & | currentPeakData_ () |
Returns the active layer (mutable). | |
void | resizeEvent (QResizeEvent *e) |
reimplemented QT event | |
virtual void | currentLayerParamtersChanged_ () |
Change of layer parameters. | |
virtual void | intensityModeChange_ () |
This method is called whenever the intensity mode changes. Reimplement if you need to react on such changes. | |
virtual void | changeVisibleArea_ (const AreaType &new_area, bool add_to_stack=false) |
Sets the visible area. | |
virtual void | recalculateSnapFactor_ () |
REcalculates the intensity scaling factor for 'snap to maximum intensity mode'. | |
void | zoomBack_ () |
Go back in zoom history. | |
virtual void | updateScrollbars_ () |
Updates the scroll bars. | |
PointType | widgetToData_ (float x, float y) |
Convert widget to chart coordinates. | |
PointType | widgetToData_ (const QPoint &pos) |
Calls widgetToData_(float, float) with x and y position of pos . | |
void | dataToWidget_ (float x, float y, QPoint &point) |
Convert chart to widget coordinates. | |
void | paintGridLines_ (QPainter &painter) |
Helper function to paint grid lines. | |
void | recalculateRanges_ (UInt mz_dim, UInt rt_dim, UInt it_dim) |
Recalculates the data range. | |
virtual void | update_ (const char *caller_name) |
Updates the diplayed data. | |
void | adjustBuffer_ () |
Changes the size of the paint buffer to the currently required size. | |
Protected Attributes | |
QPixmap | buffer_ |
Buffer that stores the actual peak information. | |
ActionModes | action_mode_ |
Stores the current action mode (Pick, Zoom, Translate). | |
IntensityModes | intensity_mode_ |
Stores the used intensity mode function. | |
std::vector< LayerData > | layers_ |
Layer data. | |
bool | mz_to_x_axis_ |
Stores the mapping of m/z. | |
AreaType | visible_area_ |
Stores the currently visible area. | |
DRange< 3 > | overall_data_range_ |
Stores the data range (m/z, RT and intensity) of all layers. | |
bool | show_grid_ |
Stores whether or not to show a grid. | |
std::stack< AreaType > | zoom_stack_ |
The zoom stack. This is dealt with in the changeVisibleArea_() and zoomBack_() functions. | |
bool | update_buffer_ |
Whether to recalculate the data in the buffer when repainting. | |
UInt | current_layer_ |
Stores the index of the currently active layer. | |
SpectrumWidget * | spectrum_widget_ |
Back-pointer to the enclosing spectrum widget. | |
QPoint | last_mouse_pos_ |
start position of mouse actions | |
double | percentage_factor_ |
Intensity scaling factor for relative scale with multiple layers. | |
double | snap_factor_ |
Intensity scaling factor for 'snap to maximum intensity mode'. | |
QRubberBand | rubber_band_ |
Rubber band for selected area. |
Main data type (experiment).
Main data type (features).
Spectrum type.
Spectrum iterator type (iterates over peaks).
typedef SpectrumType::PeakType PeakType |
Peak type.
Feature type.
enum ActionModes |
enum IntensityModes |
SpectrumCanvas | ( | const Param & | preferences, | |
QWidget * | parent = 0 | |||
) |
Default constructor.
~SpectrumCanvas | ( | ) |
Destructor.
void setSpectrumWidget | ( | SpectrumWidget * | widget | ) | [inline] |
Sets the spectrum widget.
Sets the enclosing spectrum widget. Call this from your SpectrumWidget derived class.
widget | the spectrum widget |
SpectrumWidget* getSpectrumWidget | ( | ) | const [inline] |
Returns the spectrum widget.
Returns the enclosing spectrum widget
Int getActionMode | ( | ) | const [inline] |
Returns the action mode.
Returns the current action mode of type ActionModes
void setActionMode | ( | ActionModes | mode | ) | [inline] |
Sets the action mode.
Sets the action mode for the left mouse button, e.g. zoom, translate etc.
mode | the new action mode. |
Int getIntensityMode | ( | ) | const [inline] |
Returns the intensity mode.
Returns the current intensity mode of type IntensityModes
void setIntensityMode | ( | IntensityModes | mod | ) | [inline] |
Sets the intensity mode.
Sets the intensity mode
mod | the new intensity mode |
bool gridLinesShown | ( | ) | const [inline] |
Returns if the grid is currently shown.
true
if the grid is visible, false
otherwise const LayerData& getCurrentLayer | ( | ) | const [inline] |
returns the layer data of the active layer
bool getLayerFlag | ( | LayerData::Flags | f | ) | const [inline] |
returns a layer flag of the current layer
void setLayerFlag | ( | LayerData::Flags | f, | |
bool | value | |||
) | [inline] |
sets a layer flag of the current layer
bool getLayerFlag | ( | UInt | layer, | |
LayerData::Flags | f | |||
) | const [inline] |
returns a layer flag of the layer layer
void setLayerFlag | ( | UInt | layer, | |
LayerData::Flags | f, | |||
bool | value | |||
) | [inline] |
sets a layer flag of the layer layer
const AreaType& getVisibleArea | ( | ) | [inline] |
Returns the currently visible area.
Dimension 0 is the m/z dimension. Dimension 1 is the RT dimension (not used in 1D).
virtual void setFilters | ( | const DataFilters & | filters | ) | [virtual] |
Sets the filters applied to the data before drawing (for the current layer).
bool isMzToXAxis | ( | ) |
Returns the mapping of m/z to axes.
void mzToXAxis | ( | bool | mz_to_x_axis | ) |
Sets the mapping of m/z to axes.
UInt getLayerCount | ( | ) | const [inline] |
Returns the number of layers.
UInt activeLayerIndex | ( | ) | const |
Returns the index of the active layer.
virtual void activateLayer | ( | int | layer_index | ) | [pure virtual] |
change the active layer (the one that is used for selecting and so on)
Implemented in Spectrum1DCanvas, Spectrum2DCanvas, and Spectrum3DCanvas.
virtual void removeLayer | ( | int | layer_index | ) | [pure virtual] |
removes the layer with index layer_index
Implemented in Spectrum1DCanvas, Spectrum2DCanvas, and Spectrum3DCanvas.
ExperimentType& addEmptyPeakLayer | ( | ) |
Adds another peak layer to fill afterwards.
Call finishAdding(float) after you filled the layer!
virtual Int finishAdding | ( | ) | [pure virtual] |
Finish adding data after call to addEmptyPeakLayer().
You can use this method instead of addLayer (add by copy). First call addEmptyPeakLayer(),then fill returned reference and finally call finishAdding(float).
Implemented in Spectrum1DCanvas, Spectrum2DCanvas, and Spectrum3DCanvas.
Int addLayer | ( | const ExperimentType & | ) |
Add a peak data layer (data is copied).
Int addLayer | ( | const FeatureMapType & | map, | |
bool | pairs | |||
) |
Add a feature data layer (data is copied).
pairs | Flag that indicates that a feature pair file was read. | |
map | Feature map |
double getCurrentMinIntensity | ( | ) | const [inline] |
Returns the minimum intensity of the active layer.
double getCurrentMaxIntensity | ( | ) | const [inline] |
Returns the maximum intensity of the active layer.
double getMinIntensity | ( | UInt | index | ) | const [inline] |
Returns the minimum intensity of the layer with index index
.
void setCurrentLayerParameters | ( | const Param & | param | ) | [inline] |
Sets the parameters of the current layer.
double getMaxIntensity | ( | UInt | index | ) | const [inline] |
Returns the maximum intensity of the layer with index index
.
const DRange<3>& getDataRange | ( | ) |
Returns the area which encloses all data points.
The order domensions is dependent on the derived class.
double getSnapFactor | ( | ) |
virtual void showCurrentLayerPreferences | ( | ) | [pure virtual] |
Shows the preferences dialog of the active layer.
Implemented in Spectrum1DCanvas, Spectrum2DCanvas, and Spectrum3DCanvas.
virtual void saveCurrentLayer | ( | bool | visible | ) | [pure virtual] |
Saves the current layer data.
visible | If true, only the visible data is stored. Otherwise the whole data is stored. |
Implemented in Spectrum1DCanvas, Spectrum2DCanvas, and Spectrum3DCanvas.
void changeVisibility | ( | int | i, | |
bool | b | |||
) | [slot] |
change the visibility of a layer
i | the index of the layer | |
b | true if layer is supposed to be visible |
void showGridLines | ( | bool | show | ) | [slot] |
Whether or not to show grid lines.
Sets whether grid lines are shown or not.
show | Boolean variable deciding whether or not to show the grid lines. |
void resetZoom | ( | ) | [slot] |
Zooms fully out.
Sets the visible area to the initial value, such that all data is shown.
void setVisibleArea | ( | AreaType | area | ) | [slot] |
Sets the visible area.
Sets the visible area to a new value. Note that it does not emit visibleAreaChanged()
area | the new visible area |
Reimplemented in Spectrum1DCanvas.
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 in Spectrum1DCanvas, and Spectrum2DCanvas.
virtual void verticalScrollBarChange | ( | int | value | ) | [virtual, slot] |
Notifies the canvas that the vertical scollbar has been moved.
Reimplement this slot to react on scrollbar events.
Reimplemented in Spectrum2DCanvas.
void layerActivated | ( | QWidget * | w | ) | [signal] |
Signal emitted whenever a new Layer is activated within the current window.
void visibleAreaChanged | ( | DRange< 2 > | area | ) | [signal] |
Change of the visible area.
Signal emitted whenever the visible area changes.
area | The new visible area. |
void sendCursorStatus | ( | double | mz = -1.0 , |
|
double | intens = -1.0 , |
|||
double | rt = -1.0 | |||
) | [signal] |
Emited when the cursor position changes (for displaying in status bar).
void sendStatusMessage | ( | std::string | , | |
OpenMS::UInt | ||||
) | [signal] |
Displays a status message. See TOPPViewBase::showStatusMessage .
void recalculateAxes | ( | ) | [signal] |
Forces recalculation of axis ticks in the connected widget.
void updateVScrollbar | ( | float | , | |
float | , | |||
float | , | |||
float | ||||
) | [signal] |
Triggers the update of the vertical scrollbar.
void updateHScrollbar | ( | float | , | |
float | , | |||
float | , | |||
float | ||||
) | [signal] |
Triggers the update of the horizontal scrollbar.
void changeLegendVisibility | ( | ) | [signal] |
Toggle axis legend visibility change.
LayerData& getCurrentLayer_ | ( | ) | [inline, protected] |
ExperimentType& currentPeakData_ | ( | ) | [inline, protected] |
Returns the active layer (mutable).
void resizeEvent | ( | QResizeEvent * | e | ) | [protected] |
virtual void currentLayerParamtersChanged_ | ( | ) | [protected, virtual] |
Change of layer parameters.
This method is called whenever the paramters of the current layer change. Reimplement if you need to react on such changes.
Reimplemented in Spectrum1DCanvas, Spectrum2DCanvas, and Spectrum3DCanvas.
virtual void intensityModeChange_ | ( | ) | [protected, virtual] |
This method is called whenever the intensity mode changes. Reimplement if you need to react on such changes.
Reimplemented in Spectrum2DCanvas, and Spectrum3DCanvas.
virtual void changeVisibleArea_ | ( | const AreaType & | new_area, | |
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. | |
add_to_stack | If the new area is to add to the zoom_stack_ |
Reimplemented in Spectrum1DCanvas, and Spectrum3DCanvas.
virtual void recalculateSnapFactor_ | ( | ) | [protected, virtual] |
REcalculates the intensity scaling factor for 'snap to maximum intensity mode'.
Reimplemented in Spectrum1DCanvas, and Spectrum2DCanvas.
void zoomBack_ | ( | ) | [protected] |
Go back in zoom history.
Pops the topmost item from the zoom stack and resets the visible area to the area of that item
virtual void updateScrollbars_ | ( | ) | [protected, virtual] |
Updates the scroll bars.
Updates the scrollbars after a change of the visible area.
Reimplemented in Spectrum1DCanvas, and Spectrum2DCanvas.
PointType widgetToData_ | ( | float | x, | |
float | y | |||
) | [inline, protected] |
Convert widget to chart coordinates.
Translates widget coordinates to chart coordinates.
x | the widget coordinate x | |
y | the widget coordinate y |
PointType widgetToData_ | ( | const QPoint & | pos | ) | [inline, protected] |
Calls widgetToData_(float, float) with x and y position of pos
.
void dataToWidget_ | ( | float | x, | |
float | y, | |||
QPoint & | point | |||
) | [inline, protected] |
Convert chart to widget coordinates.
Translates chart coordinates to widget coordinates.
x | the chart coordinate x | |
y | the chart coordinate y | |
point | returned widget coordinates |
void paintGridLines_ | ( | QPainter & | painter | ) | [protected] |
Helper function to paint grid lines.
Recalculates the data range.
A small margin is added to each side of the range in order to display all data.
mz_dim | Int of m/z in overall_data_range_ | |
rt_dim | Int of RT in overall_data_range_ | |
it_dim | Int of intensity in overall_data_range_ |
virtual void update_ | ( | const char * | caller_name | ) | [protected, virtual] |
Updates the diplayed data.
The default implementation calls QWidget::update().
This method is reimplemented in the 3D view to update the OpenGL widget.
caller_name | Name of the calling function (use __PRETTY_FUNCTION__). |
Reimplemented in Spectrum3DCanvas.
void adjustBuffer_ | ( | ) | [protected] |
Changes the size of the paint buffer to the currently required size.
QPixmap buffer_ [protected] |
Buffer that stores the actual peak information.
ActionModes action_mode_ [protected] |
Stores the current action mode (Pick, Zoom, Translate).
IntensityModes intensity_mode_ [protected] |
Stores the used intensity mode function.
bool mz_to_x_axis_ [protected] |
Stores the mapping of m/z.
AreaType visible_area_ [protected] |
Stores the currently visible area.
DRange<3> overall_data_range_ [protected] |
Stores the data range (m/z, RT and intensity) of all layers.
bool show_grid_ [protected] |
Stores whether or not to show a grid.
std::stack<AreaType> zoom_stack_ [protected] |
The zoom stack. This is dealt with in the changeVisibleArea_() and zoomBack_() functions.
bool update_buffer_ [protected] |
Whether to recalculate the data in the buffer when repainting.
UInt current_layer_ [protected] |
Stores the index of the currently active layer.
SpectrumWidget* spectrum_widget_ [protected] |
Back-pointer to the enclosing spectrum widget.
QPoint last_mouse_pos_ [protected] |
start position of mouse actions
double percentage_factor_ [protected] |
Intensity scaling factor for relative scale with multiple layers.
In this mode all layers are scaled to the same maximum.
double snap_factor_ [protected] |
Intensity scaling factor for 'snap to maximum intensity mode'.
In this mode the highest currently visible intensisty is treated like the maximum overall intensity.
QRubberBand rubber_band_ [protected] |
Rubber band for selected area.
Generated Tue Apr 1 15:36:48 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |