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

#include <View.h>

+ Inheritance diagram for View:

Classes

struct  Private
 

Public Slots

void activateResource (Resource *resource)
 activateResource activates the given resource.
 
ManagedColorbackgroundColor () const
 backgroundColor allows access to the currently active background color. This is nominally per canvas/view, but in practice per mainwindow.
 
qreal brushRotation () const
 return the current rotation for brush tip
 
qreal brushSize () const
 return the current size for brush
 
Canvascanvas () const
 
QString currentBlendingMode () const
 return the current blending mode for brush
 
ResourcecurrentBrushPreset () const
 return the current selected preset
 
ResourcecurrentGradient () const
 return the current selected gradient
 
ResourcecurrentPattern () const
 return the current selected pattern
 
bool disablePressure () const
 return current disabled pressure status
 
Documentdocument () const
 
bool eraserMode () const
 return current eraser mode status (active/inactive)
 
QTransform flakeToCanvasTransform () const
 flakeToCanvasTransform The transformation of the canvas relative to the view without rotation and mirroring
 
QTransform flakeToDocumentTransform () const
 flakeToDocumentTransform The transformation of the document relative to the view without rotation and mirroring
 
QTransform flakeToImageTransform () const
 flakeToImageTransform The transformation of the image relative to the view without rotation and mirroring
 
ManagedColorforegroundColor () const
 
bool globalAlphaLock () const
 return current global alpha lock mode (active/inactive)
 
float HDRExposure () const
 
float HDRGamma () const
 
qreal paintingFlow () const
 return the current flow for brush
 
qreal paintingOpacity () const
 return the current opacity for brush
 
qreal patternSize () const
 return the current pattern size for brush
 
QList< Node * > selectedNodes () const
 
void setBackGroundColor (ManagedColor *color)
 
void setBrushRotation (qreal brushRotation)
 set the current rotation for brush tip
 
void setBrushSize (qreal brushSize)
 set the current size for brush
 
void setCurrentBlendingMode (const QString &blendingMode)
 set the current blending mode for brush
 
void setCurrentBrushPreset (Resource *resource)
 set the current selected preset
 
void setCurrentGradient (Resource *resource)
 set the current selected gradient
 
void setCurrentPattern (Resource *resource)
 set the current selected pattern
 
void setDisablePressure (bool value)
 set current disabled pressure status
 
void setDocument (Document *document)
 
void setEraserMode (bool value)
 set current eraser active/inactive
 
void setForeGroundColor (ManagedColor *color)
 
void setGlobalAlphaLock (bool value)
 set current global alpha lock mode active/inactive
 
void setHDRExposure (float exposure)
 set the current HDR Exposure value
 
void setHDRGamma (float gamma)
 set the current HDR Gamma value
 
void setPaintingFlow (qreal flow)
 set the current flow value for brush
 
void setPaintingOpacity (qreal opacity)
 set the current opacity for brush
 
void setPatternSize (qreal size)
 set the current pattern size value for brush
 
void setVisible ()
 
void showFloatingMessage (const QString &message, const QIcon &icon, int timeout, int priority)
 showFloatingMessage displays a floating message box on the top-left corner of the canvas
 
bool visible () const
 
Windowwindow () const
 

Public Member Functions

bool operator!= (const View &other) const
 
bool operator== (const View &other) const
 
 View (KisView *view, QObject *parent=0)
 
 ~View () override
 

Private Member Functions

KisViewview ()
 

Private Attributes

Private *const d
 

Friends

class Scratchpad
 
class Window
 

Detailed Description

View represents one view on a document. A document can be shown in more than one view at a time.

Definition at line 24 of file View.h.

Constructor & Destructor Documentation

◆ View()

View::View ( KisView * view,
QObject * parent = 0 )
explicit

Definition at line 38 of file View.cpp.

39 : QObject(parent)
40 , d(new Private)
41{
42 d->view = view;
43}
Private *const d
Definition View.h:354
KisView * view()
Definition View.cpp:103
QPointer< KisView > view
Definition View.cpp:35

References d, View::Private::view, and view().

◆ ~View()

