本文整理汇总了C++中ToonzScene::createNewLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ ToonzScene::createNewLevel方法的具体用法?C++ ToonzScene::createNewLevel怎么用?C++ ToonzScene::createNewLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToonzScene
的用法示例。
在下文中一共展示了ToonzScene::createNewLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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);
//.........这里部分代码省略.........
示例3: 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;
}
示例4: while
//.........这里部分代码省略.........
TFrameId fid = getNewFrameId(sl, row);
// create the new drawing
TImageP img = sl->createEmptyFrame();
m_isFrameCreated = true;
// insert the drawing in the level
sl->setFrame(fid, img);
// update the cell
cell = TXshCell(sl, fid);
xsh->setCell(row, col, cell);
// create holds
if (!isAutoStretchEnabled) {
m_cellsData.push_back(row);
m_cellsData.push_back(row);
m_cellsData.push_back(2); // vuoto => nuovo
} else {
if (a >= r0) {
// create a hold before : [a+1, row-1]
TXshCell aCell = xsh->getCell(a, col);
for (int i = a + 1; i < row; i++) xsh->setCell(i, col, aCell);
m_cellsData.push_back(a + 1);
m_cellsData.push_back(row - 1);
m_cellsData.push_back(1); // vuoto => vecchio
if (b <= r1 && xsh->getCell(b, col).getSimpleLevel() == sl) {
// create also a hold after
for (int i = row + 1; i < b; i++) xsh->setCell(i, col, cell);
m_cellsData.push_back(row);
m_cellsData.push_back(b - 1);
m_cellsData.push_back(2); // vuoto => nuovo
} else {
m_cellsData.push_back(row);
m_cellsData.push_back(row);
m_cellsData.push_back(2); // vuoto => nuovo
}
} else if (b <= r1) {
// create a hold after
for (int i = row + 1; i < b; i++) xsh->setCell(i, col, cell);
m_cellsData.push_back(row);
m_cellsData.push_back(b - 1);
m_cellsData.push_back(2); // vuoto => nuovo
}
}
}
// notify & return
currentXsheet->notifyXsheetChanged();
currentScene->notifyCastChange();
currentLevel->notifyLevelChange();
return cell.getImage(true).getPointer();
}
if (row > 0 && xsh->getCell(row - 1, col).getSimpleLevel() != 0 &&
!animationSheetEnabled) {
sl = xsh->getCell(row - 1, col).getSimpleLevel();
if (sl->getType() != OVL_XSHLEVEL ||
sl->getPath().getFrame() != TFrameId::NO_FRAME) {
// la cella precedente contiene un drawing di un livello. animationSheet
// e' disabilitato
// creo un nuovo frame
currentLevel->setLevel(sl);
if (sl->isSubsequence() || sl->isReadOnly()) return 0;
TFrameId fid = sl->index2fid(sl->getFrameCount());
TImageP img = sl->createEmptyFrame();
m_isFrameCreated = true;
sl->setFrame(fid, img);
cell = TXshCell(sl, fid);
xsh->setCell(row, col, cell);
currentXsheet->notifyXsheetChanged();
currentScene->notifyCastChange();
currentLevel->notifyLevelChange();
return img.getPointer();
}
}
// animation sheet disabled or empty column. autoCreate is enabled: we must
// create a new level
int levelType = pref->getDefLevelType();
TXshLevel *xl = scene->createNewLevel(levelType);
sl = xl->getSimpleLevel();
m_isLevelCreated = true;
// create the drawing
TFrameId fid = animationSheetEnabled ? getNewFrameId(sl, row) : TFrameId(1);
TImageP img = sl->createEmptyFrame();
m_isFrameCreated = true;
sl->setFrame(fid, img);
cell = TXshCell(sl, fid);
xsh->setCell(row, col, cell);
if (animationSheetEnabled) {
m_cellsData.push_back(row);
m_cellsData.push_back(row);
m_cellsData.push_back(2); // vuoto => nuovo
}
currentXsheet->notifyXsheetChanged();
currentScene->notifyCastChange();
currentLevel->notifyLevelChange();
return img.getPointer();
}
}