Krita Source Code Documentation
Loading...
Searching...
No Matches
KisShapeLayer Class Reference

#include <kis_shape_layer.h>

+ Inheritance diagram for KisShapeLayer:

Classes

struct  Private
 

Signals

void currentLayerChanged (const KoShapeLayer *layer)
 
void selectionChanged ()
 
void sigMoveShapes (const QPointF &diff)
 
- Signals inherited from KisNode
void sigNodeChangedInternal ()
 
- Signals inherited from KisBaseNode
void keyframeChannelAdded (KisKeyframeChannel *channel)
 
void opacityChanged (quint8 value)
 

Public Member Functions

bool accept (KisNodeVisitor &) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
bool allowAsChild (KisNodeSP) const override
 
bool antialiased () const
 
KisNodeSP clone () const override
 
KUndo2CommandconvertTo (const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) override
 
KisLayerSP createMergedLayerTemplate (KisLayerSP prevLayer) override
 
KUndo2Commandcrop (const QRect &rect) override
 
void fillMergedLayerTemplate (KisLayerSP dstLayer, KisLayerSP prevLayer, bool skipPaintingThisLayer) override
 
void forceUpdateHiddenAreaOnOriginal () override
 
void forceUpdateTimedNode () override
 
bool hasPendingTimedUpdates () const override
 
QIcon icon () const override
 
bool isSelectable () const
 
bool isShapeEditable (bool recursive) const override
 checks recursively if the shape or one of its parents is not visible or locked
 
 KisShapeLayer (const KisShapeLayer &_merge, const KisShapeLayer &_addShapes)
 
 KisShapeLayer (const KisShapeLayer &_rhs)
 
 KisShapeLayer (const KisShapeLayer &_rhs, KoShapeControllerBase *controller)
 
 KisShapeLayer (const KisShapeLayer &_rhs, KoShapeControllerBase *controller, std::function< KisShapeLayerCanvasBase *()> canvasFactory)
 
 KisShapeLayer (KoShapeControllerBase *shapeController, KisImageWSP image, const QString &name, quint8 opacity)
 
bool loadLayer (KoStore *store, QStringList *warnings=0)
 
KisPaintDeviceSP original () const override
 
KisPaintDeviceSP paintDevice () const override
 
void resetCache (const KoColorSpace *colorSpace) override
 
bool saveLayer (KoStore *store) const
 
KisBaseNode::PropertyList sectionModelProperties () const override
 
KoSelectedShapesProxyselectedShapesProxy ()
 selectedShapesProxy
 
void setAntialiased (const bool antialiased)
 
void setImage (KisImageWSP image) override
 
void setParent (KoShapeContainer *parent)
 
KUndo2CommandsetProfile (const KoColorProfile *profile) override
 
void setSectionModelProperties (const KisBaseNode::PropertyList &properties) override
 
void setUserLocked (bool value) override
 
void setVisible (bool visible, bool isLoading=false) override
 
void setX (qint32) override
 
void setY (qint32) override
 
KoShapeManagershapeManager () const
 
QRect theoreticalBoundingRect () const override
 
KUndo2Commandtransform (const QTransform &transform) override
 
bool visible (bool recursive=false) const override
 
qint32 x () const override
 
qint32 y () const override
 
 ~KisShapeLayer () override
 
- Public Member Functions inherited from KisExternalLayer
 KisExternalLayer (KisImageWSP image, const QString &name, quint8 opacity)
 
virtual bool supportsPerspectiveTransform () const
 
- Public Member Functions inherited from KisLayer
bool alphaChannelDisabled () const
 
void buildProjectionUpToNode (KisPaintDeviceSP projection, KisNodeSP lastNode, const QRect &rect)
 
QBitArray & channelFlags () const
 
KisFilterMaskSP colorOverlayMask () const
 
const KoColorSpacecolorSpace () const override
 returns the image's colorSpace or null, if there is no image
 
const KoCompositeOpcompositeOp () const override
 returns the layer's composite op for the colorspace of the layer's parent.
 
QImage createThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
QImage createThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
void disableAlphaChannel (bool disable)
 
QList< KisEffectMaskSPeffectMasks () const
 
QList< KisEffectMaskSPeffectMasks (KisNodeSP lastNode) const
 
QRect exactBounds () const override
 
QRect extent () const override
 
bool hasClones () const
 
bool hasEffectMasks () const
 
virtual KisLayerProjectionPlaneSP internalProjectionPlane () const
 
 KisLayer (const KisLayer &rhs)
 
 KisLayer (KisImageWSP image, const QString &name, quint8 opacity)
 
KisPSDLayerStyleSP layerStyle () const
 
QRect looseUserVisibleBounds () const
 
KisMetaData::StoremetaData ()
 
virtual bool needProjection () const
 
void notifyChildMaskChanged ()
 
KisLayerSP parentLayer () const
 
QRect partialChangeRect (KisNodeSP lastNode, const QRect &rect)
 
 Private (KisLayer *q)
 
KisPaintDeviceSP projection () const override
 
KisAbstractProjectionPlaneSP projectionPlane () const override
 
void registerClone (KisCloneLayerWSP clone)
 
const QList< KisCloneLayerWSPregisteredClones () const
 
virtual KisSelectionSP selection () const
 
virtual KisSelectionMaskSP selectionMask () const
 
virtual void setChannelFlags (const QBitArray &channelFlags)
 
void setLayerStyle (KisPSDLayerStyleSP layerStyle)
 
void setTemporary (bool t)
 
bool temporary () const
 
int thumbnailSeqNo () const override
 
QRect tightUserVisibleBounds () const
 
void unregisterClone (KisCloneLayerWSP clone)
 
void updateClones (const QRect &rect, bool dontInvalidateFrames)
 
 ~KisLayer () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisNode
KisNodeSP at (quint32 index) const
 
KisBusyProgressIndicatorbusyProgressIndicator () const
 
quint32 childCount () const
 
QList< KisNodeSPchildNodes (const QStringList &nodeTypes, const KoProperties &properties) const
 
const KisNodefindSymmetricClone (const KisNode *srcRoot, const KisNode *dstRoot, const KisNode *srcTarget)
 
KisNodeSP firstChild () const
 
virtual KisPaintDeviceList getLodCapableDevices () const
 
KisNodeGraphListenergraphListener () const
 
int graphSequenceNumber () const
 
void handleKeyframeChannelFrameAboutToBeRemoved (const KisKeyframeChannel *channel, int time)
 
virtual void handleKeyframeChannelFrameAdded (const KisKeyframeChannel *channel, int time)
 
virtual void handleKeyframeChannelFrameChange (const KisKeyframeChannel *channel, int time)
 
void handleKeyframeChannelFrameHasBeenRemoved (const KisKeyframeChannel *channel, int time)
 
KisFrameChangeUpdateRecipe handleKeyframeChannelUpdateImpl (const KisKeyframeChannel *channel, int time)
 
int index (const KisNodeSP node) const
 
void invalidateFrames (const KisTimeSpan &range, const QRect &rect)
 
 KisNode (const KisNode &rhs)
 
 KisNode (KisImageWSP image)
 
KisNodeSP lastChild () const
 
KisNodeSP nextSibling () const
 
KisNodeProgressProxynodeProgressProxy () const
 
KisNodeSP parent () const
 
KisNodeSP prevSibling () const
 
 Private (KisNode *node)
 
void processDuplicatedClones (const KisNode *srcDuplicationRoot, const KisNode *dstDuplicationRoot, KisNode *node)
 
virtual KisProjectionLeafSP projectionLeaf () const
 
void requestTimeSwitch (int time)
 
virtual void setDirty ()
 
void setDirty (const KisRegion &region)
 
void setDirty (const QRect &rect)
 
virtual void setDirty (const QVector< QRect > &rects)
 
void setDirtyDontResetAnimationCache ()
 
void setDirtyDontResetAnimationCache (const QRect &rect)
 
void setDirtyDontResetAnimationCache (const QVector< QRect > &rects)
 setDirtyDontResetAnimationCache does almost the same thing as usual setDirty() call, but doesn't reset the animation cache (since onion skins are not used when rendering animation.
 
void setGraphListener (KisNodeGraphListener *graphListener)
 
virtual void syncLodCache ()
 
 ~KisNode () override
 
- Public Member Functions inherited from KisBaseNode
bool belongsToIsolatedGroup () const
 
bool check (const KoProperties &properties) const
 
bool collapsed () const
 
int colorLabelIndex () const
 
virtual KisPaintDeviceSP colorSampleSourceDevice () const
 
const QString & compositeOpId () const
 
void enableAnimation ()
 
KisKeyframeChannelgetKeyframeChannel (const QString &id) const
 
KisKeyframeChannelgetKeyframeChannel (const QString &id, bool create)
 
bool hasEditablePaintDevice () const
 
KisImageWSP image () const
 
bool isAnimated () const
 
bool isEditable (bool checkVisibility=true) const
 
virtual bool isFakeNode () const
 
bool isIsolatedRoot () const
 
bool isPinnedToTimeline () const
 
QMap< QString, KisKeyframeChannel * > keyframeChannels () const
 
 KisBaseNode (const KisBaseNode &rhs)
 
 KisBaseNode (KisImageWSP image)
 
void mergeNodeProperties (const KoProperties &properties)
 
QString name () const
 
const KoPropertiesnodeProperties () const
 
quint8 opacity () const
 
quint8 percentOpacity () const
 
 Private (const Private &rhs)
 
 Private (KisImageWSP p_image)
 
void setCollapsed (bool collapsed)
 
void setColorLabelIndex (int index)
 
void setCompositeOpId (const QString &compositeOpId)
 
void setName (const QString &name)
 
void setNodeProperty (const QString &name, const QVariant &value)
 
void setOpacity (quint8 val)
 
void setPercentOpacity (quint8 val)
 
void setPinnedToTimeline (bool pinned)
 
void setUuid (const QUuid &id)
 
virtual bool supportsKeyframeChannel (const QString &id)
 
bool supportsLodMoves () const
 
virtual bool supportsLodPainting () const
 
virtual void updateSettings ()
 
bool userLocked () const
 
QUuid uuid () const
 
 ~KisBaseNode () override
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 
- Public Member Functions inherited from KoShapeLayer
QRectF boundingRect () const override
 Get the bounding box of the shape.
 
bool hitTest (const QPointF &position) const override
 Check if the shape is hit on position.
 
 KoShapeLayer ()
 The default constructor.
 
 KoShapeLayer (KoShapeContainerModel *model)
 
void paintComponent (QPainter &painter) const override
 
- Public Member Functions inherited from KoShapeContainer
void addShape (KoShape *shape)
 
bool inheritsTransform (const KoShape *shape) const
 
bool isClipped (const KoShape *child) const
 
 KoShapeContainer (KoShapeContainerModel *model=0)
 
KoShapeContainerModelmodel () const
 
void paint (QPainter &painter) const override
 reimplemented
 
 Private (const Private &rhs, KoShapeContainer *q)
 
 Private (KoShapeContainer *q)
 
void removeShape (KoShape *shape)
 
void setClipped (const KoShape *child, bool clipping)
 
void setInheritsTransform (const KoShape *shape, bool inherit)
 
int shapeCount () const
 
ShapeInterfaceshapeInterface ()
 
QList< KoShape * > shapes () const
 
virtual void update () const
 
void update () const override
 reimplemented
 
 ~KoShapeContainer () override
 
virtual ~Private ()
 
- Public Member Functions inherited from KoShape
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 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
 
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
 
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 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 updateAbsolute (const QRectF &rect) const
 
KoShapeUserDatauserData () const
 
virtual void waitUntilReady (bool asynchronous=true) const
 
qint16 zIndex () const
 
virtual ~KoShape ()
 Destructor.
 
- Public Member Functions inherited from KisDelayedUpdateNodeInterface
virtual ~KisDelayedUpdateNodeInterface ()
 
- Public Member Functions inherited from KisCroppedOriginalLayerInterface
virtual ~KisCroppedOriginalLayerInterface ()
 

Static Public Member Functions

static QList< KoShape * > createShapesFromSvg (QIODevice *device, const QString &baseXmlDir, const QRectF &rectInPixels, qreal resolutionPPI, KoDocumentResourceManager *resourceManager, bool loadingFromKra, QSizeF *fragmentSize, QStringList *warnings=0, QStringList *errors=0)
 
static bool saveShapesToStore (KoStore *store, QList< KoShape * > shapes, const QSizeF &sizeInPt)
 
- Static Public Member Functions inherited from KoShape
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)
 

Protected Member Functions

KisShapeLayerCanvasBasecanvas () const
 
const KoViewConverterconverter () const
 
bool isVisible (bool recursive=true) const
 
 KisShapeLayer (KoShapeControllerBase *shapeController, KisImageWSP image, const QString &name, quint8 opacity, std::function< KisShapeLayerCanvasBase *()> canvasFactory)
 
bool loadSvg (QIODevice *device, const QString &baseXmlDir, QStringList *warnings=0)
 
KoShapeControllerBaseshapeController () const
 
- Protected Member Functions inherited from KisLayer
virtual QRect amortizedProjectionRectForCleanupInChangePass () const
 
QRect applyMasks (const KisPaintDeviceSP source, KisPaintDeviceSP destination, const QRect &requestedRect, KisNodeSP filthyNode, KisNodeSP lastNode, KisRenderPassFlags flags) const
 
bool canMergeAndKeepBlendOptions (KisLayerSP otherLayer)
 
QRect changeRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
void childNodeChanged (KisNodeSP changedChildNode) override
 
virtual void copyOriginalToProjection (const KisPaintDeviceSP original, KisPaintDeviceSP projection, const QRect &rect) const
 
virtual QRect incomingChangeRect (const QRect &rect) const
 
QRect masksChangeRect (const QList< KisEffectMaskSP > &masks, const QRect &requestedRect, bool &rectVariesFlag) const
 
QRect masksNeedRect (const QList< KisEffectMaskSP > &masks, const QRect &changeRect, QStack< QRect > &applyRects, bool &rectVariesFlag) const
 
QRect needRectForOriginal (const QRect &rect) const
 
virtual QRect outgoingChangeRect (const QRect &rect) const
 
QList< KisEffectMaskSPsearchEffectMasks (KisNodeSP lastNode) const
 
QRect updateProjection (const QRect &rect, KisNodeSP filthyNode, KisRenderPassFlags flags)
 
- Protected Member Functions inherited from KisNode
virtual QRect accessRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const
 
void addKeyframeChannel (KisKeyframeChannel *channel) override
 
void baseNodeChangedCallback () override
 
void baseNodeCollapsedChangedCallback () override
 
void baseNodeInvalidateAllFramesCallback () override
 
virtual KisFrameChangeUpdateRecipe handleKeyframeChannelFrameAboutToBeRemovedImpl (const KisKeyframeChannel *channel, int time)
 
virtual QRect needRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const
 
void notifyParentVisibilityChanged (bool value) override
 
KisBaseNodeSP parentCallback () const override
 
- Protected Member Functions inherited from KisBaseNode
virtual KisKeyframeChannelrequestKeyframeChannel (const QString &id)
 
void setSupportsLodMoves (bool value)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 
- Protected Member Functions inherited from KoShapeContainer
 KoShapeContainer (const KoShapeContainer &rhs)
 
void setModel (KoShapeContainerModel *model)
 
void setModelInit (KoShapeContainerModel *model)
 
void shapeChanged (ChangeType type, KoShape *shape=0) override
 
virtual void shapeCountChanged ()
 
- Protected Member Functions inherited from KoShape
 KoShape (const KoShape &rhs)
 
QList< ShapeChangeListener * > listeners () const
 
