15#include <kconfiggroup.h>
16#include <ksharedconfig.h>
22#include <QPainterPath>
37#include <QApplication>
42 KoColor const *
const blendColor,
int radius,
int blend,
bool pure)
48 static bool firstTime =
true;
49 if (firstTime ==
true) {
62 if (!pure && radius > 1) {
66 const int effectiveRadius = radius - 1;
68 const QRect sampleRect(pos.x() - effectiveRadius, pos.y() - effectiveRadius,
69 2 * effectiveRadius + 1, 2 * effectiveRadius + 1);
72 const int radiusSq =
pow2(effectiveRadius);
76 const QPoint realPos(it.
x(), it.
y());
78 mixer->accumulateAverage(it.
oldRawData(), nConseqPixels);
82 mixer->computeMixedColor(sampledColor.
data());
85 dev->
pixel(pos.x(), pos.y(), &sampledColor);
91 if (!pure && blendColor && blend < 100) {
93 quint8 blendScaled =
static_cast<quint8
>(blend * 2.55f);
95 const quint8 *colors[2];
96 colors[0] = blendColor->
data();
97 colors[1] = sampledColor.
data();
99 weights[0] = 255 - blendScaled;
100 weights[1] = blendScaled;
110 if (validColorSampled) {
111 out_color = sampledColor;
114 return validColorSampled;
134 if (layer->inherits(
"KisGroupLayer") && (!editableOnly || layer->
isEditable())) {
139 foundNode = !wholeGroup ? node : node->
parent();
144 if (foundNode)
break;
171 foundNodes <<
findNodes(node->
firstChild(), point, wholeGroup, includeGroups, editableOnly);
177 if (!isTransparent) {
179 if (!foundNodes.contains(node->
parent())) {
180 foundNodes << node->
parent();
199 if (node->inherits(
"KisMask")) {
208 if (nodes.isEmpty()) {
219 if (node->inherits(
"KisMask") && !masks.contains(node)) {
225 new KisCommandUtils::LambdaCommand(kundo2_i18n(
"Clear"),
226 [node, selection] () {
227 KisPaintDeviceSP device = node->paintDevice();
229 std::unique_ptr<KisCommandUtils::CompositeCommand> parentCommand(
230 new KisCommandUtils::CompositeCommand());
232 KUndo2Command *autoKeyframeCommand = KisAutoKey::tryAutoCreateDuplicatedFrame(device);
233 if (autoKeyframeCommand) {
234 parentCommand->addCommand(autoKeyframeCommand);
237 KisTransaction transaction(kundo2_noi18n(
"internal-clear-command"), device);
241 dirtyRect = selection->selectedRect();
242 device->clearSelection(selection);
244 dirtyRect = device->extent();
248 device->setDirty(dirtyRect);
249 parentCommand->addCommand(transaction.endAndTake());
251 return parentCommand.release();
263 const QString ColorSamplerConfig::CONFIG_GROUP_NAME =
"tool_color_sampler";
265 ColorSamplerConfig::ColorSamplerConfig()
266 : toForegroundColor(true)
268 , addColorToCurrentPalette(false)
269 , normaliseValues(false)
289 config.writeEntry(
"ColorSamplerDefaultActivation", props.
toXML());
297 props.
fromXML(config.readEntry(
"ColorSamplerDefaultActivation"));
311 QScreen *screen = qApp->screenAt(point);
313 screen = qApp->primaryScreen();
315 QCursor::setPos(screen, point);
326 Qt::AlignLeft | Qt::TextWordWrap | Qt::AlignVCenter);
334 if ((node->
isEditable(
true) && editableOnly) || !editableOnly) {
336 KisShapeLayerSP shapeLayer = dynamic_cast<KisShapeLayer*>(node.data());
337 if (shapeLayer && shapeLayer->isEditable() && shapeLayer->shapeManager()->shapeAt(point)) {
338 foundNodes.append(shapeLayer);
349 if (!canvas2)
return p;
353 KisShapeLayerSP shapeLayer = candidates.isEmpty()?
nullptr: candidates.last();
357 if (shape && !(currentShapes.contains(shape) && skipCurrentShapes)) {
370 paths.addPath(path->absoluteTransformation().map(path->outline()));
373 if (!paths.isEmpty()) {
389 if (!canvas2)
return false;
393 KisShapeLayerSP shapeLayer = candidates.isEmpty()?
nullptr: candidates.last();
398 && !(currentShapes.contains(shape) && skipCurrentShapes)
399 && (shapeType.isEmpty() || shapeType == shape->
shapeId())) {
417 if (!node->
isEditable(
true) || blockedNoIndirectPainting) {
419 message = i18n(
"Layer is locked and invisible.");
421 message = i18n(
"Layer is locked.");
423 message = i18n(
"Layer is invisible.");
424 }
else if (blockedNoIndirectPainting) {
425 message = i18n(
"Layer can be painted in Wash Mode only.");
427 message = i18n(
"Group not editable.");
436 int brushSize = minSize;
439 int increment = qMax(1,
int(std::ceil(qreal(brushSize) / 15)));
440 brushSize += increment;
441 }
while (brushSize < maxSize);
447 std::vector<int>::iterator result = std::upper_bound(
m_sizes.begin(),
m_sizes.end(), qRound(size));
453 std::vector<int>::reverse_iterator result =
454 std::upper_bound(
m_sizes.rbegin(),
m_sizes.rend(), qRound(size), std::greater<int>());
QVector< KisImageSignalType > KisImageSignalVector
const quint8 OPACITY_TRANSPARENT_U8
KisImageWSP image() const
KoShapeManager shapeManager
KisViewManager * viewManager() const
void slotNonUiActivatedNode(KisNodeSP node)
bool supportsWraproundMode() const
virtual const KoColorSpace * compositionSourceColorSpace() const
const KoColorSpace * colorSpace() const
void setSupportsWraparoundMode(bool value)
bool pixel(qint32 x, qint32 y, QColor *c) const
void applyCommand(KUndo2Command *command, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
bool nextPixels(int numPixels)
ALWAYS_INLINE int x() const
int nConseqPixels() const
ALWAYS_INLINE const quint8 * oldRawData() const
ALWAYS_INLINE int y() const
KoShapeManager * shapeManager() const
KisNodeManager * nodeManager() const
The node manager handles everything about nodes.
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
virtual KoShapeManager * shapeManager() const =0
KoMixColorsOp * mixColorsOp
void convertTo(const KoColorSpace *cs, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
static KoColor createTransparent(const KoColorSpace *cs)
virtual Mixer * createMixer() const =0
virtual void mixColors(const quint8 *const *colors, const qint16 *weights, int nColors, quint8 *dst, int weightSum=255) const =0
The position of a path point within a path shape.
void deselectAll()
clear the selections list
void select(KoShape *shape)
const QList< KoShape * > selectedShapes() const
KoShape * shapeAt(const QPointF &position, KoFlake::ShapeSelection selection=KoFlake::ShapeOnTop, bool omitHiddenShapes=true)
virtual QPainterPath outline() const
QTransform absoluteTransformation() const
QRectF boundingRect() const override
Get the bounding box of the shape.
QList< KoShape * > shapesInside
KoSvgText::WritingMode writingMode() const
writingMode There's a number of places we need to check the writing mode to provide proper controls.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
qreal kisSquareDistance(const QPointF &pt1, const QPointF &pt2)
KUndo2MagicString kundo2_i18n(const char *text)
void recursiveApplyNodes(NodePointer node, Functor func)
void filterMergeableNodes(KisNodeList &nodes, bool allowMasks)
bool isEditable(bool checkVisibility=true) const
virtual bool visible(bool recursive=false) const
bool hasEditablePaintDevice() const
KisPaintDeviceSP projection() const override
KisNodeSP prevSibling() const
KisNodeSP firstChild() const
KisNodeSP lastChild() const
KisNodeSP nextSibling() const
void toXML(QDomDocument &, QDomElement &) const override
bool fromXML(const QString &xml, bool clear=true) override
virtual void setProperty(const QString &name, const QVariant &value)
bool getBool(const QString &name, bool def=false) const
int getInt(const QString &name, int def=0) const