8#include <QScopedPointer>
11#include <KoAbstractGradient.h>
12#include <kis_paintop_preset.h>
14#include <KisViewManager.h>
15#include <kis_node_manager.h>
16#include <kis_selection_manager.h>
17#include <kis_canvas_resource_provider.h>
18#include <kis_exposure_gamma_correction_interface.h>
19#include <kis_paintop_box.h>
20#include <KisMainWindow.h>
21#include <KoCanvasBase.h>
22#include <kis_canvas2.h>
23#include <KisResourceTypes.h>
24#include <KisDocument.h>
29#include "ManagedColor.h"
31#include "LibKisUtils.h"
39View::View(KisView* view,
QObject *parent)
51bool View::operator==(
const View &other)
const
53 return (d->view == other.d->view);
56bool View::operator!=(
const View &other)
const
58 return !(operator==(other));
63 if (!d->view)
return 0;
64 KisMainWindow *mainwin = d->view->mainWindow();
72 if (!d->view)
return 0;
80 d->view = d->view->replaceBy(
document->document());
85 if (!d->view)
return false;
86 return d->view->isVisible();
92 KisMainWindow *mainwin = d->view->mainWindow();
93 mainwin->setActiveView(d->view);
94 mainwin->subWindowActivated();
99 if (!d->view)
return 0;
111 if (!d->view)
return;
112 if (!resource)
return;
114 KoResourceSP r = resource->resource();
117 if (KoPatternSP pattern = r.dynamicCast<KoPattern>()) {
119 d->view->canvasBase()->resourceManager()->setResource(KoCanvasResource::CurrentPattern, value);
120 }
else if (KoAbstractGradientSP gradient = r.dynamicCast<KoAbstractGradient>()) {
122 d->view->canvasBase()->resourceManager()->setResource(KoCanvasResource::CurrentGradient, value);
123 }
else if (KoResourceSP preset = r.dynamicCast<KisPaintOpPreset>()) {
124 d->view->viewManager()->paintOpBox()->resourceSelected(preset);
131 if (!d->view)
return 0;
132 return new ManagedColor(d->view->resourceProvider()->fgColor());
137 if (!d->view)
return;
138 d->view->resourceProvider()->setFGColor(color->color());
143 if (!d->view)
return 0;
144 return new ManagedColor(d->view->resourceProvider()->bgColor());
149 if (!d->view)
return;
150 d->view->resourceProvider()->setBGColor(color->color());
155 if (!d->view)
return 0;
156 return new Resource(d->view->resourceProvider()->currentPreset(), ResourceType::PaintOpPresets);
166 if (!d->view)
return 0;
167 return new Resource(d->view->resourceProvider()->currentPattern(), ResourceType::Patterns);
177 if (!d->view)
return 0;
178 return new Resource(d->view->resourceProvider()->currentGradient(), ResourceType::Gradients);
188 if (!d->view)
return "";
189 return d->view->resourceProvider()->currentCompositeOp();
194 if (!d->view)
return;
195 d->view->resourceProvider()->setCurrentCompositeOp(blendingMode);
200 if (!d->view)
return 0.0;
201 KisExposureGammaCorrectionInterface *iface = d->view->canvasBase()->exposureGammaCorrectionInterface();
202 return iface->currentExposure();
207 if (!d->view)
return;
208 KisExposureGammaCorrectionInterface *iface = d->view->canvasBase()->exposureGammaCorrectionInterface();
209 iface->setCurrentExposure(exposure);
214 if (!d->view)
return 0.0;
215 KisExposureGammaCorrectionInterface *iface = d->view->canvasBase()->exposureGammaCorrectionInterface();
216 return iface->currentGamma();
221 if (!d->view)
return;
222 KisExposureGammaCorrectionInterface *iface = d->view->canvasBase()->exposureGammaCorrectionInterface();
223 return iface->setCurrentGamma(gamma);
228 if (!d->view)
return 0.0;
229 return d->view->resourceProvider()->opacity();
234 if (!d->view)
return;
235 d->view->resourceProvider()->setOpacity(opacity);
240 if (!d->view)
return 0.0;
241 return d->view->resourceProvider()->size();
246 if (!d->view)
return;
247 d->view->resourceProvider()->setSize(
brushSize);
252 if (!d->view)
return 0.0;
253 return d->view->resourceProvider()->brushRotation();
258 if (!d->view)
return;
259 d->view->resourceProvider()->setBrushRotation(
brushRotation);
264 if (!d->view)
return 0.0;
265 return d->view->resourceProvider()->flow();
270 if (!d->view)
return;
271 d->view->resourceProvider()->setFlow(flow);
276 if (!d->view)
return 0.0;
277 return d->view->resourceProvider()->patternSize();
282 if (!d->view)
return;
283 d->view->resourceProvider()->setPatternSize(size);
291 return d->view->resourceProvider()->eraserMode();
299 d->view->resourceProvider()->setEraserMode(value);
307 return d->view->resourceProvider()->globalAlphaLock();
315 d->view->resourceProvider()->setGlobalAlphaLock(value);
323 return d->view->resourceProvider()->disablePressure();
331 d->view->resourceProvider()->setDisablePressure(value);
339 if (!d->view->viewManager()->nodeManager())
return QList<Node *>();
341 KisNodeList
selectedNodes = d->view->viewManager()->nodeManager()->selectedNodes();
342 return LibKisUtils::createNodeList(
selectedNodes, d->view->image());
347 if (!d->view)
return;
349 KisFloatingMessage::Priority p;
350 p =
static_cast<KisFloatingMessage::Priority
>(priority);
352 d->view->showFloatingMessage(message, icon, timeout, p);
357 if (!d->view->document())
return QTransform();
358 return d->view->canvasBase()->coordinatesConverter()->documentToFlakeTransform().inverted();
363 if (!d->view->document())
return QTransform();
364 return d->view->canvasBase()->coordinatesConverter()->flakeToWidgetTransform();
369 if (!d->view->document())
return QTransform();
371 const KisCoordinatesConverter* coordinatesConverter(d->view->canvasBase()->coordinatesConverter());
372 QTransform imageToFlakeTransform = coordinatesConverter->imageToDocumentTransform() * coordinatesConverter->documentToFlakeTransform();
374 return imageToFlakeTransform.
inverted();
Canvas wraps the canvas inside a view on an image/document.
The Document class encapsulates a Krita Document/Image.
The ManagedColor class is a class to handle colors that are color managed.
A Resource represents a gradient, pattern, brush tip, brush preset, palette or workspace definition.
View represents one view on a document.
void setBrushRotation(qreal brushRotation)
set the current rotation for brush tip
float HDRExposure() const
bool eraserMode() const
return current eraser mode status (active/inactive)
void setHDRGamma(float gamma)
set the current HDR Gamma value
bool globalAlphaLock() const
return current global alpha lock mode (active/inactive)
qreal patternSize() const
return the current pattern size for brush
void setBrushSize(qreal brushSize)
set the current size for brush
void setCurrentBrushPreset(Resource *resource)
set the current selected preset
void setDisablePressure(bool value)
set current disabled pressure status
void setGlobalAlphaLock(bool value)
set current global alpha lock mode active/inactive
qreal paintingFlow() const
return the current flow for brush
void setDocument(Document *document)
Reset the view to show document.
void setCurrentPattern(Resource *resource)
set the current selected pattern
ManagedColor * foregroundColor() const
foregroundColor allows access to the currently active foreground color.
Resource * currentPattern() const
return the current selected pattern
void setCurrentBlendingMode(const QString &blendingMode)
set the current blending mode for brush
ManagedColor * backgroundColor() const
backgroundColor allows access to the currently active background color.
QTransform flakeToCanvasTransform() const
flakeToCanvasTransform The transformation of the canvas relative to the view without rotation and mir...
QString currentBlendingMode() const
return the current blending mode for brush
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
void setPaintingOpacity(qreal opacity)
set the current opacity for brush
QTransform flakeToImageTransform() const
flakeToImageTransform The transformation of the image relative to the view without rotation and mirro...
qreal paintingOpacity() const
return the current opacity for brush
void activateResource(Resource *resource)
activateResource activates the given resource.
void setHDRExposure(float exposure)
set the current HDR Exposure value
qreal brushRotation() const
return the current rotation for brush tip
void setPatternSize(qreal size)
set the current pattern size value for brush
QList< Node * > selectedNodes() const
Resource * currentBrushPreset() const
return the current selected preset
void setPaintingFlow(qreal flow)
set the current flow value for brush
QTransform flakeToDocumentTransform() const
flakeToDocumentTransform The transformation of the document relative to the view without rotation and...
void setEraserMode(bool value)
set current eraser active/inactive
Resource * currentGradient() const
return the current selected gradient
void setVisible()
Make the current view visible.
void setCurrentGradient(Resource *resource)
set the current selected gradient
Document * document() const
qreal brushSize() const
return the current size for brush
bool disablePressure() const
return current disabled pressure status
Window represents one Krita mainwindow.
QVariant fromValue(T &&value)