void setSizeImpl (const QSizeF &size) const
 
void shapeChangedPriv (KoShape::ChangeType type)
 
QTransform transform () const
 return the current matrix that contains the rotation/scale/position of this shape
 

Private Slots

void slotImageResolutionChanged ()
 
void slotMoveShapes (const QPointF &diff)
 
void slotTransformShapes (const QTransform &transform)
 

Private Member Functions

void initShapeLayerImpl (KoShapeControllerBase *controller, KisShapeLayerCanvasBase *overrideCanvas)
 
QList< KoShape * > shapesToBeTransformed ()
 

Private Attributes

Private *const m_d
 

Friends

class ShapeLayerContainerModel
 
class TransformShapeLayerDeferred
 

Additional Inherited Members

- Public Types inherited from KisNode
enum  PositionToFilthy { N_ABOVE_FILTHY = 0x08 , N_FILTHY_PROJECTION = 0x20 , N_FILTHY = 0x40 , N_BELOW_FILTHY = 0x80 }
 
- Public Types inherited from KisBaseNode
typedef QList< PropertyPropertyList
 
- Public Types inherited from KoShape
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 Attributes inherited from KisLayer
QBitArray channelFlags
 
KisCloneLayersList clonesList
 
KisPSDLayerStyleSP layerStyle
 
KisLayerStyleProjectionPlaneSP layerStyleProjectionPlane
 
KisLayerMasksCache masksCache
 
KisMetaData::StoremetaDataStore {nullptr}
 
KisLayerProjectionPlaneSP projectionPlane
 
KisSafeNodeProjectionStoreSP safeProjection
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisNode
KisBusyProgressIndicatorbusyProgressIndicator
 
std::optional< KisFrameChangeUpdateRecipeframeRemovalUpdateRecipe
 
KisNodeGraphListenergraphListener
 
KisNodeProgressProxynodeProgressProxy
 
KisSafeReadNodeList nodes
 
QReadWriteLock nodeSubgraphLock
 
KisNodeWSP parent
 
KisProjectionLeafSP projectionLeaf
 
- Public Attributes inherited from KisBaseNode
bool animated {false}
 
bool collapsed {false}
 
QString compositeOp
 
KisBaseNode::Property hack_visible
 
QUuid id
 
KisImageWSP image
 
QMap< QString, KisKeyframeChannel * > keyframeChannels
 
KisAnimatedOpacityProperty opacityProperty
 
bool pinnedToTimeline {false}
 
KoProperties properties
 
bool supportsLodMoves {false}
 
- Public Attributes inherited from KoShapeContainer
KoShapeContainerModelmodel
 
KoShapeContainer::ShapeInterface shapeInterface
 
- Static Public Attributes inherited from KoShape
static const qint16 maxZIndex = std::numeric_limits<qint16>::max()
 
static const qint16 minZIndex = std::numeric_limits<qint16>::min()
 

Detailed Description

A KisShapeLayer contains any number of non-krita flakes, such as path shapes, text shapes and anything else people come up with.

The KisShapeLayer has a shapemanager and a canvas of its own. The canvas paints onto the projection, and the projection is what we render in Krita. This means that no matter how many views you have, you cannot have a different view on your shapes per view.

XXX: what about removing shapes?

Definition at line 43 of file kis_shape_layer.h.

Constructor & Destructor Documentation

◆ KisShapeLayer() [1/6]

KisShapeLayer::KisShapeLayer ( KoShapeControllerBase * shapeController,
KisImageWSP image,
const QString & name,
quint8 opacity )

Definition at line 143 of file kis_shape_layer.cc.

147 : KisShapeLayer(controller, image, name, opacity,
148 [&] () { return new KisShapeLayerCanvas(image->colorSpace(), new KisDefaultBounds(image), this);})
149{
150}
const KoColorSpace * colorSpace() const
KisShapeLayer(KoShapeControllerBase *shapeController, KisImageWSP image, const QString &name, quint8 opacity)
QString name() const
Definition KoShape.cpp:955
KisImageWSP image
quint8 opacity() const

References KisImage::colorSpace(), and KisBaseNode::image.

◆ KisShapeLayer() [2/6]

KisShapeLayer::KisShapeLayer ( const KisShapeLayer & _rhs)

Definition at line 152 of file kis_shape_layer.cc.

153 : KisShapeLayer(rhs,
154 rhs.m_d->controller)
155{
156}

◆ KisShapeLayer() [3/6]

KisShapeLayer::KisShapeLayer ( const KisShapeLayer & _rhs,
KoShapeControllerBase * controller )

Definition at line 158 of file kis_shape_layer.cc.

159 : KisShapeLayer(rhs,
160 controller,
161 [&] () {
162 const KisShapeLayerCanvas* shapeLayerCanvas = dynamic_cast<const KisShapeLayerCanvas*>(rhs.m_d->canvas);
163 KIS_ASSERT(shapeLayerCanvas);
164 return new KisShapeLayerCanvas(*shapeLayerCanvas, this);})
165{
166}
#define KIS_ASSERT(cond)
Definition kis_assert.h:33

References KisShapeLayer::Private::canvas, KIS_ASSERT, and m_d.

◆ KisShapeLayer() [4/6]

KisShapeLayer::KisShapeLayer ( const KisShapeLayer & _rhs,
KoShapeControllerBase * controller,
std::function< KisShapeLayerCanvasBase *()> canvasFactory )

The transformations of the added shapes are automatically merged into the transformation of the layer, so we should apply this extra transform separately

Definition at line 168 of file kis_shape_layer.cc.

170 : KisExternalLayer(_rhs)
171 , KoShapeLayer(new ShapeLayerContainerModel(this)) //no _rhs here otherwise both layer have the same KoShapeContainerModel
172 , m_d(new Private())
173{
174 initShapeLayerImpl(controller, canvasFactory());
176
181 const QTransform thisInvertedTransform = this->absoluteTransformation().inverted();
182
184
185 Q_FOREACH (KoShape *shape, _rhs.shapes()) {
186 KoShape *clonedShape = shape->cloneShape();
187 KIS_SAFE_ASSERT_RECOVER(clonedShape) { continue; }
188 clonedShape->setTransformation(shape->absoluteTransformation() * thisInvertedTransform);
189 addShape(clonedShape);
190 }
191
193}
KisExternalLayer(KisImageWSP image, const QString &name, quint8 opacity)
KoShapeManager * shapeManager() const override
Private *const m_d
void initShapeLayerImpl(KoShapeControllerBase *controller, KisShapeLayerCanvasBase *overrideCanvas)
friend class ShapeLayerContainerModel
QList< KoShape * > shapes() const
void addShape(KoShape *shape)
KoShapeLayer()
The default constructor.
void setUpdatesBlocked(bool value)
QTransform absoluteTransformation() const
Definition KoShape.cpp:335
void setTransformation(const QTransform &matrix)
Definition KoShape.cpp:374
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
Definition KoShape.cpp:172
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
KisShapeLayerCanvasBase * canvas

References KoShape::absoluteTransformation(), KoShapeContainer::addShape(), KisShapeLayer::Private::canvas, KoShape::cloneShape(), initShapeLayerImpl(), KisShapeLayer::Private::isAntialiased, KIS_SAFE_ASSERT_RECOVER, m_d, KoShape::setTransformation(), KoShapeManager::setUpdatesBlocked(), KisShapeLayerCanvasBase::shapeManager(), and KoShapeContainer::shapes().

◆ KisShapeLayer() [5/6]

KisShapeLayer::KisShapeLayer ( const KisShapeLayer & _merge,
const KisShapeLayer & _addShapes )

Merge constructor.

Creates a new layer as a merge of two existing layers.

This is used by createMergedLayer()

With current implementation this matrix will always be an identity, because we do not copy the transformation from any of the source layers. But we should handle this anyway, to not be caught by this in the future.

Definition at line 195 of file kis_shape_layer.cc.

196 : KisExternalLayer(_rhs)
197 , KoShapeLayer(new ShapeLayerContainerModel(this)) //no _merge here otherwise both layer have the same KoShapeContainerModel
198 , m_d(new Private())
199{
200 // Make sure our new layer is visible otherwise the shapes cannot be painted.
201 setVisible(true);
202
203 m_d->isAntialiased = _rhs.m_d->isAntialiased;
204
205 const KisShapeLayerCanvas* shapeLayerCanvas = dynamic_cast<const KisShapeLayerCanvas*>(_rhs.canvas());
206 KIS_ASSERT(shapeLayerCanvas);
207 initShapeLayerImpl(_rhs.m_d->controller, new KisShapeLayerCanvas(*shapeLayerCanvas, this));
208
214 const QTransform thisInvertedTransform = this->absoluteTransformation().inverted();
215
216 QList<KoShape *> shapesAbove;
217 QList<KoShape *> shapesBelow;
218
219 // copy in _rhs's shapes
220 Q_FOREACH (KoShape *shape, _rhs.shapes()) {
221 KoShape *clonedShape = shape->cloneShape();
222 KIS_SAFE_ASSERT_RECOVER(clonedShape) { continue; }
223 clonedShape->setTransformation(shape->absoluteTransformation() * thisInvertedTransform);
224 shapesBelow.append(clonedShape);
225 }
226
227 // copy in _addShapes's shapes
228 Q_FOREACH (KoShape *shape, _addShapes.shapes()) {
229 KoShape *clonedShape = shape->cloneShape();
230 KIS_SAFE_ASSERT_RECOVER(clonedShape) { continue; }
231 clonedShape->setTransformation(shape->absoluteTransformation() * thisInvertedTransform);
232 shapesAbove.append(clonedShape);
233 }
234
236 KoShapeReorderCommand::mergeDownShapes(shapesBelow, shapesAbove);
238 cmd.redo();
239
240 Q_FOREACH (KoShape *shape, shapesBelow + shapesAbove) {
241 addShape(shape);
242 }
243}
void setVisible(bool visible, bool isLoading=false) override
This command allows you to change the zIndex of a number of shapes.
static QList< IndexedShape > mergeDownShapes(QList< KoShape * > shapesBelow, QList< KoShape * > shapesAbove)

References KoShape::absoluteTransformation(), KoShapeContainer::addShape(), canvas(), KoShape::cloneShape(), KisShapeLayer::Private::controller, initShapeLayerImpl(), KisShapeLayer::Private::isAntialiased, KIS_ASSERT, KIS_SAFE_ASSERT_RECOVER, m_d, KoShapeReorderCommand::mergeDownShapes(), KoShapeReorderCommand::redo(), KoShape::setTransformation(), setVisible(), and KoShapeContainer::shapes().

◆ ~KisShapeLayer()

KisShapeLayer::~KisShapeLayer ( )
override

Small hack alert: we should avoid updates on shape deletion

Definition at line 257 of file kis_shape_layer.cc.

258{
263
264 Q_FOREACH (KoShape *shape, shapes()) {
265 shape->setParent(0);
266 delete shape;
267 }
268
269 delete m_d->canvas;
270 delete m_d;
271}
void setParent(KoShapeContainer *parent)
Definition KoShape.cpp:464

References KisShapeLayer::Private::canvas, m_d, KisShapeLayerCanvasBase::prepareForDestroying(), KoShape::setParent(), and KoShapeContainer::shapes().

◆ KisShapeLayer() [6/6]

KisShapeLayer::KisShapeLayer ( KoShapeControllerBase * shapeController,
KisImageWSP image,
const QString & name,
quint8 opacity,
std::function< KisShapeLayerCanvasBase *()> canvasFactory )
protected

Definition at line 245 of file kis_shape_layer.cc.

252 , m_d(new Private())
253{
254 initShapeLayerImpl(controller, canvasFactory());
255}

References initShapeLayerImpl().

Member Function Documentation

◆ accept() [1/2]

bool KisShapeLayer::accept ( KisNodeVisitor & )
overridevirtual

Accept the KisNodeVisitor (for the Visitor design pattern), should call the correct function on the KisNodeVisitor for this node type, so you need to override it for all leaf classes in the node inheritance hierarchy.

return false if the visitor could not successfully act on this node instance.

Reimplemented from KisNode.

Definition at line 469 of file kis_shape_layer.cc.

470{
471 return visitor.visit(this);
472}

References KisNodeVisitor::visit().

◆ accept() [2/2]

void KisShapeLayer::accept ( KisProcessingVisitor & visitor,
KisUndoAdapter * undoAdapter )
overridevirtual

Accept the KisNodeVisitor (for the Visitor design pattern), should call the correct function on the KisProcessingVisitor for this node type, so you need to override it for all leaf classes in the node inheritance hierarchy.

The processing visitor differs from node visitor in the way that it accepts undo adapter, that allows the processing to be multithreaded

Reimplemented from KisNode.

Definition at line 474 of file kis_shape_layer.cc.

475{
476 return visitor.visit(this, undoAdapter);
477}
virtual void visit(KisNode *node, KisUndoAdapter *undoAdapter)=0

References KisProcessingVisitor::visit().

◆ allowAsChild()

bool KisShapeLayer::allowAsChild ( KisNodeSP ) const
overridevirtual

Re-implement this method to add constraints for the subclasses that can be added as children to this node

Returns
false if the given node is not allowed as a child to this node

Implements KisNode.

Definition at line 305 of file kis_shape_layer.cc.

306{
307 return node->inherits("KisMask");
308}

◆ antialiased()

bool KisShapeLayer::antialiased ( ) const

Definition at line 774 of file kis_shape_layer.cc.

775{
776 return m_d->isAntialiased;
777}

References KisShapeLayer::Private::isAntialiased, and m_d.

◆ canvas()

KisShapeLayerCanvasBase * KisShapeLayer::canvas ( ) const
protected

Definition at line 759 of file kis_shape_layer.cc.

760{
761 return m_d->canvas;
762}

References KisShapeLayer::Private::canvas, and m_d.

◆ clone()

KisNodeSP KisShapeLayer::clone ( ) const
inlineoverridevirtual

Implements KisNode.

Definition at line 75 of file kis_shape_layer.h.

75 {
76 return new KisShapeLayer(*this);
77 }

◆ converter()

const KoViewConverter * KisShapeLayer::converter ( ) const
protected

Definition at line 484 of file kis_shape_layer.cc.

485{
486 return m_d->canvas->viewConverter();
487}
const KoViewConverter * viewConverter() const override

References KisShapeLayer::Private::canvas, m_d, and KisShapeLayerCanvasBase::viewConverter().

◆ convertTo()

KUndo2Command * KisShapeLayer::convertTo ( const KoColorSpace * dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags() )
overridevirtual

Reimplemented from KisExternalLayer.

Definition at line 743 of file kis_shape_layer.cc.

744{
745 using namespace KisDoSomethingCommandOps;
746
747 KUndo2Command *cmd = new KUndo2Command();
749 m_d->paintDevice->convertTo(dstColorSpace, renderingIntent, conversionFlags, cmd);
751 return cmd;
752}
void convertTo(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags(), KUndo2Command *parentCommand=nullptr, KoUpdater *progressUpdater=nullptr)
KisPaintDeviceSP paintDevice

References KisPaintDevice::convertTo(), m_d, and KisShapeLayer::Private::paintDevice.

◆ createMergedLayerTemplate()

KisLayerSP KisShapeLayer::createMergedLayerTemplate ( KisLayerSP prevLayer)
overridevirtual

Create and return a layer that is the result of merging this with layer.

This method is designed to be called only within KisImage::mergeLayerDown().

Descendants override this to create specific merged types when possible. The KisLayer one creates a KisPaintLayerSP via a bitBlt, and can work on all layer types.

Descendants that perform their own version do NOT call KisLayer::createMergedLayer

Reimplemented from KisLayer.

Definition at line 345 of file kis_shape_layer.cc.

346{
347 KisShapeLayer *prevShape = dynamic_cast<KisShapeLayer*>(prevLayer.data());
348
349 if (prevShape)
350 return new KisShapeLayer(*prevShape, *this);
351 else
353}
virtual KisLayerSP createMergedLayerTemplate(KisLayerSP prevLayer)
Definition kis_layer.cc:401

References KisLayer::createMergedLayerTemplate(), KisSharedPtr< T >::data(), and KisShapeLayer().

◆ createShapesFromSvg()

QList< KoShape * > KisShapeLayer::createShapesFromSvg ( QIODevice * device,
const QString & baseXmlDir,
const QRectF & rectInPixels,
qreal resolutionPPI,
KoDocumentResourceManager * resourceManager,
bool loadingFromKra,
QSizeF * fragmentSize,
QStringList * warnings = 0,
QStringList * errors = 0 )
static

We set default text version to 1, it will make all the files not having an explicit krita:textVersion tag load as "legacy" files with the bug.

The tag is not needed when loading from pure SVG, because most probably they were not saved by a buggy Krita version.

Definition at line 563 of file kis_shape_layer.cc.

564{
565
566 QString errorMsg;
567 int errorLine = 0;
568 int errorColumn;
569
570 QDomDocument doc = SvgParser::createDocumentFromSvg(device, &errorMsg, &errorLine, &errorColumn);
571 if (doc.isNull()) {
572 errKrita << "Parsing error in contents.svg! Aborting!" << Qt::endl
573 << " In line: " << errorLine << ", column: " << errorColumn << Qt::endl
574 << " Error message: " << errorMsg << Qt::endl;
575
576 if (errors) {
577 *errors << i18n("Parsing error in the main document at line %1, column %2\nError message: %3"
578 , errorLine , errorColumn , errorMsg);
579 }
580 return QList<KoShape*>();
581 }
582
583 SvgParser parser(resourceManager);
584 parser.setXmlBaseDir(baseXmlDir);
585 parser.setResolution(rectInPixels /* px */, resolutionPPI /* ppi */);
586
587 if (loadingFromKra) {
596 parser.setDefaultKraTextVersion(1);
597 }
598
599 QList<KoShape *> result = parser.parseSvg(doc.documentElement(), fragmentSize);
600
601 if (warnings) {
602 *warnings = parser.warnings();
603 }
604
605 return result;
606}
static QDomDocument createDocumentFromSvg(QIODevice *device, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0)
#define errKrita
Definition kis_debug.h:107

References SvgParser::createDocumentFromSvg(), errKrita, SvgParser::parseSvg(), SvgParser::setDefaultKraTextVersion(), SvgParser::setResolution(), SvgParser::setXmlBaseDir(), and SvgParser::warnings().

◆ crop()

KUndo2Command * KisShapeLayer::crop ( const QRect & rect)
overridevirtual

Reimplemented from KisExternalLayer.

Definition at line 670 of file kis_shape_layer.cc.

671{
672 QPoint oldPos(x(), y());
673 QPoint newPos = oldPos - rect.topLeft();
674
675 return new KisNodeMoveCommand2(this, oldPos, newPos);
676}
qint32 y() const override
qint32 x() const override

References x(), and y().

◆ currentLayerChanged

void KisShapeLayer::currentLayerChanged ( const KoShapeLayer * layer)
signal

◆ fillMergedLayerTemplate()

void KisShapeLayer::fillMergedLayerTemplate ( KisLayerSP dstLayer,
KisLayerSP prevLayer,
bool skipPaintingThisLayer )
overridevirtual

Reimplemented from KisLayer.

Definition at line 355 of file kis_shape_layer.cc.

356{
357 if (!dynamic_cast<KisShapeLayer*>(dstLayer.data())) {
358 KisLayer::fillMergedLayerTemplate(dstLayer, prevLayer, skipPaintingThisLayer);
359 }
360}
virtual void fillMergedLayerTemplate(KisLayerSP dstLayer, KisLayerSP prevLayer, bool skipPaintingThisLayer=false)
Definition kis_layer.cc:416

References KisSharedPtr< T >::data(), and KisLayer::fillMergedLayerTemplate().

◆ forceUpdateHiddenAreaOnOriginal()

void KisShapeLayer::forceUpdateHiddenAreaOnOriginal ( )
overridevirtual

Force regeneration of the hidden part of original() device (the one outside image bounds). After regeneration is completed, the layer will Q_EMIT dirty signals itself, so no manual forced update is needed.

Implements KisCroppedOriginalLayerInterface.

Definition at line 532 of file kis_shape_layer.cc.

533{
535}
virtual void forceRepaintWithHiddenAreas()

References KisShapeLayer::Private::canvas, KisShapeLayerCanvasBase::forceRepaintWithHiddenAreas(), and m_d.

◆ forceUpdateTimedNode()

void KisShapeLayer::forceUpdateTimedNode ( )
overridevirtual

Forces a repaint of a shape layer without waiting for an event loop calling a delayed timer update. If you want to see the result of the shape layer right here and right now, you should do:

shapeLayer->setDirty(); shapeLayer->image()->waitForDone(); shapeLayer->forceUpdateTimedNode(); shapeLayer->image()->waitForDone();

Implements KisDelayedUpdateNodeInterface.

Definition at line 522 of file kis_shape_layer.cc.

523{
525}
virtual void forceRepaint()=0

References KisShapeLayer::Private::canvas, KisShapeLayerCanvasBase::forceRepaint(), and m_d.

◆ hasPendingTimedUpdates()

bool KisShapeLayer::hasPendingTimedUpdates ( ) const
overridevirtual
Returns
true if there are any pending updates in the delayed queue

Implements KisDelayedUpdateNodeInterface.

Definition at line 527 of file kis_shape_layer.cc.

528{
529 return m_d->canvas->hasPendingUpdates();
530}
virtual bool hasPendingUpdates() const =0

References KisShapeLayer::Private::canvas, KisShapeLayerCanvasBase::hasPendingUpdates(), and m_d.

◆ icon()

QIcon KisShapeLayer::icon ( ) const
overridevirtual
Returns
the icon used to represent the node type, for instance in the layerbox and in the menu.

Reimplemented from KisExternalLayer.

Definition at line 368 of file kis_shape_layer.cc.

369{
370 return KisIconUtils::loadIcon("vectorLayer");
371}
QIcon loadIcon(const QString &name)

References KisIconUtils::loadIcon().

◆ initShapeLayerImpl()

void KisShapeLayer::initShapeLayerImpl ( KoShapeControllerBase * controller,
KisShapeLayerCanvasBase * overrideCanvas )
private

Definition at line 273 of file kis_shape_layer.cc.

275{
276 setSupportsLodMoves(false);
278
280
282
283 m_d->canvas = canvas;
284 m_d->canvas->moveToThread(this->thread());
285 m_d->controller = controller;
286
287 m_d->canvas->shapeManager()->selection()->disconnect(this);
288
289 connect(m_d->canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
291 this, SIGNAL(currentLayerChanged(const KoShapeLayer*)));
292
293 connect(this, SIGNAL(sigMoveShapes(QPointF)), SLOT(slotMoveShapes(QPointF)));
294
297 model->setAssociatedRootShapeManager(m_d->canvas->shapeManager());
298
299 if (this->image()) {
300 m_d->imageConnections.addUniqueConnection(this->image(), SIGNAL(sigResolutionChanged(double, double)), this, SLOT(slotImageResolutionChanged()));
302 }
303}
virtual KisPaintDeviceSP projection() const =0
KoSelectedShapesProxy * selectedShapesProxy() const override
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
void slotMoveShapes(const QPointF &diff)
void selectionChanged()
void currentLayerChanged(const KoShapeLayer *layer)
void slotImageResolutionChanged()
void sigMoveShapes(const QPointF &diff)
KisShapeLayerCanvasBase * canvas() const
void addUniqueConnection(Sender sender, Signal signal, Receiver receiver, Method method)
KoShapeContainerModel * model
KoSelection * selection
void setShapeId(const QString &id)
Definition KoShape.cpp:885
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
const QString KIS_SHAPE_LAYER_ID
void setSupportsLodMoves(bool value)
KisSignalAutoConnectionsStore imageConnections
KoShapeControllerBase * controller

References KisSignalAutoConnectionsStore::addUniqueConnection(), KisShapeLayer::Private::canvas, canvas(), KisShapeLayer::Private::controller, currentLayerChanged(), KisBaseNode::image, KisShapeLayer::Private::imageConnections, KIS_SAFE_ASSERT_RECOVER_RETURN, KIS_SHAPE_LAYER_ID, m_d, KoShapeContainer::model, KisShapeLayer::Private::paintDevice, KisShapeLayerCanvasBase::projection(), KisShapeLayerCanvasBase::selectedShapesProxy(), KoShapeManager::selection, selectionChanged(), KoShape::setShapeId(), KisBaseNode::setSupportsLodMoves(), KisShapeLayerCanvasBase::shapeManager(), sigMoveShapes(), slotImageResolutionChanged(), and slotMoveShapes().

◆ isSelectable()

bool KisShapeLayer::isSelectable ( ) const
inline

Definition at line 88 of file kis_shape_layer.h.

88 {
89 return false;
90 }

◆ isShapeEditable()

bool KisShapeLayer::isShapeEditable ( bool recursive) const
overridevirtual

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

Reimplemented from KoShape.

Definition at line 514 of file kis_shape_layer.cc.

515{
516 return KoShapeLayer::isShapeEditable(recursive) && isEditable(true);
517}
virtual bool isShapeEditable(bool recursive=true) const
checks recursively if the shape or one of its parents is not visible or locked
Definition KoShape.cpp:970
bool isEditable(bool checkVisibility=true) const

References KisBaseNode::isEditable(), and KoShape::isShapeEditable().

◆ isVisible()

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

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

803{
804 if (!recursive)
805 return s->visible;
806
807 if (!s->visible)
808 return false;
809
810 KoShapeContainer * parentShape = parent();
811
812 if (parentShape) {
813 return parentShape->isVisible(true);
814 }
815
816 return true;
817}
KoShapeContainer * parent
Definition KoShape_p.h:95
QSharedDataPointer< SharedData > s
Definition KoShape.h:977
bool isVisible(bool recursive=true) const
Definition KoShape.cpp:802

◆ loadLayer()

bool KisShapeLayer::loadLayer ( KoStore * store,
QStringList * warnings = 0 )

Definition at line 643 of file kis_shape_layer.cc.

644{
645 if (!store) {
646 warnKrita << "No store backend";
647 return false;
648 }
649
650 if (store->open("content.svg")) {
651 KoStoreDevice storeDev(store);
652 storeDev.open(QIODevice::ReadOnly);
653
654 loadSvg(&storeDev, "", warnings);
655
656 store->close();
657
658 return true;
659 }
660
661 return false;
662
663}
bool loadSvg(QIODevice *device, const QString &baseXmlDir, QStringList *warnings=0)
bool close()
Definition KoStore.cpp:156
bool open(const QString &name)
Definition KoStore.cpp:109
#define warnKrita
Definition kis_debug.h:87

References KoStore::close(), loadSvg(), KoStore::open(), KoStoreDevice::open(), and warnKrita.

◆ loadSvg()

bool KisShapeLayer::loadSvg ( QIODevice * device,
const QString & baseXmlDir,
QStringList * warnings = 0 )
protected

Definition at line 619 of file kis_shape_layer.cc.

620{
621 QSizeF fragmentSize; // unused!
622 KisImageSP image = this->image();
623
624 // FIXME: we handle xRes() only!
626 const qreal resolutionPPI = 72.0 * image->xRes();
627
629 createShapesFromSvg(device, baseXmlDir,
630 image->bounds(), resolutionPPI,
632 true,
633 &fragmentSize,
634 warnings);
635
636 Q_FOREACH (KoShape *shape, shapes) {
637 addShape(shape);
638 }
639
640 return true;
641}
double xRes() const
double yRes() const
QRect bounds() const override
static QList< KoShape * > createShapesFromSvg(QIODevice *device, const QString &baseXmlDir, const QRectF &rectInPixels, qreal resolutionPPI, KoDocumentResourceManager *resourceManager, bool loadingFromKra, QSizeF *fragmentSize, QStringList *warnings=0, QStringList *errors=0)
virtual KoDocumentResourceManager * resourceManager() const
static bool qFuzzyCompare(half p1, half p2)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KoShapeContainer::addShape(), KisImage::bounds(), KisShapeLayer::Private::controller, createShapesFromSvg(), KisBaseNode::image, KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, qFuzzyCompare(), KoShapeControllerBase::resourceManager(), KoShapeContainer::shapes(), KisImage::xRes(), and KisImage::yRes().

◆ original()

KisPaintDeviceSP KisShapeLayer::original ( ) const
overridevirtual

Return the layer data before the effect masks have had their go at it.

Implements KisLayer.

Definition at line 373 of file kis_shape_layer.cc.

374{
375 return m_d->paintDevice;
376}

References m_d, and KisShapeLayer::Private::paintDevice.

◆ paintDevice()

KisPaintDeviceSP KisShapeLayer::paintDevice ( ) const
overridevirtual

Return the paintdevice you can use to change pixels on. For a paint layer these will be paint pixels, for an adjustment layer or a mask the selection paint device.

Returns
the paint device to paint on. Can be 0 if the actual node type does not support painting.

Implements KisBaseNode.

Definition at line 378 of file kis_shape_layer.cc.

379{
380 return 0;
381}

◆ resetCache()

void KisShapeLayer::resetCache ( const KoColorSpace * colorSpace)
overridevirtual

Reimplemented from KisExternalLayer.

Definition at line 665 of file kis_shape_layer.cc.

666{
668}
virtual void resetCache(const KoColorSpace *colorSpace)=0
const KoColorSpace * colorSpace() const override
returns the image's colorSpace or null, if there is no image
Definition kis_layer.cc:225

References KisShapeLayer::Private::canvas, KisLayer::colorSpace(), m_d, and KisShapeLayerCanvasBase::resetCache().

◆ saveLayer()

bool KisShapeLayer::saveLayer ( KoStore * store) const

Definition at line 609 of file kis_shape_layer.cc.

610{
611 // FIXME: we handle xRes() only!
612
613 const QSizeF sizeInPx = image()->bounds().size();
614 const QSizeF sizeInPt(sizeInPx.width() / image()->xRes(), sizeInPx.height() / image()->yRes());
615
616 return saveShapesToStore(store, this->shapes(), sizeInPt);
617}
static bool saveShapesToStore(KoStore *store, QList< KoShape * > shapes, const QSizeF &sizeInPt)

References KisImage::bounds(), KisBaseNode::image, saveShapesToStore(), and KoShapeContainer::shapes().

◆ saveShapesToStore()

bool KisShapeLayer::saveShapesToStore ( KoStore * store,
QList< KoShape * > shapes,
const QSizeF & sizeInPt )
static

Definition at line 542 of file kis_shape_layer.cc.

543{
544 if (!store->open("content.svg")) {
545 return false;
546 }
547
548 KoStoreDevice storeDev(store);
549 storeDev.open(QIODevice::WriteOnly);
550
551 std::sort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex);
552
553 SvgWriter writer(shapes);
554 writer.save(storeDev, sizeInPt);
555
556 if (!store->close()) {
557 return false;
558 }
559
560 return true;
561}
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
Definition KoShape.cpp:393
Implements exporting shapes to SVG.
Definition SvgWriter.h:33

References KoStore::close(), KoShape::compareShapeZIndex(), KoStore::open(), KoStoreDevice::open(), SvgWriter::save(), and KoShapeContainer::shapes().

◆ sectionModelProperties()

KisBaseNode::PropertyList KisShapeLayer::sectionModelProperties ( ) const
overridevirtual

Return a the properties of this base node (locked, visible etc, with the right icons for their representation and their state.

Subclasses can extend this list with new properties, like opacity for layers or visualized for masks.

The order of properties is, unfortunately, for now, important, so take care which properties superclasses of your class define.

KisBaseNode defines visible = 0, locked = 1 KisLayer defines opacity = 2, compositeOp = 3 KisMask defines active = 2 (KisMask does not inherit kislayer)

Reimplemented from KisLayer.

Definition at line 325 of file kis_shape_layer.cc.

326{
328
330
331 return l;
332}
static KisBaseNode::Property getProperty(const KoID &id, bool state)
bool antialiased() const
KisBaseNode::PropertyList sectionModelProperties() const override
Definition kis_layer.cc:272

References KisLayerPropertiesIcons::antialiased, antialiased(), KisLayerPropertiesIcons::getProperty(), and KisLayer::sectionModelProperties().

◆ selectedShapesProxy()

KoSelectedShapesProxy * KisShapeLayer::selectedShapesProxy ( )

selectedShapesProxy

Returns
returns the selectedShapesProxy of the KoCanvasBase of this layer, used for certain undo commands.

Definition at line 537 of file kis_shape_layer.cc.

538{
539 return m_d->canvas->selectedShapesProxy();
540}

References KisShapeLayer::Private::canvas, m_d, and KisShapeLayerCanvasBase::selectedShapesProxy().

◆ selectionChanged

void KisShapeLayer::selectionChanged ( )
signal

These signals are forwarded from the local shape manager This is done because we switch KoShapeManager and therefore KoSelection in KisCanvas2, so we need to connect local managers to the UI as well.

See also
comment in the constructor of KisCanvas2

◆ setAntialiased()

void KisShapeLayer::setAntialiased ( const bool antialiased)

Definition at line 779 of file kis_shape_layer.cc.

780{
781 const bool oldAntialiased = m_d->isAntialiased;
782
783 if (antialiased != oldAntialiased) {
785 // is it the best way to rerender the vector layer?
787 }
788}

References antialiased(), KisShapeLayer::Private::canvas, KisLayer::colorSpace(), KisShapeLayer::Private::isAntialiased, m_d, and KisShapeLayerCanvasBase::resetCache().

◆ setImage()

void KisShapeLayer::setImage ( KisImageWSP image)
overridevirtual

Set the image this layer belongs to.

Reimplemented from KisLayer.

Definition at line 310 of file kis_shape_layer.cc.

311{
313 KisLayer::setImage(_image);
314 m_d->canvas->setImage(_image);
315 if (m_d->paintDevice) {
317 }
318 if (_image) {
319 m_d->imageConnections.addUniqueConnection(_image, SIGNAL(sigResolutionChanged(double, double)), this, SLOT(slotImageResolutionChanged()));
321 }
322}
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)
virtual void setImage(KisImageWSP image)
void setImage(KisImageWSP image) override
Definition kis_layer.cc:378

References KisSignalAutoConnectionsStore::addUniqueConnection(), KisShapeLayer::Private::canvas, KisSignalAutoConnectionsStore::clear(), KisShapeLayer::Private::imageConnections, m_d, KisShapeLayer::Private::paintDevice, KisPaintDevice::setDefaultBounds(), KisShapeLayerCanvasBase::setImage(), KisLayer::setImage(), and slotImageResolutionChanged().

◆ setParent()

void KisShapeLayer::setParent ( KoShapeContainer * parent)

Definition at line 362 of file kis_shape_layer.cc.

363{
364 Q_UNUSED(parent);
366}
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75

References KIS_ASSERT_RECOVER_RETURN, and KoShape::Private::parent.

◆ setProfile()

KUndo2Command * KisShapeLayer::setProfile ( const KoColorProfile * profile)
overridevirtual

Reimplemented from KisExternalLayer.

Definition at line 731 of file kis_shape_layer.cc.

732{
733 using namespace KisDoSomethingCommandOps;
734
735 KUndo2Command *cmd = new KUndo2Command();
737 m_d->paintDevice->setProfile(profile, cmd);
739
740 return cmd;
741}
bool setProfile(const KoColorProfile *profile, KUndo2Command *parentCommand)

References m_d, KisShapeLayer::Private::paintDevice, and KisPaintDevice::setProfile().

◆ setSectionModelProperties()

void KisShapeLayer::setSectionModelProperties ( const KisBaseNode::PropertyList & properties)
overridevirtual

Change the section model properties.

Reimplemented from KisLayer.

Definition at line 334 of file kis_shape_layer.cc.

335{
336 Q_FOREACH (const KisBaseNode::Property &property, properties) {
337 if (property.name == i18n("Anti-aliasing")) {
338 setAntialiased(property.state.toBool());
339 }
340 }
341
343}
void setAntialiased(const bool antialiased)
KoProperties properties
void setSectionModelProperties(const KisBaseNode::PropertyList &properties) override
Definition kis_layer.cc:297

References KisBaseNode::Property::name, KisBaseNode::properties, setAntialiased(), KisLayer::setSectionModelProperties(), and KisBaseNode::Property::state.

◆ setUserLocked()

void KisShapeLayer::setUserLocked ( bool l)
overridevirtual

Set the locked status of this node. Locked nodes cannot be edited.

Reimplemented from KisBaseNode.

Definition at line 508 of file kis_shape_layer.cc.

509{
512}
float value(const T *src, size_t ch)
void setGeometryProtected(bool on)
Definition KoShape.cpp:842
virtual void setUserLocked(bool l)

References KoShape::setGeometryProtected(), KisBaseNode::setUserLocked(), and value().

◆ setVisible()

void KisShapeLayer::setVisible ( bool visible,
bool loading = false )
overridevirtual

Set the visible status of this node. Visible nodes are active in the graph (except for selections masks which can be active while hidden), that is to say, they are taken into account when merging. Invisible nodes play no role in the final image , but will be modified when modifying all layers, for instance when cropping.

Toggling the visibility of a node will not automatically lead to recomposition.

Parameters
visiblethe new visibility state
isLoadingif true, the property is set during loading.

Reimplemented from KisBaseNode.

Definition at line 494 of file kis_shape_layer.cc.

495{
496 const bool oldVisible = this->visible(false);
497
500
501 if (visible && !oldVisible &&
503
505 }
506}
virtual void rerenderAfterBeingInvisible()=0
bool visible(bool recursive=false) const override
void setVisible(bool on)
Definition KoShape.cpp:795
virtual void setVisible(bool visible, bool loading=false)

References KisShapeLayer::Private::canvas, KisShapeLayerCanvasBase::hasChangedWhileBeingInvisible(), m_d, KisShapeLayerCanvasBase::rerenderAfterBeingInvisible(), KoShape::setVisible(), KisBaseNode::setVisible(), and visible().

◆ setX()

void KisShapeLayer::setX ( qint32 )
overridevirtual

Set the x offset of this layer in the image place. Re-implement this where it makes sense, by default it does nothing. It should not move child nodes.

Reimplemented from KisLayer.

Definition at line 398 of file kis_shape_layer.cc.

399{
400 qint32 delta = x - this->x();
401 QPointF diff = QPointF(m_d->canvas->viewConverter()->viewToDocumentX(delta), 0);
402 Q_EMIT sigMoveShapes(diff);
403
404 // Save new value to satisfy LSP
405 m_d->x = x;
406}
virtual qreal viewToDocumentX(qreal viewX) const

References KisShapeLayer::Private::canvas, m_d, sigMoveShapes(), KisShapeLayerCanvasBase::viewConverter(), KoViewConverter::viewToDocumentX(), KisShapeLayer::Private::x, and x().

◆ setY()

void KisShapeLayer::setY ( qint32 )
overridevirtual

Set the y offset of this layer in the image place. Re-implement this where it makes sense, by default it does nothing. It should not move child nodes.

Reimplemented from KisLayer.

Definition at line 408 of file kis_shape_layer.cc.

409{
410 qint32 delta = y - this->y();
411 QPointF diff = QPointF(0, m_d->canvas->viewConverter()->viewToDocumentY(delta));
412 Q_EMIT sigMoveShapes(diff);
413
414 // Save new value to satisfy LSP
415 m_d->y = y;
416}
virtual qreal viewToDocumentY(qreal viewY) const

References KisShapeLayer::Private::canvas, m_d, sigMoveShapes(), KisShapeLayerCanvasBase::viewConverter(), KoViewConverter::viewToDocumentY(), KisShapeLayer::Private::y, and y().

◆ shapeController()

KoShapeControllerBase * KisShapeLayer::shapeController ( ) const
protected

Definition at line 754 of file kis_shape_layer.cc.

755{
756 return m_d->controller;
757}

References KisShapeLayer::Private::controller, and m_d.

◆ shapeManager()

KoShapeManager * KisShapeLayer::shapeManager ( ) const

Definition at line 479 of file kis_shape_layer.cc.

480{
481 return m_d->canvas->shapeManager();
482}

References KisShapeLayer::Private::canvas, m_d, and KisShapeLayerCanvasBase::shapeManager().

◆ shapesToBeTransformed()

QList< KoShape * > KisShapeLayer::shapesToBeTransformed ( )
private

Definition at line 433 of file kis_shape_layer.cc.

434{
436
437 // We expect that **all** the shapes inherit the transform from its parent
438
439 // SANITY_CHECK: we expect all the shapes inside the
440 // shape layer to inherit transform!
441 Q_FOREACH (KoShape *shape, shapes) {
442 if (shape->parent()) {
444 break;
445 }
446 }
447 }
448
449 shapes << this;
450 filterTransformableShapes(shapes);
451 return shapes;
452}
KoShapeManager * shapeManager() const
bool inheritsTransform(const KoShape *shape) const
QList< KoShape * > shapes
KoShapeContainer * parent() const
Definition KoShape.cpp:862

References KoShapeContainer::inheritsTransform(), KIS_SAFE_ASSERT_RECOVER, KoShape::parent(), shapeManager(), KoShapeContainer::shapes(), and KoShapeManager::shapes.

◆ sigMoveShapes

void KisShapeLayer::sigMoveShapes ( const QPointF & diff)
signal

A signal + slot to synchronize UI and image threads. Image thread emits the signal, UI thread performs the action

◆ slotImageResolutionChanged

void KisShapeLayer::slotImageResolutionChanged ( )
privateslot

Definition at line 764 of file kis_shape_layer.cc.

765{
768 if (this->image()) {
769 model->setResolution(image()->xRes() * 72.0, image()->yRes() * 72.0);
770 }
771}
void setResolution(qreal xRes, qreal yRes)

References KisBaseNode::image, KIS_SAFE_ASSERT_RECOVER_RETURN, KoShapeContainer::model, and ShapeLayerContainerModel::setResolution().

◆ slotMoveShapes

void KisShapeLayer::slotMoveShapes ( const QPointF & diff)
privateslot

Definition at line 454 of file kis_shape_layer.cc.

455{
457 if (shapes.isEmpty()) return;
458
459 KoShapeMoveCommand cmd(shapes, diff);
460 cmd.redo();
461}
QList< KoShape * > shapesToBeTransformed()
The undo / redo command for shape moving.

References KoShapeMoveCommand::redo(), KoShapeContainer::shapes(), and shapesToBeTransformed().

◆ slotTransformShapes

void KisShapeLayer::slotTransformShapes ( const QTransform & transform)
privateslot

Definition at line 463 of file kis_shape_layer.cc.

464{
465 KoShapeTransformCommand cmd({this}, {transformation()}, {newTransform});
466 cmd.redo();
467}
void redo() override
redo the command
QTransform transformation() const
Returns the shapes local transformation matrix.
Definition KoShape.cpp:383

References KoShapeTransformCommand::redo(), and KoShape::transformation().

◆ theoreticalBoundingRect()

QRect KisShapeLayer::theoreticalBoundingRect ( ) const
overridevirtual

Some external layers use original() only as a projection and render some internal state into it, e.g. using KisSpontaneousProjection asynchronously. theoreticalBoundingRect() is used to get real bounding rect of a layer without relying on original().

Reimplemented from KisExternalLayer.

Definition at line 383 of file kis_shape_layer.cc.

384{
385 return kisGrowRect(m_d->canvas->viewConverter()->documentToView(this->boundingRect()).toAlignedRect(), 1);
386}
virtual QPointF documentToView(const QPointF &documentPoint) const
T kisGrowRect(const T &rect, U offset)
Definition kis_global.h:186

References KisShapeLayer::Private::canvas, KoViewConverter::documentToView(), kisGrowRect(), m_d, and KisShapeLayerCanvasBase::viewConverter().

◆ transform()

KUndo2Command * KisShapeLayer::transform ( const QTransform & transform)
overridevirtual

We cannot transform shapes in the worker thread. Therefor we Q_EMIT blocking-queued signal to transform them in the GUI thread and then return.

Reimplemented from KisExternalLayer.

Definition at line 713 of file kis_shape_layer.cc.

714{
716 if (shapes.isEmpty()) return 0;
717 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(shapes.size() == 1 && shapes.first() == this, 0);
718
723 const KisImageViewConverter *converter = dynamic_cast<const KisImageViewConverter*>(this->converter());
724 KIS_ASSERT(converter);
725 QTransform docSpaceTransform = converter->documentToView() *
727
728 return new TransformShapeLayerDeferred(this, docSpaceTransform);
729}
friend class TransformShapeLayerDeferred
const KoViewConverter * converter() const
QTransform transform() const
return the current matrix that contains the rotation/scale/position of this shape
Definition KoShape.cpp:950
virtual QPointF viewToDocument(const QPointF &viewPoint) const
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References converter(), KoViewConverter::documentToView(), KIS_ASSERT, KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KoShapeContainer::shapes(), shapesToBeTransformed(), KoShape::transform(), TransformShapeLayerDeferred, and KoViewConverter::viewToDocument().

◆ visible()

bool KisShapeLayer::visible ( bool recursive = false) const
overridevirtual
Returns
true if this node is visible (i.e, active (except for selection masks where visible and active properties are different)) in the graph
Parameters
boolrecursive if true, check whether all parents of this node are visible as well.

Reimplemented from KisBaseNode.

Definition at line 489 of file kis_shape_layer.cc.

490{
491 return KisExternalLayer::visible(recursive);
492}
virtual bool visible(bool recursive=false) const

References KisBaseNode::visible().

◆ x()

qint32 KisShapeLayer::x ( ) const
overridevirtual
Returns
the x-offset of this layer in the image plane.

Reimplemented from KisLayer.

Definition at line 388 of file kis_shape_layer.cc.

389{
390 return m_d->x;
391}

References m_d, and KisShapeLayer::Private::x.

◆ y()

qint32 KisShapeLayer::y ( ) const
overridevirtual
Returns
the y-offset of this layer in the image plane.

Reimplemented from KisLayer.

Definition at line 393 of file kis_shape_layer.cc.

394{
395 return m_d->y;
396}

References m_d, and KisShapeLayer::Private::y.

Friends And Related Symbol Documentation

◆ ShapeLayerContainerModel

friend class ShapeLayerContainerModel
friend

Definition at line 179 of file kis_shape_layer.h.

◆ TransformShapeLayerDeferred

friend class TransformShapeLayerDeferred
friend

Definition at line 185 of file kis_shape_layer.h.

Member Data Documentation

◆ m_d

Private* const KisShapeLayer::m_d
private

Definition at line 217 of file kis_shape_layer.h.


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