Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCanvasBase Class Referenceabstract

#include <KoCanvasBase.h>

+ Inheritance diagram for KoCanvasBase:

Public Member Functions

virtual void addCommand (KUndo2Command *command)=0
 
KoCanvasControllercanvasController () const
 
virtual bool canvasIsOpenGL () const
 
virtual const QWidget * canvasWidget () const =0
 
virtual QWidget * canvasWidget ()=0
 
virtual void clipToDocument (const KoShape *shape, QPointF &move) const
 
virtual void disconnectCanvasObserver (QObject *object)
 
virtual QPoint documentOrigin () const
 
virtual void gridSize (QPointF *offset, QSizeF *spacing) const =0
 
 KoCanvasBase (KoShapeControllerBase *shapeController, KoCanvasResourceProvider *sharedResourceManager=0)
 
 Private ()
 
KoCanvasResourceProviderresourceManager () const
 
virtual KoSelectedShapesProxyselectedShapesProxy () const =0
 selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged() and selectionContentChanged() signals. While shapeManager() can change throughout the life time of the canvas, selectedShapesProxy() is guaranteed to stay the same.
 
void setCanvasController (KoCanvasController *controller)
 called by KoCanvasController to set the controller that handles this canvas.
 
virtual void setCursor (const QCursor &cursor)=0
 
KoShapeControllershapeController () const
 
virtual KoShapeManagershapeManager () const =0
 
KoSnapGuidesnapGuide () const
 
virtual bool snapToGrid () const =0
 
virtual KoToolProxytoolProxy () const =0
 
virtual KoUnit unit () const =0
 
virtual void updateCanvas (const QRectF &rc)=0
 
virtual const KoViewConverterviewConverter () const =0
 
virtual KoViewConverterviewConverter ()=0
 
virtual QPointF viewToDocument (const QPointF &viewPoint) const
 
 ~KoCanvasBase () override
 
 ~Private ()
 

Public Attributes

KoCanvasControllercontroller
 
bool isResourceManagerShared
 
QPointer< KoCanvasResourceProviderresourceManager
 
QPointer< KoShapeControllershapeController
 
KoSnapGuidesnapGuide
 

Private Member Functions

 KoCanvasBase ()
 
- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Detailed Description

KoCanvasBase is the interface actual application canvas classes should implement. Flake tools know about the canvas, so they can do things like scroll, redraw, set a cursor etc.

Definition at line 23 of file KoCanvasBase.cpp.

Constructor & Destructor Documentation

◆ ~Private()

KoCanvasBase::~Private ( )
inline

Definition at line 35 of file KoCanvasBase.cpp.

35 {
36 delete shapeController;
38 delete resourceManager;
39 }
40 delete snapGuide;
41 }
KoSnapGuide * snapGuide
QPointer< KoShapeController > shapeController
bool isResourceManagerShared
QPointer< KoCanvasResourceProvider > resourceManager

◆ KoCanvasBase() [1/2]

KoCanvasBase::KoCanvasBase ( KoShapeControllerBase * shapeController,
KoCanvasResourceProvider * sharedResourceManager = 0 )
explicit

The constructor.

Parameters
shapeControllerthe implementation of the shapeController that the application provides to allow shapes to be added in multiple views.

Definition at line 49 of file KoCanvasBase.cpp.

50 : d(new Private())
51{
52 d->resourceManager = sharedResourceManager ?
53 sharedResourceManager : new KoCanvasResourceProvider();
54 d->isResourceManagerShared = sharedResourceManager;
55
56 d->shapeController = new KoShapeController(this, shapeController);
57 d->snapGuide = new KoSnapGuide(this);
58}
Private *const d

References d, and shapeController.

◆ ~KoCanvasBase()

KoCanvasBase::~KoCanvasBase ( )
override

Definition at line 60 of file KoCanvasBase.cpp.

61{
62 d->shapeController->reset();
63 delete d;
64}

References d.

◆ KoCanvasBase() [2/2]

KoCanvasBase::KoCanvasBase ( )
private

Member Function Documentation

◆ addCommand()

virtual void KoCanvasBase::addCommand ( KUndo2Command * command)
pure virtual

Adds a command to the history. Call this for each command you create. This will also execute the command. This means, most of the application's code will look like MyCommand * cmd = new MyCommand( parameters ); canvas.addCommand( cmd );

Note that the command history takes ownership of the command, it will delete it when the undo limit is reached, or when deleting the command history itself.

Parameters
commandthe command to add

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ canvasController()

KoCanvasController * KoCanvasBase::canvasController ( ) const

Return the canvas controller for this canvas.

Definition at line 99 of file KoCanvasBase.cpp.

100{
101 return d->controller;
102}

References d.

◆ canvasIsOpenGL()

virtual bool KoCanvasBase::canvasIsOpenGL ( ) const
inlinevirtual
Returns
true if opengl can be used directly on the canvas

Reimplemented in KisCanvas2.

Definition at line 62 of file KoCanvasBase.h.

62{ return false; }

◆ canvasWidget() [1/2]

virtual const QWidget * KoCanvasBase::canvasWidget ( ) const
pure virtual

Return the widget that will be added to the scrollArea.

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ canvasWidget() [2/2]

virtual QWidget * KoCanvasBase::canvasWidget ( )
pure virtual

Return the widget that will be added to the scrollArea.

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ clipToDocument()

void KoCanvasBase::clipToDocument ( const KoShape * shape,
QPointF & move ) const
virtual

Called when the user tries to move the argument shape to allow the application to limit the users movement to stay within the document bounds. An implementation can alter the parameter move to make sure that if the distance moved is applied to the shape it will not become unreachable for the user. The default implementation does not restrict movement.

Parameters
shapethe shape that will be moved soon.
movethe distance the caller intends to move the shape.

Definition at line 104 of file KoCanvasBase.cpp.

105{
106}

◆ disconnectCanvasObserver()

void KoCanvasBase::disconnectCanvasObserver ( QObject * object)
virtual

disconnect the given QObject completely and utterly from any and all connections it has to any QObject owned by the canvas. Do this in the setCanvas of every KoCanvasObserver.

Reimplemented in KisCanvas2.

Definition at line 79 of file KoCanvasBase.cpp.

80{
81 if (shapeManager()) shapeManager()->selection()->disconnect(object);
82 if (resourceManager()) resourceManager()->disconnect(object);
83 if (shapeManager()) shapeManager()->disconnect(object);
84 if (toolProxy()) toolProxy()->disconnect(object);
85 if (selectedShapesProxy()) selectedShapesProxy()->disconnect(object);
86}
virtual KoShapeManager * shapeManager() const =0
virtual KoToolProxy * toolProxy() const =0
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
KoSelection * selection

References resourceManager, selectedShapesProxy(), KoShapeManager::selection, shapeManager(), and toolProxy().

◆ documentOrigin()

virtual QPoint KoCanvasBase::documentOrigin ( ) const
inlinevirtual

Return the position of the document origin inside the canvas widget, in pixels. By default the origin of the canvas widget and the position of the document origin are coincident, thus an empty point is returned.

Reimplemented in KisCanvas2.

Definition at line 177 of file KoCanvasBase.h.

177 {
178 return QPoint(0, 0);
179 }

◆ gridSize()

virtual void KoCanvasBase::gridSize ( QPointF * offset,
QSizeF * spacing ) const
pure virtual

retrieve the grid size setting. The grid spacing will be provided in pt.

Parameters
horizontala pointer to a qreal that will be filled with the horizontal grid-spacing
verticala pointer to a qreal that will be filled with the vertical grid-spacing

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ Private()

KoCanvasBase::Private ( )
inline

Definition at line 26 of file KoCanvasBase.cpp.

27 : shapeController(0),
30 controller(0),
31 snapGuide(0)
32 {
33 }
KoCanvasController * controller

◆ resourceManager()

KoCanvasResourceProvider * KoCanvasBase::resourceManager ( ) const

Return a pointer to the resource manager associated with this canvas. The resource manager contains per-canvas settings such as current foreground and background color. If instead of per-canvas resources you need per-document resources you can by going via the shapeController instead;

canvasBase->shapeController()->resourceManager();
See also
KoShapeController::resourceManager()

◆ selectedShapesProxy()

virtual KoSelectedShapesProxy * KoCanvasBase::selectedShapesProxy ( ) const
pure virtual

selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged() and selectionContentChanged() signals. While shapeManager() can change throughout the life time of the canvas, selectedShapesProxy() is guaranteed to stay the same.

