00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KOPATHCOMMAND_H
00022 #define KOPATHCOMMAND_H
00023
00024 #include <kcommand.h>
00025 #include <QList>
00026 #include <QMap>
00027 #include <QPointF>
00028 #include "KoPathShape.h"
00029
00030 class KoParameterShape;
00031
00033 class KoPathBaseCommand : public KCommand {
00034 public:
00036 KoPathBaseCommand( KoPathShape *shape );
00037 protected:
00042 void repaint( const QRectF &oldControlPointRect );
00043 KoPathShape *m_shape;
00044 };
00045
00047 class KoPointMoveCommand : public KCommand
00048 {
00049 public:
00055 KoPointMoveCommand( const KoPathShapePointMap &pointMap, const QPointF &offset );
00056
00058 void execute();
00060 void unexecute();
00062 QString name() const;
00063 private:
00064 KoPathShapePointMap m_pointMap;
00065 QPointF m_offset;
00066 };
00067
00069 class KoControlPointMoveCommand : public KCommand
00070 {
00071 public:
00078 KoControlPointMoveCommand( KoPathPoint *point, const QPointF &offset, KoPathPoint::KoPointType pointType );
00080 void execute();
00082 void unexecute();
00084 QString name() const;
00085 private:
00086 KoPathPoint * m_point;
00087
00088 QPointF m_offset;
00089 KoPathPoint::KoPointType m_pointType;
00090 };
00091
00093 class KoPointPropertyCommand : public KoPathBaseCommand {
00094 public:
00101 KoPointPropertyCommand( KoPathShape *shape, KoPathPoint *point, KoPathPoint::KoPointProperties property );
00103 void execute();
00105 void unexecute();
00107 QString name() const;
00108 private:
00109 KoPathPoint* m_point;
00110 KoPathPoint::KoPointProperties m_newProperties;
00111 KoPathPoint::KoPointProperties m_oldProperties;
00112 QPointF m_controlPoint1;
00113 QPointF m_controlPoint2;
00114 };
00115
00117 class KoPointRemoveCommand : public KCommand {
00118 public:
00123 KoPointRemoveCommand( const KoPathShapePointMap &pointMap );
00125 void execute();
00127 void unexecute();
00129 QString name() const;
00130 private:
00131 struct KoPointRemoveData
00132 {
00133 KoPointRemoveData( KoPathPoint * point, KoSubpath * subpath, int position )
00134 : m_point( point )
00135 , m_subpath( subpath )
00136 , m_position( position )
00137 {}
00138 KoPathPoint * m_point;
00139 KoSubpath * m_subpath;
00140 int m_position;
00141 };
00142 KoPathShapePointMap m_pointMap;
00143 QList<KoPointRemoveData> m_data;
00144 };
00145
00147 class KoSegmentSplitCommand : public KoPathBaseCommand
00148 {
00149 public:
00156 KoSegmentSplitCommand( KoPathShape *shape, const KoPathSegment &segment, double splitPosition );
00163 KoSegmentSplitCommand( KoPathShape *shape, const QList<KoPathSegment> &segments, const QList<double> &splitPositions );
00170 KoSegmentSplitCommand( KoPathShape *shape, const QList<KoPathSegment> &segments, double splitPosition );
00171 virtual ~KoSegmentSplitCommand();
00173 void execute();
00175 void unexecute();
00177 QString name() const;
00178 private:
00179 QList<KoPathSegment> m_segments;
00180 typedef QPair<KoPathPoint,KoPathPoint> KoSegmentData;
00181 QList<KoSegmentData> m_oldNeighbors;
00182 QList<KoSegmentData> m_newNeighbors;
00183 QList<double> m_splitPos;
00184 QList<KoPathPoint*> m_splitPoints;
00185 bool m_deletePoint;
00186 QList< QPair<KoSubpath*,int> > m_splitPointPos;
00187 };
00188
00190 class KoPointJoinCommand : public KoPathBaseCommand
00191 {
00192 public:
00199 KoPointJoinCommand( KoPathShape *shape, KoPathPoint *point1, KoPathPoint *point2 );
00201 void execute();
00203 void unexecute();
00205 QString name() const;
00206 private:
00207 KoPathPoint* m_point1;
00208 KoPathPoint* m_point2;
00209 bool m_joined;
00210 };
00211
00213 class KoSubpathBreakCommand : public KoPathBaseCommand
00214 {
00215 public:
00221 KoSubpathBreakCommand( KoPathShape *shape, KoPathPoint *breakPoint );
00227 KoSubpathBreakCommand( KoPathShape *shape, const KoPathSegment &segment );
00228 virtual ~KoSubpathBreakCommand();
00230 void execute();
00232 void unexecute();
00234 QString name() const;
00235 private:
00236 KoPathPoint* m_breakPoint;
00237 KoPathSegment m_segment;
00238 bool m_breakSegment;
00239 bool m_broken;
00240 KoPathPoint* m_newPoint;
00241 KoPathPoint m_pointData1;
00242 KoPathPoint m_pointData2;
00243 };
00244
00246 class KoSegmentTypeCommand : public KoPathBaseCommand
00247 {
00248 public:
00255 KoSegmentTypeCommand( KoPathShape *shape, const KoPathSegment &segment, bool changeToLine );
00262 KoSegmentTypeCommand( KoPathShape *shape, const QList<KoPathSegment> &segments, bool changeToLine );
00264 void execute();
00266 void unexecute();
00268 QString name() const;
00269 private:
00270 QList<KoPathSegment> m_segments;
00271 QMap<KoPathPoint*,KoPathPoint> m_oldPointData;
00272 bool m_changeToLine;
00273 };
00274
00275 class KoShapeControllerBase;
00276
00278 class KoPathCombineCommand : public KCommand
00279 {
00280 public:
00286 KoPathCombineCommand( KoShapeControllerBase *controller, const QList<KoPathShape*> &paths );
00287 virtual ~KoPathCombineCommand();
00289 void execute();
00291 void unexecute();
00293 QString name() const;
00294 private:
00295 KoShapeControllerBase *m_controller;
00296 QList<KoPathShape*> m_paths;
00297 KoPathShape *m_combinedPath;
00298 bool m_isCombined;
00299 };
00300
00302 class KoParameterChangeCommand : public KCommand
00303 {
00304 public:
00305 KoParameterChangeCommand( KoParameterShape *shape, int handleId, const QPointF &startPoint, const QPointF &endPoint );
00306 virtual ~KoParameterChangeCommand();
00307
00309 void execute();
00311 void unexecute();
00313 QString name() const;
00314 private:
00315 KoParameterShape *m_shape;
00316 int m_handleId;
00317 QPointF m_startPoint;
00318 QPointF m_endPoint;
00319 };
00320
00322 class KoParameterToPathCommand : public KCommand
00323 {
00324 public:
00325 KoParameterToPathCommand( KoParameterShape *shape );
00326 virtual ~KoParameterToPathCommand();
00327
00329 void execute();
00331 void unexecute();
00333 QString name() const;
00334 private:
00335 KoParameterShape *m_shape;
00336 };
00337
00339 class KoPathSeparateCommand : public KCommand
00340 {
00341 public:
00347 KoPathSeparateCommand( KoShapeControllerBase *controller, const QList<KoPathShape*> &paths );
00348 virtual ~KoPathSeparateCommand();
00350 void execute();
00352 void unexecute();
00354 QString name() const;
00355 private:
00356 KoShapeControllerBase *m_controller;
00357 QList<KoPathShape*> m_paths;
00358 QList<KoPathShape*> m_separatedPaths;
00359 bool m_isSeparated;
00360 };
00361
00362 #endif