コード例 #1
0
ファイル: levelcommand.cpp プロジェクト: CroW-CZ/opentoonz
	void execute()
	{
		TApp *app = TApp::instance();
		ToonzScene *scene = app->getCurrentScene()->getScene();

		TLevelSet *levelSet = scene->getLevelSet();

		std::set<TXshLevel *> usedLevels;
		scene->getTopXsheet()->getUsedLevels(usedLevels);

		std::vector<TXshLevel *> unused;

		for (int i = 0; i < levelSet->getLevelCount(); i++) {
			TXshLevel *xl = levelSet->getLevel(i);
			if (usedLevels.count(xl) == 0)
				unused.push_back(xl);
		}
		if (unused.empty()) {
			DVGui::error(QObject::tr("No unused levels"));
			return;
		} else {
			TUndoManager *um = TUndoManager::manager();
			um->beginBlock();
			for (int i = 0; i < (int)unused.size(); i++) {
				TXshLevel *xl = unused[i];
				um->add(new DeleteLevelUndo(xl));
				scene->getLevelSet()->removeLevel(xl);
			}
			TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
			TApp::instance()->getCurrentScene()->notifyCastChange();

			um->endBlock();
		}
	}
コード例 #2
0
ファイル: filmstrip.cpp プロジェクト: jcome/opentoonz
/*! 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();
}