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 #ifndef OPENMS_VISUAL_SPECTRUM1DCANVAS_H
36 #define OPENMS_VISUAL_SPECTRUM1DCANVAS_H
37 
38 // OpenMS_GUI config
39 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
40 
41 // OpenMS
43 
44 #include <QTextDocument>
45 
46 // STL
47 #include <vector>
48 #include <utility>
49 
50 // QT
51 class QAction;
52 
53 namespace OpenMS
54 {
68  class OPENMS_GUI_DLLAPI Spectrum1DCanvas :
69  public SpectrumCanvas
70  {
71  Q_OBJECT
72 
73 public:
75  enum LabelMode
76  {
80  LM_XPERCENT_YPERCENT
81  };
82 
84  Spectrum1DCanvas(const Param & preferences, QWidget * parent = 0);
86  virtual ~Spectrum1DCanvas();
87 
89  enum DrawModes
90  {
91  DM_PEAKS, //< draw data as peak
92  DM_CONNECTEDLINES //< draw as connected lines
93  };
94 
96  DrawModes getDrawMode() const;
97 
99  void setDrawMode(DrawModes mode);
100 
101  // Docu in base class
102  virtual void showCurrentLayerPreferences();
103 
104  // Docu in base class
105  virtual void saveCurrentLayer(bool visible);
106 
108  bool flippedLayersExist();
109 
111  void flipLayer(Size index);
112 
114  bool mirrorModeActive();
115 
117  void setMirrorModeActive(bool b);
118 
120  void dataToWidget(const PeakType & peak, QPoint & point, bool flipped = false, bool percentage = true);
121 
123  void dataToWidget(double x, double y, QPoint & point, bool flipped = false, bool percentage = false);
124 
126  PointType widgetToData(const QPoint & pos, bool percentage = false);
127 
129  PointType widgetToData(double x, double y, bool percentage = false);
130 
132  void setTextBox(const QString& html);
133 
135 
137  Annotation1DItem * addPeakAnnotation(const PeakIndex& peak_index, const QString& text, const QColor& color);
138 
140  void drawAnnotations(Size layer_index, QPainter & painter);
141 
143 
145  void performAlignment(Size layer_index_1, Size layer_index_2, const Param & param);
146 
148  void resetAlignment();
149 
151  void drawAlignment(QPainter & painter);
152 
154  Size getAlignmentSize();
155 
157  double getAlignmentScore();
158 
160  std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
161 
163  void activateSpectrum(Size index, bool repaint = true);
164 
166  void setSwappedAxis(bool swapped);
167 
169  void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
170 
172  void paint(QPainter * paint_device, QPaintEvent * e);
173 signals:
175  void showCurrentPeaksAs2D();
177  void showCurrentPeaksAs3D();
178 
179 public slots:
180  // Docu in base class
181  void activateLayer(Size layer_index);
182  // Docu in base class
183  void removeLayer(Size layer_index);
184  //docu in base class
185  virtual void updateLayer(Size i);
186 
193  void setVisibleArea(DRange<2> range); //Do not change this to AreaType the signal needs QT needs the exact type...
194  // Docu in base class
195  virtual void horizontalScrollBarChange(int value);
196 
197 protected slots:
198 
200  void currentLayerParamtersChanged_();
201 
202 protected:
203  // Docu in base class
204  bool finishAdding_();
205 
207  void drawCoordinates_(QPainter & painter, const PeakIndex & peak);
209  void drawDeltas_(QPainter & painter, const PeakIndex & start, const PeakIndex & end);
210 
216  void changeVisibleArea_(double lo, double hi, bool repaint = true, bool add_to_stack = false);
217 
219  void drawHighlightedPeak_(Size layer_index, const PeakIndex & peak, QPainter & painter, bool draw_elongation = false);
220 
222  void drawDashedLine_(const QPoint & from, const QPoint & to, QPainter & painter);
223 
225  void updatePercentageFactor_(Size layer_index);
226 
237  virtual void changeVisibleArea_(const AreaType & new_area, bool repaint = true, bool add_to_stack = false);
238  // Docu in base class
239  virtual void recalculateSnapFactor_();
240  // Docu in base class
241  virtual void updateScrollbars_();
242  // Docu in base class
243  virtual void intensityModeChange_();
244 
246  std::vector<DrawModes> draw_modes_;
248  std::vector<Qt::PenStyle> peak_penstyle_;
249 
254 
257 
265  std::vector<std::pair<double, double> > aligned_peaks_mz_delta_;
267  std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
268 
273 
275  PeakIndex findPeakAtPosition_(QPoint);
276 
278  void addUserLabelAnnotation_(const QPoint & screen_position);
280  void addLabelAnnotation_(const QPoint & screen_position, QString label_text);
282  void addUserPeakAnnotation_(PeakIndex near_peak);
283 
285  void ensureAnnotationsWithinDataRange_();
286 
287  QTextDocument text_box_content_;
288 
291  void paintEvent(QPaintEvent * e);
292  void mousePressEvent(QMouseEvent * e);
293  void mouseReleaseEvent(QMouseEvent * e);
294  void mouseMoveEvent(QMouseEvent * e);
295  void keyPressEvent(QKeyEvent * e);
296  void contextMenuEvent(QContextMenuEvent * e);
298 
300  virtual void zoomForward_();
302  virtual void zoom_(int x, int y, bool zoom_in);
303  //docu in base class
304  virtual void translateLeft_(Qt::KeyboardModifiers m);
305  //docu in base class
306  virtual void translateRight_(Qt::KeyboardModifiers m);
307  //docu in base class
308  virtual void paintGridLines_(QPainter & painter);
309  };
310 } // namespace OpenMS
311 
312 #endif
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:60
bool moving_annotations_
Indicates whether annotation items are just being moved on the canvas.
Definition: Spectrum1DCanvas.h:256
QTextDocument text_box_content_
Definition: Spectrum1DCanvas.h:287
std::vector< DrawModes > draw_modes_
Draw modes (for each spectrum)
Definition: Spectrum1DCanvas.h:246
Size alignment_layer_2_
Layer index of the second alignment layer.
Definition: Spectrum1DCanvas.h:263
LabelMode
Label modes (percentage or absolute) of x axis and y axis.
Definition: Spectrum1DCanvas.h:75
DrawModes
Enumerate all available paint styles.
Definition: Spectrum1DCanvas.h:89
Definition: Spectrum1DCanvas.h:91
Definition: Spectrum1DCanvas.h:77
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:96
std::vector< Qt::PenStyle > peak_penstyle_
Draw style.
Definition: Spectrum1DCanvas.h:248
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool is_swapped_
is this widget showing data with swapped m/z and RT axis? (for drawCoordinates_ only) ...
Definition: Spectrum1DCanvas.h:272
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
bool show_alignment_
Indicates whether an alignment is currently visualized.
Definition: Spectrum1DCanvas.h:259
Size alignment_layer_1_
Layer index of the first alignment layer.
Definition: Spectrum1DCanvas.h:261
bool mirror_mode_
Indicates whether this widget is currently in mirror mode.
Definition: Spectrum1DCanvas.h:253
Canvas for visualization of one or several spectra.
Definition: Spectrum1DCanvas.h:68
Management and storage of parameters / INI files.
Definition: Param.h:75
double alignment_score_
Stores the score of the last alignment.
Definition: Spectrum1DCanvas.h:270
Definition: Spectrum1DCanvas.h:79
QPoint measurement_start_point_
start point of "ruler" for measure mode
Definition: Spectrum1DCanvas.h:251
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
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:265
std::vector< std::pair< Size, Size > > aligned_peaks_indices_
Stores the peak indices of pairs of aligned peaks in both spectra.
Definition: Spectrum1DCanvas.h:267
Definition: Spectrum1DCanvas.h:78
Index of a peak or feature.
Definition: PeakIndex.h:51

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:04 using doxygen 1.8.13