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"
26struct Shape::Private {
31Shape::Shape(KoShape *shape,
QObject *parent)
43bool Shape::operator==(
const Shape &other)
const
45 return (d->shape == other.d->shape);
48bool 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()));
236KoShape *Shape::shape()
The Document class encapsulates a Krita Document/Image.
The GroupShape class A group shape is a vector object with child shapes.
Document * activeDocument() const
static Krita * instance()
instance retrieve the singleton instance of the Application object.
The Shape class The shape class is a wrapper around Krita's vector objects.
void setVisible(bool visible)
setVisible
bool remove()
remove delete the shape.
QTransform absoluteTransformation() const
transformation the 2D transformation matrix of the shape including all grandparent transforms.
void update()
update queue the shape update.
QTransform transformation() const
transformation the 2D transformation matrix of the shape.
bool selectable() const
selectable
QRectF boundingBox() const
boundingBox the bounding box of the shape in points
bool isSelected()
isSelected
void setTransformation(QTransform matrix)
setTransformation set the 2D transformation matrix of the shape.
virtual QString type() const
type
void setName(const QString &name)
setName
void setZIndex(int zindex)
setZIndex
Shape * parentShape() const
parentShape
void updateAbsolute(QRectF box)
updateAbsolute queue the shape update in the specified rectangle.
void setPosition(QPointF point)
setPosition set the position of the shape.
QPointF position() const
position the position of the shape in points.
QString toSvg(bool prependStyles=false, bool stripTextMode=true)
toSvg convert the shape to svg, will not include style definitions.
bool geometryProtected() const
geometryProtected
void setGeometryProtected(bool protect)
setGeometryProtected
void setSelectable(bool selectable)
setSelectable
void select()
select selects the shape.
bool visible() const
visible
void deselect()
deselect deselects the shape.
virtual void close() override
const QByteArray & data() const const
virtual bool open(OpenMode flags) override
QString fromUtf8(QByteArrayView str)