Example #1
0
/**
 * @brief Add movies to the database and updates the application.
 */
void MainWindow::updateApp()
{
    QString l_directoryName = m_app->getFilesPath();
    QDirIterator l_path(l_directoryName, QDir::NoDotAndDotDot | QDir::Files,QDirIterator::Subdirectories);

    while (l_path.hasNext()) {
        l_path.next();

        QString l_filePath = l_path.fileInfo().absoluteFilePath();
        QString l_fileSuffix = l_path.fileInfo().suffix();
        // First we check whether the file is already saved or not
        QSqlQuery l_knownMovieQuery = m_app->getDatabaseManager()->getMovies("file_path",l_filePath);
        if (!l_knownMovieQuery.next() && (l_fileSuffix == "mkv" || l_fileSuffix == "avi" || l_fileSuffix == "mp4") )
        {
            QStringList l_value;
            l_value << "title" << l_path.fileInfo().baseName()
                    << "file_path" << l_path.fileInfo().absoluteFilePath()
                    << "format" << l_fileSuffix;
            m_app->getDatabaseManager()->insertNewTitle(l_value);
        }

    }
    fillLeftPannel();
    fillMoviesList();
}
	void bc_texture_loader::content_processing(core::bc_content_loading_context& p_context) const
	{
		core::bc_path l_path(p_context.m_file_path.c_str());
		core::bc_estring l_extension = l_path.get_file_extension();
		graphic::bc_image_format l_format;

		// Bug tolower operate only on single byte chars
		std::transform(std::begin(l_extension), std::end(l_extension), std::begin(l_extension), tolower);

		if (l_extension == bcL(".dds"))
		{
			l_format = graphic::bc_image_format::dds;
		}
		else if (l_extension == bcL(".bmp"))
		{
			l_format = graphic::bc_image_format::bmp;
		}
		else if (l_extension == bcL(".png"))
		{
			l_format = graphic::bc_image_format::png;
		}
		else if (l_extension == bcL(".gif"))
		{
			l_format = graphic::bc_image_format::gif;
		}
		else if (l_extension == bcL(".tiff"))
		{
			l_format = graphic::bc_image_format::tiff;
		}
		else if (l_extension == bcL(".jpg"))
		{
			l_format = graphic::bc_image_format::jpg;
		}
		else
		{
			throw bc_invalid_argument_exception((core::bc_to_string(p_context.m_file_path) + " Unknown image file format").c_str());
		}

		graphic::bc_device& l_device = core::bc_get_service< game::bc_game_system >()->get_render_system().get_device();
		graphic::bc_texture_config* l_config = p_context.m_parameter.get_value<graphic::bc_texture_config>(core::g_param_texture_config);

		l_config = l_config ? l_config : &s_default_config;

		graphic::bc_texture2d_ptr l_result = l_device.create_texture2d
		(
			*l_config,
			p_context.m_file_buffer.get(),
			p_context.m_file_buffer_size,
			l_format
		);

		p_context.set_result(graphic::bc_texture2d_content(std::move(l_result)));
	}
Example #3
0
void SaveISISNexus::selog() {
  // find log files with names <RawFilenameWithoutExt>_LogName.txt and save them
  // in potentialLogFiles
  std::vector<std::string> potentialLogFiles;
  Poco::File l_path(inputFilename);
  std::string l_filenamePart = Poco::Path(l_path.path()).getFileName();
  std::string::size_type i = l_filenamePart.find_last_of('.');
  if (i != std::string::npos) // remove the file extension
  {
    l_filenamePart.erase(i);
  }
  std::string base_name = l_filenamePart;
  boost::regex regex(l_filenamePart + "_.*\\.txt",
                     boost::regex_constants::icase);
  Poco::DirectoryIterator end_iter;
  for (Poco::DirectoryIterator dir_itr(Poco::Path(inputFilename).parent());
       dir_itr != end_iter; ++dir_itr) {
    if (!Poco::File(dir_itr->path()).isFile())
      continue;

    l_filenamePart = Poco::Path(dir_itr->path()).getFileName();

    if (boost::regex_match(l_filenamePart, regex)) {
      potentialLogFiles.push_back(dir_itr->path());
    }
  }

  Progress prog(this, 0.5, 1, potentialLogFiles.size());

  NXmakegroup(handle, "selog", "IXselog");
  NXopengroup(handle, "selog", "IXselog");

  // create a log for each of the found log files
  std::size_t nBase = base_name.size() + 1;
  for (auto &potentialLogFile : potentialLogFiles) {
    std::string logName = Poco::Path(potentialLogFile).getFileName();
    logName.erase(0, nBase);
    logName.erase(logName.size() - 4);
    if (logName.size() > 3) {
      std::string icp = logName.substr(0, 3);
      std::transform(icp.begin(), icp.end(), icp.begin(), toupper);
      if (icp == "ICP")
        continue;
    }

    std::ifstream fil(potentialLogFile.c_str());
    if (!fil) {
      g_log.warning("Cannot open log file " + potentialLogFile);
      continue;
    }

    start_time_str[10] =
        ' '; // make it compatible with boost::posix_time::ptime
    boost::posix_time::ptime start_time(
        boost::posix_time::time_from_string(start_time_str));
    start_time_str[10] = 'T'; // revert
    std::vector<float> time_vec;
    std::vector<std::string> str_vec;
    std::vector<float> flt_vec;
    std::string line;
    bool isNotNumeric = false;
    while (std::getline(fil, line)) {
      if (line.empty())
        continue;
      std::string date_time_str = line.substr(0, 19);
      date_time_str[10] = ' ';
      boost::posix_time::ptime time(
          boost::posix_time::time_from_string(date_time_str));
      boost::posix_time::time_duration dt = time - start_time;
      time_vec.push_back(float(dt.total_seconds()));
      std::istringstream istr(line.substr(20));
      // check if the data are numeric then save them in flt_vec
      if (!isNotNumeric) {
        float flt;
        istr >> flt;
        if (istr.bad() || istr.fail()) {
          isNotNumeric = true;
        } else {
          flt_vec.push_back(flt);
        }
      }
      str_vec.push_back(istr.str());
    }
    fil.close();
    NXmakegroup(handle, &logName[0], "IXseblock");
    NXopengroup(handle, &logName[0], "IXseblock");

    {
      saveString("vi_name", " ");
      saveString("set_control", " ");
      saveString("read_control", " ");
      float tmp = 0.0;
      saveFloatOpen("setpoint", &tmp, 1);
      putAttr("units", "mV");
      close();
    }

    NXmakegroup(handle, "value_log", "NXlog");
    NXopengroup(handle, "value_log", "NXlog");

    saveFloatOpen("time", &time_vec[0], static_cast<int>(time_vec.size()));
    putAttr("start", start_time_str);
    putAttr("units", "seconds");
    close();

    if (flt_vec.size() == str_vec.size()) {
      saveFloatOpen("value", &flt_vec[0], static_cast<int>(flt_vec.size()));
    } else {
      saveStringVectorOpen("value", str_vec);
    }
    putAttr("units", " ");
    close();

    saveString("name", " ");

    NXclosegroup(handle); // value_log

    NXclosegroup(handle); // logName

    prog.report();
  }