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-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 
36 #ifndef OPENMS_VISUAL_SPECTRUM2DCANVAS_H
37 #define OPENMS_VISUAL_SPECTRUM2DCANVAS_H
38 
39 // OpenMS
43 
44 // QT
45 class QPainter;
46 class QMouseEvent;
47 
48 namespace OpenMS
49 {
67  class OPENMS_GUI_DLLAPI Spectrum2DCanvas :
68  public SpectrumCanvas
69  {
70  Q_OBJECT
71 
72 public:
74  Spectrum2DCanvas(const Param& preferences, QWidget* parent = 0);
75 
78 
79  // Docu in base class
80  virtual void showCurrentLayerPreferences();
81 
82  // Docu in base class
83  virtual void saveCurrentLayer(bool visible);
84 
86  void mergeIntoLayer(Size i, FeatureMapSharedPtrType map);
87 
89  void mergeIntoLayer(Size i, ConsensusMapSharedPtrType map);
90 
92  void mergeIntoLayer(Size i, std::vector<PeptideIdentification>& peptides);
93 
95  void recalculateCurrentLayerDotGradient();
96 
97 signals:
99  void showProjectionHorizontal(ExperimentSharedPtrType, Spectrum1DCanvas::DrawModes);
101  void showProjectionVertical(ExperimentSharedPtrType, Spectrum1DCanvas::DrawModes);
103  void showProjectionInfo(int, double, double);
105  void toggleProjections();
107  void showSpectrumAs1D(int index);
108  void showSpectrumAs1D(std::vector<int, std::allocator<int> > indices);
110  void showCurrentPeaksAs3D();
111 
112 public slots:
113  // Docu in base class
114  void activateLayer(Size layer_index);
115  // Docu in base class
116  void removeLayer(Size layer_index);
117  //docu in base class
118  virtual void updateLayer(Size i);
119  // Docu in base class
120  virtual void horizontalScrollBarChange(int value);
121  // Docu in base class
122  virtual void verticalScrollBarChange(int value);
123 
133  void updateProjections();
134 
135 protected slots:
136 
138  void currentLayerParametersChanged_();
139 
140 protected:
141  // Docu in base class
142  bool finishAdding_();
143 
145  void drawCoordinates_(QPainter& painter, const PeakIndex& peak);
147  void drawDeltas_(QPainter& painter, const PeakIndex& start, const PeakIndex& end);
148 
151  void mousePressEvent(QMouseEvent* e);
152  void mouseReleaseEvent(QMouseEvent* e);
153  void mouseMoveEvent(QMouseEvent* e);
154  void paintEvent(QPaintEvent* e);
155  void contextMenuEvent(QContextMenuEvent* e);
156  void keyPressEvent(QKeyEvent* e);
157  void keyReleaseEvent(QKeyEvent* e);
158  void mouseDoubleClickEvent(QMouseEvent* e);
160 
161  // Docu in base class
162  virtual void updateScrollbars_();
163 
172  void paintDots_(Size layer_index, QPainter& p);
173 
174  void paintAllIntensities_(Size layer_index, DoubleReal pen_width, QPainter& painter);
175 
187  void paintMaximumIntensities_(Size layer_index, Size rt_pixel_count, Size mz_pixel_count, QPainter& p);
188 
195  void paintPrecursorPeaks_(Size layer_index, QPainter& painter);
196 
203  void paintFeatureData_(Size layer_index, QPainter& p);
204 
211  void paintTraceConvexHulls_(Size layer_index, QPainter& p);
212 
219  void paintFeatureConvexHulls_(Size layer_index, QPainter& p);
220 
227  void paintIdentifications_(Size layer_index, QPainter& p);
228 
235  void paintConsensusElements_(Size layer_index, QPainter& p);
236 
245  void paintConsensusElement_(Size layer_index, const ConsensusFeature& cf, QPainter& p, bool use_buffer);
246 
253  bool isConsensusFeatureVisible_(const ConsensusFeature& ce, Size layer_index);
254 
261  void paintConvexHulls_(const std::vector<ConvexHull2D>& hulls, bool hasIdentifications, QPainter& p);
262 
263  // Docu in base class
264  virtual void intensityModeChange_();
265  // DOcu in base class
266  virtual void recalculateSnapFactor_();
267 
269  ExperimentType projection_mz_;
271  ExperimentType projection_rt_;
272 
278  inline Int precalculatedColorIndex_(Real val, const MultiGradient& gradient, DoubleReal snap_factor)
279  {
280  Real gradientPos;
281  switch (intensity_mode_)
282  {
283  case IM_NONE:
284  gradientPos = val;
285  break;
286 
287  case IM_PERCENTAGE:
288  gradientPos = val * percentage_factor_;
289  break;
290 
291  case IM_SNAP:
292  gradientPos = val * snap_factor;
293  break;
294 
295  case IM_LOG:
296  gradientPos = std::log(val + 1);
297  break;
298 
299  default:
300  throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
301  }
302  return gradient.precalculatedColorIndex(gradientPos);
303  }
304 
310  inline QColor heightColor_(Real val, const MultiGradient& gradient, DoubleReal snap_factor)
311  {
312  return gradient.precalculatedColorByIndex(precalculatedColorIndex_(val, gradient, snap_factor));
313  }
314 
323  inline void dataToWidget_(DoubleReal x, DoubleReal y, QPoint& point)
324  {
325  if (!isMzToXAxis())
326  {
327  point.setX(int((y - visible_area_.minY()) / visible_area_.height() * width()));
328  point.setY(height() - int((x - visible_area_.minX()) / visible_area_.width() * height()));
329  }
330  else
331  {
332  point.setX(int((x - visible_area_.minX()) / visible_area_.width() * width()));
333  point.setY(height() - int((y - visible_area_.minY()) / visible_area_.height() * height()));
334  }
335  }
336 
338  void recalculateDotGradient_(Size layer);
339 
341  void highlightPeak_(QPainter& p, const PeakIndex& peak);
342 
344  PeakIndex findNearestPeak_(const QPoint& pos);
345 
347  void paintIcon_(const QPoint& pos, const QRgb& color, const String& icon, Size s, QPainter& p) const;
348 
353 
355  virtual void translateVisibleArea_(DoubleReal mzShiftRel, DoubleReal rtShiftRel);
356 
357  //docu in base class
358  virtual void translateLeft_();
359  //docu in base class
360  virtual void translateRight_();
361  //docu in base class
362  virtual void translateForward_();
363  //docu in base class
364  virtual void translateBackward_();
365 
367  void finishContextMenu_(QMenu* context_menu, QMenu* settings_menu);
368  };
369 }
370 
371 #endif
LayerData::ExperimentSharedPtrType ExperimentSharedPtrType
Main managed data type (experiment)
Definition: SpectrumCanvas.h:107
float Real
Real type.
Definition: Types.h:109
A more convenient string class.
Definition: String.h:56
PeakIndex measurement_start_
start peak/feature of measuring mode
Definition: Spectrum2DCanvas.h:352
DrawModes
Enumerate all avaiable paint styles.
Definition: Spectrum1DCanvas.h:84
LayerData::ConsensusMapSharedPtrType ConsensusMapSharedPtrType
Main managed data type (consensus features)
Definition: SpectrumCanvas.h:115
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:94
QColor heightColor_(Real val, const MultiGradient &gradient, DoubleReal snap_factor)
Returns the color associated with val for the gradient gradient.
Definition: Spectrum2DCanvas.h:310
Canvas for 2D-visualization of peak map, feature map and consensus map data.
Definition: Spectrum2DCanvas.h:67
Int precalculatedColorIndex_(Real val, const MultiGradient &gradient, DoubleReal snap_factor)
Returns the position on color gradient associated with given intensity.
Definition: Spectrum2DCanvas.h:278
void dataToWidget_(DoubleReal x, DoubleReal y, QPoint &point)
Convert chart to widget coordinates.
Definition: Spectrum2DCanvas.h:323
Management and storage of parameters / INI files.
Definition: Param.h:69
ExperimentType projection_rt_
RT projection data.
Definition: Spectrum2DCanvas.h:271
Int precalculatedColorIndex(DoubleReal position) const
index of color in precalculated table by position in gradient
Definition: MultiGradient.h:134
LayerData::FeatureMapSharedPtrType FeatureMapSharedPtrType
Main managed data type (features)
Definition: SpectrumCanvas.h:111
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
ExperimentType projection_mz_
m/z projection data
Definition: Spectrum2DCanvas.h:269
QColor precalculatedColorByIndex(Int index) const
precalculated color by its index in the table
Definition: MultiGradient.h:145
PeakIndex selected_peak_
the nearest peak/feature to the mouse cursor
Definition: Spectrum2DCanvas.h:350
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:65
int Int
Signed integer type.
Definition: Types.h:100
Not implemented exception.
Definition: Exception.h:437
A 2-dimensional consensus feature.
Definition: ConsensusFeature.h:59
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