File indexing completed on 2024-06-23 04:27:03
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 KOENHANCEDPATHHANDLE_H 0008 #define KOENHANCEDPATHHANDLE_H 0009 0010 #include <QPointF> 0011 #include <QDomDocument> 0012 0013 class EnhancedPathShape; 0014 class EnhancedPathParameter; 0015 class KoShapeSavingContext; 0016 class KoShapeLoadingContext; 0017 0018 /** 0019 * An interaction handle used by the EnhancedPathShape for 0020 * changing the shape interactively. 0021 */ 0022 class EnhancedPathHandle 0023 { 0024 public: 0025 /** 0026 * Constructs a new empty handle; 0027 * 0028 * Note that an empty handle is not valid, as long as there are no 0029 * positional parameters set with setPosition. 0030 */ 0031 explicit EnhancedPathHandle(EnhancedPathShape *parent); 0032 0033 /// Destroys the handle 0034 ~EnhancedPathHandle(); 0035 0036 /** 0037 * Evaluates the position of the handle. 0038 * @return the actual handle position 0039 */ 0040 QPointF position(); 0041 0042 /** 0043 * Attempts to changes the position of the handle. 0044 * Only the coordinates of the handle which reference a modifier 0045 * can be changed. The new position is automatically stored into 0046 * the modifier of the given enhanced path. 0047 * 0048 * @param position the new position the handle to set 0049 * @param path the enhanced path the handle is referenced from 0050 */ 0051 void changePosition(const QPointF &position); 0052 0053 /// Returns if the handle has valid positional parameters.S 0054 bool hasPosition() const; 0055 0056 /** 0057 * Sets the positional parameters, making the handle valid. 0058 * 0059 * It replaces the actual positional parameters. 0060 * 0061 * @param positionX the x-coordinate of the handle position 0062 * @param positionY the y-coordinate of the handle position 0063 */ 0064 void setPosition(EnhancedPathParameter *positionX, EnhancedPathParameter *positionY); 0065 0066 /** 0067 * Sets the range of the handles x-coordinate. 0068 * 0069 * A zero pointer has the effect of no maximum/minimum value. 0070 * 0071 * @param minX the minimum x-coordinate 0072 * @param maxX the maximum x-coordinate 0073 */ 0074 void setRangeX(EnhancedPathParameter *minX, EnhancedPathParameter *maxX); 0075 0076 /** 0077 * Sets the range of the handles y-coordinate. 0078 * 0079 * A zero pointer has the effect of no maximum/minimum value. 0080 * 0081 * @param minY the minimum y-coordinate 0082 * @param maxY the maximum y-coordinate 0083 */ 0084 void setRangeY(EnhancedPathParameter *minY, EnhancedPathParameter *maxY); 0085 0086 /** 0087 * Sets the center of a polar handle. 0088 * 0089 * If both parameters are valid pointers, then the handle behaves like 0090 * a polar handle. This means the x-coordinate of the position represents 0091 * an angle in degree and the y-coordinate a radius. 0092 * 0093 * @param polarX the polar center x-coordinate 0094 * @param polarY the polar center y-coordinate 0095 */ 0096 void setPolarCenter(EnhancedPathParameter *polarX, EnhancedPathParameter *polarY); 0097 0098 /** 0099 * Sets the range of the radius for polar handles. 0100 * @param minRadius the minimum polar radius 0101 * @param maxRadius the maximum polar radius 0102 */ 0103 void setRadiusRange(EnhancedPathParameter *minRadius, EnhancedPathParameter *maxRadius); 0104 0105 private: 0106 /// Returns if handle is polar 0107 bool isPolar() const; 0108 EnhancedPathShape *m_parent; ///< the enhanced path shape owning this handle 0109 EnhancedPathParameter *m_positionX; ///< the position x-coordinate 0110 EnhancedPathParameter *m_positionY; ///< the position y-coordinate 0111 EnhancedPathParameter *m_minimumX; ///< the minimum x-coordinate 0112 EnhancedPathParameter *m_minimumY; ///< the minimum y-coordinate 0113 EnhancedPathParameter *m_maximumX; ///< the maximum x-coordinate 0114 EnhancedPathParameter *m_maximumY; ///< the maximum y-coordinate 0115 EnhancedPathParameter *m_polarX; ///< the polar center x-coordinate 0116 EnhancedPathParameter *m_polarY; ///< the polar center y-coordinate 0117 EnhancedPathParameter *m_minRadius; ///< the minimum polar radius 0118 EnhancedPathParameter *m_maxRadius; ///< the maximum polar radius 0119 }; 0120 0121 #endif // KOENHANCEDPATHHANDLE_H