Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShape Class Referenceabstract

#include <KoShape.h>

+ Inheritance diagram for KoShape:

Classes

class  Private
 
struct  ShapeChangeListener
 
class  SharedData
 

Public Types

enum  ChangeType {
  PositionChanged , RotationChanged , ScaleChanged , ShearChanged ,
  SizeChanged , GenericMatrixChange , KeepAspectRatioChange , ParentChanged ,
  Deleted , StrokeChanged , BackgroundChanged , BorderChanged ,
  ParameterChanged , ContentChanged , TextContourMarginChanged , ChildChanged ,
  ConnectionPointChanged , ClipPathChanged , ClipMaskChanged , TransparencyChanged
}
 Used by shapeChanged() to select which change was made. More...
 
enum  ChildZOrderPolicy { ChildZDefault , ChildZParentChild = ChildZDefault , ChildZPassThrough }
 Used by compareShapeZIndex() to order shapes. More...
 
enum  PaintOrder { Fill , Stroke , Markers }
 

Public Member Functions

QRectF absoluteOutlineRect () const
 
QPointF absolutePosition (KoFlake::AnchorPosition anchor=KoFlake::Center) const
 
QTransform absoluteTransformation () const
 
bool addDependee (KoShape *shape)
 
QString additionalAttribute (const QString &name) const
 
void addShapeChangeListener (ShapeChangeListener *listener)
 
KoShapeAnchoranchor () const
 
void applyAbsoluteTransformation (const QTransform &matrix)
 
void applyTransformation (const QTransform &matrix)
 
virtual QSharedPointer< KoShapeBackgroundbackground () const
 
virtual QRectF boundingRect () const
 Get the bounding box of the shape.
 
virtual ChildZOrderPolicy childZOrderPolicy ()
 
KoClipMaskclipMask () const
 Returns the currently set clip mask or 0 if there is no clip mask set.
 
KoClipPathclipPath () const
 Returns the currently set clip path or 0 if there is no clip path set.
 
virtual KoShapecloneShape () const
 creates a deep copy of the shape or shape's subtree
 
KoShapecloneShapeAndBakeAbsoluteTransform () const
 creates a deep copy of the shape/shapes tree and bakes the absolute transform of this into the resulting shape.
 
void copySettings (const KoShape *shape)
 
QList< KoShape * > dependees () const
 Returns list of shapes depending on this shape.
 
QPointF documentToShape (const QPointF &point) const
 Transforms point from document coordinates to shape coordinates.
 
QRectF documentToShape (const QRectF &rect) const
 Transform rect from document coordinates to shape coordinates.
 
bool hasAdditionalAttribute (const QString &name) const
 
bool hasCommonParent (const KoShape *shape) const
 
bool hasDependee (KoShape *shape) const
 Returns if the given shape is dependent on this shape.
 
virtual bool hasTransparency () const
 
virtual bool hitTest (const QPointF &position) const
 Check if the shape is hit on position.
 
QString hyperLink () const
 
bool inheritBackground () const
 inheritBackground shows if the shape inherits background from its parent
 
bool inheritPaintOrder () const
 inheritPaintOrder
 
bool inheritsTransformFromAny (const QList< KoShape * > ancestorsInQuestion) const
 inheritsTransformFromAny checks if the shape inherits transformation from any of the shapes listed in ancestorsInQuestion. The inheritance is checked in recursive way.
 
bool inheritStroke () const
 inheritStroke shows if the shape inherits the stroke from its parent
 
bool isContentProtected () const
 
bool isGeometryProtected () const
 
bool isPrintable () const
 
bool isSelectable () const
 
virtual bool isShapeEditable (bool recursive=true) const
 checks recursively if the shape or one of its parents is not visible or locked
 
bool isVisible (bool recursive=true) const
 
bool keepAspectRatio () const
 
 KoShape ()
 Constructor.
 
qreal minimumHeight () const
 
QString name () const
 
void notifyChanged ()
 
virtual QPainterPath outline () const
 
virtual QRectF outlineRect () const
 
virtual void paint (QPainter &painter) const =0
 Paint the shape fill The class extending this one is responsible for painting itself. painter is expected to be preconfigured to work in "document" pixels.
 
virtual void paintMarkers (QPainter &painter) const
 paintStroke paints the shape's markers
 
virtual QVector< PaintOrderpaintOrder () const
 paintOrder
 
virtual void paintStroke (QPainter &painter) const
 paintStroke paints the shape's stroked outline
 
KoShapeContainerparent () const
 
QPointF position () const
 Get the position of the shape in pt.
 
void removeAdditionalAttribute (const QString &name)
 
void removeAdditionalStyleAttribute (const char *name)
 
void removeDependee (KoShape *shape)
 
void removeShapeChangeListener (ShapeChangeListener *listener)
 
void rotate (qreal angle)
 Rotate the shape (relative)
 
qreal rotation () const
 
void scale (qreal sx, qreal sy)
 Scale the shape using the zero-point which is the top-left corner.
 
void setAbsolutePosition (const QPointF &newPosition, KoFlake::AnchorPosition anchor=KoFlake::Center)
 
void setAdditionalAttribute (const QString &name, const QString &value)
 
void setAdditionalStyleAttribute (const char *name, const QString &value)
 
void setAnchor (KoShapeAnchor *anchor)
 
virtual void setBackground (QSharedPointer< KoShapeBackground > background)
 
void setClipMask (KoClipMask *clipMask)
 Sets a new clip mask, removing the old one. The mask is owned by the shape.
 
void setClipPath (KoClipPath *clipPath)
 Sets a new clip path, removing the old one.
 
void setContentProtected (bool protect)
 
void setGeometryProtected (bool on)
 
void setHyperLink (const QString &hyperLink)
 
void setInheritBackground (bool value)
 setInheritBackground marks a shape as inheriting the background from the parent shape. NOTE: The currently selected background is destroyed.
 
void setInheritPaintOrder (bool value)
 setInheritPaintOrder set inherit paint order.
 
void setInheritStroke (bool value)
 setInheritStroke marks a shape as inheriting the stroke from the parent shape. NOTE: The currently selected stroke is destroyed.
 
void setKeepAspectRatio (bool keepAspect)
 
void setMinimumHeight (qreal height)
 
void setName (const QString &name)
 
virtual void setPaintOrder (PaintOrder first, PaintOrder second)
 setPaintOrder set the paint order. As there's only three entries in any given paintorder, you only need to have the first and second entry to set it.
 
void setParent (KoShapeContainer *parent)
 
virtual void setPosition (const QPointF &position)
 Set the position of the shape in pt.
 
void setPrintable (bool on)
 
virtual void setResolution (qreal xRes, qreal yRes)
 
void setSelectable (bool selectable)
 
void setShapeId (const QString &id)
 
virtual void setSize (const QSizeF &size)
 Resize the shape.
 
virtual void setStroke (KoShapeStrokeModelSP stroke)
 
void setToolDelegates (const QSet< KoShape * > &delegates)
 
void setTransformation (const QTransform &matrix)
 
void setTransparency (qreal transparency)
 
void setUserData (KoShapeUserData *userData)
 
void setVisible (bool on)
 
void setZIndex (qint16 zIndex)
 
QString shapeId () const
 
QPointF shapeToDocument (const QPointF &point) const
 Transforms point from shape coordinates to document coordinates.
 
QRectF shapeToDocument (const QRectF &rect) const
 Transforms rect from shape coordinates to document coordinates.
 
void shear (qreal sx, qreal sy)
 Shear the shape The shape will be sheared using the zero-point which is the top-left corner.
 
virtual QSizeF size () const
 Get the size of the shape in pt.
 
virtual KoSnapData snapData () const
 Returns additional snap data the shape wants to have snapping to.
 
virtual KoShapeStrokeModelSP stroke () const
 
KoInsets strokeInsets () const
 
QSet< KoShape * > toolDelegates () const
 
QTransform transformation () const
 Returns the shapes local transformation matrix.
 
qreal transparency (bool recursive=false) const
 
virtual void update () const
 
virtual void updateAbsolute (const QRectF &rect) const
 
KoShapeUserDatauserData () const
 
virtual void waitUntilReady (bool asynchronous=true) const
 
qint16 zIndex () const
 
virtual ~KoShape ()
 Destructor.
 

Static Public Member Functions

static QRectF absoluteOutlineRect (const QList< KoShape * > &shapes)
 
static QRectF boundingRect (const QList< KoShape * > &shapes)
 
static bool compareShapeZIndex (KoShape *s1, KoShape *s2)
 
static KisHandlePainterHelper createHandlePainterHelperDocument (QPainter *painter, KoShape *shape, qreal handleRadius, int decorationThickness)
 
static KisHandlePainterHelper createHandlePainterHelperView (QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius=0.0, int decorationThickness=1)
 
static QVector< PaintOrderdefaultPaintOrder ()
 default paint order as per SVG specification
 
static QList< KoShape * > linearizeSubtree (const QList< KoShape * > &shapes)
 
static QList< KoShape * > linearizeSubtreeSorted (const QList< KoShape * > &shapes)
 

Static Public Attributes

static const qint16 maxZIndex = std::numeric_limits<qint16>::max()
 
static const qint16 minZIndex = std::numeric_limits<qint16>::min()
 

Protected Member Functions

 KoShape (const KoShape &rhs)
 
QList< ShapeChangeListener * > listeners () const
 
void setSizeImpl (const QSizeF &size) const
 
virtual void shapeChanged (ChangeType type, KoShape *shape=0)
 
void shapeChangedPriv (KoShape::ChangeType type)
 
QTransform transform () const
 return the current matrix that contains the rotation/scale/position of this shape
 

Private Member Functions

void addShapeManager (KoShapeManager *manager)
 
void removeShapeManager (KoShapeManager *manager)
 

Private Attributes

QScopedPointer< Privated
 
QSharedDataPointer< SharedDatas
 

Friends

class KoShapeManager
 

Detailed Description

Base class for all flake shapes. Shapes extend this class to allow themselves to be manipulated. This class just represents a graphical shape in the document and can be manipulated by some default tools in this library.

Due to the limited responsibility of this class, the extending object can have any data backend and is responsible for painting itself.

We strongly suggest that any extending class will use a Model View Controller (MVC) design where the View part is all in this class, as well as the one that inherits from this one. This allows the data that rests in the model to be reused in different parts of the document. For example by having two flake objects that show that same data. Or each showing a section of it.

The KoShape data is completely in postscript-points (pt) (see KoUnit for conversion methods to and from points). This image will explain the real-world use of the shape and its options.
The Rotation center can be returned with absolutePosition()

Flake objects can be created in three ways:

  • a simple new KoDerivedFlake(),
  • through an associated tool,
  • through a factory

Shape interaction notifications

We had several notification methods that allow your shape to be notified of changes in other shapes positions or rotation etc.

  1. The most general is KoShape::shapeChanged().
    a virtual method that you can use to check various changed to your shape made by tools or otherwise.
  2. for shape hierarchies the parent may receive a notification when a child was modified. This is done though KoShapeContainerModel::childChanged()
  3. any shape that is at a similar position as another shape there is collision detection. You can register your shape to be sensitive to any changes like moving or whatever to other shapes that intersect yours. Such changes will then be notified to your shape using the method from (1) You should call KoShape::setCollisionDetection(bool) to enable this.

Definition at line 88 of file KoShape.h.

Member Enumeration Documentation

◆ ChangeType

Used by shapeChanged() to select which change was made.

Enumerator
PositionChanged 

used after a setPosition()

RotationChanged 

used after a setRotation()

ScaleChanged 

used after a scale()

ShearChanged 

used after a shear()

SizeChanged 

used after a setSize()

GenericMatrixChange 

used after the matrix was changed without knowing which property explicitly changed

KeepAspectRatioChange 

used after setKeepAspectRatio()

ParentChanged 

used after a setParent()

Deleted 

the shape was deleted

StrokeChanged 

the shapes stroke has changed

BackgroundChanged 

the shapes background has changed

BorderChanged 

the shapes border has changed

ParameterChanged 

the shapes parameter has changed (KoParameterShape only)

ContentChanged 

the content of the shape changed e.g. a new image inside a pixmap/text change inside a textshape

TextContourMarginChanged 

used after text properties changed and modified the contour margin in the text shape

ChildChanged 

a child of a container was changed/removed. This is propagated to all parents

ConnectionPointChanged 

a connection point has changed

ClipPathChanged 

the shapes clip path has changed

ClipMaskChanged 

the shapes clip path has changed

TransparencyChanged 

the shapetransparency value has changed

Definition at line 92 of file KoShape.h.

92 {
101 Deleted,
113 };
@ RotationChanged
used after a setRotation()
Definition KoShape.h:94
@ StrokeChanged
the shapes stroke has changed
Definition KoShape.h:102
@ PositionChanged
used after a setPosition()
Definition KoShape.h:93
@ TransparencyChanged
the shapetransparency value has changed
Definition KoShape.h:112
@ Deleted
the shape was deleted
Definition KoShape.h:101
@ ClipPathChanged
the shapes clip path has changed
Definition KoShape.h:110
@ ConnectionPointChanged
a connection point has changed
Definition KoShape.h:109
@ ShearChanged
used after a shear()
Definition KoShape.h:96
@ ParentChanged
used after a setParent()
Definition KoShape.h:100
@ ContentChanged
the content of the shape changed e.g. a new image inside a pixmap/text change inside a textshape
Definition KoShape.h:106
@ ClipMaskChanged
the shapes clip path has changed
Definition KoShape.h:111
@ ParameterChanged
the shapes parameter has changed (KoParameterShape only)
Definition KoShape.h:105
@ BackgroundChanged
the shapes background has changed
Definition KoShape.h:103
@ ChildChanged
a child of a container was changed/removed. This is propagated to all parents
Definition KoShape.h:108
@ TextContourMarginChanged
used after text properties changed and modified the contour margin in the text shape
Definition KoShape.h:107
@ ScaleChanged
used after a scale()
Definition KoShape.h:95
@ KeepAspectRatioChange
used after setKeepAspectRatio()
Definition KoShape.h:99
@ BorderChanged
the shapes border has changed
Definition KoShape.h:104
@ SizeChanged
used after a setSize()
Definition KoShape.h:97
@ GenericMatrixChange
used after the matrix was changed without knowing which property explicitly changed
Definition KoShape.h:98

◆ ChildZOrderPolicy

Used by compareShapeZIndex() to order shapes.

Enumerator
ChildZDefault 
ChildZParentChild 

normal parent/child ordering

ChildZPassThrough 

children are considered equal to this shape

Definition at line 523 of file KoShape.h.

523 {
527 };
@ ChildZDefault
Definition KoShape.h:524
@ ChildZParentChild
normal parent/child ordering
Definition KoShape.h:525
@ ChildZPassThrough
children are considered equal to this shape
Definition KoShape.h:526

◆ PaintOrder

Enumerator
Fill 
Stroke 
Markers 

Definition at line 115 of file KoShape.h.

115 {
116 Fill,
117 Stroke,
118 Markers
119 };
@ Stroke
Definition KoShape.h:117
@ Markers
Definition KoShape.h:118

Constructor & Destructor Documentation

◆ KoShape() [1/2]

KoShape::KoShape ( )

Constructor.

Definition at line 135 of file KoShape.cpp.

136 : d(new Private()),
137 s(new SharedData)
138{
140}
QScopedPointer< Private > d
Definition KoShape.h:974
QSharedDataPointer< SharedData > s
Definition KoShape.h:977
void notifyChanged()
Definition KoShape.cpp:618

References notifyChanged().

◆ ~KoShape()

KoShape::~KoShape ( )
virtual

Destructor.

The shape must have already been detached from all the parents and shape managers. Otherwise we might accidentally request some RTTI information, which is not available anymore (we are in d-tor).

TL;DR: fix the code that caused this destruction without unparenting instead of trying to remove these assert!

Definition at line 148 of file KoShape.cpp.

149{
151 d->listeners.clear();
160 KIS_SAFE_ASSERT_RECOVER (!d->parent) {
161 d->parent->removeShape(this);
162 }
163
164 KIS_SAFE_ASSERT_RECOVER (d->shapeManagers.isEmpty()) {
165 Q_FOREACH (KoShapeManager *manager, d->shapeManagers) {
166 manager->shapeInterface()->notifyShapeDestructed(this);
167 }
168 d->shapeManagers.clear();
169 }
170}
KoShapeManager::ShapeInterface shapeInterface
void shapeChangedPriv(KoShape::ChangeType type)
Definition KoShape.cpp:104
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
void notifyShapeDestructed(KoShape *shape)

References d, Deleted, KIS_SAFE_ASSERT_RECOVER, KoShapeManager::ShapeInterface::notifyShapeDestructed(), shapeChangedPriv(), and KoShapeManager::shapeInterface.

◆ KoShape() [2/2]

KoShape::KoShape ( const KoShape & rhs)
protected

Definition at line 142 of file KoShape.cpp.

143 : d(new Private()),
144 s(rhs.s)
145{
146}

Member Function Documentation

◆ absoluteOutlineRect() [1/2]

QRectF KoShape::absoluteOutlineRect ( ) const
Returns
the bounding rect of the outline of the shape measured in absolute coordinate system. Please note that in contrast to boundingRect() this rect doesn't include the stroke and other insets.

Definition at line 321 of file KoShape.cpp.

322{
323 return absoluteTransformation().map(outline()).boundingRect();
324}
virtual QPainterPath outline() const
Definition KoShape.cpp:559
QTransform absoluteTransformation() const
Definition KoShape.cpp:335

References absoluteTransformation(), and outline().

◆ absoluteOutlineRect() [2/2]

QRectF KoShape::absoluteOutlineRect ( const QList< KoShape * > & shapes)
static

Same as a member function, but applies to a list of shapes and returns a united rect.

Definition at line 326 of file KoShape.cpp.

327{
328 QRectF absoluteOutlineRect;
329 Q_FOREACH (KoShape *shape, shapes) {
331 }
332 return absoluteOutlineRect;
333}
QRectF absoluteOutlineRect() const
Definition KoShape.cpp:321

References absoluteOutlineRect().

◆ absolutePosition()

QPointF KoShape::absolutePosition ( KoFlake::AnchorPosition anchor = KoFlake::Center) const

Return the position of this shape regardless of rotation/skew/scaling and regardless of this shape having a parent (being in a group) or not.

Parameters
anchorThe place on the (unaltered) shape that you want the position of.
Returns
the point that is the absolute, centered position of this shape.

Definition at line 573 of file KoShape.cpp.

574{
575 const QRectF rc = outlineRect();
576
577 QPointF point = rc.topLeft();
578
579 bool valid = false;
580 QPointF anchoredPoint = KoFlake::anchorToPoint(anchor, rc, &valid);
581 if (valid) {
582 point = anchoredPoint;
583 }
584
585 return absoluteTransformation().map(point);
586}
virtual QRectF outlineRect() const
Definition KoShape.cpp:566
KoShapeAnchor * anchor() const
KRITAFLAKE_EXPORT QPointF anchorToPoint(AnchorPosition anchor, const QRectF rect, bool *valid=0)
Definition KoFlake.cpp:329

References absoluteTransformation(), anchor(), KoFlake::anchorToPoint(), and outlineRect().

◆ absoluteTransformation()

QTransform KoShape::absoluteTransformation ( ) const

Create a matrix that describes all the transformations done on this shape.

The absolute transformation is the combined transformation of this shape and all its parents and grandparents.

Definition at line 335 of file KoShape.cpp.

336{
337 QTransform matrix;
338 // apply parents matrix to inherit any transformations done there.
339 KoShapeContainer * container = d->parent;
340 if (container) {
341 if (container->inheritsTransform(this)) {
342 matrix = container->absoluteTransformation();
343 } else {
344 QSizeF containerSize = container->size();
345 QPointF containerPos = container->absolutePosition() - QPointF(0.5 * containerSize.width(), 0.5 * containerSize.height());
346 matrix.translate(containerPos.x(), containerPos.y());
347 }
348 }
349
350 return s->localMatrix * matrix;
351}
bool inheritsTransform(const KoShape *shape) const
virtual QSizeF size() const
Get the size of the shape in pt.
Definition KoShape.cpp:740
QPointF absolutePosition(KoFlake::AnchorPosition anchor=KoFlake::Center) const
Definition KoShape.cpp:573
KoShapeContainer * parent() const
Definition KoShape.cpp:862

References absolutePosition(), absoluteTransformation(), d, KoShapeContainer::inheritsTransform(), parent(), s, and size().

◆ addDependee()

bool KoShape::addDependee ( KoShape * shape)

Adds a shape which depends on this shape. Making a shape dependent on this one means it will get shapeChanged() called on each update of this shape.

If this shape already depends on the given shape, establishing the dependency is refused to prevent circular dependencies.

Parameters
shapethe shape which depends on this shape
Returns
true if dependency could be established, otherwise false
See also
removeDependee(), hasDependee()

Definition at line 1026 of file KoShape.cpp.

1027{
1028 if (! shape)
1029 return false;
1030
1031 // refuse to establish a circular dependency
1032 if (shape->hasDependee(this))
1033 return false;
1034
1035 if (! d->dependees.contains(shape)) {
1036 d->dependees.append(shape);
1037 shape->addShapeChangeListener(&d->dependeesLifetimeListener);
1038 }
1039
1040 return true;
1041}
void addShapeChangeListener(ShapeChangeListener *listener)
Definition KoShape.cpp:1157
bool hasDependee(KoShape *shape) const
Returns if the given shape is dependent on this shape.
Definition KoShape.cpp:1049

References addShapeChangeListener(), d, and hasDependee().

◆ additionalAttribute()

QString KoShape::additionalAttribute ( const QString & name) const

Get additional attribute

Parameters
nameThe name of the attribute in the following form prefix:tag e.g. presentation:placeholder
Returns
The value of the attribute if it exists or a null string if not found.

Definition at line 1092 of file KoShape.cpp.

1093{
1094 return s->additionalAttributes.value(name);
1095}
QString name() const
Definition KoShape.cpp:955

References name(), and s.

◆ addShapeChangeListener()

void KoShape::addShapeChangeListener ( KoShape::ShapeChangeListener * listener)

Definition at line 1157 of file KoShape.cpp.

1158{
1159
1160 KIS_SAFE_ASSERT_RECOVER_RETURN(!d->listeners.contains(listener));
1161 listener->registerShape(this);
1162 d->listeners.append(listener);
1163}
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
void registerShape(KoShape *shape)
Definition KoShape.cpp:1134

References d, KIS_SAFE_ASSERT_RECOVER_RETURN, and KoShape::ShapeChangeListener::registerShape().

◆ addShapeManager()

void KoShape::addShapeManager ( KoShapeManager * manager)
private

Definition at line 120 of file KoShape.cpp.

121{
122 d->shapeManagers.insert(manager);
123}

References d.

◆ anchor()

KoShapeAnchor * KoShape::anchor ( ) const

Return the KoShapeAnchor, or 0

◆ applyAbsoluteTransformation()

void KoShape::applyAbsoluteTransformation ( const QTransform & matrix)

Applies a transformation to this shape.

The transformation given is relative to the global coordinate system, i.e. the document. This is a convenience function to apply a global transformation to this shape.

See also
applyTransformation
Parameters
matrixthe transformation matrix to apply

Definition at line 353 of file KoShape.cpp.

354{
355 QTransform globalMatrix = absoluteTransformation();
356 // the transformation is relative to the global coordinate system
357 // but we want to change the local matrix, so convert the matrix
358 // to be relative to the local coordinate system
359 QTransform transformMatrix = globalMatrix * matrix * globalMatrix.inverted();
360 applyTransformation(transformMatrix);
361}
void applyTransformation(const QTransform &matrix)
Definition KoShape.cpp:363

References absoluteTransformation(), and applyTransformation().

◆ applyTransformation()

void KoShape::applyTransformation ( const QTransform & matrix)

Applies a transformation to this shape.

The transformation given is relative to the shape coordinate system.

Parameters
matrixthe transformation matrix to apply

Definition at line 363 of file KoShape.cpp.

364{
365 const QTransform newLocalMatrix = matrix * s->localMatrix;
366
367 if (s->localMatrix != newLocalMatrix) {
368 s->localMatrix = newLocalMatrix;
371 }
372}

References GenericMatrixChange, notifyChanged(), s, and shapeChangedPriv().

◆ background()

QSharedPointer< KoShapeBackground > KoShape::background ( ) const
virtual

Return the brush used to paint the background of this shape with. A QBrush can have a plain color, be fully transparent or have a complex fill. setting such a brush will allow the shape to fill itself using that brush and will be able to tell if its transparent or not.

Returns
the background-brush

Reimplemented in KoSvgTextShape.

Definition at line 759 of file KoShape.cpp.

760{
761
763
764 if (!s->inheritBackground) {
765 bg = s->fill;
766 } else if (parent()) {
767 bg = parent()->background();
768 }
769
770 return bg;
771}
virtual QSharedPointer< KoShapeBackground > background() const
Definition KoShape.cpp:759

References background(), parent(), and s.

◆ boundingRect() [1/2]

QRectF KoShape::boundingRect ( ) const
virtual

Get the bounding box of the shape.

This includes the line width of the shape

Returns
the bounding box of the shape

Reimplemented in KoPathShape, KoSelection, KoShapeGroup, KoShapeLayer, KoSvgTextShape, and KisNodeShape.

Definition at line 299 of file KoShape.cpp.

300{
301 QTransform transform = absoluteTransformation();
302 QRectF bb = outlineRect();
303 if (s->stroke) {
304 KoInsets insets;
305 s->stroke->strokeInsets(this, insets);
306 bb.adjust(-insets.left, -insets.top, insets.right, insets.bottom);
307 }
308 bb = transform.mapRect(bb);
309 return bb;
310}
QTransform transform() const
return the current matrix that contains the rotation/scale/position of this shape
Definition KoShape.cpp:950
qreal bottom
Bottom inset.
Definition KoInsets.h:50
qreal right
Right inset.
Definition KoInsets.h:52
qreal top
Top inset.
Definition KoInsets.h:49
qreal left
Left inset.
Definition KoInsets.h:51

References absoluteTransformation(), KoInsets::bottom, KoInsets::left, outlineRect(), KoInsets::right, s, KoInsets::top, and transform().

◆ boundingRect() [2/2]

QRectF KoShape::boundingRect ( const QList< KoShape * > & shapes)
static

Get the united bounding box of a group of shapes. This is a utility function used in many places in Krita.

Definition at line 312 of file KoShape.cpp.

313{
314 QRectF boundingRect;
315 Q_FOREACH (KoShape *shape, shapes) {
316 boundingRect |= shape->boundingRect();
317 }
318 return boundingRect;
319}
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:299

References boundingRect().

◆ childZOrderPolicy()

KoShape::ChildZOrderPolicy KoShape::childZOrderPolicy ( )
virtual

Returns if during compareShapeZIndex() how this shape portrays the values of its children. The default behaviour is to let this shape's z values take the place of its children's values, so you get a parent/child relationship. The children are naturally still ordered relatively to their z values

But for special cases (like Calligra's TextShape) it can be overloaded to return ChildZPassThrough which means the children keep their own z values

Returns
the z order policy of this shape

Definition at line 388 of file KoShape.cpp.

389{
390 return ChildZDefault;
391}

References ChildZDefault.

◆ clipMask()

KoClipMask * KoShape::clipMask ( ) const

Returns the currently set clip mask or 0 if there is no clip mask set.

Definition at line 945 of file KoShape.cpp.

946{
947 return s->clipMask.data();
948}

References s.

◆ clipPath()

KoClipPath * KoShape::clipPath ( ) const

Returns the currently set clip path or 0 if there is no clip path set.

Definition at line 933 of file KoShape.cpp.

934{
935 return s->clipPath.data();
936}

References KoClipPath::clipPath, and s.

◆ cloneShape()

KoShape * KoShape::cloneShape ( ) const
virtual

creates a deep copy of the shape or shape's subtree

Returns
a cloned shape

Reimplemented in KoPathShape, KoShapeGroup, KoSvgTextShape, KisReferenceImage, ImageShape, EllipseShape, RectangleShape, SpiralShape, StarShape, and KarbonCalligraphicShape.

Definition at line 172 of file KoShape.cpp.

173{
174 KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "not implemented!");
175 qWarning() << shapeId() << "cannot be cloned";
176 return 0;
177}
QString shapeId() const
Definition KoShape.cpp:880
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KIS_SAFE_ASSERT_RECOVER_NOOP, and shapeId().

◆ cloneShapeAndBakeAbsoluteTransform()

KoShape * KoShape::cloneShapeAndBakeAbsoluteTransform ( ) const

creates a deep copy of the shape/shapes tree and bakes the absolute transform of this into the resulting shape.

After cloning clonedShape->transformation() is equal to this->absoluteTransformation(), even though the new shape has no parents.

This is just a convenience wrapper for cloneShape()

Returns
cloned shape

The shape is cloned without its parent's transformation, so we should adjust it manually.

Definition at line 179 of file KoShape.cpp.

180{
181 KoShape *clonedShape = this->cloneShape();
182
187 KoShape *oldParentShape = this->parent();
188 if (oldParentShape && !oldParentShape->absoluteTransformation().isIdentity()) {
189 clonedShape->applyAbsoluteTransformation(oldParentShape->absoluteTransformation());
190 }
191
192 return clonedShape;
193}
void applyAbsoluteTransformation(const QTransform &matrix)
Definition KoShape.cpp:353
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
Definition KoShape.cpp:172

References absoluteTransformation(), applyAbsoluteTransformation(), cloneShape(), and parent().

◆ compareShapeZIndex()

bool KoShape::compareShapeZIndex ( KoShape * s1,
KoShape * s2 )
static

This is a method used to sort a list using the STL sorting methods.

Parameters
s1the first shape
s2the second shape

WARNING: Our definition of zIndex is not yet compatible with SVG2's definition. In SVG stacking context of groups with the same zIndex are merged, while in Krita the contents of groups is never merged. One group will always below than the other. Therefore, when zIndex of two groups inside the same parent coincide, the resulting painting order in Krita is UNDEFINED.

To avoid this trouble we use KoShapeReorderCommand::mergeInShape() inside KoShapeCreateCommand.

The algorithm below doesn't correctly handle the case when the two pointers actually point to the same shape. So just check it in advance to guarantee strict weak ordering relation requirement

Definition at line 393 of file KoShape.cpp.

394{
413 if (s1 == s2) return false;
414
415 KoShape *parentShapeS1 = s1->parent();
416 KoShape *parentShapeS2 = s2->parent();
417
418 // We basically walk up through the parents until we find a common base parent
419 // To do that we need two loops where the inner loop walks up through the parents
420 // of s2 every time we step up one parent level on s1
421 //
422 // We don't update the index value until after we have seen that it's not a common base
423 // That way we ensure that two children of a common base are sorted according to their respective
424 // z value
425 bool foundCommonParent = false;
426 int index1 = s1->zIndex();
427 int index2 = s2->zIndex();
428 parentShapeS1 = s1;
429 parentShapeS2 = s2;
430 while (parentShapeS1 && !foundCommonParent) {
431 parentShapeS2 = s2;
432 index2 = parentShapeS2->zIndex();
433 while (parentShapeS2) {
434 if (parentShapeS2 == parentShapeS1) {
435 foundCommonParent = true;
436 break;
437 }
438 if (parentShapeS2->childZOrderPolicy() == KoShape::ChildZParentChild) {
439 index2 = parentShapeS2->zIndex();
440 }
441 parentShapeS2 = parentShapeS2->parent();
442 }
443
444 if (!foundCommonParent) {
445 if (parentShapeS1->childZOrderPolicy() == KoShape::ChildZParentChild) {
446 index1 = parentShapeS1->zIndex();
447 }
448 parentShapeS1 = parentShapeS1->parent();
449 }
450 }
451
452 // If the one shape is a parent/child of the other then sort so.
453 if (s1 == parentShapeS2) {
454 return true;
455 }
456 if (s2 == parentShapeS1) {
457 return false;
458 }
459
460 // If we went that far then the z-Index is used for sorting.
461 return index1 < index2;
462}
QPointF s1
QPointF s2
virtual ChildZOrderPolicy childZOrderPolicy()
Definition KoShape.cpp:388
qint16 zIndex() const
Definition KoShape.cpp:529

References childZOrderPolicy(), ChildZParentChild, parent(), s1, s2, and zIndex().

◆ copySettings()

void KoShape::copySettings ( const KoShape * shape)

Copy all the settings from the parameter shape and apply them to this shape. Settings like the position and rotation to visible and locked. The parent is a notable exclusion.

Parameters
shapethe shape to use as original

Definition at line 599 of file KoShape.cpp.

600{
601 s->size = shape->size();
602 s->zIndex = shape->zIndex();
603 s->visible = shape->isVisible(false);
604
605 // Ensure printable is true by default
606 if (!s->visible)
607 s->printable = true;
608 else
609 s->printable = shape->isPrintable();
610
611 s->geometryProtected = shape->isGeometryProtected();
612 s->protectContent = shape->isContentProtected();
613 s->selectable = shape->isSelectable();
614 s->keepAspect = shape->keepAspectRatio();
615 s->localMatrix = shape->s->localMatrix;
616}
bool isContentProtected() const
Definition KoShape.cpp:857
bool isSelectable() const
Definition KoShape.cpp:837
bool isGeometryProtected() const
Definition KoShape.cpp:847
bool isPrintable() const
Definition KoShape.cpp:824
bool keepAspectRatio() const
Definition KoShape.cpp:875
bool isVisible(bool recursive=true) const
Definition KoShape.cpp:802

References isContentProtected(), isGeometryProtected(), isPrintable(), isSelectable(), isVisible(), keepAspectRatio(), s, size(), and zIndex().

◆ createHandlePainterHelperDocument()

KisHandlePainterHelper KoShape::createHandlePainterHelperDocument ( QPainter * painter,
KoShape * shape,
qreal handleRadius,
int decorationThickness )
static

Definition at line 994 of file KoShape.cpp.

995{
996 const QTransform originalPainterTransform = painter->transform();
997
998 painter->setTransform(shape->absoluteTransformation() *
999 painter->transform());
1000
1001 // move c-tor
1002 return KisHandlePainterHelper(painter, originalPainterTransform, handleRadius, decorationThickness);
1003}
The KisHandlePainterHelper class is a special helper for painting handles around objects....

References absoluteTransformation().

◆ createHandlePainterHelperView()

KisHandlePainterHelper KoShape::createHandlePainterHelperView ( QPainter * painter,
KoShape * shape,
const KoViewConverter & converter,
qreal handleRadius = 0.0,
int decorationThickness = 1 )
static

A convenience method that creates a handles helper with applying transformations at the same time. Please note that you shouldn't save/restore additionally. All the work on restoring original painter's transformations is done by the helper.

Definition at line 982 of file KoShape.cpp.

983{
984 const QTransform originalPainterTransform = painter->transform();
985
986 painter->setTransform(shape->absoluteTransformation() *
987 converter.documentToView() *
988 painter->transform());
989
990 // move c-tor
991 return KisHandlePainterHelper(painter, originalPainterTransform, handleRadius, decorationThickness);
992}
virtual QPointF documentToView(const QPointF &documentPoint) const

References absoluteTransformation(), and KoViewConverter::documentToView().

◆ defaultPaintOrder()

QVector< KoShape::PaintOrder > KoShape::defaultPaintOrder ( )
static

default paint order as per SVG specification

Returns
constant value of {Fill, Stroke, Markers}

Definition at line 704 of file KoShape.cpp.

705{
706 static QVector<PaintOrder> order = {Fill, Stroke, Markers};
707 return order;
708}

References Fill, Markers, and Stroke.

◆ dependees()

QList< KoShape * > KoShape::dependees ( ) const

Returns list of shapes depending on this shape.

Definition at line 1054 of file KoShape.cpp.

1055{
1056 return d->dependees;
1057}

References d.

◆ documentToShape() [1/2]

QPointF KoShape::documentToShape ( const QPointF & point) const

Transforms point from document coordinates to shape coordinates.

Parameters
pointin document coordinates
Returns
point in shape coordinates

Definition at line 1016 of file KoShape.cpp.

1017{
1018 return absoluteTransformation().inverted().map(point);
1019}

References absoluteTransformation().

◆ documentToShape() [2/2]

QRectF KoShape::documentToShape ( const QRectF & rect) const

Transform rect from document coordinates to shape coordinates.

Parameters
rectin document coordinates
Returns
rect in shape coordinates

Definition at line 1021 of file KoShape.cpp.

1022{
1023 return absoluteTransformation().inverted().mapRect(rect);
1024}

References absoluteTransformation().

◆ hasAdditionalAttribute()

bool KoShape::hasAdditionalAttribute ( const QString & name) const

Check if additional attribute is set

Parameters
nameThe name of the attribute in the following form prefix:tag e.g. presentation:placeholder
Returns
true if there is a attribute with prefix:tag set, false otherwise

Definition at line 1087 of file KoShape.cpp.

1088{
1089 return s->additionalAttributes.contains(name);
1090}

References name(), and s.

◆ hasCommonParent()

bool KoShape::hasCommonParent ( const KoShape * shape) const
Returns
true if this shape has a common parent with shape

Definition at line 510 of file KoShape.cpp.

511{
512 const KoShape *thisShape = this;
513 while (thisShape) {
514
515 const KoShape *otherShape = shape;
516 while (otherShape) {
517 if (thisShape == otherShape) {
518 return true;
519 }
520 otherShape = otherShape->parent();
521 }
522
523 thisShape = thisShape->parent();
524 }
525
526 return false;
527}

References parent().

◆ hasDependee()

bool KoShape::hasDependee ( KoShape * shape) const

Returns if the given shape is dependent on this shape.

Definition at line 1049 of file KoShape.cpp.

1050{
1051 return d->dependees.contains(shape);
1052}

References d.

◆ hasTransparency()

bool KoShape::hasTransparency ( ) const
virtual

Returns true if there is some transparency, false if the shape is fully opaque. The default implementation will just return if the background has some transparency, you should override it and always return true if your shape is not square.

Returns
if the shape is (partly) transparent.

Definition at line 635 of file KoShape.cpp.

636{
638
639 return !bg || bg->hasTransparency() || s->transparency > 0.0;
640}

References background(), and s.

◆ hitTest()

bool KoShape::hitTest ( const QPointF & position) const
virtual

Check if the shape is hit on position.

Parameters
positionthe position where the user clicked.
Returns
true when it hits.

Reimplemented in KoPathShape, KoSelection, KoShapeGroup, and KoShapeLayer.

Definition at line 280 of file KoShape.cpp.

281{
282 if (d->parent && d->parent->isClipped(this) && !d->parent->hitTest(position))
283 return false;
284
285 QPointF point = absoluteTransformation().inverted().map(position);
286 QRectF bb = outlineRect();
287
288 if (s->stroke) {
289 KoInsets insets;
290 s->stroke->strokeInsets(this, insets);
291 bb.adjust(-insets.left, -insets.top, insets.right, insets.bottom);
292 }
293 if (bb.contains(point))
294 return true;
295
296 return false;
297}
QPointF position() const
Get the position of the shape in pt.
Definition KoShape.cpp:745

References absoluteTransformation(), KoInsets::bottom, d, KoInsets::left, outlineRect(), position(), KoInsets::right, s, and KoInsets::top.

◆ hyperLink()

QString KoShape::hyperLink ( ) const

Return the hyperlink for this shape.

Definition at line 1117 of file KoShape.cpp.

1118{
1119 return s->hyperLink;
1120}

References s.

◆ inheritBackground()

bool KoShape::inheritBackground ( ) const

inheritBackground shows if the shape inherits background from its parent

Returns
true if the shape inherits the fill

Definition at line 782 of file KoShape.cpp.

783{
784 return s->inheritBackground;
785}

References s.

◆ inheritPaintOrder()

bool KoShape::inheritPaintOrder ( ) const

inheritPaintOrder

Returns
whether the paint order is inherited. By default it is.

Definition at line 715 of file KoShape.cpp.

716{
717 return s->inheritPaintOrder;
718}

References s.

◆ inheritsTransformFromAny()

bool KoShape::inheritsTransformFromAny ( const QList< KoShape * > ancestorsInQuestion) const

inheritsTransformFromAny checks if the shape inherits transformation from any of the shapes listed in ancestorsInQuestion. The inheritance is checked in recursive way.

Returns
true if there is a (transitive) transformation-wise parent found in ancestorsInQuestion

Definition at line 488 of file KoShape.cpp.

489{
490 bool result = false;
491
492 KoShape *shape = const_cast<KoShape*>(this);
493 while (shape) {
494 KoShapeContainer *parent = shape->parent();
495 if (parent && !parent->inheritsTransform(shape)) {
496 break;
497 }
498
499 if (ancestorsInQuestion.contains(shape)) {
500 result = true;
501 break;
502 }
503
504 shape = parent;
505 }
506
507 return result;
508}

References KoShapeContainer::inheritsTransform(), and parent().

◆ inheritStroke()

bool KoShape::inheritStroke ( ) const

inheritStroke shows if the shape inherits the stroke from its parent

Returns
true if the shape inherits the stroke style

Definition at line 921 of file KoShape.cpp.

922{
923 return s->inheritStroke;
924}

References s.

◆ isContentProtected()

bool KoShape::isContentProtected ( ) const

Returns current content protection state of this shape. Content protection is a hint for tools to disallow the user editing the content.

Returns
current content protection state of this shape.
See also
isGeometryProtected(), isSelectable(), isVisible()

Definition at line 857 of file KoShape.cpp.

858{
859 return s->protectContent;
860}

References s.

◆ isGeometryProtected()

bool KoShape::isGeometryProtected ( ) const

Returns current geometry protection state of this shape. The geometry being protected means the user can not change shape or position of the shape. This includes any matrix operation such as rotation.

Returns
current geometry protection state of this shape.
See also
isContentProtected(), isSelectable(), isVisible()

Definition at line 847 of file KoShape.cpp.

848{
849 return s->geometryProtected;
850}

References s.

◆ isPrintable()

bool KoShape::isPrintable ( ) const

Returns the current printable state of this shape.

A shape can be visible but not printable, not printable and not visible or visible and printable, but not invisible and still printable.

Returns
current printable state of this shape.

Definition at line 824 of file KoShape.cpp.

825{
826 if (s->visible)
827 return s->printable;
828 else
829 return false;
830}

References s.

◆ isSelectable()

bool KoShape::isSelectable ( ) const

Returns if this shape can be selected by the user.

Returns
true only when the object is selectable.
See also
isGeometryProtected(), isContentProtected(), isVisible()

Definition at line 837 of file KoShape.cpp.

838{
839 return s->selectable;
840}

References s.

◆ isShapeEditable()

bool KoShape::isShapeEditable ( bool recursive = true) const
virtual

checks recursively if the shape or one of its parents is not visible or locked

Reimplemented in KisShapeLayer.

Definition at line 970 of file KoShape.cpp.

971{
972 if (!s->visible || s->geometryProtected)
973 return false;
974
975 if (recursive && d->parent) {
976 return d->parent->isShapeEditable(true);
977 }
978
979 return true;
980}

References d, and s.

◆ isVisible()

bool KoShape::isVisible ( bool recursive = true) const

Returns current visibility state of this shape. Being visible means being painted, as well as being used for things like guidelines or searches.

Parameters
recursivewhen true, checks visibility recursively
Returns
current visibility state of this shape.
See also
isGeometryProtected(), isContentProtected(), isSelectable()

Definition at line 802 of file KoShape.cpp.

803{
804 if (!recursive)
805 return s->visible;
806
807 if (!s->visible)
808 return false;
809
810 KoShapeContainer * parentShape = parent();
811
812 if (parentShape) {
813 return parentShape->isVisible(true);
814 }
815
816 return true;
817}

References isVisible(), parent(), and s.

◆ keepAspectRatio()

bool KoShape::keepAspectRatio ( ) const

Setting the shape to keep its aspect-ratio has the effect that user-scaling will keep the width/height ratio intact so as not to distort shapes that rely on that ratio.

Returns
whether to keep aspect ratio of this shape

Definition at line 875 of file KoShape.cpp.

876{
877 return s->keepAspect;
878}

References s.

◆ linearizeSubtree()

QList< KoShape * > KoShape::linearizeSubtree ( const QList< KoShape * > & shapes)
static

Definition at line 1178 of file KoShape.cpp.

1179{
1180 QList<KoShape *> result;
1181
1182 Q_FOREACH (KoShape *shape, shapes) {
1183 result << shape;
1184
1185 KoShapeContainer *container = dynamic_cast<KoShapeContainer*>(shape);
1186 if (container) {
1187 result << linearizeSubtree(container->shapes());
1188 }
1189 }
1190
1191 return result;
1192}
QList< KoShape * > shapes() const
static QList< KoShape * > linearizeSubtree(const QList< KoShape * > &shapes)
Definition KoShape.cpp:1178

References linearizeSubtree(), and KoShapeContainer::shapes().

◆ linearizeSubtreeSorted()

QList< KoShape * > KoShape::linearizeSubtreeSorted ( const QList< KoShape * > & shapes)
static

Definition at line 1194 of file KoShape.cpp.

1195{
1196 QList<KoShape*> sortedShapes = shapes;
1197 std::sort(sortedShapes.begin(), sortedShapes.end(), KoShape::compareShapeZIndex);
1198
1199 QList<KoShape *> result;
1200
1201 Q_FOREACH (KoShape *shape, sortedShapes) {
1202 result << shape;
1203
1204 KoShapeContainer *container = dynamic_cast<KoShapeContainer*>(shape);
1205 if (container) {
1206 result << linearizeSubtreeSorted(container->shapes());
1207 }
1208 }
1209
1210 return result;
1211}
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
Definition KoShape.cpp:393
static QList< KoShape * > linearizeSubtreeSorted(const QList< KoShape * > &shapes)
Definition KoShape.cpp:1194

References compareShapeZIndex(), linearizeSubtreeSorted(), and KoShapeContainer::shapes().

◆ listeners()

QList< KoShape::ShapeChangeListener * > KoShape::listeners ( ) const
protected

Definition at line 1173 of file KoShape.cpp.

1174{
1175 return d->listeners;
1176}

References d.

◆ minimumHeight()

qreal KoShape::minimumHeight ( ) const

Return the minimum height of the shape.

Returns
the minimum height of the shape. Default is 0.0.

◆ name()

QString KoShape::name ( ) const

Returns the name of the shape.

Returns
the shapes name

Definition at line 955 of file KoShape.cpp.

956{
957 return s->name;
958}

References s.

◆ notifyChanged()

void KoShape::notifyChanged ( )

Update the position of the shape in the tree of the KoShapeManager.

Definition at line 618 of file KoShape.cpp.

619{
620 Q_FOREACH (KoShapeManager * manager, d->shapeManagers) {
621 manager->notifyShapeChanged(this);
622 }
623}
void notifyShapeChanged(KoShape *shape)

References d, and KoShapeManager::notifyShapeChanged().

◆ outline()

QPainterPath KoShape::outline ( ) const
virtual

returns the outline of the shape in the form of a path. The outline returned will always be relative to the position() of the shape, so moving the shape will not alter the result. The outline is used to draw the stroke on, for example.

Returns
the outline of the shape in the form of a path.

Reimplemented in KoPathShape, and KoSvgTextShape.

Definition at line 559 of file KoShape.cpp.

560{
561 QPainterPath path;
562 path.addRect(outlineRect());
563 return path;
564}

References outlineRect().

◆ outlineRect()

QRectF KoShape::outlineRect ( ) const
virtual

returns the outline of the shape in the form of a rect. The outlineRect returned will always be relative to the position() of the shape, so moving the shape will not alter the result. The outline is used to calculate the boundingRect.

Returns
the outline of the shape in the form of a rect.

Reimplemented in KoPathShape, KoSelection, KoShapeGroup, and KoSvgTextShape.

Definition at line 566 of file KoShape.cpp.

567{
568 const QSizeF s = size();
569 return QRectF(QPointF(0, 0), QSizeF(qMax(s.width(), qreal(0.0001)),
570 qMax(s.height(), qreal(0.0001))));
571}

References s, and size().

◆ paint()

virtual void KoShape::paint ( QPainter & painter) const
pure virtual

Paint the shape fill The class extending this one is responsible for painting itself. painter is expected to be preconfigured to work in "document" pixels.

Parameters
painterused for painting the shape

Implemented in KisReferenceImage, KoPathShape, KoSelection, KoShapeContainer, KoSvgTextShape, KisNodeShape, and ImageShape.

◆ paintMarkers()

void KoShape::paintMarkers ( QPainter & painter) const
virtual

paintStroke paints the shape's markers

Parameters
painterused for painting the shape
See also
applyConversion()

Definition at line 202 of file KoShape.cpp.

203{
204 if (stroke()) {
205 stroke()->paintMarkers(this, painter);
206 }
207}
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:890

References stroke().

◆ paintOrder()

QVector< KoShape::PaintOrder > KoShape::paintOrder ( ) const
virtual

paintOrder

Returns
vector of paint orders, will always be 3 big and contain a fill, stroke and marker entry.

Reimplemented in KoSvgTextShape.

Definition at line 693 of file KoShape.cpp.

694{
696 if (!s->inheritPaintOrder) {
697 order = s->paintOrder;
698 } else if (parent()) {
699 order = parent()->paintOrder();
700 }
701 return order;
702}
virtual QVector< PaintOrder > paintOrder() const
paintOrder
Definition KoShape.cpp:693
static QVector< PaintOrder > defaultPaintOrder()
default paint order as per SVG specification
Definition KoShape.cpp:704

References defaultPaintOrder(), paintOrder(), parent(), and s.

◆ paintStroke()

void KoShape::paintStroke ( QPainter & painter) const
virtual

paintStroke paints the shape's stroked outline

Parameters
painterused for painting the shape
See also
applyConversion()

Reimplemented in KoSvgTextShape.

Definition at line 195 of file KoShape.cpp.

196{
197 if (stroke()) {
198 stroke()->paint(this, painter);
199 }
200}

References stroke().

◆ parent()

KoShapeContainer * KoShape::parent ( ) const

Returns the parent, or 0 if there is no parent.

Returns
the parent, or 0 if there is no parent.

Definition at line 862 of file KoShape.cpp.

863{
864 return d->parent;
865}

References d, and parent().

◆ position()

QPointF KoShape::position ( ) const

Get the position of the shape in pt.

Returns
the position of the shape

Definition at line 745 of file KoShape.cpp.

746{
747 QPointF center = outlineRect().center();
748 return s->localMatrix.map(center) - center;
749}

References outlineRect(), and s.

◆ removeAdditionalAttribute()

void KoShape::removeAdditionalAttribute ( const QString & name)

Remove additional attribute

Parameters
nameThe name of the attribute in the following form prefix:tag e.g. presentation:placeholder

Definition at line 1082 of file KoShape.cpp.

1083{
1084 s->additionalAttributes.remove(name);
1085}

References name(), and s.

◆ removeAdditionalStyleAttribute()

void KoShape::removeAdditionalStyleAttribute ( const char * name)

Definition at line 1102 of file KoShape.cpp.

1103{
1104 s->additionalStyleAttributes.remove(name);
1105}

References name(), and s.

◆ removeDependee()

void KoShape::removeDependee ( KoShape * shape)

Removes as shape depending on this shape.

See also
addDependee(), hasDependee()

Definition at line 1043 of file KoShape.cpp.

1044{
1045 d->dependees.removeOne(shape);
1046 shape->removeShapeChangeListener(&d->dependeesLifetimeListener);
1047}
void removeShapeChangeListener(ShapeChangeListener *listener)
Definition KoShape.cpp:1165

References d, and removeShapeChangeListener().

◆ removeShapeChangeListener()

void KoShape::removeShapeChangeListener ( KoShape::ShapeChangeListener * listener)

Definition at line 1165 of file KoShape.cpp.

1166{
1167
1168 KIS_SAFE_ASSERT_RECOVER_RETURN(d->listeners.contains(listener));
1169 d->listeners.removeAll(listener);
1170 listener->unregisterShape(this);
1171}
void unregisterShape(KoShape *shape)
Definition KoShape.cpp:1140

References d, KIS_SAFE_ASSERT_RECOVER_RETURN, and KoShape::ShapeChangeListener::unregisterShape().

◆ removeShapeManager()

void KoShape::removeShapeManager ( KoShapeManager * manager)
private

Definition at line 125 of file KoShape.cpp.

126{
127 d->shapeManagers.remove(manager);
128}

References d.

◆ rotate()

void KoShape::rotate ( qreal angle)

Rotate the shape (relative)

The shape will be rotated from the current rotation using the center of the shape using the size()

Parameters
anglechange the angle of rotation increasing it with 'angle' degrees

Definition at line 222 of file KoShape.cpp.

223{
224 QPointF center = s->localMatrix.map(QPointF(0.5 * size().width(), 0.5 * size().height()));
225 QTransform rotateMatrix;
226 rotateMatrix.translate(center.x(), center.y());
227 rotateMatrix.rotate(angle);
228 rotateMatrix.translate(-center.x(), -center.y());
229 s->localMatrix = s->localMatrix * rotateMatrix;
230
233}

References notifyChanged(), RotationChanged, s, shapeChangedPriv(), and size().

◆ rotation()

qreal KoShape::rotation ( ) const

Return the current rotation in degrees. It returns NaN if the shape has a shearing or scaling transformation applied.

Definition at line 720 of file KoShape.cpp.

721{
722 // try to extract the rotation angle out of the local matrix
723 // if it is a pure rotation matrix
724
725 // check if the matrix has shearing mixed in
726 if (fabs(fabs(s->localMatrix.m12()) - fabs(s->localMatrix.m21())) > 1e-10)
727 return std::numeric_limits<qreal>::quiet_NaN();
728 // check if the matrix has scaling mixed in
729 if (fabs(s->localMatrix.m11() - s->localMatrix.m22()) > 1e-10)
730 return std::numeric_limits<qreal>::quiet_NaN();
731
732 // calculate the angle from the matrix elements
733 qreal angle = atan2(-s->localMatrix.m21(), s->localMatrix.m11()) * 180.0 / M_PI;
734 if (angle < 0.0)
735 angle += 360.0;
736
737 return angle;
738}
#define M_PI
Definition kis_global.h:111
KRITAIMAGE_EXPORT qreal atan2(qreal y, qreal x)
atan2 replacement

References M_PI, and s.

◆ scale()

void KoShape::scale ( qreal sx,
qreal sy )

Scale the shape using the zero-point which is the top-left corner.

See also
position()
Parameters
sxscale in x direction
syscale in y direction

Definition at line 209 of file KoShape.cpp.

210{
211 QPointF pos = position();
212 QTransform scaleMatrix;
213 scaleMatrix.translate(pos.x(), pos.y());
214 scaleMatrix.scale(sx, sy);
215 scaleMatrix.translate(-pos.x(), -pos.y());
216 s->localMatrix = s->localMatrix * scaleMatrix;
217
220}

References notifyChanged(), position(), s, ScaleChanged, and shapeChangedPriv().

◆ setAbsolutePosition()

void KoShape::setAbsolutePosition ( const QPointF & newPosition,
KoFlake::AnchorPosition anchor = KoFlake::Center )

Move this shape to an absolute position where the end location will be the same regardless of the shape's rotation/skew/scaling and regardless of this shape having a parent (being in a group) or not.
The newPosition is going to be the center of the shape. This has the convenient effect that:

shape->setAbsolutePosition(QPointF(0,0));
shape->rotate(45);

Will result in the same visual position of the shape as the opposite:

shape->rotate(45);
shape->setAbsolutePosition(QPointF(0,0));
Parameters
newPositionthe new absolute center of the shape.
anchorThe place on the (unaltered) shape that you set the position of.

Definition at line 588 of file KoShape.cpp.

589{
590 QPointF currentAbsPosition = absolutePosition(anchor);
591 QPointF translate = newPosition - currentAbsPosition;
592 QTransform translateMatrix;
593 translateMatrix.translate(translate.x(), translate.y());
594 applyAbsoluteTransformation(translateMatrix);
597}

References absolutePosition(), anchor(), applyAbsoluteTransformation(), notifyChanged(), PositionChanged, and shapeChangedPriv().

◆ setAdditionalAttribute()

void KoShape::setAdditionalAttribute ( const QString & name,
const QString & value )

Set additional attribute

This can be used to attach additional attributes to a shape for attributes that are application specific like presentation:placeholder

Parameters
nameThe name of the attribute in the following form prefix:tag e.g. presentation:placeholder
valueThe value of the attribute

Definition at line 1077 of file KoShape.cpp.

1078{
1079 s->additionalAttributes.insert(name, value);
1080}
float value(const T *src, size_t ch)

References name(), s, and value().

◆ setAdditionalStyleAttribute()

void KoShape::setAdditionalStyleAttribute ( const char * name,
const QString & value )

Definition at line 1097 of file KoShape.cpp.

1098{
1099 s->additionalStyleAttributes.insert(name, value);
1100}

References name(), s, and value().

◆ setAnchor()

void KoShape::setAnchor ( KoShapeAnchor * anchor)

Set the KoShapeAnchor

◆ setBackground()

void KoShape::setBackground ( QSharedPointer< KoShapeBackground > background)
virtual

Set the background of the shape. A shape background can be a plain color, a gradient, a pattern, be fully transparent or have a complex fill. Setting such a background will allow the shape to be filled and will be able to tell if it is transparent or not.

If the shape inherited the background from its parent, its stops inheriting it, that is inheritBackground property resets to false.

Parameters
backgroundthe new shape background.

Reimplemented in KoSvgTextShape.

Definition at line 751 of file KoShape.cpp.

752{
753 s->inheritBackground = false;
754 s->fill = fill;
757}

References BackgroundChanged, notifyChanged(), s, and shapeChangedPriv().

◆ setClipMask()

void KoShape::setClipMask ( KoClipMask * clipMask)

Sets a new clip mask, removing the old one. The mask is owned by the shape.

Definition at line 938 of file KoShape.cpp.

939{
940 s->clipMask.reset(clipMask);
943}
KoClipMask * clipMask() const
Returns the currently set clip mask or 0 if there is no clip mask set.
Definition KoShape.cpp:945

References clipMask(), ClipMaskChanged, notifyChanged(), s, and shapeChangedPriv().

◆ setClipPath()

void KoShape::setClipPath ( KoClipPath * clipPath)

Sets a new clip path, removing the old one.

Definition at line 926 of file KoShape.cpp.

927{
928 s->clipPath.reset(clipPath);
931}
KoClipPath * clipPath() const
Returns the currently set clip path or 0 if there is no clip path set.
Definition KoShape.cpp:933

References clipPath(), ClipPathChanged, notifyChanged(), s, and shapeChangedPriv().

◆ setContentProtected()

void KoShape::setContentProtected ( bool protect)

Marks the shape to have its content protected against editing. Content protection is a hint for tools to disallow the user editing the content.

Parameters
protectwhen true set the shapes content to be protected from user modification.
See also
setGeometryProtected(), setSelectable(), setVisible()

Definition at line 852 of file KoShape.cpp.

853{
854 s->protectContent = protect;
855}

References s.

◆ setGeometryProtected()

void KoShape::setGeometryProtected ( bool on)

Tells the shape to have its position/rotation and size protected from user-changes. The geometry being protected means the user can not change shape or position of the shape. This includes any matrix operation such as rotation.

Parameters
onwhen true; set the shape to have its geometry protected.
See also
setContentProtected(), setSelectable(), setVisible()

Definition at line 842 of file KoShape.cpp.

843{
844 s->geometryProtected = on;
845}

References s.

◆ setHyperLink()

void KoShape::setHyperLink ( const QString & hyperLink)

Set hyperlink for this shape.

Parameters
hyperLinkname.

Definition at line 1122 of file KoShape.cpp.

1123{
1124 s->hyperLink = hyperLink;
1125}
QString hyperLink() const
Definition KoShape.cpp:1117

References hyperLink(), and s.

◆ setInheritBackground()

void KoShape::setInheritBackground ( bool value)

setInheritBackground marks a shape as inheriting the background from the parent shape. NOTE: The currently selected background is destroyed.

Parameters
valuetrue if the shape should inherit the filling background

Definition at line 773 of file KoShape.cpp.

774{
775
776 s->inheritBackground = value;
777 if (s->inheritBackground) {
778 s->fill.clear();
779 }
780}

References s, and value().

◆ setInheritPaintOrder()

void KoShape::setInheritPaintOrder ( bool value)

setInheritPaintOrder set inherit paint order.

Parameters
value

Definition at line 710 of file KoShape.cpp.

711{
712 s->inheritPaintOrder = value;
713}

References s, and value().

◆ setInheritStroke()

void KoShape::setInheritStroke ( bool value)

setInheritStroke marks a shape as inheriting the stroke from the parent shape. NOTE: The currently selected stroke is destroyed.

Parameters
valuetrue if the shape should inherit the stroke style

Definition at line 913 of file KoShape.cpp.

914{
915 s->inheritStroke = value;
916 if (s->inheritStroke) {
917 s->stroke.clear();
918 }
919}

References s, and value().

◆ setKeepAspectRatio()

void KoShape::setKeepAspectRatio ( bool keepAspect)

Setting the shape to keep its aspect-ratio has the effect that user-scaling will keep the width/height ratio intact so as not to distort shapes that rely on that ratio.

Parameters
keepAspectthe new value

Definition at line 867 of file KoShape.cpp.

868{
869 s->keepAspect = keepAspect;
870
873}

References KeepAspectRatioChange, notifyChanged(), s, and shapeChangedPriv().

◆ setMinimumHeight()

void KoShape::setMinimumHeight ( qreal height)

Set the minimum height of the shape. Currently it's not respected but only for informational purpose

Parameters
heightthe minimum height of the frame.

◆ setName()

void KoShape::setName ( const QString & name)

Sets the name of the shape.

Parameters
namethe new shape name

Definition at line 960 of file KoShape.cpp.

961{
962 s->name = name;
963}

References name(), and s.

◆ setPaintOrder()

void KoShape::setPaintOrder ( KoShape::PaintOrder first,
KoShape::PaintOrder second )
virtual

setPaintOrder set the paint order. As there's only three entries in any given paintorder, you only need to have the first and second entry to set it.

Parameters
firstfirst thing to paint
secondsecond thing to paint.

Reimplemented in KoSvgTextShape.

Definition at line 669 of file KoShape.cpp.

670{
671 KIS_SAFE_ASSERT_RECOVER_RETURN(first != second);
673
674 if (first != Fill) {
675 if (order.at(1) == first) {
676 order[1] = order[0];
677 order[0] = first;
678 } else if (order.at(2) == first) {
679 order[2] = order[0];
680 order[0] = first;
681 }
682 }
683 if (second != first && second != Stroke) {
684 if (order.at(2) == second) {
685 order[2] = order[1];
686 order[1] = second;
687 }
688 }
689 s->inheritPaintOrder = false;
690 s->paintOrder = order;
691}

References defaultPaintOrder(), Fill, KIS_SAFE_ASSERT_RECOVER_RETURN, and s.

◆ setParent()

void KoShape::setParent ( KoShapeContainer * parent)

Set the parent of this shape.

Parameters
parentthe new parent of this shape. Can be 0 if the shape has no parent anymore.

Definition at line 464 of file KoShape.cpp.

465{
466
467 if (d->parent == parent) {
468 return;
469 }
470
471 if (d->parent) {
472 d->parent->shapeInterface()->removeShape(this);
473 d->parent = 0;
474 }
475
476
478
479 if (parent && parent != this) {
480 d->parent = parent;
482 }
483
486}
KoShapeContainer::ShapeInterface shapeInterface

References KoShapeContainer::ShapeInterface::addShape(), d, KIS_SAFE_ASSERT_RECOVER_NOOP, notifyChanged(), parent(), ParentChanged, KoShapeContainer::ShapeInterface::removeShape(), shapeChangedPriv(), and KoShapeContainer::shapeInterface.

◆ setPosition()

void KoShape::setPosition ( const QPointF & position)
virtual

Set the position of the shape in pt.

Parameters
positionthe new position of the shape

Reimplemented in KisNodeShape.

Definition at line 267 of file KoShape.cpp.

268{
269 QPointF currentPos = position();
270 if (newPosition == currentPos)
271 return;
272 QTransform translateMatrix;
273 translateMatrix.translate(newPosition.x() - currentPos.x(), newPosition.y() - currentPos.y());
274 s->localMatrix = s->localMatrix * translateMatrix;
275
278}

References notifyChanged(), position(), PositionChanged, s, and shapeChangedPriv().

◆ setPrintable()

void KoShape::setPrintable ( bool on)

Changes the shape to be printable or not. The default is true.

If a Shape's print flag is true, the shape will be printed. If false, the shape will not be printed. If a shape is not visible (

See also
isVisible), it isPrinted will return false, too.

Definition at line 819 of file KoShape.cpp.

820{
821 s->printable = on;
822}

References s.

◆ setResolution()

void KoShape::setResolution ( qreal xRes,
qreal yRes )
virtual

Update the image resolution in pixels per inch. Shapes should override this if they need to know the image resolution.

Parameters
xRes
yRes

Reimplemented in KoSvgTextShape.

Definition at line 1213 of file KoShape.cpp.

1214{
1215}

◆ setSelectable()

void KoShape::setSelectable ( bool selectable)

Makes it possible for the user to select this shape. This parameter defaults to true.

Parameters
selectablewhen true; set the shape to be selectable by the user.
See also
setGeometryProtected(), setContentProtected(), setVisible()

Definition at line 832 of file KoShape.cpp.

833{
834 s->selectable = selectable;
835}

References s.

◆ setShapeId()

void KoShape::setShapeId ( const QString & id)

Set the Id of this shape. A shapeFactory is expected to set the Id at creation so applications can find out what kind of shape this is.

See also
KoShapeFactoryBase::shapeId()
Parameters
idthe ID from the factory that created this shape

Definition at line 885 of file KoShape.cpp.

886{
887 s->shapeId = id;
888}

References s.

◆ setSize()

void KoShape::setSize ( const QSizeF & size)
virtual

Resize the shape.

Parameters
sizethe new size of the shape. This is different from scaling as scaling is a so called secondary operation which is comparable to zooming in instead of changing the size of the basic shape. Easiest example of this difference is that using this method will not distort the size of pattern-fills and strokes.

Reimplemented in EllipseShape, SpiralShape, StarShape, KarbonCalligraphicShape, KoParameterShape, KoPathShape, KoSelection, KoShapeGroup, KoSvgTextShape, and ImageShape.

Definition at line 248 of file KoShape.cpp.

249{
250 QSizeF oldSize(size());
251
252 // always set size, as d->size and size() may vary
253 setSizeImpl(newSize);
254
255 if (oldSize == newSize)
256 return;
257
260}
void setSizeImpl(const QSizeF &size) const
Definition KoShape.cpp:262

References notifyChanged(), setSizeImpl(), shapeChangedPriv(), size(), and SizeChanged.

◆ setSizeImpl()

void KoShape::setSizeImpl ( const QSizeF & size) const
protected

Definition at line 262 of file KoShape.cpp.

263{
264 s->size = size;
265}

References s, and size().

◆ setStroke()

void KoShape::setStroke ( KoShapeStrokeModelSP stroke)
virtual

Set a new stroke, removing the old one. The stroke inheritance becomes disabled.

Parameters
strokethe new stroke, or 0 if there should be no stroke.

Reimplemented in KoSvgTextShape.

Definition at line 904 of file KoShape.cpp.

905{
906
907 s->inheritStroke = false;
908 s->stroke = stroke;
911}

References notifyChanged(), s, shapeChangedPriv(), stroke(), and StrokeChanged.

◆ setToolDelegates()

void KoShape::setToolDelegates ( const QSet< KoShape * > & delegates)

Set the tool delegates.

Parameters
delegatesthe new delegates.
See also
toolDelegates()

Definition at line 1112 of file KoShape.cpp.

1113{
1114 d->toolDelegates = delegates;
1115}

References d.

◆ setTransformation()

void KoShape::setTransformation ( const QTransform & matrix)

Sets a new transformation matrix describing the local transformations on this shape.

Parameters
matrixthe new transformation matrix

Definition at line 374 of file KoShape.cpp.

375{
376 if (s->localMatrix != matrix) {
377 s->localMatrix = matrix;
380 }
381}

References GenericMatrixChange, notifyChanged(), s, and shapeChangedPriv().

◆ setTransparency()

void KoShape::setTransparency ( qreal transparency)

Sets shape level transparency.

Parameters
transparencythe new shape level transparency

Definition at line 642 of file KoShape.cpp.

643{
644 s->transparency = qBound<qreal>(0.0, transparency, 1.0);
645
648}
qreal transparency(bool recursive=false) const
Definition KoShape.cpp:650

References notifyChanged(), s, shapeChangedPriv(), transparency(), and TransparencyChanged.

◆ setUserData()

void KoShape::setUserData ( KoShapeUserData * userData)

Set a data object on the shape to be used by an application. This is specifically useful when a shape is created in a plugin and that data from that shape should be accessible outside the plugin.

Parameters
userDatathe new user data, or 0 to delete the current one.

Definition at line 625 of file KoShape.cpp.

626{
627 s->userData.reset(userData);
628}
KoShapeUserData * userData() const
Definition KoShape.cpp:630

References s, and userData().

◆ setVisible()

void KoShape::setVisible ( bool on)

Changes the Shape to be visible or invisible. Being visible means being painted, as well as being used for things like guidelines or searches.

Parameters
onwhen true; set the shape to be visible.
See also
setGeometryProtected(), setContentProtected(), setSelectable()

Definition at line 795 of file KoShape.cpp.

796{
797 int _on = (on ? 1 : 0);
798 if (s->visible == _on) return;
799 s->visible = _on;
800}

References s.

◆ setZIndex()

void KoShape::setZIndex ( qint16 zIndex)

Set the z-coordinate of this shape. The zIndex property is used to determine which shape lies on top of other objects. An shape with a higher z-order is on top, and can obscure, another shape.

Just like two objects having the same x or y coordinate will make them 'touch', so will two objects with the same z-index touch on the z plane. In layering the shape this, however, can cause a little confusion as one always has to be on top. The layering if two overlapping objects have the same index is implementation dependent and probably depends on the order in which they are added to the shape manager.

Parameters
zIndexthe new z-index;

Definition at line 787 of file KoShape.cpp.

788{
789 if (s->zIndex == zIndex)
790 return;
791 s->zIndex = zIndex;
793}

References notifyChanged(), s, and zIndex().

◆ shapeChanged()

void KoShape::shapeChanged ( ChangeType type,
KoShape * shape = 0 )
protectedvirtual

A hook that allows inheriting classes to do something after a KoShape property changed This is called whenever the shape, position rotation or scale properties were altered.

Parameters
typean indicator which type was changed.
shapethe shape.

NOTE: we don't need to handle Deleted type for the shapes in d->dependees list here, becasue this function is called on the other side of the relation, i.e. in the actual "dependee". We handle that in Private::DependeesLifetimeListener.

Reimplemented in KoSvgTextShape, KoShapeContainer, and KoShapeGroup.

Definition at line 1059 of file KoShape.cpp.

1060{
1061 Q_UNUSED(type);
1062 Q_UNUSED(shape);
1063
1070}

◆ shapeChangedPriv()

void KoShape::shapeChangedPriv ( KoShape::ChangeType type)
protected

Notify the shape that a change was done. To be used by inheriting shapes.

Parameters
typethe change type

Definition at line 104 of file KoShape.cpp.

105{
106 if (d->parent)
107 d->parent->model()->childChanged(this, type);
108
109 this->shapeChanged(type);
110
111 Q_FOREACH (KoShape * shape, d->dependees) {
112 shape->shapeChanged(type, this);
113 }
114
115 Q_FOREACH (KoShape::ShapeChangeListener *listener, d->listeners) {
116 listener->notifyShapeChangedImpl(type, this);
117 }
118}
QList< KoShape * > dependees() const
Returns list of shapes depending on this shape.
Definition KoShape.cpp:1054
virtual void shapeChanged(ChangeType type, KoShape *shape=0)
Definition KoShape.cpp:1059
void notifyShapeChangedImpl(ChangeType type, KoShape *shape)
Definition KoShape.cpp:1146

References d, dependees(), KoShape::ShapeChangeListener::notifyShapeChangedImpl(), and shapeChanged().

◆ shapeId()

QString KoShape::shapeId ( ) const

Return the Id of this shape, identifying the type of shape by the id of the factory.

See also
KoShapeFactoryBase::shapeId()
Returns
the id of the shape-type

Definition at line 880 of file KoShape.cpp.

881{
882 return s->shapeId;
883}

References s.

◆ shapeToDocument() [1/2]

QPointF KoShape::shapeToDocument ( const QPointF & point) const

Transforms point from shape coordinates to document coordinates.

Parameters
pointin shape coordinates
Returns
point in document coordinates

Definition at line 1006 of file KoShape.cpp.

1007{
1008 return absoluteTransformation().map(point);
1009}

References absoluteTransformation().

◆ shapeToDocument() [2/2]

QRectF KoShape::shapeToDocument ( const QRectF & rect) const

Transforms rect from shape coordinates to document coordinates.

Parameters
rectin shape coordinates
Returns
rect in document coordinates

Definition at line 1011 of file KoShape.cpp.

1012{
1013 return absoluteTransformation().mapRect(rect);
1014}

References absoluteTransformation().

◆ shear()

void KoShape::shear ( qreal sx,
qreal sy )

Shear the shape The shape will be sheared using the zero-point which is the top-left corner.

See also
position()
Parameters
sxshear in x direction
syshear in y direction

Definition at line 235 of file KoShape.cpp.

236{
237 QPointF pos = position();
238 QTransform shearMatrix;
239 shearMatrix.translate(pos.x(), pos.y());
240 shearMatrix.shear(sx, sy);
241 shearMatrix.translate(-pos.x(), -pos.y());
242 s->localMatrix = s->localMatrix * shearMatrix;
243
246}

References notifyChanged(), position(), s, shapeChangedPriv(), and ShearChanged.

◆ size()

QSizeF KoShape::size ( ) const
virtual

Get the size of the shape in pt.

The size is in shape coordinates.

Returns
the size of the shape as set by setSize()

Reimplemented in KoPathShape, KoSelection, KoShapeGroup, KoSvgTextShape, and KisNodeShape.

Definition at line 740 of file KoShape.cpp.

741{
742 return s->size;
743}

References s.

◆ snapData()

KoSnapData KoShape::snapData ( ) const
virtual

Returns additional snap data the shape wants to have snapping to.

Definition at line 1072 of file KoShape.cpp.

1073{
1074 return KoSnapData();
1075}

◆ stroke()

KoShapeStrokeModelSP KoShape::stroke ( ) const
virtual

Returns the currently set stroke, or 0 if there is no stroke.

Returns
the currently set stroke, or 0 if there is no stroke.

Reimplemented in KoSvgTextShape.

Definition at line 890 of file KoShape.cpp.

891{
892
894
895 if (!s->inheritStroke) {
896 stroke = s->stroke;
897 } else if (parent()) {
898 stroke = parent()->stroke();
899 }
900
901 return stroke;
902}

References parent(), s, and stroke().

◆ strokeInsets()

KoInsets KoShape::strokeInsets ( ) const

Return the insets of the stroke. Convenience method for KoShapeStrokeModel::strokeInsets()

Definition at line 661 of file KoShape.cpp.

662{
663 KoInsets answer;
664 if (s->stroke)
665 s->stroke->strokeInsets(this, answer);
666 return answer;
667}

References s.

◆ toolDelegates()

QSet< KoShape * > KoShape::toolDelegates ( ) const

Return the tool delegates for this shape. In Flake a shape being selected will cause the tool manager to make available all tools that can edit the selected shapes. In some cases selecting one shape should allow the tool to edit a related shape be available too. The tool delegates allows this to happen by taking all the shapes in the set into account on tool selection. Notice that if the set is non-empty 'this' shape is no longer looked at. You can choose to add itself to the set too.

Definition at line 1107 of file KoShape.cpp.

1108{
1109 return d->toolDelegates;
1110}

References d.

◆ transform()

QTransform KoShape::transform ( ) const
protected

return the current matrix that contains the rotation/scale/position of this shape

Definition at line 950 of file KoShape.cpp.

951{
952 return s->localMatrix;
953}

References s.

◆ transformation()

QTransform KoShape::transformation ( ) const

Returns the shapes local transformation matrix.

Definition at line 383 of file KoShape.cpp.

384{
385 return s->localMatrix;
386}

References s.

◆ transparency()

qreal KoShape::transparency ( bool recursive = false) const

Returns the shape level transparency.

Parameters
recursivewhen true takes the parents transparency into account

Definition at line 650 of file KoShape.cpp.

651{
652 if (!recursive || !parent()) {
653 return s->transparency;
654 } else {
655 const qreal parentOpacity = 1.0-parent()->transparency(recursive);
656 const qreal childOpacity = 1.0-s->transparency;
657 return 1.0-(parentOpacity*childOpacity);
658 }
659}

References parent(), s, and transparency().

◆ update()

void KoShape::update ( ) const
virtual

Request a repaint to be queued. The repaint will be of the entire Shape, including its selection handles should this shape be selected.

This method will return immediately and only request a repaint. Successive calls will be merged into an appropriate repaint action.

Reimplemented in KoShapeContainer, and KoShapeContainer.

Definition at line 534 of file KoShape.cpp.

535{
536
537 if (!d->shapeManagers.empty()) {
538 const QRectF rect(boundingRect());
539 Q_FOREACH (KoShapeManager * manager, d->shapeManagers) {
540 manager->update(rect, this, true);
541 }
542 }
543}
void update(const QRectF &rect, const KoShape *shape=0, bool selectionHandles=false)

References boundingRect(), d, and KoShapeManager::update().

◆ updateAbsolute()

void KoShape::updateAbsolute ( const QRectF & rect) const
virtual

Request a repaint to be queued. The repaint will be restricted to the parameters rectangle, which is expected to be in absolute coordinates of the canvas and it is expected to be normalized.

This method will return immediately and only request a repaint. Successive calls will be merged into an appropriate repaint action.

Parameters
rectthe rectangle (in pt) to queue for repaint.

Definition at line 545 of file KoShape.cpp.

546{
547 if (rect.isEmpty() && !rect.isNull()) {
548 return;
549 }
550
551
552 if (!d->shapeManagers.empty() && isVisible()) {
553 Q_FOREACH (KoShapeManager *manager, d->shapeManagers) {
554 manager->update(rect);
555 }
556 }
557}

References d, isVisible(), and KoShapeManager::update().

◆ userData()

KoShapeUserData * KoShape::userData ( ) const

Return the current userData.

Definition at line 630 of file KoShape.cpp.

631{
632 return s->userData.data();
633}

References s.

◆ waitUntilReady()

void KoShape::waitUntilReady ( bool asynchronous = true) const
virtual

A shape can be in a state that it is doing processing data like loading or text layout. In this case it can be shown on screen probably partially but it should really not be printed until it is fully done processing. Warning! This method can be blocking for a long time

Parameters
asynchronousIf set to true the processing will can take place in a different thread and the function will not block until the shape is finished. In case of printing Flake will call this method from a non-main thread and only start printing it when the in case of printing method returned. If set to false the processing needs to be done synchronously and will block until the result is finished.

Definition at line 965 of file KoShape.cpp.

966{
967 Q_UNUSED(asynchronous);
968}

◆ zIndex()

qint16 KoShape::zIndex ( ) const

Retrieve the z-coordinate of this shape. The zIndex property is used to determine which shape lies on top of other objects. An shape with a higher z-order is on top, and can obscure another shape.

Returns
the z-index of this shape.
See also
setZIndex()

Definition at line 529 of file KoShape.cpp.

530{
531 return s->zIndex;
532}

References s, and zIndex().

Friends And Related Symbol Documentation

◆ KoShapeManager

friend class KoShapeManager
friend

Definition at line 990 of file KoShape.h.

Member Data Documentation

◆ d

QScopedPointer<Private> KoShape::d
private

Definition at line 974 of file KoShape.h.

◆ maxZIndex

const qint16 KoShape::maxZIndex = std::numeric_limits<qint16>::max()
static

Maximum value of z-index

Definition at line 383 of file KoShape.h.

◆ minZIndex

const qint16 KoShape::minZIndex = std::numeric_limits<qint16>::min()
static

Minimum value of z-index

Definition at line 388 of file KoShape.h.

◆ s

QSharedDataPointer<SharedData> KoShape::s
private

Definition at line 977 of file KoShape.h.


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