void makeScreenSaver(
	TFilePath scrFn,
	TFilePath swfFn,
	std::string screenSaverName)
{
	struct _stat results;
	if (_wstat(swfFn.getWideString().c_str(), &results) != 0)
		throw TException(L"Can't stat file " + swfFn.getWideString());

	int swfSize = results.st_size;
	std::auto_ptr<char> swf(new char[swfSize]);
	FILE *chan = _wfopen(swfFn.getWideString().c_str(), L"rb");
	if (!chan)
		throw TException(L"fopen failed on " + swfFn.getWideString());
	fread(swf.get(), swfSize, 1, chan);
	fclose(chan);

	TFilePath svscrn = TSystem::getBinDir() + "screensaver.dat";
	if (!TFileStatus(svscrn).doesExist()) {
		throw TException(
			std::wstring(L"Screensaver template not found: ") +
			svscrn.getWideString());
	}
	TSystem::copyFile(scrFn, svscrn);
	HANDLE hUpdateRes =
		BeginUpdateResourceW(scrFn.getWideString().c_str(), FALSE);
	if (hUpdateRes == NULL)
		throw TException(L"can't write " + scrFn.getWideString());

	BOOL result = UpdateResource(
		hUpdateRes,
		"FLASHFILE",
		MAKEINTRESOURCE(101),
		MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
		swf.get(),
		swfSize);
	if (result == FALSE)
		throw TException(L"can't add resource to " + scrFn.getWideString());
	/*
  result = UpdateResource(
     hUpdateRes,      
     RT_STRING,  
     MAKEINTRESOURCE(1),                  
     MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),  
     (void*)screenSaverName.c_str(),                   
     screenSaverName.size());

  if (result == FALSE) 
    throw TException(L"can't add name to "+scrFn.getWideString());
 */

	if (!EndUpdateResource(hUpdateRes, FALSE))
		throw TException(L"Couldn't write " + scrFn.getWideString());
}
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);
    }
  }
}
Beispiel #3
0
bool TSystem::showDocument(const TFilePath &path) {
#ifdef _WIN32
  int ret = (int)ShellExecuteW(0, L"open", path.getWideString().c_str(), 0, 0,
                               SW_SHOWNORMAL);
  if (ret <= 32) {
    return false;
    throw TSystemException(path, "Can't open");
  }
  return true;
#else
  string cmd = "open ";
  string thePath(::to_string(path));
  UINT pos = 0, count = 0;
  // string newPath;
  char newPath[2048];

  while (pos < thePath.size()) {
    char c                         = thePath[pos];
    if (c == ' ') newPath[count++] = '\\';

    newPath[count++] = c;
    ++pos;
  }
  newPath[count] = 0;

  cmd = cmd + string(newPath);
  system(cmd.c_str());
  return true;
#endif
}
TLevelReaderMov::TLevelReaderMov(const TFilePath &path) : TLevelReader(path) {
  static TAtomicVar count;
  unsigned int currCount = ++count;
  m_id                   = currCount;

  QLocalSocket socket;
  tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
                             t32bitsrv::srvCmdline());

  tipc::Stream stream(&socket);
  tipc::Message msg;

  stream << (msg << QString("$initLRMov") << m_id
                 << QString::fromStdWString(path.getWideString()));
  if (tipc::readMessage(stream, msg) != "ok")
    throw TImageException(path, "Couldn't open file");

  double frameRate;
  msg >> m_lx >> m_ly >> frameRate >> tipc::clr;

  m_info              = new TImageInfo;
  m_info->m_lx        = m_lx;
  m_info->m_ly        = m_ly;
  m_info->m_frameRate = frameRate;
}
	bool execute()
	{
		TFilePath fp;
		QString fileName = "helloworld.qs";
		QFile scriptFile(QString::fromStdWString(fp.getWideString()));
		if (!scriptFile.open(QIODevice::ReadOnly)) {
			DVGui::MsgBox(DVGui::WARNING, QObject::tr("File not found"));
			return false;
		} else {
			QTextStream stream(&scriptFile);
			QString contents = stream.readAll();
			scriptFile.close();
			QScriptEngine myEngine;
			QScriptEngineDebugger debugger;
			debugger.attachTo(&myEngine);

			QScriptValue fFoo = myEngine.newFunction(foo);
			QScriptValue fGetLevel = myEngine.newFunction(getLevel);

			myEngine.globalObject().setProperty("foo", fFoo);
			myEngine.globalObject().setProperty("getLevel", fGetLevel);
			debugger.action(QScriptEngineDebugger::InterruptAction)->trigger();
			myEngine.evaluate(contents, fileName);
		}
		return true;
	}
