本文整理汇总了C++中ToonzScene::getLevelSet方法的典型用法代码示例。如果您正苦于以下问题:C++ ToonzScene::getLevelSet方法的具体用法?C++ ToonzScene::getLevelSet怎么用?C++ ToonzScene::getLevelSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToonzScene
的用法示例。
在下文中一共展示了ToonzScene::getLevelSet方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void execute()
{
TApp *app = TApp::instance();
ToonzScene *scene = app->getCurrentScene()->getScene();
TLevelSet *levelSet = scene->getLevelSet();
std::set<TXshLevel *> usedLevels;
scene->getTopXsheet()->getUsedLevels(usedLevels);
std::vector<TXshLevel *> unused;
for (int i = 0; i < levelSet->getLevelCount(); i++) {
TXshLevel *xl = levelSet->getLevel(i);
if (usedLevels.count(xl) == 0)
unused.push_back(xl);
}
if (unused.empty()) {
DVGui::error(QObject::tr("No unused levels"));
return;
} else {
TUndoManager *um = TUndoManager::manager();
um->beginBlock();
for (int i = 0; i < (int)unused.size(); i++) {
TXshLevel *xl = unused[i];
um->add(new DeleteLevelUndo(xl));
scene->getLevelSet()->removeLevel(xl);
}
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
TApp::instance()->getCurrentScene()->notifyCastChange();
um->endBlock();
}
}
示例2: updateAllLinkedStyles
void StudioPaletteCmd::updateAllLinkedStyles(TPaletteHandle *paletteHandle,
TXsheetHandle *xsheetHandle) {
if (!xsheetHandle) return;
TXsheet *xsheet = xsheetHandle->getXsheet();
if (!xsheet) return;
ToonzScene *scene = xsheet->getScene();
if (!scene) return;
// emit signal only if something changed
bool somethingChanged = false;
StudioPalette *sp = StudioPalette::instance();
TLevelSet *levelSet = scene->getLevelSet();
for (int i = 0; i < levelSet->getLevelCount(); i++) {
TXshLevel *xl = levelSet->getLevel(i);
TXshSimpleLevel *sl = xl ? xl->getSimpleLevel() : 0;
if (!sl) continue;
TPalette *palette = sl->getPalette();
if (palette) {
somethingChanged = somethingChanged | sp->updateLinkedColors(palette);
if (sl->getType() == TZP_XSHLEVEL) {
std::vector<TFrameId> fids;
sl->getFids(fids);
std::vector<TFrameId>::iterator it;
for (it = fids.begin(); it != fids.end(); ++it) {
TFrameId fid = *it;
std::string id = sl->getImageId(fid);
}
}
}
}
if (!paletteHandle || !paletteHandle->getPalette()) return;
if (somethingChanged) paletteHandle->notifyColorStyleChanged();
}
示例3:
TXshSimpleLevel *Level::getLevel() const
{
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
TXshLevel *level = scene->getLevelSet()->getLevel(m_name.toStdWString());
TXshSimpleLevel *sl = dynamic_cast<TXshSimpleLevel *>(level);
return sl;
}
示例4: updateChooseLevelComboItems
/*! update combo items when the contents of scene cast are changed
*/
void Filmstrip::updateChooseLevelComboItems() {
// clear items
m_chooseLevelCombo->clear();
m_levels.clear();
std::map<TXshSimpleLevel *, TFrameId> new_workingFrames;
// correct and register items
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
if (scene) {
std::vector<TXshLevel *> levels;
scene->getLevelSet()->listLevels(levels);
std::vector<TXshLevel *>::iterator it;
for (it = levels.begin(); it != levels.end(); ++it) {
// register only TLV and PLI
TXshSimpleLevel *sl = (*it)->getSimpleLevel();
if (sl) {
// register only used level in xsheet
if (!scene->getTopXsheet()->isLevelUsed(sl)) continue;
m_levels.push_back(sl);
// create new m_workingFrames map with the new levelset
TFrameId fId;
std::map<TXshSimpleLevel *, TFrameId>::iterator WFit =
m_workingFrames.find(sl);
if (WFit != m_workingFrames.end())
fId = WFit->second;
else
fId = sl->getFirstFid();
new_workingFrames.insert(std::make_pair(sl, fId));
QString levelName = QString::fromStdWString(sl->getName());
if (sl->getProperties()->getDirtyFlag()) levelName += " *";
// append the current working frame number to the item name
if (fId != sl->getFirstFid() && fId.getNumber() >= 0)
levelName +=
QString(" [#") + QString::number(fId.getNumber()) + QString("]");
m_chooseLevelCombo->addItem(levelName);
}
}
}
m_chooseLevelCombo->addItem(tr("- No Current Level -"));
// swap the list
m_workingFrames.clear();
m_workingFrames = new_workingFrames;
// synchronize the current index of combo to the current level
updateCurrentLevelComboItem();
}
示例5: removeLevel
bool removeLevel(TXshLevel *level)
{
TApp *app = TApp::instance();
ToonzScene *scene = app->getCurrentScene()->getScene();
if (scene->getChildStack()->getTopXsheet()->isLevelUsed(level))
DVGui::error(QObject::tr("It is not possible to delete the used level %1.").arg(QString::fromStdWString(level->getName()))); //"E_CantDeleteUsedLevel_%1"
else {
TUndoManager *um = TUndoManager::manager();
um->add(new DeleteLevelUndo(level));
scene->getLevelSet()->removeLevel(level);
}
return true;
}
示例6: getLevel
QScriptValue getLevel(QScriptContext *ctx, QScriptEngine *eng)
{
QString levelName = ctx->argument(0).toString();
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
TXshLevel *level = scene->getLevelSet()->getLevel(levelName.toStdWString());
if (!level) {
level = scene->createNewLevel(PLI_XSHLEVEL, levelName.toStdWString());
levelName = QString::fromStdWString(level->getName());
}
if (level->getSimpleLevel())
return eng->newQObject(new ScriptWrapper::Level(level->getSimpleLevel()), QScriptEngine::ScriptOwnership);
else
return QScriptValue();
}
示例7: getResources
void SceneResources::getResources() {
ToonzScene *scene = m_scene;
std::vector<TXshLevel *> levels;
scene->getLevelSet()->listLevels(levels);
std::vector<TXshLevel *>::iterator it;
for (it = levels.begin(); it != levels.end(); ++it) {
TXshSimpleLevel *sl = (*it)->getSimpleLevel();
if (sl) m_resources.push_back(new SceneLevel(scene, sl));
TXshPaletteLevel *pl = (*it)->getPaletteLevel();
if (pl) m_resources.push_back(new ScenePalette(scene, pl));
TXshSoundLevel *sdl = (*it)->getSoundLevel();
if (sdl) m_resources.push_back(new SceneSound(scene, sdl));
}
}
示例8: apply
bool LevelCreatePopup::apply() {
TApp *app = TApp::instance();
int row = app->getCurrentFrame()->getFrame();
int col = app->getCurrentColumn()->getColumnIndex();
int i, j;
ToonzScene *scene = app->getCurrentScene()->getScene();
TXsheet *xsh = scene->getXsheet();
bool validColumn = true;
if (xsh->getColumn(col))
validColumn =
xsh->getColumn(col)->getColumnType() == TXshColumn::eLevelType;
int from = (int)m_fromFld->getValue();
int to = (int)m_toFld->getValue();
int inc = (int)m_incFld->getValue();
int step = (int)m_stepFld->getValue();
double w = m_widthFld->getValue();
double h = m_heightFld->getValue();
double dpi = m_dpiFld->getValue();
int xres = std::max(tround(w * dpi), 1);
int yres = std::max(tround(h * dpi), 1);
int lType = getLevelType();
std::wstring levelName = m_nameFld->text().toStdWString();
// tolgo i blanks prima e dopo
i = levelName.find_first_not_of(L' ');
if (i == (int)std::wstring::npos)
levelName = L"";
else {
int j = levelName.find_last_not_of(L' ');
assert(j != (int)std::wstring::npos);
levelName = levelName.substr(i, j - i + 1);
}
if (levelName.empty()) {
error(tr("No level name specified: please choose a valid level name"));
return false;
}
if (from > to) {
error(tr("Invalid frame range"));
return false;
}
if (inc <= 0) {
error(tr("Invalid increment value"));
return false;
}
if (step <= 0) {
error(tr("Invalid step value"));
return false;
}
int numFrames = step * (((to - from) / inc) + 1);
if (scene->getLevelSet()->getLevel(levelName)) {
error(
tr("The level name specified is already used: please choose a "
"different level name"));
m_nameFld->selectAll();
return false;
}
TFilePath parentDir(m_pathFld->getPath().toStdWString());
TFilePath fp =
scene->getDefaultLevelPath(lType, levelName).withParentDir(parentDir);
TFilePath actualFp = scene->decodeFilePath(fp);
if (TSystem::doesExistFileOrLevel(actualFp)) {
error(
tr("The level name specified is already used: please choose a "
"different level name"));
m_nameFld->selectAll();
return false;
}
parentDir = scene->decodeFilePath(parentDir);
if (!TFileStatus(parentDir).doesExist()) {
QString question;
/*question = "Folder " +toQString(parentDir) +
" doesn't exist.\nDo you
want to create it?";*/
question = tr("Folder %1 doesn't exist.\nDo you want to create it?")
.arg(toQString(parentDir));
int ret = DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No"));
if (ret == 0 || ret == 2) return false;
try {
TSystem::mkDir(parentDir);
DvDirModel::instance()->refreshFolder(parentDir.getParentDir());
} catch (...) {
error(tr("Unable to create") + toQString(parentDir));
return false;
}
}
TXshLevel *level =
scene->createNewLevel(lType, levelName, TDimension(), 0, fp);
TXshSimpleLevel *sl = dynamic_cast<TXshSimpleLevel *>(level);
assert(sl);
sl->setPath(fp, true);
//.........这里部分代码省略.........
示例9: setLevel
void Vectorizer::setLevel(const TXshSimpleLevelP &level)
{
m_level = level;
//Creo il livello pli
TXshSimpleLevel *sl = m_level.getPointer();
if (!sl)
return;
int rowCount = sl->getFrameCount();
if (rowCount <= 0 || sl->isEmpty())
return;
TXshLevel *xl;
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
// Build the new level name
wstring levelName = sl->getName() + L"v";
{
std::auto_ptr<NameBuilder> nameBuilder(NameBuilder::getBuilder(levelName));
for (;;) {
levelName = nameBuilder->getNext();
if (scene->getLevelSet()->getLevel(levelName) == 0)
break;
}
}
TFilePath dstPath = sl->getPath().withName(levelName).withType("pli");
dstPath = scene->decodeFilePath(dstPath);
bool overWrite = false;
if (TSystem::doesExistFileOrLevel(dstPath)) {
m_dialogShown = true;
std::wstring name = m_dialog->execute(scene, dstPath, true);
if (m_dialog->cancelPressed())
return;
switch (m_dialog->getChoice()) {
case OverwriteDialog::KEEP_OLD: {
xl = scene->getLevelSet()->getLevel(levelName);
if (!xl)
xl = scene->loadLevel(dstPath);
m_vLevel = xl->getSimpleLevel();
return;
}
CASE OverwriteDialog::OVERWRITE : overWrite = true;
DEFAULT:
levelName = name;
}
}
xl = scene->createNewLevel(PLI_XSHLEVEL, levelName);
TXshSimpleLevel *vl = xl->getSimpleLevel();
assert(vl);
if (overWrite) {
vl->setPath(scene->codeFilePath(dstPath));
vl->setName(levelName);
}
TPalette *palette = 0;
if (sl->getType() == TZP_XSHLEVEL)
palette = sl->getPalette();
palette = palette ? palette->clone() : new TPalette;
palette->setPaletteName(vl->getName());
vl->setPalette(palette);
m_vLevel = vl;
}
示例10: mergeColumns
void mergeColumns(int column, int mColumn, bool isRedo)
{
MergeColumnsSessionId++;
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
int start, end;
xsh->getCellRange(column, start, end);
if (start > end)
return;
vector<TXshCell> cell(end - start + 1);
vector<TXshCell> mCell(end - start + 1);
xsh->getCells(start, column, cell.size(), &(cell[0]));
xsh->getCells(start, mColumn, cell.size(), &(mCell[0]));
TXshColumn *col = xsh->getColumn(column);
TXshColumn *mcol = xsh->getColumn(mColumn);
vector<MatchlinePair> matchingLevels;
std::set<TFrameId> alreadyDoneSet;
TXshSimpleLevel *level = 0, *mLevel = 0;
TXshLevelP xl;
bool areRasters = false;
std::map<TFrameId, QString> images;
for (int i = 0; i < (int)cell.size(); i++) {
if (cell[i].isEmpty() || mCell[i].isEmpty())
continue;
if (!level) {
level = cell[i].getSimpleLevel();
xl = cell[i].m_level;
}
else if (level != cell[i].getSimpleLevel()) {
MsgBox(WARNING, QObject::tr("It is not possible to perform a merging involving more than one level per column."));
return;
}
if (!mLevel)
mLevel = mCell[i].getSimpleLevel();
else if (mLevel != mCell[i].getSimpleLevel()) {
MsgBox(WARNING, QObject::tr("It is not possible to perform a merging involving more than one level per column."));
return;
}
TImageP img = cell[i].getImage(true);
TImageP match = mCell[i].getImage(false);
TFrameId fid = cell[i].m_frameId;
TFrameId mFid = mCell[i].m_frameId;
if (!img || !match)
continue;
if (alreadyDoneSet.find(fid) == alreadyDoneSet.end()) {
TRasterImageP timg = (TRasterImageP)img;
TRasterImageP tmatch = (TRasterImageP)match;
TVectorImageP vimg = (TVectorImageP)img;
TVectorImageP vmatch = (TVectorImageP)match;
if (timg) {
if (!tmatch) {
MsgBox(WARNING, QObject::tr("Only raster levels can be merged to a raster level."));
return;
}
areRasters = true;
} else if (vimg) {
if (!vmatch) {
MsgBox(WARNING, QObject::tr("Only vector levels can be merged to a vector level."));
return;
}
} else {
MsgBox(WARNING, QObject::tr("It is possible to merge only Toonz vector levels or standard raster levels."));
return;
}
QString id = "MergeColumnsUndo" + QString::number(MergeColumnsSessionId) + "-" + QString::number(fid.getNumber());
TImageCache::instance()->add(id, (timg) ? timg->cloneImage() : vimg->cloneImage());
images[fid] = id;
TAffine imgAff, matchAff;
getColumnPlacement(imgAff, xsh, start + i, column, false);
getColumnPlacement(matchAff, xsh, start + i, mColumn, false);
TAffine dpiAff = getDpiAffine(level, fid);
TAffine mdpiAff = getDpiAffine(mLevel, mFid);
matchingLevels.push_back(MatchlinePair(cell[i], imgAff * dpiAff, mCell[i], matchAff * mdpiAff));
alreadyDoneSet.insert(fid);
}
}
if (matchingLevels.empty()) {
MsgBox(WARNING, QObject::tr("It is possible to merge only Toonz vector levels or standard raster levels."));
return;
}
ToonzScene *sc = TApp::instance()->getCurrentScene()->getScene();
TXshSimpleLevel *simpleLevel = sc->getLevelSet()->getLevel(column)->getSimpleLevel();
if (!isRedo)
//.........这里部分代码省略.........