File indexing completed on 2024-05-12 15:59:04
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #ifndef LIBKIS_CANVAS_H 0007 #define LIBKIS_CANVAS_H 0008 0009 #include <QObject> 0010 0011 #include "kritalibkis_export.h" 0012 #include "libkis.h" 0013 0014 class KoCanvasBase; 0015 class KisDisplayColorConverter; 0016 0017 /** 0018 * Canvas wraps the canvas inside a view on an image/document. 0019 * It is responsible for the view parameters of the document: 0020 * zoom, rotation, mirror, wraparound and instant preview. 0021 */ 0022 class KRITALIBKIS_EXPORT Canvas : public QObject 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 explicit Canvas(KoCanvasBase *canvas, QObject *parent = 0); 0028 ~Canvas() override; 0029 0030 bool operator==(const Canvas &other) const; 0031 bool operator!=(const Canvas &other) const; 0032 0033 public Q_SLOTS: 0034 0035 /** 0036 * @return the current zoomlevel. 1.0 is 100%. 0037 */ 0038 qreal zoomLevel() const; 0039 0040 /** 0041 * @brief setZoomLevel set the zoomlevel to the given @p value. 1.0 is 100%. 0042 */ 0043 void setZoomLevel(qreal value); 0044 0045 /** 0046 * @brief resetZoom set the zoomlevel to 100% 0047 */ 0048 void resetZoom(); 0049 0050 /** 0051 * @return the rotation of the canvas in degrees. 0052 */ 0053 qreal rotation() const; 0054 0055 /** 0056 * @brief setRotation set the rotation of the canvas to the given @param angle in degrees. 0057 */ 0058 void setRotation(qreal angle); 0059 0060 /** 0061 * @brief resetRotation reset the canvas rotation. 0062 */ 0063 void resetRotation(); 0064 0065 /** 0066 * @return return true if the canvas is mirrored, false otherwise. 0067 */ 0068 bool mirror() const; 0069 0070 /** 0071 * @brief setMirror turn the canvas mirroring on or off depending on @param value 0072 */ 0073 void setMirror(bool value); 0074 0075 /** 0076 * @return true if the canvas is in wraparound mode, false if not. Only when OpenGL is enabled, 0077 * is wraparound mode available. 0078 */ 0079 bool wrapAroundMode() const; 0080 0081 /** 0082 * @brief setWrapAroundMode set wraparound mode to @param enable 0083 */ 0084 void setWrapAroundMode(bool enable); 0085 0086 /** 0087 * @return true if the canvas is in Instant Preview mode, false if not. Only when OpenGL is enabled, 0088 * is Instant Preview mode available. 0089 */ 0090 bool levelOfDetailMode() const; 0091 0092 /** 0093 * @brief setLevelOfDetailMode sets Instant Preview to @param enable 0094 */ 0095 void setLevelOfDetailMode(bool enable); 0096 0097 /** 0098 * @return the view that holds this canvas 0099 */ 0100 View *view() const; 0101 0102 0103 private: 0104 0105 friend class ManagedColor; 0106 0107 KisDisplayColorConverter *displayColorConverter() const; 0108 0109 struct Private; 0110 Private *const d; 0111 0112 }; 0113 0114 #endif // LIBKIS_CANVAS_H