Krita

Canvas.cpp
1 /*
2  * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <[email protected]>
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 
16 struct Canvas::Private {
17  Private() {}
18  KisCanvas2 *canvas {0};
19 };
20 
21 Canvas::Canvas(KoCanvasBase *canvas, QObject *parent)
22  : QObject(parent)
23  , d(new Private)
24 {
25  d->canvas = static_cast<KisCanvas2*>(canvas);
26 }
27 
28 Canvas::~Canvas()
29 {
30  delete d;
31 }
32 
33 
34 bool Canvas::operator==(const Canvas &other) const
35 {
36  return (d->canvas == other.d->canvas);
37 }
38 
39 bool Canvas::operator!=(const Canvas &other) const
40 {
41  return !(operator==(other));
42 }
43 
44 
45 qreal Canvas::zoomLevel() const
46 {
47  if (!d->canvas) return 1.0;
48  return d->canvas->imageView()->zoomManager()->zoom();
49 }
50 
51 void 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 
70 qreal Canvas::rotation() const
71 {
72  if (!d->canvas) return 0;
73  return d->canvas->imageView()->canvasController()->rotation();
74 }
75 
76 void Canvas::setRotation(qreal angle)
77 {
78  if (!d->canvas) return;
79  d->canvas->imageView()->canvasController()->rotateCanvas(angle - rotation());
80 }
81 
82 
83 bool Canvas::mirror() const
84 {
85  if (!d->canvas) return false;
86  return d->canvas->imageView()->canvasIsMirrored();
87 }
88 
89 void 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 
102 KisDisplayColorConverter *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 
114 void Canvas::setWrapAroundMode(bool enable)
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"
void resetZoom()
resetZoom set the zoomlevel to 100%
Definition: Canvas.cpp:57
View * view() const
Definition: Canvas.cpp:95
void setRotation(qreal angle)
setRotation set the rotation of the canvas to the given
Definition: Canvas.cpp:76
bool wrapAroundMode() const
Definition: Canvas.cpp:108
bool levelOfDetailMode() const
Definition: Canvas.cpp:120
View represents one view on a document.
Definition: View.h:24
void setZoomLevel(qreal value)
setZoomLevel set the zoomlevel to the given value.
Definition: Canvas.cpp:51
void resetRotation()
resetRotation reset the canvas rotation.
Definition: Canvas.cpp:64
qreal rotation() const
Definition: Canvas.cpp:70
void setWrapAroundMode(bool enable)
setWrapAroundMode set wraparound mode to
Definition: Canvas.cpp:114
void setMirror(bool value)
setMirror turn the canvas mirroring on or off depending on
Definition: Canvas.cpp:89
Canvas wraps the canvas inside a view on an image/document.
Definition: Canvas.h:22
qreal zoomLevel() const
Definition: Canvas.cpp:45
bool mirror() const
Definition: Canvas.cpp:83
void setLevelOfDetailMode(bool enable)
setLevelOfDetailMode sets Instant Preview to
Definition: Canvas.cpp:126
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Dec 4 2022 04:12:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.