void MagpieFileImportPopup::showEvent(QShowEvent *)
{
	if (m_info == 0)
		return;

	int frameCount = m_info->getFrameCount();
	m_fromField->setRange(1, frameCount);
	m_fromField->setValue(1);
	m_toField->setRange(1, frameCount);
	m_toField->setValue(frameCount);

	int i;
	QList<QString> actsIdentifier = m_info->getActsIdentifier();
	for (i = 0; i < m_actFields.size(); i++) {
		IntLineEdit *field = m_actFields.at(i).second;
		QLabel *label = m_actFields.at(i).first;
		if (i >= actsIdentifier.size()) {
			field->hide();
			label->hide();
			continue;
		}
		QString act = actsIdentifier.at(i);
		field->setProperty("act", QVariant(act));
		field->show();
		label->setText(act);
		label->show();
	}
	QString oldLevelPath = m_levelField->getPath();
	TFilePath oldFilePath(oldLevelPath.toStdWString());
	TFilePath perntDir = oldFilePath.getParentDir();
	m_levelField->setPath(QString::fromStdWString(perntDir.getWideString()));
}
Beispiel #7
0
void loadControllerData(const TFilePath &fp, ControllerData &data)
{
	Tifstream is(fp);
	if (!is || !is.good()) {
		throw TException(
			L"Unable to get Farm Controller Data (looking for '" + fp.getWideString() + L"')");
	}

	while (!is.eof()) {
		char line[1024];
		is.getline(line, 1024);

		if (line[0] != '#' && QString(line) != "") {
			std::istrstream iss(line);

			char hostName[512];
			char ipAddr[80];
			int port;

			iss >> hostName >> ipAddr >> port;

			data.m_hostName = hostName;
			data.m_ipAddress = ipAddr;
			data.m_port = port;
			break;
		}
	}
 void refresh() override {
   TDoubleKeyframe kf;
   TDoubleParam *curve = getCurve();
   if (curve) kf       = curve->getKeyframeAt(getR0());
   if (curve && kf.m_isKeyframe) {
     TFilePath path;
     int fieldIndex       = 0;
     std::string unitName = "";
     if (kf.m_type == TDoubleKeyframe::File) {
       path                           = kf.m_fileParams.m_path;
       fieldIndex                     = kf.m_fileParams.m_fieldIndex;
       if (fieldIndex < 0) fieldIndex = 0;
       unitName                       = kf.m_unitName;
       if (unitName == "") {
         TMeasure *measure = curve->getMeasure();
         if (measure) {
           const TUnit *unit  = measure->getCurrentUnit();
           if (unit) unitName = ::to_string(unit->getDefaultExtension());
         }
       }
     }
     m_fileFld->setPath(QString::fromStdWString(path.getWideString()));
     m_fieldIndexFld->setText(QString::number(fieldIndex + 1));
     m_measureFld->setText(QString::fromStdString(unitName));
   }
 }
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."));
	}
}
Beispiel #10
0
 inline static TFilePath getRelativePath(const TFilePath &file,
                                         const TFilePath &relTo) {
   QDir relToDir(
       QString::fromStdWString(relTo.getParentDir().getWideString()));
   QString relFileStr(relToDir.relativeFilePath(
       QString::fromStdWString(file.getWideString())));
   return TFilePath(relFileStr.toStdWString());
 }
Beispiel #11
0
 inline static TFilePath getAbsolutePath(const TFilePath &file,
                                         const TFilePath &relTo) {
   QDir relToDir(
       QString::fromStdWString(relTo.getParentDir().getWideString()));
   QString absFileStr(relToDir.absoluteFilePath(
       QString::fromStdWString(file.getWideString())));
   return TFilePath(absFileStr.toStdWString());
 }
void installScreenSaver(TFilePath scr)
{
	std::wstring cmd = L"desk.cpl,InstallScreenSaver " + scr.getWideString();
	int ret = (int)
		ShellExecuteW(0, L"open", L"rundll32.exe", cmd.c_str(), 0, SW_SHOWNORMAL);
	if (ret <= 32)
		throw;
}
Beispiel #13
0
void CastTreeViewer::onItemChanged(QTreeWidgetItem *item, int column) {
  if (column != 0) return;
  if (item->isSelected()) {
    TFilePath oldPath(item->data(1, Qt::DisplayRole).toString().toStdWString());
    TFilePath newPath =
        getLevelSet()->renameFolder(oldPath, item->text(0).toStdWString());
    item->setText(1, QString::fromStdWString(newPath.getWideString()));
  }
}
Beispiel #14
0
Tifstream::Tifstream(const TFilePath &fp)
	: ifstream(QString::fromStdWString(fp.getWideString()).toUtf8().data(), ios::binary)
