Krita Source Code Documentation
Loading...
Searching...
No Matches
KisVisualColorModel Class Reference

The KisVisualColorModel class allows manipulating a KoColor using various color models. More...

#include <KisVisualColorModel.h>

+ Inheritance diagram for KisVisualColorModel:

Classes

struct  Private
 

Public Types

enum  ColorModel {
  None , Channel , HSV , HSL ,
  HSI , HSY , YUV
}
 

Public Slots

void slotLoadACSConfig ()
 slotLoadACSConfig loads supported settings from Advanced Color Selector
 
void slotSetChannelValues (const QVector4D &values)
 
void slotSetColor (const KoColor &c)
 
void slotSetColorSpace (const KoColorSpace *cs)
 

Signals

void sigChannelValuesChanged (const QVector4D &values, quint32 channelFlags)
 
void sigColorModelChanged ()
 sigColorModelChanged is emitted whenever the color model changes.
 
void sigColorSpaceChanged ()
 sigColorSpaceChanged notifies that the color space from which the channel values are derived changed, and thus invalidating the current ones.
 
void sigNewColor (const KoColor &c)
 

Public Member Functions

QVector4D channelValues () const
 
int colorChannelCount () const
 
ColorModel colorModel () const
 
const KoColorSpacecolorSpace () const
 
KoColor convertChannelValuesToKoColor (const QVector4D &values) const
 
QVector4D convertKoColorToChannelValues (KoColor c) const
 
void copyState (const KisVisualColorModel &other)
 Copy the internal state of another KisVisualColorModel.
 
KoColor currentColor () const
 
bool isHSXModel () const
 
 KisVisualColorModel ()
 
QVector4D maxChannelValues () const
 
void setMaxChannelValues (const QVector4D &maxValues)
 
void setRGBColorModel (ColorModel model)
 Set the HSX color model used for RGB color spaces.
 
bool supportsExposure () const
 
 ~KisVisualColorModel () override
 

Private Member Functions

void emitChannelValues ()
 
void loadColorSpace (const KoColorSpace *cs)
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

The KisVisualColorModel class allows manipulating a KoColor using various color models.

This enables different widgets to easily manipulate the same color representation (like HSV channels of an RGB color etc.) in a synchronized way without having to know the details of the underlying color space. NOTE: This class is meant to be shared between GUI classes using KisVisualColorModelSP, so DO NOT SET a QObject parent in this case.

Definition at line 31 of file KisVisualColorModel.h.

Member Enumeration Documentation

◆ ColorModel

Constructor & Destructor Documentation

◆ KisVisualColorModel()

KisVisualColorModel::KisVisualColorModel ( )

Definition at line 49 of file KisVisualColorModel.cpp.

50 : QObject(0)
51 , m_d(new Private)
52{
53 KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
54 m_d->acs_config = KisColorSelectorConfiguration::fromString(cfg.readEntry("colorSelectorConfiguration", KisColorSelectorConfiguration().toString()));
55
56}
static KisColorSelectorConfiguration fromString(QString string)
const QScopedPointer< Private > m_d
QString toString(const QString &value)

References KisColorSelectorConfiguration::fromString(), and m_d.

◆ ~KisVisualColorModel()

KisVisualColorModel::~KisVisualColorModel ( )
override

Definition at line 58 of file KisVisualColorModel.cpp.

59{
60}

Member Function Documentation

◆ channelValues()

QVector4D KisVisualColorModel::channelValues ( ) const

Definition at line 129 of file KisVisualColorModel.cpp.

130{
131 return m_d->channelValues;
132}

References m_d.

◆ colorChannelCount()

int KisVisualColorModel::colorChannelCount ( ) const

Definition at line 134 of file KisVisualColorModel.cpp.

135{
136 return m_d->colorChannelCount;
137}

References m_d.

◆ colorModel()

KisVisualColorModel::ColorModel KisVisualColorModel::colorModel ( ) const

Definition at line 139 of file KisVisualColorModel.cpp.

140{
141 return m_d->model;
142}

References m_d.

◆ colorSpace()

const KoColorSpace * KisVisualColorModel::colorSpace ( ) const

Definition at line 189 of file KisVisualColorModel.cpp.

190{
191 return m_d->currentCS;
192}

References m_d.

◆ convertChannelValuesToKoColor()

KoColor KisVisualColorModel::convertChannelValuesToKoColor ( const QVector4D & values) const

Definition at line 204 of file KisVisualColorModel.cpp.

205{
206 KoColor c(m_d->currentCS);
207 QVector4D baseValues(values);
208 QVector<float> channelVec(c.colorSpace()->channelCount());
209 channelVec.fill(1.0);
210
211 if (m_d->model != ColorModel::Channel && m_d->isRGBA) {
212
213 if (m_d->model == ColorModel::HSV) {
214 HSVToRGB(values.x()*360, values.y(), values.z(), &baseValues[0], &baseValues[1], &baseValues[2]);
215 }
216 else if (m_d->model == ColorModel::HSL) {
217 HSLToRGB(values.x()*360, values.y(), values.z(), &baseValues[0], &baseValues[1], &baseValues[2]);
218 }
219 else if (m_d->model == ColorModel::HSI) {
220 // why suddenly qreal?
221 qreal temp[3];
222 HSIToRGB(values.x(), values.y(), values.z(), &temp[0], &temp[1], &temp[2]);
223 baseValues.setX(temp[0]);
224 baseValues.setY(temp[1]);
225 baseValues.setZ(temp[2]);
226 }
227 else /*if (m_d->model == ColorModel::HSY)*/ {
228 qreal temp[3];
229 qreal Y = pow(values.z(), m_d->gamma);
230 HSYToRGB(values.x(), values.y(), Y, &temp[0], &temp[1], &temp[2],
231 m_d->lumaRGB[0], m_d->lumaRGB[1], m_d->lumaRGB[2]);
232 baseValues.setX(temp[0]);
233 baseValues.setY(temp[1]);
234 baseValues.setZ(temp[2]);
235 if (!m_d->isLinear) {
236 // Note: not all profiles define a TRC necessary for (de-)linearization,
237 // substituting with a linear profiles would be better
238 QVector<qreal> tempVec({baseValues[0], baseValues[1], baseValues[2]});
239 if (m_d->exposureSupported) {
240 m_d->currentCS->profile()->delinearizeFloatValue(tempVec);
241 }
242 else {
243 m_d->currentCS->profile()->delinearizeFloatValueFast(tempVec);
244 }
245 baseValues = QVector4D(tempVec[0], tempVec[1], tempVec[2], 0);
246 }
247 }
248 if (m_d->applyGamma) {
249 for (int i=0; i<3; i++) {
250 baseValues[i] = pow(baseValues[i], 2.2);
251 }
252 }
253 } else if (m_d->model != ColorModel::Channel && m_d->isLABlike) {
254 QVector<qreal> tempVec({baseValues[0], baseValues[1], baseValues[2]});
255 LCHToLab(values.z(), values.y(), values.x(), &tempVec[0], &tempVec[1], &tempVec[2]);
256 baseValues = QVector4D(tempVec[0], tempVec[1], tempVec[2], 0);
257 }
258
259 if (m_d->exposureSupported) {
260 for (int i = 0; i < m_d->colorChannelCount; i++) {
261 baseValues[i] *= m_d->channelMaxValues[i];
262 }
263 }
264
265 for (int i=0; i<m_d->colorChannelCount; i++) {
266 channelVec[m_d->logicalToMemoryPosition[i]] = baseValues[i];
267 }
268
269 c.colorSpace()->fromNormalisedChannelsValue(c.data(), channelVec);
270
271 return c;
272
273}
void HSYToRGB(const qreal h, const qreal s, const qreal y, qreal *red, qreal *green, qreal *blue, qreal R, qreal G, qreal B)
void LCHToLab(const qreal L, const qreal C, const qreal H, qreal *l, qreal *a, qreal *b)
void HSIToRGB(const qreal h, const qreal s, const qreal i, qreal *red, qreal *green, qreal *blue)
void HSVToRGB(float h, float s, float v, float *r, float *g, float *b)
void HSLToRGB(float h, float sl, float l, float *r, float *g, float *b)
const QString Y

References Channel, KoColorSpace::channelCount(), KoColor::colorSpace(), KoColor::data(), KoColorSpace::fromNormalisedChannelsValue(), HSI, HSIToRGB(), HSL, HSLToRGB(), HSV, HSVToRGB(), HSYToRGB(), LCHToLab(), and m_d.

◆ convertKoColorToChannelValues()

QVector4D KisVisualColorModel::convertKoColorToChannelValues ( KoColor c) const

Definition at line 275 of file KisVisualColorModel.cpp.

276{
277 if (c.colorSpace() != m_d->currentCS) {
278 c.convertTo(m_d->currentCS);
279 }
280 QVector<float> channelVec (c.colorSpace()->channelCount());
281 channelVec.fill(1.0);
282 m_d->currentCS->normalisedChannelsValue(c.data(), channelVec);
283 QVector4D channelValuesDisplay(0, 0, 0, 0), coordinates(0, 0, 0, 0);
284
285 for (int i =0; i<m_d->colorChannelCount; i++) {
286 channelValuesDisplay[i] = channelVec[m_d->logicalToMemoryPosition[i]];
287 }
288
289 if (m_d->exposureSupported) {
290 for (int i = 0; i < m_d->colorChannelCount; i++) {
291 channelValuesDisplay[i] /= m_d->channelMaxValues[i];
292 }
293 }
294 if (m_d->model != ColorModel::Channel && m_d->isRGBA) {
295 if (m_d->applyGamma) {
296 for (int i=0; i<3; i++) {
297 channelValuesDisplay[i] = pow(channelValuesDisplay[i], 1/2.2);
298 }
299 }
300 if (m_d->model == ColorModel::HSV) {
301 QVector3D hsv;
302 RGBToHSV(channelValuesDisplay[0], channelValuesDisplay[1], channelValuesDisplay[2], &hsv[0], &hsv[1], &hsv[2]);
303 hsv[0] /= 360;
304 coordinates = QVector4D(hsv, 0.f);
305 } else if (m_d->model == ColorModel::HSL) {
306 QVector3D hsl;
307 RGBToHSL(channelValuesDisplay[0], channelValuesDisplay[1], channelValuesDisplay[2], &hsl[0], &hsl[1], &hsl[2]);
308 hsl[0] /= 360;
309 coordinates = QVector4D(hsl, 0.f);
310 } else if (m_d->model == ColorModel::HSI) {
311 qreal hsi[3];
312 RGBToHSI(channelValuesDisplay[0], channelValuesDisplay[1], channelValuesDisplay[2], &hsi[0], &hsi[1], &hsi[2]);
313 coordinates = QVector4D(hsi[0], hsi[1], hsi[2], 0.f);
314 } else if (m_d->model == ColorModel::HSY) {
315 if (!m_d->isLinear) {
316 // Note: not all profiles define a TRC necessary for (de-)linearization,
317 // substituting with a linear profiles would be better
318 QVector<qreal> temp({channelValuesDisplay[0], channelValuesDisplay[1], channelValuesDisplay[2]});
319 m_d->currentCS->profile()->linearizeFloatValue(temp);
320 channelValuesDisplay = QVector4D(temp[0], temp[1], temp[2], 0);
321 }
322 qreal hsy[3];
323 RGBToHSY(channelValuesDisplay[0], channelValuesDisplay[1], channelValuesDisplay[2], &hsy[0], &hsy[1], &hsy[2],
324 m_d->lumaRGB[0], m_d->lumaRGB[1], m_d->lumaRGB[2]);
325 hsy[2] = pow(hsy[2], 1/m_d->gamma);
326 coordinates = QVector4D(hsy[0], hsy[1], hsy[2], 0.f);
327 }
328 // if we couldn't determine a hue, keep last value
329 if (coordinates[0] < 0) {
330 coordinates[0] = m_d->channelValues[0];
331 }
332 for (int i=0; i<3; i++) {
333 coordinates[i] = qBound(0.f, coordinates[i], 1.f);
334 }
335 } else if (m_d->model != ColorModel::Channel && m_d->isLABlike) {
336 qreal lch[3];
337 LabToLCH(channelValuesDisplay[0], channelValuesDisplay[1], channelValuesDisplay[2], &lch[0], &lch[1], &lch[2]);
338 coordinates = QVector4D(lch[2], lch[1], lch[0], 0.f);
339
340 if (coordinates[0] < 0) {
341 coordinates[0] = m_d->channelValues[0];
342 }
343 for (int i=0; i<3; i++) {
344 coordinates[i] = qBound(0.f, coordinates[i], 1.f);
345 }
346 } else {
347 for (int i=0; i<4; i++) {
348 coordinates[i] = qBound(0.f, channelValuesDisplay[i], 1.f);
349 }
350 }
351 return coordinates;
352}
void LabToLCH(const qreal l, const qreal a, const qreal b, qreal *L, qreal *C, qreal *H)
void RGBToHSV(float r, float g, float b, float *h, float *s, float *v)
void RGBToHSI(qreal r, qreal g, qreal b, qreal *h, qreal *s, qreal *i)
void RGBToHSL(float r, float g, float b, float *h, float *s, float *l)
void RGBToHSY(const qreal r, const qreal g, const qreal b, qreal *h, qreal *s, qreal *y, qreal R, qreal G, qreal B)
virtual quint32 channelCount() const =0
void convertTo(const KoColorSpace *cs, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
Definition KoColor.cpp:136
quint8 * data()
Definition KoColor.h:144
const KoColorSpace * colorSpace() const
return the current colorSpace
Definition KoColor.h:82

References Channel, KoColorSpace::channelCount(), KoColor::colorSpace(), KoColor::convertTo(), KoColor::data(), HSI, HSL, HSV, HSY, LabToLCH(), m_d, RGBToHSI(), RGBToHSL(), RGBToHSV(), and RGBToHSY().

◆ copyState()

void KisVisualColorModel::copyState ( const KisVisualColorModel & other)

Copy the internal state of another KisVisualColorModel.

This will Q_EMIT all necessary signals to update widgets so they can reflect the new state correctly.

Parameters
otherthe model to copy

Definition at line 162 of file KisVisualColorModel.cpp.

163{
164 m_d->channelMaxValues = other.m_d->channelMaxValues;
165 setRGBColorModel(other.m_d->modelRGB);
166 if (other.colorSpace()) {
169 }
170}
const KoColorSpace * colorSpace() const
void slotSetColorSpace(const KoColorSpace *cs)
QVector4D channelValues() const
void slotSetChannelValues(const QVector4D &values)
void setRGBColorModel(ColorModel model)
Set the HSX color model used for RGB color spaces.

References channelValues(), colorSpace(), m_d, setRGBColorModel(), slotSetChannelValues(), and slotSetColorSpace().

◆ currentColor()

KoColor KisVisualColorModel::currentColor ( ) const

Definition at line 124 of file KisVisualColorModel.cpp.

125{
126 return m_d->currentcolor;
127}

References m_d.

◆ emitChannelValues()

void KisVisualColorModel::emitChannelValues ( )
private

Definition at line 458 of file KisVisualColorModel.cpp.

459{
460 bool updatesAllowed = m_d->allowUpdates;
461 m_d->allowUpdates = false;
462 Q_EMIT sigChannelValuesChanged(m_d->channelValues, (1u << m_d->colorChannelCount) - 1);
463 m_d->allowUpdates = updatesAllowed;
464}
void sigChannelValuesChanged(const QVector4D &values, quint32 channelFlags)

References m_d, and sigChannelValuesChanged().

◆ isHSXModel()

bool KisVisualColorModel::isHSXModel ( ) const

Definition at line 194 of file KisVisualColorModel.cpp.

195{
196 return (m_d->model >= ColorModel::HSV && m_d->model <= ColorModel::HSY);
197}

References HSV, HSY, and m_d.

◆ loadColorSpace()

void KisVisualColorModel::loadColorSpace ( const KoColorSpace * cs)
private

Definition at line 401 of file KisVisualColorModel.cpp.

402{
403 const QList<KoChannelInfo *> channelList = cs->channels();
404 int cCount = 0;
405
406 for (int i = 0; i < channelList.size(); i++) {
407 const KoChannelInfo *channel = channelList.at(i);
408 if (channel->channelType() != KoChannelInfo::ALPHA) {
409 quint32 logical = channel->displayPosition();
410 if (logical > cs->alphaPos()) {
411 --logical;
412 }
413 m_d->logicalToMemoryPosition[logical] = i;
414 m_d->channelMaxValues[logical] = channel->getUIMax();
415 ++cCount;
416 }
417 }
418 KIS_ASSERT_X(cCount < 5, "", "unsupported channel count!");
419
420 m_d->colorChannelCount = cCount;
421
426 && cs->colorModelId() != CMYKAColorModelID) {
427 m_d->exposureSupported = true;
428 } else {
429 m_d->exposureSupported = false;
430 }
431 m_d->isRGBA = (cs->colorModelId() == RGBAColorModelID);
432 m_d->isLABlike = (cs->colorModelId() == LABAColorModelID || cs->colorModelId() == YCbCrAColorModelID);
433
434 const KoColorProfile *profile = cs->profile();
435 m_d->isLinear = (profile && profile->isLinear());
436
437 if (m_d->isRGBA) {
438 m_d->applyGamma = (m_d->isLinear && m_d->modelRGB != ColorModel::HSY);
439 // Note: only profiles that define colorants will give precise luma coefficients.
440 // Maybe using the explicitly set values of the Advanced Color Selector is better?
441 QVector <qreal> luma = cs->lumaCoefficients();
442 memcpy(m_d->lumaRGB, luma.constData(), 3*sizeof(qreal));
443 m_d->model = m_d->modelRGB;
444 } else if (m_d->isLABlike) {
445 m_d->model = m_d->modelRGB;
446 } else {
448 }
449
450 const KoColorSpace *oldCS = m_d->currentCS;
451 m_d->currentCS = cs;
452
453 if (!oldCS || (oldCS->colorModelId() != cs->colorModelId())) {
454 Q_EMIT sigColorModelChanged();
455 }
456}
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID YCbCrAColorModelID("YCbCrA", ki18n("YCbCr/Alpha"))
const KoID Float64BitsColorDepthID("F64", ki18n("64-bit float/channel"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID CMYKAColorModelID("CMYKA", ki18n("CMYK/Alpha"))
const KoID LABAColorModelID("LABA", ki18n("L*a*b*/Alpha"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
void sigColorModelChanged()
sigColorModelChanged is emitted whenever the color model changes.
@ ALPHA
The channel represents the opacity of a pixel.
enumChannelType channelType() const
qint32 displayPosition() const
double getUIMax(void) const
virtual quint32 alphaPos() const =0
QList< KoChannelInfo * > channels
virtual KoID colorModelId() const =0
QVector< qreal > lumaCoefficients
virtual KoID colorDepthId() const =0
virtual const KoColorProfile * profile() const =0
#define KIS_ASSERT_X(cond, where, what)
Definition kis_assert.h:40
virtual bool isLinear() const =0

References KoChannelInfo::ALPHA, KoColorSpace::alphaPos(), Channel, KoColorSpace::channels, KoChannelInfo::channelType(), CMYKAColorModelID, KoColorSpace::colorDepthId(), KoColorSpace::colorModelId(), KoChannelInfo::displayPosition(), Float16BitsColorDepthID, Float32BitsColorDepthID, Float64BitsColorDepthID, KoChannelInfo::getUIMax(), HSY, KoColorProfile::isLinear(), KIS_ASSERT_X, LABAColorModelID, KoColorSpace::lumaCoefficients, m_d, KoColorSpace::profile(), RGBAColorModelID, sigColorModelChanged(), and YCbCrAColorModelID.

◆ maxChannelValues()

QVector4D KisVisualColorModel::maxChannelValues ( ) const

Definition at line 144 of file KisVisualColorModel.cpp.

145{
146 return m_d->channelMaxValues;
147}

References m_d.

◆ setMaxChannelValues()

void KisVisualColorModel::setMaxChannelValues ( const QVector4D & maxValues)

Definition at line 149 of file KisVisualColorModel.cpp.

150{
151 if (maxValues == m_d->channelMaxValues) {
152 return;
153 }
154 m_d->channelMaxValues = maxValues;
155 if (m_d->exposureSupported) {
156 // need to re-scale our normalized channel values on exposure changes:
157 m_d->channelValues = convertKoColorToChannelValues(m_d->currentcolor);
159 }
160}
QVector4D convertKoColorToChannelValues(KoColor c) const

References convertKoColorToChannelValues(), emitChannelValues(), and m_d.

◆ setRGBColorModel()

void KisVisualColorModel::setRGBColorModel ( KisVisualColorModel::ColorModel model)

Set the HSX color model used for RGB color spaces.

Definition at line 172 of file KisVisualColorModel.cpp.

173{
174 if (model == m_d->modelRGB) {
175 return;
176 }
177 if (model >= ColorModel::HSV && model <= ColorModel::HSY) {
178 m_d->modelRGB = model;
179 if (m_d->isRGBA) {
180 m_d->model = model;
181 m_d->applyGamma = (m_d->isLinear && m_d->modelRGB != ColorModel::HSY);
182 Q_EMIT sigColorModelChanged();
183 m_d->channelValues = convertKoColorToChannelValues(m_d->currentcolor);
185 }
186 }
187}

References convertKoColorToChannelValues(), emitChannelValues(), HSV, HSY, m_d, and sigColorModelChanged().

◆ sigChannelValuesChanged

void KisVisualColorModel::sigChannelValuesChanged ( const QVector4D & values,
quint32 channelFlags )
signal

◆ sigColorModelChanged

void KisVisualColorModel::sigColorModelChanged ( )
signal

sigColorModelChanged is emitted whenever the color model changes.

This can either be due to a change in color space that uses a different channel model, or when the same color space gets represented in a different way, for example RGB representation switches from HSV to HSL etc. so the values of sigChannelValuesChanged() change meaning. Note: This will be followed by sigChannelValuesChanged() unless caused by a color space change, new channel values are not available yet when this signal occurs.

See also
getColorModel()

◆ sigColorSpaceChanged

void KisVisualColorModel::sigColorSpaceChanged ( )
signal

sigColorSpaceChanged notifies that the color space from which the channel values are derived changed, and thus invalidating the current ones.

◆ sigNewColor

void KisVisualColorModel::sigNewColor ( const KoColor & c)
signal

◆ slotLoadACSConfig

void KisVisualColorModel::slotLoadACSConfig ( )
slot

slotLoadACSConfig loads supported settings from Advanced Color Selector

Definition at line 354 of file KisVisualColorModel.cpp.

355{
356 KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
357 m_d->acs_config = KisColorSelectorConfiguration::fromString(cfg.readEntry("colorSelectorConfiguration", KisColorSelectorConfiguration().toString()));
358
359 m_d->gamma = cfg.readEntry("gamma", 2.2);
360
362
363 switch(m_d->acs_config.mainTypeParameter) {
364
369 RGB_model = KisVisualColorModel::HSV;
370 break;
371
375 RGB_model = KisVisualColorModel::HSL;
376 break;
377
381 RGB_model = KisVisualColorModel::HSI;
382 break;
383
387 RGB_model = KisVisualColorModel::HSY;
388 break;
389
390 default:
392 }
393 if (m_d->acs_config.mainType == KisColorSelectorConfiguration::Triangle) {
394 //Triangle only really works in HSV mode.
395 RGB_model = KisVisualColorModel::HSV;
396 }
397
398 setRGBColorModel(RGB_model);
399}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KisColorSelectorConfiguration::fromString(), HSI, KisColorSelectorConfiguration::hsiSH, HSL, KisColorSelectorConfiguration::hslSH, HSV, KisColorSelectorConfiguration::hsvSH, HSY, KisColorSelectorConfiguration::hsySH, KisColorSelectorConfiguration::IH, KIS_SAFE_ASSERT_RECOVER_NOOP, KisColorSelectorConfiguration::LH, m_d, setRGBColorModel(), KisColorSelectorConfiguration::SI, KisColorSelectorConfiguration::SL, KisColorSelectorConfiguration::SV, KisColorSelectorConfiguration::SV2, KisColorSelectorConfiguration::SY, KisColorSelectorConfiguration::Triangle, KisColorSelectorConfiguration::VH, and KisColorSelectorConfiguration::YH.

◆ slotSetChannelValues

void KisVisualColorModel::slotSetChannelValues ( const QVector4D & values)
slot

Definition at line 102 of file KisVisualColorModel.cpp.

103{
104 if (!m_d->allowUpdates) {
105 return;
106 }
107
108 quint32 changeFlags = 0;
109 QVector4D newValues(0, 0, 0, 0);
110 for (int i = 0; i < m_d->colorChannelCount; i++) {
111 newValues[i] = values[i];
112 changeFlags |= quint32(values[i] != m_d->channelValues[i]) << i;
113 }
114 if (changeFlags != 0) {
115 m_d->allowUpdates = false;
116 m_d->channelValues = newValues;
117 m_d->currentcolor = convertChannelValuesToKoColor(newValues);
118 Q_EMIT sigChannelValuesChanged(m_d->channelValues, changeFlags);
119 Q_EMIT sigNewColor(m_d->currentcolor);
120 m_d->allowUpdates = true;
121 }
122}
KoColor convertChannelValuesToKoColor(const QVector4D &values) const
void sigNewColor(const KoColor &c)

References convertChannelValuesToKoColor(), m_d, sigChannelValuesChanged(), and sigNewColor().

◆ slotSetColor

void KisVisualColorModel::slotSetColor ( const KoColor & c)
slot

Definition at line 62 of file KisVisualColorModel.cpp.

63{
64 if (!m_d->allowUpdates) {
65 return;
66 }
67
68 if (!m_d->currentCS) {
69 m_d->currentcolor = c;
71 }
72 else {
73 m_d->currentcolor = c.convertedTo(m_d->currentCS);
74 m_d->channelValues = convertKoColorToChannelValues(m_d->currentcolor);
76 }
77}
KoColor convertedTo(const KoColorSpace *cs, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
Definition KoColor.cpp:163

References KoColor::colorSpace(), KoColor::convertedTo(), convertKoColorToChannelValues(), emitChannelValues(), m_d, and slotSetColorSpace().

◆ slotSetColorSpace

void KisVisualColorModel::slotSetColorSpace ( const KoColorSpace * cs)
slot

Definition at line 79 of file KisVisualColorModel.cpp.

80{
81 if (!m_d->currentCS || *m_d->currentCS != *cs) {
82 const KoColorSpace *csNew = cs;
83
84 // PQ color space is not very suitable for color picking, substitute with linear one
87
91 }
92
93
94 // TODO: split off non-config related initializations
95 loadColorSpace(csNew);
96 m_d->currentcolor = KoColor(csNew);
97 m_d->channelValues = convertKoColorToChannelValues(m_d->currentcolor);
98 Q_EMIT sigColorSpaceChanged();
99 }
100}
@ TRC_ITU_R_BT_2100_0_PQ
void loadColorSpace(const KoColorSpace *cs)
void sigColorSpaceChanged()
sigColorSpaceChanged notifies that the color space from which the channel values are derived changed,...
QString id() const
Definition KoID.cpp:63
virtual TransferCharacteristics getTransferCharacteristics() const
getTransferCharacteristics This function should be subclassed at some point so we can get the value f...
static KoColorSpaceRegistry * instance()
const KoColorProfile * p2020G10Profile() const

References KoColorSpace::colorModelId(), colorSpace(), convertKoColorToChannelValues(), Float32BitsColorDepthID, KoColorProfile::getTransferCharacteristics(), KoID::id(), KoColorSpaceRegistry::instance(), loadColorSpace(), m_d, KoColorSpaceRegistry::p2020G10Profile(), KoColorSpace::profile(), RGBAColorModelID, sigColorSpaceChanged(), and TRC_ITU_R_BT_2100_0_PQ.

◆ supportsExposure()

bool KisVisualColorModel::supportsExposure ( ) const

Definition at line 199 of file KisVisualColorModel.cpp.

200{
201 return (m_d->exposureSupported);
202}

References m_d.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisVisualColorModel::m_d
private

Definition at line 103 of file KisVisualColorModel.h.


The documentation for this class was generated from the following files: