krita

kis_histogram_producer.h

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 General Public License as published by
00006  *  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 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 _KIS_HISTOGRAM_PRODUCER_
00020 #define _KIS_HISTOGRAM_PRODUCER_
00021 
00022 #include <qglobal.h>
00023 #include <ksharedptr.h>
00024 
00025 #include <kis_colorspace.h>
00026 
00027 #include "kis_generic_registry.h"
00028 
00029 class KisRectIteratorPixel;
00030 class QString;
00031 class KisChannelInfo;
00032 
00050 class KisHistogramProducer : public KShared {
00051 public:
00052     KisHistogramProducer() : m_skipTransparent(true), m_skipUnselected(true) {}
00053     virtual ~KisHistogramProducer() {}
00054 
00055     // Methods to change the bins
00056 
00058     virtual void clear() = 0;
00059 
00070     virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace* colorSpace) = 0;
00071 
00072     // Methods to set what exactly is being added to the bins
00073     virtual void setView(double from, double width) = 0;
00074     virtual void setSkipTransparent(bool set) { m_skipTransparent = set; }
00075     virtual void setSkipUnselected(bool set) { m_skipUnselected = set; }
00076 
00077     // Methods with general information about this specific producer
00078     virtual const KisID& id() const = 0;
00079     virtual QValueVector<KisChannelInfo *> channels() = 0;
00080     virtual Q_INT32 numberOfBins() = 0;
00081     virtual QString positionToString(double pos) const = 0;
00082     virtual double viewFrom() const = 0;
00083     virtual double viewWidth() const = 0;
00084     virtual double maximalZoom() const = 0;
00085 
00086     // Methods to get information on the data we have seen
00087     virtual Q_INT32 count() = 0;
00088     virtual Q_INT32 getBinAt(Q_INT32 channel, Q_INT32 position) = 0;
00089     virtual Q_INT32 outOfViewLeft(Q_INT32 channel) = 0;
00090     virtual Q_INT32 outOfViewRight(Q_INT32 channel) = 0;
00091 protected:
00092     bool m_skipTransparent;
00093     bool m_skipUnselected;
00094 };
00095 
00096 typedef KSharedPtr<KisHistogramProducer> KisHistogramProducerSP;
00097 
00098 class KisHistogramProducerFactory {
00099 public:
00100     KisHistogramProducerFactory(const KisID& id) : m_id(id) {}
00101     virtual ~KisHistogramProducerFactory() {}
00103     virtual KisHistogramProducerSP generate() = 0;
00105     virtual bool isCompatibleWith(KisColorSpace* colorSpace) const = 0;
00107     virtual float preferrednessLevelWith(KisColorSpace* colorSpace) const = 0;
00108     virtual const KisID& id() const { return m_id; }
00109 protected:
00110     KisID m_id;
00111 };
00112 
00113 class KisHistogramProducerFactoryRegistry
00114     : public KisGenericRegistry<KisHistogramProducerFactory*> {
00115 public:
00116     virtual ~KisHistogramProducerFactoryRegistry();
00117     static KisHistogramProducerFactoryRegistry* instance();
00119     KisIDList listKeysCompatibleWith(KisColorSpace* colorSpace) const;
00120 
00121 private:
00122    KisHistogramProducerFactoryRegistry();
00123    KisHistogramProducerFactoryRegistry(const KisHistogramProducerFactoryRegistry&);
00124    KisHistogramProducerFactoryRegistry operator=(const KisHistogramProducerFactoryRegistry&);
00125 
00126    static KisHistogramProducerFactoryRegistry* m_singleton;
00127 };
00128 
00129 #endif // _KIS_HISTOGRAM_PRODUCER
KDE Home | KDE Accessibility Home | Description of Access Keys