Warning, file /office/calligra/libs/flake/KoParameterShape.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org> 0003 Copyright (C) 2007 Thomas Zander <zander@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KOPARAMETERSHAPE_H 0022 #define KOPARAMETERSHAPE_H 0023 0024 #include "KoPathShape.h" 0025 #include "flake_export.h" 0026 0027 class KoParameterShapePrivate; 0028 0029 /** 0030 * KoParameterShape is the base class for all parametric shapes 0031 * in flake. 0032 * Parametric shapes are those whose appearance can be completely 0033 * defined by a few numerical parameters. Rectangle, ellipse and star 0034 * are examples of parametric shapes. 0035 * In flake, these shape parameters can be manipulated visually by means 0036 * of control points. These control points can be moved with the mouse 0037 * on the canvas which changes the shapes parameter values and hence the 0038 * shapes appearance in realtime. 0039 * KoParameterShape is derived from the KoPathShape class that means 0040 * by changing the shape parameters, the underlying path is manipulated. 0041 * A parametric shape can be converted into a path shape by simply calling 0042 * the setModified method. This makes the path tool know that it can handle 0043 * the shape like a path shape, so that modifying the single path points 0044 * is possible. 0045 */ 0046 class FLAKE_EXPORT KoParameterShape : public KoPathShape 0047 { 0048 public: 0049 KoParameterShape(); 0050 ~KoParameterShape() override; 0051 0052 /** 0053 * @brief Move handle to point 0054 * 0055 * This method calls moveHandleAction. Overload moveHandleAction to get the behaviour you want. 0056 * After that updatePath and a repaint is called. 0057 * 0058 * @param handleId the id of the handle to move 0059 * @param point the point to move the handle to in document coordinates 0060 * @param modifiers the keyboard modifiers used during moving the handle 0061 */ 0062 void moveHandle(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers = Qt::NoModifier); 0063 0064 /** 0065 * @brief Get the id of the handle within the given rect 0066 * 0067 * @param rect the rect in shape coordinates 0068 * @return id of the found handle or -1 if none was found 0069 */ 0070 int handleIdAt(const QRectF &rect) const; 0071 0072 /** 0073 * @brief Get the handle position 0074 * 0075 * @param handleId the id of the handle for which to get the position in shape coordinates 0076 */ 0077 QPointF handlePosition(int handleId) const; 0078 0079 /** 0080 * @brief Paint the handles 0081 * 0082 * @param painter the painter to paint the handles on 0083 * @param converter the view converter for applying the actual zoom 0084 * @param handleRadius the radius of the handles used for painting 0085 */ 0086 void paintHandles(QPainter &painter, const KoViewConverter &converter, int handleRadius); 0087 0088 /** 0089 * @brief Paint the given handles 0090 * 0091 * @param painter the painter to paint the handles on 0092 * @param converter the view converter for applying the actual zoom 0093 * @param handleId of the handle which should be repainted 0094 * @param handleRadius the radius of the handle used for painting 0095 */ 0096 void paintHandle(QPainter &painter, const KoViewConverter &converter, int handleId, int handleRadius); 0097 0098 /// reimplemented from KoShape 0099 void setSize(const QSizeF &size) override; 0100 0101 /** 0102 * @brief Check if object is a parametric shape 0103 * 0104 * It is no longer a parametric shape when the path was manipulated 0105 * 0106 * @return true if it is a parametric shape, false otherwise 0107 */ 0108 bool isParametricShape() const; 0109 0110 /** 0111 * @brief Set if the shape can be modified using parameters 0112 * 0113 * After the state is set to false it is no longer possible to work 0114 * with parameters on this shape. 0115 * 0116 * @param parametric the new state 0117 * @see isParametricShape 0118 */ 0119 void setParametricShape(bool parametric); 0120 0121 QPointF normalize() override; 0122 0123 /// return the number of handles set on the shape 0124 int handleCount() const; 0125 0126 protected: 0127 /** 0128 * Get the handle positions for manipulating the parameters. 0129 * @see setHandles, handleCount() 0130 */ 0131 QVector<QPointF> handles() const; 0132 0133 /** 0134 * Set the new handle positions which are used by the user to manipulate the parameters. 0135 * @see handles(), handleCount() 0136 */ 0137 void setHandles(const QVector<QPointF> &handles); 0138 0139 /// constructor 0140 KoParameterShape(KoParameterShapePrivate &); 0141 0142 /** 0143 * @brief Updates the internal state of a KoParameterShape. 0144 * 0145 * This method is called from moveHandle. 0146 * 0147 * @param handleId of the handle 0148 * @param point to move the handle to in shape coordinates 0149 * @param modifiers used during move to point 0150 */ 0151 virtual void moveHandleAction(int handleId, const QPointF & point, Qt::KeyboardModifiers modifiers = Qt::NoModifier) = 0; 0152 0153 /** 0154 * @brief Update the path of the parameter shape 0155 * 0156 * @param size of the shape 0157 */ 0158 virtual void updatePath(const QSizeF &size) = 0; 0159 0160 private: 0161 Q_DECLARE_PRIVATE(KoParameterShape) 0162 }; 0163 0164 #endif /* KOPARAMETERSHAPE_H */