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 130 of file KisVisualColorModel.cpp.

131{
132 return m_d->channelValues;
133}

References m_d.

◆ colorChannelCount()

int KisVisualColorModel::colorChannelCount ( ) const

Definition at line 135 of file KisVisualColorModel.cpp.

136{
137 return m_d->colorChannelCount;
138}

References m_d.

◆ colorModel()

KisVisualColorModel::ColorModel KisVisualColorModel::colorModel ( ) const

Definition at line 140 of file KisVisualColorModel.cpp.

141{
142 return m_d->model;
143}

References m_d.

◆ colorSpace()

const KoColorSpace * KisVisualColorModel::colorSpace ( ) const

Definition at line 190 of file KisVisualColorModel.cpp.

191{
192 return m_d->currentCS;
193}

References m_d.

◆ convertChannelValuesToKoColor()

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

Definition at line 205 of file KisVisualColorModel.cpp.

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

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

164{
165 m_d->channelMaxValues = other.m_d->channelMaxValues;
166 setRGBColorModel(other.m_d->modelRGB);
167 if (other.colorSpace()) {
170 }
171}
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 125 of file KisVisualColorModel.cpp.

126{
127 return m_d->currentcolor;
128}

References m_d.

◆ emitChannelValues()

void KisVisualColorModel::emitChannelValues ( )
private

Definition at line 459 of file KisVisualColorModel.cpp.

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

References m_d, and sigChannelValuesChanged().

◆ isHSXModel()

bool KisVisualColorModel::isHSXModel ( ) const

Definition at line 195 of file KisVisualColorModel.cpp.

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

References HSV, HSY, and m_d.

◆ loadColorSpace()

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

Definition at line 402 of file KisVisualColorModel.cpp.

403{
404 const QList<KoChannelInfo *> channelList = cs->channels();
405 int cCount = 0;
406
407 for (int i = 0; i < channelList.size(); i++) {
408 const KoChannelInfo *channel = channelList.at(i);
409 if (channel->channelType() != KoChannelInfo::ALPHA) {
410 quint32 logical = channel->displayPosition();
411 if (logical > cs->alphaPos()) {
412 --logical;
413 }
414 m_d->logicalToMemoryPosition[logical] = i;
415 m_d->channelMaxValues[logical] = channel->getUIMax();
416 ++cCount;
417 }
418 }
419 KIS_ASSERT_X(cCount < 5, "", "unsupported channel count!");
420
421 m_d->colorChannelCount = cCount;
422
427 && cs->colorModelId() != CMYKAColorModelID) {
428 m_d->exposureSupported = true;
429 } else {
430 m_d->exposureSupported = false;
431 }
432 m_d->isRGBA = (cs->colorModelId() == RGBAColorModelID);
433 m_d->isLABlike = (cs->colorModelId() == LABAColorModelID || cs->colorModelId() == YCbCrAColorModelID);
434
435 const KoColorProfile *profile = cs->profile();
436 m_d->isLinear = (profile && profile->isLinear());
437
438 if (m_d->isRGBA) {
439 m_d->applyGamma = (m_d->isLinear && m_d->modelRGB != ColorModel::HSY);
440 // Note: only profiles that define colorants will give precise luma coefficients.
441 // Maybe using the explicitly set values of the Advanced Color Selector is better?
442 QVector <qreal> luma = cs->lumaCoefficients();
443 memcpy(m_d->lumaRGB, luma.constData(), 3*sizeof(qreal));
444 m_d->model = m_d->modelRGB;
445 } else if (m_d->isLABlike) {
446 m_d->model = m_d->modelRGB;
447 } else {
449 }
450
451 const KoColorSpace *oldCS = m_d->currentCS;
452 m_d->currentCS = cs;
453
454 if (!oldCS || (oldCS->colorModelId() != cs->colorModelId())) {
455 Q_EMIT sigColorModelChanged();
456 }
457}
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 145 of file KisVisualColorModel.cpp.

146{
147 return m_d->channelMaxValues;
148}

References m_d.

◆ setMaxChannelValues()

void KisVisualColorModel::setMaxChannelValues ( const QVector4D & maxValues)

Definition at line 150 of file KisVisualColorModel.cpp.

151{
152 if (maxValues == m_d->channelMaxValues) {
153 return;
154 }
155 m_d->channelMaxValues = maxValues;
156 if (m_d->exposureSupported) {
157 // need to re-scale our normalized channel values on exposure changes:
158 m_d->channelValues = convertKoColorToChannelValues(m_d->currentcolor);
160 }
161}
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 173 of file KisVisualColorModel.cpp.

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

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 355 of file KisVisualColorModel.cpp.

356{
357 KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
358 m_d->acs_config = KisColorSelectorConfiguration::fromString(cfg.readEntry("colorSelectorConfiguration", KisColorSelectorConfiguration().toString()));
359
360 m_d->gamma = cfg.readEntry("gamma", 2.2);
361
363
364 switch(m_d->acs_config.mainTypeParameter) {
365
370 RGB_model = KisVisualColorModel::HSV;
371 break;
372
376 RGB_model = KisVisualColorModel::HSL;
377 break;
378
382 RGB_model = KisVisualColorModel::HSI;
383 break;
384
388 RGB_model = KisVisualColorModel::HSY;
389 break;
390
391 default:
393 }
394 if (m_d->acs_config.mainType == KisColorSelectorConfiguration::Triangle) {
395 //Triangle only really works in HSV mode.
396 RGB_model = KisVisualColorModel::HSV;
397 }
398
399 setRGBColorModel(RGB_model);
400}
#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 103 of file KisVisualColorModel.cpp.

104{
105 if (!m_d->allowUpdates) {
106 return;
107 }
108
109 quint32 changeFlags = 0;
110 QVector4D newValues(0, 0, 0, 0);
111 for (int i = 0; i < m_d->colorChannelCount; i++) {
112 newValues[i] = values[i];
113 changeFlags |= quint32(values[i] != m_d->channelValues[i]) << i;
114 }
115 if (changeFlags != 0) {
116 m_d->allowUpdates = false;
117 m_d->channelValues = newValues;
118 m_d->currentcolor = convertChannelValuesToKoColor(newValues);
119 Q_EMIT sigChannelValuesChanged(m_d->channelValues, changeFlags);
120 Q_EMIT sigNewColor(m_d->currentcolor);
121 m_d->allowUpdates = true;
122 }
123}
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
88
92 }
93
94
95 // TODO: split off non-config related initializations
96 loadColorSpace(csNew);
97 m_d->currentcolor = KoColor(csNew);
98 m_d->channelValues = convertKoColorToChannelValues(m_d->currentcolor);
99 Q_EMIT sigColorSpaceChanged();
100 }
101}
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 QByteArray uniqueId() const =0
static KoColorSpaceRegistry * instance()
const KoColorProfile * p2020PQProfile() const
const KoColorProfile * p2020G10Profile() const

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

◆ supportsExposure()

bool KisVisualColorModel::supportsExposure ( ) const

Definition at line 200 of file KisVisualColorModel.cpp.

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

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: