Krita Source Code Documentation
Loading...
Searching...
No Matches
KisVisualColorSelectorShape Class Referenceabstract

The KisVisualColorSelectorShape class A 2d widget can represent at maximum 2 coordinates. So first decide how many coordinates you need. (onedimensional, or twodimensional) Then, select the channels you wish to be affected. This uses the model, so for cmyk the channel is c=0, m=1, y=2, k=3, but for hsv, hue=0, sat=1, and val=2 Then finally, connect the displayrenderer, you can also do this with 'setdisplayrenderer'. More...

#include <KisVisualColorSelectorShape.h>

+ Inheritance diagram for KisVisualColorSelectorShape:

Classes

struct  Private
 

Public Types

enum  Dimensions { onedimensional , twodimensional }
 The Dimensions enum Whether or not the shape is single or two dimensional. More...
 

Signals

void sigCursorMoved (QPointF pos)
 

Public Member Functions

int channel (int dimension) const
 channel Get the channel index associated with a selector shape dimension
 
quint32 channelMask () const
 
void forceImageUpdate ()
 forceImageUpdate force the image to recache.
 
QColor getColorFromConverter (KoColor c)
 getColorFromConverter
 
KoColor getCurrentColor ()
 getCurrentColor
 
QPointF getCursorPosition () const
 getCursorPosition
 
Dimensions getDimensions () const
 getDimensions
 
const QImage & getImageMap ()
 getImageMap returns the updated base image
 
virtual QRect getSpaceForCircle (QRect geom)=0
 
virtual QRect getSpaceForSquare (QRect geom)=0
 getSpaceForSquare
 
virtual QRect getSpaceForTriangle (QRect geom)=0
 
bool isHueControl () const
 
 KisVisualColorSelectorShape (KisVisualColorSelector *parent, KisVisualColorSelectorShape::Dimensions dimension, int channel1, int channel2)
 
void setAcceptTabletEvents (bool on)
 
virtual void setBorderWidth (int width)=0
 setBorderWidth set the border of the single dimensional selector.
 
void setChannelValues (QVector4D channelValues, quint32 channelFlags)
 setChannelValues Set the current channel values; Note that channel values controlled by the shape itself have no effect unless setCursor is true. This will trigger a full widget repaint.
 
void setCursorPosition (QPointF position, bool signal=false)
 setCursorPosition Set the cursor to normalized shape coordinates. This will only repaint the cursor.
 
virtual bool supportsGamutMask () const
 
virtual void updateGamutMask ()
 Notify shape that the gamut mask changed.
 
 ~KisVisualColorSelectorShape () override
 

Protected Member Functions

KisVisualColorSelectorcolorSelector () const
 
virtual QImage compositeBackground () const
 
QImage convertImageMap (const quint8 *rawColor, quint32 bufferSize, QSize imgSize) const
 convertImageMap convert image data containing raw KoColor data into a QImage
 
void mouseMoveEvent (QMouseEvent *e) override
 
virtual QPointF mousePositionToShapeCoordinate (const QPointF &pos, const QPointF &dragStart) const
 default implementation just calls convertWidgetCoordinateToShapeCoordinate(pos)
 
void mousePressEvent (QMouseEvent *e) override
 
void mouseReleaseEvent (QMouseEvent *e) override
 
void paintEvent (QPaintEvent *) override
 
virtual QImage renderAlphaMask () const
 render the alpha mask for the widget background the returned image is expected to be QImage::Format_Alpha8
 
virtual QImage renderBackground (const QVector4D &channelValues, const QImage &alpha) const
 renderBackground Render the widget background visible inside the widget's mask in current color space Rendering shall be done with the conversion functions of KisVisualColorSelector
 
virtual QImage renderStaticAlphaMask () const
 
void resizeEvent (QResizeEvent *) override
 
KisVisualColorModelselectorModel () const
 
void tabletEvent (QTabletEvent *event) override
 

Private Member Functions

virtual QPointF convertShapeCoordinateToWidgetCoordinate (QPointF) const =0
 convertShapeCoordinateToWidgetCoordinate
 
