QGpGuiTools/ColorPaletteData.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpGuiTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2008-03-02
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef COLORPALETTEDATA_H
00029 #define COLORPALETTEDATA_H
00030 
00031 #include <QtGui>
00032 #include <QGpCoreTools.h>
00033 #include "QGpGuiToolsDLLExport.h"
00034 
00035 namespace QGpGuiTools {
00036 
00037 class QGPGUITOOLS_EXPORT ColorPaletteData : public QSharedData
00038 {
00039 public:
00040   ColorPaletteData();
00041   ColorPaletteData(const ColorPaletteData& o);
00042   ~ColorPaletteData();
00043 
00044   bool operator==(const ColorPaletteData& o) const;
00045   bool operator!=(const ColorPaletteData& o) const {return ! operator==(o);}
00046 
00047   void allocate(int n);
00048   void defaultRGBColors(int n, int transparency);
00049   void defaultHSVColors(int sat, int value, int n, int transparency);
00050   void defaultBW(int n, int transparency);
00051   void colorRGBInterpole(int imin, int imax);
00052   void colorHSVInterpole(int imin, int imax);
00053   void setVLinear(double min, double max) {setVLinear(0, _n-2, min, max);}
00054   void setVLog(double min, double max) {setVLog(0, _n-2, min, max);}
00055   void setVLinear(int imin, int imax, double min, double max);
00056   void setVLog(int imin, int imax, double min, double max);
00057 
00058   int count() const {return _n;}
00059 
00060   void setUpperValue(int i, double v) {_upperValues[i]=v;}
00061   double upperValue(int i) const {return i<_n-1 ? _upperValues[i] : 1e99;}
00062   double lowerValue(int i) const {return i>0 ? _upperValues[i-1] : -1e99;}
00063 
00064   QColor& color(int i) const {return _colors[i];}
00065   QColor& color(double val) const {return _colors[index(val)];}
00066   void setColor(int i, const QColor& c) const {_colors[i]=c;}
00067 
00068   int index(double val) const;
00069 private:
00070   QColor * _colors;
00071   double * _upperValues;
00072   int _n;
00073   int _n2;
00074 };
00075 
00076 } // namespace QGpGuiTools
00077 
00078 #endif // COLORPALETTEDATA_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines