15#include <kconfiggroup.h>
16#include <ksharedconfig.h>
22#include <QPainterPath>
38#include <QApplication>
43 KoColor const *
const blendColor,
int radius,
int blend,
bool pure)
49 static bool firstTime =
true;
50 if (firstTime ==
true) {
63 if (!pure && radius > 1) {
67 const int effectiveRadius = radius - 1;
69 const QRect sampleRect(pos.x() - effectiveRadius, pos.y() - effectiveRadius,
70 2 * effectiveRadius + 1, 2 * effectiveRadius + 1);
73 const int radiusSq =
pow2(effectiveRadius);
77 const QPoint realPos(it.
x(), it.
y());
79 mixer->accumulateAverage(it.
oldRawData(), nConseqPixels);
83 mixer->computeMixedColor(sampledColor.
data());
86 dev->
pixel(pos.x(), pos.y(), &sampledColor);
92 if (!pure && blendColor && blend < 100) {
94 quint8 blendScaled =
static_cast<quint8
>(blend * 2.55f);
96 const quint8 *colors[2];
97 colors[0] = blendColor->
data();
98 colors[1] = sampledColor.
data();
100 weights[0] = 255 - blendScaled;
101 weights[1] = blendScaled;
111 if (validColorSampled) {
112 out_color = sampledColor;
115 return validColorSampled;
135 if (layer->inherits(
"KisGroupLayer") && (!editableOnly || layer->
isEditable())) {
140 foundNode = !wholeGroup ? node : node->
parent();
145 if (foundNode)
break;
172 foundNodes <<
findNodes(node->
firstChild(), point, wholeGroup, includeGroups, editableOnly);
178 if (!isTransparent) {
180 if (!foundNodes.contains(node->
parent())) {
181 foundNodes << node->
parent();
200 if (node->inherits(
"KisMask")) {
209 if (nodes.isEmpty()) {
220 if (node->inherits(
"KisMask") && !masks.contains(node)) {
226 new KisCommandUtils::LambdaCommand(kundo2_i18n(
"Clear"),
227 [node, selection] () {
228 KisPaintDeviceSP device = node->paintDevice();
230 QScopedPointer<KisCommandUtils::CompositeCommand> parentCommand(
231 new KisCommandUtils::CompositeCommand());
233 KUndo2Command *autoKeyframeCommand = KisAutoKey::tryAutoCreateDuplicatedFrame(device);
234 if (autoKeyframeCommand) {
235 parentCommand->addCommand(autoKeyframeCommand);
238 KisTransaction transaction(kundo2_noi18n(
"internal-clear-command"), device);
242 dirtyRect = selection->selectedRect();
243 device->clearSelection(selection);
245 dirtyRect = device->extent();
249 device->setDirty(dirtyRect);
250 parentCommand->addCommand(transaction.endAndTake());
252 return parentCommand.take();
264 const QString ColorSamplerConfig::CONFIG_GROUP_NAME =
"tool_color_sampler";
266 ColorSamplerConfig::ColorSamplerConfig()
267 : toForegroundColor(true)
269 , addColorToCurrentPalette(false)
270 , normaliseValues(false)
290 config.writeEntry(
"ColorSamplerDefaultActivation", props.
toXML());
298 props.
fromXML(config.readEntry(
"ColorSamplerDefaultActivation"));
312 QScreen *screen = qApp->screenAt(point);
314 screen = qApp->primaryScreen();
316 QCursor::setPos(screen, point);
324 if ((node->
isEditable(
true) && editableOnly) || !editableOnly) {
326 KisShapeLayerSP shapeLayer = dynamic_cast<KisShapeLayer*>(node.data());
327 if (shapeLayer && shapeLayer->isEditable() && shapeLayer->shapeManager()->shapeAt(point)) {
328 foundNodes.append(shapeLayer);
339 if (!canvas2)
return p;
343 KisShapeLayerSP shapeLayer = candidates.isEmpty()?
nullptr: candidates.last();
347 if (shape && !(currentShapes.contains(shape) && skipCurrentShapes)) {
360 paths.addPath(path->absoluteTransformation().map(path->outline()));
363 if (!paths.isEmpty()) {
379 if (!canvas2)
return false;
383 KisShapeLayerSP shapeLayer = candidates.isEmpty()?
nullptr: candidates.last();
388 && !(currentShapes.contains(shape) && skipCurrentShapes)
389 && (shapeType.isEmpty() || shapeType == shape->
shapeId())) {
414 actions << actionRegistry->
makeQAction(
"movetool-move-up", actionRegistry);
415 actions << actionRegistry->
makeQAction(
"movetool-move-down", actionRegistry);
416 actions << actionRegistry->
makeQAction(
"movetool-move-left", actionRegistry);
417 actions << actionRegistry->
makeQAction(
"movetool-move-right", actionRegistry);
419 actions << actionRegistry->
makeQAction(
"movetool-move-up-more", actionRegistry);
420 actions << actionRegistry->
makeQAction(
"movetool-move-down-more", actionRegistry);
421 actions << actionRegistry->
makeQAction(
"movetool-move-left-more", actionRegistry);
422 actions << actionRegistry->
makeQAction(
"movetool-move-right-more", actionRegistry);
float value(const T *src, size_t ch)
QVector< KisImageSignalType > KisImageSignalVector
const quint8 OPACITY_TRANSPARENT_U8
QAction * makeQAction(const QString &name, QObject *parent=0)
static KisActionRegistry * instance()
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