virtual QPointF convertWidgetCoordinateToShapeCoordinate (QPointF coordinate) const =0
 convertWidgetCoordinateToShapeCoordinate Convert a coordinate in the widget's height/width to a shape coordinate.
 
virtual void drawCursor (QPainter &painter)=0
 
virtual void drawGamutMask (QPainter &painter)
 
virtual QRegion getMaskMap ()=0
 getPixmap
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

The KisVisualColorSelectorShape class A 2d widget can represent at maximum 2 coordinates. So first decide how many coordinates you need. (onedimensional, or twodimensional) Then, select the channels you wish to be affected. This uses the model, so for cmyk the channel is c=0, m=1, y=2, k=3, but for hsv, hue=0, sat=1, and val=2 Then finally, connect the displayrenderer, you can also do this with 'setdisplayrenderer'.

Either way, this class is made to be subclassed, with a few virtuals so that the geometry can be calculated properly.

Definition at line 33 of file KisVisualColorSelectorShape.h.

Member Enumeration Documentation

◆ Dimensions

The Dimensions enum Whether or not the shape is single or two dimensional.

Enumerator
onedimensional 
twodimensional 

Definition at line 41 of file KisVisualColorSelectorShape.h.

Constructor & Destructor Documentation

◆ KisVisualColorSelectorShape()

KisVisualColorSelectorShape::KisVisualColorSelectorShape ( KisVisualColorSelector * parent,
KisVisualColorSelectorShape::Dimensions dimension,
int channel1,
int channel2 )
explicit

Definition at line 40 of file KisVisualColorSelectorShape.cpp.

43 : QWidget(parent), m_d(new Private)
44{
45 m_d->dimension = dimension;
46 int maxchannel = parent->selectorModel()->colorSpace()->colorChannelCount()-1;
47 m_d->channel1 = qBound(0, channel1, maxchannel);
48 m_d->channel2 = qBound(0, channel2, maxchannel);
49 m_d->channelMask = 1 << channel1;
50 if (dimension == Dimensions::twodimensional) {
51 m_d->channelMask |= 1 << channel2;
52 }
53 this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
54}
const QScopedPointer< Private > m_d
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References m_d, and twodimensional.

◆ ~KisVisualColorSelectorShape()

KisVisualColorSelectorShape::~KisVisualColorSelectorShape ( )
override

Definition at line 56 of file KisVisualColorSelectorShape.cpp.

57{
58}

Member Function Documentation

◆ channel()

int KisVisualColorSelectorShape::channel ( int dimension) const

channel Get the channel index associated with a selector shape dimension

Parameters
dimensionA shape dimension that can be controlled by the cursor
Returns

Definition at line 405 of file KisVisualColorSelectorShape.cpp.

406{
407 if (dimension == 0) {
408 return m_d->channel1;
409 }
410 if (dimension == 1 && getDimensions() == twodimensional) {
411 return m_d->channel2;
412 }
413 return -1;
414}
Dimensions getDimensions() const
getDimensions

References getDimensions(), m_d, and twodimensional.

◆ channelMask()

quint32 KisVisualColorSelectorShape::channelMask ( ) const

Definition at line 416 of file KisVisualColorSelectorShape.cpp.

417{
418 return m_d->channelMask;
419}

References m_d.

◆ colorSelector()

KisVisualColorSelector * KisVisualColorSelectorShape::colorSelector ( ) const
protected

Definition at line 137 of file KisVisualColorSelectorShape.cpp.

138{
139 KisVisualColorSelector* selectorWidget = qobject_cast<KisVisualColorSelector*>(parent());
140 KIS_ASSERT(selectorWidget);
141 return selectorWidget;
142}
The KisVisualColorSelector class.
#define KIS_ASSERT(cond)
Definition kis_assert.h:33

References KIS_ASSERT.

◆ compositeBackground()

QImage KisVisualColorSelectorShape::compositeBackground ( ) const
protectedvirtual

Definition at line 239 of file KisVisualColorSelectorShape.cpp.

