Krita Source Code Documentation
Loading...
Searching...
No Matches
Canvas Class Reference

#include <Canvas.h>

+ Inheritance diagram for Canvas:

Classes

struct  Private
 

Public Slots

bool levelOfDetailMode () const
 
bool mirror () const
 
void pan (const QPoint &offset)
 pan the current view in pixels.
 
QPointF preferredCenter () const
 
void resetRotation ()
 resetRotation reset the canvas rotation.
 
void resetZoom ()
 resetZoom set the zoomlevel to 100%
 
qreal rotation () const
 
void setLevelOfDetailMode (bool enable)
 setLevelOfDetailMode sets Instant Preview to
 
void setMirror (bool value)
 setMirror turn the canvas mirroring on or off depending on
 
void setPreferredCenter (const QPointF &imagePos)
 setPan Centers the image pixel at imagePos in the current view
 
void setRotation (qreal angle)
 setRotation set the rotation of the canvas to the given
 
void setWrapAroundMode (bool enable)
 setWrapAroundMode set wraparound mode to
 
void setZoomLevel (qreal value)
 setZoomLevel set the zoomlevel to the given value. 1.0 is 100%.
 
Viewview () const
 
bool wrapAroundMode () const
 
qreal zoomLevel () const
 

Public Member Functions

 Canvas (KoCanvasBase *canvas, QObject *parent=0)
 
bool operator!= (const Canvas &other) const
 
bool operator== (const Canvas &other) const
 
 ~Canvas () override
 

Private Member Functions

KisDisplayColorConverterdisplayColorConverter () const
 

Private Attributes

Private *const d
 

Friends

class ManagedColor
 

Detailed Description

Canvas wraps the canvas inside a view on an image/document. It is responsible for the view parameters of the document: zoom, rotation, mirror, wraparound and instant preview.

Definition at line 22 of file Canvas.h.

Constructor & Destructor Documentation

◆ Canvas()

Canvas::Canvas ( KoCanvasBase * canvas,
QObject * parent = 0 )
explicit

Definition at line 20 of file Canvas.cpp.

21 : QObject(parent)
22 , d(new Private)
23{
24 d->canvas = static_cast<KisCanvas2*>(canvas);
25}
Private *const d
Definition Canvas.h:125
KisCanvas2 * canvas
Definition Canvas.cpp:17

References Canvas::Private::canvas, and d.

◆ ~Canvas()

Canvas::~Canvas ( )
override

Definition at line 27 of file Canvas.cpp.

28{
29 delete d;
30}

References d.

Member Function Documentation

◆ displayColorConverter()

KisDisplayColorConverter * Canvas::displayColorConverter ( ) const
private

Definition at line 131 of file Canvas.cpp.

132{
133 if (!d->canvas) return 0;
134 return d->canvas->displayColorConverter();
135}
KisDisplayColorConverter displayColorConverter

References Canvas::Private::canvas, d, and KisCanvas2::displayColorConverter.

◆ levelOfDetailMode

bool Canvas::levelOfDetailMode ( ) const
slot
Returns
true if the canvas is in Instant Preview mode, false if not. Only when OpenGL is enabled, is Instant Preview mode available.

Definition at line 149 of file Canvas.cpp.

150{
151 if (!d->canvas) return false;
152 return d->canvas->imageView()->canvasController()->levelOfDetailMode();
153}
QPointer< KisView > imageView() const

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ mirror

bool Canvas::mirror ( ) const
slot
Returns
return true if the canvas is mirrored, false otherwise.

Definition at line 112 of file Canvas.cpp.

113{
114 if (!d->canvas) return false;
115 return d->canvas->imageView()->canvasIsMirrored();
116}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ operator!=()

bool Canvas::operator!= ( const Canvas & other) const

Definition at line 38 of file Canvas.cpp.

39{
40 return !(operator==(other));
41}
bool operator==(const Canvas &other) const
Definition Canvas.cpp:33

References operator==().

◆ operator==()

bool Canvas::operator== ( const Canvas & other) const

Definition at line 33 of file Canvas.cpp.

34{
35 return (d->canvas == other.d->canvas);
36}

References Canvas::Private::canvas, and d.

◆ pan

void Canvas::pan ( const QPoint & offset)
slot

pan the current view in pixels.

Definition at line 81 of file Canvas.cpp.

82{
83 d->canvas->imageView()->canvasController()->pan(offset);
84}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ preferredCenter

QPointF Canvas::preferredCenter ( ) const
slot
Returns
the position of the image pixel that is placed in the center of the current view

Definition at line 68 of file Canvas.cpp.

69{
70 if (!d->canvas) return QPointF();
71
72 QPointF flakePos = d->canvas->imageView()->canvasController()->preferredCenter();
73
75 QPointF docPos = coordConv->flakeToDocument(flakePos);
76 QPointF imagePos = coordConv->documentToImage(docPos);
77
78 return imagePos;
79}
KisCoordinatesConverter * coordinatesConverter
_Private::Traits< T >::Result flakeToDocument(const T &obj) const
_Private::Traits< T >::Result documentToImage(const T &obj) const

References Canvas::Private::canvas, KisCanvas2::coordinatesConverter, d, KisCoordinatesConverter::documentToImage(), KisCoordinatesConverter::flakeToDocument(), and KisCanvas2::imageView().

◆ resetRotation

void Canvas::resetRotation ( )
slot

