Krita Source Code Documentation
Loading...
Searching...
No Matches
KisStrokeSelectionActionFactory Struct Reference

#include <kis_selection_action_factories.h>

+ Inheritance diagram for KisStrokeSelectionActionFactory:

Public Member Functions

 KisStrokeSelectionActionFactory ()
 
void run (KisViewManager *view, const StrokeSelectionOptions &params)
 
- Public Member Functions inherited from KisOperation
QString id () const
 
 KisOperation (const QString &id)
 
virtual void runFromXML (KisViewManager *view, const KisOperationConfiguration &config)
 
virtual ~KisOperation ()
 

Additional Inherited Members

- Protected Member Functions inherited from KisOperation
KisProcessingApplicatorbeginAction (KisViewManager *view, const KUndo2MagicString &actionName)
 
void endAction (KisProcessingApplicator *applicator, const QString &xmlData)
 

Detailed Description

Definition at line 108 of file kis_selection_action_factories.h.

Constructor & Destructor Documentation

◆ KisStrokeSelectionActionFactory()

KisStrokeSelectionActionFactory::KisStrokeSelectionActionFactory ( )
inline

Definition at line 109 of file kis_selection_action_factories.h.

109: KisOperation("selection-to-shape-action") {}
KisOperation(const QString &id)

Member Function Documentation

◆ run()

void KisStrokeSelectionActionFactory::run ( KisViewManager * view,
const StrokeSelectionOptions & params )

Definition at line 607 of file kis_selection_action_factories.cpp.

608{
609 KisImageWSP image = view->image();
610 if (!image) {
611 return;
612 }
613
614 KisSelectionSP selection = view->selection();
615 if (!selection) {
616 return;
617 }
618
619 int size = params.lineSize;
620
621 KisPixelSelectionSP pixelSelection = selection->projection();
622 if (!pixelSelection->outlineCacheValid()) {
623 pixelSelection->recalculateOutlineCache();
624 }
625
626 QPainterPath outline = pixelSelection->outlineCache();
627 QColor color = params.color.toQColor();
628
630 if (!currentNode->inherits("KisShapeLayer") && currentNode->paintDevice()) {
633 KisToolShapeUtils::FillStyle fillStyle = params.fillStyle();
634
635 KisFigurePaintingToolHelper helper(kundo2_i18n("Draw Polyline"),
636 image,
637 currentNode,
638 rManager ,
639 strokeStyle,
640 fillStyle);
641 helper.setFGColorOverride(params.color);
642 helper.setSelectionOverride(0);
643 QPen pen(Qt::red, size);
644 pen.setJoinStyle(Qt::RoundJoin);
645
646 if (fillStyle != KisToolShapeUtils::FillStyleNone) {
647 helper.paintPainterPathQPenFill(outline, pen, params.fillColor);
648 }
649 else {
650 helper.paintPainterPathQPen(outline, pen, params.fillColor);
651 }
652 }
653 else if (currentNode->inherits("KisShapeLayer")) {
654
655 QTransform transform = view->canvasBase()->coordinatesConverter()->imageToDocumentTransform();
656
657 KoShape *shape = KoPathShape::createShapeFromPainterPath(transform.map(outline));
659
660 KoShapeStrokeSP border(new KoShapeStroke(size, color));
661 shape->setStroke(border);
662
663 KUndo2Command *cmd = view->canvasBase()->shapeController()->addShapeDirect(shape, 0);
665 }
666}
#define KoPathShapeId
Definition KoPathShape.h:20
KisCoordinatesConverter * coordinatesConverter
KoCanvasResourceProvider * resourceManager()
static void runSingleCommandStroke(KisImageSP image, KUndo2Command *cmd, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
runSingleCommandStroke creates a stroke and runs cmd in it. The text() field of cmd is used as a titl...
KisCanvas2 * canvasBase() const
Return the canvas base class.
KisSelectionSP selection()
KisImageWSP image() const
Return the image this view is displaying.
KisCanvasResourceProvider * canvasResourceProvider()
QPointer< KoShapeController > shapeController
void toQColor(QColor *c) const
a convenience method for the above.
Definition KoColor.cpp:198
static KoPathShape * createShapeFromPainterPath(const QPainterPath &path)
Creates path shape from given QPainterPath.
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:1081
void setShapeId(const QString &id)
Definition KoShape.cpp:1062
KUndo2MagicString kundo2_i18n(const char *text)
int size(const Forest< T > &forest)
Definition KisForest.h:1232
virtual KisPaintDeviceSP paintDevice() const =0
void recalculateOutlineCache() override
KisPixelSelectionSP projection() const
KisToolShapeUtils::FillStyle fillStyle() const

References KisViewManager::canvasBase(), KisViewManager::canvasResourceProvider(), StrokeSelectionOptions::color, KisCanvas2::coordinatesConverter, KoPathShape::createShapeFromPainterPath(), KoCanvasResource::CurrentKritaNode, StrokeSelectionOptions::fillColor, StrokeSelectionOptions::fillStyle(), KisToolShapeUtils::FillStyleNone, KisViewManager::image(), KisCoordinatesConverter::imageToDocumentTransform(), KoPathShapeId, kundo2_i18n(), StrokeSelectionOptions::lineSize, KisPixelSelection::outlineCache, KisPixelSelection::outlineCacheValid, KisBaseNode::paintDevice(), KisFigurePaintingToolHelper::paintPainterPathQPen(), KisFigurePaintingToolHelper::paintPainterPathQPenFill(), KisSelection::projection(), KisPixelSelection::recalculateOutlineCache(), KoCanvasResourceProvider::resource(), KisCanvasResourceProvider::resourceManager(), KisProcessingApplicator::runSingleCommandStroke(), KisViewManager::selection(), KisFigurePaintingToolHelper::setFGColorOverride(), KisFigurePaintingToolHelper::setSelectionOverride(), KoShape::setShapeId(), KoShape::setStroke(), KoCanvasBase::shapeController, KisToolShapeUtils::StrokeStyleForeground, and KoColor::toQColor().


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