9#include <QRegularExpression>
36 dbgPlugins <<
"KisQmicImportTools::applyLayerNameChanges";
43 const QRegularExpression modeRe(R
"(mode\(\s*([^)]*)\s*\))");
44 QRegularExpressionMatch match;
45 if (srcGmicImage.
m_layerName.contains(modeRe, &match)) {
46 QString modeStr = match.captured(1).trimmed();
49 dbgPlugins <<
"Detected mode: " << modeStr <<
" => "
51 if (!translatedMode.isNull()) {
59 const QRegularExpression opacityRe(R
"(opacity\(\s*([^)]*)\s*\))");
60 QRegularExpressionMatch match;
61 if (srcGmicImage.
m_layerName.contains(opacityRe, &match)) {
62 const float opacity = match.captured(1).toFloat();
64 << std::lround(opacity / 100.f * 255.f);
67 static_cast<quint8
>(std::lround(
68 float(opacity * 255) / 100.f))));
73const QRegularExpression nameRe(R
"(name\(\s*([^)]*)\s*\))");
75 QRegularExpressionMatch match;
76 if (srcGmicImage.
m_layerName.contains(nameRe, &match)) {
88 const QRegularExpression positionPattern(
89 R
"(pos\(\s*(-?\d*)[^)](-?\d*)\s*\))");
90 const QRegularExpressionMatch match =
92 if (match.hasMatch()) {
93 const auto x = match.captured(1).toInt();
94 const auto y = match.captured(2).toInt();
95 const QPoint oldPos(node->
x(), node->
y());
96 const QPoint newPos(x, y);
97 dbgPlugins <<
"Detected layer position: " << oldPos << newPos
109 const QRect &dstRect)
111 dbgPlugins <<
"KisQmicImportTools::gmicImageToPaintDevice()" << dstRect;
118 painter.
bitBlt(dstRect.topLeft(),
120 QRect(QPoint(0, 0), dstRect.size()));
140 const auto isAvailable = [](
KisNodeSP node) ->
bool {
141 auto *paintLayer =
dynamic_cast<KisPaintLayer *
>(node.data());
142 return paintLayer && paintLayer->
visible(
false);
151 if (isAvailable(currentNode)) {
152 result->prepend(currentNode);
163 dynamic_cast<KisPaintLayer *>(item.data());
173 if (isAvailable(currentNode)) {
174 result->prepend(currentNode);
182 if (isAvailable(currentNode)) {
183 result->prepend(currentNode);
200 dynamic_cast<KisPaintLayer *>(item.data());
202 && paintLayer->visible(false) == visibility) {
213 <<
"Inputmode" <<
static_cast<int>(inputMode)
214 <<
"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 QString gMicNameToName(QString name)
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