#ifndef COLOUR_TABLE_H
#define COLOUR_TABLE_H

#include <QString>
#include <QVector>
#include <QColor>
#include <QIcon>
#include <QPixmap>
#include <QPainter>
#include <QPen>
#include <QBrush>
#include "Viostream.h"
#include "plplot.h"

class ColourTable;

QDOS::Vistream& operator>>(QDOS::Vistream&, ColourTable&);
QDOS::Vostream& operator<<(QDOS::Vostream&, ColourTable&);

class ColourTable
{
    friend QDOS::Vistream& operator>>(QDOS::Vistream&, ColourTable&);
    friend QDOS::Vostream& operator<<(QDOS::Vostream&, ColourTable&);
    
    public:
        ColourTable(const QString& name, const QVector<double>& points, const QVector<double>& H, const QVector<double>& S, const QVector<double>& V, bool isRGB=false);

        ColourTable(const QString& name="");

        ColourTable(const ColourTable& table);

        ~ColourTable();

        void operator=(const ColourTable&);

        void setPresetRainbow();
        void setPresetRainbowExt();
        void setPresetGrayWhiteHigh();
        void setPresetGrayWhiteLow();
        void setPresetInvRedBlue();
        void setPresetRedBlue();
        void setPresetEarth();

        void fromString(const QString&);
        QString toString() const;

        void apply() const;
        void clear();
        QString name;


        bool operator==(const ColourTable&) const;
        bool operator!=(const ColourTable&) const;

        void drawColourBar(QPainter*, int, int);
        
        void updateIcon();
        
        QIcon icon;
                
        int isRGB;
        int size;
        PLFLT* i;
        PLFLT* h;
        PLFLT* s;
        PLFLT* v;
    protected:


};

typedef ColourTable TOTO;

typedef QVector<ColourTable> ColourTablePalette;

#endif
