QGpGuiTools/ColorPalette.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 : 2002-05-24
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef COLORPALETTE_H
00030 #define COLORPALETTE_H
00031 
00032 #include <QGpCoreTools.h>
00033 
00034 #include "QGpGuiToolsDLLExport.h"
00035 #include "ColorPaletteData.h"
00036 
00037 namespace QGpGuiTools {
00038 
00039 class QGPGUITOOLS_EXPORT ColorPalette : public XMLClass
00040 {
00041   TRANSLATIONS( "ColorPalette" )
00042 public:
00043   ColorPalette() {_d=new ColorPaletteData;}
00044 
00045   virtual const QString& xml_tagName() const {return xmlColorPaletteTag;}
00046   static const QString xmlColorPaletteTag;
00047 
00048   bool operator==(const ColorPalette& o) const {return _d->operator==(*o._d);}
00049   bool operator!=(const ColorPalette& o) const {return _d->operator!=(*o._d);}
00050 
00051   void allocate(int n=10) {_d->allocate(n);}
00052   void defaultColors(int n=10, int transparency=255) {defaultHSVColors(255, 255, n, transparency);}
00053   inline void defaultRGBColors(int n=10, int transparency=255);
00054   inline void defaultHSVColors(int sat, int value, int n=10, int transparency=255);
00055   inline void defaultBW(int n=10, int transparency=255);
00056   inline void colorRGBInterpole(int imin, int imax);
00057   inline void colorHSVInterpole(int imin, int imax);
00058   inline void setVLinear(double min, double max);
00059   inline void setVLog(double min, double max);
00060   inline void setVLinear(int imin, int imax, double min, double max);
00061   inline void setVLog(int imin, int imax, double min, double max);
00062 
00063   int count() const {return _d->count();}
00064 
00065   void setUpperValue(int i, double v) {_d->setUpperValue(i, v);}
00066   double upperValue(int i) const {return _d->upperValue(i);}
00067   double lowerValue(int i) const {return _d->lowerValue(i);}
00068 
00069   const QColor& color(int i) const {return _d->color(i);}
00070   const QColor& color(double val) const {return _d->color(val);}
00071   void setColor(int i, const QColor& c) const {return _d->setColor(i, c);}
00072 
00073   int index(double val) const  {return _d->index(val);}
00074 protected:
00075   virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00076   virtual XMLMember xml_member(XML_MEMBER_ARGS);
00077   virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00078 private:
00079   QSharedDataPointer<ColorPaletteData> _d;
00080 };
00081 
00082 QGPGUITOOLS_EXPORT QTextStream& operator>>(QTextStream& s, ColorPalette& p);
00083 QGPGUITOOLS_EXPORT QTextStream& operator<<(QTextStream& s, const ColorPalette& p);
00084 
00085 inline void ColorPalette::defaultRGBColors(int n, int transparency)
00086 {
00087   _d->defaultRGBColors(n, transparency);
00088 }
00089 
00090 inline void ColorPalette::defaultHSVColors(int sat, int value, int n, int transparency)
00091 {
00092   _d->defaultHSVColors(sat, value, n, transparency);
00093 }
00094 
00095 inline void ColorPalette::defaultBW(int n, int transparency)
00096 {
00097   _d->defaultBW(n, transparency);
00098 }
00099 
00100 inline void ColorPalette::colorRGBInterpole(int imin, int imax)
00101 {
00102   _d->colorRGBInterpole(imin, imax);
00103 }
00104 
00105 inline void ColorPalette::colorHSVInterpole(int imin, int imax)
00106 {
00107   _d->colorHSVInterpole(imin, imax);
00108 }
00109 
00110 inline void ColorPalette::setVLinear(double min, double max)
00111 {
00112   _d->setVLinear(min, max);
00113 }
00114 
00115 inline void ColorPalette::setVLog(double min, double max)
00116 {
00117   _d->setVLog(min, max);
00118 }
00119 
00120 inline void ColorPalette::setVLinear(int imin, int imax, double min, double max)
00121 {
00122   _d->setVLinear(imin, imax, min, max);
00123 }
00124 
00125 inline void ColorPalette::setVLog(int imin, int imax, double min, double max)
00126 {
00127   _d->setVLog(imin, imax, min, max);
00128 }
00129 
00130 } // namespace QGpGuiTools
00131 
00132 // Allow passing ColorPalette as a QVariant
00133 Q_DECLARE_METATYPE(QGpGuiTools::ColorPalette)
00134 
00135 #endif // COLORPALETTE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines