Krita Source Code Documentation
Loading...
Searching...
No Matches
KisImageCommand::UpdateTarget Class Reference

#include <kis_image_command.h>

Public Member Functions

void update ()
 
 UpdateTarget (KisImageWSP image, KisNodeSP removedNode, const QRect &updateRect)
 

Private Attributes

KisImageWSP m_image
 
int m_removedNodeIndex
 
KisNodeSP m_removedNodeParent
 
QRect m_updateRect
 

Detailed Description

Used for performing the smallest update after a node has been removed from stack. First tries to setDirty() node's siblings. If it doesn't help, performs full refresh.

Definition at line 43 of file kis_image_command.h.

Constructor & Destructor Documentation

◆ UpdateTarget()

KisImageCommand::UpdateTarget::UpdateTarget ( KisImageWSP image,
KisNodeSP removedNode,
const QRect & updateRect )

We are saving an index, but not shared pointer, because the target node may suddenly reincarnate into another type of a layer during the removal process

Definition at line 30 of file kis_image_command.cpp.

33 : m_image(image), m_updateRect(updateRect)
34{
40 m_removedNodeParent = removedNode->parent();
42}
int index(const KisNodeSP node) const
Definition kis_node.cpp:432
KisNodeWSP parent
Definition kis_node.cpp:86

References KisNode::index(), m_removedNodeIndex, m_removedNodeParent, and KisNode::parent.

Member Function Documentation

◆ update()

void KisImageCommand::UpdateTarget::update ( )

Definition at line 44 of file kis_image_command.cpp.

44 {
45 if (!m_removedNodeParent) return;
47
48 KisNodeSP node;
49 int index = m_removedNodeIndex;
50
51 while ((node = m_removedNodeParent->at(index)) && !isLayer(node)) {
52 index++;
53 }
54
55 if (!node) {
56 index = qMax(0, m_removedNodeIndex - 1);
57
58 while ((node = m_removedNodeParent->at(index)) && !isLayer(node)) {
59 index--;
60 }
61 }
62
63 if (node) {
65 } else {
67 if (image) {
70 }
71 }
72}
void refreshGraphAsync(KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
static bool isLayer(KisNodeSP node)
KisNodeSP at(quint32 index) const
Definition kis_node.cpp:421
virtual void setDirty()
Definition kis_node.cpp:577

References KisNode::at(), isLayer(), KIS_ASSERT_RECOVER_RETURN, KisImageCommand::m_image, KisImage::refreshGraphAsync(), KisNode::setDirty(), and KisWeakSharedPtr< T >::toStrongRef().

Member Data Documentation

◆ m_image

KisImageWSP KisImageCommand::UpdateTarget::m_image
private

Definition at line 50 of file kis_image_command.h.

◆ m_removedNodeIndex

int KisImageCommand::UpdateTarget::m_removedNodeIndex
private

Definition at line 52 of file kis_image_command.h.

◆ m_removedNodeParent

KisNodeSP KisImageCommand::UpdateTarget::m_removedNodeParent
private

Definition at line 53 of file kis_image_command.h.

◆ m_updateRect

QRect KisImageCommand::UpdateTarget::m_updateRect
private

Definition at line 51 of file kis_image_command.h.


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