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

#include <KoShapeController.h>

+ Inheritance diagram for KoShapeController:

Classes

class  Private
 

Public Member Functions

KUndo2CommandaddShape (KoShape *shape, KoShapeContainer *parentShape, KUndo2Command *parent=0)
 Add a shape to the document. If the shape has no parent, the active layer will become its parent.
 
KUndo2CommandaddShapeDirect (KoShape *shape, KoShapeContainer *parentShape, KUndo2Command *parent=0)
 Add a shape to the document, skipping any dialogs or other user interaction.
 
KUndo2CommandaddShapesDirect (const QList< KoShape * > shape, KoShapeContainer *parentShape, KUndo2Command *parent=0)
 Add shapes to the document, skipping any dialogs or other user interaction.
 
KoShapeControllerBasedocumentBase () const
 Returns the KoShapeControllerBase used to add/remove shapes.
 
QRectF documentRect () const
 
QRectF documentRectInPixels () const
 
 KoShapeController (KoCanvasBase *canvas, KoShapeControllerBase *shapeController)
 
qreal pixelsPerInch () const
 
KUndo2CommandremoveShape (KoShape *shape, KUndo2Command *parent=0)
 Remove a shape from the document.
 
KUndo2CommandremoveShapes (const QList< KoShape * > &shapes, KUndo2Command *parent=0)
 
void reset ()
 reset sets the canvas and shapebased document to 0.
 
KoDocumentResourceManagerresourceManager () const
 
void setShapeControllerBase (KoShapeControllerBase *shapeController)
 Set the KoShapeControllerBase used to add/remove shapes.
 
 ~KoShapeController () override
 destructor
 

Private Attributes

Private *const d
 

Detailed Description

Class used by tools to maintain the list of shapes. All applications have some sort of list of all shapes that belong to the document. The applications implement the KoShapeControllerBase interface (all pure virtuals) to add and remove shapes from the document. To ensure that an application can expect a certain protocol to be adhered to when adding/removing shapes, all tools use the API from this class for maintaining the list of shapes in the document. So no tool gets to access the application directly.

Definition at line 34 of file KoShapeController.h.

Constructor & Destructor Documentation

◆ KoShapeController()

KoShapeController::KoShapeController ( KoCanvasBase * canvas,
KoShapeControllerBase * shapeController )

Create a new Controller; typically not called by applications, only by the KonCanvasBase constructor.

Parameters
canvasthe canvas this controller works for. The canvas can be 0
shapeControllerthe application provided shapeController that we can call.

Definition at line 107 of file KoShapeController.cpp.

108 : d(new Private())
109{
110 d->canvas = canvas;
111 d->shapeController = shapeController;
112}
KoShapeControllerBase * shapeController

References KoShapeController::Private::canvas, d, and KoShapeController::Private::shapeController.

◆ ~KoShapeController()

KoShapeController::~KoShapeController ( )
override

destructor

Definition at line 114 of file KoShapeController.cpp.

115{
116 delete d;
117}

References d.

Member Function Documentation

◆ addShape()

KUndo2Command * KoShapeController::addShape ( KoShape * shape,
KoShapeContainer * parentShape,
KUndo2Command * parent = 0 )

Add a shape to the document. If the shape has no parent, the active layer will become its parent.

Parameters
shapeto add to the document
parentShapethe parent shape
parentthe parent command if the resulting command is a compound undo command.
Returns
command which will insert the shape into the document or 0 if the insertion was cancelled. The command is not yet executed.

Definition at line 125 of file KoShapeController.cpp.

126{
127 return d->addShape(shape, true, parentShape, parent);
128}
KUndo2Command * addShape(KoShape *shape, bool showDialog, KoShapeContainer *parentShape, KUndo2Command *parent)

References KoShapeController::Private::addShape(), and d.

◆ addShapeDirect()

KUndo2Command * KoShapeController::addShapeDirect ( KoShape * shape,
KoShapeContainer * parentShape,
KUndo2Command * parent = 0 )

Add a shape to the document, skipping any dialogs or other user interaction.

Parameters
shapeto add to the document
parentShapethe parent shape
parentthe parent command if the resulting command is a compound undo command.
Returns
command which will insert the shape into the document. The command is not yet executed.

Definition at line 130 of file KoShapeController.cpp.

131{
132 return d->addShapesDirect({shape}, parentShape, parent);
133}
KUndo2Command * addShapesDirect(const QList< KoShape * > shapes, KoShapeContainer *parentShape, KUndo2Command *parent)
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References KoShapeController::Private::addShapesDirect(), and d.

◆ addShapesDirect()

KUndo2Command * KoShapeController::addShapesDirect ( const QList< KoShape * > shape,
KoShapeContainer * parentShape,
KUndo2Command * parent = 0 )