View::~View ( )
override

Definition at line 45 of file View.cpp.

46{
47 delete d;
48}

References d.

Member Function Documentation

◆ activateResource

void View::activateResource ( Resource * resource)
slot

activateResource activates the given resource.

Parameters
resourcea pattern, gradient or paintop preset

Definition at line 108 of file View.cpp.

109{
110 if (!d->view) return;
111 if (!resource) return;
112
113 KoResourceSP r = resource->resource();
114 if (!r) return;
115
116 if (KoPatternSP pattern = r.dynamicCast<KoPattern>()) {
117 QVariant value = QVariant::fromValue(pattern);
118 d->view->canvasBase()->resourceManager()->setResource(KoCanvasResource::CurrentPattern, value);
119 } else if (KoAbstractGradientSP gradient = r.dynamicCast<KoAbstractGradient>()) {
120 QVariant value = QVariant::fromValue(gradient);
121 d->view->canvasBase()->resourceManager()->setResource(KoCanvasResource::CurrentGradient, value);
122 } else if (KoResourceSP preset = r.dynamicCast<KisPaintOpPreset>()) {
123 d->view->viewManager()->paintOpBox()->resourceSelected(preset);
124 }
125}
float value(const T *src, size_t ch)
Write API docs here.
Definition KoPattern.h:21
KoResourceSP resource() const
Definition Resource.cpp:116

References KoCanvasResource::CurrentGradient, KoCanvasResource::CurrentPattern, d, Resource::resource(), value(), and View::Private::view.

◆ backgroundColor

ManagedColor * View::backgroundColor ( ) const
slot

backgroundColor allows access to the currently active background color. This is nominally per canvas/view, but in practice per mainwindow.

Returns
The current background color

Definition at line 140 of file View.cpp.

141{
142 if (!d->view) return 0;
143 return new ManagedColor(d->view->resourceProvider()->bgColor());
144}
The ManagedColor class is a class to handle colors that are color managed. A managed color is a color...

References d, and View::Private::view.

◆ brushRotation

qreal View::brushRotation ( ) const
slot

return the current rotation for brush tip

Returns
the brush tip rotation value (in degrees)

Definition at line 249 of file View.cpp.

250{
251 if (!d->view) return 0.0;
252 return d->view->resourceProvider()->brushRotation();
253}

References d, and View::Private::view.

◆ brushSize

qreal View::brushSize ( ) const
slot

return the current size for brush

Returns
the brush size value (in pixels)

Definition at line 237 of file View.cpp.

238{
239 if (!d->view) return 0.0;
240 return d->view->resourceProvider()->size();
241}

References d, and View::Private::view.

◆ canvas

Canvas * View::canvas ( ) const
slot
Returns
the canvas this view is showing. The canvas controls things like zoom and rotation.

Definition at line 96 of file View.cpp.

97{
98 if (!d->view) return 0;
99 Canvas *c = new Canvas(d->view->canvasBase());
100 return c;
101}

References d, and View::Private::view.

◆ currentBlendingMode

QString View::currentBlendingMode ( ) const
slot

return the current blending mode for brush

Returns
the current blending mode identifier

Definition at line 185 of file View.cpp.

186{
187 if (!d->view) return "";
188 return d->view->resourceProvider()->currentCompositeOp();
189}

References d, and View::Private::view.

◆ currentBrushPreset

Resource * View::currentBrushPreset ( ) const
slot

return the current selected preset

Returns
the current preset (Resource type = 'preset')

Definition at line 152 of file View.cpp.

153{
154 if (!d->view) return 0;
155 return new Resource(d->view->resourceProvider()->currentPreset(), ResourceType::PaintOpPresets);
156}
const QString PaintOpPresets

References d, ResourceType::PaintOpPresets, and View::Private::view.

◆ currentGradient

Resource * View::currentGradient ( ) const
slot

return the current selected gradient

Returns
the current gradient (Resource type = 'gradient')

Definition at line 174 of file View.cpp.

175{
176 if (!d->view) return 0;
177 return new Resource(d->view->resourceProvider()->currentGradient(), ResourceType::Gradients);
178}
const QString Gradients

References d, ResourceType::Gradients, and View::Private::view.

◆ currentPattern

Resource * View::currentPattern ( ) const
slot

return the current selected pattern

Returns
the current pattern (Resource type = 'pattern')

Definition at line 163 of file View.cpp.

164{
165 if (!d->view) return 0;
166 return new Resource(d->view->resourceProvider()->currentPattern(), ResourceType::Patterns);
167}
const QString Patterns

References d, ResourceType::Patterns, and View::Private::view.

◆ disablePressure

bool View::disablePressure ( ) const
slot

return current disabled pressure status

Returns
True if is pressure is disabled, otherwise False

Definition at line 317 of file View.cpp.

318{
319 if (!d->view) {
320 return false;
321 }
322 return d->view->resourceProvider()->disablePressure();
323}

References d, and View::Private::view.

◆ document

Document * View::document ( ) const
slot
Returns
the document this view is showing.

Definition at line 69 of file View.cpp.

70{
71 if (!d->view) return 0;
72 Document *doc = new Document(d->view->document(), false);
73 return doc;
74}

References d, and View::Private::view.

◆ eraserMode

bool View::eraserMode ( ) const
slot

return current eraser mode status (active/inactive)

Returns
True if eraser mode is active, otherwise False

Definition at line 285 of file View.cpp.

286{
287 if (!d->view) {
288 return false;
289 }
290 return d->view->resourceProvider()->eraserMode();
291}

References d, and View::Private::view.

◆ flakeToCanvasTransform

QTransform View::flakeToCanvasTransform ( ) const
slot

flakeToCanvasTransform The transformation of the canvas relative to the view without rotation and mirroring

Returns
QTransform

Definition at line 360 of file View.cpp.

361{
362 if (!d->view->document()) return QTransform();
363 return d->view->canvasBase()->coordinatesConverter()->flakeToWidgetTransform();
364}

References d, and View::Private::view.

◆ flakeToDocumentTransform

QTransform View::flakeToDocumentTransform ( ) const
slot

flakeToDocumentTransform The transformation of the document relative to the view without rotation and mirroring

Returns
QTransform

Definition at line 354 of file View.cpp.

355{
356 if (!d->view->document()) return QTransform();
357 return d->view->canvasBase()->coordinatesConverter()->documentToFlakeTransform().inverted();
358}

References d, and View::Private::view.

◆ flakeToImageTransform

QTransform View::flakeToImageTransform ( ) const
slot

flakeToImageTransform The transformation of the image relative to the view without rotation and mirroring

Returns
QTransform

Definition at line 366 of file View.cpp.

367{
368 if (!d->view->document()) return QTransform();
369
370 const KisCoordinatesConverter* coordinatesConverter(d->view->canvasBase()->coordinatesConverter());
371 QTransform imageToFlakeTransform = coordinatesConverter->imageToDocumentTransform() * coordinatesConverter->documentToFlakeTransform();
372
373 return imageToFlakeTransform.inverted();
374}

References d, KisCoordinatesConverter::documentToFlakeTransform(), KisCoordinatesConverter::imageToDocumentTransform(), and View::Private::view.

◆ foregroundColor

ManagedColor * View::foregroundColor ( ) const
slot
   @brief foregroundColor allows access to the currently active foreground color.
   This is nominally per canvas/view, but in practice per mainwindow.

   @code

color = Application.activeWindow().activeView().foregroundColor() components = color.components() components[0] = 1.0 components[1] = 0.6 components[2] = 0.7 color.setComponents(components) Application.activeWindow().activeView().setForeGroundColor(color)

Returns
The current foreground color

Definition at line 128 of file View.cpp.

129{
130 if (!d->view) return 0;
131 return new ManagedColor(d->view->resourceProvider()->fgColor());
132}

References d, and View::Private::view.

◆ globalAlphaLock

bool View::globalAlphaLock ( ) const
slot

return current global alpha lock mode (active/inactive)

Returns
True if is active, otherwise False

Definition at line 301 of file View.cpp.

302{
303 if (!d->view) {
304 return false;
305 }
306 return d->view->resourceProvider()->globalAlphaLock();
307}

References d, and View::Private::view.

◆ HDRExposure

float View::HDRExposure ( ) const
slot
Returns
the current HDR Exposure value

Definition at line 197 of file View.cpp.

198{
199 if (!d->view) return 0.0;
200 KisExposureGammaCorrectionInterface *iface = d->view->canvasBase()->exposureGammaCorrectionInterface();
201 return iface->currentExposure();
202}
virtual qreal currentExposure() const =0

References KisExposureGammaCorrectionInterface::currentExposure(), d, and View::Private::view.

◆ HDRGamma

float View::HDRGamma ( ) const
slot
Returns
the current HDR Gamma value

Definition at line 211 of file View.cpp.

212{
213 if (!d->view) return 0.0;
214 KisExposureGammaCorrectionInterface *iface = d->view->canvasBase()->exposureGammaCorrectionInterface();
215 return iface->currentGamma();
216}
virtual qreal currentGamma() const =0

References KisExposureGammaCorrectionInterface::currentGamma(), d, and View::Private::view.

◆ operator!=()

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

Definition at line 55 of file View.cpp.

56{
57 return !(operator==(other));
58}
bool operator==(const View &other) const
Definition View.cpp:50

References operator==().

◆ operator==()

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

Definition at line 50 of file View.cpp.

51{
52 return (d->view == other.d->view);
53}

References d, and View::Private::view.

◆ paintingFlow

qreal View::paintingFlow ( ) const
slot

return the current flow for brush

Returns
the brush flow value

Definition at line 261 of file View.cpp.

262{
263 if (!d->view) return 0.0;
264 return d->view->resourceProvider()->flow();
265}

References d, and View::Private::view.

◆ paintingOpacity

qreal View::paintingOpacity ( ) const
slot

return the current opacity for brush

Returns
the brush opacity value (0.00=fully transparent - 1.00=fully opaque)

Definition at line 225 of file View.cpp.

226{
227 if (!d->view) return 0.0;
228 return d->view->resourceProvider()->opacity();
229}

References d, and View::Private::view.

◆ patternSize

qreal View::patternSize ( ) const
slot

return the current pattern size for brush

Returns
the brush pattern size value

Definition at line 273 of file View.cpp.

274{
275 if (!d->view) return 0.0;
276 return d->view->resourceProvider()->patternSize();
277}

References d, and View::Private::view.

◆ selectedNodes

QList< Node * > View::selectedNodes ( ) const
slot
   @brief selectedNodes returns a list of Nodes that are selected in this view.
from krita import *
w = Krita.instance().activeWindow()
v = w.activeView()
selected_nodes = v.selectedNodes()
print(selected_nodes)
Returns
a list of Node objects which may be empty.

Definition at line 334 of file View.cpp.

335{
336 if (!d->view) return QList<Node *>();
337 if (!d->view->viewManager()) return QList<Node *>();
338 if (!d->view->viewManager()->nodeManager()) return QList<Node *>();
339
340 KisNodeList selectedNodes = d->view->viewManager()->nodeManager()->selectedNodes();
342}
QList< Node * > selectedNodes() const
Definition View.cpp:334
QList< Node * > createNodeList(KisNodeList kisnodes, KisImageWSP image)

References LibKisUtils::createNodeList(), d, selectedNodes(), and View::Private::view.

◆ setBackGroundColor

void View::setBackGroundColor ( ManagedColor * color)
slot

Definition at line 146 of file View.cpp.

147{
148 if (!d->view) return;
149 d->view->resourceProvider()->setBGColor(color->color());
150}
KoColor color() const

References ManagedColor::color(), d, and View::Private::view.

◆ setBrushRotation

void View::setBrushRotation ( qreal brushRotation)
slot

set the current rotation for brush tip

Parameters
brushRotationthe brush tip rotation (in degrees)

Definition at line 255 of file View.cpp.

256{
257 if (!d->view) return;
258 d->view->resourceProvider()->setBrushRotation(brushRotation);
259}
qreal brushRotation() const
return the current rotation for brush tip
Definition View.cpp:249

