Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCanvasBase.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2
3 SPDX-FileCopyrightText: 2006 Thorsten Zachmann <zachmann@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include <QRectF>
9#include <QPointer>
10#include <QDebug>
11
12#include "KoCanvasBase.h"
14#include "KoShapeController.h"
15#include "KoCanvasController.h"
16#include "KoViewConverter.h"
17#include "KoSnapGuide.h"
18#include "KoShapeManager.h"
19#include "KoToolProxy.h"
20#include "KoSelection.h"
23
24class Q_DECL_HIDDEN KoCanvasBase::Private
25{
26public:
28 : shapeController(0),
29 resourceManager(0),
30 isResourceManagerShared(false),
31 controller(0),
32 snapGuide(0)
33 {
34 }
35
37 delete shapeController;
38 if (!isResourceManagerShared) {
39 delete resourceManager;
40 }
41 delete snapGuide;
42 }
48};
49
51 : d(new Private())
52{
53 d->resourceManager = sharedResourceManager ?
54 sharedResourceManager : new KoCanvasResourceProvider();
55 d->isResourceManagerShared = sharedResourceManager;
56
57 d->shapeController = new KoShapeController(this, shapeController);
58 d->snapGuide = new KoSnapGuide(this);
59}
60
62{
63 d->shapeController->reset();
64 delete d;
65}
66
71
72QPointF KoCanvasBase::viewToDocument(const QPointF &viewPoint) const
73{
74 return viewConverter()->viewToDocument(viewPoint - documentOrigin());
75}
76
78{
79 if (d->shapeController)
80 return d->shapeController;
81 else
82 return 0;
83}
84
86{
87 if (shapeManager()) shapeManager()->selection()->disconnect(object);
88 if (resourceManager()) resourceManager()->disconnect(object);
89 if (shapeManager()) shapeManager()->disconnect(object);
90 if (toolProxy()) toolProxy()->disconnect(object);
91 if (selectedShapesProxy()) selectedShapesProxy()->disconnect(object);
92}
93
94
96{
97 return d->resourceManager;
98}
99
101{
102 d->controller = controller;
103}
104
106{
107 return d->controller;
108}
109
110void KoCanvasBase::clipToDocument(const KoShape *, QPointF &) const
111{
112}
113
115{
116 return d->snapGuide;
117}
void setCanvasController(KoCanvasController *controller)
called by KoCanvasController to set the controller that handles this canvas.
virtual void clipToDocument(const KoShape *shape, QPointF &move) const
KoSnapGuide * snapGuide
virtual void disconnectCanvasObserver(QObject *object)
virtual QPointF viewToDocument(const QPointF &viewPoint) const
QPointer< KoShapeController > shapeController
virtual KoShapeManager * shapeManager() const =0
Private *const d
KoCanvasController * controller
virtual KoToolProxy * toolProxy() const =0
bool isResourceManagerShared
virtual QPoint documentOrigin() const
virtual const KoViewConverter * viewConverter() const =0
virtual KoColorDisplayRendererInterface * displayRendererInterface() const
displayRendererInterface The display renderer interface has a number of color conversion functions wh...
QPointer< KoCanvasResourceProvider > resourceManager
KoCanvasController * canvasController() const
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
~KoCanvasBase() override
static KoColorDisplayRendererInterface * instance()
KoSelection * selection
virtual QPointF viewToDocument(const QPointF &viewPoint) const