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

#include <kis_selection_action_factories.h>

+ Inheritance diagram for KisSelectionToShapeActionFactory:

Public Member Functions

 KisSelectionToShapeActionFactory ()
 
void run (KisViewManager *view) override
 
- Public Member Functions inherited from KisNoParameterActionFactory
 KisNoParameterActionFactory (const QString &id)
 
void runFromXML (KisViewManager *view, const KisOperationConfiguration &config) override
 
- Public Member Functions inherited from KisOperation
QString id () const
 
 KisOperation (const QString &id)
 
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 103 of file kis_selection_action_factories.h.

Constructor & Destructor Documentation

◆ KisSelectionToShapeActionFactory()

KisSelectionToShapeActionFactory::KisSelectionToShapeActionFactory ( )
inline

Definition at line 104 of file kis_selection_action_factories.h.

104: KisNoParameterActionFactory("selection-to-shape-action") {}

Member Function Documentation

◆ run()

void KisSelectionToShapeActionFactory::run ( KisViewManager * view)
overridevirtual

Implements KisNoParameterActionFactory.

Definition at line 586 of file kis_selection_action_factories.cpp.

587{
588 KisSelectionSP selection = view->selection();
589 if (!selection->outlineCacheValid()) {
590 return;
591 }
592
593 QPainterPath selectionOutline = selection->outlineCache();
594 QTransform transform = view->canvasBase()->coordinatesConverter()->imageToDocumentTransform();
595
596 KoShape *shape = KoPathShape::createShapeFromPainterPath(transform.map(selectionOutline));
598
599 KoColor fgColor = view->canvasBase()->resourceManager()->resource(KoCanvasResource::ForegroundColor).value<KoColor>();
600 KoShapeStrokeSP border(new KoShapeStroke(1.0, fgColor.toQColor()));
601 shape->setStroke(border);
602
603 KUndo2Command *cmd = view->canvasBase()->shapeController()->addShapeDirect(shape, 0);
605}
#define KoPathShapeId
Definition KoPathShape.h:20
KisCoordinatesConverter * coordinatesConverter
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.
QPointer< KoShapeController > shapeController
QPointer< KoCanvasResourceProvider > resourceManager
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
@ ForegroundColor
The active foreground color selected for this canvas.
bool outlineCacheValid() const
QPainterPath outlineCache() const

References KisViewManager::canvasBase(), KisCanvas2::coordinatesConverter, KoPathShape::createShapeFromPainterPath(), KoCanvasResource::ForegroundColor, KisViewManager::image(), KisCoordinatesConverter::imageToDocumentTransform(), KoPathShapeId, KisSelection::outlineCache(), KisSelection::outlineCacheValid(), KoCanvasBase::resourceManager, KisProcessingApplicator::runSingleCommandStroke(), KisViewManager::selection(), KoShape::setShapeId(), KoShape::setStroke(), KoCanvasBase::shapeController, and KoColor::toQColor().


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