Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathShapeFactory Class Reference

Factory for path shapes. More...

#include <KoPathShapeFactory.h>

+ Inheritance diagram for KoPathShapeFactory:

Public Member Functions

KoShapecreateDefaultShape (KoDocumentResourceManager *documentResources=0) const override
 
 KoPathShapeFactory (const QStringList &)
 constructor
 
void newDocumentResourceManager (KoDocumentResourceManager *manager) const override
 reimplemented
 
bool supports (const QDomElement &element, KoShapeLoadingContext &context) const override
 
 ~KoPathShapeFactory () override
 
- Public Member Functions inherited from KoShapeFactoryBase
virtual KoShapecreateShape (const KoProperties *params, KoDocumentResourceManager *documentResources=0) const
 
virtual QList< KoShapeConfigWidgetBase * > createShapeOptionPanels ()
 
QString family () const
 
bool hidden () const
 
QString iconName () const
 
QString id () const
 
 KoShapeFactoryBase (const QString &id, const QString &name, const QString &deferredPluginName=QString())
 
int loadingPriority () const
 lower prio means the shape is more generic and will be checked later
 
QString name () const
 
QList< QPair< QString, QStringList > > odfElements () const
 
 Private (const QString &_id, const QString &_name, const QString &_deferredPluginName)
 
QList< KoShapeTemplatetemplates () const
 
QString toolTip () const
 
 ~KoShapeFactoryBase () override
 
 ~Private ()
 

Additional Inherited Members

- Public Attributes inherited from KoShapeFactoryBase
KoDeferredShapeFactoryBasedeferredFactory
 
QString deferredPluginName
 
QString family
 
bool hidden
 
QString iconName
 
const QString id
 
int loadingPriority
 
const QString name
 
QMutex pluginLoadingMutex
 
QList< QPointer< KoDocumentResourceManager > > resourceManagers
 
QList< KoShapeTemplatetemplates
 
QString tooltip
 
QList< QPair< QString, QStringList > > xmlElements
 
- Protected Member Functions inherited from KoShapeFactoryBase
void addTemplate (const KoShapeTemplate &params)
 
void setFamily (const QString &family)
 
void setHidden (bool hidden)
 
void setIconName (const char *iconName)
 
void setLoadingPriority (int priority)
 
void setToolTip (const QString &tooltip)
 
void setXmlElementNames (const QString &nameSpace, const QStringList &elementNames)
 
void setXmlElements (const QList< QPair< QString, QStringList > > &elementNamesList)
 

Detailed Description

Factory for path shapes.

Definition at line 16 of file KoPathShapeFactory.h.

Constructor & Destructor Documentation

◆ KoPathShapeFactory()

KoPathShapeFactory::KoPathShapeFactory ( const QStringList & )

constructor

Definition at line 22 of file KoPathShapeFactory.cpp.

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}
#define KoPathShapeId
Definition KoPathShape.h:20
void setToolTip(const QString &tooltip)
void setLoadingPriority(int priority)
void setIconName(const char *iconName)
void setXmlElementNames(const QString &nameSpace, const QStringList &elementNames)
KoShapeFactoryBase(const QString &id, const QString &name, const QString &deferredPluginName=QString())
static const QString draw
Definition KoXmlNS.h:27
#define koIconNameCStr(name)
Definition kis_icon.h:28

References KoXmlNS::draw, koIconNameCStr, KoShapeFactoryBase::setIconName(), KoShapeFactoryBase::setLoadingPriority(), KoShapeFactoryBase::setToolTip(), and KoShapeFactoryBase::setXmlElementNames().

◆ ~KoPathShapeFactory()

KoPathShapeFactory::~KoPathShapeFactory ( )
inlineoverride

Definition at line 21 of file KoPathShapeFactory.h.

21{}

Member Function Documentation

◆ createDefaultShape()

KoShape * KoPathShapeFactory::createDefaultShape ( KoDocumentResourceManager * documentResources = 0) const
overridevirtual

This method should be implemented by factories to create a shape that the user gets when doing a base insert. For example from a script. The created shape should have its values set to good defaults that the user can then adjust further if needed. Including the KoShape:setShapeId(), with the Id from this factory The default shape position is not relevant, it will be moved by the caller.

Parameters
documentResourcesthe resources manager that has all the document wide resources which can be used to create the object.
Returns
a new shape
See also
createShape() newDocumentResourceManager()

Reimplemented from KoShapeFactoryBase.

Definition at line 33 of file KoPathShapeFactory.cpp.

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}
The position of a path point within a path shape.
Definition KoPathShape.h:63
QSharedPointer< T > toQShared(T *ptr)

References toQShared().

◆ newDocumentResourceManager()

void KoPathShapeFactory::newDocumentResourceManager ( KoDocumentResourceManager * manager) const
overridevirtual

reimplemented

Reimplemented from KoShapeFactoryBase.

Definition at line 61 of file KoPathShapeFactory.cpp.

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}
void setResource(int key, const QVariant &value)
@ MarkerCollection
The collection holding all markers.

References KoDocumentResourceManager::hasResource(), KoDocumentResourceManager::MarkerCollection, and KoDocumentResourceManager::setResource().

◆ supports()

bool KoPathShapeFactory::supports ( const QDomElement & element,
KoShapeLoadingContext & context ) const
overridevirtual

returns true if this shapeFactory is able to load the ODF type started at argument element. ('draw:line' / 'draw:frame' / etc)

Implements KoShapeFactoryBase.

Definition at line 44 of file KoPathShapeFactory.cpp.

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}

References KoXmlNS::draw.


The documentation for this class was generated from the following files: