Krita Source Code Documentation
Loading...
Searching...
No Matches
KoBasicHistogramProducers.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2005 Bart Coppens <kde@bartcoppens.be>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#ifndef _Ko_BASIC_HISTOGRAM_PRODUCERS_
8#define _Ko_BASIC_HISTOGRAM_PRODUCERS_
9
10#include "KoHistogramProducer.h"
11
12#include <QVector>
13
14#include <KoConfig.h>
15
16#include "KoColorSpace.h"
17#include "KoID.h"
18#include "kritapigment_export.h"
20
21class KRITAPIGMENT_EXPORT KoBasicHistogramProducer : public KoHistogramProducer
22{
23public:
24 explicit KoBasicHistogramProducer(const KoID& id, int channelCount, int nrOfBins);
25 explicit KoBasicHistogramProducer(const KoID& id, int nrOfBins, const KoColorSpace *colorSpace);
27
28 void clear() override;
29
30 void setView(qreal from, qreal size) override {
31 m_from = from; m_width = size;
32 }
33
34 const KoID& id() const override {
35 return m_id;
36 }
38 return m_colorSpace->channels();
39 }
40 qint32 numberOfBins() override {
41 return m_nrOfBins;
42 }
43 qreal viewFrom() const override {
44 return m_from;
45 }
46 qreal viewWidth() const override {
47 return m_width;
48 }
49
50 qint32 count() override {
51 return m_count;
52 }
53
54 qint32 getBinAt(int channel, int position) override {
55 return m_bins.at(externalToInternal(channel)).at(position);
56 }
57
58 qint32 outOfViewLeft(int channel) override {
59 return m_outLeft.at(externalToInternal(channel));
60 }
61
62 qint32 outOfViewRight(int channel) override {
63 return m_outRight.at(externalToInternal(channel));
64 }
65
66protected:
74 virtual int externalToInternal(int ext) {
75 if (channels().count() > 0 && m_external.count() == 0) // Set up the translation table
76 makeExternalToInternal();
77 return m_external.at(ext);
78 }
79 // not virtual since that is useless: we call it from constructor
80 void makeExternalToInternal();
83 vBins m_outLeft, m_outRight;
84 qreal m_from, m_width;
85 qint32 m_count;
86 int m_channels, m_nrOfBins;
90};
91
92class KRITAPIGMENT_EXPORT KoBasicU8HistogramProducer : public KoBasicHistogramProducer
93{
94public:
95 KoBasicU8HistogramProducer(const KoID& id, const KoColorSpace *colorSpace);
97 void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace) override;
98 QString positionToString(qreal pos) const override;
99 qreal maximalZoom() const override {
100 return 1.0;
101 }
102};
103
105{
106public:
107 KoBasicU16HistogramProducer(const KoID& id, const KoColorSpace *colorSpace);
109 void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace) override;
110 QString positionToString(qreal pos) const override;
111 qreal maximalZoom() const override;
112};
113
115{
116public:
117 KoBasicF32HistogramProducer(const KoID& id, const KoColorSpace *colorSpace);
119 void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace) override;
120 QString positionToString(qreal pos) const override;
121 qreal maximalZoom() const override;
122};
123
124
125#ifdef HAVE_OPENEXR
126class KRITAPIGMENT_EXPORT KoBasicF16HalfHistogramProducer : public KoBasicHistogramProducer
127{
128public:
129 KoBasicF16HalfHistogramProducer(const KoID& id, const KoColorSpace *colorSpace);
130 ~KoBasicF16HalfHistogramProducer() override {}
131 void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace) override;
132 QString positionToString(qreal pos) const override;
133 qreal maximalZoom() const override;
134};
135#endif
136
144{
145public:
146 KoBasicHistogramProducerFactory(const KoID& id, const QString& modelId, const QString& depthId )
147 : KoHistogramProducerFactory(id), m_modelId(modelId), m_depthId(depthId) {
148 }
150
152 KoHistogramProducer *producer = 0;
154 if (cs) {
155 producer = new T(KoID(id(), name()), cs);
156 }
157 return producer;
158
159 }
160 bool isCompatibleWith(const KoColorSpace* colorSpace, bool strict = false) const override {
161 if( strict ){
162 return colorSpace->colorDepthId().id() == m_depthId;
163 }
164 return colorSpace->colorModelId().id() == m_modelId || colorSpace->colorDepthId().id() == m_depthId;
165 }
166 float preferrednessLevelWith(const KoColorSpace* colorSpace) const override {
167 return 0.5 * ( (colorSpace->colorModelId().id() == m_modelId) + (colorSpace->colorDepthId().id() == m_depthId) );
168 }
169protected:
171};
172
180{
181public:
184 void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace) override;
185 QString positionToString(qreal pos) const override;
186 qreal maximalZoom() const override;
188protected:
190};
191
194{
195public:
197
199
202 }
203
204 bool isCompatibleWith(const KoColorSpace*, bool strict = false) const override {
205 Q_UNUSED(strict);
206 return true;
207 }
208
209 float preferrednessLevelWith(const KoColorSpace*) const override {
210 return 0.0;
211 }
212};
213
214
221{
222public:
225 void addRegionToBin(const quint8 * pixels, const quint8 * selectionMask, quint32 nPixels, const KoColorSpace *colorSpace) override;
226 QString positionToString(qreal pos) const override;
227 qreal maximalZoom() const override;
229protected:
231};
232
235{
236public:
239
242 }
243
244 bool isCompatibleWith(const KoColorSpace*, bool strict = false) const override {
245 Q_UNUSED(strict);
246 return true;
247 }
248
249 float preferrednessLevelWith(const KoColorSpace*) const override {
250 return 0.0;
251 }
252};
253
254
255#endif // _Ko_BASIC_HISTOGRAM_PRODUCERS_
float preferrednessLevelWith(const KoColorSpace *colorSpace) const override
Returns a float in the [0.0, 1.0] range, 0.0 means this is a very generic method.
KoHistogramProducer * generate() override
Factory method, generates a new KoHistogramProducer.
KoBasicHistogramProducerFactory(const KoID &id, const QString &modelId, const QString &depthId)
bool isCompatibleWith(const KoColorSpace *colorSpace, bool strict=false) const override
Returns if a colorspace can be used with this producer.
void setView(qreal from, qreal size) override
QList< KoChannelInfo * > channels() override
qint32 outOfViewLeft(int channel) override
virtual int externalToInternal(int ext)
qint32 getBinAt(int channel, int position) override
qint32 outOfViewRight(int channel) override
const KoID & id() const override
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
bool isCompatibleWith(const KoColorSpace *, bool strict=false) const override
Returns if a colorspace can be used with this producer.
KoHistogramProducer * generate() override
Factory method, generates a new KoHistogramProducer.
float preferrednessLevelWith(const KoColorSpace *) const override
Returns a float in the [0.0, 1.0] range, 0.0 means this is a very generic method.
bool isCompatibleWith(const KoColorSpace *, bool strict=false) const override
Returns if a colorspace can be used with this producer.
KoHistogramProducer * generate() override
Factory method, generates a new KoHistogramProducer.
float preferrednessLevelWith(const KoColorSpace *) const override
Returns a float in the [0.0, 1.0] range, 0.0 means this is a very generic method.
virtual QString id() const
virtual QString name() const
virtual void clear()=0
virtual QList< KoChannelInfo * > channels()=0
virtual QString positionToString(qreal pos) const =0
virtual void addRegionToBin(const quint8 *pixels, const quint8 *selectionMask, quint32 nPixels, const KoColorSpace *colorSpace)=0
virtual qint32 count()=0
virtual qreal maximalZoom() const =0
Definition KoID.h:30
QString id() const
Definition KoID.cpp:63
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()