Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Spectrum1DCanvas.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg$
32 // $Authors: Marc Sturm, Timo Sachsenberg, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 // OpenMS
42 
43 #include <QTextDocument>
44 
45 // STL
46 #include <vector>
47 #include <utility>
48 
49 // QT
50 class QAction;
51 
52 namespace OpenMS
53 {
67  class OPENMS_GUI_DLLAPI Spectrum1DCanvas :
68  public SpectrumCanvas
69  {
70  Q_OBJECT
71 
72 public:
74  enum LabelMode
75  {
79  LM_XPERCENT_YPERCENT
80  };
81 
83  Spectrum1DCanvas(const Param & preferences, QWidget * parent = nullptr);
85  ~Spectrum1DCanvas() override;
86 
88  enum DrawModes
89  {
91  DM_CONNECTEDLINES
92  };
93 
95  DrawModes getDrawMode() const;
96 
98  void setDrawMode(DrawModes mode);
99 
100  // Docu in base class
101  void showCurrentLayerPreferences() override;
102 
103  // Docu in base class
104  void saveCurrentLayer(bool visible) override;
105 
107  bool flippedLayersExist();
108 
110  void flipLayer(Size index);
111 
113  bool mirrorModeActive();
114 
116  void setMirrorModeActive(bool b);
117 
119  void dataToWidget(const PeakType & peak, QPoint & point, bool flipped = false, bool percentage = true);
120 
122  void dataToWidget(double x, double y, QPoint & point, bool flipped = false, bool percentage = false);
123 
125  PointType widgetToData(const QPoint & pos, bool percentage = false);
126 
128  PointType widgetToData(double x, double y, bool percentage = false);
129 
131  void setTextBox(const QString& html);
132 
134 
136  Annotation1DItem * addPeakAnnotation(const PeakIndex& peak_index, const QString& text, const QColor& color);
137 
139  void drawAnnotations(Size layer_index, QPainter & painter);
140 
142 
144  void performAlignment(Size layer_index_1, Size layer_index_2, const Param & param);
145 
147  void resetAlignment();
148 
150  void drawAlignment(QPainter & painter);
151 
153  Size getAlignmentSize();
154 
156  double getAlignmentScore();
157 
159  std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
160 
162  void activateSpectrum(Size index, bool repaint = true);
163 
165  void setSwappedAxis(bool swapped);
166 
168  void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
169 
171  void paint(QPainter * paint_device, QPaintEvent * e);
172 signals:
174  void showCurrentPeaksAs2D();
176  void showCurrentPeaksAs3D();
177 
178 public slots:
179  // Docu in base class
180  void activateLayer(Size layer_index) override;
181  // Docu in base class
182  void removeLayer(Size layer_index) override;
183  //docu in base class
184  void updateLayer(Size i) override;
185 
192  void setVisibleArea(DRange<2> range); //Do not change this to AreaType the signal needs QT needs the exact type...
193  // Docu in base class
194  void horizontalScrollBarChange(int value) override;
195 
196 protected slots:
197 
199  void currentLayerParamtersChanged_();
200 
201 protected:
202  // Docu in base class
203  bool finishAdding_() override;
204 
206  void drawCoordinates_(QPainter & painter, const PeakIndex & peak);
208  void drawDeltas_(QPainter & painter, const PeakIndex & start, const PeakIndex & end);
209 
215  void changeVisibleArea_(double lo, double hi, bool repaint = true, bool add_to_stack = false);
216 
218  void drawHighlightedPeak_(Size layer_index, const PeakIndex & peak, QPainter & painter, bool draw_elongation = false);
219 
221  void drawDashedLine_(const QPoint & from, const QPoint & to, QPainter & painter);
222 
224  void updatePercentageFactor_(Size layer_index);
225 
236  void changeVisibleArea_(const AreaType & new_area, bool repaint = true, bool add_to_stack = false) override;
237  // Docu in base class
238  void recalculateSnapFactor_() override;
239  // Docu in base class
240  void updateScrollbars_() override;
241  // Docu in base class
242  void intensityModeChange_() override;
243 
245  std::vector<DrawModes> draw_modes_;
247  std::vector<Qt::PenStyle> peak_penstyle_;
248 
253 
256 
264  std::vector<std::pair<double, double> > aligned_peaks_mz_delta_;
266  std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
267 
272 
274  PeakIndex findPeakAtPosition_(QPoint);
275 
277  void addUserLabelAnnotation_(const QPoint & screen_position);
279  void addLabelAnnotation_(const QPoint & screen_position, QString label_text);
281  void addUserPeakAnnotation_(PeakIndex near_peak);
282 
284  void ensureAnnotationsWithinDataRange_();
285 
286  QTextDocument text_box_content_;
287 
290  void paintEvent(QPaintEvent * e) override;
291  void mousePressEvent(QMouseEvent * e) override;
292  void mouseReleaseEvent(QMouseEvent * e) override;
293  void mouseMoveEvent(QMouseEvent * e) override;
294  void keyPressEvent(QKeyEvent * e) override;
295  void contextMenuEvent(QContextMenuEvent * e) override;
297 
299  void zoomForward_() override;
301  void zoom_(int x, int y, bool zoom_in) override;
302  //docu in base class
303  void translateLeft_(Qt::KeyboardModifiers m) override;
304  //docu in base class
305  void translateRight_(Qt::KeyboardModifiers m) override;
306  //docu in base class
307  void paintGridLines_(QPainter & painter) override;
308  };
309 } // namespace OpenMS
310 
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:59
bool moving_annotations_
Indicates whether annotation items are just being moved on the canvas.
Definition: Spectrum1DCanvas.h:255
QTextDocument text_box_content_
Definition: Spectrum1DCanvas.h:286
std::vector< DrawModes > draw_modes_
Draw modes (for each spectrum)
Definition: Spectrum1DCanvas.h:245
Size alignment_layer_2_
Layer index of the second alignment layer.
Definition: Spectrum1DCanvas.h:262
LabelMode
Label modes (percentage or absolute) of x axis and y axis.
Definition: Spectrum1DCanvas.h:74
DrawModes
Enumerate all available paint styles.
Definition: Spectrum1DCanvas.h:88
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:54
draw data as peak
Definition: Spectrum1DCanvas.h:90
Definition: Spectrum1DCanvas.h:76
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:96
std::vector< Qt::PenStyle > peak_penstyle_
Draw style.
Definition: Spectrum1DCanvas.h:247
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
bool is_swapped_
is this widget showing data with swapped m/z and RT axis? (for drawCoordinates_ only) ...
Definition: Spectrum1DCanvas.h:271
bool show_alignment_
Indicates whether an alignment is currently visualized.
Definition: Spectrum1DCanvas.h:258
Size alignment_layer_1_
Layer index of the first alignment layer.
Definition: Spectrum1DCanvas.h:260
bool mirror_mode_
Indicates whether this widget is currently in mirror mode.
Definition: Spectrum1DCanvas.h:252
Canvas for visualization of one or several spectra.
Definition: Spectrum1DCanvas.h:67
Management and storage of parameters / INI files.
Definition: Param.h:74
double alignment_score_
Stores the score of the last alignment.
Definition: Spectrum1DCanvas.h:269
Definition: Spectrum1DCanvas.h:78
QPoint measurement_start_point_
start point of "ruler" for measure mode
Definition: Spectrum1DCanvas.h:250
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< std::pair< double, double > > aligned_peaks_mz_delta_
Stores the alignment as MZ values of pairs of aligned peaks in both spectra.
Definition: Spectrum1DCanvas.h:264
std::vector< std::pair< Size, Size > > aligned_peaks_indices_
Stores the peak indices of pairs of aligned peaks in both spectra.
Definition: Spectrum1DCanvas.h:266
Definition: Spectrum1DCanvas.h:77
Index of a peak or feature.
Definition: PeakIndex.h:50

OpenMS / TOPP release 2.3.0 Documentation generated on Wed Apr 18 2018 19:29:08 using doxygen 1.8.14