File indexing completed on 2024-06-23 04:27:02
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KOENHANCEDPATHCOMMAND_H 0008 #define KOENHANCEDPATHCOMMAND_H 0009 0010 #include <QChar> 0011 #include <QList> 0012 #include <QPointF> 0013 #include <QRectF> 0014 0015 class EnhancedPathShape; 0016 class EnhancedPathParameter; 0017 class KoPathPoint; 0018 0019 /** 0020 * A EnhancedPathCommand is a command like moveto, curveto, etc. 0021 * that directly modifies an enhanced paths outline. 0022 */ 0023 class EnhancedPathCommand 0024 { 0025 public: 0026 /// Constructs a new command from the given command type 0027 EnhancedPathCommand(const QChar &command, EnhancedPathShape *parent); 0028 ~EnhancedPathCommand(); 0029 /// Executes the command on the specified path shape 0030 bool execute(); 0031 /// Adds a new parameter to the command 0032 void addParameter(EnhancedPathParameter *parameter); 0033 /// Returns a string representation of the command 0034 QString toString() const; 0035 private: 0036 /// Returns a list of points, created from the parameter list 0037 QList<QPointF> pointsFromParameters(); 0038 /// Calculates angle from given point 0039 qreal angleFromPoint(const QPointF &point) const; 0040 /// Returns sweep angle from start to stop and given direction 0041 qreal radSweepAngle(qreal start, qreal stop, bool clockwise) const; 0042 /// Returns sweep angle from start to stop and given direction 0043 qreal degSweepAngle(qreal start, qreal stop, bool clockwise) const; 0044 /// Returns the last path point of given path 0045 KoPathPoint *lastPathPoint() const; 0046 /// Returns rectangle from given points 0047 QRectF rectFromPoints(const QPointF &tl, const QPointF &br) const; 0048 0049 QChar m_command; ///< the actual command 0050 QList<EnhancedPathParameter *> m_parameters; ///< the commands parameters 0051 EnhancedPathShape *m_parent; ///< the enhanced path owning the command 0052 }; 0053 0054 #endif // KOENHANCEDPATHCOMMAND_H