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-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_SPECTRUM2DCANVAS_H
36 #define OPENMS_VISUAL_SPECTRUM2DCANVAS_H
37 
38 // OpenMS_GUI config
40 
41 // OpenMS
45 
46 // QT
47 class QPainter;
48 class QMouseEvent;
49 
50 namespace OpenMS
51 {
69  class OPENMS_GUI_DLLAPI Spectrum2DCanvas :
70  public SpectrumCanvas
71  {
72  Q_OBJECT
73 
74 public:
76  Spectrum2DCanvas(const Param& preferences, QWidget* parent = 0);
77 
80 
81  // Docu in base class
82  virtual void showCurrentLayerPreferences();
83 
84  // Docu in base class
85  virtual void saveCurrentLayer(bool visible);
86 
88  void mergeIntoLayer(Size i, FeatureMapSharedPtrType map);
89 
91  void mergeIntoLayer(Size i, ConsensusMapSharedPtrType map);
92 
94  void mergeIntoLayer(Size i, std::vector<PeptideIdentification>& peptides);
95 
97  void recalculateCurrentLayerDotGradient();
98 
99 signals:
101  void showProjectionHorizontal(ExperimentSharedPtrType);
103  void showProjectionVertical(ExperimentSharedPtrType);
105  void showProjectionInfo(int, double, double);
107  void toggleProjections();
109  void showSpectrumAs1D(int index);
110  void showSpectrumAs1D(std::vector<int, std::allocator<int> > indices);
112  void showCurrentPeaksAs3D();
113 
114 public slots:
115  // Docu in base class
116  void activateLayer(Size layer_index);
117  // Docu in base class
118  void removeLayer(Size layer_index);
119  //docu in base class
120  virtual void updateLayer(Size i);
121  // Docu in base class
122  virtual void horizontalScrollBarChange(int value);
123  // Docu in base class
124  virtual void verticalScrollBarChange(int value);
125 
135  void updateProjections();
136 
137 protected slots:
138 
140  void currentLayerParametersChanged_();
141 
142 protected:
143  // Docu in base class
144  bool finishAdding_();
145 
147  void drawCoordinates_(QPainter& painter, const PeakIndex& peak);
149  void drawDeltas_(QPainter& painter, const PeakIndex& start, const PeakIndex& end);
150 
153  void mousePressEvent(QMouseEvent* e);
154  void mouseReleaseEvent(QMouseEvent* e);
155  void mouseMoveEvent(QMouseEvent* e);
156  void paintEvent(QPaintEvent* e);
157  void contextMenuEvent(QContextMenuEvent* e);
158  void keyPressEvent(QKeyEvent* e);
159  void keyReleaseEvent(QKeyEvent* e);
160  void mouseDoubleClickEvent(QMouseEvent* e);
162 
163  // Docu in base class
164  virtual void updateScrollbars_();
165 
174  void paintDots_(Size layer_index, QPainter& p);
175 
176  void paintAllIntensities_(Size layer_index, double pen_width, QPainter& painter);
177 
189  void paintMaximumIntensities_(Size layer_index, Size rt_pixel_count, Size mz_pixel_count, QPainter& p);
190 
197  void paintPrecursorPeaks_(Size layer_index, QPainter& painter);
198 
205  void paintFeatureData_(Size layer_index, QPainter& p);
206 
213  void paintTraceConvexHulls_(Size layer_index, QPainter& p);
214 
221  void paintFeatureConvexHulls_(Size layer_index, QPainter& p);
222 
229  void paintIdentifications_(Size layer_index, QPainter& p);
230 
237  void paintConsensusElements_(Size layer_index, QPainter& p);
238 
247  void paintConsensusElement_(Size layer_index, const ConsensusFeature& cf, QPainter& p, bool use_buffer);
248 
255  bool isConsensusFeatureVisible_(const ConsensusFeature& ce, Size layer_index);
256 
263  void paintConvexHulls_(const std::vector<ConvexHull2D>& hulls, bool hasIdentifications, QPainter& p);
264 
265  // Docu in base class
266  virtual void intensityModeChange_();
267  // DOcu in base class
268  virtual void recalculateSnapFactor_();
269 
275  inline Int precalculatedColorIndex_(float val, const MultiGradient& gradient, double snap_factor)
276  {
277  float gradientPos;
278  switch (intensity_mode_)
279  {
280  case IM_NONE:
281  gradientPos = val;
282  break;
283 
284  case IM_PERCENTAGE:
285  gradientPos = val * percentage_factor_;
286  break;
287 
288  case IM_SNAP:
289  gradientPos = val * snap_factor;
290  break;
291 
292  case IM_LOG:
293  gradientPos = std::log(val + 1);
294  break;
295 
296  default:
297  throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
298  }
299  return gradient.precalculatedColorIndex(gradientPos);
300  }
301 
307  inline QColor heightColor_(float val, const MultiGradient& gradient, double snap_factor)
308  {
309  return gradient.precalculatedColorByIndex(precalculatedColorIndex_(val, gradient, snap_factor));
310  }
311 
320  inline void dataToWidget_(double x, double y, QPoint& point)
321  {
322  if (!isMzToXAxis())
323  {
324  point.setX(int((y - visible_area_.minY()) / visible_area_.height() * width()));
325  point.setY(height() - int((x - visible_area_.minX()) / visible_area_.width() * height()));
326  }
327  else
328  {
329  point.setX(int((x - visible_area_.minX()) / visible_area_.width() * width()));
330  point.setY(height() - int((y - visible_area_.minY()) / visible_area_.height() * height()));
331  }
332  }
333 
345  double adaptPenScaling_(double ratio_data2pixel, double& pen_size) const;
346 
348  void recalculateDotGradient_(Size layer);
349 
351  void highlightPeak_(QPainter& p, const PeakIndex& peak);
352 
354  PeakIndex findNearestPeak_(const QPoint& pos);
355 
357  void paintIcon_(const QPoint& pos, const QRgb& color, const String& icon, Size s, QPainter& p) const;
358 
360  virtual void translateVisibleArea_(double mzShiftRel, double rtShiftRel);
361 
362  //docu in base class
363  virtual void translateLeft_();
364  //docu in base class
365  virtual void translateRight_();
366  //docu in base class
367  virtual void translateForward_();
368  //docu in base class
369  virtual void translateBackward_();
370 
372  void finishContextMenu_(QMenu* context_menu, QMenu* settings_menu);
373 
378 
383 
384  double pen_size_min_; //< minimum number of pixels for one data point
385  double pen_size_max_; //< maximum number of pixels for one data point
386  double canvas_coverage_min_; //< minimum coverage of the canvas required; if lower, points are upscaled in size
387 
388  private:
391 
392  };
393 }
394 
395 #endif
A more convenient string class.
Definition: String.h:57
LayerData::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Main managed data type (consensus features)
Definition: SpectrumCanvas.h:117
PeakIndex measurement_start_
start peak/feature of measuring mode
Definition: Spectrum2DCanvas.h:382
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:96
LayerData::ExperimentSharedPtrType ExperimentSharedPtrType
Main managed data type (experiment)
Definition: SpectrumCanvas.h:109
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Canvas for 2D-visualization of peak map, feature map and consensus map data.
Definition: Spectrum2DCanvas.h:69
QColor heightColor_(float val, const MultiGradient &gradient, double snap_factor)
Returns the color associated with val for the gradient gradient.
Definition: Spectrum2DCanvas.h:307
void dataToWidget_(double x, double y, QPoint &point)
Convert chart to widget coordinates.
Definition: Spectrum2DCanvas.h:320
double pen_size_min_
Definition: Spectrum2DCanvas.h:384
Int precalculatedColorIndex_(float val, const MultiGradient &gradient, double snap_factor)
Returns the position on color gradient associated with given intensity.
Definition: Spectrum2DCanvas.h:275
double canvas_coverage_min_
Definition: Spectrum2DCanvas.h:386
Management and storage of parameters / INI files.
Definition: Param.h:75
ExperimentType projection_rt_
RT projection data.
Definition: Spectrum2DCanvas.h:377
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:69
ExperimentType projection_mz_
m/z projection data
Definition: Spectrum2DCanvas.h:375
QColor precalculatedColorByIndex(Int index) const
precalculated color by its index in the table
Definition: MultiGradient.h:148
PeakIndex selected_peak_
the nearest peak/feature to the mouse cursor
Definition: Spectrum2DCanvas.h:380
LayerData::FeatureMapSharedPtrType FeatureMapSharedPtrType
Main managed data type (features)
Definition: SpectrumCanvas.h:113
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:68
int Int
Signed integer type.
Definition: Types.h:96
Int precalculatedColorIndex(double position) const
index of color in precalculated table by position in gradient
Definition: MultiGradient.h:137
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:385

OpenMS / TOPP release 2.0.0 Documentation generated on Thu Aug 20 2015 01:44:29 using doxygen 1.8.9.1