Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Remove EnhancedPathShape
Dmitry Kazakovb1c48200fa4b
diff --git a/plugins/flake/pathshapes/CMakeLists.txt b/plugins/flake/pathshapes/CMakeLists.txtindex 48c0a084c5..d33f71ca37 100644--- a/plugins/flake/pathshapes/CMakeLists.txt+++ b/plugins/flake/pathshapes/CMakeLists.txt@@ -15,12 +15,6 @@ set(pathshapes_SOURCESrectangle/RectangleShapeFactory.cpprectangle/RectangleShapeConfigWidget.cpprectangle/RectangleShapeConfigCommand.cpp- enhancedpath/EnhancedPathShape.cpp- enhancedpath/EnhancedPathShapeFactory.cpp- enhancedpath/EnhancedPathCommand.cpp- enhancedpath/EnhancedPathParameter.cpp- enhancedpath/EnhancedPathFormula.cpp- enhancedpath/EnhancedPathHandle.cppPathShapesPlugin.cpp)diff --git a/plugins/flake/pathshapes/PathShapesPlugin.cpp b/plugins/flake/pathshapes/PathShapesPlugin.cppindex 4632b1eda5..3c05a85e62 100644--- a/plugins/flake/pathshapes/PathShapesPlugin.cpp+++ b/plugins/flake/pathshapes/PathShapesPlugin.cpp@@ -12,7 +12,6 @@#include "rectangle/RectangleShapeFactory.h"#include "ellipse/EllipseShapeFactory.h"#include "spiral/SpiralShapeFactory.h"-#include "enhancedpath/EnhancedPathShapeFactory.h"#include <kpluginfactory.h>K_PLUGIN_FACTORY_WITH_JSON(PathShapesPluginFactory, "calligra_shape_paths.json", registerPlugin<PathShapesPlugin>();)@@ -23,7 +22,6 @@ PathShapesPlugin::PathShapesPlugin(QObject *parent, const QVariantList &)KoShapeRegistry::instance()->add(new StarShapeFactory());KoShapeRegistry::instance()->add(new RectangleShapeFactory());KoShapeRegistry::instance()->add(new SpiralShapeFactory());- KoShapeRegistry::instance()->add(new EnhancedPathShapeFactory());KoShapeRegistry::instance()->add(new EllipseShapeFactory());}diff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathCommand.cpp b/plugins/flake/pathshapes/enhancedpath/EnhancedPathCommand.cppdeleted file mode 100644index e5f9544133..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathCommand.cpp+++ /dev/null@@ -1,318 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- * SPDX-FileCopyrightText: 2010 Thomas Zander <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#include "EnhancedPathCommand.h"-#include "EnhancedPathParameter.h"-#include "EnhancedPathShape.h"-#include <KoPathPoint.h>-#include <math.h>-#include <QDebug>--// radian to degree factor-const qreal rad2deg = 180.0 / M_PI;--EnhancedPathCommand::EnhancedPathCommand(const QChar &command, EnhancedPathShape *parent)- : m_command(command)- , m_parent(parent)-{- Q_ASSERT(m_parent);-}--EnhancedPathCommand::~EnhancedPathCommand()-{-}--bool EnhancedPathCommand::execute()-{- /*- * The parameters of the commands are in viewbox coordinates, which have- * to be converted to the shapes coordinate system by calling viewboxToShape- * on the enhanced path the command works on.- * Parameters which resemble angles are angles corresponding to the viewbox- * coordinate system. Those have to be transformed into angles corresponding- * to the normal mathematically coordinate system to be used for the arcTo- * drawing routine. This is done by computing (2*M_PI - angle).- */- QList<QPointF> points = pointsFromParameters();- const int pointsCount = points.size();-- switch (m_command.unicode()) {- // starts new subpath at given position (x y) +- case 'M':- if (!pointsCount) {- return false;- }- m_parent->moveTo(points[0]);- if (pointsCount > 1)- for (int i = 1; i < pointsCount; i++) {- m_parent->lineTo(points[i]);- }- break;- // line from current point (x y) +- case 'L':- Q_FOREACH (const QPointF &point, points) {- m_parent->lineTo(point);- }- break;- // cubic bezier curve from current point (x1 y1 x2 y2 x y) +- case 'C':- for (int i = 0; i < pointsCount; i += 3) {- m_parent->curveTo(points[i], points[i + 1], points[i + 2]);- }- break;- // closes the current subpath- case 'Z':- m_parent->close();- break;- // ends the current set of subpaths- case 'N':- // N just ends the complete path- break;- // no fill for current set of subpaths- case 'F':- // TODO implement me- break;- // no stroke for current set of subpaths- case 'S':- // TODO implement me- break;- // segment of an ellipse (x y w h t0 t1) +- case 'T':- // same like T but with implied movement to starting point (x y w h t0 t1) +- case 'U': {- bool lineTo = m_command.unicode() == 'T';-- for (int i = 0; i < pointsCount; i += 3) {- const QPointF &radii = points[i + 1];- const QPointF &angles = points[i + 2] / rad2deg;- // compute the ellipses starting point- QPointF start(radii.x() * cos(angles.x()), -1 * radii.y() * sin(angles.x()));- qreal sweepAngle = degSweepAngle(points[i + 2].x(), points[i + 2].y(), false);-- if (lineTo) {- m_parent->lineTo(points[i] + start);- } else {- m_parent->moveTo(points[i] + start);- }-- m_parent->arcTo(radii.x(), radii.y(), points[i + 2].x(), sweepAngle);- }- break;- }- // counter-clockwise arc (x1 y1 x2 y2 x3 y3 x y) +- case 'A':- // the same as A, with implied moveto to the starting point (x1 y1 x2 y2 x3 y3 x y) +- case 'B':- // clockwise arc (x1 y1 x2 y2 x3 y3 x y) +- case 'W':- // the same as W, but implied moveto (x1 y1 x2 y2 x3 y3 x y) +- case 'V': {- bool lineTo = ((m_command.unicode() == 'A') || (m_command.unicode() == 'W'));- bool clockwise = ((m_command.unicode() == 'W') || (m_command.unicode() == 'V'));- for (int i = 0; i < pointsCount; i += 4) {- QRectF bbox = rectFromPoints(points[i], points[i + 1]);- QPointF center = bbox.center();- qreal rx = 0.5 * bbox.width();- qreal ry = 0.5 * bbox.height();-- if (rx == 0) {- rx = 1;- }-- if (ry == 0) {- ry = 1;- }-- QPointF startRadialVector = points[i + 2] - center;- QPointF endRadialVector = points[i + 3] - center;-- // convert from ellipse space to unit-circle space- qreal x0 = startRadialVector.x() / rx;- qreal y0 = startRadialVector.y() / ry;-- qreal x1 = endRadialVector.x() / rx;- qreal y1 = endRadialVector.y() / ry;-- qreal startAngle = angleFromPoint(QPointF(x0, y0));- qreal stopAngle = angleFromPoint(QPointF(x1, y1));-- // we are moving counter-clockwise to the end angle- qreal sweepAngle = radSweepAngle(startAngle, stopAngle, clockwise);- // compute the starting point to draw the line to- // as the point x3 y3 is not on the ellipse, spec says the point define radial vector- QPointF startPoint(rx * cos(startAngle), ry * sin(2 * M_PI - startAngle));-- // if A or W is first command in enhanced path- // move to the starting point- bool isFirstCommandInPath = (m_parent->subpathCount() == 0);- bool isFirstCommandInSubpath = m_parent->isClosedSubpath(m_parent->subpathCount() - 1);-- if (lineTo && !isFirstCommandInPath && !isFirstCommandInSubpath) {- m_parent->lineTo(center + startPoint);- } else {- m_parent->moveTo(center + startPoint);- }-- m_parent->arcTo(rx, ry, startAngle * rad2deg, sweepAngle * rad2deg);- }- break;- }- // elliptical quadrant (initial segment tangential to x-axis) (x y) +- case 'X': {- KoPathPoint *lastPoint = lastPathPoint();- bool xDir = true;- foreach (const QPointF &point, points) {- qreal rx = point.x() - lastPoint->point().x();- qreal ry = point.y() - lastPoint->point().y();- qreal startAngle = xDir ? (ry > 0.0 ? 90.0 : 270.0) : (rx < 0.0 ? 0.0 : 180.0);- qreal sweepAngle = xDir ? (rx * ry < 0.0 ? 90.0 : -90.0) : (rx * ry > 0.0 ? 90.0 : -90.0);- lastPoint = m_parent->arcTo(fabs(rx), fabs(ry), startAngle, sweepAngle);- xDir = !xDir;- }- break;- }- // elliptical quadrant (initial segment tangential to y-axis) (x y) +- case 'Y': {- KoPathPoint *lastPoint = lastPathPoint();- bool xDir = false;- foreach (const QPointF &point, points) {- qreal rx = point.x() - lastPoint->point().x();- qreal ry = point.y() - lastPoint->point().y();- qreal startAngle = xDir ? (ry > 0.0 ? 90.0 : 270.0) : (rx < 0.0 ? 0.0 : 180.0);- qreal sweepAngle = xDir ? (rx * ry < 0.0 ? 90.0 : -90.0) : (rx * ry > 0.0 ? 90.0 : -90.0);- lastPoint = m_parent->arcTo(fabs(rx), fabs(ry), startAngle, sweepAngle);- xDir = !xDir;- }- break;- }- // quadratic bezier curve (x1 y1 x y)+- case 'Q':- for (int i = 0; i < pointsCount; i += 2) {- m_parent->curveTo(points[i], points[i + 1]);- }- break;- default:- break;- }- return true;-}--QList<QPointF> EnhancedPathCommand::pointsFromParameters()-{- QList<QPointF> points;- QPointF p;-- int paramCount = m_parameters.count();- for (int i = 0; i < paramCount - 1; i += 2) {- p.setX(m_parameters[i]->evaluate());- p.setY(m_parameters[i + 1]->evaluate());- points.append(p);- }-- int mod = 1;- if (m_command.unicode() == 'C' || m_command.unicode() == 'U'- || m_command.unicode() == 'T') {- mod = 3;- } else if (m_command.unicode() == 'A' || m_command.unicode() == 'B'- || m_command.unicode() == 'W' || m_command.unicode() == 'V') {- mod = 4;- } else if (m_command.unicode() == 'Q') {- mod = 2;- }- if ((points.count() % mod) != 0) { // invalid command- qWarning() << "Invalid point count for command" << m_command << "ignoring" << "count:" << points.count() << "mod:" << mod;- return QList<QPointF>();- }-- return points;-}--void EnhancedPathCommand::addParameter(EnhancedPathParameter *parameter)-{- if (parameter) {- m_parameters.append(parameter);- }-}--qreal EnhancedPathCommand::angleFromPoint(const QPointF &point) const-{- qreal angle = atan2(point.y(), point.x());- if (angle < 0.0) {- angle += 2 * M_PI;- }-- return 2 * M_PI - angle;-}--qreal EnhancedPathCommand::radSweepAngle(qreal start, qreal stop, bool clockwise) const-{- qreal sweepAngle = stop - start;- if (fabs(sweepAngle) < 0.1) {- return 2 * M_PI;- }- if (clockwise) {- // we are moving clockwise to the end angle- if (stop > start) {- sweepAngle = (stop - start) - 2 * M_PI;- }- } else {- // we are moving counter-clockwise to the stop angle- if (start > stop) {- sweepAngle = 2 * M_PI - (start - stop);- }- }-- return sweepAngle;-}--qreal EnhancedPathCommand::degSweepAngle(qreal start, qreal stop, bool clockwise) const-{- qreal sweepAngle = stop - start;- if (fabs(sweepAngle) < 0.1) {- return 360.0;- }- if (clockwise) {- // we are moving clockwise to the end angle- if (stop > start) {- sweepAngle = (stop - start) - 360.0;- }- } else {- // we are moving counter-clockwise to the stop angle- if (start > stop) {- sweepAngle = 360.0 - (start - stop);- }- }-- return sweepAngle;-}--KoPathPoint *EnhancedPathCommand::lastPathPoint() const-{- KoPathPoint *lastPoint = 0;- int subpathCount = m_parent->subpathCount();- if (subpathCount) {- int subpathPointCount = m_parent->subpathPointCount(subpathCount - 1);- lastPoint = m_parent->pointByIndex(KoPathPointIndex(subpathCount - 1, subpathPointCount - 1));- }- return lastPoint;-}--QRectF EnhancedPathCommand::rectFromPoints(const QPointF &tl, const QPointF &br) const-{- return QRectF(tl, QSizeF(br.x() - tl.x(), br.y() - tl.y())).normalized();-}--QString EnhancedPathCommand::toString() const-{- QString cmd = m_command;-- Q_FOREACH (EnhancedPathParameter *p, m_parameters) {- cmd += p->toString() + ' ';- }-- return cmd.trimmed();-}diff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathCommand.h b/plugins/flake/pathshapes/enhancedpath/EnhancedPathCommand.hdeleted file mode 100644index 8ac8d7daab..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathCommand.h+++ /dev/null@@ -1,54 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#ifndef KOENHANCEDPATHCOMMAND_H-#define KOENHANCEDPATHCOMMAND_H--#include <QChar>-#include <QList>-#include <QPointF>-#include <QRectF>--class EnhancedPathShape;-class EnhancedPathParameter;-class KoPathPoint;--/**- * A EnhancedPathCommand is a command like moveto, curveto, etc.- * that directly modifies an enhanced paths outline.- */-class EnhancedPathCommand-{-public:- /// Constructs a new command from the given command type- EnhancedPathCommand(const QChar &command, EnhancedPathShape *parent);- ~EnhancedPathCommand();- /// Executes the command on the specified path shape- bool execute();- /// Adds a new parameter to the command- void addParameter(EnhancedPathParameter *parameter);- /// Returns a string representation of the command- QString toString() const;-private:- /// Returns a list of points, created from the parameter list- QList<QPointF> pointsFromParameters();- /// Calculates angle from given point- qreal angleFromPoint(const QPointF &point) const;- /// Returns sweep angle from start to stop and given direction- qreal radSweepAngle(qreal start, qreal stop, bool clockwise) const;- /// Returns sweep angle from start to stop and given direction- qreal degSweepAngle(qreal start, qreal stop, bool clockwise) const;- /// Returns the last path point of given path- KoPathPoint *lastPathPoint() const;- /// Returns rectangle from given points- QRectF rectFromPoints(const QPointF &tl, const QPointF &br) const;-- QChar m_command; ///< the actual command- QList<EnhancedPathParameter *> m_parameters; ///< the commands parameters- EnhancedPathShape *m_parent; ///< the enhanced path owning the command-};--#endif // KOENHANCEDPATHCOMMAND_Hdiff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathFormula.cpp b/plugins/flake/pathshapes/enhancedpath/EnhancedPathFormula.cppdeleted file mode 100644index 7819a08e46..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathFormula.cpp+++ /dev/null@@ -1,847 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#include "EnhancedPathFormula.h"-#include "EnhancedPathShape.h"-#include <QStack>-#include <math.h>--#include <QDebug>--/*- The formula parsing, compiling and evaluating is based on- kspreads formula engine written by Ariya Hidayat.- There is a DESIGN.html file in the kspreads directory which- explains how the engine is working.- The engine was stripped down a little to only support the- operations needed for the odf enhanced path formula spec.-*/--// helper function: return operator of given token text-FormulaToken::Operator matchOperator(const QString &text);-// helper function: return true for valid identifier character-bool isIdentifier(QChar ch);-// helper function: give operator precedence-// e.g. '+' is 1 while '*' is 3-int opPrecedence(FormulaToken::Operator op);-// helper function: return function of given token text-EnhancedPathFormula::Function matchFunction(const QString &text);-// helper function: return function name from function identifier-QString matchFunction(EnhancedPathFormula::Function function);--class FormulaToken;--class FormulaTokenStack : public QVector<FormulaToken>-{-public:- FormulaTokenStack()- : QVector<FormulaToken>(), topIndex(0)- {- ensureSpace();- }-- bool isEmpty() const- {- return topIndex == 0;- }- unsigned itemCount() const- {- return topIndex;- }- void push(const FormulaToken &token)- {- ensureSpace();- insert(topIndex++, token);- }- FormulaToken pop()- {- return (topIndex > 0) ? FormulaToken(at(--topIndex)) : FormulaToken();- }- const FormulaToken &top()- {- return top(0);- }- const FormulaToken &top(unsigned index)- {- static FormulaToken null;- if (topIndex > index) {- return at(topIndex - index - 1);- }- return null;- }-private:- void ensureSpace()- {- while ((int) topIndex >= size()) {- resize(size() + 10);- }- }- unsigned topIndex;-};--class Opcode-{-public:-- enum { Nop = 0, Load, Ref, Function, Add, Sub, Neg, Mul, Div };-- unsigned type;- unsigned index;-- Opcode(): type(Nop), index(0) {}- Opcode(unsigned t): type(t), index(0) {}- Opcode(unsigned t, unsigned i): type(t), index(i) {}-};--EnhancedPathFormula::EnhancedPathFormula(const QString &text, EnhancedPathShape *parent)- : m_valid(false)- , m_compiled(false)- , m_error(ErrorNone)- , m_text(text)- , m_parent(parent)-{- Q_ASSERT(m_parent);-}--EnhancedPathFormula::~EnhancedPathFormula()-{-}--qreal EnhancedPathFormula::evaluate()-{- // shortcut- if (m_error != ErrorNone) {- return 0.0;- }-- // lazy evaluation- if (!m_compiled) {- TokenList tokens = scan(m_text);- if (!compile(tokens)) {- debugOpcodes();- m_error = ErrorCompile;- return 0.0;- }- m_compiled = true;- }-- QStack<QVariant> stack;- // stack.reserve(3) here so that the stack is not resized all the time- // this reduces the number of a/de/re-llocations for documents with- // a lot of enhanced path shapes quite a lot.- stack.reserve(3);- int index = 0;-- if (!m_valid) {- m_error = ErrorParse;- return 0.0;- }-- for (int pc = 0; pc < m_codes.count(); pc++) {- QVariant ret; // for the function caller- Opcode &opcode = m_codes[pc];- index = opcode.index;- switch (opcode.type) {- // no operation- case Opcode::Nop:- break;-- // load a constant, push to stack- case Opcode::Load:- stack.push(m_constants[index]);- break;-- // unary operation- case Opcode::Neg: {- bool success = false;- qreal value = stack.pop().toDouble(&success);- if (success) { // do nothing if we got an error- value *= -1.0;- }- stack.push(QVariant(value));- break;- }-- // binary operation: take two values from stack, do the operation,- // push the result to stack- case Opcode::Add: {- qreal val2 = stack.pop().toDouble();- qreal val1 = stack.pop().toDouble();- stack.push(QVariant(val1 + val2));- break;- }-- case Opcode::Sub: {- qreal val2 = stack.pop().toDouble();- qreal val1 = stack.pop().toDouble();- stack.push(QVariant(val1 - val2));- break;- }-- case Opcode::Mul: {- qreal val2 = stack.pop().toDouble();- qreal val1 = stack.pop().toDouble();- stack.push(QVariant(val1 * val2));- break;- }-- case Opcode::Div: {- qreal val2 = stack.pop().toDouble();- qreal val1 = stack.pop().toDouble();- stack.push(QVariant(val1 / val2));- break;- }-- case Opcode::Ref: {- QString reference = m_constants[index].toString();- // push function name if it is a function, else push evaluated reference- Function function = matchFunction(reference);- if (FunctionUnknown == function) {- stack.push(QVariant(m_parent->evaluateReference(reference)));- } else {- stack.push(function);- }- break;- }-- // calling function- case Opcode::Function: {- // sanity check, this should not happen unless opcode is wrong- // (i.e. there's a bug in the compile() function)- if (stack.count() < index) {- qWarning() << "not enough arguments for function " << m_text;- m_error = ErrorValue; // not enough arguments- return 0.0;- }-- /// prepare function arguments- QList<qreal> args;- for (; index; index--) {- qreal value = stack.pop().toDouble();- args.push_front(value);- }-- // function identifier as int value- int function = stack.pop().toInt();- stack.push(QVariant(evaluateFunction((Function)function, args)));- break;- }-- default:- break;- }- }-- // more than one value in stack ? unsuccessful execution...- if (stack.count() != 1) {- m_error = ErrorValue;- return 0.0;- }-- return stack.pop().toDouble();-}--qreal EnhancedPathFormula::evaluateFunction(Function function, const QList<qreal> &arguments) const-{- switch (function) {- case EnhancedPathFormula::FunctionAbs:- return fabs(arguments[0]);- break;- case EnhancedPathFormula::FunctionSqrt:- return sqrt(arguments[0]);- break;- case EnhancedPathFormula::FunctionSin:- return sin(arguments[0]);- break;- case EnhancedPathFormula::FunctionCos:- return cos(arguments[0]);- break;- case EnhancedPathFormula::FunctionTan:- return tan(arguments[0]);- break;- case EnhancedPathFormula::FunctionAtan:- return atan(arguments[0]);- break;- case EnhancedPathFormula::FunctionAtan2:- // TODO atan2 with one argument as in odf spec ???- return atan2(arguments[0], arguments[1]);- break;- case EnhancedPathFormula::FunctionMin:- return qMin(arguments[0], arguments[1]);- break;- case EnhancedPathFormula::FunctionMax:- return qMax(arguments[0], arguments[1]);- break;- case EnhancedPathFormula::FunctionIf:- if (arguments[0] > 0.0) {- return arguments[1];- } else {- return arguments[2];- }- break;- default:- ;- }-- return 0.0;-}--TokenList EnhancedPathFormula::scan(const QString &formula) const-{- // parsing state- enum {- Start,- Finish,- Bad,- InNumber,- InDecimal,- InExpIndicator,- InExponent,- InString,- InIdentifier- } state;-- TokenList tokens;-- int i = 0;- state = Start;- int tokenStart = 0;- QString tokenText;- QString expr = formula + QChar();-- // main loop- while ((state != Bad) && (state != Finish) && (i < expr.length())) {- QChar ch = expr[i];-- switch (state) {- case Start:- tokenStart = i;-- // skip any whitespaces- if (ch.isSpace()) {- i++;- } else if (ch.isDigit()) { // check for number- state = InNumber;- }- // beginning with alphanumeric ?- // could be identifier, function, function reference, modifier reference- else if (isIdentifier(ch)) {- state = InIdentifier;- } else if (ch == '.') { // decimal dot ?- tokenText.append(expr[i++]);- state = InDecimal;- } else if (ch == QChar::Null) { // terminator character- state = Finish;- } else { // look for operator match- QString opString(ch);- int op = matchOperator(opString);-- // any matched operator ?- if (op != FormulaToken::OperatorInvalid) {- i++;- tokens.append(FormulaToken(FormulaToken::TypeOperator, opString, tokenStart));- } else {- state = Bad;- }- }- break;- case InIdentifier:- // consume as long as alpha, dollar sign, question mark, or digit- if (isIdentifier(ch) || ch.isDigit()) {- tokenText.append(expr[i++]);- } else if (ch == '(') { // a '(' ? then this must be a function identifier- tokens.append(FormulaToken(FormulaToken::TypeFunction, tokenText, tokenStart));- tokenStart = i;- tokenText.clear();- state = Start;- } else { // we're done with identifier- tokens.append(FormulaToken(FormulaToken::TypeReference, tokenText, tokenStart));- tokenStart = i;- tokenText.clear();- state = Start;- }- break;- case InNumber:- // consume as long as it's digit- if (ch.isDigit()) {- tokenText.append(expr[i++]);- } else if (ch == '.') { // decimal dot ?- tokenText.append('.');- i++;- state = InDecimal;- } else if (ch.toUpper() == 'E') { // exponent ?- tokenText.append('E');- i++;- state = InExpIndicator;- } else { // we're done with integer number- tokens.append(FormulaToken(FormulaToken::TypeNumber, tokenText, tokenStart));- tokenText.clear();- state = Start;- };- break;- case InDecimal:- // consume as long as it's digit- if (ch.isDigit()) {- tokenText.append(expr[i++]);- } else if (ch.toUpper() == 'E') { // exponent ?- tokenText.append('E');- i++;- state = InExpIndicator;- } else { // we're done with floating-point number- tokens.append(FormulaToken(FormulaToken::TypeNumber, tokenText, tokenStart));- tokenText.clear();- state = Start;- };- break;- case InExpIndicator:- // possible + or - right after E, e.g 1.23E+12 or 4.67E-8- if ((ch == '+') || (ch == '-')) {- tokenText.append(expr[i++]);- } else if (ch.isDigit()) { // consume as long as it's digit- state = InExponent;- } else { // invalid thing here- state = Bad;- }- break;- case InExponent:- // consume as long as it's digit- if (ch.isDigit()) {- tokenText.append(expr[i++]);- } else { // we're done with floating-point number- tokens.append(FormulaToken(FormulaToken::TypeNumber, tokenText, tokenStart));- tokenText.clear();- state = Start;- }- break;- default:- break;- }- }- return tokens;-}--bool EnhancedPathFormula::compile(const TokenList &tokens)-{- // sanity check- if (tokens.count() == 0) {- return false;- }-- FormulaTokenStack syntaxStack;- QStack<int> argStack;- unsigned argCount = 1;-- for (int i = 0; i <= tokens.count(); i++) {- // helper token: InvalidOp is end-of-formula- FormulaToken token = (i < tokens.count()) ? tokens[i] : FormulaToken(FormulaToken::TypeOperator);- FormulaToken::Type tokenType = token.type();-- // unknown token is invalid- if (tokenType == FormulaToken::TypeUnknown) {- break;- }-- // for constants, push immediately to stack- // generate code to load from a constant- if (tokenType == FormulaToken::TypeNumber) {- syntaxStack.push(token);- m_constants.append(QVariant(token.asNumber()));- m_codes.append(Opcode(Opcode::Load, m_constants.count() - 1));- }- // for identifier, push immediately to stack- // generate code to load from reference- if (tokenType == FormulaToken::TypeFunction || tokenType == FormulaToken::TypeReference) {- syntaxStack.push(token);- m_constants.append(QVariant(token.text()));- m_codes.append(Opcode(Opcode::Ref, m_constants.count() - 1));- }- // are we entering a function ?- // if token is operator, and stack already has: id (arg- if (tokenType == FormulaToken::TypeOperator && syntaxStack.itemCount() >= 3) {- FormulaToken arg = syntaxStack.top();- FormulaToken par = syntaxStack.top(1);- FormulaToken id = syntaxStack.top(2);- if (!arg.isOperator() &&- par.asOperator() == FormulaToken::OperatorLeftPar &&- id.isFunction()) {- argStack.push(argCount);- argCount = 1;- }- }- // for any other operator, try to apply all parsing rules- if (tokenType == FormulaToken::TypeOperator) {- // repeat until no more rule applies- for (;;) {- bool ruleFound = false;-- // rule for function arguments, if token is , or)- // id (arg1 , arg2 -> id (arg- if (!ruleFound)- if (syntaxStack.itemCount() >= 5)- if ((token.asOperator() == FormulaToken::OperatorRightPar) ||- (token.asOperator() == FormulaToken::OperatorComma)) {- FormulaToken arg2 = syntaxStack.top();- FormulaToken sep = syntaxStack.top(1);- FormulaToken arg1 = syntaxStack.top(2);- FormulaToken par = syntaxStack.top(3);- FormulaToken id = syntaxStack.top(4);- if (!arg2.isOperator())- if (sep.asOperator() == FormulaToken::OperatorComma)- if (!arg1.isOperator())- if (par.asOperator() == FormulaToken::OperatorLeftPar)- if (id.isFunction()) {- ruleFound = true;- syntaxStack.pop();- syntaxStack.pop();- argCount++;- }- }- // rule for function last argument:- // id (arg) -> arg- if (!ruleFound)- if (syntaxStack.itemCount() >= 4) {- FormulaToken par2 = syntaxStack.top();- FormulaToken arg = syntaxStack.top(1);- FormulaToken par1 = syntaxStack.top(2);- FormulaToken id = syntaxStack.top(3);- if (par2.asOperator() == FormulaToken::OperatorRightPar)- if (!arg.isOperator())- if (par1.asOperator() == FormulaToken::OperatorLeftPar)- if (id.isFunction()) {- ruleFound = true;- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.push(arg);- m_codes.append(Opcode(Opcode::Function, argCount));- argCount = argStack.empty() ? 0 : argStack.pop();- }- }-- // rule for parenthesis: (Y) -> Y- if (!ruleFound)- if (syntaxStack.itemCount() >= 3) {- FormulaToken right = syntaxStack.top();- FormulaToken y = syntaxStack.top(1);- FormulaToken left = syntaxStack.top(2);- if (right.isOperator())- if (!y.isOperator())- if (left.isOperator())- if (right.asOperator() == FormulaToken::OperatorRightPar)- if (left.asOperator() == FormulaToken::OperatorLeftPar) {- ruleFound = true;- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.push(y);- }- }-- // rule for binary operator: A (op) B -> A- // conditions: precedence of op >= precedence of token- // action: push (op) to result- // e.g. "A * B" becomes 'A' if token is operator '+'- if (!ruleFound)- if (syntaxStack.itemCount() >= 3) {- FormulaToken b = syntaxStack.top();- FormulaToken op = syntaxStack.top(1);- FormulaToken a = syntaxStack.top(2);- if (!a.isOperator())- if (!b.isOperator())- if (op.isOperator())- if (token.asOperator() != FormulaToken::OperatorLeftPar)- if (opPrecedence(op.asOperator()) >= opPrecedence(token.asOperator())) {- ruleFound = true;- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.push(b);- switch (op.asOperator()) {- // simple binary operations- case FormulaToken::OperatorAdd: m_codes.append(Opcode::Add); break;- case FormulaToken::OperatorSub: m_codes.append(Opcode::Sub); break;- case FormulaToken::OperatorMul: m_codes.append(Opcode::Mul); break;- case FormulaToken::OperatorDiv: m_codes.append(Opcode::Div); break;- default: break;- }- }- }-- // rule for unary operator: (op1) (op2) X -> (op1) X- // conditions: op2 is unary, token is not '('- // action: push (op2) to result- // e.g. "* - 2" becomes '*'- if (!ruleFound)- if (token.asOperator() != FormulaToken::OperatorLeftPar)- if (syntaxStack.itemCount() >= 3) {- FormulaToken x = syntaxStack.top();- FormulaToken op2 = syntaxStack.top(1);- FormulaToken op1 = syntaxStack.top(2);- if (!x.isOperator())- if (op1.isOperator())- if (op2.isOperator())- if ((op2.asOperator() == FormulaToken::OperatorAdd)- || (op2.asOperator() == FormulaToken::OperatorSub)) {- ruleFound = true;- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.push(x);- if (op2.asOperator() == FormulaToken::OperatorSub) {- m_codes.append(Opcode(Opcode::Neg));- }- }- }-- // auxiliary rule for unary operator: (op) X -> X- // conditions: op is unary, op is first in syntax stack, token is not '('- // action: push (op) to result- if (!ruleFound)- if (token.asOperator() != FormulaToken::OperatorLeftPar)- if (syntaxStack.itemCount() == 2) {- FormulaToken x = syntaxStack.top();- FormulaToken op = syntaxStack.top(1);- if (!x.isOperator())- if (op.isOperator())- if ((op.asOperator() == FormulaToken::OperatorAdd)- || (op.asOperator() == FormulaToken::OperatorSub)) {- ruleFound = true;- syntaxStack.pop();- syntaxStack.pop();- syntaxStack.push(x);- if (op.asOperator() == FormulaToken::OperatorSub) {- m_codes.append(Opcode(Opcode::Neg));- }- }- }-- if (!ruleFound) {- break;- }- }-- syntaxStack.push(token);- }- }-- // syntaxStack must left only one operand and end-of-formula (i.e. InvalidOp)- m_valid = false;- if (syntaxStack.itemCount() == 2)- if (syntaxStack.top().isOperator())- if (syntaxStack.top().asOperator() == FormulaToken::OperatorInvalid)- if (!syntaxStack.top(1).isOperator()) {- m_valid = true;- }-- // bad parsing ? clean-up everything- if (!m_valid) {- m_constants.clear();- m_codes.clear();- qWarning() << "compiling of " << m_text << " failed";- }-- return m_valid;-}--QString EnhancedPathFormula::toString() const-{- return m_text;-}--FormulaToken::FormulaToken(Type type, const QString &text, int position)- : m_type(type), m_text(text), m_position(position)-{-}--FormulaToken::FormulaToken(const FormulaToken &token)-{- if (this != &token) {- *this = token;- }-}--FormulaToken &FormulaToken::operator=(const FormulaToken &rhs)-{- if (this == &rhs) {- return *this;- }-- m_type = rhs.m_type;- m_text = rhs.m_text;- m_position = rhs.m_position;-- return *this;-}--qreal FormulaToken::asNumber() const-{- if (isNumber()) {- return m_text.toDouble();- } else {- return 0.0;- }-}--FormulaToken::Operator FormulaToken::asOperator() const-{- if (isOperator()) {- return matchOperator(m_text);- } else {- return OperatorInvalid;- }-}--// helper function: return operator of given token text-FormulaToken::Operator matchOperator(const QString &text)-{- if (text.length() != 1) {- return FormulaToken::OperatorInvalid;- }-- const char c = text[0].toLatin1();- switch (c) {- case '+': return FormulaToken::OperatorAdd; break;- case '-': return FormulaToken::OperatorSub; break;- case '*': return FormulaToken::OperatorMul; break;- case '/': return FormulaToken::OperatorDiv; break;- case '(': return FormulaToken::OperatorLeftPar; break;- case ')': return FormulaToken::OperatorRightPar; break;- case ',': return FormulaToken::OperatorComma; break;- default : return FormulaToken::OperatorInvalid; break;- }-}--// helper function: return true for valid identifier character-bool isIdentifier(QChar ch)-{- return (ch.unicode() == '?') || (ch.unicode() == '$') || (ch.isLetter());-}--// helper function: give operator precedence-// e.g. '+' is 1 while '*' is 3-int opPrecedence(FormulaToken::Operator op)-{- int prec = -1;- switch (op) {- case FormulaToken::OperatorMul: prec = 5; break;- case FormulaToken::OperatorDiv: prec = 6; break;- case FormulaToken::OperatorAdd: prec = 3; break;- case FormulaToken::OperatorSub: prec = 3; break;- case FormulaToken::OperatorComma: prec = 0; break;- case FormulaToken::OperatorRightPar: prec = 0; break;- case FormulaToken::OperatorLeftPar: prec = -1; break;- default: prec = -1; break;- }- return prec;-}--EnhancedPathFormula::Function matchFunction(const QString &text)-{- if (text == "abs") {- return EnhancedPathFormula::FunctionAbs;- }- if (text == "sqrt") {- return EnhancedPathFormula::FunctionSqrt;- }- if (text == "sin") {- return EnhancedPathFormula::FunctionSin;- }- if (text == "cos") {- return EnhancedPathFormula::FunctionCos;- }- if (text == "tan") {- return EnhancedPathFormula::FunctionTan;- }- if (text == "atan") {- return EnhancedPathFormula::FunctionAtan;- }- if (text == "atan2") {- return EnhancedPathFormula::FunctionAtan2;- }- if (text == "min") {- return EnhancedPathFormula::FunctionMin;- }- if (text == "max") {- return EnhancedPathFormula::FunctionMax;- }- if (text == "if") {- return EnhancedPathFormula::FunctionIf;- }-- return EnhancedPathFormula::FunctionUnknown;-}--QString matchFunction(EnhancedPathFormula::Function function)-{- switch (function) {- case EnhancedPathFormula::FunctionAbs:- return "fabs";- break;- case EnhancedPathFormula::FunctionSqrt:- return "sqrt";- break;- case EnhancedPathFormula::FunctionSin:- return "sin";- break;- case EnhancedPathFormula::FunctionCos:- return "cos";- break;- case EnhancedPathFormula::FunctionTan:- return "tan";- break;- case EnhancedPathFormula::FunctionAtan:- return "atan";- break;- case EnhancedPathFormula::FunctionAtan2:- return "atan2";- break;- case EnhancedPathFormula::FunctionMin:- return "min";- break;- case EnhancedPathFormula::FunctionMax:- return "max";- break;- case EnhancedPathFormula::FunctionIf:- return "if";- break;- default:- break;- }-- return "unknown";-}--void EnhancedPathFormula::debugTokens(const TokenList &tokens)-{-#ifndef NDEBUG- for (int i = 0; i < tokens.count(); i++) {- qDebug() << tokens[i].text();- }-#else- Q_UNUSED(tokens);-#endif-}--void EnhancedPathFormula::debugOpcodes()-{-#ifndef NDEBUG- foreach (const Opcode &c, m_codes) {- QString ctext;- switch (c.type) {- case Opcode::Load: ctext = QString("Load #%1").arg(c.index); break;- case Opcode::Ref: ctext = QString("Ref #%1").arg(c.index); break;- case Opcode::Function: ctext = QString("Function (%1)").arg(c.index); break;- case Opcode::Add: ctext = "Add"; break;- case Opcode::Sub: ctext = "Sub"; break;- case Opcode::Mul: ctext = "Mul"; break;- case Opcode::Div: ctext = "Div"; break;- case Opcode::Neg: ctext = "Neg"; break;- default: ctext = "Unknown"; break;- }- qDebug() << ctext;- }-#endif-}diff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathFormula.h b/plugins/flake/pathshapes/enhancedpath/EnhancedPathFormula.hdeleted file mode 100644index 4273f507e4..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathFormula.h+++ /dev/null@@ -1,180 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#ifndef KOENHANCEDPATHFORMULA_H-#define KOENHANCEDPATHFORMULA_H--#include <QString>-#include <QVariant>--class EnhancedPathShape;--class FormulaToken-{-public:- /// token types- enum Type {- TypeUnknown = 0, ///< unknown type- TypeNumber, ///< 14, 3, 1977, 3.141592, 1e10, 5.9e-7- TypeOperator, ///< +, *, /, -- TypeReference, ///< function reference, modifier reference or named variable- TypeFunction ///< function name- };-- /// operator types- enum Operator {- OperatorInvalid, ///< invalid operator- OperatorAdd, ///< + addition- OperatorSub, ///< - subtraction- OperatorMul, ///< * multiplication- OperatorDiv, ///< / division- OperatorLeftPar, ///< (left parentheses- OperatorRightPar, ///<) right parentheses- OperatorComma ///< , comma- };-- /// Constructs token with given type, text and position- explicit FormulaToken(Type type = TypeUnknown, const QString &text = QString(), int position = -1);-- /// copy constructor- FormulaToken(const FormulaToken &token);-- /// assignment operator- FormulaToken &operator=(const FormulaToken &token);-- /// Returns the type of the token- Type type() const- {- return m_type;- }- /// Returns the text representation of the token- QString text() const- {- return m_text;- }- /// Returns the position of the token- int position() const- {- return m_position;- }-- /// Returns if the token is a number- bool isNumber() const- {- return m_type == TypeNumber;- }- /// Returns if the token is a operator, OperatorInvalid if token is no operator- bool isOperator() const- {- return m_type == TypeOperator;- }- /// Returns if token is a function- bool isFunction() const- {- return m_type == TypeFunction;- }- /// Returns if token is a reference- bool isReference() const- {- return m_type == TypeReference;- }-- /// Returns the token converted to qreal- qreal asNumber() const;- /// Returns the token as operator- Operator asOperator() const;-private:- Type m_type {TypeUnknown}; ///< the token type- QString m_text; ///< the token text representation- int m_position {-1}; ///< the tokens position-};--typedef QList<FormulaToken> TokenList;--class Opcode;--class EnhancedPathFormula-{-public:- /// predefined functions- enum Function {- FunctionUnknown,- // unary functions- FunctionAbs,- FunctionSqrt,- FunctionSin,- FunctionCos,- FunctionTan,- FunctionAtan,- // binary functions- FunctionAtan2,- FunctionMin,- FunctionMax,- // ternary functions- FunctionIf- };-- /// The possible error code returned by error()- enum Error {- ErrorNone, ///< no error- ErrorValue, ///< error when converting value- ErrorParse, ///< parsing error- ErrorCompile, ///< compiling error- ErrorName ///< invalid function name value- };-- /// Constructs a new formula from the specified string representation- EnhancedPathFormula(const QString &text, EnhancedPathShape *parent);-- /// Destroys the formula- ~EnhancedPathFormula();-- /**- * Evaluates the formula using the given path as possible input.- *- * @param path the path to use as input- * @return the evaluated result- */- qreal evaluate();-- /// Returns the last occurred error- Error error() const- {- return m_error;- }-- /// returns string representation of the formula- QString toString() const;-private:- /// Separates the given formula text into tokens.- TokenList scan(const QString &formula) const;-- /// Compiles the formula tokens into byte code- bool compile(const TokenList &tokens);-- /**- * Evaluates a predefined function.- *- * @param function the identifier of the function to evaluate- * @param arguments the functions arguments- */- qreal evaluateFunction(Function function, const QList<qreal> &arguments) const;-- /// Prints token list- void debugTokens(const TokenList &tokens);- /// Prints byte code- void debugOpcodes();-- bool m_valid; ///< flag that shows if function is valid, i.e the function was compiled successfully- bool m_compiled; ///< flag that shows if function was compiled- Error m_error; ///< the last occurred error- QString m_text; ///< the formula text representation- QList<QVariant> m_constants; ///< constant values- QList<Opcode> m_codes; ///< the compiled byte code- EnhancedPathShape *m_parent;-};--#endif // KOENHANCEDPATHFORMULA_Hdiff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathHandle.cpp b/plugins/flake/pathshapes/enhancedpath/EnhancedPathHandle.cppdeleted file mode 100644index 6c5a4e433e..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathHandle.cpp+++ /dev/null@@ -1,144 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#include "EnhancedPathHandle.h"-#include "EnhancedPathShape.h"-#include "EnhancedPathParameter.h"-#include <KoShapeSavingContext.h>-#include <KoXmlWriter.h>-#include <KoXmlNS.h>-#include <KoShapeLoadingContext.h>--#include <math.h>--EnhancedPathHandle::EnhancedPathHandle(EnhancedPathShape *parent)- : m_parent(parent)- , m_positionX(0)- , m_positionY(0)- , m_minimumX(0)- , m_minimumY(0)- , m_maximumX(0)- , m_maximumY(0)- , m_polarX(0)- , m_polarY(0)- , m_minRadius(0)- , m_maxRadius(0)-{- Q_ASSERT(m_parent);-}--EnhancedPathHandle::~EnhancedPathHandle()-{-}--bool EnhancedPathHandle::hasPosition() const-{- return m_positionX && m_positionY;-}--void EnhancedPathHandle::setPosition(EnhancedPathParameter *positionX, EnhancedPathParameter *positionY)-{- m_positionX = positionX;- m_positionY = positionY;-}--QPointF EnhancedPathHandle::position()-{- if (!hasPosition()) {- return QPointF();- }-- QPointF position(m_positionX->evaluate(), m_positionY->evaluate());- if (isPolar()) {- // convert polar coordinates into cartesian coordinates- QPointF center(m_polarX->evaluate(), m_polarY->evaluate());- qreal angleInRadian = position.x() * M_PI / 180.0;- position = center + position.y() * QPointF(cos(angleInRadian), sin(angleInRadian));- }-- return position;-}--void EnhancedPathHandle::changePosition(const QPointF &position)-{- if (!hasPosition()) {- return;- }-- QPointF constrainedPosition(position);-- if (isPolar()) {- // convert cartesian coordinates into polar coordinates- QPointF polarCenter(m_polarX->evaluate(), m_polarY->evaluate());- QPointF diff = constrainedPosition - polarCenter;- // compute the polar radius- qreal radius = sqrt(diff.x() * diff.x() + diff.y() * diff.y());- // compute the polar angle- qreal angle = atan2(diff.y(), diff.x());- if (angle < 0.0) {- angle += 2 * M_PI;- }-- // constrain the radius- if (m_minRadius) {- radius = qMax(m_minRadius->evaluate(), radius);- }- if (m_maxRadius) {- radius = qMin(m_maxRadius->evaluate(), radius);- }-- constrainedPosition.setX(angle * 180.0 / M_PI);- constrainedPosition.setY(radius);- } else {- // constrain x coordinate- if (m_minimumX) {- constrainedPosition.setX(qMax(m_minimumX->evaluate(), constrainedPosition.x()));- }- if (m_maximumX) {- constrainedPosition.setX(qMin(m_maximumX->evaluate(), constrainedPosition.x()));- }-- // constrain y coordinate- if (m_minimumY) {- constrainedPosition.setY(qMax(m_minimumY->evaluate(), constrainedPosition.y()));- }- if (m_maximumY) {- constrainedPosition.setY(qMin(m_maximumY->evaluate(), constrainedPosition.y()));- }- }-- m_positionX->modify(constrainedPosition.x());- m_positionY->modify(constrainedPosition.y());-}--void EnhancedPathHandle::setRangeX(EnhancedPathParameter *minX, EnhancedPathParameter *maxX)-{- m_minimumX = minX;- m_maximumX = maxX;-}--void EnhancedPathHandle::setRangeY(EnhancedPathParameter *minY, EnhancedPathParameter *maxY)-{- m_minimumY = minY;- m_maximumY = maxY;-}--void EnhancedPathHandle::setPolarCenter(EnhancedPathParameter *polarX, EnhancedPathParameter *polarY)-{- m_polarX = polarX;- m_polarY = polarY;-}--void EnhancedPathHandle::setRadiusRange(EnhancedPathParameter *minRadius, EnhancedPathParameter *maxRadius)-{- m_minRadius = minRadius;- m_maxRadius = maxRadius;-}--bool EnhancedPathHandle::isPolar() const-{- return m_polarX && m_polarY;-}diff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathHandle.h b/plugins/flake/pathshapes/enhancedpath/EnhancedPathHandle.hdeleted file mode 100644index faa2685564..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathHandle.h+++ /dev/null@@ -1,121 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#ifndef KOENHANCEDPATHHANDLE_H-#define KOENHANCEDPATHHANDLE_H--#include <QPointF>-#include <QDomDocument>--class EnhancedPathShape;-class EnhancedPathParameter;-class KoShapeSavingContext;-class KoShapeLoadingContext;--/**- * An interaction handle used by the EnhancedPathShape for- * changing the shape interactively.- */-class EnhancedPathHandle-{-public:- /**- * Constructs a new empty handle;- *- * Note that an empty handle is not valid, as long as there are no- * positional parameters set with setPosition.- */- explicit EnhancedPathHandle(EnhancedPathShape *parent);-- /// Destroys the handle- ~EnhancedPathHandle();-- /**- * Evaluates the position of the handle.- * @return the actual handle position- */- QPointF position();-- /**- * Attempts to changes the position of the handle.- * Only the coordinates of the handle which reference a modifier- * can be changed. The new position is automatically stored into- * the modifier of the given enhanced path.- *- * @param position the new position the handle to set- * @param path the enhanced path the handle is referenced from- */- void changePosition(const QPointF &position);-- /// Returns if the handle has valid positional parameters.S- bool hasPosition() const;-- /**- * Sets the positional parameters, making the handle valid.- *- * It replaces the actual positional parameters.- *- * @param positionX the x-coordinate of the handle position- * @param positionY the y-coordinate of the handle position- */- void setPosition(EnhancedPathParameter *positionX, EnhancedPathParameter *positionY);-- /**- * Sets the range of the handles x-coordinate.- *- * A zero pointer has the effect of no maximum/minimum value.- *- * @param minX the minimum x-coordinate- * @param maxX the maximum x-coordinate- */- void setRangeX(EnhancedPathParameter *minX, EnhancedPathParameter *maxX);-- /**- * Sets the range of the handles y-coordinate.- *- * A zero pointer has the effect of no maximum/minimum value.- *- * @param minY the minimum y-coordinate- * @param maxY the maximum y-coordinate- */- void setRangeY(EnhancedPathParameter *minY, EnhancedPathParameter *maxY);-- /**- * Sets the center of a polar handle.- *- * If both parameters are valid pointers, then the handle behaves like- * a polar handle. This means the x-coordinate of the position represents- * an angle in degree and the y-coordinate a radius.- *- * @param polarX the polar center x-coordinate- * @param polarY the polar center y-coordinate- */- void setPolarCenter(EnhancedPathParameter *polarX, EnhancedPathParameter *polarY);-- /**- * Sets the range of the radius for polar handles.- * @param minRadius the minimum polar radius- * @param maxRadius the maximum polar radius- */- void setRadiusRange(EnhancedPathParameter *minRadius, EnhancedPathParameter *maxRadius);--private:- /// Returns if handle is polar- bool isPolar() const;- EnhancedPathShape *m_parent; ///< the enhanced path shape owning this handle- EnhancedPathParameter *m_positionX; ///< the position x-coordinate- EnhancedPathParameter *m_positionY; ///< the position y-coordinate- EnhancedPathParameter *m_minimumX; ///< the minimum x-coordinate- EnhancedPathParameter *m_minimumY; ///< the minimum y-coordinate- EnhancedPathParameter *m_maximumX; ///< the maximum x-coordinate- EnhancedPathParameter *m_maximumY; ///< the maximum y-coordinate- EnhancedPathParameter *m_polarX; ///< the polar center x-coordinate- EnhancedPathParameter *m_polarY; ///< the polar center y-coordinate- EnhancedPathParameter *m_minRadius; ///< the minimum polar radius- EnhancedPathParameter *m_maxRadius; ///< the maximum polar radius-};--#endif // KOENHANCEDPATHHANDLE_Hdiff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathParameter.cpp b/plugins/flake/pathshapes/enhancedpath/EnhancedPathParameter.cppdeleted file mode 100644index ec58415edd..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathParameter.cpp+++ /dev/null@@ -1,194 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#include "EnhancedPathParameter.h"-#include "EnhancedPathFormula.h"-#include "EnhancedPathShape.h"-#include <KoShapeBackground.h>-#include <KoUnit.h>-#include <math.h>--QString identifierData[] = {- "", // IdentifierUnknown- "pi", // IdentifierPi- "left", // IdentifierLeft- "top", // IdentifierTop- "right", // IdentifierRight- "bottom", // IdentifierBottom- "xstretch", // IdentifierXstretch- "ystretch", // IdentifierYstretch- "hasstroke", // IdentifierHasStroke- "hasfill", // IdentifierHasFill- "width", // IdentifierWidth- "height", // IdentifierHeight- "logwidth", // IdentifierLogwidth- "logheight" // IdentifierLogheight-};--EnhancedPathParameter::EnhancedPathParameter(EnhancedPathShape *parent)- : m_parent(parent)-{- Q_ASSERT(m_parent);-}--EnhancedPathParameter::~EnhancedPathParameter()-{-}--EnhancedPathShape *EnhancedPathParameter::parent()-{- return m_parent;-}--qreal EnhancedPathParameter::evaluate()-{- return 0.0;-}--void EnhancedPathParameter::modify(qreal value)-{- Q_UNUSED(value);-}--EnhancedPathConstantParameter::EnhancedPathConstantParameter(qreal value, EnhancedPathShape *parent)- : EnhancedPathParameter(parent)- , m_value(value)-{-}--qreal EnhancedPathConstantParameter::evaluate()-{- return m_value;-}--QString EnhancedPathConstantParameter::toString() const-{- return QString::number(m_value);-}--EnhancedPathNamedParameter::EnhancedPathNamedParameter(Identifier identifier, EnhancedPathShape *parent)- : EnhancedPathParameter(parent)- , m_identifier(identifier)-{-}--EnhancedPathNamedParameter::EnhancedPathNamedParameter(const QString &identifier, EnhancedPathShape *parent)- : EnhancedPathParameter(parent)-{- m_identifier = identifierFromString(identifier);-}--qreal EnhancedPathNamedParameter::evaluate()-{- const QRect &viewBox = parent()->viewBox();-- switch (m_identifier) {- case IdentifierPi:- return M_PI;- break;- case IdentifierLeft:- return viewBox.left();- break;- case IdentifierTop:- return viewBox.top();- break;- case IdentifierRight:- return viewBox.right();- break;- case IdentifierBottom:- return viewBox.bottom();- break;- case IdentifierXstretch:- break;- case IdentifierYstretch:- break;- case IdentifierHasStroke:- return parent()->stroke() ? 1.0 : 0.0;- break;- case IdentifierHasFill:- return parent()->background() ? 0.0 : 1.0;- break;- case IdentifierWidth:- return viewBox.width();- break;- case IdentifierHeight:- return viewBox.height();- break;- case IdentifierLogwidth:- // TODO: ? viewBox does not have any unit or const relation to mm- return KoUnit(KoUnit::Millimeter).toUserValue(viewBox.width()) * 100;- break;- case IdentifierLogheight:- // TODO: ? viewBox does not have any unit or const relation to mm- return KoUnit(KoUnit::Millimeter).toUserValue(viewBox.height()) * 100;- break;- default:- break;- }- return 0.0;-}--Identifier EnhancedPathNamedParameter::identifierFromString(const QString &text)-{- if (text.isEmpty()) {- return IdentifierUnknown;- } else if (text == "pi") {- return IdentifierPi;- } else if (text == "left") {- return IdentifierLeft;- } else if (text == "top") {- return IdentifierTop;- } else if (text == "right") {- return IdentifierRight;- } else if (text == "bottom") {- return IdentifierBottom;- } else if (text == "xstretch") {- return IdentifierXstretch;- } else if (text == "ystretch") {- return IdentifierYstretch;- } else if (text == "hasstroke") {- return IdentifierHasStroke;- } else if (text == "hasfill") {- return IdentifierHasFill;- } else if (text == "width") {- return IdentifierWidth;- } else if (text == "height") {- return IdentifierHeight;- } else if (text == "logwidth") {- return IdentifierLogwidth;- } else if (text == "logheight") {- return IdentifierLogheight;- } else {- return IdentifierUnknown;- }-}--QString EnhancedPathNamedParameter::toString() const-{- return identifierData[m_identifier];-}--EnhancedPathReferenceParameter::EnhancedPathReferenceParameter(const QString &reference, EnhancedPathShape *parent)- : EnhancedPathParameter(parent)- , m_reference(reference)-{-}--qreal EnhancedPathReferenceParameter::evaluate()-{- return parent()->evaluateReference(m_reference);-}--void EnhancedPathReferenceParameter::modify(qreal value)-{- parent()->modifyReference(m_reference, value);-}--QString EnhancedPathReferenceParameter::toString() const-{- return m_reference;-}-diff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathParameter.h b/plugins/flake/pathshapes/enhancedpath/EnhancedPathParameter.hdeleted file mode 100644index 3da4bd44ce..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathParameter.h+++ /dev/null@@ -1,91 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#ifndef KOENHANCEDPATHPARAMETER_H-#define KOENHANCEDPATHPARAMETER_H--#include <QString>--class EnhancedPathShape;--/// the different possible identifiers, taken from the odf spec-enum Identifier {- IdentifierUnknown, ///< unknown identifier- IdentifierPi, ///< value of pi.- IdentifierLeft, ///< left of svg:viewBox or draw:coordinate-origin-x- IdentifierTop, ///< top of svg:viewBox or draw:coordinate-origin-y- IdentifierRight, ///< right of svg:viewBox or draw:coordinate-origin-x + draw:coordinate-width- IdentifierBottom, ///< bottom of svg:viewBox or draw:coordinate-origin-y + draw:coordinate-height- IdentifierXstretch, ///< The value of draw:path-stretchpoint-x is used.- IdentifierYstretch, ///< The value of draw:path-stretchpoint-y is used.- IdentifierHasStroke, ///< If the shape has a line style, a value of 1 is used.- IdentifierHasFill, ///< If the shape has a fill style, a value of 1 is used.- IdentifierWidth, ///< The width of the svg:viewBox is used.- IdentifierHeight, ///< The height of the svg:viewBox is used.- IdentifierLogwidth, ///< The width of the svg:viewBox in 1/100th mm is used.- IdentifierLogheight ///< The height of the svg:viewBox in 1/100th mm is used.-};--/// The abstract parameter class-class EnhancedPathParameter-{-public:- explicit EnhancedPathParameter(EnhancedPathShape *parent);- virtual ~EnhancedPathParameter();- /// evaluates the parameter using the given path- virtual qreal evaluate() = 0;- /// modifies the parameter if possible, using the new value- virtual void modify(qreal value);- /// returns string representation of the parameter- virtual QString toString() const = 0;-protected:- EnhancedPathShape *parent();-private:- EnhancedPathShape *m_parent;-};--/// A constant parameter, a fixed value (i.e. 5, 11.3, -7)-class EnhancedPathConstantParameter : public EnhancedPathParameter-{-public:- /// Constructs the constant parameter with the given value- EnhancedPathConstantParameter(qreal value, EnhancedPathShape *parent);- qreal evaluate() override;- QString toString() const override;-private:- qreal m_value; ///< the constant value-};--/// A named parameter, one that refers to a variable of the path-class EnhancedPathNamedParameter : public EnhancedPathParameter-{-public:- /// Constructs named parameter from given identifier- EnhancedPathNamedParameter(Identifier identifier, EnhancedPathShape *parent);- /// Constructs named parameter from given identifier string- EnhancedPathNamedParameter(const QString &identifier, EnhancedPathShape *parent);- qreal evaluate() override;- /// Returns identifier type from given string- static Identifier identifierFromString(const QString &text);- QString toString() const override;-private:- Identifier m_identifier; ///< the identifier type-};--/// A referencing parameter, one that references another formula or a modifier-class EnhancedPathReferenceParameter : public EnhancedPathParameter-{-public:- /// Constructs reference parameter from the given reference string- explicit EnhancedPathReferenceParameter(const QString &reference, EnhancedPathShape *parent);- qreal evaluate() override;- void modify(qreal value) override;- QString toString() const override;-private:- QString m_reference; ///< the reference, formula or modifier-};--#endif // KOENHANCEDPATHPARAMETER_Hdiff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathShape.cpp b/plugins/flake/pathshapes/enhancedpath/EnhancedPathShape.cppdeleted file mode 100644index 7b720fbbaa..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathShape.cpp+++ /dev/null@@ -1,543 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007, 2010, 2011 Jan Hambrecht <[email protected]>- * SPDX-FileCopyrightText: 2009-2010 Thomas Zander <[email protected]>- * SPDX-FileCopyrightText: 2010 Carlos Licea <[email protected]>- * SPDX-FileCopyrightText: 2010 Nokia Corporation and /or its subsidiary(-ies).- * Contact: Suresh Chande [email protected]- * SPDX-FileCopyrightText: 2009-2010 Thorsten Zachmann <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#include <KoParameterShape_p.h>--#include "EnhancedPathShape.h"-#include "EnhancedPathCommand.h"-#include "EnhancedPathParameter.h"-#include "EnhancedPathHandle.h"-#include "EnhancedPathFormula.h"--#include <QPainterPath>--#include <KoXmlNS.h>-#include <KoXmlWriter.h>-#include <KoShapeSavingContext.h>-#include <KoUnit.h>-#include <KoPathPoint.h>--EnhancedPathShape::EnhancedPathShape(const QRect &viewBox)- : m_viewBox(viewBox)- , m_viewBoxOffset(0.0, 0.0)- , m_mirrorVertically(false)- , m_mirrorHorizontally(false)- , m_pathStretchPointX(-1)- , m_pathStretchPointY(-1)- , m_cacheResults(false)-{-}--EnhancedPathShape::EnhancedPathShape(const EnhancedPathShape &rhs)- : KoParameterShape(rhs),- m_viewBox(rhs.m_viewBox),- m_viewBound(rhs.m_viewBound),- m_viewMatrix(rhs.m_viewMatrix),- m_mirrorMatrix(rhs.m_mirrorMatrix),- m_viewBoxOffset(rhs.m_viewBoxOffset),- m_textArea(rhs.m_textArea),- m_commands(rhs.m_commands),- m_enhancedHandles(rhs.m_enhancedHandles),- m_formulae(rhs.m_formulae),- m_modifiers(rhs.m_modifiers),- m_parameters(rhs.m_parameters),- m_mirrorVertically(rhs.m_mirrorVertically),- m_mirrorHorizontally(rhs.m_mirrorHorizontally),- m_pathStretchPointX(rhs.m_pathStretchPointX),- m_pathStretchPointY(rhs.m_pathStretchPointY),- m_resultCache(rhs.m_resultCache),- m_cacheResults(rhs.m_cacheResults)-{-}--EnhancedPathShape::~EnhancedPathShape()-{- reset();-}--KoShape *EnhancedPathShape::cloneShape() const-{- return new EnhancedPathShape(*this);-}--void EnhancedPathShape::reset()-{- qDeleteAll(m_commands);- m_commands.clear();- qDeleteAll(m_enhancedHandles);- m_enhancedHandles.clear();- setHandles(QList<QPointF>());- qDeleteAll(m_formulae);- m_formulae.clear();- qDeleteAll(m_parameters);- m_parameters.clear();- m_modifiers.clear();- m_viewMatrix.reset();- m_viewBoxOffset = QPointF();- clear();- m_textArea.clear();-}--void EnhancedPathShape::moveHandleAction(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers)-{- Q_UNUSED(modifiers);- EnhancedPathHandle *handle = m_enhancedHandles[ handleId ];- if (handle) {- handle->changePosition(shapeToViewbox(point));- }-}--void EnhancedPathShape::updatePath(const QSizeF &size)-{- if (isParametricShape()) {- clear();- enableResultCache(true);-- foreach (EnhancedPathCommand *cmd, m_commands) {- cmd->execute();- }-- enableResultCache(false);-- qreal stretchPointsScale = 1;- bool isStretched = useStretchPoints(size, stretchPointsScale);- m_viewBound = outline().boundingRect();- m_mirrorMatrix.reset();- m_mirrorMatrix.translate(m_viewBound.center().x(), m_viewBound.center().y());- m_mirrorMatrix.scale(m_mirrorHorizontally ? -1 : 1, m_mirrorVertically ? -1 : 1);- m_mirrorMatrix.translate(-m_viewBound.center().x(), -m_viewBound.center().y());- QTransform matrix(1.0, 0.0, 0.0, 1.0, m_viewBoxOffset.x(), m_viewBoxOffset.y());-- // if stretch points are set than stretch the path manually- if (isStretched) {- //if the path was stretched manually the stretch matrix is not more valid- //and it has to be recalculated so that stretching in x and y direction is the same- matrix.scale(stretchPointsScale, stretchPointsScale);- matrix = m_mirrorMatrix * matrix;- } else {- matrix = m_mirrorMatrix * m_viewMatrix * matrix;- }- foreach (KoSubpath *subpath, subpaths()) {- foreach (KoPathPoint *point, *subpath) {- point->map(matrix);- }- }-- const int handleCount = m_enhancedHandles.count();- QList<QPointF> handles;- for (int i = 0; i < handleCount; ++i) {- handles.append(matrix.map(m_enhancedHandles[i]->position()));- }- setHandles(handles);-- normalize();- }-}--void EnhancedPathShape::setSize(const QSizeF &newSize)-{- // handle offset- KoParameterShape::setSize(newSize);-- // calculate scaling factors from viewbox size to shape size- qreal xScale = m_viewBound.width() == 0 ? 1 : newSize.width() / m_viewBound.width();- qreal yScale = m_viewBound.height() == 0 ? 1 : newSize.height() / m_viewBound.height();-- // create view matrix, take mirroring into account- m_viewMatrix.reset();- m_viewMatrix.scale(xScale, yScale);-- updatePath(newSize);-}--QPointF EnhancedPathShape::normalize()-{- QPointF offset = KoParameterShape::normalize();-- m_viewBoxOffset -= offset;-- return offset;-}--QPointF EnhancedPathShape::shapeToViewbox(const QPointF &point) const-{- return (m_mirrorMatrix * m_viewMatrix).inverted().map(point - m_viewBoxOffset);-}--void EnhancedPathShape::evaluateHandles()-{- const int handleCount = m_enhancedHandles.count();- QList<QPointF> handles;- for (int i = 0; i < handleCount; ++i) {- handles.append(m_enhancedHandles[i]->position());- }- setHandles(handles);-}--QRect EnhancedPathShape::viewBox() const-{- return m_viewBox;-}--qreal EnhancedPathShape::evaluateReference(const QString &reference)-{- if (reference.isEmpty()) {- return 0.0;- }-- const char c = reference[0].toLatin1();-- qreal res = 0.0;-- switch (c) {- // referenced modifier- case '$': {- bool success = false;- int modifierIndex = reference.mid(1).toInt(&success);- res = m_modifiers.value(modifierIndex);- break;- }- // referenced formula- case '?': {- QString fname = reference.mid(1);- if (m_cacheResults && m_resultCache.contains(fname)) {- res = m_resultCache.value(fname);- } else {- FormulaStore::const_iterator formulaIt = m_formulae.constFind(fname);- if (formulaIt != m_formulae.constEnd()) {- EnhancedPathFormula *formula = formulaIt.value();- if (formula) {- res = formula->evaluate();- if (m_cacheResults) {- m_resultCache.insert(fname, res);- }- }- }- }- break;- }- // maybe an identifier ?- default:- EnhancedPathNamedParameter p(reference, this);- res = p.evaluate();- break;- }-- return res;-}--qreal EnhancedPathShape::evaluateConstantOrReference(const QString &val)-{- bool ok = true;- qreal res = val.toDouble(&ok);- if (ok) {- return res;- }- return evaluateReference(val);-}--void EnhancedPathShape::modifyReference(const QString &reference, qreal value)-{- if (reference.isEmpty()) {- return;- }-- const char c = reference[0].toLatin1();-- if (c == '$') {- bool success = false;- int modifierIndex = reference.mid(1).toInt(&success);- if (modifierIndex >= 0 && modifierIndex < m_modifiers.count()) {- m_modifiers[modifierIndex] = value;- }- }-}--EnhancedPathParameter *EnhancedPathShape::parameter(const QString &text)-{- Q_ASSERT(! text.isEmpty());-- ParameterStore::const_iterator parameterIt = m_parameters.constFind(text);- if (parameterIt != m_parameters.constEnd()) {- return parameterIt.value();- } else {- EnhancedPathParameter *parameter = 0;- const char c = text[0].toLatin1();- if (c == '$' || c == '?') {- parameter = new EnhancedPathReferenceParameter(text, this);- } else {- bool success = false;- qreal constant = text.toDouble(&success);- if (success) {- parameter = new EnhancedPathConstantParameter(constant, this);- } else {- Identifier identifier = EnhancedPathNamedParameter::identifierFromString(text);- if (identifier != IdentifierUnknown) {- parameter = new EnhancedPathNamedParameter(identifier, this);- }- }- }-- if (parameter) {- m_parameters[text] = parameter;- }-- return parameter;- }-}--void EnhancedPathShape::addFormula(const QString &name, const QString &formula)-{- if (name.isEmpty() || formula.isEmpty()) {- return;- }-- m_formulae[name] = new EnhancedPathFormula(formula, this);-}--void EnhancedPathShape::addHandle(const QMap<QString, QVariant> &handle)-{- if (handle.isEmpty()) {- return;- }-- if (!handle.contains("draw:handle-position")) {- return;- }- QVariant position = handle.value("draw:handle-position");-- QStringList tokens = position.toString().simplified().split(' ');- if (tokens.count() < 2) {- return;- }-- EnhancedPathHandle *newHandle = new EnhancedPathHandle(this);- newHandle->setPosition(parameter(tokens[0]), parameter(tokens[1]));-- // check if we have a polar handle- if (handle.contains("draw:handle-polar")) {- QVariant polar = handle.value("draw:handle-polar");- QStringList tokens = polar.toString().simplified().split(' ');- if (tokens.count() == 2) {- newHandle->setPolarCenter(parameter(tokens[0]), parameter(tokens[1]));-- QVariant minRadius = handle.value("draw:handle-radius-range-minimum");- QVariant maxRadius = handle.value("draw:handle-radius-range-maximum");- if (minRadius.isValid() && maxRadius.isValid()) {- newHandle->setRadiusRange(parameter(minRadius.toString()), parameter(maxRadius.toString()));- }- }- } else {- QVariant minX = handle.value("draw:handle-range-x-minimum");- QVariant maxX = handle.value("draw:handle-range-x-maximum");- if (minX.isValid() && maxX.isValid()) {- newHandle->setRangeX(parameter(minX.toString()), parameter(maxX.toString()));- }-- QVariant minY = handle.value("draw:handle-range-y-minimum");- QVariant maxY = handle.value("draw:handle-range-y-maximum");- if (minY.isValid() && maxY.isValid()) {- newHandle->setRangeY(parameter(minY.toString()), parameter(maxY.toString()));- }- }-- m_enhancedHandles.append(newHandle);-- evaluateHandles();-}--void EnhancedPathShape::addModifiers(const QString &modifiers)-{- if (modifiers.isEmpty()) {- return;- }-- QStringList tokens = modifiers.simplified().split(' ');- int tokenCount = tokens.count();- for (int i = 0; i < tokenCount; ++i) {- m_modifiers.append(tokens[i].toDouble());- }-}--void EnhancedPathShape::addCommand(const QString &command)-{- addCommand(command, true);-}--void EnhancedPathShape::addCommand(const QString &command, bool triggerUpdate)-{- QString commandStr = command.simplified();- if (commandStr.isEmpty()) {- return;- }-- // the first character is the command- EnhancedPathCommand *cmd = new EnhancedPathCommand(commandStr[0], this);-- // strip command char- commandStr = commandStr.mid(1).simplified();-- // now parse the command parameters- if (!commandStr.isEmpty()) {- QStringList tokens = commandStr.split(' ');- for (int i = 0; i < tokens.count(); ++i) {- cmd->addParameter(parameter(tokens[i]));- }- }- m_commands.append(cmd);-- if (triggerUpdate) {- updatePath(size());- }-}--bool EnhancedPathShape::useStretchPoints(const QSizeF &size, qreal &scale)-{- bool retval = false;- if (m_pathStretchPointX != -1 && m_pathStretchPointY != -1) {- qreal scaleX = size.width();- qreal scaleY = size.height();- if (qreal(m_viewBox.width()) / m_viewBox.height() < qreal(scaleX) / scaleY) {- qreal deltaX = (scaleX * m_viewBox.height()) / scaleY - m_viewBox.width();- foreach (KoSubpath *subpath, subpaths()) {- foreach (KoPathPoint *currPoint, *subpath) {- if (currPoint->point().x() >= m_pathStretchPointX &&- currPoint->controlPoint1().x() >= m_pathStretchPointX &&- currPoint->controlPoint2().x() >= m_pathStretchPointX) {- currPoint->setPoint(QPointF(currPoint->point().x() + deltaX, currPoint->point().y()));- currPoint->setControlPoint1(QPointF(currPoint->controlPoint1().x() + deltaX,- currPoint->controlPoint1().y()));- currPoint->setControlPoint2(QPointF(currPoint->controlPoint2().x() + deltaX,- currPoint->controlPoint2().y()));- retval = true;- }- }- }- scale = scaleY / m_viewBox.height();- } else if (qreal(m_viewBox.width()) / m_viewBox.height() > qreal(scaleX) / scaleY) {- qreal deltaY = (m_viewBox.width() * scaleY) / scaleX - m_viewBox.height();- foreach (KoSubpath *subpath, subpaths()) {- foreach (KoPathPoint *currPoint, *subpath) {- if (currPoint->point().y() >= m_pathStretchPointY &&- currPoint->controlPoint1().y() >= m_pathStretchPointY &&- currPoint->controlPoint2().y() >= m_pathStretchPointY) {- currPoint->setPoint(QPointF(currPoint->point().x(), currPoint->point().y() + deltaY));- currPoint->setControlPoint1(QPointF(currPoint->controlPoint1().x(),- currPoint->controlPoint1().y() + deltaY));- currPoint->setControlPoint2(QPointF(currPoint->controlPoint2().x(),- currPoint->controlPoint2().y() + deltaY));- retval = true;- }- }- }- scale = scaleX / m_viewBox.width();- }-- notifyPointsChanged();- }- return retval;-}--void EnhancedPathShape::parsePathData(const QString &data)-{- if (data.isEmpty()) {- return;- }-- int start = -1;- bool separator = true;- for (int i = 0; i < data.length(); ++i) {- QChar ch = data.at(i);- ushort uni_ch = ch.unicode();- if (separator && (uni_ch == 'M' || uni_ch == 'L'- || uni_ch == 'C' || uni_ch == 'Z'- || uni_ch == 'N' || uni_ch == 'F'- || uni_ch == 'S' || uni_ch == 'T'- || uni_ch == 'U' || uni_ch == 'A'- || uni_ch == 'B' || uni_ch == 'W'- || uni_ch == 'V' || uni_ch == 'X'- || uni_ch == 'Y' || uni_ch == 'Q')) {- if (start != -1) { // process last chars- addCommand(data.mid(start, i - start), false);- }- start = i;- }- separator = ch.isSpace();- }- if (start < data.length()) {- addCommand(data.mid(start));- }- if (start != -1) {- updatePath(size());- }-}--void EnhancedPathShape::setMirrorHorizontally(bool mirrorHorizontally)-{- if (m_mirrorHorizontally != mirrorHorizontally) {- m_mirrorHorizontally = mirrorHorizontally;- updatePath(size());- }--}--void EnhancedPathShape::setMirrorVertically(bool mirrorVertically)-{- if (m_mirrorVertically != mirrorVertically) {- m_mirrorVertically = mirrorVertically;- updatePath(size());- }-}--void EnhancedPathShape::shapeChanged(ChangeType type, KoShape *shape)-{- KoParameterShape::shapeChanged(type, shape);-- if (!shape || shape == this) {- if (type == ParentChanged || type == ParameterChanged) {- updateTextArea();- }- }-}--void EnhancedPathShape::updateTextArea()-{- if (m_textArea.size() >= 4) {- QRectF r = m_viewBox;- r.setLeft(evaluateConstantOrReference(m_textArea[0]));- r.setTop(evaluateConstantOrReference(m_textArea[1]));- r.setRight(evaluateConstantOrReference(m_textArea[2]));- r.setBottom(evaluateConstantOrReference(m_textArea[3]));- r = m_viewMatrix.mapRect(r).translated(m_viewBoxOffset);- }-}--void EnhancedPathShape::enableResultCache(bool enable)-{- m_resultCache.clear();- m_cacheResults = enable;-}--void EnhancedPathShape::setPathStretchPointX(qreal pathStretchPointX)-{- if (m_pathStretchPointX != pathStretchPointX) {- m_pathStretchPointX = pathStretchPointX;- }--}--void EnhancedPathShape::setPathStretchPointY(qreal pathStretchPointY)-{- if (m_pathStretchPointY != pathStretchPointY) {- m_pathStretchPointY = pathStretchPointY;- }--}diff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathShape.h b/plugins/flake/pathshapes/enhancedpath/EnhancedPathShape.hdeleted file mode 100644index 85295e19e7..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathShape.h+++ /dev/null@@ -1,168 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007, 2010, 2011 Jan Hambrecht <[email protected]>- * SPDX-FileCopyrightText: 2010 Carlos Licea <[email protected]>- * SPDX-FileCopyrightText: 2010 Nokia Corporation and /or its subsidiary(-ies).- * Contact: Suresh Chande [email protected]- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#ifndef KOENHANCEDPATHSHAPE_H-#define KOENHANCEDPATHSHAPE_H--#include <KoParameterShape.h>-#include <QList>-#include <QMap>-#include <QRectF>-#include <QStringList>--#define EnhancedPathShapeId "EnhancedPathShape"--class EnhancedPathCommand;-class EnhancedPathHandle;-class EnhancedPathFormula;-class EnhancedPathParameter;-class KoShapeSavingContext;-class KoShapeLoadingContext;--/**- * An enhanced shape is a custom shape which can be defined- * by enhanced geometry data.- * The data consists of a list of commands like moveto,- * lineto, curveto, etc. which are used to create the outline- * of the shape. The coordinates or parameters of the commands- * can be constant values, named variables (identifiers),- * modifiers, functions or formulae.-*/-class EnhancedPathShape : public KoParameterShape-{-public:- EnhancedPathShape(const QRect &viewBox);- ~EnhancedPathShape() override;-- KoShape* cloneShape() const override;-- /**- * Evaluates the given reference to a identifier, modifier or formula.- * @param reference the reference to evaluate- * @return the result of the evaluation- */- qreal evaluateReference(const QString &reference);-- /**- * Evaluates the given constant or reference to a identifier, modifier- * or formula.- * @param val the value to evaluate- * @return the result of the evaluation- */- qreal evaluateConstantOrReference(const QString &val);-- /**- * Attempts to modify a given reference.- *- * Only modifiers can me modified, others silently ignore the attempt.- *- * @param reference the reference to modify- * @param value the new value- */- void modifyReference(const QString &reference, qreal value);-- // from KoShape- void setSize(const QSizeF &newSize) override;- // from KoParameterShape- QPointF normalize() override;-- /// Add formula with given name and textual representation- void addFormula(const QString &name, const QString &formula);-- /// Add a single handle with format: x y minX maxX minY maxY- void addHandle(const QMap<QString, QVariant> &handle);-- /// Add modifiers with format: modifier0 modifier1 modifier2 ...- void addModifiers(const QString &modifiers);-- /// Add command for instance "M 0 0"- void addCommand(const QString &command);-- /// Returns the viewbox of the enhanced path shape- QRect viewBox() const;-- /// Converts from shape coordinates to viewbox coordinates- QPointF shapeToViewbox(const QPointF &point) const;-- /// Sets if the shape is to be mirrored horizontally before applying any other transformations- //NOTE: in the standard nothing is mentioned about the priorities of the transformations"- //it's assumed like this because of the behavior shown in OOo- void setMirrorHorizontally(bool mirrorHorizontally);-- /// Sets if the shape is to be mirrored vertically before applying any other transformations- //NOTE: in the standard nothing is mentioned about the priorities of the transformations"- //it's assumed like this because of the behavior shown in OOo- void setMirrorVertically(bool mirrorVertically);-- // Sets member variable representing draw:path-stretchpoint-x attribute- void setPathStretchPointX(qreal pathStretchPointX);-- // Sets member variable representing draw:path-stretchpoint-y attribute- void setPathStretchPointY(qreal pathStretchPointY);-- /// Returns parameter from given textual representation- EnhancedPathParameter *parameter(const QString &text);--protected:- //from KoShape- void shapeChanged(ChangeType type, KoShape *shape = 0) override;- // from KoParameterShape- void moveHandleAction(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers = Qt::NoModifier) override;- // from KoParameterShape- void updatePath(const QSizeF &size) override;--private:- EnhancedPathShape(const EnhancedPathShape &rhs);-- void evaluateHandles();- void reset();-- /// parses the enhanced path data- void parsePathData(const QString &data);-- /// Adds a new command- void addCommand(const QString &command, bool triggerUpdate);-- /// Updates the size and position of an optionally existing text-on-shape text area- void updateTextArea();-- /// Enables caching results- void enableResultCache(bool enable);-- // This function checks if draw:path-stretchpoint-x or draw:path-stretchpoint-y attributes are set.- // If the attributes are set the path shape coordinates (m_subpaths) are changed so that the form- // of the shape is preserved after stretching. It is needed for example in round-rectangles, to- // have the corners round after stretching. Without it the corners would be elliptical.- // Returns true if any points were actually changed, otherwise false.- bool useStretchPoints(const QSizeF &size, qreal &scale);-- typedef QMap<QString, EnhancedPathFormula *> FormulaStore;- typedef QList<qreal> ModifierStore;- typedef QMap<QString, EnhancedPathParameter *> ParameterStore;-- QRect m_viewBox; ///< the viewbox rectangle- QRectF m_viewBound; ///< the bounding box of the path in viewbox coordinates- QTransform m_viewMatrix; ///< matrix to convert from viewbox coordinates to shape coordinates- QTransform m_mirrorMatrix; ///< matrix to used for mirroring- QPointF m_viewBoxOffset;- QStringList m_textArea;- QList<EnhancedPathCommand *> m_commands; ///< the commands creating the outline- QList<EnhancedPathHandle *> m_enhancedHandles; ///< the handles for modifying the shape- FormulaStore m_formulae; ///< the formulae- ModifierStore m_modifiers; ///< the modifier values- ParameterStore m_parameters; ///< the shared parameters- bool m_mirrorVertically; ///<whether or not the shape is to be mirrored vertically before transforming it- bool m_mirrorHorizontally; ///<whether or not the shape is to be mirrored horizontally before transforming it- qreal m_pathStretchPointX; ///< draw:path-stretchpoint-x attribute- qreal m_pathStretchPointY; ///< draw:path-stretchpoint-y attribute- QHash<QString, qreal> m_resultCache; ///< cache for intermediate results used when evaluating path- bool m_cacheResults; ///< indicates if result cache is enabled-};--#endif // KOENHANCEDPATHSHAPE_Hdiff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathShapeFactory.cpp b/plugins/flake/pathshapes/enhancedpath/EnhancedPathShapeFactory.cppdeleted file mode 100644index a5c0b7f4e6..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathShapeFactory.cpp+++ /dev/null@@ -1,554 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#include "enhancedpath/EnhancedPathShapeFactory.h"-#include "enhancedpath/EnhancedPathShape.h"--#include <KoShapeStroke.h>-#include <KoProperties.h>-#include <KoXmlNS.h>-#include <KoColorBackground.h>-#include <KoShapeLoadingContext.h>--#include <KoIcon.h>--#include <klocalizedstring.h>-#include "kis_pointer_utils.h"--#include <QString>--#include <math.h>--EnhancedPathShapeFactory::EnhancedPathShapeFactory()- : KoShapeFactoryBase(EnhancedPathShapeId, i18n("An enhanced path shape"))-{- setToolTip(i18n("An enhanced path"));- setIconName(koIconNameCStr("krita_draw_path"));- setXmlElementNames(KoXmlNS::draw, QStringList("custom-shape"));- setLoadingPriority(1);--// addCross();-// addArrow();-// addCallout();-// addSmiley();-// addCircularArrow();-// addGearhead();-}--KoShape *EnhancedPathShapeFactory::createDefaultShape(KoDocumentResourceManager *) const-{- EnhancedPathShape *shape = new EnhancedPathShape(QRect(0, 0, 100, 100));- shape->setStroke(toQShared(new KoShapeStroke(1.0)));- shape->setShapeId(KoPathShapeId);-- shape->addModifiers("35");-- shape->addFormula("Right", "width - $0");- shape->addFormula("Bottom", "height - $0");- shape->addFormula("Half", "min(0.5 * height, 0.5 * width)");-- shape->addCommand("M $0 0");- shape->addCommand("L ?Right 0 ?Right $0 width $0 width ?Bottom ?Right ?Bottom");- shape->addCommand("L ?Right height $0 height $0 ?Bottom 0 ?Bottom 0 $0 $0 $0");- shape->addCommand("Z");-- ComplexType handle;- handle["draw:handle-position"] = "$0 0";- handle["draw:handle-range-x-minimum"] = '0';- handle["draw:handle-range-x-maximum"] = "?Half";- shape->addHandle(handle);- shape->setSize(QSize(100, 100));-- return shape;-}--KoShape *EnhancedPathShapeFactory::createShape(const KoProperties *params, KoDocumentResourceManager *) const-{- QVariant viewboxData;- const QRect viewBox = (params->property(QLatin1String("viewBox"), viewboxData)) ?- viewboxData.toRect() :- QRect(0, 0, 100, 100);-- EnhancedPathShape *shape = new EnhancedPathShape(viewBox);-- shape->setShapeId(KoPathShapeId);- shape->setStroke(toQShared(new KoShapeStroke(1.0)));- shape->addModifiers(params->stringProperty("modifiers"));-- ListType handles = params->property("handles").toList();- foreach (const QVariant &v, handles) {- shape->addHandle(v.toMap());- }-- ComplexType formulae = params->property("formulae").toMap();- ComplexType::const_iterator formula = formulae.constBegin();- ComplexType::const_iterator lastFormula = formulae.constEnd();- for (; formula != lastFormula; ++formula) {- shape->addFormula(formula.key(), formula.value().toString());- }-- QStringList commands = params->property("commands").toStringList();- foreach (const QString &cmd, commands) {- shape->addCommand(cmd);- }-- QVariant color;- if (params->property("background", color)) {- shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(color.value<QColor>())));- }- QSizeF size = shape->size();- if (size.width() > size.height()) {- shape->setSize(QSizeF(100, 100 * size.height() / size.width()));- } else {- shape->setSize(QSizeF(100 * size.width() / size.height(), 100));- }-- return shape;-}--KoProperties *EnhancedPathShapeFactory::dataToProperties(- const QString &modifiers, const QStringList &commands,- const ListType &handles, const ComplexType &formulae) const-{- KoProperties *props = new KoProperties();- props->setProperty("modifiers", modifiers);- props->setProperty("commands", commands);- props->setProperty("handles", handles);- props->setProperty("formulae", formulae);- props->setProperty("background", QVariant::fromValue<QColor>(QColor(Qt::red)));-- return props;-}--void EnhancedPathShapeFactory::addCross()-{- QString modifiers("35");-- QStringList commands;- commands.append("M $0 0");- commands.append("L ?Right 0 ?Right $0 width $0 width ?Bottom ?Right ?Bottom");- commands.append("L ?Right height $0 height $0 ?Bottom 0 ?Bottom 0 $0 $0 $0");- commands.append("Z");-- ListType handles;- ComplexType handle;- handle["draw:handle-position"] = "$0 0";- handle["draw:handle-range-x-minimum"] = '0';- handle["draw:handle-range-x-maximum"] = "?Half";- handles.append(QVariant(handle));-- ComplexType formulae;- formulae["Right"] = "width - $0";- formulae["Bottom"] = "height - $0";- formulae["Half"] = "min(0.5 * height, 0.5 * width)";-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "cross";- t.name = i18n("Cross");- t.family = "funny";- t.toolTip = i18n("A cross");- t.iconName = koIconName("cross-shape");- t.properties = dataToProperties(modifiers, commands, handles, formulae);-- addTemplate(t);-}--void EnhancedPathShapeFactory::addArrow()-{- {- // arrow right- QString modifiers("60 35");-- QStringList commands;- commands.append("M $0 $1");- commands.append("L $0 0 width ?HalfHeight $0 height $0 ?LowerCorner 0 ?LowerCorner 0 $1");- commands.append("Z");-- ListType handles;- ComplexType handle;- handle["draw:handle-position"] = "$0 $1";- handle["draw:handle-range-x-minimum"] = '0';- handle["draw:handle-range-x-maximum"] = "width";- handle["draw:handle-range-y-minimum"] = '0';- handle["draw:handle-range-y-maximum"] = "?HalfHeight";- handles.append(QVariant(handle));-- ComplexType formulae;- formulae["HalfHeight"] = "0.5 * height";- formulae["LowerCorner"] = "height - $1";-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "arrow_right";- t.name = i18n("Arrow");- t.family = "arrow";- t.toolTip = i18n("An arrow");- t.iconName = koIconName("draw-arrow-forward");- t.properties = dataToProperties(modifiers, commands, handles, formulae);-- addTemplate(t);- }-- {- // arrow left- QString modifiers("40 35");-- QStringList commands;- commands.append("M $0 $1");- commands.append("L $0 0 0 ?HalfHeight $0 height $0 ?LowerCorner width ?LowerCorner width $1");- commands.append("Z");-- ListType handles;- ComplexType handle;- handle["draw:handle-position"] = "$0 $1";- handle["draw:handle-range-x-minimum"] = '0';- handle["draw:handle-range-x-maximum"] = "width";- handle["draw:handle-range-y-minimum"] = '0';- handle["draw:handle-range-y-maximum"] = "?HalfHeight";- handles.append(QVariant(handle));-- ComplexType formulae;- formulae["HalfHeight"] = "0.5 * height";- formulae["LowerCorner"] = "height - $1";-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "arrow_left";- t.name = i18n("Arrow");- t.family = "arrow";- t.toolTip = i18n("An arrow");- t.iconName = koIconName("draw-arrow-back");- t.properties = dataToProperties(modifiers, commands, handles, formulae);-- addTemplate(t);- }-- {- // arrow top- QString modifiers("35 40");-- QStringList commands;- commands.append("M $0 $1");- commands.append("L 0 $1 ?HalfWidth 0 width $1 ?RightCorner $1 ?RightCorner height $0 height");- commands.append("Z");-- ListType handles;- ComplexType handle;- handle["draw:handle-position"] = "$0 $1";- handle["draw:handle-range-x-minimum"] = '0';- handle["draw:handle-range-x-maximum"] = "?HalfWidth";- handle["draw:handle-range-y-minimum"] = '0';- handle["draw:handle-range-y-maximum"] = "height";- handles.append(QVariant(handle));-- ComplexType formulae;- formulae["HalfWidth"] = "0.5 * width";- formulae["RightCorner"] = "width - $0";-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "arrow_top";- t.name = i18n("Arrow");- t.family = "arrow";- t.toolTip = i18n("An arrow");- t.iconName = koIconName("draw-arrow-up");- t.properties = dataToProperties(modifiers, commands, handles, formulae);-- addTemplate(t);- }-- {- // arrow bottom- QString modifiers("35 60");-- QStringList commands;- commands.append("M $0 $1");- commands.append("L 0 $1 ?HalfWidth height width $1 ?RightCorner $1 ?RightCorner 0 $0 0");- commands.append("Z");-- ListType handles;- ComplexType handle;- handle["draw:handle-position"] = "$0 $1";- handle["draw:handle-range-x-minimum"] = '0';- handle["draw:handle-range-x-maximum"] = "?HalfWidth";- handle["draw:handle-range-y-minimum"] = '0';- handle["draw:handle-range-y-maximum"] = "height";- handles.append(QVariant(handle));-- ComplexType formulae;- formulae["HalfWidth"] = "0.5 * width";- formulae["RightCorner"] = "width - $0";-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "arrow_bottom";- t.name = i18n("Arrow");- t.family = "arrow";- t.toolTip = i18n("An arrow");- t.iconName = koIconName("draw-arrow-down");- t.properties = dataToProperties(modifiers, commands, handles, formulae);-- addTemplate(t);- }-}--void EnhancedPathShapeFactory::addCallout()-{- QString modifiers("4250 45000");-- QStringList commands;- commands.append("M 3590 0");- commands.append("X 0 3590");- commands.append("L ?f2 ?f3 0 8970 0 12630 ?f4 ?f5 0 18010");- commands.append("Y 3590 21600");- commands.append("L ?f6 ?f7 8970 21600 12630 21600 ?f8 ?f9 18010 21600");- commands.append("X 21600 18010");- commands.append("L ?f10 ?f11 21600 12630 21600 8970 ?f12 ?f13 21600 3590");- commands.append("Y 18010 0");- commands.append("L ?f14 ?f15 12630 0 8970 0 ?f16 ?f17");- commands.append("Z");- commands.append("N");-- ComplexType formulae;- formulae["f0"] = "$0 -10800";- formulae["f1"] = "$1 -10800";- formulae["f2"] = "if(?f18 ,$0 ,0)";- formulae["f3"] = "if(?f18 ,$1 ,6280)";- formulae["f4"] = "if(?f23 ,$0 ,0)";- formulae["f5"] = "if(?f23 ,$1 ,15320)";- formulae["f6"] = "if(?f26 ,$0 ,6280)";- formulae["f7"] = "if(?f26 ,$1 ,21600)";- formulae["f8"] = "if(?f29 ,$0 ,15320)";- formulae["f9"] = "if(?f29 ,$1 ,21600)";- formulae["f10"] = "if(?f32 ,$0 ,21600)";- formulae["f11"] = "if(?f32 ,$1 ,15320)";- formulae["f12"] = "if(?f34 ,$0 ,21600)";- formulae["f13"] = "if(?f34 ,$1 ,6280)";- formulae["f14"] = "if(?f36 ,$0 ,15320)";- formulae["f15"] = "if(?f36 ,$1 ,0)";- formulae["f16"] = "if(?f38 ,$0 ,6280)";- formulae["f17"] = "if(?f38 ,$1 ,0)";- formulae["f18"] = "if($0 ,-1,?f19)";- formulae["f19"] = "if(?f1 ,-1,?f22)";- formulae["f20"] = "abs(?f0)";- formulae["f21"] = "abs(?f1)";- formulae["f22"] = "?f20 -?f21";- formulae["f23"] = "if($0 ,-1,?f24)";- formulae["f24"] = "if(?f1 ,?f22 ,-1)";- formulae["f25"] = "$1 -21600";- formulae["f26"] = "if(?f25 ,?f27 ,-1)";- formulae["f27"] = "if(?f0 ,-1,?f28)";- formulae["f28"] = "?f21 -?f20";- formulae["f29"] = "if(?f25 ,?f30 ,-1)";- formulae["f30"] = "if(?f0 ,?f28 ,-1)";- formulae["f31"] = "$0 -21600";- formulae["f32"] = "if(?f31 ,?f33 ,-1)";- formulae["f33"] = "if(?f1 ,?f22 ,-1)";- formulae["f34"] = "if(?f31 ,?f35 ,-1)";- formulae["f35"] = "if(?f1 ,-1,?f22)";- formulae["f36"] = "if($1 ,-1,?f37)";- formulae["f37"] = "if(?f0 ,?f28 ,-1)";- formulae["f38"] = "if($1 ,-1,?f39)";- formulae["f39"] = "if(?f0 ,-1,?f28)";- formulae["f40"] = "$0";- formulae["f41"] = "$1";-- ListType handles;- ComplexType handle;- handle["draw:handle-position"] = "$0 $1";- handles.append(QVariant(handle));-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "callout";- t.name = i18n("Callout");- t.family = "funny";- t.toolTip = i18n("A callout");- t.iconName = koIconName("callout-shape");- KoProperties *properties = dataToProperties(modifiers, commands, handles, formulae);- properties->setProperty(QLatin1String("viewBox"), QRect(0, 0, 21600, 21600));- t.properties = properties;-- addTemplate(t);-}--void EnhancedPathShapeFactory::addSmiley()-{- QString modifiers("17520");-- QStringList commands;- commands.append("U 10800 10800 10800 10800 0 23592960");- commands.append("Z");- commands.append("N");- commands.append("U 7305 7515 1165 1165 0 23592960");- commands.append("Z");- commands.append("N");- commands.append("U 14295 7515 1165 1165 0 23592960");- commands.append("Z");- commands.append("N");- commands.append("M 4870 ?f1");- commands.append("C 8680 ?f2 12920 ?f2 16730 ?f1");- commands.append("Z");- commands.append("F");- commands.append("N");-- ComplexType formulae;- formulae["f0"] = "$0 -15510";- formulae["f1"] = "17520-?f0";- formulae["f2"] = "15510+?f0";-- ListType handles;- ComplexType handle;- handle["draw:handle-position"] = "10800 $0";- handle["draw:handle-range-y-minimum"] = "15510";- handle["draw:handle-range-y-maximum"] = "17520";- handles.append(QVariant(handle));-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "smiley";- t.name = i18n("Smiley");- t.family = "funny";- t.toolTip = i18n("Smiley");- t.iconName = koIconName("smiley-shape");- KoProperties *properties = dataToProperties(modifiers, commands, handles, formulae);- properties->setProperty(QLatin1String("viewBox"), QRect(0, 0, 21600, 21600));- t.properties = properties;-- addTemplate(t);-}--void EnhancedPathShapeFactory::addCircularArrow()-{- QString modifiers("180 0 5500");-- QStringList commands;- commands.append("B ?f3 ?f3 ?f20 ?f20 ?f19 ?f18 ?f17 ?f16");- commands.append("W 0 0 21600 21600 ?f9 ?f8 ?f11 ?f10");- commands.append("L ?f24 ?f23 ?f36 ?f35 ?f29 ?f28");- commands.append("Z");- commands.append("N");-- ComplexType formulae;-- formulae["f0"] = "$0";- formulae["f1"] = "$1";- formulae["f2"] = "$2";- formulae["f3"] = "10800+$2";- formulae["f4"] = "10800*sin($0 *(pi/180))";- formulae["f5"] = "10800*cos($0 *(pi/180))";- formulae["f6"] = "10800*sin($1 *(pi/180))";- formulae["f7"] = "10800*cos($1 *(pi/180))";- formulae["f8"] = "?f4 +10800";- formulae["f9"] = "?f5 +10800";- formulae["f10"] = "?f6 +10800";- formulae["f11"] = "?f7 +10800";- formulae["f12"] = "?f3 *sin($0 *(pi/180))";- formulae["f13"] = "?f3 *cos($0 *(pi/180))";- formulae["f14"] = "?f3 *sin($1 *(pi/180))";- formulae["f15"] = "?f3 *cos($1 *(pi/180))";- formulae["f16"] = "?f12 +10800";- formulae["f17"] = "?f13 +10800";- formulae["f18"] = "?f14 +10800";- formulae["f19"] = "?f15 +10800";- formulae["f20"] = "21600-?f3";- formulae["f21"] = "13500*sin($1 *(pi/180))";- formulae["f22"] = "13500*cos($1 *(pi/180))";- formulae["f23"] = "?f21 +10800";- formulae["f24"] = "?f22 +10800";- formulae["f25"] = "$2 -2700";- formulae["f26"] = "?f25 *sin($1 *(pi/180))";- formulae["f27"] = "?f25 *cos($1 *(pi/180))";- formulae["f28"] = "?f26 +10800";- formulae["f29"] = "?f27 +10800";- formulae["f30"] = "($1+45)*pi/180";- formulae["f31"] = "sqrt(((?f29-?f24)*(?f29-?f24))+((?f28-?f23)*(?f28-?f23)))";- formulae["f32"] = "sqrt(2)/2*?f31";- formulae["f33"] = "?f32*sin(?f30)";- formulae["f34"] = "?f32*cos(?f30)";- formulae["f35"] = "?f28+?f33";- formulae["f36"] = "?f29+?f34";-- ListType handles;- ComplexType handle;- handle["draw:handle-position"] = "$0 10800";- handle["draw:handle-polar"] = "10800 10800";- handle["draw:handle-radius-range-minimum"] = "10800";- handle["draw:handle-radius-range-maximum"] = "10800";- handles.append(QVariant(handle));-- handle.clear();- handle["draw:handle-position"] = "$1 $2";- handle["draw:handle-polar"] = "10800 10800";- handle["draw:handle-radius-range-minimum"] = '0';- handle["draw:handle-radius-range-maximum"] = "10800";- handles.append(QVariant(handle));-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "circulararrow";- t.name = i18n("Circular Arrow");- t.family = "arrow";- t.toolTip = i18n("A circular-arrow");- t.iconName = koIconName("circular-arrow-shape");- KoProperties *properties = dataToProperties(modifiers, commands, handles, formulae);- properties->setProperty(QLatin1String("viewBox"), QRect(0, 0, 21600, 21600));- t.properties = properties;- addTemplate(t);-}--void EnhancedPathShapeFactory::addGearhead()-{- QStringList commands;- commands.append("M 20 70");- commands.append("L 20 100 30 100 30 50 30 70 40 70 40 40 0 40 0 70 10 70 10 50 10 100 20 100");- commands.append("Z");- commands.append("N");-- uint toothCount = 10;- qreal toothAngle = 360.0 / qreal(toothCount);- //kDebug() <<"toothAngle =" << toothAngle;- qreal outerRadius = 0.5 * 25.0;- qreal innerRadius = 0.5 * 17.0;- QPointF center(20, 25);- qreal radian = (270.0 - 0.35 * toothAngle) * M_PI / 180.0;- commands.append(QString("M %1 %2").arg(center.x() + innerRadius * cos(radian)).arg(center.y() + innerRadius * sin(radian)));- QString cmd("L");- for (uint i = 0; i < toothCount; ++i) {- radian += 0.15 * toothAngle * M_PI / 180.0;- cmd += QString(" %1 %2").arg(center.x() + outerRadius * cos(radian)).arg(center.y() + outerRadius * sin(radian));- radian += 0.35 * toothAngle * M_PI / 180.0;- cmd += QString(" %1 %2").arg(center.x() + outerRadius * cos(radian)).arg(center.y() + outerRadius * sin(radian));- radian += 0.15 * toothAngle * M_PI / 180.0;- cmd += QString(" %1 %2").arg(center.x() + innerRadius * cos(radian)).arg(center.y() + innerRadius * sin(radian));- radian += 0.35 * toothAngle * M_PI / 180.0;- cmd += QString(" %1 %2").arg(center.x() + innerRadius * cos(radian)).arg(center.y() + innerRadius * sin(radian));- }- //kDebug() <<"gear command =" << cmd;- commands.append(cmd);- commands.append("Z");- commands.append("N");-- KoShapeTemplate t;- t.id = KoPathShapeId;- t.templateId = "gearhead";- t.name = i18n("Gearhead");- t.family = "funny";- t.toolTip = i18n("A gearhead");- t.iconName = koIconName("gearhead-shape");- KoProperties *properties = dataToProperties(QString(), commands, ListType(), ComplexType());- properties->setProperty("background", QVariant::fromValue<QColor>(QColor(Qt::blue)));- properties->setProperty(QLatin1String("viewBox"), QRect(0, 0, 40, 90));- t.properties = properties;- addTemplate(t);-}--bool EnhancedPathShapeFactory::supports(const QDomElement &e, KoShapeLoadingContext &context) const-{- Q_UNUSED(context);- return (e.localName() == "custom-shape" && e.namespaceURI() == KoXmlNS::draw);-}diff --git a/plugins/flake/pathshapes/enhancedpath/EnhancedPathShapeFactory.h b/plugins/flake/pathshapes/enhancedpath/EnhancedPathShapeFactory.hdeleted file mode 100644index 89dc372d54..0000000000--- a/plugins/flake/pathshapes/enhancedpath/EnhancedPathShapeFactory.h+++ /dev/null@@ -1,39 +0,0 @@-/* This file is part of the KDE project- * SPDX-FileCopyrightText: 2007 Jan Hambrecht <[email protected]>- *- * SPDX-License-Identifier: LGPL-2.0-or-later- */--#ifndef KOENHANCEDPATHSHAPEFACTORY_H-#define KOENHANCEDPATHSHAPEFACTORY_H--#include <KoShapeFactoryBase.h>--class KoShape;--/// Factory for path shapes-class EnhancedPathShapeFactory : public KoShapeFactoryBase-{-public:- /// constructor- EnhancedPathShapeFactory();- ~EnhancedPathShapeFactory() override {}- KoShape *createShape(const KoProperties *params, KoDocumentResourceManager *documentResources = 0) const override;- KoShape *createDefaultShape(KoDocumentResourceManager *documentResources = 0) const override;- bool supports(const QDomElement &e, KoShapeLoadingContext &context) const override;-private:- void addCross();- void addArrow();- void addCallout();- void addSmiley();- void addCircularArrow();- void addGearhead();-- typedef QMap<QString, QVariant > ComplexType;- typedef QList<QVariant> ListType;- KoProperties *dataToProperties(const QString &modifiers, const QStringList &commands,- const ListType &handles, const ComplexType &formulae) const;--};--#endif // KOENHANCEDPATHSHAPEFACTORY_H