1 #include <boost/filesystem/fstream.hpp>
35 m_desc.add_options()(
"images,i", po::value<int>(&
m_images)->default_value(0),
36 "Number of images between initial and final state when "
37 "viewing diff_trans_configs.")(
39 "Attempt to display corresponding relaxed structures to the given "
50 std::vector<std::string> confignames;
56 po::positional_options_description p;
57 p.add(
"confignames", -1);
60 po::store(po::command_line_parser(args.
argc() - 1, args.
argv() + 1)
61 .options(view_opt.
desc())
70 if (vm.count(
"help")) {
72 log() << view_opt.
desc() << std::endl;
77 if (vm.count(
"desc")) {
79 log() << view_opt.
desc() << std::endl;
80 log() <<
"This allows opening visualization programs directly from \n"
81 "CASM. It iterates over all selected configurations and \n"
82 "one by one writes a POSCAR and executes \n"
83 " '$VIEW_COMMAND /path/to/POSCAR' \n"
84 "where $VIEW_COMMAND is set via 'casm settings "
85 "--set-view-command'.\n"
86 "A script 'casm.view' is included with can be used to run \n"
87 "a command and then pause 1s, which is useful for opening \n"
88 "POSCARs with VESTA. An example on Mac might look like: \n"
89 " casm settings --set-view-command 'casm.view \"open -a "
90 "/Applications/VESTA/VESTA.app\"' \n\n";
100 }
catch (po::error &e) {
101 err_log() <<
"ERROR: " << e.what() << std::endl << std::endl;
104 }
catch (std::exception &e) {
105 err_log() <<
"Unhandled Exception reached the top of main: " << e.what()
106 <<
", application will now exit" << std::endl;
110 const fs::path &root = args.
root;
119 err_log() <<
"Error in 'casm view': No command set. Use 'casm settings "
120 "--set-view-command' to set the command to open visualization "
121 "software. It should take one argument, the path to a POSCAR "
122 "to be visualized. For example, to use VESTA on Mac: casm "
123 "settings --set-view-command 'casm.view \"open -a "
124 "/Applications/VESTA/VESTA.app\"'.\n";
130 std::unique_ptr<PrimClex> uniq_primclex;
134 if (!vm.count(
"config")) {
136 }
else if (selection ==
"MASTER") {
143 for (
int i = 0; i < confignames.size(); i++) {
144 config_select.
data()[confignames[i]] =
true;
147 fs::path tmp_dir = root /
".casm" /
"tmp";
148 fs::create_directory(tmp_dir);
154 fs::path POSCARpath = tmp_dir /
"POSCAR";
158 log() <<
"Obtaining relaxed structure from:\n";
164 file.open(POSCARpath);
177 fs::path POSCARpath = tmp_dir /
"POSCAR";
178 file.open(POSCARpath);
183 if (vm.count(
"relaxed")) {
184 log() <<
"No relaxed structure found."
#define ERR_MISSING_DEPENDS
void add_confignames_suboption()
Add a –confignames suboption.
const po::options_description & desc()
Get the program options, filled with the initialized values.
void add_help_suboption()
Add a plain –help and –desc suboptions.
po::options_description m_desc
void add_configtype_suboption(std::string _default, std::set< std::string > _configtype_opts)
Add –type suboption (default, set of short_name of allowed ConfigTypes)
void add_configlist_nodefault_suboption()
Add –config suboption (no default)
const std::vector< std::string > & config_strs() const
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
void initialize() override
Fill in the options descriptions accordingly.
boost::iterator_range< iterator > selected()
void error(const std::string &what)
Remember how to use popen.
void popen(std::string _command)
Execute popen for a given command.
void print(std::ostream &sout) const
Print the last command executed and the resulting stdout.
PrimClex is the top-level data structure for a CASM project.
std::string view_command() const
Get current command used by 'casm view'.
Print POSCAR with formating options.
void sort()
Default sort is by atom name.
void print(std::ostream &sout) const
Print POSCAR to stream.
Representation of a crystal of molecular and/or atomic occupants, and any additional properties....
PrimClex & make_primclex_if_not(const CommandArgs &args, std::unique_ptr< PrimClex > &uniq_primclex)
If !_primclex, construct new PrimClex stored in uniq_primclex, then return reference to existing or c...
ProjectSettings open_project_settings(fs::path path_in_project)
ConfigIO::GenericConfigFormatter< jsonParser > config()
const std::set< std::string > & config_types_short()
std::set of all QueryTraits<ConfigType>::short_name
int view_command(const CommandArgs &args)
xtal::SimpleStructure make_simple_structure(Supercell const &_scel, ConfigDoF const &_dof, std::vector< DoFKey > const &_which_dofs={})
Construct from ConfigDoF _dof belonging to provided Supercell _scel.
std::string calc_properties_path(const ConfigType &config, std::string calctype="")
bool is_calculated(const ConfigType &config, std::string calctype="")
Return true if all required properties have been been calculated for the configuration.
std::string pos_path(const ConfigType &config, std::string calctype="")
void from_json(ClexDescription &desc, const jsonParser &json)
Data structure holding basic CASM command info.