Krita

Canvas.h
1/*
2 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#ifndef LIBKIS_CANVAS_H
7#define LIBKIS_CANVAS_H
8
9#include <QObject>
10
11#include "kritalibkis_export.h"
12#include "libkis.h"
13
14class KoCanvasBase;
15class KisDisplayColorConverter;
16
17/**
18 * Canvas wraps the canvas inside a view on an image/document.
19 * It is responsible for the view parameters of the document:
20 * zoom, rotation, mirror, wraparound and instant preview.
21 */
22class KRITALIBKIS_EXPORT Canvas : public QObject
23{
25
26public:
27 explicit Canvas(KoCanvasBase *canvas, QObject *parent = 0);
28 ~Canvas() override;
29
30 bool operator==(const Canvas &other) const;
31 bool operator!=(const Canvas &other) const;
32
33public Q_SLOTS:
34
35 /**
36 * @return the current zoomlevel. 1.0 is 100%.
37 */
38 qreal zoomLevel() const;
39
40 /**
41 * @brief setZoomLevel set the zoomlevel to the given @p value. 1.0 is 100%.
42 */
43 void setZoomLevel(qreal value);
44
45 /**
46 * @brief setPan Centers the image pixel at \p imagePos in the current view
47 */
48 void setPreferredCenter(const QPointF& imagePos);
49
50 /**
51 * @brief \return the position of the image pixel that is placed in the center of the current view
52 */
54
55 /**
56 * @brief pan the current view in pixels.
57 */
58 void pan(const QPoint& offset);
59
60 /**
61 * @brief resetZoom set the zoomlevel to 100%
62 */
63 void resetZoom();
64
65 /**
66 * @return the rotation of the canvas in degrees.
67 */
68 qreal rotation() const;
69
70 /**
71 * @brief setRotation set the rotation of the canvas to the given @param angle in degrees.
72 */
73 void setRotation(qreal angle);
74
75 /**
76 * @brief resetRotation reset the canvas rotation.
77 */
78 void resetRotation();
79
80 /**
81 * @return return true if the canvas is mirrored, false otherwise.
82 */
83 bool mirror() const;
84
85 /**
86 * @brief setMirror turn the canvas mirroring on or off depending on @param value
87 */
88 void setMirror(bool value);
89
90 /**
91 * @return true if the canvas is in wraparound mode, false if not. Only when OpenGL is enabled,
92 * is wraparound mode available.
93 */
94 bool wrapAroundMode() const;
95
96 /**
97 * @brief setWrapAroundMode set wraparound mode to @param enable
98 */
99 void setWrapAroundMode(bool enable);
100
101 /**
102 * @return true if the canvas is in Instant Preview mode, false if not. Only when OpenGL is enabled,
103 * is Instant Preview mode available.
104 */
105 bool levelOfDetailMode() const;
106
107 /**
108 * @brief setLevelOfDetailMode sets Instant Preview to @param enable
109 */
110 void setLevelOfDetailMode(bool enable);
111
112 /**
113 * @return the view that holds this canvas
114 */
115 View *view() const;
116
117
118private:
119
120 friend class ManagedColor;
121
122 KisDisplayColorConverter *displayColorConverter() const;
123
124 struct Private;
125 Private *const d;
126
127};
128
129#endif // LIBKIS_CANVAS_H
bool mirror() const
Definition Canvas.cpp:113
void setMirror(bool value)
setMirror turn the canvas mirroring on or off depending on
Definition Canvas.cpp:119
qreal rotation() const
Definition Canvas.cpp:100
void setRotation(qreal angle)
setRotation set the rotation of the canvas to the given
Definition Canvas.cpp:106
View * view() const
Definition Canvas.cpp:125
QPointF preferredCenter() const
Definition Canvas.cpp:69
void setWrapAroundMode(bool enable)
setWrapAroundMode set wraparound mode to
Definition Canvas.cpp:144
bool levelOfDetailMode() const
Definition Canvas.cpp:150
void setLevelOfDetailMode(bool enable)
setLevelOfDetailMode sets Instant Preview to
Definition Canvas.cpp:156
void resetRotation()
resetRotation reset the canvas rotation.
Definition Canvas.cpp:94
qreal zoomLevel() const
Definition Canvas.cpp:45
bool wrapAroundMode() const
Definition Canvas.cpp:138
void setZoomLevel(qreal value)
setZoomLevel set the zoomlevel to the given value.
Definition Canvas.cpp:51
void setPreferredCenter(const QPointF &imagePos)
setPan Centers the image pixel at imagePos in the current view
Definition Canvas.cpp:57
void pan(const QPoint &offset)
pan the current view in pixels.
Definition Canvas.cpp:82
void resetZoom()
resetZoom set the zoomlevel to 100%
Definition Canvas.cpp:87
View represents one view on a document.
Definition View.h:25
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Mar 7 2025 11:56:48 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.