Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathShapeFactory.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2006 Thomas Zander <zander@kde.org>
3 * SPDX-FileCopyrightText: 2011 Thorsten Zachmann <zachmann@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
8#include "KoPathShape.h"
9#include "KoShapeStroke.h"
10#include "KoMarkerCollection.h"
13#include <KoIcon.h>
14#include "KoInsets.h"
15
16#include <klocalizedstring.h>
17
18#include <KoXmlNS.h>
19
20#include "kis_pointer_utils.h"
21
23 : KoShapeFactoryBase(KoPathShapeId, i18n("Simple path shape"))
24{
25 setToolTip(i18n("A simple path shape"));
26 setIconName(koIconNameCStr("pathshape"));
27 QStringList elementNames;
28 elementNames << "path" << "line" << "polyline" << "polygon";
29 setXmlElementNames(KoXmlNS::draw, elementNames);
31}
32
34{
35 KoPathShape* path = new KoPathShape();
36 path->moveTo(QPointF(0, 50));
37 path->curveTo(QPointF(0, 120), QPointF(50, 120), QPointF(50, 50));
38 path->curveTo(QPointF(50, -20), QPointF(100, -20), QPointF(100, 50));
39 path->normalize();
40 path->setStroke(toQShared(new KoShapeStroke(1.0)));
41 return path;
42}
43
44bool KoPathShapeFactory::supports(const QDomElement & e, KoShapeLoadingContext &context) const
45{
46 Q_UNUSED(context);
47 if (e.namespaceURI() == KoXmlNS::draw) {
48 if (e.localName() == "path")
49 return true;
50 if (e.localName() == "line")
51 return true;
52 if (e.localName() == "polyline")
53 return true;
54 if (e.localName() == "polygon")
55 return true;
56 }
57
58 return false;
59}
60
62{
63 // we also need a MarkerCollection so add if it is not there yet
65 KoMarkerCollection *markerCollection = new KoMarkerCollection(manager);
66 manager->setResource(KoDocumentResourceManager::MarkerCollection, QVariant::fromValue(markerCollection));
67 }
68}
#define KoPathShapeId
Definition KoPathShape.h:20
void setResource(int key, const QVariant &value)
@ MarkerCollection
The collection holding all markers.
void newDocumentResourceManager(KoDocumentResourceManager *manager) const override
reimplemented
bool supports(const QDomElement &element, KoShapeLoadingContext &context) const override
KoShape * createDefaultShape(KoDocumentResourceManager *documentResources=0) const override
KoPathShapeFactory(const QStringList &)
constructor
The position of a path point within a path shape.
Definition KoPathShape.h:63
void setToolTip(const QString &tooltip)
void setLoadingPriority(int priority)
void setIconName(const char *iconName)
void setXmlElementNames(const QString &nameSpace, const QStringList &elementNames)
static const QString draw
Definition KoXmlNS.h:27
#define koIconNameCStr(name)
Definition kis_icon.h:28
QSharedPointer< T > toQShared(T *ptr)