std::wstring OverwriteDialog::execute(ToonzScene *scene, const TFilePath &srcLevelPath, bool multiload) { TFilePath levelPath = srcLevelPath; TFilePath actualLevelPath = scene->decodeFilePath(levelPath); if (!TSystem::doesExistFileOrLevel(actualLevelPath)) return levelPath.getWideName(); if (m_applyToAll && m_choice == RENAME) { levelPath = addSuffix(levelPath); actualLevelPath = scene->decodeFilePath(levelPath); } if (m_applyToAll) { if (m_choice != RENAME || !TSystem::doesExistFileOrLevel(actualLevelPath)) return levelPath.getWideName(); } m_label->setText(tr("File %1 already exists.\nWhat do you want to do?").arg(toQString(levelPath))); // find a compatible suffix if (TSystem::doesExistFileOrLevel(actualLevelPath)) { int i = 0; while (TSystem::doesExistFileOrLevel(scene->decodeFilePath(addSuffix(srcLevelPath)))) { m_suffix->setText("_" + QString::number(++i)); } } if (multiload) m_okToAllBtn->show(); else m_okToAllBtn->hide(); // there could be a WaitCursor cursor QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); raise(); exec(); QApplication::restoreOverrideCursor(); if (m_rename->isChecked()) { if (m_suffix->text() == "") { MsgBox(WARNING, tr("The suffix field is empty. Please specify a suffix.")); return execute(scene, srcLevelPath, multiload); } levelPath = addSuffix(srcLevelPath); actualLevelPath = scene->decodeFilePath(levelPath); if (TSystem::doesExistFileOrLevel(actualLevelPath)) { MsgBox(WARNING, tr("File %1 exists as well; please choose a different suffix.").arg(toQString(levelPath))); return execute(scene, srcLevelPath, multiload); } m_choice = RENAME; } else if (m_overwrite->isChecked()) m_choice = OVERWRITE; else { assert(m_keep->isChecked()); m_choice = KEEP_OLD; } return levelPath.getWideName(); }
bool TSystem::doesExistFileOrLevel(const TFilePath &fp) { if (TFileStatus(fp).doesExist()) return true; if (fp.isLevelName()) { const TFilePath &parentDir = fp.getParentDir(); if (!TFileStatus(parentDir).doesExist()) return false; TFilePathSet files; try { files = TSystem::readDirectory(parentDir, false, true, true); } catch (...) { } TFilePathSet::iterator it, end = files.end(); for (it = files.begin(); it != end; ++it) { if (it->getLevelNameW() == fp.getLevelNameW()) return true; } } else if (fp.getType() == "psd") { QString name(QString::fromStdWString(fp.getWideName())); name.append(QString::fromStdString(fp.getDottedType())); int sepPos = name.indexOf("#"); int dotPos = name.indexOf(".", sepPos); int removeChars = dotPos - sepPos; int doubleUnderscorePos = name.indexOf("__", sepPos); if (doubleUnderscorePos > 0) removeChars = doubleUnderscorePos - sepPos; name.remove(sepPos, removeChars); TFilePath psdpath(fp.getParentDir() + TFilePath(name.toStdWString())); if (TFileStatus(psdpath).doesExist()) return true; } return false; }
void RenderCommand::doRender(bool isPreview) { bool isWritable = true; bool isMultiFrame; /*-- 初期化処理。フレーム範囲の計算や、Renderの場合はOutputSettingsから保存先パスも作る --*/ if (!init(isPreview)) return; if (m_fp.getDots() == ".") { isMultiFrame = false; TFileStatus fs(m_fp); if (fs.doesExist()) isWritable = fs.isWritable(); } else { isMultiFrame = true; TFilePath dir = m_fp.getParentDir(); QDir qDir(QString::fromStdWString(dir.getWideString())); QString levelName = QRegExp::escape(QString::fromStdWString(m_fp.getWideName())); QString levelType = QString::fromStdString(m_fp.getType()); QString exp(levelName + ".[0-9]{1,4}." + levelType); QRegExp regExp(exp); QStringList list = qDir.entryList(QDir::Files); QStringList livelFrames = list.filter(regExp); int i; for (i = 0; i < livelFrames.size() && isWritable; i++) { TFilePath frame = dir + TFilePath(livelFrames[i].toStdWString()); if (frame.isEmpty() || !frame.isAbsolute()) continue; TFileStatus fs(frame); isWritable = fs.isWritable(); } } if (!isWritable) { string str = "It is not possible to write the output: the file"; str += isMultiFrame ? "s are read only." : " is read only."; MsgBox(WARNING, QString::fromStdString(str)); return; } ToonzScene *scene = 0; TCamera *camera = 0; try { /*-- Xsheetノードに繋がっている各ラインごとに計算するモード。 MultipleRender で Schematic Flows または Fx Schematic Terminal Nodes が選択されている場合 --*/ if (m_multimediaRender && m_fp.getType() != "swf") //swf is not currently supported on multimedia... multimediaRender(); else if (!isPreview && m_fp.getType() == "swf") flashRender(); else /*-- 通常のRendering --*/ rasterRender(isPreview); } catch (TException &e) { MsgBox(WARNING, QString::fromStdString(toString(e.getMessage()))); } catch (...) { MsgBox(WARNING, QObject::tr("It is not possible to complete the rendering.")); } }
/*! Returns the folder's name of the specified TFilePath \b folderDir.\n Returns the empty string if \b folderDir isn't a folder of the project.*/ wstring TProject::getFolderNameFromPath(const TFilePath &folderDir) { int index = getFolderIndexFromPath(folderDir); if (index < 0) return L""; if (getFolder(index).isAbsolute()) return ::to_wstring("+" + getFolderName(index)); else return folderDir.getWideName(); }
void StudioPaletteTreeViewer::dropEvent(QDropEvent *event) { TFilePath newPath = getItemPath(m_dropItem); resetDropItem(); if (newPath.isEmpty()) return; const QMimeData *mimeData = event->mimeData(); const PaletteData *paletteData = dynamic_cast<const PaletteData *>(mimeData); if (paletteData) { if (paletteData->hasOnlyPalette()) { TPalette *palette = paletteData->getPalette(); if (!palette) return; try { StudioPaletteCmd::createPalette( newPath, ::to_string(palette->getPaletteName()), palette); } catch (TException &e) { error("Can't create palette: " + QString(::to_string(e.getMessage()).c_str())); } catch (...) { error("Can't create palette"); } } return; } if (!mimeData->hasUrls() || mimeData->urls().size() == 0) return; QList<QUrl> urls = mimeData->urls(); TUndoManager::manager()->beginBlock(); int i; for (i = 0; i < urls.size(); i++) { QUrl url = urls[i]; TFilePath path = TFilePath(url.toLocalFile().toStdWString()); StudioPalette *studioPalette = StudioPalette::instance(); if (path == newPath || path.getParentDir() == newPath) continue; if (isInStudioPalette(path)) { TFilePath newPalettePath = newPath + TFilePath(path.getWideName() + ::to_wstring(path.getDottedType())); try { StudioPaletteCmd::movePalette(newPalettePath, path); } catch (TException &e) { error("Can't rename palette: " + QString(::to_string(e.getMessage()).c_str())); } catch (...) { error("Can't rename palette"); } } } TUndoManager::manager()->endBlock(); event->setDropAction(Qt::CopyAction); event->accept(); }
void StudioPaletteTreeViewer::onItemChanged(QTreeWidgetItem *item, int column) { if (item != currentItem() || isRootItem(item)) return; wstring name = item->text(column).toStdWString(); TFilePath oldPath = getCurrentFolderPath(); if (oldPath.isEmpty() || name.empty() || oldPath.getWideName() == name) return; TFilePath newPath(oldPath.getParentDir() + TFilePath(name + ::to_wstring(oldPath.getDottedType()))); try { StudioPaletteCmd::movePalette(newPath, oldPath); } catch (TException &e) { error(QString(::to_string(e.getMessage()).c_str())); item->setText(column, QString::fromStdWString(oldPath.getWideName())); } catch (...) { error("Can't rename file"); item->setText(column, QString::fromStdWString(oldPath.getWideName())); } refreshItem(getItem(oldPath.getParentDir())); setCurrentItem(getItem(newPath)); }
void CastTreeViewer::onCastFolderAdded(const TFilePath &path) { QTreeWidgetItem *root = topLevelItem(0)->child(0); assert(root->data(1, Qt::DisplayRole).toString() == toQString(getLevelSet()->getDefaultFolder())); QString childName = QString::fromStdWString(path.getWideName()); QString childPathQstr = QString::fromStdWString(path.getWideString()); QTreeWidgetItem *childItem = new QTreeWidgetItem(root, QStringList(childName) << childPathQstr); childItem->setFlags(childItem->flags() | Qt::ItemIsEditable); root->addChild(childItem); setCurrentItem(childItem); }
TFilePath ResourceImportStrategy::process(ToonzScene *scene, ToonzScene *srcScene, TFilePath srcPath) { TFilePath srcActualPath = srcScene->decodeFilePath(srcPath); if (!scene->isExternPath(srcActualPath) || m_strategy == DONT_IMPORT) return srcPath; TFilePath dstPath; if (srcPath.getWideString().find(L'+') == 0) dstPath = srcPath; else dstPath = scene->getImportedLevelPath(srcPath); TFilePath actualDstPath = scene->decodeFilePath(dstPath); assert(actualDstPath != TFilePath()); if (m_strategy == IMPORT_AND_OVERWRITE) { //bool overwritten = false; if (TSystem::doesExistFileOrLevel(actualDstPath)) { TSystem::removeFileOrLevel(actualDstPath); // overwritten = true; } if (TSystem::doesExistFileOrLevel(srcPath)) TXshSimpleLevel::copyFiles(actualDstPath, srcPath); return dstPath; } else if (m_strategy == IMPORT_AND_RENAME) { std::wstring levelName = srcPath.getWideName(); TLevelSet *parentLevelSet = scene->getLevelSet(); NameModifier nm(levelName); wstring newName; for (;;) { newName = nm.getNext(); if (!parentLevelSet->hasLevel(newName)) break; } dstPath = dstPath.withName(newName); actualDstPath = scene->decodeFilePath(dstPath); if (TSystem::doesExistFileOrLevel(actualDstPath)) TSystem::removeFileOrLevel(actualDstPath); if (TSystem::doesExistFileOrLevel(srcActualPath)) { TXshSimpleLevel::copyFiles(actualDstPath, srcActualPath); } return dstPath; } return srcPath; }
void AddFxContextMenu::loadMacro() { TFilePath macroDir = m_presetPath + TFilePath("macroFx"); try { if (TFileStatus(macroDir).isDirectory()) { TFilePathSet macros = TSystem::readDirectory(macroDir); if (macros.empty()) return; QMenu *insertMacroMenu = new QMenu("Macro", m_insertMenu); QMenu *addMacroMenu = new QMenu("Macro", m_addMenu); QMenu *replaceMacroMenu = new QMenu("Macro", m_replaceMenu); m_insertMenu->addMenu(insertMacroMenu); m_addMenu->addMenu(addMacroMenu); m_replaceMenu->addMenu(replaceMacroMenu); for (TFilePathSet::iterator it = macros.begin(); it != macros.end(); ++it) { TFilePath macroPath = *it; QString name = QString::fromStdWString(macroPath.getWideName()); QAction *insertAction = new QAction(name, insertMacroMenu); QAction *addAction = new QAction(name, addMacroMenu); QAction *replaceAction = new QAction(name, replaceMacroMenu); insertAction->setData( QVariant(QString::fromStdWString(macroPath.getWideString()))); addAction->setData( QVariant(QString::fromStdWString(macroPath.getWideString()))); replaceAction->setData( QVariant(QString::fromStdWString(macroPath.getWideString()))); insertMacroMenu->addAction(insertAction); addMacroMenu->addAction(addAction); replaceMacroMenu->addAction(replaceAction); m_insertActionGroup->addAction(insertAction); m_addActionGroup->addAction(addAction); m_replaceActionGroup->addAction(replaceAction); } } } catch (...) { } }
MagpieInfo::MagpieInfo(TFilePath path) : m_fileName(QString::fromStdWString(path.getWideName())) { QFile file(QString::fromStdWString(path.getWideString())); if (!file.open(QFile::ReadOnly)) return; QTextStream textStream(&file); QString line; do { line = textStream.readLine(); //E' la prima riga if (line == QString("Toonz")) continue; if (!line.contains(L'|')) { if (!line.isEmpty()) m_actsIdentifier.append(line); continue; } QStringList list = line.split(QString("|")); assert(list.size() == 3); m_actorActs.append(list.at(1)); m_comments.append(list.at(2)); } while (!line.isNull()); }
TFilePath OverwriteDialog::addSuffix(const TFilePath &src) const { return src.withName(src.getWideName() + m_suffix->text().toStdWString()); }
bool AddFxContextMenu::loadPreset(const string &name, QMenu *insertFxGroup, QMenu *addFxGroup, QMenu *replaceFxGroup) { TFilePath presetsFilepath(m_presetPath + name); if (TFileStatus(presetsFilepath).isDirectory()) { TFilePathSet presets = TSystem::readDirectory(presetsFilepath, false); if (!presets.empty()) { QMenu *inserMenu = new QMenu(QString::fromStdWString(TStringTable::translate(name)), insertFxGroup); insertFxGroup->addMenu(inserMenu); QMenu *addMenu = new QMenu(QString::fromStdWString(TStringTable::translate(name)), addFxGroup); addFxGroup->addMenu(addMenu); QMenu *replaceMenu = new QMenu(QString::fromStdWString(TStringTable::translate(name)), replaceFxGroup); replaceFxGroup->addMenu(replaceMenu); //This is a workaround to set the bold style to the first element of this menu //Setting a font directly to a QAction is not enought; style sheet definitions //preval over QAction font settings. inserMenu->setObjectName("fxMenu"); addMenu->setObjectName("fxMenu"); replaceMenu->setObjectName("fxMenu"); QAction *insertAction = new QAction(QString::fromStdWString(TStringTable::translate(name)), inserMenu); QAction *addAction = new QAction(QString::fromStdWString(TStringTable::translate(name)), addMenu); QAction *replaceAction = new QAction(QString::fromStdWString(TStringTable::translate(name)), replaceMenu); insertAction->setCheckable(true); addAction->setCheckable(true); replaceAction->setCheckable(true); insertAction->setData(QVariant(QString::fromStdString(name))); addAction->setData(QVariant(QString::fromStdString(name))); replaceAction->setData(QVariant(QString::fromStdString(name))); inserMenu->addAction(insertAction); addMenu->addAction(addAction); replaceMenu->addAction(replaceAction); m_insertActionGroup->addAction(insertAction); m_addActionGroup->addAction(addAction); m_replaceActionGroup->addAction(replaceAction); for (TFilePathSet::iterator it2 = presets.begin(); it2 != presets.end(); ++it2) { TFilePath presetName = *it2; QString qPresetName = QString::fromStdWString(presetName.getWideName()); insertAction = new QAction(qPresetName, inserMenu); addAction = new QAction(qPresetName, addMenu); replaceAction = new QAction(qPresetName, replaceMenu); insertAction->setData(QVariant(QString::fromStdWString(presetName.getWideString()))); addAction->setData(QVariant(QString::fromStdWString(presetName.getWideString()))); replaceAction->setData(QVariant(QString::fromStdWString(presetName.getWideString()))); inserMenu->addAction(insertAction); addMenu->addAction(addAction); replaceMenu->addAction(replaceAction); m_insertActionGroup->addAction(insertAction); m_addActionGroup->addAction(addAction); m_replaceActionGroup->addAction(replaceAction); } return true; } else return false; } else return false; }
Preferences::Preferences() : m_units("mm"), m_cameraUnits("inch"), m_scanLevelType("tif"), m_defLevelWidth(0.0), m_defLevelHeight(0.0), m_defLevelDpi(0.0), m_iconSize(160, 120), m_blankColor(TPixel32::White), m_frontOnionColor(TPixel::Black), m_backOnionColor(TPixel::Black), m_transpCheckBg(TPixel::White), m_transpCheckInk(TPixel::Black), m_transpCheckPaint(TPixel(127, 127, 127)), m_autosavePeriod(15), m_chunkSize(10), m_rasterOptimizedMemory(0), m_shrink(1), m_step(1), m_blanksCount(0), m_keyframeType(3), m_animationStep(1), m_textureSize(0), m_xsheetStep(10), m_shmmax(-1), m_shmseg(-1), m_shmall(-1), m_shmmni(-1), m_onionPaperThickness(50), m_currentLanguage(0), m_currentStyleSheet(0), m_undoMemorySize(100), m_dragCellsBehaviour(0), m_lineTestFpsCapture(25), m_defLevelType(0), m_autocreationType(1), m_autoExposeEnabled(true), m_autoCreateEnabled(true), m_subsceneFolderEnabled(true), m_generatedMovieViewEnabled(true), m_xsheetAutopanEnabled(true), m_ignoreAlphaonColumn1Enabled(false), m_rewindAfterPlaybackEnabled(true), m_fitToFlipbookEnabled(false), m_previewAlwaysOpenNewFlipEnabled(false), m_autosaveEnabled(false), m_defaultViewerEnabled(false), m_saveUnpaintedInCleanup(true), m_askForOverrideRender(true), m_automaticSVNFolderRefreshEnabled(true), m_SVNEnabled(false), m_minimizeSaveboxAfterEditing(true), m_levelsBackupEnabled(false), m_sceneNumberingEnabled(false), m_animationSheetEnabled(false), m_inksOnly(false), m_fillOnlySavebox(false), m_show0ThickLines(true), m_regionAntialias(false), m_viewerBGColor(128, 128, 128, 255), m_previewBGColor(64, 64, 64, 255), m_chessboardColor1(180, 180, 180), m_chessboardColor2(230, 230, 230), m_showRasterImagesDarkenBlendedInViewer(false), m_actualPixelViewOnSceneEditingMode(false), m_viewerZoomCenter(0), m_initialLoadTlvCachingBehavior(0), m_removeSceneNumberFromLoadedLevelName(false), m_replaceAfterSaveLevelAs(true), m_showFrameNumberWithLetters(false), m_levelNameOnEachMarker(false), m_columnIconLoadingPolicy((int)LoadAtOnce), m_moveCurrentFrameByClickCellArea(true), m_onionSkinEnabled(false), m_multiLayerStylePickerEnabled(false), m_paletteTypeOnLoadRasterImageAsColorModel(0), m_showKeyframesOnXsheetCellArea(true) { TCamera camera; m_defLevelType = PLI_XSHLEVEL; m_defLevelWidth = camera.getSize().lx; m_defLevelHeight = camera.getSize().ly; m_defLevelDpi = camera.getDpi().x; TFilePath layoutDir = ToonzFolder::getMyModuleDir(); TFilePath savePath = layoutDir + TFilePath("preferences.ini"); m_settings.reset(new QSettings(QString::fromStdWString(savePath.getWideString()), QSettings::IniFormat)); getValue(*m_settings, "autoExposeEnabled", m_autoExposeEnabled); getValue(*m_settings, "autoCreateEnabled", m_autoCreateEnabled); getValue(*m_settings, "subsceneFolderEnabled", m_subsceneFolderEnabled); getValue(*m_settings, "generatedMovieViewEnabled", m_generatedMovieViewEnabled); getValue(*m_settings, "xsheetAutopanEnabled", m_xsheetAutopanEnabled); getValue(*m_settings, "ignoreAlphaonColumn1Enabled", m_ignoreAlphaonColumn1Enabled); getValue(*m_settings, "rewindAfterPlayback", m_rewindAfterPlaybackEnabled); getValue(*m_settings, "previewAlwaysOpenNewFlip", m_previewAlwaysOpenNewFlipEnabled); getValue(*m_settings, "fitToFlipbook", m_fitToFlipbookEnabled); getValue(*m_settings, "automaticSVNFolderRefreshEnabled", m_automaticSVNFolderRefreshEnabled); getValue(*m_settings, "SVNEnabled", m_SVNEnabled); getValue(*m_settings, "minimizeSaveboxAfterEditing", m_minimizeSaveboxAfterEditing); getValue(*m_settings, "levelsBackupEnabled", m_levelsBackupEnabled); getValue(*m_settings, "sceneNumberingEnabled", m_sceneNumberingEnabled); getValue(*m_settings, "animationSheetEnabled", m_animationSheetEnabled); getValue(*m_settings, "autosaveEnabled", m_autosaveEnabled); getValue(*m_settings, "defaultViewerEnabled", m_defaultViewerEnabled); getValue(*m_settings, "rasterOptimizedMemory", m_rasterOptimizedMemory); getValue(*m_settings, "saveUnpaintedInCleanup", m_saveUnpaintedInCleanup); getValue(*m_settings, "autosavePeriod", m_autosavePeriod); getValue(*m_settings, "taskchunksize", m_chunkSize); getValue(*m_settings, "xsheetStep", m_xsheetStep); int r = 0, g = 0, b = 0; getValue(*m_settings, "frontOnionColor.r", r); getValue(*m_settings, "frontOnionColor.g", g); getValue(*m_settings, "frontOnionColor.b", b); m_frontOnionColor = TPixel32(r, g, b); getValue(*m_settings, "onionPaperThickness", m_onionPaperThickness); r = 0, g = 0, b = 0; getValue(*m_settings, "backOnionColor.r", r); getValue(*m_settings, "backOnionColor.g", g); getValue(*m_settings, "backOnionColor.b", b); m_backOnionColor = TPixel32(r, g, b); r = m_transpCheckBg.r, g = m_transpCheckBg.g, b = m_transpCheckBg.b; getValue(*m_settings, "transpCheckInkOnBlack.r", r); getValue(*m_settings, "transpCheckInkOnBlack.g", g); getValue(*m_settings, "transpCheckInkOnBlack.b", b); m_transpCheckBg = TPixel32(r, g, b); r = m_transpCheckInk.r, g = m_transpCheckInk.g, b = m_transpCheckInk.b; getValue(*m_settings, "transpCheckInkOnWhite.r", r); getValue(*m_settings, "transpCheckInkOnWhite.g", g); getValue(*m_settings, "transpCheckInkOnWhite.b", b); m_transpCheckInk = TPixel32(r, g, b); r = m_transpCheckPaint.r, g = m_transpCheckPaint.g, b = m_transpCheckPaint.b; getValue(*m_settings, "transpCheckPaint.r", r); getValue(*m_settings, "transpCheckPaint.g", g); getValue(*m_settings, "transpCheckPaint.b", b); m_transpCheckPaint = TPixel32(r, g, b); getValue(*m_settings, "onionInksOnly", m_inksOnly); getValue(*m_settings, "iconSizeX", m_iconSize.lx); getValue(*m_settings, "iconSizeY", m_iconSize.ly); getValue(*m_settings, s_show0ThickLines, m_show0ThickLines); getValue(*m_settings, s_regionAntialias, m_regionAntialias); getValue(*m_settings, "viewShrink", m_shrink); getValue(*m_settings, "viewStep", m_step); getValue(*m_settings, "blanksCount", m_blanksCount); getValue(*m_settings, "askForOverrideRender", m_askForOverrideRender); r = 255, g = 255, b = 255; getValue(*m_settings, "blankColor.r", r); getValue(*m_settings, "blankColor.g", g); getValue(*m_settings, "blankColor.b", b); getValue(*m_settings, "undoMemorySize", m_undoMemorySize); setUndoMemorySize(m_undoMemorySize); m_blankColor = TPixel32(r, g, b); QString units; units = m_settings->value("linearUnits").toString(); if (units != "") m_units = units; setUnits(m_units.toStdString()); units = m_settings->value("cameraUnits").toString(); if (units != "") m_cameraUnits = units; setCameraUnits(m_cameraUnits.toStdString()); getValue(*m_settings, "keyframeType", m_keyframeType); getValue(*m_settings, "animationStep", m_animationStep); getValue(*m_settings, "textureSize", m_textureSize); QString scanLevelType; scanLevelType = m_settings->value("scanLevelType").toString(); if (scanLevelType != "") m_scanLevelType = scanLevelType; setScanLevelType(m_scanLevelType.toStdString()); getValue(*m_settings, "shmmax", m_shmmax); getValue(*m_settings, "shmseg", m_shmseg); getValue(*m_settings, "shmall", m_shmall); getValue(*m_settings, "shmmni", m_shmmni); // Load level formats getDefaultLevelFormats(m_levelFormats); getValue(*m_settings, m_levelFormats); std::sort(m_levelFormats.begin(), m_levelFormats.end(), // Format sorting must be formatLess); // enforced TFilePath lang_path = TEnv::getConfigDir() + "loc"; TFilePathSet lang_fpset; m_languageMaps[0] = "english"; //m_currentLanguage=0; try { TFileStatus langPathFs(lang_path); if (langPathFs.doesExist() && langPathFs.isDirectory()) { TSystem::readDirectory(lang_fpset, lang_path, true, false); } else { } TFilePathSet::iterator it = lang_fpset.begin(); int i = 1; for (it; it != lang_fpset.end(); it++, i++) { TFilePath newPath = *it; if (newPath == lang_path) continue; if (TFileStatus(newPath).isDirectory()) { QString string = QString::fromStdWString(newPath.getWideName()); m_languageMaps[i] = string; } } } catch (...) { } TFilePath path(TEnv::getConfigDir() + "qss"); TFilePathSet fpset; try { TSystem::readDirectory(fpset, path, true, false); TFilePathSet::iterator it = fpset.begin(); int i = 0; for (it; it != fpset.end(); it++, i++) { TFilePath newPath = *it; if (newPath == path) continue; QString fpName = QString::fromStdWString(newPath.getWideName()); #ifdef MACOSX QString string = fpName + QString("/") + fpName + QString("_mac.qss"); #else QString string = fpName + QString("/") + fpName + QString(".qss"); #endif if (fpName == QString("standard")) m_currentStyleSheet = i; m_styleSheetMaps[i] = "file:///" + path.getQString() + "/" + string; } } catch (...) { } getValue(*m_settings, "CurrentLanguage", m_currentLanguage); getValue(*m_settings, "CurrentStyleSheet", m_currentStyleSheet); getValue(*m_settings, "DragCellsBehaviour", m_dragCellsBehaviour); getValue(*m_settings, "LineTestFpsCapture", m_lineTestFpsCapture); getValue(*m_settings, "FillOnlysavebox", m_fillOnlySavebox); getValue(*m_settings, "AutocreationType", m_autocreationType); getValue(*m_settings, "DefLevelType", m_defLevelType); getValue(*m_settings, "DefLevelWidth", m_defLevelWidth); getValue(*m_settings, "DefLevelHeight", m_defLevelHeight); getValue(*m_settings, "DefLevelDpi", m_defLevelDpi); getValue(*m_settings, "viewerBGColor", m_viewerBGColor); getValue(*m_settings, "previewBGColor", m_previewBGColor); getValue(*m_settings, "chessboardColor1", m_chessboardColor1); getValue(*m_settings, "chessboardColor2", m_chessboardColor2); getValue(*m_settings, "showRasterImagesDarkenBlendedInViewer", m_showRasterImagesDarkenBlendedInViewer); getValue(*m_settings, "actualPixelViewOnSceneEditingMode", m_actualPixelViewOnSceneEditingMode); getValue(*m_settings, "viewerZoomCenter", m_viewerZoomCenter); getValue(*m_settings, "initialLoadTlvCachingBehavior", m_initialLoadTlvCachingBehavior); getValue(*m_settings, "removeSceneNumberFromLoadedLevelName", m_removeSceneNumberFromLoadedLevelName); getValue(*m_settings, "replaceAfterSaveLevelAs", m_replaceAfterSaveLevelAs); getValue(*m_settings, "showFrameNumberWithLetters", m_showFrameNumberWithLetters); getValue(*m_settings, "levelNameOnEachMarkerEnabled", m_levelNameOnEachMarker); getValue(*m_settings, "columnIconLoadingPolicy", m_columnIconLoadingPolicy); getValue(*m_settings, "moveCurrentFrameByClickCellArea", m_moveCurrentFrameByClickCellArea); getValue(*m_settings, "onionSkinEnabled", m_onionSkinEnabled); getValue(*m_settings, "multiLayerStylePickerEnabled", m_multiLayerStylePickerEnabled); getValue(*m_settings, "paletteTypeOnLoadRasterImageAsColorModel", m_paletteTypeOnLoadRasterImageAsColorModel); getValue(*m_settings, "showKeyframesOnXsheetCellArea", m_showKeyframesOnXsheetCellArea); }
bool RenderCommand::init(bool isPreview) { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); TSceneProperties *sprop = scene->getProperties(); /*-- Preview/Renderに応じてそれぞれのSettingを取得 --*/ TOutputProperties &outputSettings = isPreview ? *sprop->getPreviewProperties() : *sprop->getOutputProperties(); outputSettings.getRange(m_r0, m_r1, m_step); /*-- シーン全体のレンダリングの場合、m_r1をScene長に設定 --*/ if (m_r0 == 0 && m_r1 == -1) { m_r0 = 0; m_r1 = scene->getFrameCount() - 1; } if (m_r0 < 0) m_r0 = 0; if (m_r1 >= scene->getFrameCount()) m_r1 = scene->getFrameCount() - 1; if (m_r1 < m_r0) { MsgBox(WARNING, QObject::tr("The command cannot be executed because the scene is empty.")); return false; // throw TException("empty scene"); // non so perche', ma termina il programma // nonostante il try all'inizio } // Initialize the preview case /*TRenderSettings rs = sprop->getPreviewProperties()->getRenderSettings(); TRenderSettings rso = sprop->getOutputProperties()->getRenderSettings(); rs.m_stereoscopic=true; rs.m_stereoscopicShift=0.05; rso.m_stereoscopic=true; rso.m_stereoscopicShift=0.05; sprop->getPreviewProperties()->setRenderSettings(rs); sprop->getOutputProperties()->setRenderSettings(rso);*/ if (isPreview) { /*-- PreviewではTimeStretchを考慮しないので、そのままフレーム値を格納してゆく --*/ m_numFrames = (int)(m_r1 - m_r0 + 1); m_r = m_r0; m_stepd = m_step; m_multimediaRender = 0; return true; } // Full render case // Read the output filepath TFilePath fp = outputSettings.getPath(); /*-- ファイル名が指定されていない場合は、シーン名を出力ファイル名にする --*/ if (fp.getWideName() == L"") fp = fp.withName(scene->getScenePath().getName()); /*-- ラスタ画像の場合、ファイル名にフレーム番号を追加 --*/ if (TFileType::getInfo(fp) == TFileType::RASTER_IMAGE || fp.getType() == "pct" || fp.getType() == "pic" || fp.getType() == "pict") //pct e' un formato"livello" (ha i settings di quicktime) ma fatto di diversi frames fp = fp.withFrame(TFrameId::EMPTY_FRAME); fp = scene->decodeFilePath(fp); if (!TFileStatus(fp.getParentDir()).doesExist()) { try { TFilePath parent = fp.getParentDir(); TSystem::mkDir(parent); DvDirModel::instance()->refreshFolder(parent.getParentDir()); } catch (TException &e) { MsgBox(WARNING, QObject::tr("It is not possible to create folder : %1").arg(QString::fromStdString(toString(e.getMessage())))); return false; } catch (...) { MsgBox(WARNING, QObject::tr("It is not possible to create a folder.")); return false; } } m_fp = fp; // Retrieve camera infos const TCamera *camera = isPreview ? scene->getCurrentPreviewCamera() : scene->getCurrentCamera(); TDimension cameraSize = camera->getRes(); TPointD cameraDpi = camera->getDpi(); // Retrieve render interval/step/times double stretchTo = (double)outputSettings.getRenderSettings().m_timeStretchTo; double stretchFrom = (double)outputSettings.getRenderSettings().m_timeStretchFrom; m_timeStretchFactor = stretchTo / stretchFrom; m_stepd = m_step / m_timeStretchFactor; int stretchedR0 = tfloor(m_r0 * m_timeStretchFactor); int stretchedR1 = tceil((m_r1 + 1) * m_timeStretchFactor) - 1; m_r = stretchedR0 / m_timeStretchFactor; m_numFrames = (stretchedR1 - stretchedR0) / m_step + 1; // Update the multimedia render switch m_multimediaRender = outputSettings.getMultimediaRendering(); return true; }