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

#include <kis_node_juggler_compressed.h>

+ Inheritance diagram for KisNodeJugglerCompressed:

Classes

struct  Private
 

Public Slots

void end ()
 

Signals

void requestUpdateAsyncFromCommand ()
 

Public Member Functions

void addNode (const KisNodeList &nodes, KisNodeSP dstParent, KisNodeSP dstAbove)
 
bool canMergeAction (const KUndo2MagicString &actionName)
 
void copyNode (const KisNodeList &nodes, KisNodeSP dstParent, KisNodeSP dstAbove)
 
void duplicateNode (const KisNodeList &nodes)
 
bool isEnded () const
 
 KisNodeJugglerCompressed (const KUndo2MagicString &actionName, KisImageSP image, KisNodeManager *nodeManager, int timeout)
 
void lowerNode (const KisNodeList &nodes)
 
void moveNode (const KisNodeList &nodes, KisNodeSP dstParent, KisNodeSP dstAbove)
 
void moveNode (KisNodeSP node, KisNodeSP parent, KisNodeSP above)
 
void raiseNode (const KisNodeList &nodes)
 
void removeNode (const KisNodeList &nodes)
 
void setAutoDelete (bool value)
 
 ~KisNodeJugglerCompressed () override
 

Private Slots

void slotEndStrokeRequested ()
 
void slotImageAboutToBeDeleted ()
 
void slotUndoDuringStrokeRequested ()
 
void slotUpdateTimeout ()
 
void startTimers ()
 

Private Member Functions

void cleanup ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 19 of file kis_node_juggler_compressed.h.

Constructor & Destructor Documentation

◆ KisNodeJugglerCompressed()

KisNodeJugglerCompressed::KisNodeJugglerCompressed ( const KUndo2MagicString & actionName,
KisImageSP image,
KisNodeManager * nodeManager,
int timeout )

Definition at line 708 of file kis_node_juggler_compressed.cpp.

709 : m_d(new Private(this, actionName, image, nodeManager, timeout))
710{
711
712 KisImageSignalVector emitSignals;
713
714 m_d->applicator.reset(
715 new KisProcessingApplicator(m_d->image, 0,
717 emitSignals,
718 actionName));
719 connect(this, SIGNAL(requestUpdateAsyncFromCommand()), SLOT(startTimers()));
720 connect(&m_d->compressor, SIGNAL(timeout()), SLOT(slotUpdateTimeout()));
721
722 connect(m_d->image, SIGNAL(sigStrokeCancellationRequested()), SLOT(slotEndStrokeRequested()));
723 connect(m_d->image, SIGNAL(sigUndoDuringStrokeRequested()), SLOT(slotUndoDuringStrokeRequested()));
724 connect(m_d->image, SIGNAL(sigStrokeEndRequestedActiveNodeFiltered()), SLOT(slotEndStrokeRequested()));
725 connect(m_d->image, SIGNAL(sigAboutToBeDeleted()), SLOT(slotImageAboutToBeDeleted()));
726
727 m_d->applicator->applyCommand(
728 new UpdateMovedNodesCommand(m_d->updateData, false));
729 m_d->isStarted = true;
730}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
const QScopedPointer< Private > m_d

References connect(), m_d, KisProcessingApplicator::NONE, requestUpdateAsyncFromCommand(), slotEndStrokeRequested(), slotImageAboutToBeDeleted(), slotUndoDuringStrokeRequested(), slotUpdateTimeout(), and startTimers().

◆ ~KisNodeJugglerCompressed()

KisNodeJugglerCompressed::~KisNodeJugglerCompressed ( )
override

Definition at line 732 of file kis_node_juggler_compressed.cpp.

733{
734 KIS_ASSERT_RECOVER(!m_d->applicator) {
735 m_d->applicator->end();
736 m_d->applicator.reset();
737 }
738}
#define KIS_ASSERT_RECOVER(cond)
Definition kis_assert.h:55

References KIS_ASSERT_RECOVER, and m_d.

Member Function Documentation

◆ addNode()

void KisNodeJugglerCompressed::addNode ( const KisNodeList & nodes,
KisNodeSP dstParent,
KisNodeSP dstAbove )

Definition at line 821 of file kis_node_juggler_compressed.cpp.

