Krita
7 #include <kis_icon_utils.h>
10 #include <SvgSavingContext.h>
12 #include <KoDocumentResourceManager.h>
13 #include <kis_processing_applicator.h>
16 #include <KisDocument.h>
17 #include <kis_canvas2.h>
18 #include <KisMainWindow.h>
19 #include <KoShapeController.h>
20 #include <KoSelection.h>
24 #include "GroupShape.h"
26 struct Shape::Private {
31 Shape::Shape(KoShape *shape,
QObject *parent)
43 bool Shape::operator==(
const Shape &other)
const
45 return (d->shape == other.d->shape);
48 bool Shape::operator!=(
const Shape &other)
const
50 return !(operator==(other));
55 return d->shape->name();
60 d->shape->setName(
name);
65 return d->shape->shapeId();
70 return d->shape->zIndex();
75 d->shape->setZIndex(zindex);
80 return d->shape->isSelectable();
90 return d->shape->isGeometryProtected();
95 d->shape->setGeometryProtected(protect);
100 return d->shape->isVisible();
110 return d->shape->boundingRect();
115 return d->shape->position();
120 d->shape->setPosition(point);
125 return d->shape->transformation();
130 d->shape->setTransformation(matrix);
135 return d->shape->absoluteTransformation();
140 return d->shape->update();
145 return d->shape->updateAbsolute(box);
150 if (!d->shape)
return false;
151 if (!d->shape->parent())
return false;
153 bool removeStatus =
false;
156 if (KisPart::instance()->viewCount(document->document()) > 0) {
158 if (view && view->document() == document->document()) {
159 KisProcessingApplicator::runSingleCommandStroke(view->image(), view->canvasBase()->shapeController()->removeShape(d->shape));
160 view->image()->waitForDone();
181 SvgSavingContext savingContext(shapesBuffer, stylesBuffer);
182 savingContext.setStrippedTextMode(stripTextMode);
183 SvgWriter writer({d->shape});
184 writer.saveDetached(savingContext);
187 shapesBuffer.
close();
188 stylesBuffer.
close();
195 if (!d->shape)
return;
197 KisView *activeView = KisPart::instance()->currentMainwindow()->activeView();
198 KoSelection *selection = activeView->canvasBase()->shapeManager()->selection();
200 selection->select(d->shape);
205 if (!d->shape)
return;
207 KisView *activeView = KisPart::instance()->currentMainwindow()->activeView();
208 KoSelection *selection = activeView->canvasBase()->shapeManager()->selection();
210 selection->deselect(d->shape);
215 if (!d->shape)
return false;
217 KisView *activeView = KisPart::instance()->currentMainwindow()->activeView();
218 KoSelection *selection = activeView->canvasBase()->shapeManager()->selection();
220 return selection->isSelected(d->shape);
225 if (!d->shape)
return 0;
226 if (!d->shape->parent())
return 0;
228 if (
dynamic_cast<KoShapeGroup*
>(d->shape->parent())) {
229 return new GroupShape(
dynamic_cast<KoShapeGroup*
>(d->shape->parent()));
236 KoShape *Shape::shape()
QString toSvg(bool prependStyles=false, bool stripTextMode=true)
toSvg convert the shape to svg, will not include style definitions.
void updateAbsolute(QRectF box)
updateAbsolute queue the shape update in the specified rectangle.
virtual bool open(QIODevice::OpenMode flags) override
QString fromUtf8(const char *str, int size)
void setSelectable(bool selectable)
setSelectable
const QByteArray & data() const const
QTransform absoluteTransformation() const
transformation the 2D transformation matrix of the shape including all grandparent transforms.
void setZIndex(int zindex)
setZIndex
The Document class encapsulates a Krita Document/Image.
The Shape class The shape class is a wrapper around Krita's vector objects.
bool geometryProtected() const
geometryProtected
void setPosition(QPointF point)
setPosition set the position of the shape.
virtual QString type() const
type
void select()
select selects the shape.
bool isSelected()
isSelected
static Krita * instance()
instance retrieve the singleton instance of the Application object.
QTransform transformation() const
transformation the 2D transformation matrix of the shape.
void setVisible(bool visible)
setVisible
QPointF position() const
position the position of the shape in points.
The GroupShape class A group shape is a vector object with child shapes.
void setName(const QString &name)
setName
QRectF boundingBox() const
boundingBox the bounding box of the shape in points
virtual void close() override
Shape * parentShape() const
parentShape
void deselect()
deselect deselects the shape.
Document * activeDocument() const
bool remove()
remove delete the shape.
bool selectable() const
selectable
void setTransformation(QTransform matrix)
setTransformation set the 2D transformation matrix of the shape.
void setGeometryProtected(bool protect)
setGeometryProtected
void update()
update queue the shape update.
bool visible() const
visible
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 22 2023 04:09:51 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.