References brushRotation(), d, and View::Private::view.

◆ setBrushSize

void View::setBrushSize ( qreal brushSize)
slot

set the current size for brush

Parameters
brushSizethe brush size (in pixels)

Definition at line 243 of file View.cpp.

244{
245 if (!d->view) return;
246 d->view->resourceProvider()->setSize(brushSize);
247}
qreal brushSize() const
return the current size for brush
Definition View.cpp:237

References brushSize(), d, and View::Private::view.

◆ setCurrentBlendingMode

void View::setCurrentBlendingMode ( const QString & blendingMode)
slot

set the current blending mode for brush

Parameters
blendingModethe current belding mode identifier

Definition at line 191 of file View.cpp.

192{
193 if (!d->view) return;
194 d->view->resourceProvider()->setCurrentCompositeOp(blendingMode);
195}

References d, and View::Private::view.

◆ setCurrentBrushPreset

void View::setCurrentBrushPreset ( Resource * resource)
slot

set the current selected preset

Parameters
resourcethe current preset to set (Resource type = 'preset')

Definition at line 158 of file View.cpp.

159{
160 activateResource(resource);
161}
void activateResource(Resource *resource)
activateResource activates the given resource.
Definition View.cpp:108

References activateResource().

◆ setCurrentGradient

void View::setCurrentGradient ( Resource * resource)
slot

set the current selected gradient

Parameters
resourcethe current gradient to set (Resource type = 'gradient')

Definition at line 180 of file View.cpp.

181{
182 activateResource(resource);
183}

References activateResource().

◆ setCurrentPattern

void View::setCurrentPattern ( Resource * resource)
slot

set the current selected pattern

Parameters
resourcethe current pattern to set (Resource type = 'pattern')

Definition at line 169 of file View.cpp.

170{
171 activateResource(resource);
172}

References activateResource().

◆ setDisablePressure

void View::setDisablePressure ( bool value)
slot

set current disabled pressure status

Parameters
valueSet to True to disable pressure, False to enabled pressure

Definition at line 325 of file View.cpp.

326{
327 if (!d->view) {
328 return;
329 }
330 d->view->resourceProvider()->setDisablePressure(value);
331}

References d, value(), and View::Private::view.

◆ setDocument

void View::setDocument ( Document * document)
slot

Reset the view to show document.

Definition at line 76 of file View.cpp.

77{
78 if (!d->view || !document || !document->document()) return;
79 d->view = d->view->replaceBy(document->document());
80}

References d, and View::Private::view.

◆ setEraserMode

void View::setEraserMode ( bool value)
slot

set current eraser active/inactive

Parameters
valueSet to True to activate eraser mode, False to deactivate

Definition at line 293 of file View.cpp.

294{
295 if (!d->view) {
296 return;
297 }
298 d->view->resourceProvider()->setEraserMode(value);
299}

References d, value(), and View::Private::view.

◆ setForeGroundColor

void View::setForeGroundColor ( ManagedColor * color)
slot

Definition at line 134 of file View.cpp.

135{
136 if (!d->view) return;
137 d->view->resourceProvider()->setFGColor(color->color());
138}

References ManagedColor::color(), d, and View::Private::view.

◆ setGlobalAlphaLock

void View::setGlobalAlphaLock ( bool value)
slot

set current global alpha lock mode active/inactive

Parameters
valueSet to True to lock global alpha mode, False to unlock

Definition at line 309 of file View.cpp.

310{
311 if (!d->view) {
312 return;
313 }
314 d->view->resourceProvider()->setGlobalAlphaLock(value);
315}

References d, value(), and View::Private::view.

◆ setHDRExposure

void View::setHDRExposure ( float exposure)
slot

set the current HDR Exposure value

Parameters
exposurethe HDR Exposure to set

Definition at line 204 of file View.cpp.

205{
206 if (!d->view) return;
207 KisExposureGammaCorrectionInterface *iface = d->view->canvasBase()->exposureGammaCorrectionInterface();
208 iface->setCurrentExposure(exposure);
209}
virtual void setCurrentExposure(qreal value)=0

References d, KisExposureGammaCorrectionInterface::setCurrentExposure(), and View::Private::view.

◆ setHDRGamma

void View::setHDRGamma ( float gamma)
slot

set the current HDR Gamma value

Parameters
exposurethe HDR Gamma to set

Definition at line 218 of file View.cpp.

219{
220 if (!d->view) return;
221 KisExposureGammaCorrectionInterface *iface = d->view->canvasBase()->exposureGammaCorrectionInterface();
222 return iface->setCurrentGamma(gamma);
223}
virtual void setCurrentGamma(qreal value)=0

References d, KisExposureGammaCorrectionInterface::setCurrentGamma(), and View::Private::view.

◆ setPaintingFlow

void View::setPaintingFlow ( qreal flow)
slot

set the current flow value for brush

Parameters
flowthe brush flow

Definition at line 267 of file View.cpp.

268{
269 if (!d->view) return;
270 d->view->resourceProvider()->setFlow(flow);
271}

References d, and View::Private::view.

◆ setPaintingOpacity

void View::setPaintingOpacity ( qreal opacity)
slot

set the current opacity for brush

Parameters
opacitythe opacity value (0.00=fully transparent - 1.00=fully opaque)

Definition at line 231 of file View.cpp.

232{
233 if (!d->view) return;
234 d->view->resourceProvider()->setOpacity(opacity);
235}

References d, and View::Private::view.

◆ setPatternSize

void View::setPatternSize ( qreal size)
slot

set the current pattern size value for brush

Parameters
flowthe brush pattern size

Definition at line 279 of file View.cpp.

280{
281 if (!d->view) return;
282 d->view->resourceProvider()->setPatternSize(size);
283}

References d, and View::Private::view.

◆ setVisible

void View::setVisible ( )
slot

Make the current view visible.

Definition at line 88 of file View.cpp.

89{
90 if (!d->view) return;
91 KisMainWindow *mainwin = d->view->mainWindow();
92 mainwin->setActiveView(d->view);
93 mainwin->subWindowActivated();
94}
Main window for Krita.
void setActiveView(KisView *view)
Set the active view, this will update the undo/redo actions.

References d, KisMainWindow::setActiveView(), KisMainWindow::subWindowActivated(), and View::Private::view.

◆ showFloatingMessage

void View::showFloatingMessage ( const QString & message,
const QIcon & icon,
int timeout,
int priority )
slot

showFloatingMessage displays a floating message box on the top-left corner of the canvas

Parameters
messageMessage to be displayed inside the floating message box
iconIcon to be displayed inside the message box next to the message string
timeoutMilliseconds until the message box disappears
priority0 = High, 1 = Medium, 2 = Low. Higher priority messages will be displayed in place of lower priority messages

Definition at line 344 of file View.cpp.

345{
346 if (!d->view) return;
347
349 p = static_cast<KisFloatingMessage::Priority>(priority);
350
351 d->view->showFloatingMessage(message, icon, timeout, p);
352}
const Params2D p

References d, p, and View::Private::view.

◆ view()

KisView * View::view ( )
private

Definition at line 103 of file View.cpp.

104{
105 return d->view;
106}

References d, and View::Private::view.

◆ visible

bool View::visible ( ) const
slot
Returns
True if the current view is visible, False if not.

Definition at line 82 of file View.cpp.

83{
84 if (!d->view) return false;
85 return d->view->isVisible();
86}

References d, and View::Private::view.

◆ window

Window * View::window ( ) const
slot
Returns
the window this view is shown in.

Definition at line 60 of file View.cpp.

61{
62 if (!d->view) return 0;
63 KisMainWindow *mainwin = d->view->mainWindow();
64 Window *win = new Window(mainwin);
65 return win;
66}
friend class Window
Definition View.h:347

References d, View::Private::view, and Window.

Friends And Related Symbol Documentation

◆ Scratchpad

friend class Scratchpad
friend

Definition at line 348 of file View.h.

◆ Window

friend class Window
friend

Definition at line 347 of file View.h.

Member Data Documentation

◆ d

Private* const View::d
private

Definition at line 354 of file View.h.


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