29 FileConversion::FileConversion(
31 vector<int> timesteps,
32 shared_ptr<SimShell::Ws::MergedPreferences> prefs,
33 IConverterFormat* output_format,
37 m_timesteps(timesteps),
39 m_output_format(output_format),
40 m_output_path(output_path),
41 m_output_prefix(output_prefix)
43 for (
auto& file : *m_project) {
44 auto sim_file = static_pointer_cast<Ws::StartupFileBase>(file.second);
45 for (
auto step : sim_file->GetTimeSteps()) {
46 m_step_to_file_map[step] = sim_file;
51 void FileConversion::Run(
function<
void(
int)> progress_callback)
54 m_project->SetWatchingDirectory(
false);
56 string path = m_output_path;
57 bool use_temp_dir =
false;
58 QDir project_dir(QString::fromStdString(path));
59 if (path == m_project->GetPath()) {
60 project_dir.mkdir(
"temp");
65 m_output_format->PreConvert(path +
'/' + m_output_prefix, m_preferences);
67 for (
auto timestep : m_timesteps) {
68 if (progress_callback)
70 auto sim_state = m_step_to_file_map[timestep]->GetSimState(timestep);
71 m_output_format->Convert(sim_state);
76 QDir d(QString::fromStdString(path));
77 for (
auto& entry : d.entryList()) {
78 QFile f(QString::fromStdString(m_project->GetPath()) +
'/' + entry);
80 d.rename(entry,
"../" + entry);
82 project_dir.rmdir(
"temp");
85 m_output_format->PostConvert();
86 if (progress_callback)
91 m_project->SetWatchingDirectory(
true);
Interface for Conversion.
Namespace for SimPT shell package.
Namespace for generic workspace classes.