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-2015.
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 // OpenMS_GUI config
40 
41 // STL
42 #include <vector>
43 #include <utility>
44 
45 // OpenMS
47 
48 //QT
49 class QAction;
50 
51 namespace OpenMS
52 {
66  class OPENMS_GUI_DLLAPI Spectrum1DCanvas :
67  public SpectrumCanvas
68  {
69  Q_OBJECT
70 
71 public:
73  enum LabelMode
74  {
78  LM_XPERCENT_YPERCENT
79  };
80 
82  Spectrum1DCanvas(const Param & preferences, QWidget * parent = 0);
84  virtual ~Spectrum1DCanvas();
85 
87  enum DrawModes
88  {
89  DM_PEAKS, //< draw data as peak
90  DM_CONNECTEDLINES //< draw as connected lines
91  };
92 
94  DrawModes getDrawMode() const;
95 
97  void setDrawMode(DrawModes mode);
98 
99  // Docu in base class
100  virtual void showCurrentLayerPreferences();
101 
102  // Docu in base class
103  virtual void saveCurrentLayer(bool visible);
104 
106  bool flippedLayersExist();
107 
109  void flipLayer(Size index);
110 
112  bool mirrorModeActive();
113 
115  void setMirrorModeActive(bool b);
116 
118  void dataToWidget(const PeakType & peak, QPoint & point, bool flipped = false, bool percentage = true);
119 
121  void dataToWidget(double x, double y, QPoint & point, bool flipped = false, bool percentage = false);
122 
124  PointType widgetToData(const QPoint & pos, bool percentage = false);
125 
127  PointType widgetToData(double x, double y, bool percentage = false);
128 
130 
132  Annotation1DItem * addPeakAnnotation(PeakIndex peak_index, QString text, QColor color);
133 
135  void drawAnnotations(Size layer_index, QPainter & painter);
136 
138 
140  void performAlignment(Size layer_index_1, Size layer_index_2, const Param & param);
141 
143  void resetAlignment();
144 
146  void drawAlignment(QPainter & painter);
147 
149  Size getAlignmentSize();
150 
152  double getAlignmentScore();
153 
155  std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
156 
158  void activateSpectrum(Size index, bool repaint = true);
159 
161  void setSwappedAxis(bool swapped);
162 
164  void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
165 
167  void paint(QPainter * paint_device, QPaintEvent * e);
168 signals:
170  void showCurrentPeaksAs2D();
172  void showCurrentPeaksAs3D();
173 
174 public slots:
175  // Docu in base class
176  void activateLayer(Size layer_index);
177  // Docu in base class
178  void removeLayer(Size layer_index);
179  //docu in base class
180  virtual void updateLayer(Size i);
181 
188  void setVisibleArea(DRange<2> range); //Do not change this to AreaType the signal needs QT needs the exact type...
189  // Docu in base class
190  virtual void horizontalScrollBarChange(int value);
191 
192 protected slots:
193 
195  void currentLayerParamtersChanged_();
196 
197 protected:
198  // Docu in base class
199  bool finishAdding_();
200 
202  void drawCoordinates_(QPainter & painter, const PeakIndex & peak);
204  void drawDeltas_(QPainter & painter, const PeakIndex & start, const PeakIndex & end);
205 
211  void changeVisibleArea_(double lo, double hi, bool repaint = true, bool add_to_stack = false);
212 
214  void drawHighlightedPeak_(Size layer_index, const PeakIndex & peak, QPainter & painter, bool draw_elongation = false);
215 
217  void drawDashedLine_(const QPoint & from, const QPoint & to, QPainter & painter);
218 
220  void updatePercentageFactor_(Size layer_index);
221 
232  virtual void changeVisibleArea_(const AreaType & new_area, bool repaint = true, bool add_to_stack = false);
233  // Docu in base class
234  virtual void recalculateSnapFactor_();
235  // Docu in base class
236  virtual void updateScrollbars_();
237  // Docu in base class
238  virtual void intensityModeChange_();
239 
241  std::vector<DrawModes> draw_modes_;
243  std::vector<Qt::PenStyle> peak_penstyle_;
244 
249 
252 
260  std::vector<std::pair<double, double> > aligned_peaks_mz_delta_;
262  std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
263 
268 
270  PeakIndex findPeakAtPosition_(QPoint);
271 
273  void addUserLabelAnnotation_(const QPoint & screen_position);
275  void addLabelAnnotation_(const QPoint & screen_position, QString label_text);
277  void addUserPeakAnnotation_(PeakIndex near_peak);
278 
280  void ensureAnnotationsWithinDataRange_();
281 
284  void paintEvent(QPaintEvent * e);
285  void mousePressEvent(QMouseEvent * e);
286  void mouseReleaseEvent(QMouseEvent * e);
287  void mouseMoveEvent(QMouseEvent * e);
288  void keyPressEvent(QKeyEvent * e);
289  void contextMenuEvent(QContextMenuEvent * e);
291 
293  virtual void zoomForward_();
295  virtual void zoom_(int x, int y, bool zoom_in);
296  //docu in base class
297  virtual void translateLeft_();
298  //docu in base class
299  virtual void translateRight_();
300  //docu in base class
301  virtual void paintGridLines_(QPainter & painter);
302  };
303 } // namespace OpenMS
304 
305 #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:251
std::vector< DrawModes > draw_modes_
Draw modes (for each spectrum)
Definition: Spectrum1DCanvas.h:241
Size alignment_layer_2_
Layer index of the second alignment layer.
Definition: Spectrum1DCanvas.h:258
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:96
DrawModes
Enumerate all available paint styles.
Definition: Spectrum1DCanvas.h:87
std::vector< Qt::PenStyle > peak_penstyle_
Draw style.
Definition: Spectrum1DCanvas.h:243
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:267
Definition: Spectrum1DCanvas.h:89
Definition: Spectrum1DCanvas.h:75
bool show_alignment_
Indicates whether an alignment is currently visualized.
Definition: Spectrum1DCanvas.h:254
Size alignment_layer_1_
Layer index of the first alignment layer.
Definition: Spectrum1DCanvas.h:256
bool mirror_mode_
Indicates whether this widget is currently in mirror mode.
Definition: Spectrum1DCanvas.h:248
Canvas for visualization of one or several spectra.
Definition: Spectrum1DCanvas.h:66
Management and storage of parameters / INI files.
Definition: Param.h:75
double alignment_score_
Stores the score of the last alignment.
Definition: Spectrum1DCanvas.h:265
QPoint measurement_start_point_
start point of "ruler" for measure mode
Definition: Spectrum1DCanvas.h:246
LabelMode
Label modes (percentage or absolute) of x axis and y axis.
Definition: Spectrum1DCanvas.h:73
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:260
Definition: Spectrum1DCanvas.h:76
std::vector< std::pair< Size, Size > > aligned_peaks_indices_
Stores the peak indices of pairs of aligned peaks in both spectra.
Definition: Spectrum1DCanvas.h:262
Definition: Spectrum1DCanvas.h:77
Index of a peak or feature.
Definition: PeakIndex.h:51

OpenMS / TOPP release 2.0.0 Documentation generated on Fri May 29 2015 17:20:30 using doxygen 1.8.9.1