240{
241 // Shapes are expect to return a valid alpha mask or a valid
242 // static alpha mask. If they provide both, the rendered backgrounds
243 // get composited.
244 if (m_d->alphaNeedsUpdate) {
245 QImage staticAlpha = renderStaticAlphaMask();
246 if (!staticAlpha.isNull()) {
247 QVector4D neutralValues(1, 1, 1, 1);
248 switch (selectorModel()->colorModel()) {
252 neutralValues.setZ(0.5f);
253 default:
254 break;
255 }
256
257 m_d->staticBackground = renderBackground(neutralValues, staticAlpha);
258 }
259 m_d->alphaMask = renderAlphaMask();
260 m_d->alphaNeedsUpdate = false;
261 }
262 if (m_d->alphaMask.isNull()) {
263 return m_d->staticBackground;
264 }
265
266 QImage bgImage = renderBackground(m_d->currentChannelValues, m_d->alphaMask);
267 if (!m_d->staticBackground.isNull()) {
268 QPainter painter(&bgImage);
269 // composite static and dynamic background parts
270 painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
271 painter.drawImage(0, 0, m_d->staticBackground);
272 }
273 return bgImage;
274}
KisVisualColorModel * selectorModel() const
virtual QImage renderBackground(const QVector4D &channelValues, const QImage &alpha) const
renderBackground Render the widget background visible inside the widget's mask in current color space...
virtual QImage renderAlphaMask() const
render the alpha mask for the widget background the returned image is expected to be QImage::Format_A...

References KisVisualColorModel::HSI, KisVisualColorModel::HSL, KisVisualColorModel::HSY, m_d, renderAlphaMask(), renderBackground(), renderStaticAlphaMask(), and selectorModel().

◆ convertImageMap()

QImage KisVisualColorSelectorShape::convertImageMap ( const quint8 * rawColor,
quint32 bufferSize,
QSize imgSize ) const
protected

convertImageMap convert image data containing raw KoColor data into a QImage

Parameters
datamust point to memory of size width()*height()*pixelSize
sizethe number of bytes to read from data, must match aforementioned criteria
Returns
the converted QImage guaranteed to match the widget size (black content on failure)

Definition at line 165 of file KisVisualColorSelectorShape.cpp.

166{
167 const KoColorSpace *colorSpace = selectorModel()->colorSpace();
168 Q_ASSERT(bufferSize == imgSize.width() * imgSize.height() * colorSpace->pixelSize());
170
171 // Convert the buffer to a qimage
172 QImage image = renderer->toQImage(colorSpace, rawColor, imgSize, colorSelector()->proofColors());
173
174 // safeguard:
175 if (image.isNull())
176 {
177 image = QImage(width(), height(), QImage::Format_ARGB32);
178 image.fill(Qt::black);
179 }
180
181 return image;
182}
const KoColorSpace * colorSpace() const
KisVisualColorSelector * colorSelector() const
const KoColorDisplayRendererInterface * displayRenderer() const
virtual QImage toQImage(const KoColorSpace *srcColorSpace, const quint8 *data, QSize size, bool proofPaintColors=false) const =0
Convert a consecutive block of pixel data to an ARGB32 QImage.
virtual quint32 pixelSize() const =0

References colorSelector(), KisVisualColorModel::colorSpace(), KisVisualColorSelector::displayRenderer(), KoColorSpace::pixelSize(), selectorModel(), and KoColorDisplayRendererInterface::toQImage().

◆ convertShapeCoordinateToWidgetCoordinate()

virtual QPointF KisVisualColorSelectorShape::convertShapeCoordinateToWidgetCoordinate ( QPointF ) const
privatepure virtual

convertShapeCoordinateToWidgetCoordinate

Returns
take the position in the shape and convert it to screen coordinates.

Implemented in KisVisualDiamondSelectorShape, KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, and KisVisualTriangleSelectorShape.

◆ convertWidgetCoordinateToShapeCoordinate()

virtual QPointF KisVisualColorSelectorShape::convertWidgetCoordinateToShapeCoordinate ( QPointF coordinate) const
privatepure virtual

convertWidgetCoordinateToShapeCoordinate Convert a coordinate in the widget's height/width to a shape coordinate.

