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

MultiGradient.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 #ifndef OPENMS_VISUAL_MULTIGRADIENT_H
00028 #define OPENMS_VISUAL_MULTIGRADIENT_H
00029 
00030 //OpenMS
00031 #include <OpenMS/CONCEPT/Types.h>
00032 #include <OpenMS/CONCEPT/Macros.h>
00033 #include <OpenMS/CONCEPT/Exception.h>
00034 
00035 //QT
00036 #include <QtGui/QColor>
00037 
00038 //STL
00039 #include <map>
00040 #include <vector>
00041 #include <cmath>
00042 
00043 namespace OpenMS 
00044 {
00045   
00056   class MultiGradient
00057   {
00058     public:
00059   
00061     enum InterpolationMode 
00062     {
00063       IM_LINEAR,  
00064       IM_STAIRS   
00065     };
00066     
00068     MultiGradient();
00070     ~MultiGradient();
00071   
00073     void insert (Int position, const QColor& color);
00075     bool remove (Int position);
00077     bool exists (Int position);
00079     UInt position(UInt index) throw (Exception::IndexUnderflow,Exception::IndexOverflow);
00081     const QColor& color(UInt index) throw (Exception::IndexUnderflow,Exception::IndexOverflow);
00082   
00083   
00090     QColor interpolatedColorAt(DoubleReal position) const;
00097     QColor interpolatedColorAt(DoubleReal position, DoubleReal min, DoubleReal max) const;
00098   
00100     void activatePrecalculationMode(DoubleReal min, DoubleReal max, UInt steps);
00102     void deactivatePrecalculationMode();
00110     inline const QColor& precalculatedColorAt(DoubleReal position) const
00111     {
00112       OPENMS_PRECONDITION(pre_.size()!=0,"MultiGradient::precalculatedColorAt(DoubleReal): Precalculation mode not activated!");
00113       OPENMS_PRECONDITION(position>=pre_min_,"MultiGradient::precalculatedColorAt(DoubleReal): Position out of specified range!");
00114       OPENMS_PRECONDITION(position<=pre_min_+pre_size_,"MultiGradient::precalculatedColorAt(DoubleReal): Position out of specified range!");
00115       return pre_[(UInt)((position - pre_min_) / pre_size_ * pre_steps_)];  
00116     }
00117 
00119     UInt size() const;
00120   
00122     void setInterpolationMode(UInt mode);
00124     UInt getInterpolationMode() const;
00125   
00127     std::string toString() const;
00143     void fromString(const std::string& gradient);
00144   
00145     protected:
00147     std::map<UInt,QColor> pos_col_;
00149     UInt interpolation_mode_;
00151     std::vector<QColor> pre_;
00153     DoubleReal pre_min_;
00155     DoubleReal pre_size_;
00157     UInt pre_steps_;
00158   
00159   };
00160   
00161 }
00162 #endif // OPENMS_VISUAL_MULTIGRADIENT_H
00163 

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