/*: ifstream(openFileForReading(fp), ios::binary) 
NO! Questo costruttore non e' standard, anche se e' presente 
in molte versioni. Nel MAC non c'e e fa un cast a char*
sperando che sia il nome del file => compila ma non funziona
*/
{
}
Beispiel #15
0
void TSystem::hideFile(const TFilePath &fp) {
#ifdef _WIN32
  if (!SetFileAttributesW(fp.getWideString().c_str(), FILE_ATTRIBUTE_HIDDEN))
    throw TSystemException(fp, "can't hide file!");
#else  // MACOSX, and others
  TSystem::renameFile(TFilePath(fp.getParentDir() + L"." + fp.getLevelNameW()),
                      fp);
#endif
}
Beispiel #16
0
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 (...) {
  }
}
Beispiel #17
0
/*! Returns the absolute path of \b fp.
        If \b fp contains "$project", replaces it with the name of the project.
        \note the returned path can contain "$scene"
*/
TFilePath TProject::decode(TFilePath fp) const {
  for (;;) {
    wstring fpstr = fp.getWideString();
    int j         = fpstr.find(L"$project");
    if (j == (int)wstring::npos) break;
    fpstr.replace(j, 8, getName().getWideString());
    fp = TFilePath(fpstr);
  }
  return makeAbsolute(getProjectFolder(), fp);
}
	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);
			}
		}
	}
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);
}
Beispiel #20
0
/*! Returns the index of the folder specified in the path \b folderDir.
        Returns -1 if \b folderDir isn't a folder of the project.
*/
int TProject::getFolderIndexFromPath(const TFilePath &folderDir) {
  TFilePath scenePath          = decode(getFolder(Scenes));
  bool sceneDependentScenePath = false;
  if (scenePath.getName().find("$scene") != string::npos) {
    scenePath               = scenePath.getParentDir();
    sceneDependentScenePath = true;
  }
  int folderIndex;
  for (folderIndex = 0; folderIndex < getFolderCount(); folderIndex++)
    if (isConstantFolder(folderIndex)) {
      TFilePath fp = decode(getFolder(folderIndex));
      if (fp == folderDir) return folderIndex;
    } else {
      TFilePath fp = decode(getFolder(folderIndex));
      wstring a    = fp.getWideString();
      wstring b    = folderDir.getWideString();
      int alen     = a.length();
      int blen     = b.length();
      int i        = a.find(L"$scene");
      assert(i != (int)wstring::npos);
      if (i == (int)wstring::npos) continue;
      int j = i + 1;
      while (j < alen && isalnum(a[j])) j++;
      // a.substr(i,j-i) == "$scenexxxx"
      int k = j + blen - alen;
      if (!(0 <= i && i < k && k <= blen)) continue;
      assert(i < blen);
      if (i > 0 && a.substr(0, i) != b.substr(0, i)) continue;
      if (k < blen && (j >= alen || a.substr(j) != b.substr(k))) continue;
      wstring v = b.substr(i, k - i);
      TFilePath scene(v + L".tnz");
      if (sceneDependentScenePath)
        scene = scenePath + scene.getWideName() + scene;
      else
        scene = scenePath + scene;
      if (TFileStatus(scene).doesExist()) return folderIndex;
    }
  return -1;
}
Beispiel #21
0
TSoundTrackWriterP::TSoundTrackWriterP(const TFilePath &path) {
  QString type = QString::fromStdString(toLower(path.getType()));
  std::map<QString, TSoundTrackWriterCreateProc *>::iterator it;
  it = SoundTrackWriterTable.find(type);
  if (it != SoundTrackWriterTable.end()) {
    m_pointer = it->second(path);
    assert(m_pointer);
    m_pointer->addRef();
  } else {
    m_pointer = 0;
    throw TException(path.getWideString() +
                     L"soundtrack writer not implemented");
  }
}
Beispiel #22
0
  bool operator()(const TFilePath &a, const TFilePath &b) const {
    // Perform case sensitive compare, fallback to case insensitive.
    const wstring a_str = a.getWideString();
    const wstring b_str = b.getWideString();

    unsigned int i   = 0;
    int case_compare = -1;
    while (a_str[i] || b_str[i]) {
      if (a_str[i] != b_str[i]) {
        const wchar_t a_wchar = towlower(a_str[i]);
        const wchar_t b_wchar = towlower(b_str[i]);
        if (a_wchar < b_wchar) {
          return true;
        } else if (a_wchar > b_wchar) {
          return false;
        } else if (case_compare == -1) {
          case_compare = a_str[i] < b_str[i];
        }
      }
      i++;
    }
    return (case_compare == 1);
  }
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;
}
Beispiel #24
0
TLevelP TLevelReader::loadInfo()
{
	TFilePath parentDir = m_path.getParentDir();
	TFilePath levelName(m_path.getLevelName());
	//  cout << "Parent dir = '" << parentDir << "'" << endl;
	//  cout << "Level name = '" << levelName << "'" << endl;
	TFilePathSet files;
	try {
		files = TSystem::readDirectory(parentDir, false, true, true);
	} catch (...) {
		throw TImageException(m_path, "unable to read directory content");
	}
	TLevelP level;
	vector<TFilePath> data;
	for (TFilePathSet::iterator it = files.begin(); it != files.end(); it++) {
		TFilePath ln(it->getLevelName());
		// cout << "try " << *it << "  " << it->getLevelName() <<  endl;
		if (levelName == TFilePath(it->getLevelName())) {
			try {
				level->setFrame(it->getFrame(), TImageP());
				data.push_back(*it);
			} catch (string msg) {
				throw msg;
			}
		}
	}
	if (!data.empty()) {
		std::vector<TFilePath>::iterator it = std::min_element(data.begin(), data.end(), myLess);
		TFilePath fr = (*it).withoutParentDir().withName("").withType("");
		wstring ws = fr.getWideString();
		if (ws.length() == 5) {
			if (ws.rfind(L'_') == (int)wstring::npos)
				m_frameFormat = TFrameId::FOUR_ZEROS;
			else
				m_frameFormat = TFrameId::UNDERSCORE_FOUR_ZEROS;
		} else {
			if (ws.rfind(L'_') == (int)wstring::npos)
				m_frameFormat = TFrameId::NO_PAD;
			else
				m_frameFormat = TFrameId::UNDERSCORE_NO_PAD;
		}

	} else
		m_frameFormat = TFrameId::FOUR_ZEROS;

	return level;
}
TLevelWriterMov::TLevelWriterMov(const TFilePath &path, TPropertyGroup *winfo)
    : TLevelWriter(path, winfo) {
  static TAtomicVar count;
  unsigned int currCount = ++count;
  m_id                   = currCount;

  QLocalSocket socket;
  tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
                             t32bitsrv::srvCmdline());

  tipc::Stream stream(&socket);
  tipc::Message msg;

  QString res, propsFp;
  if (winfo) {
    // Request a temporary file to store the infos to
    stream << (msg << QString("$tmpfile_request")
                   << QString("initLWMov") + QString::number(currCount));
    if (tipc::readMessage(stream, msg) != "ok") goto err;

    msg >> propsFp >> tipc::clr;
    assert(!propsFp.isEmpty());

    TFilePath propsTfp(propsFp.toStdWString());
    {
      TOStream os(propsTfp);
      winfo->saveData(os);
    }
  }

  // Pass fp to the server
  stream << (msg << QString("$initLWMov") << m_id
                 << QString::fromStdWString(path.getWideString()) << propsFp);
  if (tipc::readMessage(stream, msg) != "ok") goto err;

  if (winfo) {
    stream << (msg << tipc::clr << QString("$tmpfile_release")
                   << QString("initLWMov") + QString::number(currCount));
    if (tipc::readMessage(stream, msg) != "ok") goto err;
  }

  return;

