Warning, file /office/calligra/libs/pigment/KoHistogramProducer.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be> 0003 * 0004 * This library is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU Lesser General Public License as published by 0006 * the Free Software Foundation; either version 2.1 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef _KO_HISTOGRAM_PRODUCER_ 0020 #define _KO_HISTOGRAM_PRODUCER_ 0021 0022 #include <QtGlobal> 0023 0024 #include "pigment_export.h" 0025 0026 #include <KoGenericRegistry.h> 0027 #include <KoID.h> 0028 0029 class QString; 0030 class KoChannelInfo; 0031 class KoColorSpace; 0032 0033 /** 0034 * This class is an interface used in the generation of a histogram. It is a container of 0035 * data, all mathematically interesting things will calculated by an histogram. 0036 * 0037 * The default view will be the entire range each color can be in. And don't let the 0038 * numberOfBins return anything else then 256 unless you have a very good reason for it. 0039 * 0040 * About the views: a view is a zoom combined with a start level: the entire 0041 * range of a channel is 0.0 - 1.0: this is the position. Combined with a zoom, we can 0042 * calculate what part of a channel will fall in a bin. This gives us an interface to 0043 * that the views that is not dependent of the actual colorspace of the histogram. 0044 * The 'size' value is the size, again from 0.0 to 1.0 of the displayed range. 0045 * 0046 * For comfort of the GUI, and because it is logical, channels are accessed in the order 0047 * in which they are found in the channels() method. This is potentially different from 0048 * the order in which they are internally ordered! 0049 **/ 0050 class PIGMENTCMS_EXPORT KoHistogramProducer 0051 { 0052 public: 0053 KoHistogramProducer() : m_skipTransparent(true), m_skipUnselected(true) {} 0054 virtual ~KoHistogramProducer() {} 0055 0056 // Methods to change the bins 0057 0058 /** Clears the data in this producer, but keeps its other settings */ 0059 virtual void clear() = 0; 0060 0061 /** 0062 * Adds the values from the specified array of pixels to the bins -- does not 0063 * reset anything. 0064 * 0065 * @param pixels A pointer an array of pixeldata in the given colorspace 0066 * @param selectionMask a pointer to an array of bytes, where 0 is unselected and 1-255 is degree of selectedness. The array 0067 * must be just as long as the array of pixels. 0068 * @param nPixels The number of pixels 0069 * @param colorSpace the colorspace that can decode the pixel data. 0070 */ 0071 virtual void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace* colorSpace) = 0; 0072 0073 // Methods to set what exactly is being added to the bins 0074 virtual void setView(qreal from, qreal width) = 0; 0075 virtual void setSkipTransparent(bool set) { 0076 m_skipTransparent = set; 0077 } 0078 virtual void setSkipUnselected(bool set) { 0079 m_skipUnselected = set; 0080 } 0081 0082 // Methods with general information about this specific producer 0083 virtual const KoID& id() const = 0; 0084 virtual QList<KoChannelInfo *> channels() = 0; 0085 virtual qint32 numberOfBins() = 0; 0086 virtual QString positionToString(qreal pos) const = 0; 0087 virtual qreal viewFrom() const = 0; 0088 virtual qreal viewWidth() const = 0; 0089 virtual qreal maximalZoom() const = 0; 0090 0091 // Methods to get information on the data we have seen 0092 virtual qint32 count() = 0; 0093 virtual qint32 getBinAt(qint32 channel, qint32 position) = 0; 0094 virtual qint32 outOfViewLeft(qint32 channel) = 0; 0095 virtual qint32 outOfViewRight(qint32 channel) = 0; 0096 protected: 0097 bool m_skipTransparent; 0098 bool m_skipUnselected; 0099 }; 0100 0101 class PIGMENTCMS_EXPORT KoHistogramProducerFactory 0102 { 0103 public: 0104 explicit KoHistogramProducerFactory(const KoID &id) : m_id(id) {} 0105 virtual ~KoHistogramProducerFactory() {} 0106 0107 /// Factory method, generates a new KoHistogramProducer 0108 virtual KoHistogramProducer *generate() = 0; 0109 0110 /// Returns if a colorspace can be used with this producer 0111 virtual bool isCompatibleWith(const KoColorSpace* colorSpace) const = 0; 0112 0113 /// Returns a float in the [0.0, 1.0] range, 0.0 means this is a very generic method 0114 virtual float preferrednessLevelWith(const KoColorSpace* colorSpace) const = 0; 0115 0116 virtual QString id() const { 0117 return m_id.id(); 0118 } 0119 0120 virtual QString name() const { 0121 return m_id.name(); 0122 } 0123 protected: 0124 KoID m_id; 0125 }; 0126 0127 0128 class PIGMENTCMS_EXPORT KoHistogramProducerFactoryRegistry 0129 : public KoGenericRegistry<KoHistogramProducerFactory*> 0130 { 0131 public: 0132 KoHistogramProducerFactoryRegistry(); 0133 ~KoHistogramProducerFactoryRegistry() override; 0134 static KoHistogramProducerFactoryRegistry* instance(); 0135 /// returns a list, sorted by preferrence: higher preferance comes first 0136 QList<QString> keysCompatibleWith(const KoColorSpace* colorSpace) const; 0137 0138 private: 0139 KoHistogramProducerFactoryRegistry(const KoHistogramProducerFactoryRegistry&); 0140 KoHistogramProducerFactoryRegistry operator=(const KoHistogramProducerFactoryRegistry&); 0141 }; 0142 0143 #endif // _KO_HISTOGRAM_PRODUCER