Parameters
coordinatethe position your wish to have the shape coordinates of.

Implemented in KisVisualDiamondSelectorShape, KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, and KisVisualTriangleSelectorShape.

◆ drawCursor()

virtual void KisVisualColorSelectorShape::drawCursor ( QPainter & painter)
privatepure virtual

◆ drawGamutMask()

void KisVisualColorSelectorShape::drawGamutMask ( QPainter & painter)
privatevirtual

Reimplemented in KisVisualEllipticalSelectorShape.

Definition at line 384 of file KisVisualColorSelectorShape.cpp.

385{
386 // Nothing to do if gamut masks not supported
387 Q_UNUSED(painter);
388}

◆ forceImageUpdate()

void KisVisualColorSelectorShape::forceImageUpdate ( )

forceImageUpdate force the image to recache.

Definition at line 119 of file KisVisualColorSelectorShape.cpp.

120{
121 //qDebug() << this << "forceImageUpdate";
122 m_d->alphaNeedsUpdate = true;
123 m_d->imagesNeedUpdate = true;
124}

References m_d.

◆ getColorFromConverter()

QColor KisVisualColorSelectorShape::getColorFromConverter ( KoColor c)

getColorFromConverter

Parameters
ca koColor.
Returns
get the qcolor from the given kocolorusing this widget's display renderer.

Definition at line 131 of file KisVisualColorSelectorShape.cpp.

132{
134 return renderer->toQColor(c, colorSelector()->proofColors());
135}
virtual QColor toQColor(const KoColor &c, bool proofToPaintColors=false) const =0

References colorSelector(), KisVisualColorSelector::displayRenderer(), and KoColorDisplayRendererInterface::toQColor().

◆ getCurrentColor()

KoColor KisVisualColorSelectorShape::getCurrentColor ( )

getCurrentColor

Returns
the current kocolor

Definition at line 395 of file KisVisualColorSelectorShape.cpp.

396{
397 const KisVisualColorModel *selector = selectorModel();
398 if (selector)
399 {
400 return selector->convertChannelValuesToKoColor(m_d->currentChannelValues);
401 }
402 return KoColor();
403}
The KisVisualColorModel class allows manipulating a KoColor using various color models.
KoColor convertChannelValuesToKoColor(const QVector4D &values) const

References KisVisualColorModel::convertChannelValuesToKoColor(), m_d, and selectorModel().

◆ getCursorPosition()

QPointF KisVisualColorSelectorShape::getCursorPosition ( ) const

getCursorPosition

Returns
current cursor position in shape-coordinates.

Definition at line 60 of file KisVisualColorSelectorShape.cpp.

60 {
61 return m_d->currentCoordinates;
62}

References m_d.

◆ getDimensions()

KisVisualColorSelectorShape::Dimensions KisVisualColorSelectorShape::getDimensions ( ) const

getDimensions

Returns
whether this is a single or twodimensional widget.

Definition at line 390 of file KisVisualColorSelectorShape.cpp.

391{
392 return m_d->dimension;
393}

References m_d.

◆ getImageMap()

const QImage & KisVisualColorSelectorShape::getImageMap ( )

getImageMap returns the updated base image

Returns
the final image of the shape content, before the handle gets drawn. the pixmap will not change until a redraw is required, which depends on whether the shape is static or changes depending on other color channels.

Definition at line 151 of file KisVisualColorSelectorShape.cpp.

152{
153 //qDebug() << this << ">>>>>>>>> getImageMap()" << m_d->imagesNeedUpdate;
154
155 if (m_d->imagesNeedUpdate) {
156 // NOTE: pure static backgrounds are currently somewhat implicitly handled,
157 // it would be nicer to avoid re-checking and overwriting m_d->gradient.
158 // But QImage's implicit data sharing allows all this mindless by-value stuff...
159 m_d->gradient = compositeBackground();
160 m_d->imagesNeedUpdate = false;
161 }
162 return m_d->gradient;
163}

References compositeBackground(), and m_d.

◆ getMaskMap()

virtual QRegion KisVisualColorSelectorShape::getMaskMap ( )
privatepure virtual

◆ getSpaceForCircle()

virtual QRect KisVisualColorSelectorShape::getSpaceForCircle ( QRect geom)
pure virtual

◆ getSpaceForSquare()

virtual QRect KisVisualColorSelectorShape::getSpaceForSquare ( QRect geom)
pure virtual

getSpaceForSquare

Parameters
geomthe full widget rectangle
Returns
rectangle with enough space for second widget

Implemented in KisVisualDiamondSelectorShape, KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, and KisVisualTriangleSelectorShape.

◆ getSpaceForTriangle()

virtual QRect KisVisualColorSelectorShape::getSpaceForTriangle ( QRect geom)
pure virtual

◆ isHueControl()

bool KisVisualColorSelectorShape::isHueControl ( ) const

◆ mouseMoveEvent()

void KisVisualColorSelectorShape::mouseMoveEvent ( QMouseEvent * e)
overrideprotected

Definition at line 305 of file KisVisualColorSelectorShape.cpp.

306{
307 if (e->buttons() & Qt::LeftButton) {
308 QPointF coordinates = mousePositionToShapeCoordinate(e->localPos(), m_d->dragStart);
309 setCursorPosition(coordinates, true);
310 } else {
311 e->ignore();
312 }
313}
void setCursorPosition(QPointF position, bool signal=false)
setCursorPosition Set the cursor to normalized shape coordinates. This will only repaint the cursor.
virtual QPointF mousePositionToShapeCoordinate(const QPointF &pos, const QPointF &dragStart) const
default implementation just calls convertWidgetCoordinateToShapeCoordinate(pos)

References m_d, mousePositionToShapeCoordinate(), and setCursorPosition().

◆ mousePositionToShapeCoordinate()

QPointF KisVisualColorSelectorShape::mousePositionToShapeCoordinate ( const QPointF & pos,
const QPointF & dragStart ) const
protectedvirtual

default implementation just calls convertWidgetCoordinateToShapeCoordinate(pos)

Reimplemented in KisVisualEllipticalSelectorShape.

Definition at line 286 of file KisVisualColorSelectorShape.cpp.

287{
288 Q_UNUSED(dragStart);
290}
virtual QPointF convertWidgetCoordinateToShapeCoordinate(QPointF coordinate) const =0
convertWidgetCoordinateToShapeCoordinate Convert a coordinate in the widget's height/width to a shape...

References convertWidgetCoordinateToShapeCoordinate().

◆ mousePressEvent()

void KisVisualColorSelectorShape::mousePressEvent ( QMouseEvent * e)
overrideprotected

Definition at line 292 of file KisVisualColorSelectorShape.cpp.

293{
294 if (e->button() == Qt::LeftButton) {
295 m_d->dragStart = e->localPos();
296 Q_EMIT colorSelector()->sigInteraction(true);
297 QPointF coordinates = mousePositionToShapeCoordinate(e->localPos(), m_d->dragStart);
298 setCursorPosition(coordinates, true);
299 }
300 else {
301 e->ignore();
302 }
303}
void sigInteraction(bool active)
sigInteraction is emitted whenever mouse interaction status changes

References colorSelector(), m_d, mousePositionToShapeCoordinate(), setCursorPosition(), and KisVisualColorSelector::sigInteraction().

◆ mouseReleaseEvent()

void KisVisualColorSelectorShape::mouseReleaseEvent ( QMouseEvent * e)
overrideprotected

Definition at line 315 of file KisVisualColorSelectorShape.cpp.

316{
317 if (e->button() == Qt::LeftButton) {
318 Q_EMIT colorSelector()->sigInteraction(false);
319 } else {
320 e->ignore();
321 }
322}

References colorSelector(), and KisVisualColorSelector::sigInteraction().

◆ paintEvent()

void KisVisualColorSelectorShape::paintEvent ( QPaintEvent * )
overrideprotected

Definition at line 360 of file KisVisualColorSelectorShape.cpp.

361{
362 QPainter painter(this);
363
364 const QImage &fullSelector = getImageMap();
365 if (!fullSelector.isNull()) {
366 painter.drawImage(0, 0, fullSelector);
367 }
368
369 drawGamutMask(painter);
370
371 if (isEnabled()) {
372 painter.setRenderHint(QPainter::Antialiasing);
373 drawCursor(painter);
374 }
375}
virtual void drawCursor(QPainter &painter)=0
virtual void drawGamutMask(QPainter &painter)
const QImage & getImageMap()
getImageMap returns the updated base image

References drawCursor(), drawGamutMask(), and getImageMap().

◆ renderAlphaMask()

QImage KisVisualColorSelectorShape::renderAlphaMask ( ) const
protectedvirtual

render the alpha mask for the widget background the returned image is expected to be QImage::Format_Alpha8

Reimplemented in KisVisualDiamondSelectorShape, KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, and KisVisualTriangleSelectorShape.

Definition at line 276 of file KisVisualColorSelectorShape.cpp.

277{
278 return QImage();
279}

◆ renderBackground()

QImage KisVisualColorSelectorShape::renderBackground ( const QVector4D & channelValues,
const QImage & alpha ) const
protectedvirtual

renderBackground Render the widget background visible inside the widget's mask in current color space Rendering shall be done with the conversion functions of KisVisualColorSelector

Parameters
datapoints to zero-initialized memory of size width()*height()*pixelSize
pixelSizethe data size to transfer from KoColor::data() to data per pixel in the current color space
channelValuesthe normalized channel values of the currently selected color

Definition at line 184 of file KisVisualColorSelectorShape.cpp.

185{
186 const KisVisualColorModel *selector = selectorModel();
187 Q_ASSERT(selector);
188
189 // Hi-DPI aware rendering requires that we determine the device pixel dimension;
190 // actual widget size in device pixels is not accessible unfortunately, it might be 1px smaller...
191 const qreal deviceDivider = 1.0 / devicePixelRatioF();
192 const int deviceWidth = qCeil(width() * devicePixelRatioF());
193 const int deviceHeight = qCeil(height() * devicePixelRatioF());
194 quint32 imageSize = deviceWidth * deviceHeight * selector->colorSpace()->pixelSize();
195 QScopedArrayPointer<quint8> raw(new quint8[imageSize] {});
196 quint8 *dataPtr = raw.data();
197 QVector4D coordinates = channelValues;
198 const qsizetype pixelSize = selector->colorSpace()->pixelSize();
199
200 bool checkAlpha = !alpha.isNull() && alpha.valid(deviceWidth - 1, deviceHeight - 1);
201 KIS_SAFE_ASSERT_RECOVER(!checkAlpha || alpha.format() == QImage::Format_Alpha8) {
202 checkAlpha = false;
203 }
204
205 KoColor filler(Qt::white, selector->colorSpace());
206 for (int y = 0; y < deviceHeight; y++) {
207 const uchar *alphaLine = checkAlpha ? alpha.scanLine(y) : 0;
208 for (int x=0; x < deviceWidth; x++) {
209 if (!checkAlpha || alphaLine[x]) {
210 QPointF newcoordinate = convertWidgetCoordinateToShapeCoordinate(QPointF(x, y) * deviceDivider);
211 coordinates[m_d->channel1] = newcoordinate.x();
212 if (m_d->dimension == Dimensions::twodimensional) {
213 coordinates[m_d->channel2] = newcoordinate.y();
214 }
215 KoColor c = selector->convertChannelValuesToKoColor(coordinates);
216 memcpy(dataPtr, c.data(), pixelSize);
217 }
218 else {
219 // need to write a color with non-zero alpha, otherwise the display converter
220 // will for some arcane reason crop the final QImage and screw rendering
221 memcpy(dataPtr, filler.data(), pixelSize);
222 }
223 dataPtr += pixelSize;
224 }
225 }
226 QImage image = convertImageMap(raw.data(), imageSize, QSize(deviceWidth, deviceHeight));
227 image.setDevicePixelRatio(devicePixelRatioF());
228
229 if (!alpha.isNull()) {
230 QPainter painter(&image);
231 // transfer alphaMask to Alpha channel
232 painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
233 painter.drawImage(0, 0, alpha);
234 }
235
236 return image;
237}
QImage convertImageMap(const quint8 *rawColor, quint32 bufferSize, QSize imgSize) const
convertImageMap convert image data containing raw KoColor data into a QImage
quint8 * data()
Definition KoColor.h:144
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

References KisVisualColorModel::colorSpace(), KisVisualColorModel::convertChannelValuesToKoColor(), convertImageMap(), convertWidgetCoordinateToShapeCoordinate(), KoColor::data(), KIS_SAFE_ASSERT_RECOVER, m_d, KoColorSpace::pixelSize(), selectorModel(), and twodimensional.

◆ renderStaticAlphaMask()

QImage KisVisualColorSelectorShape::renderStaticAlphaMask ( ) const
protectedvirtual

Reimplemented in KisVisualEllipticalSelectorShape.

Definition at line 281 of file KisVisualColorSelectorShape.cpp.

282{
283 return QImage();
284}

◆ resizeEvent()

void KisVisualColorSelectorShape::resizeEvent ( QResizeEvent * )
overrideprotected

Definition at line 377 of file KisVisualColorSelectorShape.cpp.

378{
381 setMask(getMaskMap());
382}
void forceImageUpdate()
forceImageUpdate force the image to recache.
virtual void updateGamutMask()
Notify shape that the gamut mask changed.
virtual QRegion getMaskMap()=0
getPixmap

References forceImageUpdate(), getMaskMap(), and updateGamutMask().

◆ selectorModel()

KisVisualColorModel * KisVisualColorSelectorShape::selectorModel ( ) const
protected

Definition at line 144 of file KisVisualColorSelectorShape.cpp.

145{
146 KisVisualColorSelector* selectorWidget = qobject_cast<KisVisualColorSelector*>(parent());
147 KIS_ASSERT(selectorWidget);
148 return selectorWidget->selectorModel().data();
149}
KisVisualColorModelSP selectorModel() const

References KIS_ASSERT, and KisVisualColorSelector::selectorModel().

◆ setAcceptTabletEvents()

void KisVisualColorSelectorShape::setAcceptTabletEvents ( bool on)

Definition at line 102 of file KisVisualColorSelectorShape.cpp.

103{
104 m_d->acceptTabletEvents = on;
105}

References m_d.

◆ setBorderWidth()

virtual void KisVisualColorSelectorShape::setBorderWidth ( int width)
pure virtual

setBorderWidth set the border of the single dimensional selector.

Parameters
width

Implemented in KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, KisVisualDiamondSelectorShape, and KisVisualTriangleSelectorShape.

◆ setChannelValues()

void KisVisualColorSelectorShape::setChannelValues ( QVector4D channelValues,
quint32 channelFlags )

setChannelValues Set the current channel values; Note that channel values controlled by the shape itself have no effect unless setCursor is true. This will trigger a full widget repaint.

Parameters
positionnormalized shape coordinates ([0,1] range) these are not yet transformed to color space specific ranges!
setCursorif true, sets the cursor too, otherwise the shape-controlled channels are not set

Definition at line 82 of file KisVisualColorSelectorShape.cpp.

83{
84 //qDebug() << this << "setChannelValues";
85 m_d->currentChannelValues = channelValues;
86 bool setCursor = channelFlags & m_d->channelMask;
87 if (setCursor) {
88 m_d->currentCoordinates = QPointF(qBound(0.f, channelValues[m_d->channel1], 1.f),
89 qBound(0.f, channelValues[m_d->channel2], 1.f));
90 }
91 else {
92 // for internal consistency, because we have a bit of redundancy here
93 m_d->currentChannelValues[m_d->channel1] = m_d->currentCoordinates.x();
94 if (m_d->dimension == Dimensions::twodimensional){
95 m_d->currentChannelValues[m_d->channel2] = m_d->currentCoordinates.y();
96 }
97 }
98 m_d->imagesNeedUpdate = m_d->imagesNeedUpdate || channelFlags & ~m_d->channelMask;
99 update();
100}
bool update(QSpinBox *spinBox)

