KoShape Class Reference

Base class for all flake shapes. More...

#include <KoShape.h>

Inheritance diagram for KoShape:

KoPathShape KoSelection KoShapeContainer KoParameterShape KoShapeGroup KoShapeLayer List of all members.

Public Types

 PositionChanged
 used after a setPosition()
 RotationChanged
 used after a setRotation()
 ScaleChanged
 used after a setScale()
 ShearChanged
 used after a setShear()
 SizeChanged
 used after a setSize()
 GenericMatrixChange
 used after the matrix was changed without knowing which property explicitly changed
 ParentChanged
 used after a setParent()
 CollisionDetected
 used when another shape moved in our boundingrect
 Deleted
 the shape was deleted
 BorderChanged
 the shapes border has changed
 BackgroundChanged
 the shapes background has changed
 ShadowChanged
 the shapes shadow has changed
enum  ChangeType {
  PositionChanged, RotationChanged, ScaleChanged, ShearChanged,
  SizeChanged, GenericMatrixChange, ParentChanged, CollisionDetected,
  Deleted, BorderChanged, BackgroundChanged, ShadowChanged
}
 Used by shapeChanged() to select which change was made. More...

Public Member Functions

 KoShape ()
 Constructor.
virtual ~KoShape ()
 Destructor.
virtual void paint (QPainter &painter, const KoViewConverter &converter)=0
 Paint the shape The class extending this one is responsible for painting itself.
virtual void paintDecorations (QPainter &painter, const KoViewConverter &converter, const KoCanvasBase *canvas)
 Paint non-print decorations specific for this type of shape.
virtual bool loadOdf (const KoXmlElement &element, KoShapeLoadingContext &context)=0
 Load a shape from odf.
virtual void saveOdf (KoShapeSavingContext &context) const =0
 store the shape data as ODF XML.
void saveOdfFrameAttributes (KoShapeSavingContext &context) const
 When saving this shape to ODF, you may nest it in a 'draw:frame' and shape properties should be saved as attributes on that element instead of on the normal shape.
virtual void init (QMap< QString, KoDataCenter * > dataCenterMap)
 After the shape has been created this method is called so it can get access to any DataCenter it might want.
void setScale (double sx, double sy)
 Scale the shape using the zero-point which is the top-left corner.
void rotate (double angle)
 Rotate the shape (relative).
double rotation () const
 Return the current rotation in degrees.
void setShear (double sx, double sy)
 Shear the shape The shape will be sheared using the zero-point which is the top-left corner.
virtual void setSize (const QSizeF &size)
 Resize the shape.
virtual QSizeF size () const
 Get the size of the shape in pt.
virtual void setPosition (const QPointF &position)
 Set the position of the shape in pt.
virtual QPointF position () const
 Get the position of the shape in pt.
virtual bool hitTest (const QPointF &position) const
 Check if the shape is hit on position.
virtual QRectF boundingRect () const
 Get the bounding box of the shape.
void addConnectionPoint (const QPointF &point)
 Add a connector point to the shape A connector is a place on the shape that allows a graphical connection to be made using a line, for example.
QList< QPointF > connectionPoints () const
 Return a list of the connection points that have been added to this shape.
void setBackground (const QBrush &brush)
 Set the background of the shape.
QBrush background () const
 return the brush used to paint te background of this shape with.
virtual bool hasTransparency ()
 Returns true if there is some transparency, false if the shape is fully opaque.
int zIndex () const
 Retrieve the z-coordinate of this shape.
void setZIndex (int zIndex)
 Set the z-coordinate of this shape.
void setVisible (bool on)
 Changes the Shape to be visible or invisible.
bool isVisible () const
 Returns current visibility state of this shape.
void setPrintable (bool on)
 Changes the shape to be printable or not.
bool isPrintable () const
 Returns the current printable state of this shape.
void setSelectable (bool selectable)
 Makes it possible for the user to select this shape.
bool isSelectable () const
 Returns wheather this shape can be selected by the user.
void setLocked (bool locked)
 Changes the Shape to be locked in place.
bool isLocked () const
 Returns current locked state of this shape.
KoShapeContainerparent () const
 Returns the parent, or 0 if there is no parent.
void setParent (KoShapeContainer *parent)
 Set the parent of this shape.
virtual void update () const
 Request a repaint to be queued.
void update (const QRectF &shape) const
 Request a repaint to be queued.
virtual const QPainterPath outline () const
 returns the outline of the shape in the form of a path.
KoShapeBorderModelborder () const
 Returns the currently set border, or 0 if there is no border.
void setBorder (KoShapeBorderModel *border)
 Set a new border, removing the old one.
KoInsets borderInsets () const
 Return the insets of the border.
void setShadow (KoShapeShadow *shadow)
 Sets the new shadow, removing the old one.
KoShapeShadow * shadow () const
 Returns the currently set shadow or 0 if there is now shadow set.
void setKeepAspectRatio (bool keepAspect)
 Setting the shape to keep its aspect-ratio has the effect that user-scaling will keep the width/hight ratio intact so as not to distort shapes that rely on that ratio.
bool keepAspectRatio () const
 Setting the shape to keep its aspect-ratio has the effect that user-scaling will keep the width/hight ratio intact so as not to distort shapes that rely on that ratio.
QPointF absolutePosition (KoFlake::Position anchor=KoFlake::CenteredPosition) 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.
void setAbsolutePosition (QPointF newPosition, KoFlake::Position anchor=KoFlake::CenteredPosition)
 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.
void setUserData (KoShapeUserData *userData)
 Set a data object on the shape to be used by an application.
KoShapeUserDatauserData () const
 Return the current userData.
void setApplicationData (KoShapeApplicationData *applicationData)
 Set a data object on the shape to be used by an application.
KoShapeApplicationDataapplicationData () const
 Return the current applicationData.
const QString & shapeId () const
 Return the Id of this shape, identifying the type of shape by the id of the factory.
void setShapeId (const QString &id)
 Set the Id of this shape.
QMatrix absoluteTransformation (const KoViewConverter *converter) const
 Create a matrix that describes all the transformations done on this shape.
void applyAbsoluteTransformation (const QMatrix &matrix)
 Applies a transformation to this shape.
void setTransformation (const QMatrix &matrix)
 Sets a new transformation matrix describing the local transformations on this shape.
QMatrix transformation () const
 Returns the shapes local transformation matrix.
void applyTransformation (const QMatrix &matrix)
 Applies a transformation to this shape.
virtual void copySettings (const KoShape *shape)
 Copy all the settings from the parameter shape and apply them to this shape.
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.
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.
QString name () const
 Returns the name of the shape.
void setName (const QString &name)
 Sets the name of the shape.
void notifyChanged ()
 Update the position of the shape in the tree of the KoShapeManager.
virtual void waitUntilReady () const
 A shape can be in a state that its doing loading or text layout or similar in which case it can be shown on screen just fine (probably partially) but it should really not be printed until its fully done.
void deleteLater ()
 Schedule the shape for thread-safe deletion.
bool isEditable () const
 checks recursively if the shape or one of its parents is not visible or locked
void removeConnectionPoint (int index)
 Removes connection point with given index.
void addDependee (KoShape *shape)
 Adds a shape which depends on this shape.
void removeDependee (KoShape *shape)
 Removes as shape depending on this shape.
KoShapeclone (KoShapeControllerBase *base) const
 Creates a clone of this shape.
virtual KoSnapData snapData () const
 Returns additional snap data the shape wants to have snapping to.
void setAdditionalAttribute (const char *name, const QString &value)
 Set additional attribute.
void removeAdditionalAttribute (const char *name)
 Remove additional attribute.
bool hasAdditionalAttribute (const char *name)
 Check if additional attribute is set.
QString additionalAttribute (const char *name)
 Get additional attribute.

Static Public Member Functions

static bool compareShapeZIndex (KoShape *s1, KoShape *s2)
 This is a method used to sort a list using the STL sorting methods.
static void applyConversion (QPainter &painter, const KoViewConverter &converter)
 Convenience method that allows people implementing paint() to use the shape internal coordinate system directly to paint itself instead of considering the views zoom.

Protected Types

 OdfTransformation = 1
 Store transformation information.
 OdfSize = 2
 Store size information.
 OdfAdditionalAttributes = 4
 Store position of shape.
 OdfMandatories = 8
 Id, z-index, layer and style.
 OdfAllAttributes = OdfTransformation | OdfSize | OdfAdditionalAttributes | OdfMandatories
 A mask for all the attributes.
enum  OdfAttribute {
  OdfTransformation = 1, OdfSize = 2, OdfAdditionalAttributes = 4, OdfMandatories = 8,
  OdfAllAttributes = OdfTransformation | OdfSize | OdfAdditionalAttributes | OdfMandatories
}
 attributes from ODF 1.1 chapter 9.2.15 Common Drawing Shape Attributes More...

Protected Member Functions

bool loadOdfAttributes (const KoXmlElement &element, KoShapeLoadingContext &context, int attributes)
 This method is used during loading of the shape to load common attributes.
QMatrix parseOdfTransform (const QString &transform)
 Parses the transformation attribute from the given string.
void saveOdfAttributes (KoShapeSavingContext &context, int attributes) const
 This method can be used while saving the shape as ODF to add the data stored on this shape to the current element.
void saveOdfConnections (KoShapeSavingContext &context) const
 Add a new draw-glue-point element for each connections() present on this shape.
virtual QString saveStyle (KoGenStyle &style, KoShapeSavingContext &context) const
 Saves the style used for the shape.
virtual void loadStyle (const KoXmlElement &element, KoShapeLoadingContext &context)
 Loads the stroke and fill style from the given element.
QBrush loadOdfFill (const KoXmlElement &element, KoShapeLoadingContext &context)
 Loads the fill style.
KoShapeBorderModelloadOdfStroke (const KoXmlElement &element, KoShapeLoadingContext &context)
 Loads the stroke style.
KoShapeShadow * loadOdfShadow (const KoXmlElement &element, KoShapeLoadingContext &context)
 Loads the shadow style.
QString getStyleProperty (const char *property, const KoXmlElement &element, KoShapeLoadingContext &context)
 Fills the style stack and returns the value of the given style property (e.g fill, stroke).
virtual void shapeChanged (ChangeType type)
 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.
virtual void notifyShapeChanged (KoShape *shape, ChangeType type)
 This is called whenever a shape this shape depends on has changed.
void setCollisionDetection (bool detect)
 Set the property collision detection.
bool collisionDetection ()
 get the property collision detection.
const QMatrix & matrix () const
 return the current matrix that contains the rotation/scale/position of this shape
virtual KoShapecloneShape () const =0
 Deriving shapes have to implement that to support cloning.

Friends

class KoShapeManager
class Private

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.

flake_shape_coords.png

The Rotation center can be returned with absolutePosition()

Flake objects can be created in three ways:

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.


Member Enumeration Documentation

enum KoShape::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 setScale()
ShearChanged  used after a setShear()
SizeChanged  used after a setSize()
GenericMatrixChange  used after the matrix was changed without knowing which property explicitly changed
ParentChanged  used after a setParent()
CollisionDetected  used when another shape moved in our boundingrect
Deleted  the shape was deleted
BorderChanged  the shapes border has changed
BackgroundChanged  the shapes background has changed
ShadowChanged  the shapes shadow has changed

enum KoShape::OdfAttribute [protected]

attributes from ODF 1.1 chapter 9.2.15 Common Drawing Shape Attributes

Enumerator:
OdfTransformation  Store transformation information.
OdfSize  Store size information.
OdfAdditionalAttributes  Store position of shape.
OdfMandatories  Id, z-index, layer and style.
OdfAllAttributes  A mask for all the attributes.


Member Function Documentation

QPointF KoShape::absolutePosition ( KoFlake::Position  anchor = KoFlake::CenteredPosition  )  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:
anchor The place on the (unaltered) shape that you want the position of.
Returns:
the point that is the absolute, centered position of this shape.

QMatrix KoShape::absoluteTransformation ( const KoViewConverter converter  )  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.

Parameters:
converter if not null, this method uses the converter to mark the right offsets in the current view.

void KoShape::addConnectionPoint ( const QPointF &  point  ) 

Add a connector point to the shape A connector is a place on the shape that allows a graphical connection to be made using a line, for example.

Parameters:
point the position where to place the connector. The points coordinate system are based around the zero-pos which is the top-left of the shape The point does not have to be inside the boundings rectangle. The point is in pt, just like the rest of the KoShape class uses.

QString KoShape::additionalAttribute ( const char *  name  ) 

Get additional attribute.

Parameters:
name The 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.

void KoShape::applyAbsoluteTransformation ( const QMatrix &  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:
matrix the transformation matrix to apply

void KoShape::applyConversion ( QPainter &  painter,
const KoViewConverter converter 
) [static]

Convenience method that allows people implementing paint() to use the shape internal coordinate system directly to paint itself instead of considering the views zoom.

Parameters:
painter the painter to alter the zoom level of.
converter the converter for the current views zoom.

void KoShape::applyTransformation ( const QMatrix &  matrix  ) 

Applies a transformation to this shape.

The transformation given is relative to the shape coordinate system.

Parameters:
matrix the transformation matrix to apply

QBrush KoShape::background (  )  const

return the brush used to paint te 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

KoShapeBorderModel * KoShape::border (  )  const

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

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

KoInsets KoShape::borderInsets (  )  const

Return the insets of the border.

Convenience method for KoShapeBorderModel::borderInsets()

QRectF KoShape::boundingRect (  )  const [virtual]

Get the bounding box of the shape.

This includes the line width but not the shadow of the shape

Returns:
the bounding box of the shape

Reimplemented in KoPathShape, KoSelection, and KoShapeLayer.

KoShape* KoShape::clone ( KoShapeControllerBase base  )  const

Creates a clone of this shape.

Deriving shapes have to implement the proteced abstract clone function which does create the specific shape instance and copies the shapes data.

bool KoShape::collisionDetection (  )  [protected]

get the property collision detection.

Returns:
true if collision detection is on.

bool KoShape::compareShapeZIndex ( KoShape s1,
KoShape s2 
) [static]

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

Parameters:
s1 the first shape
s2 the second shape

QList< QPointF > KoShape::connectionPoints (  )  const

Return a list of the connection points that have been added to this shape.

Returns:
a list of the connectors that have been added to this shape.

void KoShape::copySettings ( const KoShape shape  )  [virtual]

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:
shape the shape to use as original

void KoShape::deleteLater (  ) 

Schedule the shape for thread-safe deletion.

After calling this method will self-delete in the main threads event loop. If deleting a shape can possibly be done in a separate thread, you should delete it using this method. If you delete a shape from another thread then its possible the main thread will use it after its been removed, while painting for example. Note that in contrary to the equivalent method on QObject, you can not call this more than ones!

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

Transform rect from document coordinates to shape coordinates.

Parameters:
rect in document coordinates
Returns:
rect in shape coordinates

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

Transforms point from document coordinates to shape coordinates.

Parameters:
point in document coordinates
Returns:
point in shape coordinates

bool KoShape::hasAdditionalAttribute ( const char *  name  ) 

Check if additional attribute is set.

Parameters:
name The 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

bool KoShape::hasTransparency (  )  [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.

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

Check if the shape is hit on position.

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

Reimplemented in KoSelection, KoShapeGroup, and KoShapeLayer.

virtual void KoShape::init ( QMap< QString, KoDataCenter * >  dataCenterMap  )  [inline, virtual]

After the shape has been created this method is called so it can get access to any DataCenter it might want.

The default implementation does nothing.

bool KoShape::isLocked (  )  const

Returns current locked state of this shape.

Being locked means the shape can no longer change shape or position.

Returns:
current locked state of this shape.

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.

bool KoShape::isSelectable (  )  const

Returns wheather this shape can be selected by the user.

Returns:
true only when the object is selectable.

bool KoShape::isVisible (  )  const

Returns current visibility state of this shape.

Being visible means being painted, as well as being used for things like guidelines or searches.

Returns:
current visibility state of this shape.

bool KoShape::keepAspectRatio (  )  const

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

Returns:
whether to keep aspect ratio of this shape

virtual bool KoShape::loadOdf ( const KoXmlElement element,
KoShapeLoadingContext context 
) [pure virtual]

Load a shape from odf.

Parameters:
context the KoShapeLoadingContext used for loading
element element which represents the shape in odf
Returns:
false if loading failed

Implemented in KoPAPageBase, KoPathShape, KoShapeGroup, and KoShapeLayer.

bool KoShape::loadOdfAttributes ( const KoXmlElement element,
KoShapeLoadingContext context,
int  attributes 
) [protected]

This method is used during loading of the shape to load common attributes.

Parameters:
context the KoShapeLoadingContext used for loading
element element which represents the shape in odf
attributes a number of OdfAttribute items to state which attributes to load.

void KoShape::loadStyle ( const KoXmlElement element,
KoShapeLoadingContext context 
) [protected, virtual]

Loads the stroke and fill style from the given element.

Parameters:
element the xml element to load the style from
context the loading context used for loading

QString KoShape::name (  )  const

Returns the name of the shape.

Returns:
the shapes name

const QPainterPath KoShape::outline (  )  const [virtual]

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

The outline returned will always have the position() of the shape as the origin, so moving the shape will not alter the result. The outline is used to draw the border on, for example.

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

Reimplemented in KoPathShape.

virtual void KoShape::paint ( QPainter &  painter,
const KoViewConverter converter 
) [pure virtual]

Paint the shape The class extending this one is responsible for painting itself.

Since we do not assume the shape is square the paint must also clear its background if it will draw something transparent on top. This can be done with a method like: painter.fillRect(converter.normalToView(QRectF(QPointF(0.0,0.0), size())), background()); Or equavalent for non-square objects. Do note that a shape's top-left is always at coordinate 0,0. Even if the shape itself is rotated or translated.

Parameters:
painter used for painting the shape
converter to convert between internal and view coordinates.
See also:
applyConversion()

Implemented in KoPathShape, KoSelection, and KoShapeContainer.

void KoShape::paintDecorations ( QPainter &  painter,
const KoViewConverter converter,
const KoCanvasBase canvas 
) [virtual]

Paint non-print decorations specific for this type of shape.

The default implementation is empty.

Parameters:
painter used for painting the shape
converter to convert between internal and view coordinates.
canvas the canvas that requested this paint. This can be used to retrieve canvas specific properties like selection and get a reference to the KoCanvasResourceProvider.

KoShapeContainer * KoShape::parent (  )  const

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

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

QMatrix KoShape::parseOdfTransform ( const QString &  transform  )  [protected]

Parses the transformation attribute from the given string.

Parameters:
transform the transform attribute string
Returns:
the resulting transformation matrix

QPointF KoShape::position (  )  const [virtual]

Get the position of the shape in pt.

Returns:
the position of the shape

void KoShape::removeAdditionalAttribute ( const char *  name  ) 

Remove additional attribute.

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

void KoShape::rotate ( double  angle  ) 

Rotate the shape (relative).

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

Parameters:
angle change the angle of rotation increasing it with 'angle' degrees

double KoShape::rotation (  )  const

Return the current rotation in degrees.

It returns NaN if the shape has a shearing or scaling transformation applied.

virtual void KoShape::saveOdf ( KoShapeSavingContext context  )  const [pure virtual]

store the shape data as ODF XML.

This is the method that will be called when saving a shape as a described in¬ OpenDocument 9.2 Drawing Shapes.

See also:
saveOdfAttributes

Implemented in KoPAMasterPage, KoPAPage, KoPAPageBase, KoPathShape, KoShapeGroup, and KoShapeLayer.

void KoShape::saveOdfAttributes ( KoShapeSavingContext context,
int  attributes 
) const [protected]

This method can be used while saving the shape as ODF to add the data stored on this shape to the current element.

Parameters:
context the context for the current save.
attributes a number of OdfAttribute items to state which attributes to save.
See also:
saveOdf

void KoShape::saveOdfFrameAttributes ( KoShapeSavingContext context  )  const

When saving this shape to ODF, you may nest it in a 'draw:frame' and shape properties should be saved as attributes on that element instead of on the normal shape.

After starting to write such an element you can call this method to write all relevant properties.

QString KoShape::saveStyle ( KoGenStyle style,
KoShapeSavingContext context 
) const [protected, virtual]

Saves the style used for the shape.

This method fills the given style object with the border and background properties and then adds the style to the context.

Parameters:
style the style object to fill
context used for saving
Returns:
the name of the style
See also:
saveOdf

void KoShape::setAbsolutePosition ( QPointF  newPosition,
KoFlake::Position  anchor = KoFlake::CenteredPosition 
)

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:
newPosition the new absolute center of the shape.
anchor The place on the (unaltered) shape that you set the position of.

void KoShape::setAdditionalAttribute ( const char *  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:
name The name of the attribute in the following form prefix:tag e.g. presentation:placeholder
value The value of the attribute

void KoShape::setApplicationData ( KoShapeApplicationData applicationData  ) 

Set a data object on the shape to be used by an application.

This is specifically useful when an application wants to have data that is per shape and should be deleted when the shape is destructed.

Parameters:
applicationData the new application data, or 0 to delete the current one.

void KoShape::setBackground ( const QBrush &  brush  ) 

Set the background of the shape.

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.

Parameters:
brush the brush for the background.

void KoShape::setBorder ( KoShapeBorderModel border  ) 

Set a new border, removing the old one.

Parameters:
border the new border, or 0 if there should be no border.