31 Node(layer->image(), layer, parent)
55 shapes << new GroupShape(dynamic_cast<KoShapeGroup*>(originalShapes.at(i)));
76 const QSizeF pageSize(sizeInPx.width() / this->node()->image()->xRes(),
77 sizeInPx.height() / this->node()->image()->yRes());
79 buffer.open(QIODevice::WriteOnly);
83 writer.
save(buffer, pageSize);
86 svgData = QString::fromUtf8(buffer.data());
98 if (svgData.isEmpty() || !svgData.contains(
"<svg") ) {
113 qWarning() <<
"Failed to process an SVG string at"
114 << errorLine <<
":" << errorColumn <<
"->" << errorMsg;
127 SvgParser parser(document->document()->shapeController()->resourceManager());
131 originalShapes = parser.
parseSvg(dom.documentElement(), &fragmentSize);
140 for (
int i=0; i<originalShapes.size(); i++) {
141 if (
dynamic_cast<KoShapeGroup*
>(originalShapes.at(i))) {
142 shapes << new GroupShape(dynamic_cast<KoShapeGroup*>(originalShapes.at(i)));
157 if (!vector)
return 0;
161 if (!shape)
return 0;
166 return new Shape(shape);
179 for (
int i=0; i<originalShapes.size(); i++) {
180 if (
dynamic_cast<KoShapeGroup*
>(originalShapes.at(i))) {
181 shapes << new GroupShape(dynamic_cast<KoShapeGroup*>(originalShapes.at(i)));
192 if (
shapes.isEmpty())
return 0;
197 if (!container)
return 0;
200 KoShape *originalShape = shape->shape();
202 if (originalShape && originalShape->
parent() == container) {
203 originalShapes << originalShape;
205 qWarning() <<
"Attempt to add an invalid shape.";
210 if (originalShapes.isEmpty())
return 0;
216 if (!document)
return 0;
220 const int groupZIndex = originalShapes.last()->zIndex();
const quint8 OPACITY_OPAQUE_U8
The GroupShape class A group shape is a vector object with child shapes.
QRect bounds() const override
static void runSingleCommandStroke(KisImageSP image, KUndo2Command *cmd, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
runSingleCommandStroke creates a stroke and runs cmd in it. The text() field of cmd is used as a titl...
KoShapeManager * shapeManager() const
void setAntialiased(const bool antialiased)
QList< KoShape * > shapes() const
The undo / redo command for creating shapes.
The undo / redo command for grouping shapes.
QList< KoShape * > shapesAt(const QRectF &rect, bool omitHiddenShapes=true, bool containedMode=false)
KoShape * shapeAt(const QPointF &position, KoFlake::ShapeSelection selection=KoFlake::ShapeOnTop, bool omitHiddenShapes=true)
void setName(const QString &name)
void setZIndex(qint16 zIndex)
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
KoShapeContainer * parent() const
Document * activeDocument() const
static Krita * instance()
instance retrieve the singleton instance of the Application object.
QPoint position() const
position returns the position of the paint device of this node. The position is always 0,...
QRect bounds() const
bounds return the exact bounds of the node's paint device
The Shape class The shape class is a wrapper around Krita's vector objects.
static QDomDocument createDocumentFromSvg(QIODevice *device, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0)
QList< KoShape * > parseSvg(const QDomElement &e, QSizeF *fragmentSize=0)
Parses a svg fragment, returning the list of top level child shapes.
void setResolution(const QRectF boundsInPixels, qreal pixelsPerInch)
Implements exporting shapes to SVG.
bool save(QIODevice &outputDevice, const QSizeF &pageSize)
Writes svg to specified output device.
bool isAntialiased() const
return antialiasing status for the Vector layer
virtual QString type() const override
type Krita has several types of nodes, split in layers and masks. Group layers can contain other laye...
QList< Shape * > addShapesFromSvg(const QString &svg)
addShapesFromSvg add shapes to the layer from a valid svg.
QList< Shape * > shapesInRect(const QRectF &rect, bool omitHiddenShapes=true, bool containedMode=false) const
shapeInRect get all non-group shapes that the shape's boundingBox() intersects or is contained within...
QList< Shape * > shapes() const
shapes
QString toSvg()
toSvg convert the shapes in the layer to svg.
Shape * createGroupShape(const QString &name, QList< Shape * > shapes) const
createGroupShape combine a list of top level shapes into a group.
void setAntialiased(const bool antialiased)
set antialiasing status for the Vector layer
Shape * shapeAtPosition(const QPointF &position) const
shapeAtPoint check if the position is located within any non-group shape's boundingBox() on the curre...
KisSharedPtr< KisShapeLayer > KisShapeLayerSP
KUndo2MagicString kundo2_i18n(const char *text)
Document * findNodeInDocuments(KisNodeSP kisnode)