Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

Spectrum2DCanvas.h (Maintainer: Marc Sturm)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Marc Sturm $
00025 // --------------------------------------------------------------------------
00026 
00027 
00028 #ifndef OPENMS_VISUAL_SPECTRUM2DCANVAS_H
00029 #define OPENMS_VISUAL_SPECTRUM2DCANVAS_H
00030 
00031 // OpenMS
00032 #include <OpenMS/VISUAL/SpectrumCanvas.h>
00033 #include <OpenMS/VISUAL/Spectrum1DCanvas.h>
00034 #include <OpenMS/VISUAL/MultiGradient.h>
00035 
00036 // QT
00037 class QPainter;
00038 class QMouseEvent;
00039 class QWheelEvent;
00040 
00041 namespace OpenMS
00042 {
00056   class Spectrum2DCanvas 
00057     : public SpectrumCanvas
00058   {
00059       Q_OBJECT
00060 
00061     public:
00063       Spectrum2DCanvas(const Param& preferences, QWidget* parent = 0);
00064 
00066       ~Spectrum2DCanvas();
00067 
00068       // Docu in base class
00069       virtual void showCurrentLayerPreferences();
00070 
00071       // Docu in base class
00072       virtual void saveCurrentLayer(bool visible);
00073       
00074     signals:
00076       void showProjectionHorizontal(const MSExperiment<>&, Spectrum1DCanvas::DrawModes);
00078       void showProjectionVertical(const MSExperiment<>&, Spectrum1DCanvas::DrawModes);
00080       void showProjectionInfo(int, double, double);
00082       void showCurrentPeaksAs3D();
00084       void showSpectrumAs1D(int index);
00085     
00086     public slots:
00087 
00088       // Docu in base class
00089       void activateLayer(int layer_index);
00090       // Docu in base class
00091       void removeLayer(int layer_index);
00092       // Docu in base class
00093       Int finishAdding();
00094       // Docu in base class
00095       virtual void horizontalScrollBarChange(int value);
00096       // Docu in base class
00097       virtual void verticalScrollBarChange(int value);
00107       void showProjections();
00108       
00109     protected:
00112       void mousePressEvent(QMouseEvent* e);
00113       void mouseReleaseEvent(QMouseEvent* e);
00114       void mouseMoveEvent(QMouseEvent* e);
00115       void wheelEvent(QWheelEvent* e);
00116       void mouseDoubleClickEvent(QMouseEvent* e);
00117       void paintEvent(QPaintEvent* e);
00118       void contextMenuEvent(QContextMenuEvent* e);
00120 
00121       // Docu in base class
00122       virtual void updateScrollbars_();
00123 
00133       void paintDots_(UInt layer_index, QPainter& p);
00134 
00141       void paintTraceConvexHulls_(UInt layer_index, QPainter& p);
00142 
00149       void paintFeatureConvexHulls_(UInt layer_index, QPainter& p);
00150 
00157       void paintConvexHulls_(const std::vector<ConvexHull2D>& hulls, QPainter& p);
00158 
00165       void paintFeaturePairConnections_(UInt layer_index, QPainter& p);
00166       
00167       // Docu in base class
00168       virtual void intensityModeChange_();
00169       // DOcu in base class
00170       virtual void recalculateSnapFactor_();
00171       // Docu in base class
00172       virtual void currentLayerParamtersChanged_();
00174       void recalculateDotGradient_(UInt layer);
00175 
00177       MSExperiment<> projection_mz_;
00179       MSExperiment<> projection_rt_;
00180 
00181 
00183       float betweenFactor_(float v1, float v2, float val);
00189       inline const QColor& heightColor_(float val, const MultiGradient& gradient)
00190       {
00191         switch (intensity_mode_)
00192         {
00193           case IM_NONE:
00194             return gradient.precalculatedColorAt(val);
00195             break;
00196           case IM_PERCENTAGE:
00197             return gradient.precalculatedColorAt(val*percentage_factor_);
00198             break;
00199           case IM_SNAP:
00200             return gradient.precalculatedColorAt(val*snap_factor_);
00201             break;
00202           default:
00203             throw Exception::NotImplemented(__FILE__, __LINE__, __PRETTY_FUNCTION__);
00204         }
00205       }
00206 
00208       void highlightPeak_(QPainter& p, const Feature* peak);
00209 
00211       const Feature* findNearestPeak_(const QPoint& pos);
00212 
00214       const Feature* selected_peak_;
00216       const Feature* measurement_start_;
00218       const Feature* measurement_stop_;
00220       Feature tmp_peak_;
00221 
00222   };
00223 }
00224 
00225 #endif

Generated Tue Apr 1 15:36:38 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1