15#include <kconfiggroup.h>
16#include <ksharedconfig.h>
22#include <QPainterPath>
36#include <QApplication>
41 KoColor const *
const blendColor,
int radius,
int blend,
bool pure)
47 static bool firstTime =
true;
48 if (firstTime ==
true) {
61 if (!pure && radius > 1) {
65 const int effectiveRadius = radius - 1;
67 const QRect sampleRect(pos.x() - effectiveRadius, pos.y() - effectiveRadius,
68 2 * effectiveRadius + 1, 2 * effectiveRadius + 1);
71 const int radiusSq =
pow2(effectiveRadius);
75 const QPoint realPos(it.
x(), it.
y());
77 mixer->accumulateAverage(it.
oldRawData(), nConseqPixels);
81 mixer->computeMixedColor(sampledColor.
data());
84 dev->
pixel(pos.x(), pos.y(), &sampledColor);
90 if (!pure && blendColor && blend < 100) {
92 quint8 blendScaled =
static_cast<quint8
>(blend * 2.55f);
94 const quint8 *colors[2];
95 colors[0] = blendColor->
data();
96 colors[1] = sampledColor.
data();
98 weights[0] = 255 - blendScaled;
99 weights[1] = blendScaled;
109 if (validColorSampled) {
110 out_color = sampledColor;
113 return validColorSampled;
133 if (layer->inherits(
"KisGroupLayer") && (!editableOnly || layer->
isEditable())) {
138 foundNode = !wholeGroup ? node : node->
parent();
143 if (foundNode)
break;
170 foundNodes <<
findNodes(node->
firstChild(), point, wholeGroup, includeGroups, editableOnly);
176 if (!isTransparent) {
178 if (!foundNodes.contains(node->
parent())) {
179 foundNodes << node->
parent();
198 if (node->inherits(
"KisMask")) {
207 if (nodes.isEmpty()) {
218 if (node->inherits(
"KisMask") && !masks.contains(node)) {
224 new KisCommandUtils::LambdaCommand(kundo2_i18n(
"Clear"),
225 [node, selection] () {
226 KisPaintDeviceSP device = node->paintDevice();
228 QScopedPointer<KisCommandUtils::CompositeCommand> parentCommand(
229 new KisCommandUtils::CompositeCommand());
231 KUndo2Command *autoKeyframeCommand = KisAutoKey::tryAutoCreateDuplicatedFrame(device);
232 if (autoKeyframeCommand) {
233 parentCommand->addCommand(autoKeyframeCommand);
236 KisTransaction transaction(kundo2_noi18n(
"internal-clear-command"), device);
240 dirtyRect = selection->selectedRect();
241 device->clearSelection(selection);
243 dirtyRect = device->extent();
247 device->setDirty(dirtyRect);
248 parentCommand->addCommand(transaction.endAndTake());
250 return parentCommand.take();
262 const QString ColorSamplerConfig::CONFIG_GROUP_NAME =
"tool_color_sampler";
264 ColorSamplerConfig::ColorSamplerConfig()
265 : toForegroundColor(true)
267 , addColorToCurrentPalette(false)
268 , normaliseValues(false)
288 config.writeEntry(
"ColorSamplerDefaultActivation", props.
toXML());
296 props.
fromXML(config.readEntry(
"ColorSamplerDefaultActivation"));
310 QScreen *screen = qApp->screenAt(point);
312 screen = qApp->primaryScreen();
314 QCursor::setPos(screen, point);
322 if ((node->
isEditable(
true) && editableOnly) || !editableOnly) {
324 KisShapeLayerSP shapeLayer = dynamic_cast<KisShapeLayer*>(node.data());
325 if (shapeLayer && shapeLayer->isEditable() && shapeLayer->shapeManager()->shapeAt(point)) {
326 foundNodes.append(shapeLayer);
337 if (!canvas2)
return p;
341 KisShapeLayerSP shapeLayer = candidates.isEmpty()?
nullptr: candidates.last();
345 if (shape && !(currentShapes.contains(shape) && skipCurrentShapes)) {
348 if (t && isHorizontal) {
359 if (!paths.isEmpty()) {
375 if (!canvas2)
return false;
379 KisShapeLayerSP shapeLayer = candidates.isEmpty()?
nullptr: candidates.last();
384 && !(currentShapes.contains(shape) && skipCurrentShapes)
385 && (shapeType.isEmpty() || shapeType == shape->
shapeId())) {
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.
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.
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
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