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

#include <KisPathEnclosingProducer.h>

+ Inheritance diagram for KisPathEnclosingProducer:

Signals

void enclosingMaskProduced (KisPixelSelectionSP enclosingMask)
 

Public Member Functions

void beginAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void beginPrimaryAction (KoPointerEvent *event) override
 
void beginPrimaryDoubleClickAction (KoPointerEvent *event) override
 
void continuePrimaryAction (KoPointerEvent *event) override
 
void endPrimaryAction (KoPointerEvent *event) override
 
bool eventFilter (QObject *obj, QEvent *event) override
 
bool hasUserInteractionRunning () const
 
 KisPathEnclosingProducer (KoCanvasBase *canvas)
 
void mousePressEvent (KoPointerEvent *event) override
 
KisPopupWidgetInterfacepopupWidget () override
 
 ~KisPathEnclosingProducer () override
 
- Public Member Functions inherited from KisDynamicDelegateTool< DelegatedPathTool >
 KisDynamicDelegateTool ()=delete
 
 KisDynamicDelegateTool (Args ... args)
 
 KisDynamicDelegateTool (const KisDynamicDelegateTool &)=delete
 
KisDynamicDelegateTooloperator= (const KisDynamicDelegateTool &)=delete
 
 ~KisDynamicDelegateTool () override
 
- Public Member Functions inherited from KisDelegatedTool< BaseClass, DelegateTool, ActivationPolicy >
void activate (const QSet< KoShape * > &shapes) override
 
QList< QPointer< QWidget > > createOptionWidgets () override
 
void deactivate () override
 
 KisDelegatedTool (KoCanvasBase *canvas, const QCursor &cursor, DelegateTool *delegateTool)
 
DelegateTool * localTool () const
 
void mouseDoubleClickEvent (KoPointerEvent *event) override
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 

Protected Slots

void resetCursorStyle () override
 

Protected Member Functions

void addPathShape (KoPathShape *pathShape)
 
void beginShape () override
 
void endShape () override
 
void requestStrokeCancellation () override
 
void requestStrokeEnd () override
 

Private Attributes

bool m_hasUserInteractionRunning {false}
 

Friends

class KisToolPathLocalTool
 

Additional Inherited Members

- Protected Attributes inherited from KisDelegatedTool< BaseClass, DelegateTool, ActivationPolicy >
QScopedPointer< DelegateTool > m_localTool
 

Detailed Description

Definition at line 42 of file KisPathEnclosingProducer.h.

Constructor & Destructor Documentation

◆ KisPathEnclosingProducer()

KisPathEnclosingProducer::KisPathEnclosingProducer ( KoCanvasBase * canvas)

Definition at line 48 of file KisPathEnclosingProducer.cpp.

50 KisCursor::load("tool_polygonal_selection_cursor.png", 6, 6),
51 new KisToolPathLocalTool(canvas, this))
52{
53 setObjectName("enclosing_tool_path");
54 setSupportOutline(true);
55 setOutlineEnabled(false);
56
57 KisCanvas2 *kritaCanvas = dynamic_cast<KisCanvas2*>(canvas);
58
59 connect(kritaCanvas->viewManager()->canvasResourceProvider(), SIGNAL(sigEffectiveCompositeOpChanged()), SLOT(resetCursorStyle()));
60}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisViewManager * viewManager() const
static QCursor load(const QString &cursorName, int hotspotX=-1, int hotspotY=-1)
KisCanvasResourceProvider * canvasResourceProvider()

References KisViewManager::canvasResourceProvider(), connect(), resetCursorStyle(), and KisCanvas2::viewManager().

◆ ~KisPathEnclosingProducer()

KisPathEnclosingProducer::~KisPathEnclosingProducer ( )
override

Definition at line 62 of file KisPathEnclosingProducer.cpp.

63{}

Member Function Documentation

◆ addPathShape()

void KisPathEnclosingProducer::addPathShape ( KoPathShape * pathShape)
protected

Definition at line 158 of file KisPathEnclosingProducer.cpp.

159{
160 KisCanvas2 * kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
161 if (!kisCanvas) {
162 return;
163 }
164
165 KisImageWSP image = kisCanvas->image();
166 KisPixelSelectionSP enclosingMask = new KisPixelSelection();
167
168 pathShape->normalize();
169 pathShape->close();
170
171 KisPainter painter(enclosingMask);
172 painter.setPaintColor(KoColor(Qt::white, enclosingMask->colorSpace()));
173 painter.setAntiAliasPolygonFill(false);
174 painter.setFillStyle(KisPainter::FillStyleForegroundColor);
175 painter.setStrokeStyle(KisPainter::StrokeStyleNone);
176
177 QTransform matrix;
178 matrix.scale(image->xRes(), image->yRes());
179 matrix.translate(pathShape->position().x(), pathShape->position().y());
180
181 QPainterPath path = matrix.map(pathShape->outline());
182 painter.fillPainterPath(path);
183 enclosingMask->setOutlineCache(path);
184
185 delete pathShape;
186
187 Q_EMIT enclosingMaskProduced(enclosingMask);
188}
KisImageWSP image() const
double xRes() const
double yRes() const
const KoColorSpace * colorSpace() const
@ FillStyleForegroundColor
void enclosingMaskProduced(KisPixelSelectionSP enclosingMask)
virtual QPointF normalize()
Normalizes the path data.
void close()
Closes the current subpath.
QPainterPath outline() const override
reimplemented
QPointF position() const
Get the position of the shape in pt.
Definition KoShape.cpp:825
void setOutlineCache(const QPainterPath &cache)

References KoPathShape::close(), KisPaintDevice::colorSpace(), enclosingMaskProduced(), KisPainter::fillPainterPath(), KisPainter::FillStyleForegroundColor, KisCanvas2::image(), KoPathShape::normalize(), KoPathShape::outline(), KoShape::position(), KisPainter::setAntiAliasPolygonFill(), KisPainter::setFillStyle(), KisPixelSelection::setOutlineCache(), KisPainter::setPaintColor(), KisPainter::setStrokeStyle(), KisPainter::StrokeStyleNone, KisImage::xRes(), and KisImage::yRes().

◆ beginAlternateAction()

void KisPathEnclosingProducer::beginAlternateAction ( KoPointerEvent * event,
AlternateAction action )
override

Definition at line 124 of file KisPathEnclosingProducer.cpp.

124 {
125 KisDynamicDelegateTool::beginAlternateAction(event, action);
126 if (!nodeEditable()) return;
127
128 if (nodePaintAbility() == KisDynamicDelegateTool::MYPAINTBRUSH_UNPAINTABLE) {
129 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
130 QString message = i18n("The MyPaint Brush Engine is not available for this colorspace");
131 kiscanvas->viewManager()->showFloatingMessage(message, koIcon("object-locked"));
132 event->ignore();
133 return;
134 }
135}
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
#define koIcon(name)
Use these macros for icons without any issues.
Definition kis_icon.h:25

References koIcon, KisViewManager::showFloatingMessage(), and KisCanvas2::viewManager().

◆ beginPrimaryAction()

void KisPathEnclosingProducer::beginPrimaryAction ( KoPointerEvent * event)
override

Definition at line 137 of file KisPathEnclosingProducer.cpp.

138{
139 if (!nodeEditable()) return;
140 KisDynamicDelegateTool::mousePressEvent(event);
141}

◆ beginPrimaryDoubleClickAction()

void KisPathEnclosingProducer::beginPrimaryDoubleClickAction ( KoPointerEvent * event)
override

Definition at line 153 of file KisPathEnclosingProducer.cpp.

154{
155 KisDynamicDelegateTool::mouseDoubleClickEvent(event);
156}

◆ beginShape()

void KisPathEnclosingProducer::beginShape ( )
overrideprotected

◆ continuePrimaryAction()

void KisPathEnclosingProducer::continuePrimaryAction ( KoPointerEvent * event)
override

Definition at line 143 of file KisPathEnclosingProducer.cpp.

144{
145 mouseMoveEvent(event);
146}
void mouseMoveEvent(KoPointerEvent *event) override

References KisDelegatedTool< BaseClass, DelegateTool, ActivationPolicy >::mouseMoveEvent().

◆ enclosingMaskProduced

void KisPathEnclosingProducer::enclosingMaskProduced ( KisPixelSelectionSP enclosingMask)
signal

◆ endPrimaryAction()

void KisPathEnclosingProducer::endPrimaryAction ( KoPointerEvent * event)
override

Definition at line 148 of file KisPathEnclosingProducer.cpp.

149{
150 mouseReleaseEvent(event);
151}
void mouseReleaseEvent(KoPointerEvent *event) override

References KisDelegatedTool< BaseClass, DelegateTool, ActivationPolicy >::mouseReleaseEvent().

◆ endShape()

void KisPathEnclosingProducer::endShape ( )
overrideprotected

Definition at line 200 of file KisPathEnclosingProducer.cpp.

201{
203}

References m_hasUserInteractionRunning.

◆ eventFilter()

bool KisPathEnclosingProducer::eventFilter ( QObject * obj,
QEvent * event )
override

Definition at line 101 of file KisPathEnclosingProducer.cpp.

102{
103 Q_UNUSED(obj);
105 return false;
106 }
107 if (event->type() == QEvent::MouseButtonPress ||
108 event->type() == QEvent::MouseButtonDblClick) {
109 QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
110 if (mouseEvent->button() == Qt::RightButton) {
111 localTool()->removeLastPoint();
112 return true;
113 }
114 } else if (event->type() == QEvent::TabletPress) {
115 QTabletEvent *tabletEvent = static_cast<QTabletEvent*>(event);
116 if (tabletEvent->button() == Qt::RightButton) {
117 localTool()->removeLastPoint();
118 return true;
119 }
120 }
121 return false;
122}
DelegateTool * localTool() const

References KisDelegatedTool< BaseClass, DelegateTool, ActivationPolicy >::localTool(), and m_hasUserInteractionRunning.

◆ hasUserInteractionRunning()

bool KisPathEnclosingProducer::hasUserInteractionRunning ( ) const

Definition at line 190 of file KisPathEnclosingProducer.cpp.

191{
193}

References m_hasUserInteractionRunning.

◆ mousePressEvent()

void KisPathEnclosingProducer::mousePressEvent ( KoPointerEvent * event)
override

Definition at line 93 of file KisPathEnclosingProducer.cpp.

94{
95 Q_UNUSED(event)
96}

◆ popupWidget()

KisPopupWidgetInterface * KisPathEnclosingProducer::popupWidget ( )
override

Definition at line 88 of file KisPathEnclosingProducer.cpp.

89{
90 return m_hasUserInteractionRunning ? nullptr : KisDynamicDelegateTool::popupWidget();
91}

References m_hasUserInteractionRunning.

◆ requestStrokeCancellation()

void KisPathEnclosingProducer::requestStrokeCancellation ( )
overrideprotected

Definition at line 82 of file KisPathEnclosingProducer.cpp.

83{
84 KisDynamicDelegateTool::requestStrokeCancellation();
85 localTool()->cancelPath();
86}

References KisDelegatedTool< BaseClass, DelegateTool, ActivationPolicy >::localTool().

◆ requestStrokeEnd()

void KisPathEnclosingProducer::requestStrokeEnd ( )
overrideprotected

Definition at line 76 of file KisPathEnclosingProducer.cpp.

77{
78 KisDynamicDelegateTool::requestStrokeEnd();
79 localTool()->endPathWithoutLastPoint();
80}

References KisDelegatedTool< BaseClass, DelegateTool, ActivationPolicy >::localTool().

◆ resetCursorStyle

void KisPathEnclosingProducer::resetCursorStyle ( )
overrideprotectedslot

Definition at line 65 of file KisPathEnclosingProducer.cpp.

66{
67 if (isEraser()) {
68 useCursor(KisCursor::load("tool_polygonal_selection_enclose_eraser_cursor.png", 6, 6));
69 } else {
70 KisDynamicDelegateTool::resetCursorStyle();
71 }
72
73 overrideCursorIfNotEditable();
74}

References KisCursor::load().

Friends And Related Symbol Documentation

◆ KisToolPathLocalTool

friend class KisToolPathLocalTool
friend

Definition at line 72 of file KisPathEnclosingProducer.h.

Member Data Documentation

◆ m_hasUserInteractionRunning

bool KisPathEnclosingProducer::m_hasUserInteractionRunning {false}
private

Definition at line 78 of file KisPathEnclosingProducer.h.

78{false};

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