Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Spectrum2DCanvas.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 $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_VISUAL_SPECTRUM2DCANVAS_H
36 #define OPENMS_VISUAL_SPECTRUM2DCANVAS_H
37 
38 // OpenMS_GUI config
39 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
40 
41 // OpenMS
45 
46 // QT
47 class QPainter;
48 class QMouseEvent;
49 class QAction;
50 class QMenu;
51 
52 namespace OpenMS
53 {
71  class OPENMS_GUI_DLLAPI Spectrum2DCanvas :
72  public SpectrumCanvas
73  {
74  Q_OBJECT
75 
76 public:
78  Spectrum2DCanvas(const Param& preferences, QWidget* parent = 0);
79 
82 
83  // Docu in base class
84  virtual void showCurrentLayerPreferences();
85 
86  // Docu in base class
87  virtual void saveCurrentLayer(bool visible);
88 
90  void mergeIntoLayer(Size i, FeatureMapSharedPtrType map);
91 
93  void mergeIntoLayer(Size i, ConsensusMapSharedPtrType map);
94 
96  void mergeIntoLayer(Size i, std::vector<PeptideIdentification>& peptides);
97 
99  void recalculateCurrentLayerDotGradient();
100 
101 signals:
103  void showProjectionHorizontal(ExperimentSharedPtrType);
105  void showProjectionVertical(ExperimentSharedPtrType);
107  void showProjectionInfo(int, double, double);
109  void toggleProjections();
111  void showSpectrumAs1D(int index);
112  void showSpectrumAs1D(std::vector<int, std::allocator<int> > indices);
114  void showCurrentPeaksAs3D();
115 
116 public slots:
117  // Docu in base class
118  void activateLayer(Size layer_index);
119  // Docu in base class
120  void removeLayer(Size layer_index);
121  //docu in base class
122  virtual void updateLayer(Size i);
123  // Docu in base class
124  virtual void horizontalScrollBarChange(int value);
125  // Docu in base class
126  virtual void verticalScrollBarChange(int value);
127 
137  void updateProjections();
138 
139 protected slots:
140 
142  void currentLayerParametersChanged_();
143 
144 protected:
145  // Docu in base class
146  bool finishAdding_();
147 
149  bool collectFragmentScansInArea(double rt_min, double rt_max, double mz_min, double mz_max, QAction* a, QMenu * msn_scans, QMenu * msn_meta);
150 
152  void drawCoordinates_(QPainter& painter, const PeakIndex& peak);
154  void drawDeltas_(QPainter& painter, const PeakIndex& start, const PeakIndex& end);
155 
158  void mousePressEvent(QMouseEvent* e);
159  void mouseReleaseEvent(QMouseEvent* e);
160  void mouseMoveEvent(QMouseEvent* e);
161  void paintEvent(QPaintEvent* e);
162  void contextMenuEvent(QContextMenuEvent* e);
163  void keyPressEvent(QKeyEvent* e);
164  void keyReleaseEvent(QKeyEvent* e);
165  void mouseDoubleClickEvent(QMouseEvent* e);
167 
168  // Docu in base class
169  virtual void updateScrollbars_();
170 
179  void paintDots_(Size layer_index, QPainter& p);
180 
181  void paintAllIntensities_(Size layer_index, double pen_width, QPainter& painter);
182 
194  void paintMaximumIntensities_(Size layer_index, Size rt_pixel_count, Size mz_pixel_count, QPainter& p);
195 
202  void paintPrecursorPeaks_(Size layer_index, QPainter& painter);
203 
210  void paintFeatureData_(Size layer_index, QPainter& p);
211 
218  void paintTraceConvexHulls_(Size layer_index, QPainter& p);
219 
226  void paintFeatureConvexHulls_(Size layer_index, QPainter& p);
227 
234  void paintIdentifications_(Size layer_index, QPainter& p);
235 
242  void paintConsensusElements_(Size layer_index, QPainter& p);
243 
252  void paintConsensusElement_(Size layer_index, const ConsensusFeature& cf, QPainter& p, bool use_buffer);
253 
260  bool isConsensusFeatureVisible_(const ConsensusFeature& ce, Size layer_index);
261 
268  void paintConvexHulls_(const std::vector<ConvexHull2D>& hulls, bool hasIdentifications, QPainter& p);
269 
270  // Docu in base class
271  virtual void intensityModeChange_();
272  // DOcu in base class
273  virtual void recalculateSnapFactor_();
274 
280  inline Int precalculatedColorIndex_(float val, const MultiGradient& gradient, double snap_factor)
281  {
282  float gradientPos;
283  switch (intensity_mode_)
284  {
285  case IM_NONE:
286  gradientPos = val;
287  break;
288 
289  case IM_PERCENTAGE:
290  gradientPos = val * percentage_factor_;
291  break;
292 
293  case IM_SNAP:
294  gradientPos = val * snap_factor;
295  break;
296 
297  case IM_LOG:
298  gradientPos = std::log(val + 1);
299  break;
300 
301  default:
302  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
303  }
304  return gradient.precalculatedColorIndex(gradientPos);
305  }
306 
312  inline QColor heightColor_(float val, const MultiGradient& gradient, double snap_factor)
313  {
314  return gradient.precalculatedColorByIndex(precalculatedColorIndex_(val, gradient, snap_factor));
315  }
316 
325  inline void dataToWidget_(double x, double y, QPoint& point)
326  {
327  if (!isMzToXAxis())
328  {
329  point.setX(int((y - visible_area_.minY()) / visible_area_.height() * width()));
330  point.setY(height() - int((x - visible_area_.minX()) / visible_area_.width() * height()));
331  }
332  else
333  {
334  point.setX(int((x - visible_area_.minX()) / visible_area_.width() * width()));
335  point.setY(height() - int((y - visible_area_.minY()) / visible_area_.height() * height()));
336  }
337  }
338 
350  double adaptPenScaling_(double ratio_data2pixel, double& pen_size) const;
351 
353  void recalculateDotGradient_(Size layer);
354 
356  void highlightPeak_(QPainter& p, const PeakIndex& peak);
357 
359  PeakIndex findNearestPeak_(const QPoint& pos);
360 
362  void paintIcon_(const QPoint& pos, const QRgb& color, const String& icon, Size s, QPainter& p) const;
363 
365  virtual void translateVisibleArea_(double mzShiftRel, double rtShiftRel);
366 
367  //docu in base class
368  virtual void translateLeft_(Qt::KeyboardModifiers m);
369  //docu in base class
370  virtual void translateRight_(Qt::KeyboardModifiers m);
371  //docu in base class
372  virtual void translateForward_();
373  //docu in base class
374  virtual void translateBackward_();
375 
377  void finishContextMenu_(QMenu* context_menu, QMenu* settings_menu);
378 
380  ExperimentType projection_mz_;
382  ExperimentType projection_rt_;
383 
388 
391 
392  double pen_size_min_; //< minimum number of pixels for one data point
393  double pen_size_max_; //< maximum number of pixels for one data point
394  double canvas_coverage_min_; //< minimum coverage of the canvas required; if lower, points are upscaled in size
395 
396  private:
399 
400  };
401 }
402 
403 #endif
LayerData::ExperimentSharedPtrType ExperimentSharedPtrType
Main managed data type (experiment)
Definition: SpectrumCanvas.h:109
A more convenient string class.
Definition: String.h:57
PeakIndex measurement_start_
start peak/feature of measuring mode
Definition: Spectrum2DCanvas.h:387
Int precalculatedColorIndex(double position) const
index of color in precalculated table by position in gradient
Definition: MultiGradient.h:137
LayerData::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Main managed data type (consensus features)
Definition: SpectrumCanvas.h:117
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:96
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
QColor precalculatedColorByIndex(Int index) const
precalculated color by its index in the table
Definition: MultiGradient.h:148
Canvas for 2D-visualization of peak map, feature map and consensus map data.
Definition: Spectrum2DCanvas.h:71
QColor heightColor_(float val, const MultiGradient &gradient, double snap_factor)
Returns the color associated with val for the gradient gradient.
Definition: Spectrum2DCanvas.h:312
void dataToWidget_(double x, double y, QPoint &point)
Convert chart to widget coordinates.
Definition: Spectrum2DCanvas.h:325
double pen_size_min_
Definition: Spectrum2DCanvas.h:392
Int precalculatedColorIndex_(float val, const MultiGradient &gradient, double snap_factor)
Returns the position on color gradient associated with given intensity.
Definition: Spectrum2DCanvas.h:280
double canvas_coverage_min_
Definition: Spectrum2DCanvas.h:394
MultiGradient linear_gradient_
stores the linear color gradient for non-log modes
Definition: Spectrum2DCanvas.h:390
Management and storage of parameters / INI files.
Definition: Param.h:75
ExperimentType projection_rt_
RT projection data.
Definition: Spectrum2DCanvas.h:382
LayerData::FeatureMapSharedPtrType FeatureMapSharedPtrType
Main managed data type (features)
Definition: SpectrumCanvas.h:113
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
ExperimentType projection_mz_
m/z projection data
Definition: Spectrum2DCanvas.h:380
PeakIndex selected_peak_
the nearest peak/feature to the mouse cursor
Definition: Spectrum2DCanvas.h:385
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:68
int Int
Signed integer type.
Definition: Types.h:103
Not implemented exception.
Definition: Exception.h:437
A 2-dimensional consensus feature.
Definition: ConsensusFeature.h:65
Index of a peak or feature.
Definition: PeakIndex.h:51
double pen_size_max_
Definition: Spectrum2DCanvas.h:393

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