OpenToonz - An open-source full-featured 2D animation creation software
C
Allow undo/redo converting level to vectors.
Martin van Zijl9cb41369ee9e
diff --git a/toonz/sources/toonz/columncommand.cpp b/toonz/sources/toonz/columncommand.cppindex 6195b922a..155d71779 100644--- a/toonz/sources/toonz/columncommand.cpp+++ b/toonz/sources/toonz/columncommand.cpp@@ -467,7 +467,7 @@ void cloneSubXsheets(TXsheet *xsh) {// PasteColumnsUndo//------------------------------------------------------------------------------class PasteColumnsUndo final : public TUndo {+class PasteColumnsUndo : public TUndo {std::set<int> m_indices;StageObjectsData *m_data;QMap<TFxPort *, TFx *> m_columnLinks;@@ -1349,3 +1349,23 @@ ColumnsStatusCommandc16(MI_LockSelectedColumns, CMD_LOCK, TARGET_SELECTED),c17(MI_UnlockSelectedColumns, CMD_UNLOCK, TARGET_SELECTED);} // namespace++//=============================================================================+// ConvertToVectorUndo+//-----------------------------------------------------------------------------++// Same in functionality to PasteColumnsUndo; think of it perhaps like+// pasting the newly created vector column.+class ConvertToVectorUndo final : public PasteColumnsUndo {+public:+ ConvertToVectorUndo(std::set<int> indices) : PasteColumnsUndo(indices) {};++ QString getHistoryString() override {+ return QObject::tr("Convert to Vectors");+ }+};++void ColumnCmd::addConvertToVectorUndo(std::set<int> &newColumnIndices)+{+ TUndoManager::manager()->add(new ConvertToVectorUndo(newColumnIndices));+}diff --git a/toonz/sources/toonz/columncommand.h b/toonz/sources/toonz/columncommand.hindex aef95daf4..e3b53e3db 100644--- a/toonz/sources/toonz/columncommand.h+++ b/toonz/sources/toonz/columncommand.h@@ -32,6 +32,9 @@ bool canResequence(int index);void cloneChild(int index);void clearCells(int index);+//! Adds an undo object for converting layer to vector.+void addConvertToVectorUndo(std::set<int> &newColumnIndices);+} // namespace#endifdiff --git a/toonz/sources/toonz/vectorizerpopup.cpp b/toonz/sources/toonz/vectorizerpopup.cppindex fb15f10ef..683453a02 100644--- a/toonz/sources/toonz/vectorizerpopup.cpp+++ b/toonz/sources/toonz/vectorizerpopup.cpp@@ -46,6 +46,7 @@#include "tcolorstyles.h"#include "tstroke.h"#include "tpersistset.h"+#include "columncommand.h"// Qt includes#include <QFrame>@@ -950,6 +951,7 @@ bool VectorizerPopup::apply() {SLOT(onFinished()), Qt::QueuedConnection);assert(ret);+ std::set<int> newColumnIndices;int newIndexColumn = c1 + 1;for (auto const level : levels) {TXshSimpleLevel *sl = dynamic_cast<TXshSimpleLevel *>(level);@@ -1017,9 +1019,11 @@ bool VectorizerPopup::apply() {}}}+ newColumnIndices.insert(newIndexColumn);newIndexColumn += 1;} else if (vl) {std::vector<TFrameId> gomi;+ newColumnIndices.insert(scene->getXsheet()->getFirstFreeColumnIndex());scene->getXsheet()->exposeLevel(0, scene->getXsheet()->getFirstFreeColumnIndex(), vl, gomi);}@@ -1027,6 +1031,10 @@ bool VectorizerPopup::apply() {if (m_vectorizer->isCanceled()) break;}+ // Add undo object+ if (!m_vectorizer->isCanceled())+ ColumnCmd::addConvertToVectorUndo(newColumnIndices);+m_progressDialog->close();delete m_vectorizer;