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 136 of file KoShape.cpp.

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

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 149 of file KoShape.cpp.

150{
152 d->listeners.clear();
161 KIS_SAFE_ASSERT_RECOVER (!d->parent) {
162 d->parent->removeShape(this);
163 }
164
165 KIS_SAFE_ASSERT_RECOVER (d->shapeManagers.isEmpty()) {
166 Q_FOREACH (KoShapeManager *manager, d->shapeManagers) {
167 manager->shapeInterface()->notifyShapeDestructed(this);
168 }
169 d->shapeManagers.clear();
170 }
171}
KoShapeManager::ShapeInterface shapeInterface
void shapeChangedPriv(KoShape::ChangeType type)
Definition KoShape.cpp:105
#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 143 of file KoShape.cpp.

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

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 319 of file KoShape.cpp.

320{
321 return absoluteTransformation().map(outline()).boundingRect();
322}
virtual QPainterPath outline() const
Definition KoShape.cpp:554
QTransform absoluteTransformation() const
Definition KoShape.cpp:330

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 324 of file KoShape.cpp.

325{
326 return std::accumulate(shapes.begin(), shapes.end(), QRectF(),
328}
QRectF absoluteOutlineRect() const
Definition KoShape.cpp:319
auto mem_bit_or(MemType Class::*ptr)
mem_bit_or is a binary functor that applies a bitwise-or operator to member of an object and a given ...
Definition KisMpl.h:589

References absoluteOutlineRect(), and kismpl::mem_bit_or().

◆ 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 568 of file KoShape.cpp.

569{
570 const QRectF rc = outlineRect();
571
572 QPointF point = rc.topLeft();
573
574 bool valid = false;
575 QPointF anchoredPoint = KoFlake::anchorToPoint(anchor, rc, &valid);
576 if (valid) {
577 point = anchoredPoint;
578 }
579
580 return absoluteTransformation().map(point);
581}
virtual QRectF outlineRect() const
Definition KoShape.cpp:561
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 330 of file KoShape.cpp.

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

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 1021 of file KoShape.cpp.

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

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 1087 of file KoShape.cpp.

1088{
1089 return s->additionalAttributes.value(name);
1090}
QString name() const
Definition KoShape.cpp:950

References name(), and s.

◆ addShapeChangeListener()

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

Definition at line 1152 of file KoShape.cpp.

1153{
1154
1155 KIS_SAFE_ASSERT_RECOVER_RETURN(!d->listeners.contains(listener));
1156 listener->registerShape(this);
1157 d->listeners.append(listener);
1158}
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
void registerShape(KoShape *shape)
Definition KoShape.cpp:1129

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

◆ addShapeManager()

void KoShape::addShapeManager ( KoShapeManager * manager)
private

Definition at line 121 of file KoShape.cpp.

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

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 348 of file KoShape.cpp.

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

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 358 of file KoShape.cpp.

359{
360 const QTransform newLocalMatrix = matrix * s->localMatrix;
361
362 if (s->localMatrix != newLocalMatrix) {
363 s->localMatrix = newLocalMatrix;
366 }
367}

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 754 of file KoShape.cpp.

755{
756
758
759 if (!s->inheritBackground) {
760 bg = s->fill;
761 } else if (parent()) {
762 bg = parent()->background();
763 }
764
765 return bg;
766}
virtual QSharedPointer< KoShapeBackground > background() const
Definition KoShape.cpp:754

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 300 of file KoShape.cpp.

301{
302 QTransform transform = absoluteTransformation();
303 QRectF bb = outlineRect();
304 if (s->stroke) {
305 KoInsets insets;
306 s->stroke->strokeInsets(this, insets);
307 bb.adjust(-insets.left, -insets.top, insets.right, insets.bottom);
308 }
309 bb = transform.mapRect(bb);
310 return bb;
311}
QTransform transform() const
return the current matrix that contains the rotation/scale/position of this shape
Definition KoShape.cpp:945
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 313 of file KoShape.cpp.

314{
315 return std::accumulate(shapes.begin(), shapes.end(), QRectF(),
317}
virtual QRectF boundingRect() const
Get the bounding box of the shape.
Definition KoShape.cpp:300

References boundingRect(), and kismpl::mem_bit_or().

◆ 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 383 of file KoShape.cpp.

384{
385 return ChildZDefault;
386}

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 940 of file KoShape.cpp.

941{
942 return s->clipMask.data();
943}

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 928 of file KoShape.cpp.

929{
930 return s->clipPath.data();
931}

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 173 of file KoShape.cpp.

174{
175 KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "not implemented!");
176 qWarning() << shapeId() << "cannot be cloned";
177 return 0;
178}
QString shapeId() const
Definition KoShape.cpp:875
#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 180 of file KoShape.cpp.

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

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 388 of file KoShape.cpp.

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

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 594 of file KoShape.cpp.

595{
596 s->size = shape->size();
597 s->zIndex = shape->zIndex();
598 s->visible = shape->isVisible(false);
599
600 // Ensure printable is true by default
601 if (!s->visible)
602 s->printable = true;
603 else
604 s->printable = shape->isPrintable();
605
606 s->geometryProtected = shape->isGeometryProtected();
607 s->protectContent = shape->isContentProtected();
608 s->selectable = shape->isSelectable();
609 s->keepAspect = shape->keepAspectRatio();
610 s->localMatrix = shape->s->localMatrix;
611}
bool isContentProtected() const
Definition KoShape.cpp:852
bool isSelectable() const
Definition KoShape.cpp:832
bool isGeometryProtected() const
Definition KoShape.cpp:842
bool isPrintable() const
Definition KoShape.cpp:819
bool keepAspectRatio() const
Definition KoShape.cpp:870
bool isVisible(bool recursive=true) const
Definition KoShape.cpp:797

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 989 of file KoShape.cpp.

990{
991 const QTransform originalPainterTransform = painter->transform();
992
993 painter->setTransform(shape->absoluteTransformation() *
994 painter->transform());
995
996 // move c-tor
997 return KisHandlePainterHelper(painter, originalPainterTransform, handleRadius, decorationThickness);
998}
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 977 of file KoShape.cpp.

978{
979 const QTransform originalPainterTransform = painter->transform();
980
981 painter->setTransform(shape->absoluteTransformation() *
982 converter.documentToView() *
983 painter->transform());
984
985 // move c-tor
986 return KisHandlePainterHelper(painter, originalPainterTransform, handleRadius, decorationThickness);
987}
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 699 of file KoShape.cpp.

700{
701 static QVector<PaintOrder> order = {Fill, Stroke, Markers};
702 return order;
703}

References Fill, Markers, and Stroke.

◆ dependees()

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

Returns list of shapes depending on this shape.

Definition at line 1049 of file KoShape.cpp.

1050{
1051 return d->dependees;
1052}

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 1011 of file KoShape.cpp.

1012{
1013 return absoluteTransformation().inverted().map(point);
1014}

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 1016 of file KoShape.cpp.

1017{
1018 return absoluteTransformation().inverted().mapRect(rect);
1019}

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 1082 of file KoShape.cpp.

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

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 505 of file KoShape.cpp.

506{
507 const KoShape *thisShape = this;
508 while (thisShape) {
509
510 const KoShape *otherShape = shape;
511 while (otherShape) {
512 if (thisShape == otherShape) {
513 return true;
514 }
515 otherShape = otherShape->parent();
516 }
517
518 thisShape = thisShape->parent();
519 }
520
521 return false;
522}

◆ hasDependee()

bool KoShape::hasDependee ( KoShape * shape) const

Returns if the given shape is dependent on this shape.

Definition at line 1044 of file KoShape.cpp.

1045{
1046 return d->dependees.contains(shape);
1047}

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 630 of file KoShape.cpp.

631{
633
634 return !bg || bg->hasTransparency() || s->transparency > 0.0;
635}

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 281 of file KoShape.cpp.

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

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 1112 of file KoShape.cpp.

1113{
1114 return s->hyperLink;
1115}

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 777 of file KoShape.cpp.

778{
779 return s->inheritBackground;
780}

References s.

◆ inheritPaintOrder()

bool KoShape::inheritPaintOrder ( ) const

inheritPaintOrder

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

Definition at line 710 of file KoShape.cpp.

711{
712 return s->inheritPaintOrder;
713}

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 483 of file KoShape.cpp.

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

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 916 of file KoShape.cpp.

917{
918 return s->inheritStroke;
919}

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 852 of file KoShape.cpp.

853{
854 return s->protectContent;
855}

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 842 of file KoShape.cpp.

843{
844 return s->geometryProtected;
845}

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 819 of file KoShape.cpp.

820{
821 if (s->visible)
822 return s->printable;
823 else
824 return false;
825}

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 832 of file KoShape.cpp.

833{
834 return s->selectable;
835}

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 965 of file KoShape.cpp.

966{
967 if (!s->visible || s->geometryProtected)
968 return false;
969
970 if (recursive && d->parent) {
971 return d->parent->isShapeEditable(true);
972 }
973
974 return true;
975}

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 797 of file KoShape.cpp.

798{
799 if (!recursive)
800 return s->visible;
801
802 if (!s->visible)
803 return false;
804
805 KoShapeContainer * parentShape = parent();
806
807 if (parentShape) {
808 return parentShape->isVisible(true);
809 }
810
811 return true;
812}

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 870 of file KoShape.cpp.

871{
872 return s->keepAspect;
873}

References s.

◆ linearizeSubtree()

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

Definition at line 1173 of file KoShape.cpp.

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

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

◆ linearizeSubtreeSorted()

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

Definition at line 1189 of file KoShape.cpp.

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

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

◆ listeners()

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

Definition at line 1168 of file KoShape.cpp.

1169{
1170 return d->listeners;
1171}

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 950 of file KoShape.cpp.

951{
952 return s->name;
953}

References s.

◆ notifyChanged()

void KoShape::notifyChanged ( )

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

Definition at line 613 of file KoShape.cpp.

614{
615 Q_FOREACH (KoShapeManager * manager, d->shapeManagers) {
616 manager->notifyShapeChanged(this);
617 }
618}
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 554 of file KoShape.cpp.

555{
556 QPainterPath path;
557 path.addRect(outlineRect());
558 return path;
559}

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 561 of file KoShape.cpp.

562{
563 const QSizeF s = size();
564 return QRectF(QPointF(0, 0), QSizeF(qMax(s.width(), qreal(0.0001)),
565 qMax(s.height(), qreal(0.0001))));
566}

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 203 of file KoShape.cpp.

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

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 688 of file KoShape.cpp.

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

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 196 of file KoShape.cpp.

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

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 857 of file KoShape.cpp.

858{
859 return d->parent;
860}

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 740 of file KoShape.cpp.

741{
742 QPointF center = outlineRect().center();
743 return s->localMatrix.map(center) - center;
744}

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 1077 of file KoShape.cpp.

1078{
1079 s->additionalAttributes.remove(name);
1080}

References name(), and s.

◆ removeAdditionalStyleAttribute()

void KoShape::removeAdditionalStyleAttribute ( const char * name)

Definition at line 1097 of file KoShape.cpp.

1098{
1099 s->additionalStyleAttributes.remove(name);
1100}

References name(), and s.

◆ removeDependee()

void KoShape::removeDependee ( KoShape * shape)

Removes as shape depending on this shape.

See also
addDependee(), hasDependee()

Definition at line 1038 of file KoShape.cpp.

1039{
1040 d->dependees.removeOne(shape);
1041 shape->removeShapeChangeListener(&d->dependeesLifetimeListener);
1042}
void removeShapeChangeListener(ShapeChangeListener *listener)
Definition KoShape.cpp:1160

References d, and removeShapeChangeListener().

◆ removeShapeChangeListener()

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

Definition at line 1160 of file KoShape.cpp.

1161{
1162
1163 KIS_SAFE_ASSERT_RECOVER_RETURN(d->listeners.contains(listener));
1164 d->listeners.removeAll(listener);
1165 listener->unregisterShape(this);
1166}
void unregisterShape(KoShape *shape)
Definition KoShape.cpp:1135

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

◆ removeShapeManager()

void KoShape::removeShapeManager ( KoShapeManager * manager)
private

Definition at line 126 of file KoShape.cpp.

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

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 223 of file KoShape.cpp.

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

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 715 of file KoShape.cpp.

716{
717 // try to extract the rotation angle out of the local matrix
718 // if it is a pure rotation matrix
719
720 // check if the matrix has shearing mixed in
721 if (fabs(fabs(s->localMatrix.m12()) - fabs(s->localMatrix.m21())) > 1e-10)
722 return std::numeric_limits<qreal>::quiet_NaN();
723 // check if the matrix has scaling mixed in
724 if (fabs(s->localMatrix.m11() - s->localMatrix.m22()) > 1e-10)
725 return std::numeric_limits<qreal>::quiet_NaN();
726
727 // calculate the angle from the matrix elements
728 qreal angle = atan2(-s->localMatrix.m21(), s->localMatrix.m11()) * 180.0 / M_PI;
729 if (angle < 0.0)
730 angle += 360.0;
731
732 return angle;
733}
#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 210 of file KoShape.cpp.

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

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 583 of file KoShape.cpp.

584{
585 QPointF currentAbsPosition = absolutePosition(anchor);
586 QPointF translate = newPosition - currentAbsPosition;
587 QTransform translateMatrix;
588 translateMatrix.translate(translate.x(), translate.y());
589 applyAbsoluteTransformation(translateMatrix);
592}

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 1072 of file KoShape.cpp.

1073{
1074 s->additionalAttributes.insert(name, value);
1075}
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 1092 of file KoShape.cpp.

1093{
1094 s->additionalStyleAttributes.insert(name, value);
1095}

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 746 of file KoShape.cpp.

747{
748 s->inheritBackground = false;
749 s->fill = fill;
752}

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 933 of file KoShape.cpp.

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

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 921 of file KoShape.cpp.

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

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 847 of file KoShape.cpp.

848{
849 s->protectContent = protect;
850}

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 837 of file KoShape.cpp.

838{
839 s->geometryProtected = on;
840}

References s.

◆ setHyperLink()

void KoShape::setHyperLink ( const QString & hyperLink)

Set hyperlink for this shape.

Parameters
hyperLinkname.

Definition at line 1117 of file KoShape.cpp.

1118{
1119 s->hyperLink = hyperLink;
1120}
QString hyperLink() const
Definition KoShape.cpp:1112

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 768 of file KoShape.cpp.

769{
770
771 s->inheritBackground = value;
772 if (s->inheritBackground) {
773 s->fill.clear();
774 }
775}

References s, and value().

◆ setInheritPaintOrder()

void KoShape::setInheritPaintOrder ( bool value)

setInheritPaintOrder set inherit paint order.

Parameters
value

Definition at line 705 of file KoShape.cpp.

706{
707 s->inheritPaintOrder = value;
708}

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 908 of file KoShape.cpp.

909{
910 s->inheritStroke = value;
911 if (s->inheritStroke) {
912 s->stroke.clear();
913 }
914}

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 862 of file KoShape.cpp.

863{
864 s->keepAspect = keepAspect;
865
868}

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 955 of file KoShape.cpp.

956{
957 s->name = name;
958}

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 664 of file KoShape.cpp.

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

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 459 of file KoShape.cpp.

460{
461
462 if (d->parent == parent) {
463 return;
464 }
465
466 if (d->parent) {
467 d->parent->shapeInterface()->removeShape(this);
468 d->parent = 0;
469 }
470
471
473
474 if (parent && parent != this) {
475 d->parent = parent;
477 }
478
481}
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 268 of file KoShape.cpp.

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

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 814 of file KoShape.cpp.

815{
816 s->printable = on;
817}

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 1208 of file KoShape.cpp.

1209{
1210}

◆ 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 827 of file KoShape.cpp.

828{
829 s->selectable = selectable;
830}

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 880 of file KoShape.cpp.

881{
882 s->shapeId = id;
883}

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 249 of file KoShape.cpp.

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

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

◆ setSizeImpl()

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

Definition at line 263 of file KoShape.cpp.

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

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 899 of file KoShape.cpp.

900{
901
902 s->inheritStroke = false;
903 s->stroke = stroke;
906}

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 1107 of file KoShape.cpp.

1108{
1109 d->toolDelegates = delegates;
1110}

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 369 of file KoShape.cpp.

370{
371 if (s->localMatrix != matrix) {
372 s->localMatrix = matrix;
375 }
376}

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 637 of file KoShape.cpp.

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

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 620 of file KoShape.cpp.

621{
622 s->userData.reset(userData);
623}
KoShapeUserData * userData() const
Definition KoShape.cpp:625

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 790 of file KoShape.cpp.

791{
792 int _on = (on ? 1 : 0);
793 if (s->visible == _on) return;
794 s->visible = _on;
795}

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 782 of file KoShape.cpp.

783{
784 if (s->zIndex == zIndex)
785 return;
786 s->zIndex = zIndex;
788}

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 1054 of file KoShape.cpp.

1055{
1056 Q_UNUSED(type);
1057 Q_UNUSED(shape);
1058
1065}

◆ 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 105 of file KoShape.cpp.

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

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 875 of file KoShape.cpp.

876{
877 return s->shapeId;
878}

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 1001 of file KoShape.cpp.

1002{
1003 return absoluteTransformation().map(point);
1004}

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 1006 of file KoShape.cpp.

1007{
1008 return absoluteTransformation().mapRect(rect);
1009}

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 236 of file KoShape.cpp.

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

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 735 of file KoShape.cpp.

736{
737 return s->size;
738}

References s.

◆ snapData()

KoSnapData KoShape::snapData ( ) const
virtual

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

Definition at line 1067 of file KoShape.cpp.

1068{
1069 return KoSnapData();
1070}

◆ 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 885 of file KoShape.cpp.

886{
887
889
890 if (!s->inheritStroke) {
891 stroke = s->stroke;
892 } else if (parent()) {
893 stroke = parent()->stroke();
894 }
895
896 return stroke;
897}

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

◆ strokeInsets()

KoInsets KoShape::strokeInsets ( ) const

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

Definition at line 656 of file KoShape.cpp.

657{
658 KoInsets answer;
659 if (s->stroke)
660 s->stroke->strokeInsets(this, answer);
661 return answer;
662}

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 1102 of file KoShape.cpp.

1103{
1104 return d->toolDelegates;
1105}

References d.

◆ transform()

QTransform KoShape::transform ( ) const
protected

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

Definition at line 945 of file KoShape.cpp.

946{
947 return s->localMatrix;
948}

References s.

◆ transformation()

QTransform KoShape::transformation ( ) const

Returns the shapes local transformation matrix.

Definition at line 378 of file KoShape.cpp.

379{
380 return s->localMatrix;
381}

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 645 of file KoShape.cpp.

646{
647 if (!recursive || !parent()) {
648 return s->transparency;
649 } else {
650 const qreal parentOpacity = 1.0-parent()->transparency(recursive);
651 const qreal childOpacity = 1.0-s->transparency;
652 return 1.0-(parentOpacity*childOpacity);
653 }
654}

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 529 of file KoShape.cpp.

530{
531
532 if (!d->shapeManagers.empty()) {
533 const QRectF rect(boundingRect());
534 Q_FOREACH (KoShapeManager * manager, d->shapeManagers) {
535 manager->update(rect, this, true);
536 }
537 }
538}
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 540 of file KoShape.cpp.

541{
542 if (rect.isEmpty() && !rect.isNull()) {
543 return;
544 }
545
546
547 if (!d->shapeManagers.empty() && isVisible()) {
548 Q_FOREACH (KoShapeManager *manager, d->shapeManagers) {
549 manager->update(rect);
550 }
551 }
552}

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

◆ userData()

KoShapeUserData * KoShape::userData ( ) const

Return the current userData.

Definition at line 625 of file KoShape.cpp.

626{
627 return s->userData.data();
628}

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 960 of file KoShape.cpp.

961{
962 Q_UNUSED(asynchronous);
963}

◆ 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 524 of file KoShape.cpp.

525{
526 return s->zIndex;
527}

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: