|
Krita Source Code Documentation
|
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 | |
| KisVisualColorSelector * | colorSelector () 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 |
| KisVisualColorModel * | selectorModel () 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< Private > | m_d |
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.
The Dimensions enum Whether or not the shape is single or two dimensional.
| Enumerator | |
|---|---|
| onedimensional | |
| twodimensional | |
Definition at line 41 of file KisVisualColorSelectorShape.h.
|
explicit |
Definition at line 40 of file KisVisualColorSelectorShape.cpp.
References m_d, and twodimensional.
|
override |
Definition at line 56 of file KisVisualColorSelectorShape.cpp.
| int KisVisualColorSelectorShape::channel | ( | int | dimension | ) | const |
channel Get the channel index associated with a selector shape dimension
| dimension | A shape dimension that can be controlled by the cursor |
Definition at line 405 of file KisVisualColorSelectorShape.cpp.
References getDimensions(), m_d, and twodimensional.
| quint32 KisVisualColorSelectorShape::channelMask | ( | ) | const |
Definition at line 416 of file KisVisualColorSelectorShape.cpp.
References m_d.
|
protected |
Definition at line 137 of file KisVisualColorSelectorShape.cpp.
References KIS_ASSERT.
|
protectedvirtual |
Definition at line 239 of file KisVisualColorSelectorShape.cpp.
References KisVisualColorModel::HSI, KisVisualColorModel::HSL, KisVisualColorModel::HSY, m_d, renderAlphaMask(), renderBackground(), renderStaticAlphaMask(), and selectorModel().
|
protected |
convertImageMap convert image data containing raw KoColor data into a QImage
| data | must point to memory of size width()*height()*pixelSize |
| size | the number of bytes to read from data, must match aforementioned criteria |
Definition at line 165 of file KisVisualColorSelectorShape.cpp.
References colorSelector(), KisVisualColorModel::colorSpace(), KisVisualColorSelector::displayRenderer(), KoColorSpace::pixelSize(), selectorModel(), and KoColorDisplayRendererInterface::toQImage().
|
privatepure virtual |
convertShapeCoordinateToWidgetCoordinate
Implemented in KisVisualDiamondSelectorShape, KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, and KisVisualTriangleSelectorShape.
|
privatepure virtual |
convertWidgetCoordinateToShapeCoordinate Convert a coordinate in the widget's height/width to a shape coordinate.
| coordinate | the position your wish to have the shape coordinates of. |
Implemented in KisVisualDiamondSelectorShape, KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, and KisVisualTriangleSelectorShape.
|
privatepure virtual |
|
privatevirtual |
Reimplemented in KisVisualEllipticalSelectorShape.
Definition at line 384 of file KisVisualColorSelectorShape.cpp.
| void KisVisualColorSelectorShape::forceImageUpdate | ( | ) |
forceImageUpdate force the image to recache.
Definition at line 119 of file KisVisualColorSelectorShape.cpp.
References m_d.
| QColor KisVisualColorSelectorShape::getColorFromConverter | ( | KoColor | c | ) |
getColorFromConverter
| c | a koColor. |
Definition at line 131 of file KisVisualColorSelectorShape.cpp.
References colorSelector(), KisVisualColorSelector::displayRenderer(), and KoColorDisplayRendererInterface::toQColor().
| KoColor KisVisualColorSelectorShape::getCurrentColor | ( | ) |
getCurrentColor
Definition at line 395 of file KisVisualColorSelectorShape.cpp.
References KisVisualColorModel::convertChannelValuesToKoColor(), m_d, and selectorModel().
| QPointF KisVisualColorSelectorShape::getCursorPosition | ( | ) | const |
getCursorPosition
Definition at line 60 of file KisVisualColorSelectorShape.cpp.
References m_d.
| KisVisualColorSelectorShape::Dimensions KisVisualColorSelectorShape::getDimensions | ( | ) | const |
getDimensions
Definition at line 390 of file KisVisualColorSelectorShape.cpp.
References m_d.
| const QImage & KisVisualColorSelectorShape::getImageMap | ( | ) |
getImageMap returns the updated base image
Definition at line 151 of file KisVisualColorSelectorShape.cpp.
References compositeBackground(), and m_d.
|
privatepure virtual |
getPixmap
Implemented in KisVisualDiamondSelectorShape, KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, and KisVisualTriangleSelectorShape.
|
pure virtual |
|
pure virtual |
getSpaceForSquare
| geom | the full widget rectangle |
Implemented in KisVisualDiamondSelectorShape, KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, and KisVisualTriangleSelectorShape.
|
pure virtual |
| bool KisVisualColorSelectorShape::isHueControl | ( | ) | const |
Definition at line 107 of file KisVisualColorSelectorShape.cpp.
References getDimensions(), KisVisualColorModel::isHSXModel(), m_d, onedimensional, and selectorModel().
|
overrideprotected |
Definition at line 305 of file KisVisualColorSelectorShape.cpp.
References m_d, mousePositionToShapeCoordinate(), and setCursorPosition().
|
protectedvirtual |
default implementation just calls convertWidgetCoordinateToShapeCoordinate(pos)
Reimplemented in KisVisualEllipticalSelectorShape.
Definition at line 286 of file KisVisualColorSelectorShape.cpp.
References convertWidgetCoordinateToShapeCoordinate().
|
overrideprotected |
Definition at line 292 of file KisVisualColorSelectorShape.cpp.
References colorSelector(), m_d, mousePositionToShapeCoordinate(), setCursorPosition(), and KisVisualColorSelector::sigInteraction().
|
overrideprotected |
Definition at line 315 of file KisVisualColorSelectorShape.cpp.
References colorSelector(), and KisVisualColorSelector::sigInteraction().
|
overrideprotected |
Definition at line 360 of file KisVisualColorSelectorShape.cpp.
References drawCursor(), drawGamutMask(), and getImageMap().
|
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.
|
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
| data | points to zero-initialized memory of size width()*height()*pixelSize |
| pixelSize | the data size to transfer from KoColor::data() to data per pixel in the current color space |
| channelValues | the normalized channel values of the currently selected color |
Definition at line 184 of file KisVisualColorSelectorShape.cpp.
References KisVisualColorModel::colorSpace(), KisVisualColorModel::convertChannelValuesToKoColor(), convertImageMap(), convertWidgetCoordinateToShapeCoordinate(), KoColor::data(), KIS_SAFE_ASSERT_RECOVER, m_d, KoColorSpace::pixelSize(), selectorModel(), and twodimensional.
|
protectedvirtual |
Reimplemented in KisVisualEllipticalSelectorShape.
Definition at line 281 of file KisVisualColorSelectorShape.cpp.
|
overrideprotected |
Definition at line 377 of file KisVisualColorSelectorShape.cpp.
References forceImageUpdate(), getMaskMap(), and updateGamutMask().
|
protected |
Definition at line 144 of file KisVisualColorSelectorShape.cpp.
References KIS_ASSERT, and KisVisualColorSelector::selectorModel().
| void KisVisualColorSelectorShape::setAcceptTabletEvents | ( | bool | on | ) |
Definition at line 102 of file KisVisualColorSelectorShape.cpp.
References m_d.
|
pure virtual |
setBorderWidth set the border of the single dimensional selector.
| width |
Implemented in KisVisualEllipticalSelectorShape, KisVisualRectangleSelectorShape, KisVisualDiamondSelectorShape, and KisVisualTriangleSelectorShape.
| 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.
| position | normalized shape coordinates ([0,1] range) these are not yet transformed to color space specific ranges! |
| setCursor | if true, sets the cursor too, otherwise the shape-controlled channels are not set |
Definition at line 82 of file KisVisualColorSelectorShape.cpp.
References m_d, and twodimensional.
| void KisVisualColorSelectorShape::setCursorPosition | ( | QPointF | position, |
| bool | signal = false ) |
setCursorPosition Set the cursor to normalized shape coordinates. This will only repaint the cursor.
| position | normalized shape coordinates ([0,1] range, not yet transformed to actual channel values!) |
| signal | if true, Q_EMIT a sigCursorMoved signal |
Definition at line 64 of file KisVisualColorSelectorShape.cpp.
References m_d, sigCursorMoved(), and twodimensional.
|
signal |
|
virtual |
Reimplemented in KisVisualEllipticalSelectorShape.
Definition at line 114 of file KisVisualColorSelectorShape.cpp.
|
overrideprotected |
Definition at line 324 of file KisVisualColorSelectorShape.cpp.
References m_d, mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
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.
|
private |
Definition at line 185 of file KisVisualColorSelectorShape.h.