822{
823 KisNodeSP activeNode = m_d->nodeManager ? m_d->nodeManager->activeNode() : 0;
824
825 m_d->applicator->applyCommand(
826 new DuplicateLayers(m_d->updateData,
827 m_d->image,
828 nodes,
829 dstParent, dstAbove,
830 activeNode,
833}

References DuplicateLayers::ADD, KisStrokeJobData::EXCLUSIVE, m_d, and KisStrokeJobData::SEQUENTIAL.

◆ canMergeAction()

bool KisNodeJugglerCompressed::canMergeAction ( const KUndo2MagicString & actionName)

Definition at line 740 of file kis_node_juggler_compressed.cpp.

741{
742 return actionName == m_d->actionName;
743}

References m_d.

◆ cleanup()

void KisNodeJugglerCompressed::cleanup ( )
private

Definition at line 888 of file kis_node_juggler_compressed.cpp.

889{
890 m_d->applicator.reset();
891 m_d->compressor.stop();
892 m_d->image.clear();
893 m_d->updateData.clear();
894 m_d->isStarted = false;
895
896 if (m_d->autoDelete) {
897 m_d->selfDestructionCompressor.stop();
898 this->deleteLater();
899 }
900}

References m_d.

◆ copyNode()

void KisNodeJugglerCompressed::copyNode ( const KisNodeList & nodes,
KisNodeSP dstParent,
KisNodeSP dstAbove )

Definition at line 793 of file kis_node_juggler_compressed.cpp.

794{
795 KisNodeSP activeNode = m_d->nodeManager ? m_d->nodeManager->activeNode() : 0;
796
797 m_d->applicator->applyCommand(
798 new DuplicateLayers(m_d->updateData,
799 m_d->image,
800 nodes,
801 dstParent, dstAbove,
802 activeNode,
805}

References DuplicateLayers::COPY, KisStrokeJobData::EXCLUSIVE, m_d, and KisStrokeJobData::SEQUENTIAL.

◆ duplicateNode()

void KisNodeJugglerCompressed::duplicateNode ( const KisNodeList & nodes)

Definition at line 779 of file kis_node_juggler_compressed.cpp.

780{
781 KisNodeSP activeNode = m_d->nodeManager ? m_d->nodeManager->activeNode() : 0;
782
783 m_d->applicator->applyCommand(
784 new DuplicateLayers(m_d->updateData,
785 m_d->image,
786 nodes,
787 KisNodeSP(), KisNodeSP(),
788 activeNode,
791}
KisSharedPtr< KisNode > KisNodeSP
Definition kis_types.h:86

References DuplicateLayers::COPY, KisStrokeJobData::EXCLUSIVE, m_d, and KisStrokeJobData::SEQUENTIAL.

◆ end

void KisNodeJugglerCompressed::end ( )
slot

Definition at line 877 of file kis_node_juggler_compressed.cpp.

878{
879 if (!m_d->isStarted) return;
880
881 m_d->applicator->applyCommand(
882 new UpdateMovedNodesCommand(m_d->updateData, true));
883
884 m_d->applicator->end();
885 cleanup();
886}

References cleanup(), and m_d.

◆ isEnded()

bool KisNodeJugglerCompressed::isEnded ( ) const

Definition at line 944 of file kis_node_juggler_compressed.cpp.

945{
946 return !m_d->isStarted;
947}

References m_d.

◆ lowerNode()

void KisNodeJugglerCompressed::lowerNode ( const KisNodeList & nodes)

Definition at line 745 of file kis_node_juggler_compressed.cpp.

746{
747 KisNodeSP activeNode = m_d->nodeManager ? m_d->nodeManager->activeNode() : 0;
748
749 m_d->applicator->applyCommand(
750 new LowerRaiseLayer(m_d->updateData,
751 m_d->image,
752 nodes, activeNode, true),
754
755}

References KisStrokeJobData::EXCLUSIVE, m_d, and KisStrokeJobData::SEQUENTIAL.

◆ moveNode() [1/2]

void KisNodeJugglerCompressed::moveNode ( const KisNodeList & nodes,
KisNodeSP dstParent,
KisNodeSP dstAbove )

Definition at line 807 of file kis_node_juggler_compressed.cpp.

808{
809 KisNodeSP activeNode = m_d->nodeManager ? m_d->nodeManager->activeNode() : 0;
810
811 m_d->applicator->applyCommand(
812 new DuplicateLayers(m_d->updateData,
813 m_d->image,
814 nodes,
815 dstParent, dstAbove,
816 activeNode,
819}

References KisStrokeJobData::EXCLUSIVE, m_d, DuplicateLayers::MOVE, and KisStrokeJobData::SEQUENTIAL.

◆ moveNode() [2/2]

void KisNodeJugglerCompressed::moveNode ( KisNodeSP node,
KisNodeSP parent,
KisNodeSP above )

Definition at line 835 of file kis_node_juggler_compressed.cpp.

836{
837 m_d->applicator->applyCommand(new KisImageLayerMoveCommand(m_d->image, node, parent, above, false),
839
840 MoveNodeStructSP moveStruct = toQShared(new MoveNodeStruct(m_d->image, node, parent, above));
841
842 m_d->updateData->addInitialUpdate(moveStruct);
843}
The command for layer moves inside the layer stack.
QSharedPointer< T > toQShared(T *ptr)

References KisStrokeJobData::EXCLUSIVE, m_d, KisStrokeJobData::SEQUENTIAL, and toQShared().

◆ raiseNode()

void KisNodeJugglerCompressed::raiseNode ( const KisNodeList & nodes)

Definition at line 757 of file kis_node_juggler_compressed.cpp.

758{
759 KisNodeSP activeNode = m_d->nodeManager ? m_d->nodeManager->activeNode() : 0;
760
761 m_d->applicator->applyCommand(
762 new LowerRaiseLayer(m_d->updateData,
763 m_d->image,
764 nodes, activeNode, false),
766}

References KisStrokeJobData::EXCLUSIVE, m_d, and KisStrokeJobData::SEQUENTIAL.

◆ removeNode()

void KisNodeJugglerCompressed::removeNode ( const KisNodeList & nodes)

Definition at line 768 of file kis_node_juggler_compressed.cpp.

769{
770 KisNodeSP activeNode = m_d->nodeManager ? m_d->nodeManager->activeNode() : 0;
771
772 m_d->applicator->applyCommand(
773 new RemoveLayers(m_d->updateData,
774 m_d->image,
775 nodes, activeNode),
777}

References KisStrokeJobData::EXCLUSIVE, m_d, and KisStrokeJobData::SEQUENTIAL.

◆ requestUpdateAsyncFromCommand

void KisNodeJugglerCompressed::requestUpdateAsyncFromCommand ( )
signal

◆ setAutoDelete()

void KisNodeJugglerCompressed::setAutoDelete ( bool value)

Definition at line 902 of file kis_node_juggler_compressed.cpp.

903{
904 m_d->autoDelete = value;
905 connect(&m_d->selfDestructionCompressor, SIGNAL(timeout()), SLOT(end()));
906}
float value(const T *src, size_t ch)

References connect(), end(), m_d, and value().

◆ slotEndStrokeRequested

void KisNodeJugglerCompressed::slotEndStrokeRequested ( )
privateslot

Definition at line 908 of file kis_node_juggler_compressed.cpp.

909{
910 if (!m_d->isStarted) return;
911 end();
912}

References end(), and m_d.

◆ slotImageAboutToBeDeleted

void KisNodeJugglerCompressed::slotImageAboutToBeDeleted ( )
privateslot

We should start a proper end() routine with updates to avoid an assert about missing updates

Definition at line 933 of file kis_node_juggler_compressed.cpp.

934{
935 if (!m_d->isStarted) return;
936
941 end();
942}

References end(), and m_d.

◆ slotUndoDuringStrokeRequested

void KisNodeJugglerCompressed::slotUndoDuringStrokeRequested ( )
privateslot

When the user presses Cltr+Z during the process of layer removal we should end the process and pass execution process back to the undo stack to make it undone. If we just cancel the action, then no redo action will be created (see bug 491186).

So we just wait till the end of the action and return back to the undo stack.

Definition at line 914 of file kis_node_juggler_compressed.cpp.

915{
916 if (!m_d->isStarted) return;
917
928 KisImageSP image = m_d->image;
929 end();
930 image->waitForDone();
931}
void waitForDone()

References end(), m_d, and KisImage::waitForDone().

◆ slotUpdateTimeout

void KisNodeJugglerCompressed::slotUpdateTimeout ( )
privateslot

Since the update should be synchronized with the flow of layer-add commands, we issue it from a fake undo command that doesn't generate any history

Definition at line 854 of file kis_node_juggler_compressed.cpp.

855{
856 // The juggler could have been already finished explicitly
857 // by slotEndStrokeRequested(). In such a case the final updates
858 // will be issued by the last command of the stroke.
859
860 if (!m_d->updateData || !m_d->isStarted) return;
861
862 BatchMoveUpdateDataSP updateData = m_d->updateData;
863
869 m_d->applicator->applyCommand(
871 [updateData] () {
872 updateData->processUnhandledUpdates();
873 return nullptr;
874 }));
875}
The LambdaCommand struct is a shorthand for creation of AggregateCommand commands using C++ lambda fe...

References m_d.

◆ startTimers

void KisNodeJugglerCompressed::startTimers ( )
privateslot

Definition at line 845 of file kis_node_juggler_compressed.cpp.

846{
847 m_d->compressor.start();
848
849 if (m_d->autoDelete) {
850 m_d->selfDestructionCompressor.start();
851 }
852}

References m_d.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisNodeJugglerCompressed::m_d
private

Definition at line 60 of file kis_node_juggler_compressed.h.


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