File: EnhancedPathHandle.h

package info (click to toggle)
calligra 1%3A3.2.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 261,632 kB
  • sloc: cpp: 650,836; xml: 27,662; python: 6,044; perl: 2,724; yacc: 1,817; ansic: 1,325; sh: 1,277; lex: 1,107; ruby: 1,010; javascript: 495; makefile: 17
file content (142 lines) | stat: -rw-r--r-- 5,114 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* This file is part of the KDE project
 * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef KOENHANCEDPATHHANDLE_H
#define KOENHANCEDPATHHANDLE_H

#include <QPointF>
#include <KoXmlReaderForward.h>

class EnhancedPathShape;
class EnhancedPathParameter;
class KoShapeSavingContext;
class KoShapeLoadingContext;

/**
 * An interaction handle used by the EnhancedPathShape for
 * changing the shape interactively.
 */
class EnhancedPathHandle
{
public:
    /**
     * Constructs a new empty handle;
     *
     * Note that an empty handle is not valid, as long as there are no
     * positional parameters set with setPosition.
    */
    explicit EnhancedPathHandle(EnhancedPathShape *parent);

    /// Destroys the handle
    ~EnhancedPathHandle();

    /**
     * Evaluates the position of the handle.
     * @return the actual handle position
     */
    QPointF position();

    /**
     * Attempts to changes the position of the handle.
     * Only the coordinates of the handle which reference a modifier
     * can be changed. The new position is automatically stored into
     * the modifier of the given enhanced path.
     *
     * @param position the new position the handle to set
     * @param path the enhanced path the handle is referenced from
     */
    void changePosition(const QPointF &position);

    /// Returns if the handle has valid positional parameters.S
    bool hasPosition() const;

    /**
     * Sets the positional parameters, making the handle valid.
     *
     * It replaces the actual positional parameters.
     *
     * @param positionX the x-coordinate of the handle position
     * @param positionY the y-coordinate of the handle position
     */
    void setPosition(EnhancedPathParameter *positionX, EnhancedPathParameter *positionY);

    /**
     * Sets the range of the handles x-coordinate.
     *
     * A zero pointer has the effect of no maximum/minimum value.
     *
     * @param minX the minimum x-coordinate
     * @param maxX the maximum x-coordinate
     */
    void setRangeX(EnhancedPathParameter *minX, EnhancedPathParameter *maxX);

    /**
     * Sets the range of the handles y-coordinate.
     *
     * A zero pointer has the effect of no maximum/minimum value.
     *
     * @param minY the minimum y-coordinate
     * @param maxY the maximum y-coordinate
     */
    void setRangeY(EnhancedPathParameter *minY, EnhancedPathParameter *maxY);

    /**
     * Sets the center of a polar handle.
     *
     * If both parameters are valid pointers, then the handle behaves like
     * a polar handle. This means the x-coordinate of the position represents
     * an angle in degree and the y-coordinate a radius.
     * 
     * @param polarX the polar center x-coordinate
     * @param polarY the polar center y-coordinate
     */
    void setPolarCenter(EnhancedPathParameter *polarX, EnhancedPathParameter *polarY);

    /**
     * Sets the range of the radius for polar handles.
     * @param minRadius the minimum polar radius
     * @param maxRadius the maximum polar radius
     */
    void setRadiusRange(EnhancedPathParameter *minRadius, EnhancedPathParameter *maxRadius);

    /// save to the given shape saving context
    void saveOdf(KoShapeSavingContext &context) const;
    /// load handle from given element
    bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context);

    QString positionX() const;
    QString positionY() const;

private:
    /// Returns if handle is polar
    bool isPolar() const;
    EnhancedPathShape *m_parent; ///< the enhanced path shape owning this handle
    EnhancedPathParameter *m_positionX; ///< the position x-coordinate 
    EnhancedPathParameter *m_positionY; ///< the position y-coordinate
    EnhancedPathParameter *m_minimumX;  ///< the minimum x-coordinate
    EnhancedPathParameter *m_minimumY;  ///< the minmum y-coordinate
    EnhancedPathParameter *m_maximumX;  ///< the maximum x-coordinate
    EnhancedPathParameter *m_maximumY;  ///< the maximum y-coordinate
    EnhancedPathParameter *m_polarX;    ///< the polar center x-coordinate
    EnhancedPathParameter *m_polarY;    ///< the polar center y-coordinate
    EnhancedPathParameter *m_minRadius; ///< the minimum polar radius
    EnhancedPathParameter *m_maxRadius; ///< the maximum polar radius
};

#endif // KOENHANCEDPATHHANDLE_H