15#include <kconfiggroup.h>
16#include <ksharedconfig.h>
22#include <QPainterPath>
39#include <QApplication>
44 KoColor const *
const blendColor,
int radius,
int blend,
bool pure)
50 static bool firstTime =
true;
51 if (firstTime ==
true) {
64 if (!pure && radius > 1) {
68 const int effectiveRadius = radius - 1;
70 const QRect sampleRect(pos.x() - effectiveRadius, pos.y() - effectiveRadius,
71 2 * effectiveRadius + 1, 2 * effectiveRadius + 1);
74 const int radiusSq =
pow2(effectiveRadius);
78 const QPoint realPos(it.
x(), it.
y());
80 mixer->accumulateAverage(it.
oldRawData(), nConseqPixels);
84 mixer->computeMixedColor(sampledColor.
data());
87 dev->
pixel(pos.x(), pos.y(), &sampledColor);
93 if (!pure && blendColor && blend < 100) {
95 quint8 blendScaled =
static_cast<quint8
>(blend * 2.55f);
97 const quint8 *colors[2];
98 colors[0] = blendColor->
data();
99 colors[1] = sampledColor.
data();
101 weights[0] = 255 - blendScaled;
102 weights[1] = blendScaled;
112 if (validColorSampled) {
113 out_color = sampledColor;
116 return validColorSampled;
136 if (layer->inherits(
"KisGroupLayer") && (!editableOnly || layer->
isEditable())) {
141 foundNode = !wholeGroup ? node : node->
parent();
146 if (foundNode)
break;
173 foundNodes <<
findNodes(node->
firstChild(), point, wholeGroup, includeGroups, editableOnly);
179 if (!isTransparent) {
181 if (!foundNodes.contains(node->
parent())) {
182 foundNodes << node->
parent();
201 if (node->inherits(
"KisMask")) {
210 if (nodes.isEmpty()) {
221 if (node->inherits(
"KisMask") && !masks.contains(node)) {
227 new KisCommandUtils::LambdaCommand(kundo2_i18n(
"Clear"),
228 [node, selection] () {
229 KisPaintDeviceSP device = node->paintDevice();
231 QScopedPointer<KisCommandUtils::CompositeCommand> parentCommand(
232 new KisCommandUtils::CompositeCommand());
234 KUndo2Command *autoKeyframeCommand = KisAutoKey::tryAutoCreateDuplicatedFrame(device);
235 if (autoKeyframeCommand) {
236 parentCommand->addCommand(autoKeyframeCommand);
239 KisTransaction transaction(kundo2_noi18n(
"internal-clear-command"), device);
243 dirtyRect = selection->selectedRect();
244 device->clearSelection(selection);
246 dirtyRect = device->extent();
250 device->setDirty(dirtyRect);
251 parentCommand->addCommand(transaction.endAndTake());
253 return parentCommand.take();
265 const QString ColorSamplerConfig::CONFIG_GROUP_NAME =
"tool_color_sampler";
267 ColorSamplerConfig::ColorSamplerConfig()
268 : toForegroundColor(true)
270 , addColorToCurrentPalette(false)
271 , normaliseValues(false)
291 config.writeEntry(
"ColorSamplerDefaultActivation", props.
toXML());
299 props.
fromXML(config.readEntry(
"ColorSamplerDefaultActivation"));
313 QScreen *screen = qApp->screenAt(point);
315 screen = qApp->primaryScreen();
317 QCursor::setPos(screen, point);
328 Qt::AlignLeft | Qt::TextWordWrap | Qt::AlignVCenter);
336 if ((node->
isEditable(
true) && editableOnly) || !editableOnly) {
338 KisShapeLayerSP shapeLayer = dynamic_cast<KisShapeLayer*>(node.data());
339 if (shapeLayer && shapeLayer->isEditable() && shapeLayer->shapeManager()->shapeAt(point)) {
340 foundNodes.append(shapeLayer);
351 if (!canvas2)
return p;
355 KisShapeLayerSP shapeLayer = candidates.isEmpty()?
nullptr: candidates.last();
359 if (shape && !(currentShapes.contains(shape) && skipCurrentShapes)) {
372 paths.addPath(path->absoluteTransformation().map(path->outline()));
375 if (!paths.isEmpty()) {
391 if (!canvas2)
return false;
395 KisShapeLayerSP shapeLayer = candidates.isEmpty()?
nullptr: candidates.last();
400 && !(currentShapes.contains(shape) && skipCurrentShapes)
401 && (shapeType.isEmpty() || shapeType == shape->
shapeId())) {
426 actions << actionRegistry->
makeQAction(
"movetool-move-up", actionRegistry);
427 actions << actionRegistry->
makeQAction(
"movetool-move-down", actionRegistry);
428 actions << actionRegistry->
makeQAction(
"movetool-move-left", actionRegistry);
429 actions << actionRegistry->
makeQAction(
"movetool-move-right", actionRegistry);
431 actions << actionRegistry->
makeQAction(
"movetool-move-up-more", actionRegistry);
432 actions << actionRegistry->
makeQAction(
"movetool-move-down-more", actionRegistry);
433 actions << actionRegistry->
makeQAction(
"movetool-move-left-more", actionRegistry);
434 actions << actionRegistry->
makeQAction(
"movetool-move-right-more", actionRegistry);
454 if (!node->
isEditable(
true) || blockedNoIndirectPainting) {
456 message = i18n(
"Layer is locked and invisible.");
458 message = i18n(
"Layer is locked.");
460 message = i18n(
"Layer is invisible.");
461 }
else if (blockedNoIndirectPainting) {
462 message = i18n(
"Layer can be painted in Wash Mode only.");
464 message = i18n(
"Group not editable.");
473 int brushSize = minSize;
476 int increment = qMax(1,
int(std::ceil(qreal(brushSize) / 15)));
477 brushSize += increment;
478 }
while (brushSize < maxSize);
484 std::vector<int>::iterator result = std::upper_bound(
m_sizes.begin(),
m_sizes.end(), qRound(size));
490 std::vector<int>::reverse_iterator result =
491 std::upper_bound(
m_sizes.rbegin(),
m_sizes.rend(), qRound(size), std::greater<int>());
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.
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