err:

  throw TException("Unable to write file");
}
void CastTreeViewer::populateFolder(QTreeWidgetItem *folder)
{
	TFilePath folderPath(folder->data(1, Qt::DisplayRole).toString().toStdWString());
	std::vector<TFilePath> folders;
	getLevelSet()->listFolders(folders, folderPath);
	int i;
	for (i = 0; i < (int)folders.size(); i++) {
		TFilePath fp = folders[i];
		QString fpQstr = QString::fromStdWString(fp.getWideString());
		QString name = QString::fromStdWString(fp.withoutParentDir().getWideString());
		QTreeWidgetItem *child = new QTreeWidgetItem((QTreeWidgetItem *)0, QStringList(name) << fpQstr);
		if (name != AudioFolderName)
			child->setFlags(child->flags() | Qt::ItemIsEditable);
		folder->addChild(child);
		populateFolder(child);
	}
}
void CasmSubmitPage::Data::loadCasm(const TFilePath &fp)
{
	if (!TFileStatus(fp).doesExist()) {
		string msg = toString(fp.getWideString()) + "\n";
		msg += "File not found\n";
		msg += "Please verify that the path and file name are correct";
		m_filepathTextField->setText("");
		TMessage::error(msg);
		return;
	}

	Application::instance()->setCurrentFolder(fp.getParentDir());

	string uncString = convertToUncString(fp);

	m_filepathTextField->setText(uncString);
	m_taskNameTextField->setText(TFilePath(uncString).getName());

#ifdef WIN32
	int x = uncString.find("\\", 2);
	while (x != string::npos) {
		uncString.replace(x, 1, "/", 0, 1);
		x = uncString.find("\\", x + 1);
	}
#endif

	TFilePath uncFilePath = TFilePath(uncString);
	CasmFileInfo casmFileInfo(uncFilePath);
	int start, end;
	bool interlaced;
	casmFileInfo.getFrameRange(start, end, interlaced);

	if (m_casmTask)
		delete m_casmTask;
	m_casmTask = new CasmTask;

	m_casmTask->m_casmFile = uncString;
	m_casmTask->m_start = start;
	m_casmTask->m_end = end;
	m_casmTask->m_step = 1;

	m_configPanel->setTask(m_casmTask);
}
Beispiel #28
0
/*! Called when the current palette is switched
*/
void StudioPaletteTreeViewer::onCurrentItemChanged(QTreeWidgetItem *current,
                                                   QTreeWidgetItem *previous) {
  TFilePath oldPath = getItemPath(previous);
  TFilePath newPath = getCurrentFolderPath();
  if (!m_studioPaletteHandle) return;

  if (m_currentPalette.getPointer() && m_currentPalette->getDirtyFlag()) {
    TFilePath oldPath = StudioPalette::instance()->getPalettePath(
        m_currentPalette->getGlobalName());
    if (oldPath == newPath) return;
    wstring gname = m_currentPalette->getGlobalName();
    QString question;
    question = "The current palette " +
               QString::fromStdWString(oldPath.getWideString()) +
               " \nin the studio palette has been modified. Do you want to "
               "save your changes?";
    int ret = DVGui::MsgBox(question, QObject::tr("Save"),
                            QObject::tr("Discard"), QObject::tr("Cancel"), 0);
    if (ret == 3) {
      setCurrentItem(getItem(oldPath));
      return;
    }
    if (ret == 1) {
      // If the palette is level palette (i.e. NOT stdio palette), just
      // overwrite it
      if (gname.empty())
        StudioPalette::instance()->save(oldPath, m_currentPalette.getPointer());
      else
        StudioPalette::instance()->setPalette(
            oldPath, m_currentPalette.getPointer(), false);
    }
    m_currentPalette->setDirtyFlag(false);
  }
  // load palette here
  m_currentPalette = StudioPalette::instance()->getPalette(newPath, false);
  m_studioPaletteHandle->setPalette(m_currentPalette.getPointer());
  m_studioPaletteHandle->notifyPaletteSwitched();
  StudioPaletteCmd::updateAllLinkedStyles(m_levelPaletteHandle, m_xsheetHandle);
}
Beispiel #29
0
void CastTreeViewer::newFolder() {
  QTreeWidgetItem *parentItem = currentItem();
  if (parentItem == (QTreeWidgetItem *)0) return;
  QString parentName = parentItem->data(0, Qt::DisplayRole).toString();
  if (parentName == AudioFolderName) return;

  TFilePath parentPath =
      TFilePath(parentItem->data(1, Qt::DisplayRole).toString().toStdWString());
  QString childName("New Folder");
  TFilePath childPath   = parentPath + childName.toStdWString();
  QString childPathQstr = QString::fromStdWString(childPath.getWideString());
  QTreeWidgetItem *childItem =
      new QTreeWidgetItem(parentItem, QStringList(childName) << childPathQstr);
  childItem->setFlags(childItem->flags() | Qt::ItemIsEditable);
  parentItem->addChild(childItem);
  setCurrentItem(childItem);
  editItem(childItem);
  TLevelSet *levelSet =
      TApp::instance()->getCurrentScene()->getScene()->getLevelSet();
  levelSet->createFolder(parentPath, childName.toStdWString());
  TApp::instance()->getCurrentScene()->setDirtyFlag(true);
}
void TFarmStuff::getControllerData(QString &hostName, QString &ipAddr,
                                   int &port) {
  ControllerData data;

  TFilePath groot   = getGlobalRoot();
  QString grootpath = QString::fromStdWString(groot.getWideString());

  if (groot.isEmpty() || grootpath == " ")
    throw TFarmStuff::TMissingGRootEnvironmentVariable();

  bool fileExists = false;
  TFileStatus fs(groot);
  fileExists = fs.doesExist();
  if (!fileExists) throw TFarmStuff::TMissingGRootFolder();

  TFilePath fp = groot + "config" + "controller.txt";
  ::loadControllerData(fp, data);

  hostName = data.m_hostName;
  ipAddr   = data.m_ipAddress;
  port     = data.m_port;
}