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-2013.
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 $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_VISUAL_SPECTRUM1DCANVAS_H
36 #define OPENMS_VISUAL_SPECTRUM1DCANVAS_H
37 
38 // STL
39 #include <vector>
40 #include <utility>
41 
42 // OpenMS
44 
45 //QT
46 class QAction;
47 
48 namespace OpenMS
49 {
63  class OPENMS_GUI_DLLAPI Spectrum1DCanvas :
64  public SpectrumCanvas
65  {
66  Q_OBJECT
67 
68 public:
70  enum LabelMode
71  {
75  LM_XPERCENT_YPERCENT
76  };
77 
79  Spectrum1DCanvas(const Param & preferences, QWidget * parent = 0);
81  virtual ~Spectrum1DCanvas();
82 
84  enum DrawModes
85  {
86  DM_PEAKS, //< draw data as peak
87  DM_CONNECTEDLINES //< draw as connected lines
88  };
89 
91  DrawModes getDrawMode() const;
92 
94  void setDrawMode(DrawModes mode);
95 
96  // Docu in base class
97  virtual void showCurrentLayerPreferences();
98 
99  // Docu in base class
100  virtual void saveCurrentLayer(bool visible);
101 
103  bool flippedLayersExist();
104 
106  void flipLayer(Size index);
107 
109  bool mirrorModeActive();
110 
112  void setMirrorModeActive(bool b);
113 
115  void dataToWidget(const PeakType & peak, QPoint & point, bool flipped = false, bool percentage = true);
116 
118  void dataToWidget(DoubleReal x, DoubleReal y, QPoint & point, bool flipped = false, bool percentage = false);
119 
121  PointType widgetToData(const QPoint & pos, bool percentage = false);
122 
124  PointType widgetToData(DoubleReal x, DoubleReal y, bool percentage = false);
125 
127 
129  Annotation1DItem * addPeakAnnotation(PeakIndex peak_index, QString text, QColor color);
130 
132  void drawAnnotations(Size layer_index, QPainter & painter);
133 
135 
137  void performAlignment(Size layer_index_1, Size layer_index_2, const Param & param);
138 
140  void resetAlignment();
141 
143  void drawAlignment(QPainter & painter);
144 
146  Size getAlignmentSize();
147 
149  DoubleReal getAlignmentScore();
150 
152  std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
153 
155  void activateSpectrum(Size index, bool repaint = true);
156 
158  void setSwappedAxis(bool swapped);
159 
161  void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
162 
164  void paint(QPainter * paint_device, QPaintEvent * e);
165 signals:
167  void showCurrentPeaksAs2D();
169  void showCurrentPeaksAs3D();
170 
171 public slots:
172  // Docu in base class
173  void activateLayer(Size layer_index);
174  // Docu in base class
175  void removeLayer(Size layer_index);
176  //docu in base class
177  virtual void updateLayer(Size i);
178 
185  void setVisibleArea(DRange<2> range); //Do not change this to AreaType the signal needs QT needs the exact type...
186  // Docu in base class
187  virtual void horizontalScrollBarChange(int value);
188 
189 protected slots:
190 
192  void currentLayerParamtersChanged_();
193 
194 protected:
195  // Docu in base class
196  bool finishAdding_();
197 
199  void drawCoordinates_(QPainter & painter, const PeakIndex & peak);
201  void drawDeltas_(QPainter & painter, const PeakIndex & start, const PeakIndex & end);
202 
208  void changeVisibleArea_(double lo, double hi, bool repaint = true, bool add_to_stack = false);
209 
211  void drawHighlightedPeak_(Size layer_index, const PeakIndex & peak, QPainter & painter, bool draw_elongation = false);
212 
214  void drawDashedLine_(const QPoint & from, const QPoint & to, QPainter & painter);
215 
217  void updatePercentageFactor_(Size layer_index);
218 
229  virtual void changeVisibleArea_(const AreaType & new_area, bool repaint = true, bool add_to_stack = false);
230  // Docu in base class
231  virtual void recalculateSnapFactor_();
232  // Docu in base class
233  virtual void updateScrollbars_();
234  // Docu in base class
235  virtual void intensityModeChange_();
236 
238  std::vector<DrawModes> draw_modes_;
240  std::vector<Qt::PenStyle> peak_penstyle_;
241 
246 
249 
257  std::vector<std::pair<DoubleReal, DoubleReal> > aligned_peaks_mz_delta_;
259  std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
260 
265 
267  PeakIndex findPeakAtPosition_(QPoint);
268 
270  void addUserLabelAnnotation_(const QPoint & screen_position);
272  void addLabelAnnotation_(const QPoint & screen_position, QString label_text);
274  void addUserPeakAnnotation_(PeakIndex near_peak);
275 
277  void ensureAnnotationsWithinDataRange_();
278 
281  void paintEvent(QPaintEvent * e);
282  void mousePressEvent(QMouseEvent * e);
283  void mouseReleaseEvent(QMouseEvent * e);
284  void mouseMoveEvent(QMouseEvent * e);
285  void keyPressEvent(QKeyEvent * e);
286  void contextMenuEvent(QContextMenuEvent * e);
288 
290  virtual void zoomForward_();
292  virtual void zoom_(int x, int y, bool zoom_in);
293  //docu in base class
294  virtual void translateLeft_();
295  //docu in base class
296  virtual void translateRight_();
297  //docu in base class
298  virtual void paintGridLines_(QPainter & painter);
299  };
300 } // namespace OpenMS
301 
302 #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:248
std::vector< DrawModes > draw_modes_
Draw modes (for each spectrum)
Definition: Spectrum1DCanvas.h:238
Size alignment_layer_2_
Layer index of the second alignment layer.
Definition: Spectrum1DCanvas.h:255
LabelMode
Label modes (percentage or absolut) of x axis and y axis.
Definition: Spectrum1DCanvas.h:70
DrawModes
Enumerate all avaiable paint styles.
Definition: Spectrum1DCanvas.h:84
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
Definition: Spectrum1DCanvas.h:86
Definition: Spectrum1DCanvas.h:72
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:94
std::vector< Qt::PenStyle > peak_penstyle_
Draw style.
Definition: Spectrum1DCanvas.h:240
bool is_swapped_
is this widget showing data with swapped m/z and RT axis? (for drawCoordinates_ only) ...
Definition: Spectrum1DCanvas.h:264
bool show_alignment_
Indicates whether an alignment is currently visualized.
Definition: Spectrum1DCanvas.h:251
Size alignment_layer_1_
Layer index of the first alignment layer.
Definition: Spectrum1DCanvas.h:253
bool mirror_mode_
Indicates whether this widget is currently in mirror mode.
Definition: Spectrum1DCanvas.h:245
Canvas for visualization of one or several spectra.
Definition: Spectrum1DCanvas.h:63
Management and storage of parameters / INI files.
Definition: Param.h:69
Definition: Spectrum1DCanvas.h:74
QPoint measurement_start_point_
start point of &quot;ruler&quot; for measure mode
Definition: Spectrum1DCanvas.h:243
DoubleReal alignment_score_
Stores the score of the last alignment.
Definition: Spectrum1DCanvas.h:262
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
std::vector< std::pair< DoubleReal, DoubleReal > > aligned_peaks_mz_delta_
Stores the alignment as MZ values of pairs of aligned peaks in both spectra.
Definition: Spectrum1DCanvas.h:257
std::vector< std::pair< Size, Size > > aligned_peaks_indices_
Stores the peak indizes of pairs of aligned peaks in both spectra.
Definition: Spectrum1DCanvas.h:259
Definition: Spectrum1DCanvas.h:73
Index of a peak or feature.
Definition: PeakIndex.h:51

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:21 using doxygen 1.8.5