38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
51 #include <QRubberBand>
68 class LayerDataFeature;
69 class LayerDataConsensus;
227 spectrum_widget_ = widget;
238 return spectrum_widget_;
261 return intensity_mode_;
275 intensity_mode_ = mod;
276 intensityModeChange_();
292 return layers_.getLayer(index);
297 return layers_.getLayer(index);
303 return layers_.getCurrentLayer();
308 return layers_.getCurrentLayer();
314 return layers_.getCurrentLayerIndex();
320 return getLayerFlag(layers_.getCurrentLayerIndex(), f);
326 setLayerFlag(layers_.getCurrentLayerIndex(), f, value);
332 return layers_.getLayer(layer).flags.test(f);
342 layers_.getLayer(layer).flags.set(f, value);
343 update_buffer_ =
true;
352 layers_.getCurrentLayer().label = label;
353 update_buffer_ =
true;
364 return visible_area_;
371 return visible_area_.getAreaXY().encloses(p);
378 int X_pixel_count = buffer_.width();
379 int Y_pixel_count = buffer_.height();
399 return layers_.getLayerCount();
410 for (
Size i = getLayerCount(); i > 0; --i)
414 visible_area_.clear();
418 bool addLayer(std::unique_ptr<LayerData1DBase> layer);
474 bool addLayer(std::vector<PeptideIdentification>& peptides,
const String& filename =
"");
479 return layers_.getCurrentLayer().getMinIntensity();
485 return layers_.getCurrentLayer().getMaxIntensity();
491 return getLayer(index).getMinIntensity();
497 return getLayer(index).getMaxIntensity();
509 getCurrentLayer().param = param;
510 emit preferencesChange();
651 return AreaXYType({0, 0}, {(float)width(), (float)height()});
716 void drawText_(QPainter & painter,
const QStringList& text);
767 virtual void zoom_(
int x,
int y,
bool zoom_in);
781 virtual void translateLeft_(Qt::KeyboardModifiers m);
809 const auto& xy = visible_area_.getAreaXY();
811 xy.minX() + x / width() * xy.width(),
812 xy.minY() + (height() - y) / height() * xy.height()
819 return widgetToData_(pos.x(), pos.y());
861 bool show_grid_ =
true;
866 std::vector<VisibleArea>::iterator zoom_pos_ = zoom_stack_.end();
877 virtual void update_(
const char* caller_name);
883 bool update_buffer_ =
false;
897 double percentage_factor_ = 1.0;
912 QMenu* context_add_ =
nullptr;
915 bool show_timing_ =
false;
925 std::set<DataProcessing::ProcessingAction> actions;
926 actions.insert(action);
930 p->setProcessingActions(actions);
932 p->getSoftware().setName(
"PlotCanvas");
938 for (
Size i = 0; i < map.
size(); ++i)
940 map[i].getDataProcessing().push_back(p);
Definition: DimMapper.h:819
const Area & setArea(const RangeAllType &data)
Set the area using unit data (RT, m/z, ...)
Definition: DimMapper.h:865
A container for consensus elements.
Definition: ConsensusMap.h:92
DataFilter array providing some convenience functions.
Definition: DataFilters.h:53
Description of the applied preprocessing steps.
Definition: DataProcessing.h:53
ProcessingAction
Definition: DataProcessing.h:59
static DateTime now()
Returns the current date and time.
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
Allows dynamical switching (at runtime) between a dimension (RT, m/z, int, IM, etc) and X,...
Definition: DimMapper.h:645
A container for features.
Definition: FeatureMap.h:106
Class that stores the data for one layer.
Definition: LayerDataBase.h:195
Definition: PlotCanvas.h:83
Size getLayerCount() const
Size getCurrentLayerIndex() const
Size current_layer_
Definition: PlotCanvas.h:113
LayerDataBase & getCurrentLayer()
LayerDataBase & getLayer(const Size index)
void removeLayer(Size layer_index)
const LayerDataBase & getLayer(const Size index) const
void setCurrentLayer(Size index)
throws Exception::IndexOverflow unless index is smaller than getLayerCount()
void addLayer(LayerDataBaseUPtr new_layer)
const LayerDataBase & getCurrentLayer() const
void removeCurrentLayer()
std::vector< LayerDataBaseUPtr > layers_
Definition: PlotCanvas.h:111
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
Size size() const
The number of spectra.
Definition: MSExperiment.h:147
The representation of a 1D spectrum.
Definition: MSSpectrum.h:70
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSSpectrum.h:136
Management and storage of parameters / INI files.
Definition: Param.h:70
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:65
Base class for visualization canvas classes.
Definition: PlotCanvas.h:146
void setVisibleAreaX(double min, double max)
Set only the visible area for the x axis; other axes are untouched.
virtual void translateBackward_()
Translation bound to the 'Down' key.
float getMaxIntensity(Size index) const
Returns the maximum intensity of the layer with index index.
Definition: PlotCanvas.h:495
float getMinIntensity(Size index) const
Returns the minimum intensity of the layer with index index.
Definition: PlotCanvas.h:489
float getCurrentMinIntensity() const
Returns the minimum intensity of the active layer.
Definition: PlotCanvas.h:477
void addDataProcessing_(PeakMap &map, DataProcessing::ProcessingAction action) const
Data processing setter for peak maps.
Definition: PlotCanvas.h:923
void layerActivated(QWidget *w)
Signal emitted whenever a new layer is activated within the current window.
void setLayerName(Size i, const String &name)
Sets the name of layer i.
~PlotCanvas() override
Destructor.
std::vector< VisibleArea > zoom_stack_
The zoom stack.
Definition: PlotCanvas.h:864
LayerStack layers_
Layer data.
Definition: PlotCanvas.h:838
virtual void recalculateRanges_()
Recalculates the overall_data_range_.
std::vector< double > snap_factors_
Intensity scaling factor for 'snap to maximum intensity mode'.
Definition: PlotCanvas.h:906
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/t...
bool addLayer(std::vector< PeptideIdentification > &peptides, const String &filename="")
Add an identification data layer.
PlotCanvas(const Param &preferences, QWidget *parent=nullptr)
Default constructor.
LayerDataBase::ConstExperimentSharedPtrType ConstExperimentSharedPtrType
Definition: PlotCanvas.h:157
String getLayerName(Size i)
Gets the name of layer i.
virtual void horizontalScrollBarChange(int value)
Notifies the canvas that the horizontal scrollbar has been moved.
SpectrumType::PeakType PeakType
Peak type.
Definition: PlotCanvas.h:173
QImage buffer_
Buffer that stores the actual peak information.
Definition: PlotCanvas.h:826
void setMapper(const DimMapper< 2 > &mapper)
Set a new mapper for the canvas.
DimMapper< 2 > unit_mapper_
Mapper for X and Y axis.
Definition: PlotCanvas.h:829
PeakIndex selected_peak_
selected peak
Definition: PlotCanvas.h:918
double getPercentageFactor() const
Returns the percentage factor.
void setIntensityMode(IntensityModes mod)
Sets the intensity mode.
Definition: PlotCanvas.h:273
RangeType overall_data_range_
Stores the data range (m/z, RT and intensity) of all layers.
Definition: PlotCanvas.h:858
void recalculateAxes()
Forces recalculation of axis ticks in the connected widget.
bool addChromLayer(const ExperimentSharedPtrType &map, ODExperimentSharedPtrType od_map, const String &filename="")
Add a chrom data layer.
LayerDataBase::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Main managed data type (consensus features)
Definition: PlotCanvas.h:166
Size getLayerCount() const
Returns the number of layers.
Definition: PlotCanvas.h:397
virtual void updateLayer(Size i)=0
Updates layer i when the data in the corresponding file changes.
bool gridLinesShown() const
Returns if the grid is currently shown.
Definition: PlotCanvas.h:284
void setVisibleArea(const VisibleArea &area)
Sets the visible area.
SpectrumType::ConstIterator SpectrumConstIteratorType
Spectrum iterator type (iterates over peaks)
Definition: PlotCanvas.h:171
void enterEvent(QEvent *e) override
LayerDataBase::FeatureMapSharedPtrType FeatureMapSharedPtrType
Main managed data type (features)
Definition: PlotCanvas.h:162
virtual void updateScrollbars_()
Updates the scroll bars.
Size getCurrentLayerIndex() const
returns the index of the active layer
Definition: PlotCanvas.h:312
void setLabel(LayerDataBase::LabelType label)
Definition: PlotCanvas.h:347
bool addLayer(FeatureMapSharedPtrType map, const String &filename="")
Add a feature data layer.
Int getActionMode() const
Returns the action mode.
Definition: PlotCanvas.h:247
void setVisibleAreaY(double min, double max)
Set only the visible area for the y axis; other axes are untouched.
const DimMapper< 2 > & getMapper() const
Get Mapper to translate between values for axis (X/Y) and units (m/z, RT, intensity,...
virtual void activateLayer(Size layer_index)=0
change the active layer (the one that is used for selecting and so on)
const LayerDataBase & getLayer(Size index) const
returns the layer data with index index
Definition: PlotCanvas.h:290
void updateCursor_()
Updates the cursor according to the current action mode.
void sendCursorStatus(const String &x_value, const String &y_value)
Emitted when the cursor position changes (for displaying e.g. in status bar)
virtual void removeLayer(Size layer_index)=0
removes the layer with index layer_index
virtual void verticalScrollBarChange(int value)
Notifies the canvas that the vertical scrollbar has been moved.
void actionModeChange()
Emitted when the action mode changes.
LayerDataBase & getLayer(Size index)
returns the layer data with index index
Definition: PlotCanvas.h:295
void leaveEvent(QEvent *e) override
void zoomClear_()
Clears the zoom stack and invalidates the current zoom position. After calling this,...
void keyReleaseEvent(QKeyEvent *e) override
void drawText_(QPainter &painter, const QStringList &text)
Draws several lines of text to the upper right corner of the widget.
ExperimentType::SpectrumType SpectrumType
Spectrum type.
Definition: PlotCanvas.h:169
virtual void showMetaData(bool modifiable=false, Int index=-1)
Shows a dialog with the meta data.
virtual void paintGridLines_(QPainter &painter)
Helper function to paint grid lines.
LayerDataBase & getCurrentLayer()
returns the layer data of the active layer
Definition: PlotCanvas.h:306
PointXYType widgetToData_(double x, double y)
Convert widget (pixel) to chart (unit) coordinates.
Definition: PlotCanvas.h:807
void keyPressEvent(QKeyEvent *e) override
void setLayerFlag(LayerDataBase::Flags f, bool value)
sets a layer flag of the current layer
Definition: PlotCanvas.h:324
virtual void zoomForward_()
Go forward in zoom history.
void setAdditionalContextMenu(QMenu *menu)
Sets the additional context menu. If not 0, this menu is added to the context menu of the canvas.
Area< 2 >::AreaXYType AreaXYType
The range of data shown on the X and Y axis (unit depends on runtime config)
Definition: PlotCanvas.h:178
void changeVisibility(Size i, bool b)
change the visibility of a layer
bool getLayerFlag(Size layer, LayerDataBase::Flags f) const
returns a layer flag of the layer layer
Definition: PlotCanvas.h:330
PixelArea getPixelRange() const
Definition: PlotCanvas.h:376
PointXYType widgetToData_(const QPoint &pos)
Calls widgetToData_ with x and y position of pos.
Definition: PlotCanvas.h:817
void wheelEvent(QWheelEvent *e) override
void focusOutEvent(QFocusEvent *e) override
const VisibleArea & getVisibleArea() const
Returns the currently visible area. This is the authority which determines the X and Y axis' scale.
Definition: PlotCanvas.h:362
void visibleAreaChanged(const VisibleArea &area)
Change of the visible area.
void modificationStatus_(Size layer_index, bool modified)
Takes all actions necessary when the modification status of a layer changes (signals etc....
virtual void translateForward_()
Translation bound to the 'Up' key.
void zoomBack_()
Go backward in zoom history.
IntensityModes
Display modes of intensity.
Definition: PlotCanvas.h:203
@ IM_NONE
Normal mode: f(x)=x; y-axis shows the maximum of all layers, no scaling.
Definition: PlotCanvas.h:204
@ IM_SNAP
Shows the maximum displayed intensity (across all layers) as if it was the overall maximum intensity.
Definition: PlotCanvas.h:206
@ IM_PERCENTAGE
Shows intensities normalized by each layer's maximum: f(x)=x/max(x)*100.
Definition: PlotCanvas.h:205
LayerDataBase::FeatureMapType FeatureMapType
Main data type (features)
Definition: PlotCanvas.h:160
float getCurrentMaxIntensity() const
Returns the maximum intensity of the active layer.
Definition: PlotCanvas.h:483
void saveCurrentLayer(bool visible)
Saves the current layer data.
AreaXYType canvasPixelArea() const
Get the Area in pixel coordinates of the current canvas for X and Y axis.
Definition: PlotCanvas.h:649
virtual void setFilters(const DataFilters &filters)
Sets the filters applied to the data before drawing (for the current layer)
const LayerDataBase & getCurrentLayer() const
returns the layer data of the active layer
Definition: PlotCanvas.h:301
void changeLayerFilterState(Size i, bool b)
change if the defined data filters are used
void layerModficationChange(Size layer, bool modified)
Signal emitted whenever the modification status of a layer changes (editing and storing)
virtual void translateRight_(Qt::KeyboardModifiers m)
Translation bound to the 'Right' key.
bool addPeakLayer(const ExperimentSharedPtrType &map, ODExperimentSharedPtrType od_map, const String &filename="", const bool use_noise_cutoff=false)
Add a peak data layer.
bool addLayer(ConsensusMapSharedPtrType map, const String &filename="")
Add a consensus feature data layer.
void setCurrentLayerParameters(const Param ¶m)
Sets the parameters of the current layer.
Definition: PlotCanvas.h:507
void updateHScrollbar(float f_min, float disp_min, float disp_max, float f_max)
Triggers the update of the horizontal scrollbar.
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 displ...
virtual void resetZoom(bool repaint=true)
Zooms fully out and resets the zoom stack.
void setVisibleArea(const AreaXYType &area)
Sets the visible area.
bool addLayer(std::unique_ptr< LayerData1DBase > layer)
Add an already constructed layer (e.g. for projections)
QPoint last_mouse_pos_
start position of mouse actions
Definition: PlotCanvas.h:889
double getSnapFactor()
Returns the first intensity scaling factor for 'snap to maximum intensity mode' (for the currently vi...
virtual bool finishAdding_()=0
Method that is called when a new layer has been added.
ActionModes
Mouse action modes.
Definition: PlotCanvas.h:195
@ AM_ZOOM
zoom
Definition: PlotCanvas.h:197
@ AM_TRANSLATE
translate
Definition: PlotCanvas.h:196
virtual void intensityModeChange_()
This method is called whenever the intensity mode changes. Reimplement if you need to react on such c...
virtual void changeVisibleArea_(VisibleArea new_area, bool repaint=true, bool add_to_stack=false)
Sets the visible area.
bool isVisible(const PointOnAxis &p) const
Definition: PlotCanvas.h:369
void popIncompleteLayer_(const QString &error_message="")
void preferencesChange()
Emitted when the layer preferences have changed.
PeakIndex measurement_start_
start peak of measuring mode
Definition: PlotCanvas.h:920
IntensityModes getIntensityMode() const
Returns the intensity mode.
Definition: PlotCanvas.h:259
bool getLayerFlag(LayerDataBase::Flags f) const
returns a layer flag of the current layer
Definition: PlotCanvas.h:318
void updateVScrollbar(float f_min, float disp_min, float disp_max, float f_max)
Triggers the update of the vertical scrollbar.
void zoomAdd_(const VisibleArea &area)
Add a visible area to the zoom stack.
virtual void showCurrentLayerPreferences()=0
Shows the preferences dialog of the active layer.
void resizeEvent(QResizeEvent *e) override
const RangeType & getDataRange() const
Returns the area which encloses all data points of all layers.
QRubberBand rubber_band_
Rubber band for selected area.
Definition: PlotCanvas.h:909
LayerDataBase::ConsensusMapType ConsensusMapType
Main data type (consensus features)
Definition: PlotCanvas.h:164
DimMapper< 2 >::Point PointOnAxis
Definition: PlotCanvas.h:191
LayerDataBase::ExperimentSharedPtrType ExperimentSharedPtrType
Main managed data type (experiment)
Definition: PlotCanvas.h:156
void changeLegendVisibility()
Toggle axis legend visibility change.
void showGridLines(bool show)
Whether or not to show grid lines.
void layerZoomChanged(QWidget *w)
Signal emitted whenever the zoom changed.
virtual void recalculateSnapFactor_()
Recalculates the intensity scaling factor for 'snap to maximum intensity mode'.
void removeLayers()
removes all layers by calling removeLayer() for all layer indices (from highest to lowest)
Definition: PlotCanvas.h:408
LayerDataBase::ODExperimentSharedPtrType ODExperimentSharedPtrType
Definition: PlotCanvas.h:158
PlotWidget * getPlotWidget() const
Returns the spectrum widget.
Definition: PlotCanvas.h:236
void dimensionsChanged_()
Call this whenever the DimMapper receives new dimensions; will update the axes and scrollbars.
VisibleArea visible_area_
Stores the currently visible area in data units (e.g. seconds, m/z, intensity etc) and axis (X,...
Definition: PlotCanvas.h:846
virtual void update_(const char *caller_name)
Updates the displayed data.
void setLayerFlag(Size layer, LayerDataBase::Flags f, bool value)
sets a layer flag of the layer layer
Definition: PlotCanvas.h:336
void setVisibleArea(const RangeAllType &area)
Sets the visible area.
void setPlotWidget(PlotWidget *widget)
Sets the spectrum widget.
Definition: PlotCanvas.h:225
LayerDataBase::ExperimentType ExperimentType
Main data type (experiment)
Definition: PlotCanvas.h:154
A more convenient string class.
Definition: String.h:60
static String getVersion()
Return the version number of OpenMS.
int Int
Signed integer type.
Definition: Types.h:102
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
std::unique_ptr< LayerDataChrom > LayerDataChromUPtr
Definition: PlotCanvas.h:72
std::unique_ptr< LayerDataConsensus > LayerDataConsensusUPtr
Definition: PlotCanvas.h:75
std::unique_ptr< LayerDataBase > LayerDataBaseUPtr
Definition: PlotCanvas.h:71
RangeManager< RangeRT, RangeMZ, RangeIntensity, RangeMobility > RangeAllType
Range which contains all known dimensions.
Definition: RangeManager.h:923
boost::shared_ptr< DataProcessing > DataProcessingPtr
Definition: DataProcessing.h:136
DPosition< 2U > PointXYType
Type of the Points in a 'flat' canvas (1D and 2D)
Definition: CommonDefs.h:59
std::unique_ptr< LayerDataFeature > LayerDataFeatureUPtr
Definition: PlotCanvas.h:74
std::unique_ptr< LayerDataPeak > LayerDataPeakUPtr
Definition: PlotCanvas.h:73
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerDataBase.h:152
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerDataBase.h:157
LabelType
Label used in visualization.
Definition: LayerDataBase.h:124
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerDataBase.h:140
boost::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition: LayerDataBase.h:154
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerDataBase.h:146
Flags
Flags that determine which information is shown.
Definition: LayerDataBase.h:110
Index of a peak or feature.
Definition: PeakIndex.h:51