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

- Public Types inherited from KisOperation
enum  Flag { Normal = 0x0 , ReadOnly = 0x1 }
 
- Protected Member Functions inherited from KisOperation
KisProcessingApplicator * beginAction (KisViewManager *view, const KUndo2MagicString &actionName, Flags flags=Normal)
 
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 527 of file kis_selection_action_factories.cpp.

528{
529 KisImageWSP image = view->image();
530 if (!image) {
531 return;
532 }
533
534 KisSelectionSP selection = view->selection();
535 if (!selection) {
536 return;
537 }
538
539 int size = params.lineSize;
540
541 KisPixelSelectionSP pixelSelection = selection->projection();
542 if (!pixelSelection->outlineCacheValid()) {
543 pixelSelection->recalculateOutlineCache();
544 }
545
546 QPainterPath outline = pixelSelection->outlineCache();
547 QColor color = params.color.toQColor();
548
550 if (!currentNode->inherits("KisShapeLayer") && currentNode->paintDevice()) {
553 KisToolShapeUtils::FillStyle fillStyle = params.fillStyle();
554
555 KisFigurePaintingToolHelper helper(kundo2_i18n("Draw Polyline"),
556 image,
557 currentNode,
558 rManager ,
559 strokeStyle,
560 fillStyle);
561 helper.setFGColorOverride(params.color);
562 helper.setSelectionOverride(0);
563 QPen pen(Qt::red, size);
564 pen.setJoinStyle(Qt::RoundJoin);
565
566 if (fillStyle != KisToolShapeUtils::FillStyleNone) {
567 helper.paintPainterPathQPenFill(outline, pen, params.fillColor);
568 }
569 else {
570 helper.paintPainterPathQPen(outline, pen, params.fillColor);
571 }
572 }
573 else if (currentNode->inherits("KisShapeLayer")) {
574
575 QTransform transform = view->canvasBase()->coordinatesConverter()->imageToDocumentTransform();
576
577 KoShape *shape = KoPathShape::createShapeFromPainterPath(transform.map(outline));
579
580 KoShapeStrokeSP border(new KoShapeStroke(size, color));
581 shape->setStroke(border);
582
583 KUndo2Command *cmd = view->canvasBase()->shapeController()->addShapeDirect(shape, 0);
585 }
586}
#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:899
void setShapeId(const QString &id)
Definition KoShape.cpp:880
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: