File indexing completed on 2025-02-02 04:14:48
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2006, 2008 Jan Hambrecht <jaham@gmx.net> 0003 * SPDX-FileCopyrightText: 2006, 2007 Thorsten Zachmann <zachmann@kde.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KOPATHPOINTTYPECOMMAND_H 0009 #define KOPATHPOINTTYPECOMMAND_H 0010 0011 #include <kundo2command.h> 0012 #include <QList> 0013 #include "KoPathBaseCommand.h" 0014 #include "KoPathPoint.h" 0015 #include "KoPathPointData.h" 0016 #include "kritaflake_export.h" 0017 0018 /// The undo / redo command for changing the path point type. 0019 class KRITAFLAKE_EXPORT KoPathPointTypeCommand : public KoPathBaseCommand 0020 { 0021 public: 0022 /// The type of the point 0023 enum PointType { 0024 Corner, 0025 Smooth, 0026 Symmetric, 0027 Line, 0028 Curve 0029 }; 0030 /** 0031 * Command to change the type of the given points 0032 * @param pointDataList List of point for changing the points 0033 * @param pointType the new point type to set 0034 * @param parent the parent command used for macro commands 0035 */ 0036 KoPathPointTypeCommand(const QList<KoPathPointData> &pointDataList, PointType pointType, KUndo2Command *parent = 0); 0037 ~KoPathPointTypeCommand() override; 0038 0039 /// redo the command 0040 void redo() override; 0041 /// revert the actions done in redo 0042 void undo() override; 0043 0044 static void makeCubicPointSmooth(KoPathPoint *point); 0045 0046 private: 0047 // used for storing the data for undo 0048 struct PointData { 0049 PointData(const KoPathPointData pointData) 0050 : m_pointData(pointData) {} 0051 KoPathPointData m_pointData; 0052 // old control points in document coordinates 0053 QPointF m_oldControlPoint1; 0054 QPointF m_oldControlPoint2; 0055 KoPathPoint::PointProperties m_oldProperties; 0056 bool m_hadControlPoint1 {false}; 0057 bool m_hadControlPoint2 {false}; 0058 }; 0059 0060 bool appendPointData(KoPathPointData data); 0061 void undoChanges(const QList<PointData> &data); 0062 0063 PointType m_pointType; 0064 QList<PointData> m_oldPointData; 0065 QList<PointData> m_additionalPointData; 0066 }; 0067 0068 #endif // KOPATHPOINTTYPECOMMAND_H