Krita

Canvas.cpp
1/*
2 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#include "Canvas.h"
7#include <KoCanvasBase.h>
8#include <kis_canvas2.h>
9#include <KisView.h>
10#include <KoCanvasController.h>
11#include <kis_canvas_controller.h>
12#include <kis_zoom_manager.h>
13#include <QPointer>
14#include <View.h>
15
16struct Canvas::Private {
17 Private() {}
18 KisCanvas2 *canvas {0};
19};
20
21Canvas::Canvas(KoCanvasBase *canvas, QObject *parent)
22 : QObject(parent)
23 , d(new Private)
24{
25 d->canvas = static_cast<KisCanvas2*>(canvas);
26}
27
28Canvas::~Canvas()
29{
30 delete d;
31}
32
33
34bool Canvas::operator==(const Canvas &other) const
35{
36 return (d->canvas == other.d->canvas);
37}
38
39bool Canvas::operator!=(const Canvas &other) const
40{
41 return !(operator==(other));
42}
43
44
45qreal Canvas::zoomLevel() const
46{
47 if (!d->canvas) return 1.0;
48 return d->canvas->imageView()->zoomManager()->zoom();
49}
50
51void Canvas::setZoomLevel(qreal value)
52{
53 if (!d->canvas) return;
54 d->canvas->imageView()->zoomController()->setZoom(KoZoomMode::ZOOM_CONSTANT, value);
55}
56
58{
59 if (!d->canvas) return;
60 d->canvas->imageView()->zoomManager()->zoomTo100();
61}
62
63
65{
66 if (!d->canvas) return;
67 d->canvas->imageView()->canvasController()->resetCanvasRotation();
68}
69
70qreal Canvas::rotation() const
71{
72 if (!d->canvas) return 0;
73 return d->canvas->imageView()->canvasController()->rotation();
74}
75
76void Canvas::setRotation(qreal angle)
77{
78 if (!d->canvas) return;
79 d->canvas->imageView()->canvasController()->rotateCanvas(angle - rotation());
80}
81
82
83bool Canvas::mirror() const
84{
85 if (!d->canvas) return false;
86 return d->canvas->imageView()->canvasIsMirrored();
87}
88
89void Canvas::setMirror(bool value)
90{
91 if (!d->canvas) return;
92 d->canvas->imageView()->canvasController()->mirrorCanvas(value);
93}
94
96{
97 if (!d->canvas) return 0;
98 View *view = new View(d->canvas->imageView());
99 return view;
100}
101
102KisDisplayColorConverter *Canvas::displayColorConverter() const
103{
104 if (!d->canvas) return 0;
105 return d->canvas->displayColorConverter();
106}
107
109{
110 if (!d->canvas) return false;
111 return d->canvas->imageView()->canvasController()->wrapAroundMode();
112}
113
115{
116 if (!d->canvas) return;
117 d->canvas->imageView()->canvasController()->slotToggleWrapAroundMode(enable);
118}
119
121{
122 if (!d->canvas) return false;
123 return d->canvas->imageView()->canvasController()->levelOfDetailMode();
124}
125
127{
128 if (!d->canvas) return;
129 return d->canvas->imageView()->canvasController()->slotToggleLevelOfDetailMode(enable);
130}
131
132#include "moc_Canvas.cpp"
Canvas wraps the canvas inside a view on an image/document.
Definition Canvas.h:23
bool mirror() const
Definition Canvas.cpp:83
void setMirror(bool value)
setMirror turn the canvas mirroring on or off depending on
Definition Canvas.cpp:89
qreal rotation() const
Definition Canvas.cpp:70
void setRotation(qreal angle)
setRotation set the rotation of the canvas to the given
Definition Canvas.cpp:76
View * view() const
Definition Canvas.cpp:95
void setWrapAroundMode(bool enable)
setWrapAroundMode set wraparound mode to
Definition Canvas.cpp:114
bool levelOfDetailMode() const
Definition Canvas.cpp:120
void setLevelOfDetailMode(bool enable)
setLevelOfDetailMode sets Instant Preview to
Definition Canvas.cpp:126
void resetRotation()
resetRotation reset the canvas rotation.
Definition Canvas.cpp:64
qreal zoomLevel() const
Definition Canvas.cpp:45
bool wrapAroundMode() const
Definition Canvas.cpp:108
void setZoomLevel(qreal value)
setZoomLevel set the zoomlevel to the given value.
Definition Canvas.cpp:51
void resetZoom()
resetZoom set the zoomlevel to 100%
Definition Canvas.cpp:57
View represents one view on a document.
Definition View.h:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.