chalk

kis_histogram_producer.h
1/*
2 * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#ifndef _KIS_HISTOGRAM_PRODUCER_
20#define _KIS_HISTOGRAM_PRODUCER_
21
22#include <tqglobal.h>
23#include <ksharedptr.h>
24
25#include <kis_colorspace.h>
26
27#include "kis_generic_registry.h"
28
29class KisRectIteratorPixel;
30class TQString;
31class KisChannelInfo;
32
50class KisHistogramProducer : public TDEShared {
51public:
52 KisHistogramProducer() : m_skipTransparent(true), m_skipUnselected(true) {}
53 virtual ~KisHistogramProducer() {}
54
55 // Methods to change the bins
56
58 virtual void clear() = 0;
59
70 virtual void addRegionToBin(TQ_UINT8 * pixels, TQ_UINT8 * selectionMask, TQ_UINT32 nPixels, KisColorSpace* colorSpace) = 0;
71
72 // Methods to set what exactly is being added to the bins
73 virtual void setView(double from, double width) = 0;
74 virtual void setSkipTransparent(bool set) { m_skipTransparent = set; }
75 virtual void setSkipUnselected(bool set) { m_skipUnselected = set; }
76
77 // Methods with general information about this specific producer
78 virtual const KisID& id() const = 0;
79 virtual TQValueVector<KisChannelInfo *> channels() = 0;
80 virtual TQ_INT32 numberOfBins() = 0;
81 virtual TQString positionToString(double pos) const = 0;
82 virtual double viewFrom() const = 0;
83 virtual double viewWidth() const = 0;
84 virtual double maximalZoom() const = 0;
85
86 // Methods to get information on the data we have seen
87 virtual TQ_INT32 count() = 0;
88 virtual TQ_INT32 getBinAt(TQ_INT32 channel, TQ_INT32 position) = 0;
89 virtual TQ_INT32 outOfViewLeft(TQ_INT32 channel) = 0;
90 virtual TQ_INT32 outOfViewRight(TQ_INT32 channel) = 0;
91protected:
92 bool m_skipTransparent;
93 bool m_skipUnselected;
94};
95
96typedef TDESharedPtr<KisHistogramProducer> KisHistogramProducerSP;
97
98class KisHistogramProducerFactory {
99public:
100 KisHistogramProducerFactory(const KisID& id) : m_id(id) {}
101 virtual ~KisHistogramProducerFactory() {}
103 virtual KisHistogramProducerSP generate() = 0;
105 virtual bool isCompatibleWith(KisColorSpace* colorSpace) const = 0;
107 virtual float preferrednessLevelWith(KisColorSpace* colorSpace) const = 0;
108 virtual const KisID& id() const { return m_id; }
109protected:
110 KisID m_id;
111};
112
113class KisHistogramProducerFactoryRegistry
114 : public KisGenericRegistry<KisHistogramProducerFactory*> {
115public:
116 virtual ~KisHistogramProducerFactoryRegistry();
117 static KisHistogramProducerFactoryRegistry* instance();
119 KisIDList listKeysCompatibleWith(KisColorSpace* colorSpace) const;
120
121private:
122 KisHistogramProducerFactoryRegistry();
123 KisHistogramProducerFactoryRegistry(const KisHistogramProducerFactoryRegistry&);
124 KisHistogramProducerFactoryRegistry operator=(const KisHistogramProducerFactoryRegistry&);
125
126 static KisHistogramProducerFactoryRegistry* m_singleton;
127};
128
129#endif // _KIS_HISTOGRAM_PRODUCER
This class gives some basic information about a channel, that is, one of the components that makes up...
A colorspace is the definition of a certain color model in Chalk.
Base class for registry objects in Chalk.
virtual void clear()=0
Clears the data in this producer, but keeps its other settings.
virtual void addRegionToBin(TQ_UINT8 *pixels, TQ_UINT8 *selectionMask, TQ_UINT32 nPixels, KisColorSpace *colorSpace)=0
Adds the values from the specified array of pixels to the bins – does not reset anything.