Returns
persistent KoSelectedShapesProxy object

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ setCanvasController()

void KoCanvasBase::setCanvasController ( KoCanvasController * controller)

called by KoCanvasController to set the controller that handles this canvas.

Definition at line 94 of file KoCanvasBase.cpp.

95{
96 d->controller = controller;
97}

References controller, and d.

◆ setCursor()

virtual void KoCanvasBase::setCursor ( const QCursor & cursor)
pure virtual

set the specified cursor on this canvas

Parameters
cursorthe new cursor
Returns
the old cursor

Implemented in SimpleCanvas, KisShapeLayerCanvasBase, KisShapeSelectionCanvas, and KisCanvas2.

◆ shapeController()

KoShapeController * KoCanvasBase::shapeController ( ) const

Return the shape controller for this canvas. A shape controller is used to create or delete shapes and show the relevant dialogs to the user.

◆ shapeManager()

virtual KoShapeManager * KoCanvasBase::shapeManager ( ) const
pure virtual

Return the current shapeManager. WARNING: the shape manager can switch in time, e.g. when a layer is changed. Please don't keep any persistent connections to it. Instead please use selectedShapesProxy(), which is guaranteed to be the same throughout the life of the canvas.

Returns
the current shapeManager

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ snapGuide()

KoSnapGuide * KoCanvasBase::snapGuide ( ) const

Returns the snap guide of the canvas

◆ snapToGrid()

virtual bool KoCanvasBase::snapToGrid ( ) const
pure virtual

return if snap to grid is enabled.

Returns
if snap to grid is enabled.

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ toolProxy()

virtual KoToolProxy * KoCanvasBase::toolProxy ( ) const
pure virtual

Return the proxy to the active tool (determining which tool is really, really active is hard when tablets are involved, so leave that to others.

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ unit()

virtual KoUnit KoCanvasBase::unit ( ) const
pure virtual

Return the unit of the current document for initialization of the widgets created by the flake framework.

See also
KoDocument::unit()

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ updateCanvas()

virtual void KoCanvasBase::updateCanvas ( const QRectF & rc)
pure virtual

Tell the canvas to repaint the specified rectangle. The coordinates are document coordinates, not view coordinates.

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvas, KisShapeSelectionCanvas, and ReferenceImagesCanvas.

◆ viewConverter() [1/2]

virtual const KoViewConverter * KoCanvasBase::viewConverter ( ) const
pure virtual

Return the viewConverter for this view.

Returns
the viewConverter for this view.

Implemented in SimpleCanvas, KisCanvas2, KisShapeLayerCanvasBase, and KisShapeSelectionCanvas.

◆ viewConverter() [2/2]

virtual KoViewConverter * KoCanvasBase::viewConverter ( )
pure virtual

◆ viewToDocument()

QPointF KoCanvasBase::viewToDocument ( const QPointF & viewPoint) const
virtual

Convert a coordinate in pixels to pt.

Parameters
viewPointthe point in the coordinate system of the widget, or window.

Definition at line 66 of file KoCanvasBase.cpp.

67{
68 return viewConverter()->viewToDocument(viewPoint - documentOrigin());
69}
virtual QPoint documentOrigin() const
virtual const KoViewConverter * viewConverter() const =0
virtual QPointF viewToDocument(const QPointF &viewPoint) const

References documentOrigin(), viewConverter(), and KoViewConverter::viewToDocument().

Member Data Documentation

◆ controller

KoCanvasController* KoCanvasBase::controller

Definition at line 45 of file KoCanvasBase.cpp.

◆ d

Private* const KoCanvasBase::d
private

Definition at line 225 of file KoCanvasBase.h.

◆ isResourceManagerShared

bool KoCanvasBase::isResourceManagerShared

Definition at line 44 of file KoCanvasBase.cpp.

◆ resourceManager

KoCanvasResourceProvider * KoCanvasBase::resourceManager

Definition at line 43 of file KoCanvasBase.cpp.

◆ shapeController

KoShapeController * KoCanvasBase::shapeController

Definition at line 42 of file KoCanvasBase.cpp.

◆ snapGuide

KoSnapGuide * KoCanvasBase::snapGuide

Definition at line 46 of file KoCanvasBase.cpp.


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