void CastTreeViewer::dragMoveEvent(QDragMoveEvent *event) { if (!event->mimeData()->hasFormat("application/vnd.toonz.levels") || m_dropFilePath != TFilePath()) return; m_dropTargetItem = itemAt(event->pos()); ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); QString rootName = QString("Root"); if (scene) { std::wstring name = (scene->isUntitled()) ? L"Untitled" : scene->getSceneName(); rootName = rootName.fromStdWString(name); } if (m_dropTargetItem && m_dropTargetItem->data(0, Qt::DisplayRole).toString() == AudioFolderName || m_dropFilePath != TFilePath() && m_dropTargetItem->data(0, Qt::DisplayRole).toString() == rootName) m_dropTargetItem = 0; if (!m_dropTargetItem) event->ignore(); else event->acceptProposedAction(); viewport()->update(); }
void FunctionViewer::refreshModel() { TXsheet *xsh = m_xshHandle ? m_xshHandle->getXsheet() : 0; m_functionGraph->getModel()->refreshData(xsh); if (xsh) { int rowCount = xsh->getFrameCount(); m_numericalColumns->setRowCount(rowCount); m_numericalColumns->updateAll(); ToonzScene *scene = xsh->getScene(); if (!scene) // This seems wrong. It should rather be return; // asserted - though I'm not touching it now... TFilePath scenePath = scene->getScenePath().getParentDir(); if (scene->isUntitled()) scenePath = TProjectManager::instance()->getCurrentProject()->getScenesPath(); m_treeView->setCurrentScenePath(scenePath); int distance, offset; scene->getProperties()->getMarkers(distance, offset); m_numericalColumns->setMarkRow(distance, offset); } m_treeView->updateAll(); m_toolbar->setCurve(0); }
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(); }
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(); } }
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; }
void MagpieFileImportPopup::onLevelPathChanged() { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); TFilePath levelPath(m_levelField->getPath().toStdWString()); levelPath = scene->decodeFilePath(levelPath); if (levelPath.isEmpty() || levelPath.getUndottedType().empty() || !TSystem::doesExistFileOrLevel(levelPath)) { DVGui::error(tr("The file path is missing.")); return; } m_levelPath = levelPath; string format = m_levelPath.getType(); if (format == "tzp" || format == "tzu") { wstring name = m_levelPath.getWideName(); IoCmd::ConvertingPopup *convertingPopup = new IoCmd::ConvertingPopup( TApp::instance()->getMainWindow(), QString::fromStdWString(name) + QString::fromStdString(m_levelPath.getDottedType())); convertingPopup->show(); bool ok = scene->convertLevelIfNeeded(m_levelPath); convertingPopup->hide(); if (!ok) return; } m_flipbook->setLevel(m_levelPath); }
TFx *InsertFxPopup::createFx() { TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); TXsheet *xsh = scene->getXsheet(); QTreeWidgetItem *item = m_fxTree->currentItem(); QString text = item->data(0, Qt::UserRole).toString(); if (text.isEmpty()) return 0; TFx *fx; TFilePath path = TFilePath(text.toStdWString()); if (TFileStatus(path).doesExist() && TFileStatus(path.getParentDir()).isDirectory()) { std::string folder = path.getParentDir().getName(); if (folder == "macroFx") //Devo caricare una macro fx = createMacroFxByPath(path); else //Verifico se devo caricare un preset { folder = path.getParentDir().getParentDir().getName(); if (folder == "presets") //Devo caricare un preset fx = createPresetFxByName(path); } } else fx = createFxByName(text.toStdString()); if (fx) return fx; else return 0; }
/*! 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(); }
void onDeliver() { if (m_error) { m_error = false; MsgBox(DVGui::CRITICAL, QObject::tr("There was an error saving frames for the %1 level.").arg(QString::fromStdWString(m_fp.withoutParentDir().getWideString()))); } bool isPreview = (m_fp.getType() == "noext"); TImageCache::instance()->remove(toString(m_fp.getWideString() + L".0")); TNotifier::instance()->notify(TSceneNameChange()); if (Preferences::instance()->isGeneratedMovieViewEnabled()) { if (!isPreview && (Preferences::instance()->isDefaultViewerEnabled()) && (m_fp.getType() == "mov" || m_fp.getType() == "avi" || m_fp.getType() == "3gp")) { QString name = QString::fromStdString(m_fp.getName()); int index; if ((index = name.indexOf("#RENDERID")) != -1) //!quite ugly I know.... m_fp = m_fp.withName(name.left(index).toStdWString()); if (!TSystem::showDocument(m_fp)) { QString msg(QObject::tr("It is not possible to display the file %1: no player associated with its format").arg(QString::fromStdWString(m_fp.withoutParentDir().getWideString()))); MsgBox(WARNING, msg); } } else { int r0, r1, step; TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); TOutputProperties &outputSettings = isPreview ? *scene->getProperties()->getPreviewProperties() : *scene->getProperties()->getOutputProperties(); outputSettings.getRange(r0, r1, step); const TRenderSettings rs = outputSettings.getRenderSettings(); if (r0 == 0 && r1 == -1) r0 = 0, r1 = scene->getFrameCount() - 1; double timeStretchFactor = isPreview ? 1.0 : (double)outputSettings.getRenderSettings().m_timeStretchTo / outputSettings.getRenderSettings().m_timeStretchFrom; r0 = tfloor(r0 * timeStretchFactor); r1 = tceil((r1 + 1) * timeStretchFactor) - 1; TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); prop->m_frameRate = outputSettings.getFrameRate(); TSoundTrack *snd = app->getCurrentXsheet()->getXsheet()->makeSound(prop); if (outputSettings.getRenderSettings().m_stereoscopic) { assert(!isPreview); ::viewFile(m_fp.withName(m_fp.getName() + "_l"), r0 + 1, r1 + 1, step, isPreview ? rs.m_shrinkX : 1, snd, 0, false, true); ::viewFile(m_fp.withName(m_fp.getName() + "_r"), r0 + 1, r1 + 1, step, isPreview ? rs.m_shrinkX : 1, snd, 0, false, true); } else ::viewFile(m_fp, r0 + 1, r1 + 1, step, isPreview ? rs.m_shrinkX : 1, snd, 0, false, true); } } }
VectorizerParameters *VectorizerPopup::getParameters() const { assert(m_sceneHandle); ToonzScene *scene = m_sceneHandle->getScene(); assert(scene); TSceneProperties *sceneProp = scene->getProperties(); assert(sceneProp); assert(sceneProp->getVectorizerParameters()); return sceneProp->getVectorizerParameters(); }
void CastTreeViewer::onSceneNameChanged() { QTreeWidgetItem *root = topLevelItem(0); if (!root) return; ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); QString rootName = QString("Root"); if (scene) { std::wstring name = (scene->isUntitled()) ? L"Untitled" : scene->getSceneName(); rootName = rootName.fromStdWString(name); } root->setText(0, rootName); }
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; }
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(); }
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)); } }
void addSoundtrack(const ToonzScene &scene, int frameOffset, int sceneFrameCount) { assert(m_status <= 2); m_status = 2; TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); prop->m_frameRate = m_fps; TSoundTrack *snd = scene.getXsheet()->makeSound(prop); if (!snd || m_filepath.getDots() == "..") { m_whiteSample += sceneFrameCount * 918; return; } long samplePerFrame = snd->getSampleRate() / m_fps; TSoundTrackP snd1 = snd->extract( frameOffset * samplePerFrame, (TINT32)((frameOffset + sceneFrameCount - 1) * samplePerFrame)); if (!m_st) { m_st = TSoundTrack::create(snd1->getFormat(), m_whiteSample); m_whiteSample = 0; } TINT32 fromSample = m_st->getSampleCount(); TINT32 numSample = std::max(TINT32(sceneFrameCount * samplePerFrame), snd1->getSampleCount()); m_st = TSop::insertBlank(m_st, fromSample, numSample + m_whiteSample); m_st->copy(snd1, TINT32(fromSample + m_whiteSample)); m_whiteSample = 0; }
void CastTreeViewer::rebuildCastTree() { clear(); ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); QString rootName = QString("Root"); if (scene) { wstring name = (scene->isUntitled()) ? L"Untitled" : scene->getSceneName(); rootName = rootName.fromStdWString(name); } QTreeWidgetItem *root = new QTreeWidgetItem((QTreeWidgetItem *)0, QStringList(rootName)); static QPixmap clapboard(":Resources/clapboard.png"); root->setIcon(0, clapboard); insertTopLevelItem(0, root); populateFolder(root); }
bool LevelCreatePopup::levelExists(std::wstring levelName) { TFilePath fp; TFilePath actualFp; ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); TLevelSet *levelSet = TApp::instance()->getCurrentScene()->getScene()->getLevelSet(); TFilePath parentDir(m_pathFld->getPath().toStdWString()); fp = scene->getDefaultLevelPath(getLevelType(), levelName) .withParentDir(parentDir); actualFp = scene->decodeFilePath(fp); if (levelSet->getLevel(levelName) != 0 || TSystem::doesExistFileOrLevel(actualFp)) { return true; } else return false; }
void FormatSettingsPopup::showEvent(QShowEvent *se) { #ifdef WIN32 if (m_format == "avi") { assert(m_codecComboBox); m_codecComboBox->blockSignals(true); m_codecComboBox->clear(); ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); TEnumProperty *eProps = dynamic_cast<TEnumProperty *>(m_props->getProperty(0)); assert(eProps); TDimension res(0, 0); if (m_levelPath.isEmpty()) res = scene->getCurrentCamera()->getRes(); else { TLevelReaderP lr(m_levelPath); TLevelP level = lr->loadInfo(); const TImageInfo *info = lr->getImageInfo(level->begin()->first); res.lx = info->m_lx; res.ly = info->m_ly; } TEnumProperty::Range range = eProps->getRange(); int currIndex = -1; wstring defaultVal = eProps->getValue(); QMap<wstring, bool> usableCodecs = AviCodecRestrictions::getUsableCodecs(res); for (int i = 0; i < (int)range.size(); i++) { wstring nameProp = range[i]; if (nameProp == L"Uncompressed" || (usableCodecs.contains(nameProp) && usableCodecs[nameProp])) { if (nameProp == defaultVal) currIndex = m_codecComboBox->count(); m_codecComboBox->addItem(QString::fromStdWString(nameProp)); } } m_codecComboBox->blockSignals(false); if (currIndex >= 0) m_codecComboBox->setCurrentIndex(currIndex); } #endif Dialog::showEvent(se); }
void CameraTab::updateImageInfo() { CleanupSettingsModel *model = CleanupSettingsModel::instance(); CleanupParameters *params = model->getCurrentParameters(); TDimension outRes(0, 0); TPointD outDpi; params->getOutputImageInfo(outRes, outDpi.x, outDpi.y); setImageInfo(outRes.lx, outRes.ly, outDpi.x, outDpi.y); TXshSimpleLevel *sl; TFrameId fid; model->getCleanupFrame(sl, fid); ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); TFilePath outputPath(sl ? scene->decodeFilePath(model->getOutputPath(sl, params)) : TFilePath()); setImageInfo(outputPath); }
void TApp::updateCurrentFrame() { ToonzScene *scene = m_currentScene->getScene(); m_currentFrame->setSceneFrameSize(scene->getFrameCount()); int f0, f1, step; scene->getProperties()->getPreviewProperties()->getRange(f0, f1, step); if (f0 > f1) { f0 = 0; f1 = scene->getFrameCount() - 1; } if (f0 != m_currentFrame->getStartFrame() || f1 != m_currentFrame->getEndFrame()) { m_currentFrame->setFrameRange(f0, f1); std::vector<TFrameId> fids; TXshSimpleLevel *sl = m_currentLevel->getSimpleLevel(); if (sl) { sl->getFids(fids); m_currentFrame->setFrameIds(fids); } } }
bool addFrame(ToonzScene &scene, int row, bool isLast) { TAffine cameraView = scene.getXsheet()->getPlacement(TStageObjectId::CameraId(0), row).inv(); TPixel32 bgColor = scene.getProperties()->getBgColor(); TStageObject *cameraPegbar = scene.getXsheet()->getStageObject(TStageObjectId::CameraId(0)); assert(cameraPegbar); TCamera *camera = cameraPegbar->getCamera(); assert(camera); TAffine dpiAff = getDpiAffine(camera).inv(); TAffine aff = cameraView * dpiAff; Stage::VisitArgs args; args.m_scene = &scene; args.m_xsh = scene.getXsheet(); args.m_row = row; args.m_col = m_columnIndex; args.m_osm = &m_osMask; ImagePainter::VisualSettings vs; FlashStagePainter painter(m_flash, aff, vs, bgColor); m_flash.beginFrame(++m_frameIndex); Stage::visit(painter, args); /* &scene, scene.getXsheet(), row, m_columnIndex, m_osMask, false, 0); */ m_frameIndex = m_flash.endFrame(isLast, m_frameCountLoader, (m_sceneCount == m_sceneIndex)); return true; }
static void printCurrentFrame() { QPrinter printer; QPrintDialog dialog(&printer, 0); if (!dialog.exec()) return; ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); int frame = TApp::instance()->getCurrentFrame()->getFrame(); int lx = TApp::instance() ->getCurrentScene() ->getScene() ->getCurrentCamera() ->getRes() .lx; int ly = TApp::instance() ->getCurrentScene() ->getScene() ->getCurrentCamera() ->getRes() .ly; TRaster32P raster(lx, ly); if (scene->getFrameCount() <= 0) { // Ricordarsi di usare DvMsgBox !! (se si decommenta questo codice :) ) // QMessageBox::warning(0,"Print",tr("It is not possible to generate an // animation\nbecause the scene is empty.", "WARNING")); return; } raster->fill(scene->getProperties()->getBgColor()); scene->renderFrame(raster, frame, TApp::instance()->getCurrentXsheet()->getXsheet()); QImage img = rasterToQImage(raster); QPainter painter(&printer); QRect rect = painter.viewport(); QSize size = img.size(); size.scale(rect.size(), Qt::KeepAspectRatio); painter.setViewport(rect.x(), rect.y(), size.width(), size.height()); painter.setWindow(img.rect()); painter.drawImage(0, 0, img); }
QScriptValue foo(QScriptContext *ctx, QScriptEngine *eng) { int r = ctx->argument(0).toInteger(); int c = ctx->argument(1).toInteger(); QScriptValue levelArg = ctx->argument(2); ScriptWrapper::Level *level = dynamic_cast<ScriptWrapper::Level *>(levelArg.toQObject()); if (level) { TXshSimpleLevel *sl = level->getLevel(); if (!sl) return QScriptValue(0); TFrameId fid(1); if (!sl->isFid(fid)) sl->setFrame(fid, sl->createEmptyFrame()); ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); scene->getXsheet()->setCell(r, c, TXshCell(sl, fid)); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); } return QScriptValue(1); }
void TApp::autosave() { ToonzScene *scene = getCurrentScene()->getScene(); if (!getCurrentScene()->getDirtyFlag()) return; if (getCurrentTool()->isToolBusy()) { m_autosaveSuspended = true; return; } else m_autosaveSuspended = false; if (scene->isUntitled()) { DVGui::warning( tr("It is not possible to save automatically an untitled scene.")); return; } DVGui::ProgressDialog pb( "Autosaving scene..." + toQString(scene->getScenePath()), 0, 0, 1); pb.show(); IoCmd::saveScene(); pb.setValue(1); }
void start(const ToonzScene &scene) { m_status = 3; m_alphaNeeded = scene.getProperties()->getBgColor().m < 255; assert(m_started == false); m_started = true; if (TSystem::doesExistFileOrLevel(m_filepath)) TSystem::removeFileOrLevel(m_filepath); m_lw = TLevelWriterP(m_filepath); m_lw->setFrameRate(m_fps); if (m_lw->getProperties() && m_fileOptions) m_lw->getProperties()->setProperties(m_fileOptions); if (m_st) m_lw->saveSoundTrack(m_st.getPointer()); }
void startScene(const ToonzScene &scene, int r) { m_flash.cleanCachedImages(); m_flash.setBackgroundColor(m_bgColor); TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); prop->m_frameRate = m_fps; TSoundTrackP snd = scene.getXsheet()->makeSound(prop); if (snd) { if (m_useMarkers) { long samplePerFrame = snd->getSampleRate() / m_fps; snd = snd->extract((TINT32)(m_renderRange.first * samplePerFrame), (TINT32)(m_renderRange.second * samplePerFrame)); } m_flash.putSound(snd, 0); } if (m_sceneIndex == 0 && m_sceneCount == 1) { if (m_renderRange.first == m_renderRange.second) m_frameCountLoader = 0; else m_frameCountLoader = 1; } else if (m_sceneIndex == 0) m_frameCountLoader = m_renderRange.second - m_renderRange.first + 1; m_sceneIndex++; }
void ColumnCmd::cloneChild(int index) { if (!canResequence(index)) return; /*-- カラムを取得 --*/ TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); TXshColumn *column = xsh->getColumn(index); assert(column); // get the subxsheet to clone (childLevel, childXsh) /*-- SubXsheetレベルを取得 --*/ TXshLevelColumn *lcolumn = column->getLevelColumn(); assert(lcolumn); int r0 = 0, r1 = -1; lcolumn->getRange(r0, r1); assert(r0 <= r1); /*-- SubXsheetの一番頭のセル --*/ TXshCell cell = lcolumn->getCell(r0); assert(!cell.isEmpty()); /*- cell内に格納されているLevelを取得 -*/ TXshChildLevel *childLevel = cell.m_level->getChildLevel(); assert(childLevel); /*- SubXsheetのXsheetを取得 -*/ TXsheet *childXsh = childLevel->getXsheet(); // insert a new empty column /*- 隣に空きColumnをInsertしてCloneに備える -*/ int newColumnIndex = index + 1; xsh->insertColumn(newColumnIndex); // create a subxsheet (newChildLevel, newChildXsh) ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); ChildStack *childStack = scene->getChildStack(); TXshChildLevel *newChildLevel = childStack->createChild(0, newColumnIndex); TXsheet *newChildXsh = newChildLevel->getXsheet(); // copy columns. std::set<int> indices; for (int i = 0; i < childXsh->getColumnCount(); i++) indices.insert(i); StageObjectsData *data = new StageObjectsData(); data->storeColumns(indices, childXsh, 0); data->storeColumnFxs(indices, childXsh, 0); std::list<int> restoredSplineIds; data->restoreObjects(indices, restoredSplineIds, newChildXsh, StageObjectsData::eDoClone); delete data; cloneNotColumnLinkedFxsAndOutputsFx(childXsh, newChildXsh); cloneXsheetTStageObjectTree(childXsh, newChildXsh); /*--以下は、Clone SubXsheet するときに、SubXsheet内にある子SubXsheetをクローンする関数 クローンされた中にある子SubXsheetは、同じもので良いので、スキップする --*/ // cloneSubXsheets(newChildXsh); /*-- XSheetノードのFxSchematicでのDagNodePosを再現 FxやColumnノードの位置の再現は上のsetColumnで行っている --*/ newChildXsh->getFxDag()->getXsheetFx()->getAttributes()->setDagNodePos( childXsh->getFxDag()->getXsheetFx()->getAttributes()->getDagNodePos()); newChildXsh->updateFrameCount(); /*-- TXshChildLevel作成時にsetCellした1つ目のセルを消去 --*/ xsh->removeCells(0, newColumnIndex); /*-- CloneしたColumnのセル番号順を再現 --*/ for (int r = r0; r <= r1; r++) { TXshCell cell = lcolumn->getCell(r); if (cell.isEmpty()) continue; cell.m_level = newChildLevel; xsh->setCell(r, newColumnIndex, cell); } TStageObjectId currentObjectId = TApp::instance()->getCurrentObject()->getObjectId(); xsh->getStageObject(TStageObjectId::ColumnId(newColumnIndex)) ->setParent(xsh->getStageObjectParent(currentObjectId)); xsh->updateFrameCount(); TUndoManager::manager()->add( new CloneChildUndo(newChildLevel, newColumnIndex)); // notify changes TApp::instance()->getCurrentScene()->setDirtyFlag(true); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); }
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); if (lType == TZP_XSHLEVEL || lType == OVL_XSHLEVEL) { sl->getProperties()->setDpiPolicy(LevelProperties::DP_ImageDpi); sl->getProperties()->setDpi(dpi); sl->getProperties()->setImageDpi(TPointD(dpi, dpi)); sl->getProperties()->setImageRes(TDimension(xres, yres)); } /*-- これからLevelを配置しようとしているセルが空いているかどうかのチェック * --*/ bool areColumnsShifted = false; TXshCell cell = xsh->getCell(row, col); bool isInRange = true; for (i = row; i < row + numFrames; i++) { if (!cell.isEmpty()) { isInRange = false; break; } cell = xsh->getCell(i, col); } if (!validColumn) { isInRange = false; } /*-- 別のLevelに占有されていた場合、Columnを1つ右に移動 --*/ if (!isInRange) { col += 1; TApp::instance()->getCurrentColumn()->setColumnIndex(col); areColumnsShifted = true; xsh->insertColumn(col); } CreateLevelUndo *undo = new CreateLevelUndo(row, col, numFrames, step, areColumnsShifted); TUndoManager::manager()->add(undo); for (i = from; i <= to; i += inc) { TFrameId fid(i); TXshCell cell(sl, fid); if (lType == PLI_XSHLEVEL) sl->setFrame(fid, new TVectorImage()); else if (lType == TZP_XSHLEVEL) { TRasterCM32P raster(xres, yres); raster->fill(TPixelCM32()); TToonzImageP ti(raster, TRect()); ti->setDpi(dpi, dpi); sl->setFrame(fid, ti); ti->setSavebox(TRect(0, 0, xres - 1, yres - 1)); } else if (lType == OVL_XSHLEVEL) { TRaster32P raster(xres, yres); raster->clear(); TRasterImageP ri(raster); ri->setDpi(dpi, dpi); sl->setFrame(fid, ri); } for (j = 0; j < step; j++) xsh->setCell(row++, col, cell); } if (lType == TZP_XSHLEVEL || lType == OVL_XSHLEVEL) { sl->save(fp); DvDirModel::instance()->refreshFolder(fp.getParentDir()); } undo->onAdd(sl); app->getCurrentScene()->notifySceneChanged(); app->getCurrentScene()->notifyCastChange(); app->getCurrentXsheet()->notifyXsheetChanged(); // Cambia l'immagine corrente ma non cambiano ne' il frame ne' la colonna // corrente // (entrambi notificano il cambiamento dell'immagine al tool). // devo verfificare che sia settato il tool giusto. app->getCurrentTool()->onImageChanged( (TImage::Type)app->getCurrentImageType()); return true; }
void LevelCreatePopup::updatePath() { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); TFilePath defaultPath; defaultPath = scene->getDefaultLevelPath(getLevelType()).getParentDir(); m_pathFld->setPath(toQString(defaultPath)); }
//!Specialized render invocation for multimedia rendering. Flash rendering //!is currently not supported in this mode. void RenderCommand::multimediaRender() { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); string ext = m_fp.getType(); #ifdef WIN32 if (ext == "avi") { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); MsgBox(WARNING, msg); return; } } #endif; TOutputProperties *prop = scene->getProperties()->getOutputProperties(); //Build thread count int index = prop->getThreadIndex(); const int procCount = TSystem::getProcessorCount(); const int threadCounts[3] = {1, procCount / 2, procCount}; int threadCount = threadCounts[index]; //Build raster granularity size index = prop->getMaxTileSizeIndex(); const int maxTileSizes[4] = { (std::numeric_limits<int>::max)(), TOutputProperties::LargeVal, TOutputProperties::MediumVal, TOutputProperties::SmallVal}; TRenderSettings rs = prop->getRenderSettings(); rs.m_maxTileSize = maxTileSizes[index]; MultimediaRenderer multimediaRenderer(scene, m_fp, prop->getMultimediaRendering(), threadCount); multimediaRenderer.setRenderSettings(rs); #ifdef BRAVODEMO rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes()); #endif TPointD cameraDpi = scene->getCurrentCamera()->getDpi(); multimediaRenderer.setDpi(cameraDpi.x, cameraDpi.y); multimediaRenderer.enablePrecomputing(true); for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd) multimediaRenderer.addFrame(m_r); MultimediaProgressBar *listener = new MultimediaProgressBar(&multimediaRenderer); QObject::connect(listener, SIGNAL(canceled()), &multimediaRenderer, SLOT(onCanceled())); multimediaRenderer.addListener(listener); multimediaRenderer.start(); }