diff --git a/lib/jkqtplotter/jkqtptools.cpp b/lib/jkqtplotter/jkqtptools.cpp index c99d9eb414..37fe70c2ff 100644 --- a/lib/jkqtplotter/jkqtptools.cpp +++ b/lib/jkqtplotter/jkqtptools.cpp @@ -19,7 +19,6 @@ #include "jkqtplotter/jkqtptools.h" -#include "jkqtcommon/jkqtpenhancedpainter.h" #include #include #include @@ -602,6 +601,10 @@ QString JKQTPColorDerivationMode::toString() const case ColorChangeMode::InvertColor: name="inverted_color"; break; + default: + qDebug()<<"unknown colorModification="<=QT_VERSION_CHECK(6, 0, 0)) + static QRegularExpression rx1arg("(transparency|more_transparent|less_transparent|replace_color_not_transparency|replace_color_and_transparency|darker_color|lighter_color)\\((.*)\\)", QRegularExpression::CaseInsensitiveOption|QRegularExpression::InvertedGreedinessOption); +#else + const QRegExp rx1arg=[](){ QRegExp rx4("(transparency|more_transparent|less_transparent|replace_color_not_transparency|replace_color_and_transparency|darker_color|lighter_color)\\((.*)\\)", Qt::CaseInsensitive); + rx4.setMinimal(false); + return rx4; + }(); +#endif + for (QString p: parts) { + p=p.removeIf([](QChar c) { return c.isSpace()||c=='\t';}).trimmed(); + if (p=="same_color") res.colorModification=ColorChangeMode::SameColor; + else if (p=="invert"||p=="inverted"||p=="inverted_color") res.colorModification=ColorChangeMode::InvertColor; + else if (p=="invert"||p=="inverted"||p=="inverted_color") res.colorModification=ColorChangeMode::InvertColor; + else if (p=="more_transparent") { res.transparencyModification=TransparencyChangeMode::MoreTransparent; res.transparencyModficationStrength=0.3; } + else if (p=="non_transparent" || p=="opaque") { res.transparencyModification=TransparencyChangeMode::ReplaceTransparency; res.targetTransparency=0; } + else if (p=="transparent") { res.transparencyModification=TransparencyChangeMode::ReplaceTransparency; res.targetTransparency=1; } + else if (p=="less_transpatransparentrent") { res.transparencyModification=TransparencyChangeMode::LessTransparent; res.transparencyModficationStrength=0.3; } + else if (p=="same_transparency") { res.transparencyModification=TransparencyChangeMode::SameTransparency; } + else { +#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0)) + const auto m1arg=rx1arg.match(p); + if (m1arg.hasMatch()) { + const QString instr=m1arg.captured(1).trimmed(); + const QString arg1=m1arg.captured(2).trimmed(); +#else + if (rx1arg.indexIn(slt[i])>=0) { + const QString instr=rx1arg.cap(1).trimmed(); + const QString arg1=rx1arg.cap(2).trimmed(); +#endif + bool arg1f_ok=false; + const float arg1f=arg1.toFloat(&arg1f_ok); + if (instr=="transparency" && arg1f_ok) { + res.transparencyModification=TransparencyChangeMode::ReplaceTransparency; + res.targetTransparency=arg1f; + } else if (instr=="more_transparent" && arg1f_ok) { + res.transparencyModification=TransparencyChangeMode::MoreTransparent; + res.transparencyModficationStrength=arg1f; + } else if (instr=="less_transparent" && arg1f_ok) { + res.transparencyModification=TransparencyChangeMode::LessTransparent; + res.transparencyModficationStrength=arg1f; + } else if (instr=="darker_color" && arg1f_ok) { + res.colorModification=ColorChangeMode::DarkerColor; + res.colorModificationStrength=arg1f; + } else if (instr=="lighter_color" && arg1f_ok) { + res.colorModification=ColorChangeMode::LighterColor; + res.colorModificationStrength=arg1f; + } else if (instr=="replace_color_not_transparency") { + const QColor arg1c=jkqtp_String2QColor(arg1); + res.colorModification=ColorChangeMode::ReplaceColorNotTransparency; + res.targetColor=arg1c; + } else if (instr=="replace_color_and_transparency") { + const QColor arg1c=jkqtp_String2QColor(arg1); + res.colorModification=ColorChangeMode::ReplaceColorAndTransparency; + res.targetColor=arg1c; + } + } + } + } - - return JKQTPColorDerivationMode(); + return res; } QColor JKQTPColorDerivationMode::apply(const QColor& basecolor) const