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

#include <kis_selection_filters.h>

+ Inheritance diagram for KisInvertSelectionFilter:

Public Member Functions

QRect changeRect (const QRect &rect, KisDefaultBoundsBaseSP defaultBounds) override
 
KUndo2MagicString name () override
 
void process (KisPixelSelectionSP pixelSelection, const QRect &rect) override
 
- Public Member Functions inherited from KisSelectionFilter
virtual ~KisSelectionFilter ()
 

Additional Inherited Members

- Protected Member Functions inherited from KisSelectionFilter
void computeBorder (qint32 *circ, qint32 xradius, qint32 yradius)
 
void computeTransition (quint8 *transition, quint8 **buf, qint32 width)
 
void rotatePointers (quint8 **p, quint32 n)
 

Detailed Description

Definition at line 134 of file kis_selection_filters.h.

Member Function Documentation

◆ changeRect()

QRect KisInvertSelectionFilter::changeRect ( const QRect & rect,
KisDefaultBoundsBaseSP defaultBounds )
overridevirtual

Reimplemented from KisSelectionFilter.

Definition at line 888 of file kis_selection_filters.cpp.

889{
890 Q_UNUSED(rect);
891 return defaultBounds->bounds();
892}
virtual QRect bounds() const =0

References KisDefaultBoundsBase::bounds().

◆ name()

KUndo2MagicString KisInvertSelectionFilter::name ( )
overridevirtual

Reimplemented from KisSelectionFilter.

Definition at line 883 of file kis_selection_filters.cpp.

884{
885 return kundo2_i18n("Invert Selection");
886}
KUndo2MagicString kundo2_i18n(const char *text)

References kundo2_i18n().

◆ process()

void KisInvertSelectionFilter::process ( KisPixelSelectionSP pixelSelection,
const QRect & rect )
overridevirtual

A special treatment for the user-visible selection inversion:

If the selection is fully contained inside the image, then just invert it pixel-by-pixel without changing the default pixel. It makes it selectedExactRect() work a little bit more expected for the user (see bug 457820).

If the selection spreads outside the image bounds, then just invert it in a mathematical way adjusting the default pixel.

Implements KisSelectionFilter.

Definition at line 894 of file kis_selection_filters.cpp.

895{
896 Q_UNUSED(rect);
897
898 const QRect imageRect = pixelSelection->defaultBounds()->bounds();
899 const QRect selectionRect = pixelSelection->selectedExactRect();
900
914 if (!imageRect.contains(selectionRect)) {
915 pixelSelection->invert();
916 } else {
917 KisSequentialIterator it(pixelSelection, imageRect);
918 while(it.nextPixel()) {
919 *(it.rawData()) = MAX_SELECTED - *(it.rawData());
920 }
921 pixelSelection->crop(imageRect);
922 pixelSelection->invalidateOutlineCache();
923 }
924}
void crop(qint32 x, qint32 y, qint32 w, qint32 h)
KisDefaultBoundsBaseSP defaultBounds() const
const quint8 MAX_SELECTED
Definition kis_global.h:32
QRect selectedExactRect() const

References KisDefaultBoundsBase::bounds(), KisPaintDevice::crop(), KisPaintDevice::defaultBounds(), KisPixelSelection::invalidateOutlineCache(), KisPixelSelection::invert(), MAX_SELECTED, KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::nextPixel(), KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::rawData(), and KisPixelSelection::selectedExactRect().


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