F:/KPlato/koffice/libs/pigment/KoBasicHistogramProducers.h

Aller à la documentation de ce fichier.
00001 /*
00002  *  Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published
00006  *  by the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #ifndef _Ko_BASIC_HISTOGRAM_PRODUCERS_
00020 #define _Ko_BASIC_HISTOGRAM_PRODUCERS_
00021 
00022 #include "KoHistogramProducer.h"
00023 
00024 #include <q3valuevector.h>
00025 #include <klocale.h>
00026 
00027 #include "config.h"
00028 #include "KoColorSpace.h"
00029 #include "KoID.h"
00030 #include <koffice_export.h>
00031 
00032 class KoLabColorSpace;
00033 
00034 class /*PIGMENT_EXPORT*/ KoBasicHistogramProducer : public KoHistogramProducer {
00035 public:
00036     KoBasicHistogramProducer(const KoID& id, int channels, int nrOfBins, KoColorSpace *colorSpace);
00037     virtual ~KoBasicHistogramProducer() {}
00038 
00039     virtual void clear();
00040 
00041     virtual void setView(double from, double size) { m_from = from; m_width = size; }
00042 
00043     virtual const KoID& id() const { return m_id; }
00044     virtual Q3ValueVector<KoChannelInfo *> channels() { return m_colorSpace->channels(); }
00045     virtual qint32 numberOfBins() { return m_nrOfBins; }
00046     virtual double viewFrom() const { return m_from; }
00047     virtual double viewWidth() const { return m_width; }
00048 
00049     virtual qint32 count() { return m_count; }
00050 
00051     virtual qint32 getBinAt(int channel, int position)
00052         { return m_bins.at(externalToInternal(channel)).at(position); }
00053 
00054     virtual qint32 outOfViewLeft(int channel)
00055         { return m_outLeft.at(externalToInternal(channel)); }
00056 
00057     virtual qint32 outOfViewRight(int channel)
00058         { return m_outRight.at(externalToInternal(channel)); }
00059 
00060 protected:
00068     virtual int externalToInternal(int ext) {
00069         if (channels().count() > 0 && m_external.count() == 0) // Set up the translation table
00070             makeExternalToInternal();
00071         return m_external.at(ext);
00072     }
00073     // not virtual since that is useless: we call it from constructor
00074     void makeExternalToInternal();
00075     typedef Q3ValueVector<quint32> vBins;
00076     Q3ValueVector<vBins> m_bins;
00077     vBins m_outLeft, m_outRight;
00078     double m_from, m_width;
00079     qint32 m_count;
00080     int m_channels, m_nrOfBins;
00081     KoColorSpace *m_colorSpace;
00082     KoID m_id;
00083     Q3ValueVector<qint32> m_external;
00084 };
00085 
00086 class /*PIGMENT_EXPORT*/ KoBasicU8HistogramProducer : public KoBasicHistogramProducer {
00087 public:
00088     KoBasicU8HistogramProducer(const KoID& id, KoColorSpace *colorSpace);
00089     virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, KoColorSpace *colorSpace);
00090     virtual QString positionToString(double pos) const;
00091     virtual double maximalZoom() const { return 1.0; }
00092 };
00093 
00094 class /*PIGMENT_EXPORT*/ KoBasicU16HistogramProducer : public KoBasicHistogramProducer {
00095 public:
00096     KoBasicU16HistogramProducer(const KoID& id, KoColorSpace *colorSpace);
00097     virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, KoColorSpace *colorSpace);
00098     virtual QString positionToString(double pos) const;
00099     virtual double maximalZoom() const;
00100 };
00101 
00102 class /*PIGMENT_EXPORT*/ KoBasicF32HistogramProducer : public KoBasicHistogramProducer {
00103 public:
00104     KoBasicF32HistogramProducer(const KoID& id, KoColorSpace *colorSpace);
00105     virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, KoColorSpace *colorSpace);
00106     virtual QString positionToString(double pos) const;
00107     virtual double maximalZoom() const;
00108 };
00109 
00110 #ifdef HAVE_OPENEXR
00111 class /*PIGMENT_EXPORT*/ KoBasicF16HalfHistogramProducer : public KoBasicHistogramProducer {
00112 public:
00113     KoBasicF16HalfHistogramProducer(const KoID& id, KoColorSpace *colorSpace);
00114     virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, KoColorSpace *colorSpace);
00115     virtual QString positionToString(double pos) const;
00116     virtual double maximalZoom() const;
00117 };
00118 #endif
00119 
00126 template<class T> class KoBasicHistogramProducerFactory : public KoHistogramProducerFactory {
00127 public:
00128     KoBasicHistogramProducerFactory(const KoID& id, KoColorSpace *colorSpace)
00129         : KoHistogramProducerFactory(id), m_cs(colorSpace) {}
00130     virtual ~KoBasicHistogramProducerFactory() {}
00131     virtual KoHistogramProducerSP generate() { return KoHistogramProducerSP(new T(id(), m_cs)); }
00132     virtual bool isCompatibleWith(KoColorSpace* colorSpace) const { return colorSpace->id() == m_cs->id(); }
00133     virtual float preferrednessLevelWith(KoColorSpace* /*colorSpace*/) const { return 1.0; }
00134 protected:
00135     KoColorSpace *m_cs;
00136 };
00137 
00144 class /*PIGMENT_EXPORT*/ KoGenericRGBHistogramProducer : public KoBasicHistogramProducer {
00145 public:
00146     KoGenericRGBHistogramProducer();
00147     virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, KoColorSpace *colorSpace);
00148     virtual QString positionToString(double pos) const;
00149     virtual double maximalZoom() const;
00150     virtual Q3ValueVector<KoChannelInfo *> channels();
00151 protected:
00152     Q3ValueVector<KoChannelInfo *> m_channelsList;
00153 };
00154 
00156 class  /*PIGMENT_EXPORT*/ KoGenericRGBHistogramProducerFactory : public KoHistogramProducerFactory {
00157 public:
00158     KoGenericRGBHistogramProducerFactory()
00159         : KoHistogramProducerFactory(KoID("GENRGBHISTO", i18n("Generic RGB Histogram"))) {}
00160     virtual ~KoGenericRGBHistogramProducerFactory() {}
00161     virtual KoHistogramProducerSP generate() { return KoHistogramProducerSP(new KoGenericRGBHistogramProducer()); }
00162     virtual bool isCompatibleWith(KoColorSpace*) const { return true; }
00163     virtual float preferrednessLevelWith(KoColorSpace*) const { return 0.0; }
00164 };
00165 
00166 
00172 class  /*PIGMENT_EXPORT*/ KoGenericLabHistogramProducer : public KoBasicHistogramProducer {
00173     public:
00174         KoGenericLabHistogramProducer();
00175         virtual ~KoGenericLabHistogramProducer();
00176         virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, KoColorSpace *colorSpace);
00177         virtual QString positionToString(double pos) const;
00178         virtual double maximalZoom() const;
00179         virtual Q3ValueVector<KoChannelInfo *> channels();
00180     protected:
00181         Q3ValueVector<KoChannelInfo *> m_channelsList;
00182     private:
00183         static KoLabColorSpace* m_labCs;
00184 };
00185 
00187 class /*PIGMENT_EXPORT*/ KoGenericLabHistogramProducerFactory : public KoHistogramProducerFactory {
00188     public:
00189         KoGenericLabHistogramProducerFactory()
00190     : KoHistogramProducerFactory(KoID("GENLABHISTO", i18n("Generic L*a*b* Histogram"))) {}
00191         virtual ~KoGenericLabHistogramProducerFactory() {}
00192         virtual KoHistogramProducerSP generate() { return KoHistogramProducerSP(new KoGenericLabHistogramProducer()); }
00193         virtual bool isCompatibleWith(KoColorSpace*) const { return true; }
00194         virtual float preferrednessLevelWith(KoColorSpace*) const { return 0.0; }
00195 };
00196 
00197 
00198 #endif // _Ko_BASIC_HISTOGRAM_PRODUCERS_

Généré le Wed Nov 22 23:41:13 2006 pour KPlato par  doxygen 1.5.1-p1