Add shapes to the document, skipping any dialogs or other user interaction.

Parameters
shapethe shape to add to the document
parentShapethe parent shape
parentthe parent command if the resulting command is a compound undo command.
Returns
command which will insert the shapes into the document. The command is not yet executed.

Definition at line 135 of file KoShapeController.cpp.

136{
137 return d->addShapesDirect(shapes, parentShape, parent);
138}

References KoShapeController::Private::addShapesDirect(), and d.

◆ documentBase()

KoShapeControllerBase * KoShapeController::documentBase ( ) const

Returns the KoShapeControllerBase used to add/remove shapes.

Returns
the KoShapeControllerBase

Definition at line 180 of file KoShapeController.cpp.

181{
182 return d->shapeController;
183}

References d, and KoShapeController::Private::shapeController.

◆ documentRect()

QRectF KoShapeController::documentRect ( ) const

◆ documentRectInPixels()

QRectF KoShapeController::documentRectInPixels ( ) const

The size of the document measured in rasterized pixels. This information is needed for loading SVG documents that use 'px' as the default unit.

Definition at line 156 of file KoShapeController.cpp.

157{
158 return d->shapeController ? d->shapeController->documentRectInPixels() : QRectF(0,0,1920,1080);
159}
virtual QRectF documentRectInPixels() const =0

References d, KoShapeControllerBase::documentRectInPixels(), and KoShapeController::Private::shapeController.

◆ pixelsPerInch()

qreal KoShapeController::pixelsPerInch ( ) const

Resolution of the rasterized representation of the document. Used to load SVG documents correctly.

Definition at line 161 of file KoShapeController.cpp.

162{
163 return d->shapeController ? d->shapeController->pixelsPerInch() : 72.0;
164}
virtual qreal pixelsPerInch() const =0

References d, KoShapeControllerBase::pixelsPerInch(), and KoShapeController::Private::shapeController.

◆ removeShape()

KUndo2Command * KoShapeController::removeShape ( KoShape * shape,
KUndo2Command * parent = 0 )

Remove a shape from the document.

Parameters
shapeto remove from the document
parentthe parent command if the resulting command is a compound undo command.
Returns
command which will remove the shape from the document. The command is not yet executed.

Definition at line 140 of file KoShapeController.cpp.

141{
142 return removeShapes({shape}, parent);
143}
KUndo2Command * removeShapes(const QList< KoShape * > &shapes, KUndo2Command *parent=0)

References removeShapes().

◆ removeShapes()

KUndo2Command * KoShapeController::removeShapes ( const QList< KoShape * > & shapes,
KUndo2Command * parent = 0 )

Remove a shape from the document.

Parameters
shapesthe set of shapes to remove from the document
parentthe parent command if the resulting command is a compound undo command.
Returns
command which will remove the shape from the document. The command is not yet executed.

Definition at line 145 of file KoShapeController.cpp.

146{
147 KUndo2Command *cmd = new KoShapeDeleteCommand(d->shapeController, shapes, parent);
148 return cmd;
149}
The undo / redo command for deleting shapes.

References d, and KoShapeController::Private::shapeController.

◆ reset()

void KoShapeController::reset ( )

reset sets the canvas and shapebased document to 0.

Definition at line 119 of file KoShapeController.cpp.

120{
121 d->canvas = 0;
122 d->shapeController = 0;
123}

References KoShapeController::Private::canvas, d, and KoShapeController::Private::shapeController.

◆ resourceManager()

KoDocumentResourceManager * KoShapeController::resourceManager ( ) const

Return a pointer to the resource manager associated with the shape-set (typically a document). The resource manager contains document wide resources * such as variable managers, the image collection and others.

Definition at line 171 of file KoShapeController.cpp.

172{
173 if (!d->shapeController) {
174 qWarning() << "THIS IS NOT GOOD!";
175 return 0;
176 }
178}
virtual KoDocumentResourceManager * resourceManager() const

References d, KoShapeControllerBase::resourceManager(), and KoShapeController::Private::shapeController.

◆ setShapeControllerBase()

void KoShapeController::setShapeControllerBase ( KoShapeControllerBase * shapeController)

Set the KoShapeControllerBase used to add/remove shapes.

NOTE: only Sheets uses this method. Do not use it in your application. Sheets has to also call: KoToolManager::instance()->updateShapeControllerBase(shapeController, canvas->canvasController());

Parameters
shapeControllerthe new shapeController.

Definition at line 151 of file KoShapeController.cpp.

152{
153 d->shapeController = shapeController;
154}

References d, and KoShapeController::Private::shapeController.

Member Data Documentation

◆ d

Private* const KoShapeController::d
private

Definition at line 155 of file KoShapeController.h.


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