void ProjectDvDirModelRootNode::refreshChildren() {
  m_childrenValid = true;
  if (m_children.empty()) {
    TProjectManager *pm = TProjectManager::instance();
    std::vector<TFilePath> projectRoots;
    pm->getProjectRoots(projectRoots);

    int i;
    for (i = 0; i < (int)projectRoots.size(); i++) {
      TFilePath projectRoot = projectRoots[i];
      std::wstring rootDir  = projectRoot.getWideString();
      ProjectDvDirModelSpecialFileFolderNode *projectRootNode =
          new ProjectDvDirModelSpecialFileFolderNode(
              this, L"Project root (" + rootDir + L")", projectRoot);
      projectRootNode->setPixmap(svgToPixmap(":Resources/projects.svg"));
      addChild(projectRootNode);
    }

    // SVN Repository
    QList<SVNRepository> repositories =
        VersionControl::instance()->getRepositories();
    int count = repositories.size();
    for (int i = 0; i < count; i++) {
      SVNRepository repo = repositories.at(i);

      ProjectDvDirModelSpecialFileFolderNode *node =
          new ProjectDvDirModelSpecialFileFolderNode(
              this, repo.m_name.toStdWString(),
              TFilePath(repo.m_localPath.toStdWString()));
      node->setPixmap(svgToPixmap(":Resources/vcroot.svg"));
      addChild(node);
    }
  }
}
示例#2
0
/*! Loads the project specified in \b projectPath.\n
        \b projectPath must be an absolute path.
*/
void TProject::load(const TFilePath &projectPath) {
  assert(isAProjectPath(projectPath));

  TFilePath latestProjectPath = getLatestVersionProjectPath(projectPath);
  TFilePath inputProjectPath  = searchProjectPath(projectPath.getParentDir());

  TProjectManager *pm = TProjectManager::instance();
  m_name              = pm->projectPathToProjectName(latestProjectPath);
  m_path              = latestProjectPath;

  m_folderNames.clear();
  m_folders.clear();
  m_useScenePathFlags.clear();
  delete m_sprop;
  m_sprop = new TSceneProperties();

  // Read the project
  TIStream is(inputProjectPath);
  if (!is) return;

  string tagName;
  if (!is.matchTag(tagName) || tagName != "project") return;

  while (is.matchTag(tagName)) {
    if (tagName == "folders") {
      while (is.matchTag(tagName)) {
        if (tagName == "folder") {
          string name = is.getTagAttribute("name");
          TFilePath path(is.getTagAttribute("path"));
          setFolder(name, path);
          string useScenePath = is.getTagAttribute("useScenePath");
          setUseScenePath(name, useScenePath == "yes");
        } else
          throw TException("expected <folder>");
      }
      is.matchEndTag();
    } else if (tagName == "version") {
      int major, minor;
      is >> major >> minor;
      is.setVersion(VersionNumber(major, minor));
      is.matchEndTag();
    } else if (tagName == "sceneProperties") {
TFilePath ExportScenePopup::createNewProject()
{
	TProjectManager *pm = TProjectManager::instance();
	TFilePath projectName(m_newProjectName->text().toStdWString());
	if (projectName == TFilePath()) {
		MsgBox(WARNING, tr("The project name cannot be empty or contain any of the following characters:(new line)   \\ / : * ? \"  |"));
		return TFilePath();
	}
	if (projectName.isAbsolute()) {
		// bad project name
		MsgBox(WARNING, tr("The project name cannot be empty or contain any of the following characters:(new line)   \\ / : * ? \"  |"));
		return TFilePath();
	}
	if (pm->getProjectPathByName(projectName) != TFilePath()) {
		// project already exists
		MsgBox(WARNING, tr("The project name you specified is already used."));
		return TFilePath();
	}

	TFilePath currentProjectRoot;
	DvDirModelFileFolderNode *node = dynamic_cast<DvDirModelFileFolderNode *>(m_projectTreeView->getCurrentNode());
	if (node)
		currentProjectRoot = node->getPath();
	else
		currentProjectRoot = pm->getCurrentProjectRoot();
	TFilePath projectFolder = currentProjectRoot + projectName;
	TFilePath projectPath = pm->projectFolderToProjectPath(projectFolder);
	TProject *project = new TProject();

	TProjectP currentProject = pm->getCurrentProject();
	assert(currentProject);
	int i;
	for (i = 0; i < (int)currentProject->getFolderCount(); i++)
		project->setFolder(currentProject->getFolderName(i), currentProject->getFolder(i));
	project->save(projectPath);
	DvDirModel::instance()->refreshFolder(currentProjectRoot);

	return projectPath;
}
void ExportSceneDvDirModelRootNode::refreshChildren()
{
	m_childrenValid = true;
	m_children.clear();
	//if(m_children.empty())
	//{
	TProjectManager *pm = TProjectManager::instance();
	std::vector<TFilePath> projectRoots;
	pm->getProjectRoots(projectRoots);

	int i;
	for (i = 0; i < (int)projectRoots.size(); i++) {
		TFilePath projectRoot = projectRoots[i];
		ExportSceneDvDirModelSpecialFileFolderNode *projectRootNode =
			new ExportSceneDvDirModelSpecialFileFolderNode(this, L"Project root", projectRoot);
		projectRootNode->setPixmap(QPixmap(":Resources/projects.png"));
		m_projectRootNodes.push_back(projectRootNode);
		addChild(projectRootNode);
	}

	TFilePath sandboxProjectPath = pm->getSandboxProjectFolder();
	m_sandboxProjectNode =
		new ExportSceneDvDirModelProjectNode(this, sandboxProjectPath);
	addChild(m_sandboxProjectNode);

	// SVN Repository
	QList<SVNRepository> repositories = VersionControl::instance()->getRepositories();
	int count = repositories.size();
	for (int i = 0; i < count; i++) {
		SVNRepository repo = repositories.at(i);

		ExportSceneDvDirModelSpecialFileFolderNode *node =
			new ExportSceneDvDirModelSpecialFileFolderNode(this, repo.m_name.toStdWString(), TFilePath(repo.m_localPath.toStdWString()));
		node->setPixmap(QPixmap(":Resources/vcroot.png"));
		addChild(node);
	}
	//}
}
void ExportScenePopup::onExport()
{
	QApplication::setOverrideCursor(Qt::WaitCursor);
	TProjectManager *pm = TProjectManager::instance();
	TFilePath oldProjectPath = pm->getCurrentProjectPath();
	TFilePath projectPath;
	if (!m_createNewProject) {
		DvDirModelFileFolderNode *node = (DvDirModelFileFolderNode *)m_projectTreeView->getCurrentNode();
		if (!node || !pm->isProject(node->getPath())) {
			QApplication::restoreOverrideCursor();
			MsgBox(WARNING, tr("The folder you selected is not a project."));
			return;
		}
		projectPath = pm->projectFolderToProjectPath(node->getPath());
		assert(projectPath != TFilePath());
	} else //Create project
	{
		projectPath = createNewProject();
		if (projectPath == TFilePath()) {
			QApplication::restoreOverrideCursor();
			return;
		}
	}
	pm->setCurrentProjectPath(projectPath);

	std::vector<TFilePath> newScenes;
	int i;
	for (i = 0; i < m_scenes.size(); i++) {
		TFilePath newScenePath = importScene(m_scenes[i]);
		if (newScenePath == TFilePath())
			continue;
		newScenes.push_back(newScenePath);
	}
	pm->setCurrentProjectPath(oldProjectPath);
	if (newScenes.empty()) {
		QApplication::restoreOverrideCursor();
		MsgBox(WARNING, tr("There was an error exporting the scene."));
		return;
	}
	for (i = 0; i < newScenes.size(); i++)
		collectAssets(newScenes[i]);

	QApplication::restoreOverrideCursor();
	accept();
}
示例#6
0
/*! Saves the project in the specified path.
        The TfilePath fp must be an absolute path. The project is saved as a xml
   file.\n
        Uses TProjectManager and TOStream.
        \note Exceptions can be thrown.
        \see TProjectManager and TOStream.
*/
bool TProject::save(const TFilePath &projectPath) {
  assert(isAProjectPath(projectPath));

  TProjectManager *pm     = TProjectManager::instance();
  m_name                  = pm->projectPathToProjectName(projectPath);
  m_path                  = getLatestVersionProjectPath(projectPath);
  TFilePath projectFolder = projectPath.getParentDir();

  if (!TFileStatus(projectFolder).doesExist()) {
    try {
      TSystem::mkDir(projectFolder);
    } catch (...) {
      return false;
    }
  }

  TFilePath sceneFolder    = decode(getFolder(TProject::Scenes));
  TFilePath scenesDescPath = sceneFolder + "scenes.xml";

  TFileStatus fs(projectPath);
  if (fs.doesExist() && !fs.isWritable()) {
    throw TSystemException(
        projectPath,
        "Cannot save the project settings. The file is read-only.");
    return false;
  }
  TFileStatus fs2(scenesDescPath);
  if (fs2.doesExist() && !fs2.isWritable()) {
    throw TSystemException(
        projectPath,
        "Cannot save the project settings. The scenes file is read-only.");
    return false;
  }

  TOStream os(m_path);
  os.openChild("project");
  os.openChild("version");
  os << 70 << 1;    // Standard version signature:
  os.closeChild();  //   <Major Toonz version number * 10>.<Major version
                    //   advancement>
  os.openChild("folders");
  int i = 0;
  for (i = 0; i < getFolderCount(); i++) {
    TFilePath folderRelativePath = getFolder(i);
    if (folderRelativePath == TFilePath()) continue;
    std::map<std::string, string> attr;
    string folderName = getFolderName(i);
    attr["name"]      = folderName;
    attr["path"]      = ::to_string(folderRelativePath);  // escape()
    if (getUseScenePath(folderName)) attr["useScenePath"] = "yes";
    os.openCloseChild("folder", attr);
  }
  os.closeChild();

  os.openChild("sceneProperties");
  getSceneProperties().saveData(os);
  os.closeChild();
  os.closeChild();

  // crea (se necessario) le directory relative ai vari folder
  for (i = 0; i < getFolderCount(); i++)
    if (isConstantFolder(i)) {
      TFilePath fp = getFolder(i);
      if (fp == TFilePath()) continue;
      fp = decode(fp);
      // if(!fp.isAbsolute()) fp = projectFolder + fp;
      if (!TFileStatus(fp).doesExist()) {
        try {
          TSystem::mkDir(fp);
        } catch (...) {
        }
      }
    }

  /*-- +scenes だけでなく、全てのProject Folderにscenes.xmlを生成する --*/
  std::vector<std::string> foldernames;
  pm->getFolderNames(foldernames);
  for (int f = 0; f < foldernames.size(); f++) {
    TFilePath folderpath = decode(getFolder(foldernames.at(f)));
    if (folderpath.isEmpty() || !isConstantFolder(f)) continue;

    TFilePath xmlPath = folderpath + "scenes.xml";
    TFileStatus xmlfs(xmlPath);
    if (xmlfs.doesExist() && !xmlfs.isWritable()) continue;

    TFilePath relativeProjectFolder =
        makeRelative(folderpath, m_path.getParentDir());

    TOStream os2(xmlPath);
    std::map<std::string, string> attr;
    attr["type"] = "projectFolder";
    os2.openChild("parentProject", attr);
    os2 << relativeProjectFolder;
    os2.closeChild();
  }

  // The project has been successfully saved. In case there are other
  // project files from older Toonz project versions, those files are
  // renamed so that older Toonz versions can no longer 'see' it.
  if (!isFolderUnderVersionControl(projectFolder))
    hideOlderProjectFiles(projectFolder);

  return true;
}
void ProjectCreatePopup::createProject() {
  if (!IoCmd::saveSceneIfNeeded(QObject::tr("Create project"))) return;

#ifdef LINETEST
  TnzCamera *camera = TnzCamera::instance();
  if (camera->isCameraConnected()) camera->cameraDisconnect();
#endif

  QFileInfo fi(m_nameFld->text());

  if (!isValidFileName(fi.baseName())) {
    error(
        tr("Project Name cannot be empty or contain any of the following "
           "characters:\n \\ / : * ? \" < > |"));
    return;
  }

  TProjectManager *pm   = TProjectManager::instance();
  TFilePath projectName = TFilePath(m_nameFld->text().toStdWString());
  if (projectName == TFilePath()) {
    return;
  }

  if (projectName.isAbsolute()) {
    error(tr("Bad project name: '%1' looks like an absolute file path")
              .arg(m_nameFld->text()));
    return;
  }

  if (pm->getProjectPathByName(projectName) != TFilePath()) {
    error(tr("Project '%1' already exists").arg(m_nameFld->text()));
    // project already exists
    return;
  }

  TFilePath currentProjectRoot;
  DvDirModelFileFolderNode *node =
      dynamic_cast<DvDirModelFileFolderNode *>(m_treeView->getCurrentNode());
  if (node)
    currentProjectRoot = node->getPath();
  else
    currentProjectRoot = pm->getCurrentProjectRoot();

  TFilePath projectFolder = currentProjectRoot + projectName;
  TFilePath projectPath   = pm->projectFolderToProjectPath(projectFolder);
  TProject *project       = new TProject();
  updateProjectFromFields(project);
  TProjectP currentProject = pm->getCurrentProject();
  project->setSceneProperties(currentProject->getSceneProperties());
  try {
    bool isSaved = project->save(projectPath);
    if (!isSaved)
      DVGui::error(tr("It is not possible to create the %1 project.")
                       .arg(toQString(projectPath)));
  } catch (TSystemException se) {
    DVGui::warning(QString::fromStdWString(se.getMessage()));
    return;
  }
  pm->setCurrentProjectPath(projectPath);
  IoCmd::newScene();
  DvDirModel::instance()->refreshFolder(projectFolder.getParentDir());
  accept();
}
ProjectPopup::ProjectPopup(bool isModal)
    : Dialog(TApp::instance()->getMainWindow(), isModal, false, "Project") {
  TProjectManager *pm = TProjectManager::instance();

  m_choosePrjLabel     = new QLabel(tr("Project:"), this);
  m_chooseProjectCombo = new QComboBox();
  m_prjNameLabel       = new QLabel(tr("Project Name:"), this);
  m_nameFld            = new LineEdit();
  m_model              = new ProjectDirModel;
  m_treeView           = new DvDirTreeView(this);

  m_nameFld->setMaximumHeight(WidgetHeight);
  m_treeView->setModel(m_model);
  m_treeView->setStyleSheet("border:1px solid rgb(120,120,120);");

  //----layout
  m_topLayout->setMargin(5);
  m_topLayout->setSpacing(10);
  {
    m_topLayout->addWidget(m_treeView, 0);

    QGridLayout *upperLayout = new QGridLayout();
    upperLayout->setMargin(5);
    upperLayout->setHorizontalSpacing(5);
    upperLayout->setVerticalSpacing(10);
    {
      upperLayout->addWidget(m_choosePrjLabel, 0, 0,
                             Qt::AlignRight | Qt::AlignVCenter);
      upperLayout->addWidget(m_chooseProjectCombo, 0, 1);

      upperLayout->addWidget(m_prjNameLabel, 1, 0,
                             Qt::AlignRight | Qt::AlignVCenter);
      upperLayout->addWidget(m_nameFld, 1, 1);
    }
    upperLayout->setColumnStretch(0, 0);
    upperLayout->setColumnStretch(1, 1);

    std::vector<std::string> folderNames;
    pm->getFolderNames(folderNames);
    int i;
    for (i = 0; i < (int)folderNames.size(); i++) {
      std::string name = folderNames[i];
      QString qName    = QString::fromStdString(name);
      FileField *ff    = new FileField(0, qName);
      m_folderFlds.append(qMakePair(name, ff));
      upperLayout->addWidget(new QLabel("+" + qName, this), i + 2, 0,
                             Qt::AlignRight | Qt::AlignVCenter);
      upperLayout->addWidget(ff, i + 2, 1);
    }
    struct {
      QString name;
      std::string folderName;
    } cbs[] = {{tr("Append $scenepath to +drawings"), TProject::Drawings},
               {tr("Append $scenepath to +inputs"), TProject::Inputs},
               {tr("Append $scenepath to +extras"), TProject::Extras}};
    int currentRow = upperLayout->rowCount();

    for (i = 0; i < tArrayCount(cbs); i++) {
      CheckBox *cb = new CheckBox(cbs[i].name);
      cb->setMaximumHeight(WidgetHeight);
      upperLayout->addWidget(cb, currentRow + i, 1);
      m_useScenePathCbs.append(qMakePair(cbs[i].folderName, cb));
    }
    m_topLayout->addLayout(upperLayout);
  }

  pm->addListener(this);
}
示例#9
0
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
	//  Enable standard input/output on Windows Platform for debug
	BOOL consoleAttached = ::AttachConsole(ATTACH_PARENT_PROCESS);
	if (consoleAttached) {
		freopen("CON", "r", stdin);
		freopen("CON", "w", stdout);
		freopen("CON", "w", stderr);
	}
#endif

	/*-- "-layout [レイアウト設定ファイル名]" で、必要なモジュールのPageだけのレイアウトで起動することを可能にする --*/
	QString argumentLayoutFileName = "";
	TFilePath loadScenePath;
	if (argc > 1) {
		for (int a = 1; a < argc; a++) {
			if (QString(argv[a]) == "-layout") {
				argumentLayoutFileName = QString(argv[a + 1]);
				a++;
			} else
				loadScenePath = TFilePath(argv[a]);
		}
	}

	QApplication a(argc, argv);

#ifdef Q_OS_WIN
	//	Since currently OpenToonz does not work with OpenGL of software or angle,
	//	force Qt to use desktop OpenGL
	a.setAttribute(Qt::AA_UseDesktopOpenGL, true);
#endif

	// Some Qt objects are destroyed badly withouth a living qApp. So, we must enforce a way to either
	// postpone the application destruction until the very end, OR ensure that sensible objects are
	// destroyed before.

	// Using a static QApplication only worked on Windows, and in any case C++ respects the statics destruction
	// order ONLY within the same library. On MAC, it made the app crash on exit o_o. So, nope.

	std::auto_ptr<QObject> mainScope(new QObject(&a)); // A QObject destroyed before the qApp is therefore explicitly
	mainScope->setObjectName("mainScope");			   // provided. It can be accessed by looking in the qApp's children.

#ifdef _WIN32
#ifndef x64
	//Store the floating point control word. It will be re-set before Toonz initialization
	//has ended.
	unsigned int fpWord = 0;
	_controlfp_s(&fpWord, 0, 0);
#endif
#endif

#ifdef _WIN32
	//At least on windows, Qt's 4.5.2 native windows feature tend to create
	//weird flickering effects when dragging panel separators.
	a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif

	//Set the app's locale for numeric stuff to standard C. This is important for atof() and similar
	//calls that are locale-dependant.
	setlocale(LC_NUMERIC, "C");

// Set current directory to the bundle/application path - this is needed to have correct relative paths
#ifdef MACOSX
	{
		QDir appDir(QApplication::applicationDirPath());
		appDir.cdUp(), appDir.cdUp(), appDir.cdUp();

		bool ret = QDir::setCurrent(appDir.absolutePath());
		assert(ret);
	}
#endif

	// splash screen
	QPixmap splashPixmap(":Resources/splash.png");
#ifdef _WIN32
	a.setFont(QFont("Arial", 10));
#else
	a.setFont(QFont("Helvetica", 10));
#endif

	QString offsetStr("\n\n\n\n\n\n\n\n");

	TSystem::hasMainLoop(true);

	TMessageRepository::instance();

	QSplashScreen splash(splashPixmap);
	splash.show();
	a.processEvents();

	splash.showMessage(offsetStr + "Initializing QGLFormat...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	// OpenGL
	QGLFormat fmt;
	fmt.setAlpha(true);
	fmt.setStencil(true);
	QGLFormat::setDefaultFormat(fmt);

#ifdef LINUX
	glutInit(&argc, argv);
#endif

	splash.showMessage(offsetStr + "Initializing Toonz environment ...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	//Install run out of contiguous memory callback
	TBigMemoryManager::instance()->setRunOutOfContiguousMemoryHandler(&toonzRunOutOfContMemHandler);

	// Toonz environment
	initToonzEnv();

	// Initialize thread components
	TThread::init();

	TProjectManager *projectManager = TProjectManager::instance();
	if (Preferences::instance()->isSVNEnabled()) {
		// Read Version Control repositories and add it to project manager as "special" svn project root
		VersionControl::instance()->init();
		QList<SVNRepository> repositories = VersionControl::instance()->getRepositories();
		int count = repositories.size();
		for (int i = 0; i < count; i++) {
			SVNRepository r = repositories.at(i);

			TFilePath localPath(r.m_localPath.toStdWString());
			if (!TFileStatus(localPath).doesExist()) {
				try {
					TSystem::mkDir(localPath);
				} catch (TException &e) {
					fatalError(QString::fromStdWString(e.getMessage()));
				}
			}
			projectManager->addSVNProjectsRoot(localPath);
		}
	}

#if defined(MACOSX) && defined(__LP64__)

	//Load the shared memory settings
	int shmmax = Preferences::instance()->getShmMax();
	int shmseg = Preferences::instance()->getShmSeg();
	int shmall = Preferences::instance()->getShmAll();
	int shmmni = Preferences::instance()->getShmMni();

	if (shmall < 0) //Make sure that at least 100 MB of shared memory are available
		shmall = (tipc::shm_maxSharedPages() < (100 << 8)) ? (100 << 8) : -1;

	tipc::shm_set(shmmax, shmseg, shmall, shmmni);

#endif

	// DVDirModel must be instantiated after Version Control initialization...
	FolderListenerManager::instance()->addListener(DvDirModel::instance());

	splash.showMessage(offsetStr + "Loading Translator ...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	// Carico la traduzione contenuta in toonz.qm (se � presente)
	QString languagePathString = QString::fromStdString(toString(TEnv::getConfigDir() + "loc"));
#ifndef WIN32
	//the merge of menu on osx can cause problems with different languages with the Preferences menu
	//qt_mac_set_menubar_merge(false);
	languagePathString += "/" + Preferences::instance()->getCurrentLanguage();
#else
	languagePathString += "\\" + Preferences::instance()->getCurrentLanguage();
#endif
	QTranslator translator;
#ifdef LINETEST
	translator.load("linetest", languagePathString);
#else
	translator.load("toonz", languagePathString);
#endif

	// La installo
	a.installTranslator(&translator);

	// Carico la traduzione contenuta in toonzqt.qm (se e' presente)
	QTranslator translator2;
	translator2.load("toonzqt", languagePathString);
	a.installTranslator(&translator2);

	// Carico la traduzione contenuta in tnzcore.qm (se e' presente)
	QTranslator tnzcoreTranslator;
	tnzcoreTranslator.load("tnzcore", languagePathString);
	qApp->installTranslator(&tnzcoreTranslator);

	// Carico la traduzione contenuta in toonzlib.qm (se e' presente)
	QTranslator toonzlibTranslator;
	toonzlibTranslator.load("toonzlib", languagePathString);
	qApp->installTranslator(&toonzlibTranslator);

	// Carico la traduzione contenuta in colorfx.qm (se e' presente)
	QTranslator colorfxTranslator;
	colorfxTranslator.load("colorfx", languagePathString);
	qApp->installTranslator(&colorfxTranslator);

	// Carico la traduzione contenuta in tools.qm
	QTranslator toolTranslator;
	toolTranslator.load("tnztools", languagePathString);
	qApp->installTranslator(&toolTranslator);

	// Aggiorno la traduzione delle properties di tutti i tools
	TTool::updateToolsPropertiesTranslation();

	splash.showMessage(offsetStr + "Loading styles ...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	// stile
	QApplication::setStyle("windows");

	IconGenerator::setFilmstripIconSize(Preferences::instance()->getIconSize());

	splash.showMessage(offsetStr + "Loading shaders ...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	loadShaderInterfaces(ToonzFolder::getLibraryFolder() + TFilePath("shaders"));

	splash.showMessage(offsetStr + "Initializing Toonz application ...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	TTool::setApplication(TApp::instance());
	TApp::instance()->init();

//iwsw commented out temporarily
#if 0 
  QStringList monitorNames;
  /*-- 接続モニタがPVM-2541の場合のみLUTを読み込む --*/
  if (Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  {
	  /*-- 接続モニタがPVM-2541の場合のみLUTを読み込む --*/
	  monitorNames = Ghibli3DLutUtil::getMonitorName();
	  if (monitorNames.contains(QString::fromStdWString(L"PVM-2541")))
		  /*-- 3DLUTファイルを読み込む --*/
		  Ghibli3DLutUtil::loadLutFile(Preferences::instance()->get3DLutPath());
  }
  /*-- 接続モニタをスプラッシュ画面にも表示 --*/
  if (!monitorNames.isEmpty())
  {
	  lastUpdateStr += QString("Monitor Name : ");
	  for (int mn = 0; mn < monitorNames.size(); mn++)
	  {
		  if (mn != 0)
			  lastUpdateStr += QString(", ");
		  lastUpdateStr += monitorNames.at(mn);
	  }
	  lastUpdateStr += QString("\n");
  }
#endif

	splash.showMessage(offsetStr + "Loading Plugins...", Qt::AlignCenter, Qt::white);
	a.processEvents();
	/* poll the thread ends: 
	 絶対に必要なわけではないが PluginLoader は中で setup ハンドラが常に固有のスレッドで呼ばれるよう main thread queue の blocking をしているので
	 processEvents を行う必要がある
   */
	while (!PluginLoader::load_entries("")) {
		a.processEvents();
	}

	splash.showMessage(offsetStr + "Creating main window ...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	/*-- Layoutファイル名をMainWindowのctorに渡す --*/
	MainWindow w(argumentLayoutFileName);

	splash.showMessage(offsetStr + "Loading style sheet ...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	// Carico lo styleSheet
	QString currentStyle = Preferences::instance()->getCurrentStyleSheet();
	a.setStyleSheet(currentStyle);

	TApp::instance()->setMainWindow(&w);
	w.setWindowTitle(applicationFullName);

	splash.showMessage(offsetStr + "Starting main window ...", Qt::AlignCenter, Qt::white);
	a.processEvents();

	TFilePath fp = ToonzFolder::getModuleFile("mainwindow.ini");
	QSettings settings(toQString(fp), QSettings::IniFormat);
	w.restoreGeometry(settings.value("MainWindowGeometry").toByteArray());

#ifndef MACOSX
	//Workaround for the maximized window case: Qt delivers two resize events, one in the normal geometry, before
	//maximizing (why!?), the second afterwards - all inside the following show() call. This makes troublesome for
	//the docking system to correctly restore the saved geometry. Fortunately, MainWindow::showEvent(..) gets called
	//just between the two, so we can disable the currentRoom layout right before showing and re-enable it after
	//the normal resize has happened.
	if (w.isMaximized())
		w.getCurrentRoom()->layout()->setEnabled(false);
#endif

	QRect splashGeometry = splash.geometry();
	splash.finish(&w);

	a.setQuitOnLastWindowClosed(false);
// a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
	w.checkForUpdates();

	w.show();

	//Show floating panels only after the main window has been shown
	w.startupFloatingPanels();

	CommandManager::instance()->execute(T_Hand);
	if (!loadScenePath.isEmpty()) {
		splash.showMessage(QString("Loading file '") + loadScenePath.getQString() + "'...", Qt::AlignCenter, Qt::white);

		loadScenePath = loadScenePath.withType("tnz");
		if (TFileStatus(loadScenePath).doesExist())
			IoCmd::loadScene(loadScenePath);
	}

	QFont *myFont;

	std::string family = EnvSoftwareCurrentFont;
	myFont = new QFont(QString(family.c_str()));

	myFont->setPixelSize(EnvSoftwareCurrentFontSize);
	/*-- フォントのBoldの指定 --*/
	std::string weight = EnvSoftwareCurrentFontWeight;
	if (strcmp(weight.c_str(), "Yes") == 0)
		myFont->setBold(true);
	else
		myFont->setBold(false);
	a.setFont(*myFont);

	QAction *action = CommandManager::instance()->getAction("MI_OpenTMessage");
	if (action)
		QObject::connect(TMessageRepository::instance(), SIGNAL(openMessageCenter()), action, SLOT(trigger()));

	QObject::connect(
		TUndoManager::manager(), SIGNAL(somethingChanged()),
		TApp::instance()->getCurrentScene(), SLOT(setDirtyFlag()));

#ifdef _WIN32
#ifndef x64
	//On 32-bit architecture, there could be cases in which initialization could alter the
	//FPU floating point control word. I've seen this happen when loading some AVI coded (VFAPI),
	//where 80-bit internal precision was used instead of the standard 64-bit (much faster and
	//sufficient - especially considering that x86 truncates to 64-bit representation anyway).
	//IN ANY CASE, revert to the original control word.
	//In the x64 case these precision changes simply should not take place up to _controlfp_s
	//documentation.
	_controlfp_s(0, fpWord, -1);
#endif
#endif

	a.installEventFilter(TApp::instance());

	int ret = a.exec();

	TUndoManager::manager()->reset();
	PreviewFxManager::instance()->reset();

#ifdef _WIN32
	if (consoleAttached) {
		::FreeConsole();
	}
#endif

	return ret;
}
示例#10
0
/*! In particolare imposta la projectRoot e
    la stuffDir, controlla se la directory di outputs esiste (e provvede a
    crearla in caso contrario) verifica inoltre che stuffDir esista.
*/
void initToonzEnv()
{
	StudioPalette::enable(true);

	TEnv::setApplication(applicationName, applicationVersion, applicationRevision);
	TEnv::setRootVarName(rootVarName);
	TEnv::setSystemVarPrefix(systemVarPrefix);
	TEnv::setDllRelativeDir(TFilePath(dllRelativePath));

	QCoreApplication::setOrganizationName("OpenToonz");
	QCoreApplication::setOrganizationDomain("");
	QString fullApplicationNameQStr = QString(applicationName) + " " + applicationVersion;
	QCoreApplication::setApplicationName(fullApplicationNameQStr);

	/*-- TOONZROOTのPathの確認 --*/
	// controllo se la xxxroot e' definita e corrisponde ad un folder esistente
	TFilePath stuffDir = TEnv::getStuffDir();
	if (stuffDir == TFilePath() || !TFileStatus(stuffDir).isDirectory()) {
		if (stuffDir == TFilePath())
			fatalError("Undefined or empty: \"" + toQString(TEnv::getRootVarPath()) + "\"");
		else
			fatalError("Folder \"" + toQString(stuffDir) + "\" not found or not readable");
	}

	Tiio::defineStd();
	initImageIo();
	initSoundIo();
	initStdFx();
	initColorFx();

	// TPluginManager::instance()->loadStandardPlugins();

	TFilePath library = ToonzFolder::getLibraryFolder();

	TRasterImagePatternStrokeStyle::setRootDir(library);
	TVectorImagePatternStrokeStyle::setRootDir(library);
	TVectorBrushStyle::setRootDir(library);

	CustomStyleManager::setRootPath(library);

	// sembra indispensabile nella lettura dei .tab 2.2:
	TPalette::setRootDir(library);
	TImageStyle::setLibraryDir(library);

	//TProjectManager::instance()->enableTabMode(true);

	TProjectManager *projectManager = TProjectManager::instance();

	/*-- TOONZPROJECTSのパスセットを取得する。(TOONZPROJECTSはセミコロンで区切って複数設定可能) --*/
	TFilePathSet projectsRoots = ToonzFolder::getProjectsFolders();
	TFilePathSet::iterator it;
	for (it = projectsRoots.begin(); it != projectsRoots.end(); ++it)
		projectManager->addProjectsRoot(*it);

	/*-- もしまだ無ければ、TOONZROOT/sandboxにsandboxプロジェクトを作る --*/
	projectManager->createSandboxIfNeeded();

	/*
  TProjectP project = projectManager->getCurrentProject();
  Non dovrebbe servire per Tab:
  project->setFolder(TProject::Drawings, TFilePath("$scenepath"));
  project->setFolder(TProject::Extras, TFilePath("$scenepath"));
  project->setUseScenePath(TProject::Drawings, false);
  project->setUseScenePath(TProject::Extras, false);
*/
	// Imposto la rootDir per ImageCache

	/*-- TOONZCACHEROOTの設定  --*/
	TFilePath cacheDir = ToonzFolder::getCacheRootFolder();
	if (cacheDir.isEmpty())
		cacheDir = TEnv::getStuffDir() + "cache";
	TImageCache::instance()->setRootDir(cacheDir);
}