resetRotation reset the canvas rotation.

Definition at line 93 of file Canvas.cpp.

94{
95 if (!d->canvas) return;
96 d->canvas->imageView()->canvasController()->resetCanvasRotation();
97}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ resetZoom

void Canvas::resetZoom ( )
slot

resetZoom set the zoomlevel to 100%

Definition at line 86 of file Canvas.cpp.

87{
88 if (!d->canvas) return;
89 d->canvas->imageView()->zoomManager()->zoomTo100();
90}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ rotation

qreal Canvas::rotation ( ) const
slot
Returns
the rotation of the canvas in degrees.

Definition at line 99 of file Canvas.cpp.

100{
101 if (!d->canvas) return 0;
102 return d->canvas->imageView()->canvasController()->rotation();
103}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ setLevelOfDetailMode

void Canvas::setLevelOfDetailMode ( bool enable)
slot

setLevelOfDetailMode sets Instant Preview to

Parameters
enable

Definition at line 155 of file Canvas.cpp.

156{
157 if (!d->canvas) return;
158 return d->canvas->imageView()->canvasController()->slotToggleLevelOfDetailMode(enable);
159}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ setMirror

void Canvas::setMirror ( bool value)
slot

setMirror turn the canvas mirroring on or off depending on

Parameters
value

Definition at line 118 of file Canvas.cpp.

119{
120 if (!d->canvas) return;
121 d->canvas->imageView()->canvasController()->mirrorCanvas(value);
122}
float value(const T *src, size_t ch)

References Canvas::Private::canvas, d, KisCanvas2::imageView(), and value().

◆ setPreferredCenter

void Canvas::setPreferredCenter ( const QPointF & imagePos)
slot

setPan Centers the image pixel at imagePos in the current view

Definition at line 56 of file Canvas.cpp.

57{
58 if (!d->canvas) return;
59
61
62 QPointF documentPos = coordConv->imageToDocument(imagePos);
63 QPointF flakePos = coordConv->documentToFlake(documentPos);
64
65 d->canvas->imageView()->canvasController()->setPreferredCenter(flakePos);
66}
_Private::Traits< T >::Result documentToFlake(const T &obj) const
_Private::Traits< T >::Result imageToDocument(const T &obj) const

References Canvas::Private::canvas, KisCanvas2::coordinatesConverter, d, KisCoordinatesConverter::documentToFlake(), KisCoordinatesConverter::imageToDocument(), and KisCanvas2::imageView().

◆ setRotation

void Canvas::setRotation ( qreal angle)
slot

setRotation set the rotation of the canvas to the given

Parameters
anglein degrees.

Definition at line 105 of file Canvas.cpp.

106{
107 if (!d->canvas) return;
108 d->canvas->imageView()->canvasController()->rotateCanvas(angle - rotation());
109}
qreal rotation() const
Definition Canvas.cpp:99

References Canvas::Private::canvas, d, KisCanvas2::imageView(), and rotation().

◆ setWrapAroundMode

void Canvas::setWrapAroundMode ( bool enable)
slot

setWrapAroundMode set wraparound mode to

Parameters
enable

Definition at line 143 of file Canvas.cpp.

144{
145 if (!d->canvas) return;
146 d->canvas->imageView()->canvasController()->slotToggleWrapAroundMode(enable);
147}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ setZoomLevel

void Canvas::setZoomLevel ( qreal value)
slot

setZoomLevel set the zoomlevel to the given value. 1.0 is 100%.

Definition at line 50 of file Canvas.cpp.

51{
52 if (!d->canvas) return;
53 d->canvas->imageView()->canvasController()->setZoom(KoZoomMode::ZOOM_CONSTANT, value);
54}
@ ZOOM_CONSTANT
zoom x %
Definition KoZoomMode.h:24

References Canvas::Private::canvas, d, KisCanvas2::imageView(), value(), and KoZoomMode::ZOOM_CONSTANT.

◆ view

View * Canvas::view ( ) const
slot
Returns
the view that holds this canvas

Definition at line 124 of file Canvas.cpp.

125{
126 if (!d->canvas) return 0;
127 View *view = new View(d->canvas->imageView());
128 return view;
129}
View * view() const
Definition Canvas.cpp:124
Definition View.h:25

References Canvas::Private::canvas, d, KisCanvas2::imageView(), and view().

◆ wrapAroundMode

bool Canvas::wrapAroundMode ( ) const
slot
Returns
true if the canvas is in wraparound mode, false if not. Only when OpenGL is enabled, is wraparound mode available.

Definition at line 137 of file Canvas.cpp.

138{
139 if (!d->canvas) return false;
140 return d->canvas->imageView()->canvasController()->wrapAroundMode();
141}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

◆ zoomLevel

qreal Canvas::zoomLevel ( ) const
slot
Returns
the current zoomlevel. 1.0 is 100%.

Definition at line 44 of file Canvas.cpp.

45{
46 if (!d->canvas) return 1.0;
47 return d->canvas->imageView()->viewConverter()->zoom();
48}

References Canvas::Private::canvas, d, and KisCanvas2::imageView().

Friends And Related Symbol Documentation

◆ ManagedColor

friend class ManagedColor
friend

Definition at line 120 of file Canvas.h.

Member Data Documentation

◆ d

Private* const Canvas::d
private

Definition at line 125 of file Canvas.h.


The documentation for this class was generated from the following files: