28 handles.push_back(QPointF(100, 0));
29 handles.push_back(QPointF(100, 0));
31 QSizeF
size(100, 100);
37 m_cornerRadiusX(rhs.m_cornerRadiusX),
38 m_cornerRadiusY(rhs.m_cornerRadiusY)
56 qreal width2 =
size().width() / 2.0;
57 qreal height2 =
size().height() / 2.0;
62 }
else if (
p.x() >
size().width()) {
63 p.setX(
size().width());
67 if (!(modifiers & Qt::ControlModifier)) {
74 }
else if (
p.y() > height2) {
77 p.setX(
size().width());
79 if (!(modifiers & Qt::ControlModifier)) {
112 qreal x2 =
size.width() - rx;
113 qreal y2 =
size.height() - ry;
115 QPointF curvePoints[12];
117 int requiredCurvePointCount = 4;
119 requiredCurvePointCount += 2;
122 requiredCurvePointCount += 2;
134 points[cp]->setPoint(QPointF(rx, 0));
135 points[cp]->removeControlPoint1();
136 points[cp]->removeControlPoint2();
140 points[++cp]->setPoint(QPointF(x2, 0));
141 points[cp]->removeControlPoint1();
142 points[cp]->removeControlPoint2();
147 arcToCurve(rx, ry, 90, -90, points[cp]->point(), curvePoints);
148 points[cp]->setControlPoint2(curvePoints[0]);
149 points[++cp]->setControlPoint1(curvePoints[1]);
150 points[cp]->setPoint(curvePoints[2]);
151 points[cp]->removeControlPoint2();
156 points[++cp]->setPoint(QPointF(
size.width(), y2));
157 points[cp]->removeControlPoint1();
158 points[cp]->removeControlPoint2();
163 arcToCurve(rx, ry, 0, -90, points[cp]->point(), curvePoints);
164 points[cp]->setControlPoint2(curvePoints[0]);
165 points[++cp]->setControlPoint1(curvePoints[1]);
166 points[cp]->setPoint(curvePoints[2]);
167 points[cp]->removeControlPoint2();
172 points[++cp]->setPoint(QPointF(rx,
size.height()));
173 points[cp]->removeControlPoint1();
174 points[cp]->removeControlPoint2();
179 arcToCurve(rx, ry, 270, -90, points[cp]->point(), curvePoints);
180 points[cp]->setControlPoint2(curvePoints[0]);
181 points[++cp]->setControlPoint1(curvePoints[1]);
182 points[cp]->setPoint(curvePoints[2]);
183 points[cp]->removeControlPoint2();
188 points[++cp]->setPoint(QPointF(0, ry));
189 points[cp]->removeControlPoint1();
190 points[cp]->removeControlPoint2();
195 arcToCurve(rx, ry, 180, -90, points[cp]->point(), curvePoints);
196 points[cp]->setControlPoint2(curvePoints[0]);
197 points[0]->setControlPoint1(curvePoints[1]);
198 points[0]->setPoint(curvePoints[2]);
202 for (
int i = 1; i < cp; ++i) {
220 int currentPointCount =
subpaths()[0]->count();
221 if (currentPointCount > requiredPointCount) {
222 for (
int i = 0; i < currentPointCount - requiredPointCount; ++i) {
226 }
else if (requiredPointCount > currentPointCount) {
227 for (
int i = 0; i < requiredPointCount - currentPointCount; ++i) {
242 radius = qBound(0.0, radius, 100.0);
255 radius = qBound(0.0, radius, 100.0);
284 context.
shapeWriter().addAttribute(
"rx", 0.01 * rx * 0.5 *
size.width());
288 context.
shapeWriter().addAttribute(
"ry", 0.01 * ry * 0.5 *
size.height());
302 const QString rxStr = element.attribute(
"rx");
303 const QString ryStr = element.attribute(
"ry");
307 if (!rxStr.isEmpty() && ryStr.isEmpty()) {
310 if (rxStr.isEmpty() && !ryStr.isEmpty()) {
322 if (w == 0.0 || h == 0.0) {
QList< KoPathPoint * > KoSubpath
a KoSubpath contains a path from a moveTo until a close or a new moveTo
QList< QPointF > handles
the handles that the user can grab and change
void setSize(const QSizeF &size) override
reimplemented from KoShape
void setHandles(const QList< QPointF > &handles)
bool isParametricShape() const
Check if object is a parametric shape.
A KoPathPoint represents a point in a path.
@ StartSubpath
it starts a new subpath by a moveTo command
@ CloseSubpath
it closes a subpath (only applicable on StartSubpath and StopSubpath)
@ StopSubpath
it stops a subpath (last point of subpath)
const KoSubpathList & subpaths() const
QSizeF size() const override
reimplemented
void notifyPointsChanged()
int arcToCurve(qreal rx, qreal ry, qreal startAngle, qreal sweepAngle, const QPointF &offset, QPointF *curvePoints) const
Add an arc.
void clear()
Removes all subpaths and their points from the path.
QTransform transformation() const
Returns the shapes local transformation matrix.
virtual void setPosition(const QPointF &position)
Set the position of the shape in pt.
qreal cornerRadiusX() const
Returns the corner radius in x-direction.
void moveHandleAction(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers=Qt::NoModifier) override
Updates the internal state of a KoParameterShape.
QString pathShapeId() const override
reimplemented
~RectangleShape() override
void setCornerRadiusY(qreal radius)
void setCornerRadiusX(qreal radius)
qreal m_cornerRadiusX
in percent of half of the rectangle width (a number between 0 and 100)
qreal cornerRadiusY() const
Returns the corner radius in y-direction.
KoShape * cloneShape() const override
creates a deep copy of the shape or shape's subtree
void createPoints(int requiredPointCount)
void updatePath(const QSizeF &size) override
Update the path of the parameter shape.
bool loadSvg(const QDomElement &element, SvgLoadingContext &context) override
reimplemented from SvgShape
bool saveSvg(SvgSavingContext &context) override
reimplemented from SvgShape
qreal m_cornerRadiusY
in percent of half of the rectangle height (a number between 0 and 100)
Contains data used for loading svg.
SvgGraphicsContext * currentGC() const
Returns the current graphics context.
KoSvgTextProperties resolvedProperties() const
These are the text properties, completely resolved, ensuring that everything is inherited and the siz...
Context for saving svg files.
QScopedPointer< KoXmlWriter > shapeWriter
QString getID(const KoShape *obj)
Returns the unique id for the given shape.
static void saveSvgStyle(KoShape *shape, SvgSavingContext &context)
Saves the style of the specified shape.
static void saveMetadata(const KoShape *shape, SvgSavingContext &context)
static qreal parseUnitX(SvgGraphicsContext *gc, const KoSvgTextProperties &resolved, const QString &unit)
parses a length attribute in x-direction
static void writeTransformAttributeLazy(const QString &name, const QTransform &transform, KoXmlWriter &shapeWriter)
Writes a transform as an attribute name iff the transform is not empty.
static qreal parseUnitY(SvgGraphicsContext *gc, const KoSvgTextProperties &resolved, const QString &unit)
parses a length attribute in y-direction