11#include <klocalizedstring.h>
72 bool makeSharpClip =
false,
90 const bool needsTransparentPixel = selection && rc != image->
bounds() && hasNonTransparentDefaultPixel;
110 qreal newAlpha = sel * dstAlpha / (1.0 - dstAlpha + sel * dstAlpha);
111 float mask = newAlpha / dstAlpha;
122 if ( needsTransparentPixel ) {
167 SelectAll(
KisImageSP image) : m_image(image) {}
192 KisImageBarrierLock lock(image, std::try_to_lock);
193 if (!lock.owns_lock())
return;
227 bool usePattern =
false;
228 bool useBgColor =
false;
229 if (fillSource.contains(
"pattern")) {
231 }
else if (fillSource.contains(
"bg")) {
237 if (!fillSource.contains(
"opacity")) {
295 if (!selection)
return;
309 const auto currentToolHasSelection =
312 const bool haveShapesSelected =
317 const bool skipShapes = selection && !currentToolHasSelection;
319 if (!skipShapes && !flags.testFlag(
SharpClip) && (haveShapesSelected || currentToolHasSelection)) {
327 KisImageBarrierLock lock(image, std::try_to_lock);
328 if (!lock.owns_lock())
return;
335 }
else if (selection) {
339 Q_FOREACH (
KisNodeSP node, selectedNodes) {
340 if (node->inherits(
"KisMask")) {
348 Q_FOREACH (
KisNodeSP node, selectedNodes) {
350 if (node->inherits(
"KisShapeLayer") || node->inherits(
"KisFileLayer")) {
355 dupNode = node->
clone();
357 nodes.append(dupNode);
363 node->paintDevice()->burnKeyframe();
374 if (node && node->
paintDevice() && !node->inherits(
"KisMask")) {
390 selectedNodes.append(masks);
391 Q_FOREACH (
KisNodeSP node, selectedNodes) {
399 if (node->inherits(
"KisMask") && !masks.contains(node)) {
405 : m_node(node), m_sel(sel) {}
435 KUndo2Command *command =
new ClearSelection(node, selection);
489 "Selection is already in a vector format "),
501 QPainterPath selectionOutline = selection->
outlineCache();
529 "Selection is already in a raster format "),
561 bool hasSelectionShapes =
false;
564 Q_FOREACH (
KoShape *shape, originalShapes) {
566 hasSelectionShapes =
true;
573 if (clonedShapes.isEmpty()) {
574 if (hasSelectionShapes) {
576 "The shape already belongs to a selection"),
593 QPainterPath selectionOutline = selection->
outlineCache();
630 if (!currentNode->inherits(
"KisShapeLayer") && currentNode->
paintDevice()) {
643 QPen pen(Qt::red, size);
644 pen.setJoinStyle(Qt::RoundJoin);
653 else if (currentNode->inherits(
"KisShapeLayer")) {
686 if (!currentNode->inherits(
"KisShapeLayer") && currentNode->
paintDevice())
const quint8 OPACITY_OPAQUE_U8
void setOutDirtyRect(QSharedPointer< QRect > outDirtyRect)
void setSeedPoint(const QPoint &seedPoint)
void setSelectionOnly(bool selectionOnly)
void setUseBgColor(bool useBgColor)
void setUsePattern(bool usePattern)
KUndo2MagicString text() const
KisCoordinatesConverter * coordinatesConverter
KoShapeManager shapeManager
KoCanvasResourceProvider * resourceManager()
void setLayers(KisNodeList nodes, KisImageSP image, bool forceCopy=false)
static KisClipboard * instance()
QTransform imageToDocumentTransform() const
void refreshGraphAsync(KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override
const KoColorSpace * colorSpace() const
KisImageAnimationInterface * animationInterface() const
void barrierLock(bool readOnly=false)
Wait until all the queued background jobs are completed and lock the image.
void addJob(KisStrokeId id, KisStrokeJobData *data) override
void cropImage(const QRect &newRect)
start asynchronous operation on cropping the image
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
KisSelectionSP globalSelection() const
QRect bounds() const override
void addSpontaneousJob(KisSpontaneousJob *spontaneousJob)
void endStroke(KisStrokeId id) override
void setResolution(double xres, double yres)
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
virtual KisTimeSpan affectedFrames(int time) const
Get the set of frames affected by any changes to the value or content of the active keyframe at the g...
KisNodeList selectedNodes()
void cutLayersToClipboard()
void copyLayersToClipboard()
KisProcessingApplicator * beginAction(KisViewManager *view, const KUndo2MagicString &actionName)
void endAction(KisProcessingApplicator *applicator, const QString &xmlData)
void crop(qint32 x, qint32 y, qint32 w, qint32 h)
void setDefaultPixel(const KoColor &defPixel)
void purgeDefaultPixels()
const KoColorSpace * colorSpace() const
void clearSelection(KisSelectionSP selection)
KoColor defaultPixel() const
static void runSingleCommandStroke(KisImageSP image, KUndo2Command *cmd, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
runSingleCommandStroke creates a stroke and runs cmd in it. The text() field of cmd is used as a titl...
void applyCommand(KUndo2Command *command, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
void setOpacity(qreal opacity)
bool haveShapesSelected()
ALWAYS_INLINE quint8 * rawData()
ALWAYS_INLINE const quint8 * oldRawData() const
void setSupportsWrapAroundMode(bool value)
KUndo2Command * endAndTake()
bool blockUntilOperationsFinished(KisImageSP image)
blockUntilOperationsFinished blocks the GUI of the application until execution of actions on image is...
KisCanvas2 * canvasBase() const
Return the canvas base class.
KisSelectionSP selection()
KisNodeManager * nodeManager() const
The node manager handles everything about nodes.
KisSelectionManager * selectionManager()
KisImageWSP image() const
Return the image this view is displaying.
KisCanvasResourceProvider * canvasResourceProvider()
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
QPointer< KoShapeController > shapeController
QPointer< KoCanvasResourceProvider > resourceManager
QVariant resource(int key) const
virtual void applyAlphaU8Mask(quint8 *pixels, const quint8 *alpha, qint32 nPixels) const =0
virtual qreal opacityF(const quint8 *pixel) const =0
virtual void applyAlphaNormedFloatMask(quint8 *pixels, const float *alpha, qint32 nPixels) const =0
static KoColor createTransparent(const KoColorSpace *cs)
void toQColor(QColor *c) const
a convenience method for the above.
static KoPathShape * createShapeFromPainterPath(const QPainterPath &path)
Creates path shape from given QPainterPath.
const QList< KoShape * > selectedShapes() const
KoShapeUserData * userData() const
KoShape * cloneShapeAndBakeAbsoluteTransform() const
creates a deep copy of the shape/shapes tree and bakes the absolute transform of this into the result...
virtual void setStroke(KoShapeStrokeModelSP stroke)
void setUserData(KoShapeUserData *userData)
void setShapeId(const QString &id)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
QSharedPointer< KUndo2Command > KUndo2CommandSP
KUndo2MagicString kundo2_i18n(const char *text)
KisImageSP makeImage(KisViewManager *view, KisNodeList nodes)
void trimDevice(KisViewManager *view, KisPaintDeviceSP device, bool makeSharpClip=false, const KisTimeSpan &range=KisTimeSpan())
KisNodeList sortAndFilterMergeableInternalNodes(KisNodeList nodes, bool allowMasks)
void recursiveApplyNodes(NodePointer node, Functor func)
@ ForegroundColor
The active foreground color selected for this canvas.
virtual KisPaintDeviceSP projection() const =0
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)
virtual KisPaintDeviceSP paintDevice() const =0
bool hasEditablePaintDevice() const
void run(KisViewManager *view) override
The LambdaCommand struct is a shorthand for creation of AggregateCommand commands using C++ lambda fe...
void run(KisViewManager *view) override
void run(Flags flags, KisViewManager *view)
void run(KisViewManager *view) override
void run(const QString &fillSource, KisViewManager *view)
void runFilter(KisSelectionFilter *filter, KisViewManager *view, const KisOperationConfiguration &config)
void run(KisViewManager *view) override
void runFromXML(KisViewManager *view, const KisOperationConfiguration &config) override
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
virtual KisNodeSP clone() const =0
QPainterPath outlineCache
void recalculateOutlineCache() override
void clear(const QRect &r)
void select(const QRect &r, quint8 selectedness=MAX_SELECTED)
void toXML(QDomDocument &, QDomElement &) const override
virtual void setProperty(const QString &name, const QVariant &value)
void run(KisViewManager *view) override
void run(KisViewManager *view) override
void run(KisViewManager *view) override
void run(KisViewManager *view) override
void run(KisViewManager *view) override
KisPixelSelectionSP projection() const
bool outlineCacheValid() const
KisPixelSelectionSP pixelSelection
QRect selectedRect() const
bool hasShapeSelection() const
QRect selectedExactRect() const
Slow, but exact way of determining the rectangle that encloses the selection.
QPainterPath outlineCache() const
void run(KisViewManager *view) override
void run(KisViewManager *view, const StrokeSelectionOptions ¶ms)
void run(KisViewManager *view, const StrokeSelectionOptions ¶ms)
KisToolShapeUtils::FillStyle fillStyle() const