OpenToonz - An open-source full-featured 2D animation creation software
C
Add column selection ability to Vectorizer (level command)
Abel You50461407b4fb
diff --git a/toonz/sources/toonz/columnselection.cpp b/toonz/sources/toonz/columnselection.cppindex 9b1d59a0b..40973571d 100644--- a/toonz/sources/toonz/columnselection.cpp+++ b/toonz/sources/toonz/columnselection.cpp@@ -28,42 +28,6 @@#include "ttoonzimage.h"#include "tundo.h"-namespace {-// obtain level set contained in the column specified by indices-// it is used for checking and updating the scene cast when pasting-// based on TXsheet::getUsedLevels-void getLevelSetFromColumnIndices(const std::set<int>& indices,- std::set<TXshLevel*>& levelSet) {- TXsheet* xsh = TApp::instance()->getCurrentXsheet()->getXsheet();- for (auto c : indices) {- TXshColumnP column = const_cast<TXsheet*>(xsh)->getColumn(c);- if (!column) continue;-- TXshCellColumn* cellColumn = column->getCellColumn();- if (!cellColumn) continue;-- int r0, r1;- if (!cellColumn->getRange(r0, r1)) continue;-- TXshLevel* level = 0;- for (int r = r0; r <= r1; r++) {- TXshCell cell = cellColumn->getCell(r);- if (cell.isEmpty() || !cell.m_level) continue;-- if (level != cell.m_level.getPointer()) {- level = cell.m_level.getPointer();- levelSet.insert(level);- if (level->getChildLevel()) {- TXsheet* childXsh = level->getChildLevel()->getXsheet();- childXsh->getUsedLevels(levelSet);- }- }- }- }-}--} // namespace-//=============================================================================// TColumnSelection//-----------------------------------------------------------------------------@@ -357,3 +321,36 @@ void TColumnSelection::hideColumns() {// TApp::instance()->->notify(TColumnHeadChange());app->getCurrentScene()->setDirtyFlag(true);}++// obtain level set contained in the column specified by indices+// it is used for checking and updating the scene cast when pasting+// based on TXsheet::getUsedLevels+void TColumnSelection::getLevelSetFromColumnIndices(const std::set<int>& indices,+ std::set<TXshLevel*>& levelSet) {+ TXsheet* xsh = TApp::instance()->getCurrentXsheet()->getXsheet();+ for (auto c : indices) {+ TXshColumnP column = const_cast<TXsheet*>(xsh)->getColumn(c);+ if (!column) continue;++ TXshCellColumn* cellColumn = column->getCellColumn();+ if (!cellColumn) continue;++ int r0, r1;+ if (!cellColumn->getRange(r0, r1)) continue;++ TXshLevel* level = 0;+ for (int r = r0; r <= r1; r++) {+ TXshCell cell = cellColumn->getCell(r);+ if (cell.isEmpty() || !cell.m_level) continue;++ if (level != cell.m_level.getPointer()) {+ level = cell.m_level.getPointer();+ levelSet.insert(level);+ if (level->getChildLevel()) {+ TXsheet* childXsh = level->getChildLevel()->getXsheet();+ childXsh->getUsedLevels(levelSet);+ }+ }+ }+ }+}diff --git a/toonz/sources/toonz/columnselection.h b/toonz/sources/toonz/columnselection.hindex 323751bf6..865f4eaa1 100644--- a/toonz/sources/toonz/columnselection.h+++ b/toonz/sources/toonz/columnselection.h@@ -6,6 +6,7 @@#include "toonzqt/selection.h"#include "tgeometry.h"#include <set>+#include "toonz/txshlevel.h"class ReframePopup;@@ -54,6 +55,8 @@ public:void reframe4Cells() { reframeCells(4); }void reframeWithEmptyInbetweens();+ static void getLevelSetFromColumnIndices(const std::set<int>& indices,+ std::set<TXshLevel*>& levelSet);};#endif // TCELLSELECTION_Hdiff --git a/toonz/sources/toonz/vectorizerpopup.cpp b/toonz/sources/toonz/vectorizerpopup.cppindex 8e8bd53b2..d81130e52 100644--- a/toonz/sources/toonz/vectorizerpopup.cpp+++ b/toonz/sources/toonz/vectorizerpopup.cpp@@ -7,6 +7,7 @@#include "fileselection.h"#include "castselection.h"#include "cellselection.h"+#include "columnselection.h"#include "overwritepopup.h"#include "vectorizerswatch.h"#include "filebrowserpopup.h"@@ -120,6 +121,8 @@ bool getSelectedLevels(std::set<TXshLevel *> &levels, int &r0, int &c0, int &r1,dynamic_cast<CastSelection *>(TSelection::getCurrent());TCellSelection *cellSelection =dynamic_cast<TCellSelection *>(TSelection::getCurrent());+ TColumnSelection* columnSelection =+ dynamic_cast<TColumnSelection*>(TSelection::getCurrent());if (castSelection) {std::vector<TXshLevel *> selectedLevels;@@ -129,7 +132,12 @@ bool getSelectedLevels(std::set<TXshLevel *> &levels, int &r0, int &c0, int &r1,levels.insert(selectedLevels[i]);return false;- } else if (cellSelection) {+ }+ else if (columnSelection) {+ TColumnSelection::getLevelSetFromColumnIndices(columnSelection->getIndices(), levels);+ return false;+ }+ else if (cellSelection) {cellSelection->getSelectedCells(r0, c0, r1, c1);for (int c = c0; c <= c1; ++c) {@@ -143,7 +151,7 @@ bool getSelectedLevels(std::set<TXshLevel *> &levels, int &r0, int &c0, int &r1,return true;}-+return false;}@@ -343,7 +351,7 @@ int Vectorizer::doVectorize() {TXshSimpleLevel *sl = m_level.getPointer();if (!sl) return 0;-+int rowCount = sl->getFrameCount();if (rowCount <= 0 || sl->isEmpty()) return 0;diff --git a/toonz/sources/toonz/vectorizerpopup.h b/toonz/sources/toonz/vectorizerpopup.hindex e79f8be2f..c94dcf130 100644--- a/toonz/sources/toonz/vectorizerpopup.h+++ b/toonz/sources/toonz/vectorizerpopup.h@@ -320,7 +320,7 @@ private:TXshSimpleLevelP m_level; //!< Input level to vectorize (only one level at a//! time is dealt here).VectorizerParameters m_params; //!< Vectorizer options to be applied-+TXshSimpleLevelP m_vLevel; //!< Output vectorized levelstd::vector<TFrameId> m_fids; //!< Frame ids of the input \b m_level