9#include <QRegularExpression>
37 dbgPlugins <<
"KisQmicImportTools::applyLayerNameChanges";
44 const QRegExp modeRe(R
"(mode\(\s*([^)]*)\s*\))");
45 if (modeRe.indexIn(srcGmicImage.
m_layerName) != -1) {
46 QString modeStr = modeRe.cap(1).trimmed();
49 dbgPlugins <<
"Detected mode: " << modeStr <<
" => "
51 if (!translatedMode.isNull()) {
59 const QRegExp opacityRe(R
"(opacity\(\s*([^)]*)\s*\))");
61 if (opacityRe.indexIn(srcGmicImage.
m_layerName) != -1) {
62 const auto opacity = opacityRe.cap(1).toFloat();
64 << std::lround(opacity / 100.f * 255.f);
67 static_cast<quint8
>(std::lround(
68 float(opacity * 255) / 100.f))));
73 const QRegExp nameRe(R
"(name\(\s*([^)]*)\s*\))");
75 if (nameRe.indexIn(srcGmicImage.
m_layerName) != -1) {
76 const auto name = nameRe.cap(1);
87 const QRegularExpression positionPattern(
88 R
"(pos\(\s*(-?\d*)[^)](-?\d*)\s*\))");
89 const QRegularExpressionMatch match =
91 if (match.hasMatch()) {
92 const auto x = match.captured(1).toInt();
93 const auto y = match.captured(2).toInt();
94 const QPoint oldPos(node->
x(), node->
y());
95 const QPoint newPos(x, y);
96 dbgPlugins <<
"Detected layer position: " << oldPos << newPos
108 const QRect &dstRect)
110 dbgPlugins <<
"KisQmicImportTools::gmicImageToPaintDevice()" << dstRect;
117 painter.
bitBlt(dstRect.topLeft(),
119 QRect(QPoint(0, 0), dstRect.size()));
139 const auto isAvailable = [](
KisNodeSP node) ->
bool {
140 auto *paintLayer =
dynamic_cast<KisPaintLayer *
>(node.data());
141 return paintLayer && paintLayer->
visible(
false);
150 if (isAvailable(currentNode)) {
151 result->prepend(currentNode);
162 dynamic_cast<KisPaintLayer *>(item.data());
172 if (isAvailable(currentNode)) {
173 result->prepend(currentNode);
181 if (isAvailable(currentNode)) {
182 result->prepend(currentNode);
199 dynamic_cast<KisPaintLayer *>(item.data());
201 && paintLayer->visible(false) == visibility) {
212 <<
"Inputmode" <<
static_cast<int>(inputMode)
213 <<
"must be specified by GMic or is not implemented in Krita";
const QString COMPOSITE_COPY
The command for setting the composite op.
The command for setting the node opacity.
The command for setting the node's name.
QRect exactBounds() const
const KoColorSpace * colorSpace() const
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
void setCompositeOpId(const KoCompositeOp *op)
static void convertFromGmicFast(const KisQMicImage &gmicImage, KisPaintDeviceSP dst, float gmicUnitValue)
Fast versions.
static QString stringToBlendingMode(QString str)
void recursiveApplyNodes(NodePointer node, Functor func)
virtual KisPaintDeviceSP paintDevice() const =0
virtual bool visible(bool recursive=false) const
KisNodeSP prevSibling() const
KisNodeSP nextSibling() const