References m_d, and twodimensional.

◆ setCursorPosition()

void KisVisualColorSelectorShape::setCursorPosition ( QPointF position,
bool signal = false )

setCursorPosition Set the cursor to normalized shape coordinates. This will only repaint the cursor.

Parameters
positionnormalized shape coordinates ([0,1] range, not yet transformed to actual channel values!)
signalif true, Q_EMIT a sigCursorMoved signal

Definition at line 64 of file KisVisualColorSelectorShape.cpp.

65{
66 QPointF newPos(qBound(0.0, position.x(), 1.0), qBound(0.0, position.y(), 1.0));
67 if (newPos != m_d->currentCoordinates)
68 {
69 m_d->currentCoordinates = newPos;
70 // for internal consistency, because we have a bit of redundancy here
71 m_d->currentChannelValues[m_d->channel1] = newPos.x();
72 if (m_d->dimension == Dimensions::twodimensional){
73 m_d->currentChannelValues[m_d->channel2] = newPos.y();
74 }
75 update();
76 if (signal){
77 Q_EMIT sigCursorMoved(newPos);
78 }
79 }
80}
void sigCursorMoved(QPointF pos)

References m_d, sigCursorMoved(), and twodimensional.

◆ sigCursorMoved

void KisVisualColorSelectorShape::sigCursorMoved ( QPointF pos)
signal

◆ supportsGamutMask()

bool KisVisualColorSelectorShape::supportsGamutMask ( ) const
virtual

Reimplemented in KisVisualEllipticalSelectorShape.

Definition at line 114 of file KisVisualColorSelectorShape.cpp.

115{
116 return false;
117}

◆ tabletEvent()

void KisVisualColorSelectorShape::tabletEvent ( QTabletEvent * event)
overrideprotected

Definition at line 324 of file KisVisualColorSelectorShape.cpp.

325{
326 // only accept tablet events that are associated to "left" button
327 // NOTE: QTabletEvent does not have a windowPos() equivalent, but we don't need it
328 if (m_d->acceptTabletEvents &&
329 (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton)))
330 {
331 event->accept();
332 switch (event->type()) {
333 case QEvent::TabletPress: {
334 QMouseEvent mouseEvent(QEvent::MouseButtonPress, event->posF(), event->posF(),
335 event->globalPosF(), event->button(), event->buttons(),
336 event->modifiers(), Qt::MouseEventSynthesizedByApplication);
337 mousePressEvent(&mouseEvent);
338 break;
339 }
340 case QEvent::TabletMove: {
341 QMouseEvent mouseEvent(QEvent::MouseMove, event->posF(), event->posF(),
342 event->globalPosF(), event->button(), event->buttons(),
343 event->modifiers(), Qt::MouseEventSynthesizedByApplication);
344 mouseMoveEvent(&mouseEvent);
345 break;
346 }
347 case QEvent::TabletRelease: {
348 QMouseEvent mouseEvent(QEvent::MouseButtonRelease, event->posF(), event->posF(),
349 event->globalPosF(), event->button(), event->buttons(),
350 event->modifiers(), Qt::MouseEventSynthesizedByApplication);
351 mouseReleaseEvent(&mouseEvent);
352 break;
353 }
354 default:
355 event->ignore();
356 }
357 }
358}
void mouseReleaseEvent(QMouseEvent *e) override
void mouseMoveEvent(QMouseEvent *e) override
void mousePressEvent(QMouseEvent *e) override

References m_d, mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ updateGamutMask()

void KisVisualColorSelectorShape::updateGamutMask ( )
virtual

Notify shape that the gamut mask changed.

The gamut mask shall be updated and the widget repainted if necessary. This includes removal of gamut masks

Reimplemented in KisVisualEllipticalSelectorShape.

Definition at line 126 of file KisVisualColorSelectorShape.cpp.

127{
128 // Nothing to do if gamut masks not supported
129}

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisVisualColorSelectorShape::m_d
private

Definition at line 185 of file KisVisualColorSelectorShape.h.


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