[97ebf8] | 1 | /*
|
---|
| 2 | * MapOfActions.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: 10.05.2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[112b09] | 8 | #include "Helpers/MemDebug.hpp"
|
---|
| 9 |
|
---|
[97ebf8] | 10 | using namespace std;
|
---|
| 11 |
|
---|
| 12 | #include "Actions/MapOfActions.hpp"
|
---|
[d02e07] | 13 | #include "Descriptors/AtomIdDescriptor.hpp"
|
---|
| 14 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
[97ebf8] | 15 | #include "Helpers/Assert.hpp"
|
---|
[4e145c] | 16 | #include "Patterns/Singleton_impl.hpp"
|
---|
[97ebf8] | 17 |
|
---|
[0286bc] | 18 | #include <boost/lexical_cast.hpp>
|
---|
| 19 | #include <boost/optional.hpp>
|
---|
| 20 | #include <boost/program_options.hpp>
|
---|
| 21 |
|
---|
[986ed3] | 22 | #include <iostream>
|
---|
| 23 |
|
---|
[ab9a27] | 24 | #include "atom.hpp"
|
---|
[d02e07] | 25 | #include "Box.hpp"
|
---|
[97ebf8] | 26 | #include "CommandLineParser.hpp"
|
---|
[ab9a27] | 27 | #include "element.hpp"
|
---|
[952f38] | 28 | #include "Helpers/Log.hpp"
|
---|
[57f243] | 29 | #include "LinearAlgebra/Matrix.hpp"
|
---|
[ab9a27] | 30 | #include "molecule.hpp"
|
---|
[d02e07] | 31 | #include "periodentafel.hpp"
|
---|
[57f243] | 32 | #include "LinearAlgebra/Vector.hpp"
|
---|
[952f38] | 33 | #include "Helpers/Verbose.hpp"
|
---|
[97ebf8] | 34 |
|
---|
[326bbe] | 35 | #include "Actions/ActionRegistry.hpp"
|
---|
| 36 | #include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
|
---|
| 37 | #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
|
---|
[d02e07] | 38 | #include "Actions/AnalysisAction/PointCorrelationAction.hpp"
|
---|
[326bbe] | 39 | #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
|
---|
[d02e07] | 40 | #include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
|
---|
[326bbe] | 41 | #include "Actions/AtomAction/AddAction.hpp"
|
---|
| 42 | #include "Actions/AtomAction/ChangeElementAction.hpp"
|
---|
| 43 | #include "Actions/AtomAction/RemoveAction.hpp"
|
---|
[22c44bf] | 44 | #include "Actions/AtomAction/RotateAroundOriginByAngleAction.hpp"
|
---|
[34c338] | 45 | #include "Actions/AtomAction/TranslateAction.hpp"
|
---|
[326bbe] | 46 | #include "Actions/CmdAction/BondLengthTableAction.hpp"
|
---|
| 47 | #include "Actions/CmdAction/ElementDbAction.hpp"
|
---|
| 48 | #include "Actions/CmdAction/FastParsingAction.hpp"
|
---|
| 49 | #include "Actions/CmdAction/HelpAction.hpp"
|
---|
| 50 | #include "Actions/CmdAction/VerboseAction.hpp"
|
---|
| 51 | #include "Actions/CmdAction/VersionAction.hpp"
|
---|
| 52 | #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
|
---|
| 53 | #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
|
---|
| 54 | #include "Actions/FragmentationAction/FragmentationAction.hpp"
|
---|
| 55 | #include "Actions/MoleculeAction/BondFileAction.hpp"
|
---|
| 56 | #include "Actions/MoleculeAction/ChangeNameAction.hpp"
|
---|
| 57 | #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
|
---|
| 58 | #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
|
---|
[eaf4ae] | 59 | #include "Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp"
|
---|
[b2531f] | 60 | #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
|
---|
[326bbe] | 61 | #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
|
---|
| 62 | #include "Actions/MoleculeAction/SaveBondsAction.hpp"
|
---|
| 63 | #include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
|
---|
[b2531f] | 64 | #include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
|
---|
[326bbe] | 65 | #include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
|
---|
| 66 | #include "Actions/ParserAction/LoadXyzAction.hpp"
|
---|
| 67 | #include "Actions/ParserAction/SaveXyzAction.hpp"
|
---|
[e472eab] | 68 | #include "Actions/SelectionAction/AllAtomsAction.hpp"
|
---|
[770287] | 69 | #include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp"
|
---|
[e472eab] | 70 | #include "Actions/SelectionAction/AllMoleculesAction.hpp"
|
---|
[533838] | 71 | #include "Actions/SelectionAction/AtomByIdAction.hpp"
|
---|
[e212ff] | 72 | #include "Actions/SelectionAction/ClearAllAtomsAction.hpp"
|
---|
[2218d94] | 73 | #include "Actions/SelectionAction/ClearAllMoleculesAction.hpp"
|
---|
[533838] | 74 | #include "Actions/SelectionAction/MoleculeByIdAction.hpp"
|
---|
[481e92] | 75 | #include "Actions/SelectionAction/MoleculeOfAtomAction.hpp"
|
---|
[e472eab] | 76 | #include "Actions/SelectionAction/NotAllAtomsAction.hpp"
|
---|
[381c5f] | 77 | #include "Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp"
|
---|
[e472eab] | 78 | #include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
|
---|
[533838] | 79 | #include "Actions/SelectionAction/NotAtomByIdAction.hpp"
|
---|
| 80 | #include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
|
---|
[75a80f] | 81 | #include "Actions/SelectionAction/NotMoleculeOfAtomAction.hpp"
|
---|
[326bbe] | 82 | #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
|
---|
| 83 | #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
|
---|
| 84 | #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
|
---|
| 85 | #include "Actions/WorldAction/BoundInBoxAction.hpp"
|
---|
| 86 | #include "Actions/WorldAction/CenterInBoxAction.hpp"
|
---|
| 87 | #include "Actions/WorldAction/CenterOnEdgeAction.hpp"
|
---|
| 88 | #include "Actions/WorldAction/ChangeBoxAction.hpp"
|
---|
| 89 | #include "Actions/WorldAction/InputAction.hpp"
|
---|
| 90 | #include "Actions/WorldAction/OutputAction.hpp"
|
---|
| 91 | #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
|
---|
| 92 | #include "Actions/WorldAction/RepeatBoxAction.hpp"
|
---|
| 93 | #include "Actions/WorldAction/ScaleBoxAction.hpp"
|
---|
| 94 | #include "Actions/WorldAction/SetDefaultNameAction.hpp"
|
---|
| 95 | #include "Actions/WorldAction/SetGaussianBasisAction.hpp"
|
---|
[b9c847] | 96 | #include "Actions/WorldAction/SetOutputFormatsAction.hpp"
|
---|
[0286bc] | 97 | #include "Actions/Values.hpp"
|
---|
| 98 |
|
---|
| 99 | void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int)
|
---|
| 100 | {
|
---|
| 101 | VectorValue VV;
|
---|
[b540f3] | 102 | std::vector<std::string> components;
|
---|
| 103 |
|
---|
| 104 | // split comma-separated values
|
---|
| 105 | if (values.size() != 1) {
|
---|
| 106 | cerr << "Not one vector but " << components.size() << " given " << endl;
|
---|
| 107 | throw boost::program_options::validation_error("Unequal to one vector given");
|
---|
| 108 | }
|
---|
| 109 | std::string argument(values.at(0));
|
---|
| 110 | std::string::iterator Aiter = argument.begin();
|
---|
| 111 | std::string::iterator Biter = argument.begin();
|
---|
| 112 | for (; Aiter != argument.end(); ++Aiter) {
|
---|
| 113 | if (*Aiter == ',') {
|
---|
| 114 | components.push_back(string(Biter,Aiter));
|
---|
| 115 | do {
|
---|
| 116 | Aiter++;
|
---|
| 117 | } while (*Aiter == ' ' || *Aiter == '\t');
|
---|
| 118 | Biter = Aiter;
|
---|
| 119 | }
|
---|
| 120 | }
|
---|
| 121 | components.push_back(string(Biter,argument.end()));
|
---|
| 122 |
|
---|
| 123 | if (components.size() != 3) {
|
---|
| 124 | cerr << "Specified vector does not have three components but " << components.size() << endl;
|
---|
[0286bc] | 125 | throw boost::program_options::validation_error("Specified vector does not have three components");
|
---|
| 126 | }
|
---|
[b540f3] | 127 | VV.x = boost::lexical_cast<double>(components.at(0));
|
---|
| 128 | VV.y = boost::lexical_cast<double>(components.at(1));
|
---|
| 129 | VV.z = boost::lexical_cast<double>(components.at(2));
|
---|
[0286bc] | 130 | v = boost::any(VectorValue(VV));
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | void validate(boost::any& v, const std::vector<std::string>& values, BoxValue *, int)
|
---|
| 134 | {
|
---|
| 135 | BoxValue BV;
|
---|
[b540f3] | 136 | std::vector<std::string> components;
|
---|
| 137 |
|
---|
| 138 | // split comma-separated values
|
---|
| 139 | if (values.size() != 1) {
|
---|
| 140 | cerr << "Not one vector but " << components.size() << " given " << endl;
|
---|
| 141 | throw boost::program_options::validation_error("Unequal to one vector given");
|
---|
| 142 | }
|
---|
| 143 | std::string argument(values.at(0));
|
---|
| 144 | std::string::iterator Aiter = argument.begin();
|
---|
| 145 | std::string::iterator Biter = argument.begin();
|
---|
| 146 | for (; Aiter != argument.end(); ++Aiter) {
|
---|
| 147 | if (*Aiter == ',') {
|
---|
| 148 | components.push_back(string(Biter,Aiter));
|
---|
| 149 | do {
|
---|
| 150 | Aiter++;
|
---|
| 151 | } while (*Aiter == ' ' || *Aiter == '\t');
|
---|
| 152 | Biter = Aiter;
|
---|
| 153 | }
|
---|
| 154 | }
|
---|
| 155 | components.push_back(string(Biter,argument.end()));
|
---|
| 156 |
|
---|
| 157 | if (components.size() != 6) {
|
---|
| 158 | cerr << "Specified vector does not have three components but " << components.size() << endl;
|
---|
[0286bc] | 159 | throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
|
---|
| 160 | }
|
---|
[b540f3] | 161 | BV.xx = boost::lexical_cast<double>(components.at(0));
|
---|
[8467df] | 162 | BV.yx = boost::lexical_cast<double>(components.at(1));
|
---|
| 163 | BV.yy = boost::lexical_cast<double>(components.at(2));
|
---|
| 164 | BV.zx = boost::lexical_cast<double>(components.at(3));
|
---|
| 165 | BV.zy = boost::lexical_cast<double>(components.at(4));
|
---|
[b540f3] | 166 | BV.zz = boost::lexical_cast<double>(components.at(5));
|
---|
[0286bc] | 167 | v = boost::any(BoxValue(BV));
|
---|
| 168 | }
|
---|
| 169 |
|
---|
[97ebf8] | 170 | /** Constructor of class MapOfActions.
|
---|
| 171 | *
|
---|
| 172 | */
|
---|
| 173 | MapOfActions::MapOfActions()
|
---|
| 174 | {
|
---|
| 175 | // initialise lookup map
|
---|
| 176 | CmdParserLookup[&generic] = &(CommandLineParser::getInstance().generic);
|
---|
| 177 | CmdParserLookup[&config] = &(CommandLineParser::getInstance().config);
|
---|
| 178 | CmdParserLookup[&hidden] = &(CommandLineParser::getInstance().hidden);
|
---|
| 179 | CmdParserLookup[&visible] = &(CommandLineParser::getInstance().visible);
|
---|
| 180 |
|
---|
| 181 | // keys for actions
|
---|
| 182 | DescriptionMap["add-atom"] = "add atom of specified element";
|
---|
| 183 | DescriptionMap["bond-table"] = "setting name of the bond length table file";
|
---|
| 184 | DescriptionMap["bond-file"] = "name of the bond file";
|
---|
| 185 | DescriptionMap["boundary"] = "change box to add an empty boundary around all atoms";
|
---|
| 186 | DescriptionMap["bound-in-box"] = "bound all atoms in the domain";
|
---|
| 187 | DescriptionMap["center-edge"] = "center edge of all atoms on (0,0,0)";
|
---|
| 188 | DescriptionMap["center-in-box"] = "center all atoms in the domain";
|
---|
| 189 | DescriptionMap["change-box"] = "change the symmetrc matrix of the simulation domain";
|
---|
| 190 | DescriptionMap["change-element"] = "change the element of an atom";
|
---|
| 191 | DescriptionMap["change-molname"] = "change the name of a molecule";
|
---|
[e212ff] | 192 | DescriptionMap["clear-atom-selection"] = "clear the atom selection";
|
---|
[2218d94] | 193 | DescriptionMap["clear-molecule-selection"] = "clear the molecule selection";
|
---|
[97ebf8] | 194 | DescriptionMap["convex-envelope"] = "create the convex envelope for a molecule";
|
---|
| 195 | DescriptionMap["default-molname"] = "set the default name of new molecules";
|
---|
| 196 | DescriptionMap["depth-first-search"] = "Depth-First Search analysis of the molecular system";
|
---|
| 197 | DescriptionMap["element-db"] = "setting the path where the element databases can be found";
|
---|
| 198 | DescriptionMap["fastparsing"] = "setting whether trajectories shall be parsed completely (n) or just first step (y)";
|
---|
| 199 | DescriptionMap["fill-molecule"] = "fill empty space of box with a filler molecule";
|
---|
| 200 | DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order";
|
---|
[a77976] | 201 | DescriptionMap["help"] = "Give this help screen";
|
---|
[4f7f34e] | 202 | DescriptionMap["input"] = "specify input files";
|
---|
[97ebf8] | 203 | DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
|
---|
| 204 | DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
|
---|
[b9c847] | 205 | DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
|
---|
| 206 | DescriptionMap["output"] = "write output files";
|
---|
| 207 | DescriptionMap["set-output"] = "specify output formats";
|
---|
[e65de8] | 208 | DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements";
|
---|
[97ebf8] | 209 | DescriptionMap["parse-xyz"] = "parse xyz file into World";
|
---|
[e65de8] | 210 | DescriptionMap["point-correlation"] = "pair correlation analysis between element and point";
|
---|
[97ebf8] | 211 | DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
|
---|
[446bc1] | 212 | DescriptionMap["redo"] = "redo last action";
|
---|
[97ebf8] | 213 | DescriptionMap["remove-atom"] = "remove a specified atom";
|
---|
| 214 | DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom";
|
---|
| 215 | DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
|
---|
[22c44bf] | 216 | DescriptionMap["rotate-origin"] = "rotate selected atoms by a specific angle around origin";
|
---|
[eaf4ae] | 217 | DescriptionMap["rotate-self"] = "rotates molecules by a specific angle around own center of gravity";
|
---|
[97ebf8] | 218 | DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis";
|
---|
| 219 | DescriptionMap["save-adjacency"] = "name of the adjacency file to write to";
|
---|
| 220 | DescriptionMap["save-bonds"] = "name of the bonds file to write to";
|
---|
| 221 | DescriptionMap["save-temperature"] = "name of the temperature file to write to";
|
---|
[326bbe] | 222 | DescriptionMap["SaveXyz"] = "save world as xyz file";
|
---|
[2a92ff] | 223 | DescriptionMap["scale-box"] = "scale box and atomic positions inside";
|
---|
[4e4c4d] | 224 | DescriptionMap["select-all-atoms"] = "select all atoms";
|
---|
| 225 | DescriptionMap["select-all-molecules"] = "select all molecules";
|
---|
| 226 | DescriptionMap["select-atom-by-id"] = "select an atom by index";
|
---|
| 227 | DescriptionMap["select-molecule-by-id"] = "select a molecule by index";
|
---|
[481e92] | 228 | DescriptionMap["select-molecule-of-atom"] = "select a molecule to which a given atom belongs";
|
---|
[770287] | 229 | DescriptionMap["select-molecules-atoms"] = "select all atoms of a molecule";
|
---|
[b9c847] | 230 | DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
|
---|
| 231 | DescriptionMap["set-output"] = "specify output formats";
|
---|
[6866aa] | 232 | DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
|
---|
[e65de8] | 233 | DescriptionMap["surface-correlation"] = "pair correlation analysis between element and surface";
|
---|
[97ebf8] | 234 | DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
|
---|
[34c338] | 235 | DescriptionMap["translate-atoms"] = "translate all selected atoms by given vector";
|
---|
[446bc1] | 236 | DescriptionMap["undo"] = "undo last action";
|
---|
[4e4c4d] | 237 | DescriptionMap["unselect-all-atoms"] = "unselect all atoms";
|
---|
| 238 | DescriptionMap["unselect-all-molecules"] = "unselect all molecules";
|
---|
| 239 | DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index";
|
---|
| 240 | DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index";
|
---|
[75a80f] | 241 | DescriptionMap["unselect-molecule-of-atom"] = "unselect a molecule to which a given atom belongs";
|
---|
[381c5f] | 242 | DescriptionMap["unselect-molecules-atoms"] = "unselect all atoms of a molecule";
|
---|
[97ebf8] | 243 | DescriptionMap["verbose"] = "set verbosity level";
|
---|
| 244 | DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file";
|
---|
| 245 | DescriptionMap["version"] = "show version";
|
---|
| 246 | // keys for values
|
---|
| 247 | DescriptionMap["bin-output-file"] = "name of the bin output file";
|
---|
| 248 | DescriptionMap["bin-end"] = "start of the last bin";
|
---|
| 249 | DescriptionMap["bin-start"] = "start of the first bin";
|
---|
| 250 | DescriptionMap["bin-width"] = "width of the bins";
|
---|
[f6bd32] | 251 | DescriptionMap["convex-file"] = "filename of the non-convex envelope";
|
---|
[97ebf8] | 252 | DescriptionMap["distance"] = "distance in space";
|
---|
| 253 | DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction";
|
---|
[0286bc] | 254 | DescriptionMap["DoRotate"] = "whether to rotate or just report angles";
|
---|
[58bbd3] | 255 | DescriptionMap["element"] = "single element";
|
---|
| 256 | DescriptionMap["elements"] = "set of elements";
|
---|
[a02462] | 257 | DescriptionMap["end-step"] = "last or end step";
|
---|
| 258 | DescriptionMap["id-mapping"] = "whether the identity shall be used in mapping atoms onto atoms or some closest distance measure shall be used";
|
---|
[97ebf8] | 259 | DescriptionMap["input"] = "name of input file";
|
---|
| 260 | DescriptionMap["length"] = "length in space";
|
---|
| 261 | DescriptionMap["lengths"] = "list of three of lengths in space, one for each axis direction";
|
---|
| 262 | DescriptionMap["MaxDistance"] = "maximum distance in space";
|
---|
| 263 | DescriptionMap["molecule-by-id"] = "index of a molecule";
|
---|
[f6bd32] | 264 | DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope";
|
---|
[e4b5de] | 265 | DescriptionMap["order"] = "order of a discretization, dissection, ...";
|
---|
[97ebf8] | 266 | DescriptionMap["output-file"] = "name of the output file";
|
---|
| 267 | DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
|
---|
| 268 | DescriptionMap["position"] = "position in R^3 space";
|
---|
[a02462] | 269 | DescriptionMap["start-step"] = "first or start step";
|
---|
[97ebf8] | 270 |
|
---|
| 271 | // short forms for the actions
|
---|
| 272 | ShortFormMap["add-atom"] = "a";
|
---|
| 273 | ShortFormMap["bond-table"] = "g";
|
---|
| 274 | ShortFormMap["bond-file"] = "A";
|
---|
| 275 | ShortFormMap["boundary"] = "c";
|
---|
[6ca1f7] | 276 | ShortFormMap["change-box"] = "B";
|
---|
[97ebf8] | 277 | ShortFormMap["center-edge"] = "O";
|
---|
| 278 | ShortFormMap["center-in-box"] = "b";
|
---|
| 279 | ShortFormMap["change-element"] = "E";
|
---|
[b9c847] | 280 | // ShortFormMap["convex-envelope"] = "x";
|
---|
[97ebf8] | 281 | ShortFormMap["default-molname"] = "X";
|
---|
| 282 | ShortFormMap["depth-first-search"] = "D";
|
---|
| 283 | ShortFormMap["element-db"] = "e";
|
---|
| 284 | ShortFormMap["fastparsing"] = "n";
|
---|
| 285 | ShortFormMap["fill-molecule"] = "F";
|
---|
| 286 | ShortFormMap["fragment-mol"] = "f";
|
---|
| 287 | ShortFormMap["help"] = "h";
|
---|
| 288 | ShortFormMap["input"] = "i";
|
---|
| 289 | ShortFormMap["linear-interpolate"] = "L";
|
---|
| 290 | ShortFormMap["nonconvex-envelope"] = "N";
|
---|
[cd8e55] | 291 | // ShortFormMap["output"] = "o";
|
---|
[e65de8] | 292 | // ShortFormMap["pair-correlation"] = "C";
|
---|
[97ebf8] | 293 | ShortFormMap["parse-xyz"] = "p";
|
---|
| 294 | ShortFormMap["remove-atom"] = "r";
|
---|
| 295 | ShortFormMap["remove-sphere"] = "R";
|
---|
| 296 | ShortFormMap["repeat-box"] = "d";
|
---|
| 297 | ShortFormMap["rotate-to-pas"] = "m";
|
---|
| 298 | ShortFormMap["save-adjacency"] = "J";
|
---|
| 299 | ShortFormMap["save-bonds"] = "j";
|
---|
| 300 | ShortFormMap["save-temperature"] = "S";
|
---|
| 301 | ShortFormMap["scale-box"] = "s";
|
---|
| 302 | ShortFormMap["set-basis"] = "M";
|
---|
[b9c847] | 303 | ShortFormMap["set-output"] = "o";
|
---|
[6866aa] | 304 | ShortFormMap["subgraph-dissect"] = "I";
|
---|
[48ab70a] | 305 | ShortFormMap["suspend-in-water"] = "u";
|
---|
[34c338] | 306 | ShortFormMap["translate-atoms"] = "t";
|
---|
[6670a97] | 307 | ShortFormMap["verbose"] = "v";
|
---|
[97ebf8] | 308 | ShortFormMap["verlet-integrate"] = "P";
|
---|
[6670a97] | 309 | ShortFormMap["version"] = "V";
|
---|
[97ebf8] | 310 |
|
---|
| 311 | // value types for the actions
|
---|
[ab9a27] | 312 | TypeMap["add-atom"] = &typeid(element);
|
---|
| 313 | TypeMap["bond-file"] = &typeid(std::string);
|
---|
| 314 | TypeMap["bond-table"] = &typeid(std::string);
|
---|
| 315 | TypeMap["boundary"] = &typeid(VectorValue);
|
---|
| 316 | TypeMap["center-in-box"] = &typeid(BoxValue);
|
---|
| 317 | TypeMap["change-box"] = &typeid(BoxValue);
|
---|
| 318 | TypeMap["change-element"] = &typeid(element);
|
---|
| 319 | TypeMap["change-molname"] = &typeid(std::string);
|
---|
[e212ff] | 320 | TypeMap["clear-atom-selection"] = &typeid(void);
|
---|
[2218d94] | 321 | TypeMap["clear-molecule-selection"] = &typeid(void);
|
---|
[1d9b7d2] | 322 | TypeMap["convex-envelope"] = &typeid(void);
|
---|
[ab9a27] | 323 | TypeMap["default-molname"] = &typeid(std::string);
|
---|
| 324 | TypeMap["depth-first-search"] = &typeid(double);
|
---|
| 325 | TypeMap["element-db"] = &typeid(std::string);
|
---|
| 326 | TypeMap["fastparsing"] = &typeid(bool);
|
---|
| 327 | TypeMap["fill-molecule"] = &typeid(std::string);
|
---|
| 328 | TypeMap["fragment-mol"] = &typeid(std::string);
|
---|
| 329 | TypeMap["input"] = &typeid(std::string);
|
---|
| 330 | TypeMap["linear-interpolate"] = &typeid(std::string);
|
---|
| 331 | TypeMap["molecular-volume"] = &typeid(molecule);
|
---|
[1d9b7d2] | 332 | TypeMap["nonconvex-envelope"] = &typeid(double);
|
---|
[ab9a27] | 333 | TypeMap["output"] = &typeid(void);
|
---|
| 334 | TypeMap["parse-xyz"] = &typeid(std::string);
|
---|
[e65de8] | 335 | TypeMap["pair-correlation"] = &typeid(void);
|
---|
| 336 | TypeMap["point-correlation"] = &typeid(void);
|
---|
[b76394] | 337 | TypeMap["principal-axis-system"] = &typeid(void);
|
---|
[446bc1] | 338 | TypeMap["redo"] = &typeid(void);
|
---|
[120088] | 339 | TypeMap["remove-atom"] = &typeid(void);
|
---|
[ab9a27] | 340 | TypeMap["remove-sphere"] = &typeid(double);
|
---|
| 341 | TypeMap["repeat-box"] = &typeid(VectorValue);
|
---|
[eaf4ae] | 342 | TypeMap["rotate-origin"] = &typeid(double);
|
---|
| 343 | TypeMap["rotate-self"] = &typeid(double);
|
---|
| 344 | TypeMap["rotate-to-pas"] = &typeid(VectorValue);
|
---|
[ab9a27] | 345 | TypeMap["save-adjacency"] = &typeid(std::string);
|
---|
| 346 | TypeMap["save-bonds"] = &typeid(std::string);
|
---|
| 347 | TypeMap["save-temperature"] = &typeid(std::string);
|
---|
| 348 | TypeMap["scale-box"] = &typeid(VectorValue);
|
---|
[770287] | 349 | TypeMap["select-all-atoms"] = &typeid(void);
|
---|
| 350 | TypeMap["select-all-molecules"] = &typeid(void);
|
---|
| 351 | TypeMap["select-atom-by-id"] = &typeid(atom);
|
---|
| 352 | TypeMap["select-molecule-by-id"] = &typeid(molecule);
|
---|
[481e92] | 353 | TypeMap["select-molecule-of-atom"] = &typeid(atom);
|
---|
[770287] | 354 | TypeMap["select-molecules-atoms"] = &typeid(molecule);
|
---|
[ab9a27] | 355 | TypeMap["set-basis"] = &typeid(std::string);
|
---|
| 356 | TypeMap["set-output"] = &typeid(std::vector<std::string>);
|
---|
| 357 | TypeMap["subgraph-dissect"] = &typeid(void);
|
---|
[e65de8] | 358 | TypeMap["surface-correlation"] = &typeid(void);
|
---|
[ab9a27] | 359 | TypeMap["suspend-in-water"] = &typeid(double);
|
---|
[34c338] | 360 | TypeMap["translate-atoms"] = &typeid(VectorValue);
|
---|
[446bc1] | 361 | TypeMap["undo"] = &typeid(void);
|
---|
[770287] | 362 | TypeMap["unselect-all-atoms"] = &typeid(void);
|
---|
| 363 | TypeMap["unselect-all-molecules"] = &typeid(void);
|
---|
| 364 | TypeMap["unselect-atom-by-id"] = &typeid(atom);
|
---|
| 365 | TypeMap["unselect-molecule-by-id"] = &typeid(molecule);
|
---|
[75a80f] | 366 | TypeMap["unselect-molecule-of-atom"] = &typeid(atom);
|
---|
[381c5f] | 367 | TypeMap["unselect-molecules-atoms"] = &typeid(molecule);
|
---|
[ab9a27] | 368 | TypeMap["verlet-integrate"] = &typeid(std::string);
|
---|
| 369 | TypeMap["verbose"] = &typeid(int);
|
---|
[e30ce8] | 370 |
|
---|
[97ebf8] | 371 | // value types for the values
|
---|
[ab9a27] | 372 | TypeMap["bin-output-file"] = &typeid(std::string);
|
---|
| 373 | TypeMap["bin-end"] = &typeid(double);
|
---|
| 374 | TypeMap["bin-start"] = &typeid(double);
|
---|
| 375 | TypeMap["bin-width"] = &typeid(double);
|
---|
| 376 | TypeMap["convex-file"] = &typeid(std::string);
|
---|
| 377 | TypeMap["distance"] = &typeid(double);
|
---|
| 378 | TypeMap["distances"] = &typeid(VectorValue);
|
---|
| 379 | TypeMap["DoRotate"] = &typeid(bool);
|
---|
| 380 | TypeMap["element"] = &typeid(element);
|
---|
| 381 | TypeMap["elements"] = &typeid(std::vector<element *>);
|
---|
| 382 | TypeMap["end-step"] = &typeid(int);
|
---|
| 383 | TypeMap["id-mapping"] = &typeid(bool);
|
---|
| 384 | TypeMap["length"] = &typeid(double);
|
---|
| 385 | TypeMap["lengths"] = &typeid(VectorValue);
|
---|
| 386 | TypeMap["MaxDistance"] = &typeid(double);
|
---|
[e65de8] | 387 | TypeMap["molecule-by-id"] = &typeid(molecule);
|
---|
[ab9a27] | 388 | TypeMap["nonconvex-file"] = &typeid(std::string);
|
---|
| 389 | TypeMap["order"] = &typeid(int);
|
---|
| 390 | TypeMap["output-file"] = &typeid(std::string);
|
---|
| 391 | TypeMap["periodic"] = &typeid(bool);
|
---|
| 392 | TypeMap["position"] = &typeid(VectorValue);
|
---|
| 393 | TypeMap["start-step"] = &typeid(int);
|
---|
| 394 |
|
---|
[0b0a20] | 395 | TypeEnumMap[&typeid(void)] = None;
|
---|
| 396 | TypeEnumMap[&typeid(bool)] = Boolean;
|
---|
[ab9a27] | 397 | TypeEnumMap[&typeid(int)] = Integer;
|
---|
[0b0a20] | 398 | TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers;
|
---|
[ab9a27] | 399 | TypeEnumMap[&typeid(double)] = Double;
|
---|
[0b0a20] | 400 | TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles;
|
---|
[ab9a27] | 401 | TypeEnumMap[&typeid(std::string)] = String;
|
---|
[0b0a20] | 402 | TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings;
|
---|
| 403 | TypeEnumMap[&typeid(VectorValue)] = Vector;
|
---|
[39b639] | 404 | TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectors;
|
---|
[0b0a20] | 405 | TypeEnumMap[&typeid(BoxValue)] = Box;
|
---|
| 406 | TypeEnumMap[&typeid(molecule)] = Molecule;
|
---|
| 407 | TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules;
|
---|
[ab9a27] | 408 | TypeEnumMap[&typeid(atom)] = Atom;
|
---|
[0b0a20] | 409 | TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
|
---|
[ab9a27] | 410 | TypeEnumMap[&typeid(element)] = Element;
|
---|
| 411 | TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements;
|
---|
[97ebf8] | 412 |
|
---|
[e30ce8] | 413 | // default values for any action that needs one (always string!)
|
---|
[ab9a27] | 414 | CurrentValue["bin-width"] = "0.5";
|
---|
| 415 | CurrentValue["fastparsing"] = "0";
|
---|
| 416 | CurrentValue["periodic"] = "0";
|
---|
[e30ce8] | 417 |
|
---|
[326bbe] | 418 | // put action into each menu category
|
---|
[b2531f] | 419 | MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis");
|
---|
[5b5c4d] | 420 | MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Atoms");
|
---|
| 421 | MenuDescription["command"] = pair<std::string,std::string>("Configuration", "configuration options");
|
---|
[b2531f] | 422 | MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation");
|
---|
[5b5c4d] | 423 | MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Molecules");
|
---|
| 424 | MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Input/Output");
|
---|
| 425 | MenuDescription["selection"] = pair<std::string,std::string>("Select atoms/molecules", "Selection");
|
---|
| 426 | MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselation");
|
---|
| 427 | MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Globals");
|
---|
[b2531f] | 428 |
|
---|
[326bbe] | 429 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") );
|
---|
| 430 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") );
|
---|
[e65de8] | 431 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "point-correlation") );
|
---|
| 432 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "surface-correlation") );
|
---|
[326bbe] | 433 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") );
|
---|
[e30ce8] | 434 |
|
---|
[326bbe] | 435 | MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "add-atom") );
|
---|
| 436 | MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "change-element") );
|
---|
| 437 | MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "remove-atom") );
|
---|
[34c338] | 438 | MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "translate-atoms") );
|
---|
[326bbe] | 439 |
|
---|
| 440 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "bond-table") );
|
---|
| 441 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "element-db") );
|
---|
| 442 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "fastparsing") );
|
---|
| 443 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "verbose") );
|
---|
| 444 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "version") );
|
---|
| 445 |
|
---|
| 446 | MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "depth-first-search") );
|
---|
| 447 | MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "fragment-mol") );
|
---|
| 448 | MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "subgraph-dissect") );
|
---|
| 449 |
|
---|
| 450 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "bond-file") );
|
---|
| 451 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "change-molname") );
|
---|
| 452 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") );
|
---|
| 453 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") );
|
---|
[eaf4ae] | 454 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-origin") );
|
---|
| 455 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-self") );
|
---|
[326bbe] | 456 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") );
|
---|
| 457 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") );
|
---|
| 458 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-bonds") );
|
---|
| 459 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-temperature") );
|
---|
| 460 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "suspend-in-water") );
|
---|
| 461 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "verlet-integrate") );
|
---|
| 462 |
|
---|
| 463 | MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") );
|
---|
| 464 | MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") );
|
---|
| 465 |
|
---|
[e212ff] | 466 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "clear-atom-selection") );
|
---|
[2218d94] | 467 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "clear-molecule-selection") );
|
---|
[e212ff] | 468 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-atoms") );
|
---|
| 469 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-molecules") );
|
---|
[5b5c4d] | 470 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") );
|
---|
| 471 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") );
|
---|
[481e92] | 472 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-of-atom") );
|
---|
[770287] | 473 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecules-atoms") );
|
---|
[e212ff] | 474 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-atoms") );
|
---|
| 475 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-molecules") );
|
---|
[5b5c4d] | 476 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") );
|
---|
| 477 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") );
|
---|
[75a80f] | 478 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-of-atom") );
|
---|
[381c5f] | 479 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecules-atoms") );
|
---|
[5b5c4d] | 480 |
|
---|
[326bbe] | 481 | MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") );
|
---|
| 482 | MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "nonconvex-envelope") );
|
---|
| 483 |
|
---|
| 484 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "boundary") );
|
---|
| 485 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "bound-in-box") );
|
---|
| 486 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-in-box") );
|
---|
| 487 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-edge") );
|
---|
| 488 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "change-box") );
|
---|
| 489 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
|
---|
| 490 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
|
---|
| 491 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") );
|
---|
| 492 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
|
---|
| 493 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
|
---|
| 494 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") );
|
---|
| 495 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") );
|
---|
[b9c847] | 496 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-output") );
|
---|
[326bbe] | 497 |
|
---|
| 498 | // put actions into command line category
|
---|
[f0a3ec] | 499 | generic.insert("add-atom");
|
---|
[f4bd01] | 500 | generic.insert("bond-file");
|
---|
[39af9f] | 501 | generic.insert("bond-table");
|
---|
[116f37] | 502 | generic.insert("boundary");
|
---|
[97ebf8] | 503 | // generic.insert("bound-in-box");
|
---|
[584a2a] | 504 | generic.insert("center-edge");
|
---|
[158c594] | 505 | generic.insert("center-in-box");
|
---|
[6ca1f7] | 506 | generic.insert("change-box");
|
---|
[97ebf8] | 507 | // generic.insert("change-molname");
|
---|
[e212ff] | 508 | generic.insert("change-element");
|
---|
| 509 | generic.insert("clear-atom-selection");
|
---|
[2218d94] | 510 | generic.insert("clear-molecule-selection");
|
---|
[f6bd32] | 511 | generic.insert("convex-envelope");
|
---|
[387b36] | 512 | generic.insert("default-molname");
|
---|
[8540f0] | 513 | generic.insert("depth-first-search");
|
---|
[198494] | 514 | generic.insert("element-db");
|
---|
[f821d6] | 515 | generic.insert("fastparsing");
|
---|
[0286bc] | 516 | generic.insert("fill-molecule");
|
---|
[e4b5de] | 517 | generic.insert("fragment-mol");
|
---|
[97ebf8] | 518 | generic.insert("help");
|
---|
[4f7f34e] | 519 | generic.insert("input");
|
---|
| 520 | generic.insert("linear-interpolate");
|
---|
[97ebf8] | 521 | // generic.insert("molecular-volume");
|
---|
[980dd6] | 522 | generic.insert("nonconvex-envelope");
|
---|
[4f7f34e] | 523 | generic.insert("output");
|
---|
[58bbd3] | 524 | generic.insert("pair-correlation");
|
---|
[a1e929] | 525 | generic.insert("parse-xyz");
|
---|
[e65de8] | 526 | generic.insert("point-correlation");
|
---|
[97ebf8] | 527 | // generic.insert("principal-axis-system");
|
---|
[446bc1] | 528 | generic.insert("redo");
|
---|
[d55743e] | 529 | generic.insert("remove-atom");
|
---|
[e2b47c] | 530 | generic.insert("remove-sphere");
|
---|
[0286bc] | 531 | generic.insert("repeat-box");
|
---|
[eaf4ae] | 532 | generic.insert("rotate-origin");
|
---|
| 533 | generic.insert("rotate-self");
|
---|
[2b5574] | 534 | generic.insert("rotate-to-pas");
|
---|
[77de81] | 535 | generic.insert("save-adjacency");
|
---|
| 536 | generic.insert("save-bonds");
|
---|
[a307af] | 537 | generic.insert("save-temperature");
|
---|
[2a92ff] | 538 | generic.insert("scale-box");
|
---|
[e472eab] | 539 | generic.insert("select-all-atoms");
|
---|
| 540 | generic.insert("select-all-molecules");
|
---|
| 541 | generic.insert("select-atom-by-id");
|
---|
| 542 | generic.insert("select-molecule-by-id");
|
---|
[481e92] | 543 | generic.insert("select-molecule-of-atom");
|
---|
[770287] | 544 | generic.insert("select-molecules-atoms");
|
---|
[bdaacd] | 545 | generic.insert("set-basis");
|
---|
[b9c847] | 546 | generic.insert("set-output");
|
---|
[6866aa] | 547 | generic.insert("subgraph-dissect");
|
---|
[e65de8] | 548 | generic.insert("surface-correlation");
|
---|
[48ab70a] | 549 | generic.insert("suspend-in-water");
|
---|
[34c338] | 550 | generic.insert("translate-atoms");
|
---|
[446bc1] | 551 | generic.insert("undo");
|
---|
[e472eab] | 552 | generic.insert("unselect-all-atoms");
|
---|
| 553 | generic.insert("unselect-all-molecules");
|
---|
| 554 | generic.insert("unselect-atom-by-id");
|
---|
| 555 | generic.insert("unselect-molecule-by-id");
|
---|
[75a80f] | 556 | generic.insert("unselect-molecule-of-atom");
|
---|
[381c5f] | 557 | generic.insert("unselect-molecules-atoms");
|
---|
[97ebf8] | 558 | generic.insert("verbose");
|
---|
[aacce8] | 559 | generic.insert("verlet-integrate");
|
---|
[97ebf8] | 560 | generic.insert("version");
|
---|
| 561 |
|
---|
| 562 | // positional arguments
|
---|
[f6bd32] | 563 | generic.insert("input");
|
---|
[0286bc] | 564 |
|
---|
| 565 | // hidden arguments
|
---|
[533838] | 566 | hidden.insert("bin-end");
|
---|
| 567 | hidden.insert("bin-output-file");
|
---|
| 568 | hidden.insert("bin-start");
|
---|
| 569 | hidden.insert("bin-width");
|
---|
| 570 | hidden.insert("convex-file");
|
---|
| 571 | hidden.insert("distance");
|
---|
| 572 | hidden.insert("DoRotate");
|
---|
| 573 | hidden.insert("distances");
|
---|
| 574 | hidden.insert("element");
|
---|
| 575 | hidden.insert("elements");
|
---|
| 576 | hidden.insert("end-step");
|
---|
| 577 | hidden.insert("id-mapping");
|
---|
| 578 | hidden.insert("lengths");
|
---|
| 579 | hidden.insert("MaxDistance");
|
---|
[e65de8] | 580 | hidden.insert("molecule-by-id");
|
---|
[533838] | 581 | hidden.insert("nonconvex-file");
|
---|
| 582 | hidden.insert("order");
|
---|
| 583 | hidden.insert("output-file");
|
---|
| 584 | hidden.insert("periodic");
|
---|
| 585 | hidden.insert("position");
|
---|
| 586 | hidden.insert("start-step");
|
---|
[97ebf8] | 587 | }
|
---|
| 588 |
|
---|
| 589 | /** Destructor of class MapOfActions.
|
---|
| 590 | *
|
---|
| 591 | */
|
---|
| 592 | MapOfActions::~MapOfActions()
|
---|
| 593 | {
|
---|
| 594 | DescriptionMap.clear();
|
---|
| 595 | }
|
---|
| 596 |
|
---|
[d02e07] | 597 | void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
|
---|
| 598 | {
|
---|
| 599 | int atomID = -1;
|
---|
[4e145c] | 600 | if (typeid( atom ) == *TypeMap[name]) {
|
---|
| 601 | if (CurrentValue.find(name) == CurrentValue.end())
|
---|
| 602 | throw MissingValueException(__FILE__, __LINE__);
|
---|
[d02e07] | 603 | atomID = lexical_cast<int>(CurrentValue[name].c_str());
|
---|
[4e145c] | 604 | CurrentValue.erase(name);
|
---|
| 605 | } else
|
---|
[d02e07] | 606 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 607 | _T = World::getInstance().getAtom(AtomById(atomID));
|
---|
| 608 | }
|
---|
| 609 |
|
---|
| 610 | void MapOfActions::queryCurrentValue(const char * name, class element * &_T) {
|
---|
| 611 | int Z = -1;
|
---|
[4e145c] | 612 | if (typeid( element ) == *TypeMap[name]) {
|
---|
| 613 | if (CurrentValue.find(name) == CurrentValue.end())
|
---|
| 614 | throw MissingValueException(__FILE__, __LINE__);
|
---|
[d02e07] | 615 | Z = lexical_cast<int>(CurrentValue[name].c_str());
|
---|
[4e145c] | 616 | CurrentValue.erase(name);
|
---|
| 617 | } else
|
---|
[d02e07] | 618 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 619 | _T = World::getInstance().getPeriode()->FindElement(Z);
|
---|
| 620 | }
|
---|
| 621 |
|
---|
| 622 | void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) {
|
---|
| 623 | int molID = -1;
|
---|
[4e145c] | 624 | if (typeid( molecule ) == *TypeMap[name]) {
|
---|
| 625 | if (CurrentValue.find(name) == CurrentValue.end())
|
---|
| 626 | throw MissingValueException(__FILE__, __LINE__);
|
---|
[d02e07] | 627 | molID = lexical_cast<int>(CurrentValue[name].c_str());
|
---|
[4e145c] | 628 | CurrentValue.erase(name);
|
---|
| 629 | } else
|
---|
[d02e07] | 630 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 631 | _T = World::getInstance().getMolecule(MoleculeById(molID));
|
---|
| 632 | }
|
---|
| 633 |
|
---|
| 634 | void MapOfActions::queryCurrentValue(const char * name, class Box &_T) {
|
---|
| 635 | Matrix M;
|
---|
| 636 | double tmp;
|
---|
| 637 | if (typeid( BoxValue ) == *TypeMap[name]) {
|
---|
[4e145c] | 638 | if (CurrentValue.find(name) == CurrentValue.end())
|
---|
| 639 | throw MissingValueException(__FILE__, __LINE__);
|
---|
[d02e07] | 640 | std::istringstream stream(CurrentValue[name]);
|
---|
| 641 | stream >> tmp;
|
---|
| 642 | M.set(0,0,tmp);
|
---|
| 643 | stream >> tmp;
|
---|
| 644 | M.set(0,1,tmp);
|
---|
| 645 | M.set(1,0,tmp);
|
---|
| 646 | stream >> tmp;
|
---|
| 647 | M.set(0,2,tmp);
|
---|
| 648 | M.set(2,0,tmp);
|
---|
| 649 | stream >> tmp;
|
---|
| 650 | M.set(1,1,tmp);
|
---|
| 651 | stream >> tmp;
|
---|
| 652 | M.set(1,2,tmp);
|
---|
| 653 | M.set(2,1,tmp);
|
---|
| 654 | stream >> tmp;
|
---|
| 655 | M.set(2,2,tmp);
|
---|
[39b639] | 656 | _T = M;
|
---|
| 657 | CurrentValue.erase(name);
|
---|
[d02e07] | 658 | } else
|
---|
| 659 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 660 | }
|
---|
| 661 |
|
---|
| 662 | void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) {
|
---|
| 663 | if (typeid( VectorValue ) == *TypeMap[name]) {
|
---|
| 664 | std::istringstream stream(CurrentValue[name]);
|
---|
[4e145c] | 665 | CurrentValue.erase(name);
|
---|
[d02e07] | 666 | stream >> _T[0];
|
---|
| 667 | stream >> _T[1];
|
---|
| 668 | stream >> _T[2];
|
---|
| 669 | } else
|
---|
| 670 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 671 | }
|
---|
| 672 |
|
---|
[0b0a20] | 673 | void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T)
|
---|
| 674 | {
|
---|
| 675 | int atomID = -1;
|
---|
| 676 | atom *Walker = NULL;
|
---|
| 677 | if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
|
---|
| 678 | if (CurrentValue.find(name) == CurrentValue.end())
|
---|
| 679 | throw MissingValueException(__FILE__, __LINE__);
|
---|
| 680 | std::istringstream stream(CurrentValue[name]);
|
---|
| 681 | CurrentValue.erase(name);
|
---|
| 682 | while (!stream.fail()) {
|
---|
[e65de8] | 683 | stream >> atomID >> ws;
|
---|
[0b0a20] | 684 | Walker = World::getInstance().getAtom(AtomById(atomID));
|
---|
| 685 | if (Walker != NULL)
|
---|
| 686 | _T.push_back(Walker);
|
---|
[e65de8] | 687 | atomID = -1;
|
---|
| 688 | Walker = NULL;
|
---|
[0b0a20] | 689 | }
|
---|
| 690 | } else
|
---|
| 691 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 692 | }
|
---|
| 693 |
|
---|
[d02e07] | 694 | void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
|
---|
| 695 | {
|
---|
| 696 | int Z = -1;
|
---|
| 697 | element *elemental = NULL;
|
---|
| 698 | if (typeid( std::vector<element *> ) == *TypeMap[name]) {
|
---|
[4e145c] | 699 | if (CurrentValue.find(name) == CurrentValue.end())
|
---|
| 700 | throw MissingValueException(__FILE__, __LINE__);
|
---|
[d02e07] | 701 | std::istringstream stream(CurrentValue[name]);
|
---|
[4e145c] | 702 | CurrentValue.erase(name);
|
---|
[d02e07] | 703 | while (!stream.fail()) {
|
---|
[e65de8] | 704 | stream >> Z >> ws;
|
---|
[d02e07] | 705 | elemental = World::getInstance().getPeriode()->FindElement(Z);
|
---|
| 706 | if (elemental != NULL)
|
---|
| 707 | _T.push_back(elemental);
|
---|
[e65de8] | 708 | Z = -1;
|
---|
[d02e07] | 709 | }
|
---|
| 710 | } else
|
---|
| 711 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 712 | }
|
---|
| 713 |
|
---|
[0b0a20] | 714 | void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T)
|
---|
[3e54d0] | 715 | {
|
---|
[0b0a20] | 716 | int molID = -1;
|
---|
| 717 | molecule *mol = NULL;
|
---|
| 718 | if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
|
---|
[4e145c] | 719 | if (CurrentValue.find(name) == CurrentValue.end())
|
---|
| 720 | throw MissingValueException(__FILE__, __LINE__);
|
---|
[3e54d0] | 721 | std::istringstream stream(CurrentValue[name]);
|
---|
[4e145c] | 722 | CurrentValue.erase(name);
|
---|
[3e54d0] | 723 | while (!stream.fail()) {
|
---|
[e65de8] | 724 | stream >> molID >> ws;
|
---|
[0b0a20] | 725 | mol = World::getInstance().getMolecule(MoleculeById(molID));
|
---|
| 726 | if (mol != NULL)
|
---|
| 727 | _T.push_back(mol);
|
---|
[e65de8] | 728 | molID = -1;
|
---|
| 729 | mol = NULL;
|
---|
[3e54d0] | 730 | }
|
---|
| 731 | } else
|
---|
| 732 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 733 | }
|
---|
| 734 |
|
---|
[d02e07] | 735 |
|
---|
| 736 | void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
|
---|
| 737 | {
|
---|
| 738 | if (typeid( atom ) == *TypeMap[name]) {
|
---|
| 739 | std::ostringstream stream;
|
---|
| 740 | stream << _T->getId();
|
---|
| 741 | CurrentValue[name] = stream.str();
|
---|
| 742 | } else
|
---|
| 743 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 744 | }
|
---|
| 745 |
|
---|
| 746 | void MapOfActions::setCurrentValue(const char * name, class element * &_T)
|
---|
| 747 | {
|
---|
| 748 | if (typeid( element ) == *TypeMap[name]) {
|
---|
| 749 | std::ostringstream stream;
|
---|
| 750 | stream << _T->Z;
|
---|
| 751 | CurrentValue[name] = stream.str();
|
---|
| 752 | } else
|
---|
| 753 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 754 | }
|
---|
| 755 |
|
---|
| 756 | void MapOfActions::setCurrentValue(const char * name, class molecule * &_T)
|
---|
| 757 | {
|
---|
| 758 | if (typeid( molecule ) == *TypeMap[name]) {
|
---|
| 759 | std::ostringstream stream;
|
---|
| 760 | stream << _T->getId();
|
---|
| 761 | CurrentValue[name] = stream.str();
|
---|
| 762 | } else
|
---|
| 763 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 764 | }
|
---|
| 765 |
|
---|
| 766 | void MapOfActions::setCurrentValue(const char * name, class Box &_T)
|
---|
| 767 | {
|
---|
| 768 | const Matrix &M = _T.getM();
|
---|
[39b639] | 769 | if (typeid( BoxValue ) == *TypeMap[name]) {
|
---|
[d02e07] | 770 | std::ostringstream stream;
|
---|
| 771 | stream << M.at(0,0) << " ";
|
---|
| 772 | stream << M.at(0,1) << " ";
|
---|
| 773 | stream << M.at(0,2) << " ";
|
---|
| 774 | stream << M.at(1,1) << " ";
|
---|
| 775 | stream << M.at(1,2) << " ";
|
---|
| 776 | stream << M.at(2,2) << " ";
|
---|
| 777 | CurrentValue[name] = stream.str();
|
---|
| 778 | } else
|
---|
| 779 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 780 | }
|
---|
| 781 |
|
---|
| 782 | void MapOfActions::setCurrentValue(const char * name, class Vector &_T)
|
---|
| 783 | {
|
---|
[39b639] | 784 | if (typeid( VectorValue ) == *TypeMap[name]){
|
---|
[d02e07] | 785 | std::ostringstream stream;
|
---|
| 786 | stream << _T[0] << " ";
|
---|
| 787 | stream << _T[1] << " ";
|
---|
| 788 | stream << _T[2] << " ";
|
---|
| 789 | CurrentValue[name] = stream.str();
|
---|
| 790 | } else
|
---|
| 791 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 792 | }
|
---|
| 793 |
|
---|
[0b0a20] | 794 | void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T)
|
---|
| 795 | {
|
---|
| 796 | if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
|
---|
| 797 | std::ostringstream stream;
|
---|
| 798 | for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
| 799 | stream << (*iter)->getId() << " ";
|
---|
| 800 | }
|
---|
| 801 | CurrentValue[name] = stream.str();
|
---|
| 802 | } else
|
---|
| 803 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 804 | }
|
---|
| 805 |
|
---|
[d02e07] | 806 | void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
|
---|
| 807 | {
|
---|
| 808 | if (typeid( std::vector<element *> ) == *TypeMap[name]) {
|
---|
| 809 | std::ostringstream stream;
|
---|
| 810 | for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
[0b0a20] | 811 | stream << (*iter)->Z << " ";
|
---|
[d02e07] | 812 | }
|
---|
| 813 | CurrentValue[name] = stream.str();
|
---|
| 814 | } else
|
---|
| 815 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 816 | }
|
---|
| 817 |
|
---|
[0b0a20] | 818 | void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T)
|
---|
[3e54d0] | 819 | {
|
---|
[0b0a20] | 820 | if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
|
---|
[3e54d0] | 821 | std::ostringstream stream;
|
---|
[0b0a20] | 822 | for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
| 823 | stream << (*iter)->getId() << " ";
|
---|
[3e54d0] | 824 | }
|
---|
| 825 | CurrentValue[name] = stream.str();
|
---|
| 826 | } else
|
---|
| 827 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
| 828 | }
|
---|
| 829 |
|
---|
[d02e07] | 830 |
|
---|
[326bbe] | 831 |
|
---|
| 832 | void MapOfActions::populateActions()
|
---|
| 833 | {
|
---|
| 834 | new AnalysisMolecularVolumeAction();
|
---|
| 835 | new AnalysisPairCorrelationAction();
|
---|
[d02e07] | 836 | new AnalysisPointCorrelationAction();
|
---|
[326bbe] | 837 | new AnalysisPrincipalAxisSystemAction();
|
---|
[d02e07] | 838 | new AnalysisSurfaceCorrelationAction();
|
---|
[326bbe] | 839 |
|
---|
| 840 | new AtomAddAction();
|
---|
| 841 | new AtomChangeElementAction();
|
---|
| 842 | new AtomRemoveAction();
|
---|
[22c44bf] | 843 | new AtomRotateAroundOriginByAngleAction();
|
---|
[34c338] | 844 | new AtomTranslateAction();
|
---|
[326bbe] | 845 |
|
---|
| 846 | new CommandLineBondLengthTableAction();
|
---|
| 847 | new CommandLineElementDbAction();
|
---|
| 848 | new CommandLineFastParsingAction();
|
---|
| 849 | new CommandLineHelpAction();
|
---|
| 850 | new CommandLineVerboseAction();
|
---|
| 851 | new CommandLineVersionAction();
|
---|
| 852 |
|
---|
| 853 | new FragmentationDepthFirstSearchAction();
|
---|
| 854 | new FragmentationFragmentationAction();
|
---|
| 855 | new FragmentationSubgraphDissectionAction();
|
---|
| 856 |
|
---|
| 857 | new MoleculeBondFileAction();
|
---|
| 858 | new MoleculeChangeNameAction();
|
---|
| 859 | new MoleculeFillWithMoleculeAction();
|
---|
| 860 | new MoleculeLinearInterpolationofTrajectoriesAction();
|
---|
[eaf4ae] | 861 | new MoleculeRotateAroundSelfByAngleAction();
|
---|
[b2531f] | 862 | new MoleculeRotateToPrincipalAxisSystemAction();
|
---|
[326bbe] | 863 | new MoleculeSaveAdjacencyAction();
|
---|
| 864 | new MoleculeSaveBondsAction();
|
---|
| 865 | new MoleculeSaveTemperatureAction();
|
---|
[b2531f] | 866 | new MoleculeSuspendInWaterAction();
|
---|
[326bbe] | 867 | new MoleculeVerletIntegrationAction();
|
---|
| 868 |
|
---|
| 869 | new ParserLoadXyzAction();
|
---|
| 870 | new ParserSaveXyzAction();
|
---|
| 871 |
|
---|
[e212ff] | 872 | new SelectionClearAllAtomsAction();
|
---|
[2218d94] | 873 | new SelectionClearAllMoleculesAction();
|
---|
[e472eab] | 874 | new SelectionAllAtomsAction();
|
---|
[770287] | 875 | new SelectionAllAtomsOfMoleculeAction();
|
---|
[e472eab] | 876 | new SelectionAllMoleculesAction();
|
---|
[533838] | 877 | new SelectionAtomByIdAction();
|
---|
| 878 | new SelectionMoleculeByIdAction();
|
---|
[481e92] | 879 | new SelectionMoleculeOfAtomAction();
|
---|
[e472eab] | 880 | new SelectionNotAllAtomsAction();
|
---|
[381c5f] | 881 | new SelectionNotAllAtomsOfMoleculeAction();
|
---|
[e472eab] | 882 | new SelectionNotAllMoleculesAction();
|
---|
[533838] | 883 | new SelectionNotAtomByIdAction();
|
---|
| 884 | new SelectionNotMoleculeByIdAction();
|
---|
[75a80f] | 885 | new SelectionNotMoleculeOfAtomAction();
|
---|
[533838] | 886 |
|
---|
[326bbe] | 887 | new TesselationConvexEnvelopeAction();
|
---|
| 888 | new TesselationNonConvexEnvelopeAction();
|
---|
| 889 |
|
---|
| 890 | new WorldAddEmptyBoundaryAction();
|
---|
| 891 | new WorldBoundInBoxAction();
|
---|
| 892 | new WorldCenterInBoxAction();
|
---|
| 893 | new WorldCenterOnEdgeAction();
|
---|
| 894 | new WorldChangeBoxAction();
|
---|
| 895 | new WorldInputAction();
|
---|
| 896 | new WorldOutputAction();
|
---|
| 897 | new WorldRemoveSphereOfAtomsAction();
|
---|
| 898 | new WorldRepeatBoxAction();
|
---|
| 899 | new WorldScaleBoxAction();
|
---|
| 900 | new WorldSetDefaultNameAction();
|
---|
| 901 | new WorldSetGaussianBasisAction();
|
---|
[b9c847] | 902 | new WorldSetOutputFormatsAction();
|
---|
[326bbe] | 903 | }
|
---|
| 904 |
|
---|
[97ebf8] | 905 | /** Adds all options to the CommandLineParser.
|
---|
| 906 | *
|
---|
| 907 | */
|
---|
| 908 | void MapOfActions::AddOptionsToParser()
|
---|
| 909 | {
|
---|
| 910 | // add other options
|
---|
| 911 | for (map< set<string>*, po::options_description* >::iterator ListRunner = CmdParserLookup.begin(); ListRunner != CmdParserLookup.end(); ++ListRunner) {
|
---|
| 912 | for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
|
---|
| 913 | if (hasValue(*OptionRunner)) {
|
---|
[e65de8] | 914 | DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl);
|
---|
[ab9a27] | 915 | switch(TypeEnumMap[TypeMap[*OptionRunner]]) {
|
---|
[97ebf8] | 916 | default:
|
---|
| 917 | case None:
|
---|
| 918 | ListRunner->second->add_options()
|
---|
| 919 | (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
|
---|
| 920 | ;
|
---|
| 921 | break;
|
---|
| 922 | case Boolean:
|
---|
| 923 | ListRunner->second->add_options()
|
---|
[e30ce8] | 924 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[ab9a27] | 925 | CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
|
---|
[39b639] | 926 | po::value< bool >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
|
---|
[e30ce8] | 927 | po::value< bool >(),
|
---|
| 928 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 929 | ;
|
---|
| 930 | break;
|
---|
[0286bc] | 931 | case Box:
|
---|
| 932 | ListRunner->second->add_options()
|
---|
| 933 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[39b639] | 934 | po::value<BoxValue>(),
|
---|
[0286bc] | 935 | getDescription(*OptionRunner).c_str())
|
---|
| 936 | ;
|
---|
| 937 | break;
|
---|
[97ebf8] | 938 | case Integer:
|
---|
| 939 | ListRunner->second->add_options()
|
---|
[e30ce8] | 940 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[ab9a27] | 941 | CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
|
---|
[39b639] | 942 | po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
|
---|
[e30ce8] | 943 | po::value< int >(),
|
---|
| 944 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 945 | ;
|
---|
| 946 | break;
|
---|
[0b0a20] | 947 | case ListOfIntegers:
|
---|
[97ebf8] | 948 | ListRunner->second->add_options()
|
---|
[e30ce8] | 949 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
| 950 | po::value< vector<int> >()->multitoken(),
|
---|
| 951 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 952 | ;
|
---|
| 953 | break;
|
---|
| 954 | case Double:
|
---|
| 955 | ListRunner->second->add_options()
|
---|
[e30ce8] | 956 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[ab9a27] | 957 | CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
|
---|
[39b639] | 958 | po::value< double >()->default_value(lexical_cast<double>(CurrentValue[*OptionRunner].c_str())) :
|
---|
[e30ce8] | 959 | po::value< double >(),
|
---|
| 960 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 961 | ;
|
---|
| 962 | break;
|
---|
| 963 | case ListOfDoubles:
|
---|
| 964 | ListRunner->second->add_options()
|
---|
[e30ce8] | 965 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
| 966 | po::value< vector<double> >()->multitoken(),
|
---|
| 967 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 968 | ;
|
---|
| 969 | break;
|
---|
| 970 | case String:
|
---|
| 971 | ListRunner->second->add_options()
|
---|
[e30ce8] | 972 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[ab9a27] | 973 | CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
|
---|
| 974 | po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) :
|
---|
[e30ce8] | 975 | po::value< std::string >(),
|
---|
| 976 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 977 | ;
|
---|
| 978 | break;
|
---|
[0b0a20] | 979 | case ListOfStrings:
|
---|
[cd8e55] | 980 | ListRunner->second->add_options()
|
---|
| 981 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
| 982 | po::value< vector<std::string> >()->multitoken(),
|
---|
| 983 | getDescription(*OptionRunner).c_str())
|
---|
| 984 | ;
|
---|
| 985 | break;
|
---|
[0b0a20] | 986 | case Vector:
|
---|
[97ebf8] | 987 | ListRunner->second->add_options()
|
---|
[e30ce8] | 988 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[0b0a20] | 989 | po::value<VectorValue>(),
|
---|
[e30ce8] | 990 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 991 | ;
|
---|
| 992 | break;
|
---|
[0b0a20] | 993 | case ListOfVectors:
|
---|
[97ebf8] | 994 | ListRunner->second->add_options()
|
---|
[e30ce8] | 995 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[0b0a20] | 996 | po::value< vector<VectorValue> >()->multitoken(),
|
---|
[e30ce8] | 997 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 998 | ;
|
---|
| 999 | break;
|
---|
| 1000 | case Molecule:
|
---|
| 1001 | ListRunner->second->add_options()
|
---|
[e30ce8] | 1002 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[ab9a27] | 1003 | CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
|
---|
[39b639] | 1004 | po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
|
---|
[e30ce8] | 1005 | po::value< int >(),
|
---|
| 1006 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 1007 | ;
|
---|
| 1008 | break;
|
---|
| 1009 | case ListOfMolecules:
|
---|
| 1010 | ListRunner->second->add_options()
|
---|
[e30ce8] | 1011 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
| 1012 | po::value< vector<int> >()->multitoken(),
|
---|
| 1013 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 1014 | ;
|
---|
| 1015 | break;
|
---|
| 1016 | case Atom:
|
---|
| 1017 | ListRunner->second->add_options()
|
---|
[e30ce8] | 1018 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[ab9a27] | 1019 | CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
|
---|
[39b639] | 1020 | po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
|
---|
[e30ce8] | 1021 | po::value< int >(),
|
---|
| 1022 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 1023 | ;
|
---|
| 1024 | break;
|
---|
| 1025 | case ListOfAtoms:
|
---|
| 1026 | ListRunner->second->add_options()
|
---|
[e30ce8] | 1027 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
| 1028 | po::value< vector<int> >()->multitoken(),
|
---|
| 1029 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 1030 | ;
|
---|
| 1031 | break;
|
---|
| 1032 | case Element:
|
---|
| 1033 | ListRunner->second->add_options()
|
---|
[e30ce8] | 1034 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
[39b639] | 1035 | po::value< int >(),
|
---|
[e30ce8] | 1036 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 1037 | ;
|
---|
| 1038 | break;
|
---|
| 1039 | case ListOfElements:
|
---|
| 1040 | ListRunner->second->add_options()
|
---|
[e30ce8] | 1041 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
| 1042 | po::value< vector<int> >()->multitoken(),
|
---|
| 1043 | getDescription(*OptionRunner).c_str())
|
---|
[97ebf8] | 1044 | ;
|
---|
| 1045 | break;
|
---|
| 1046 | }
|
---|
| 1047 | } else {
|
---|
[0b0a20] | 1048 | DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
|
---|
[97ebf8] | 1049 | ListRunner->second->add_options()
|
---|
| 1050 | (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
|
---|
| 1051 | ;
|
---|
| 1052 | }
|
---|
| 1053 | }
|
---|
| 1054 | }
|
---|
| 1055 | }
|
---|
| 1056 |
|
---|
| 1057 | /** Getter for MapOfActions:DescriptionMap.
|
---|
| 1058 | * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
|
---|
| 1059 | * \param actionname name of the action to lookup
|
---|
| 1060 | * \return Description of the action
|
---|
| 1061 | */
|
---|
| 1062 | std::string MapOfActions::getDescription(string actionname)
|
---|
| 1063 | {
|
---|
| 1064 | ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescription");
|
---|
| 1065 | return DescriptionMap[actionname];
|
---|
| 1066 | }
|
---|
| 1067 |
|
---|
| 1068 | /** Specific Getter for a MapOfActions:ShortFormMap.
|
---|
| 1069 | * If action has a short for, then combination is as "actionname,ShortForm" (this is
|
---|
| 1070 | * the desired format for boost::program_options). If no short form exists in the map,
|
---|
| 1071 | * just actionname will be returned
|
---|
| 1072 | * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
|
---|
| 1073 | * \param actionname name of the action to lookup
|
---|
| 1074 | * \return actionname,ShortForm or Description of the action
|
---|
| 1075 | */
|
---|
| 1076 | std::string MapOfActions::getKeyAndShortForm(string actionname)
|
---|
| 1077 | {
|
---|
| 1078 | stringstream output;
|
---|
| 1079 | ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescriptionAndShortForm");
|
---|
| 1080 | output << actionname;
|
---|
| 1081 | if (ShortFormMap.find(actionname) != DescriptionMap.end())
|
---|
| 1082 | output << "," << ShortFormMap[actionname];
|
---|
| 1083 | return output.str();
|
---|
| 1084 | }
|
---|
| 1085 |
|
---|
| 1086 | /** Getter for MapOfActions:ShortFormMap.
|
---|
| 1087 | * Note that we assert when action does not exist CommandLineParser::ShortFormMap.
|
---|
| 1088 | * \param actionname name of the action to lookup
|
---|
| 1089 | * \return ShortForm of the action
|
---|
| 1090 | */
|
---|
| 1091 | std::string MapOfActions::getShortForm(string actionname)
|
---|
| 1092 | {
|
---|
| 1093 | ASSERT(ShortFormMap.find(actionname) != ShortFormMap.end(), "Unknown action name passed to MapOfActions::getShortForm");
|
---|
| 1094 | return ShortFormMap[actionname];
|
---|
| 1095 | }
|
---|
| 1096 |
|
---|
| 1097 | /** Returns whether the given action needs a value or not.
|
---|
| 1098 | * \param actionname name of the action to look up
|
---|
| 1099 | * \return true - value is needed, false - no value is stored in MapOfActions::TypeMap
|
---|
| 1100 | */
|
---|
| 1101 | bool MapOfActions::hasValue(string actionname)
|
---|
| 1102 | {
|
---|
| 1103 | return (TypeMap.find(actionname) != TypeMap.end());
|
---|
| 1104 | }
|
---|
| 1105 |
|
---|
| 1106 | /** Getter for MapOfActions::TypeMap.
|
---|
| 1107 | * \param actionname name of the action to look up
|
---|
| 1108 | * \return type of the action
|
---|
| 1109 | */
|
---|
[ab9a27] | 1110 | std::string MapOfActions::getValueType(string actionname)
|
---|
[97ebf8] | 1111 | {
|
---|
[ab9a27] | 1112 | return TypeMap[actionname]->name();
|
---|
[97ebf8] | 1113 | }
|
---|
| 1114 |
|
---|
| 1115 | /** Searches whether action is registered with CommandLineParser.
|
---|
| 1116 | * Note that this method is only meant transitionally for ParseCommandLineOptions' removal.
|
---|
| 1117 | * I.e. All actions that are already handled by the new CommandLineUIFactory can be checked
|
---|
| 1118 | * by this function.
|
---|
| 1119 | * \param shortform command short form to look for
|
---|
| 1120 | * \return true - action has been registered, false - action has not been registered.
|
---|
| 1121 | */
|
---|
| 1122 | bool MapOfActions::isShortFormPresent(string shortform)
|
---|
| 1123 | {
|
---|
| 1124 | bool result = false;
|
---|
| 1125 | string actionname;
|
---|
| 1126 | for (map<std::string, std::string>::iterator ShortFormRunner = ShortFormMap.begin(); ShortFormRunner != ShortFormMap.end(); ++ShortFormRunner)
|
---|
| 1127 | if (ShortFormRunner->second == shortform) {
|
---|
| 1128 | actionname = ShortFormRunner->first;
|
---|
| 1129 | break;
|
---|
| 1130 | }
|
---|
| 1131 | result = result || (generic.find(actionname) != generic.end());
|
---|
| 1132 | result = result || (config.find(actionname) != config.end());
|
---|
| 1133 | result = result || (hidden.find(actionname) != hidden.end());
|
---|
| 1134 | result = result || (visible.find(actionname) != visible.end());
|
---|
| 1135 | result = result || (inputfile.find(actionname) != inputfile.end());
|
---|
| 1136 | return result;
|
---|
| 1137 | }
|
---|
| 1138 |
|
---|
[7e6b00] | 1139 | /** Returns the inverse to MapOfActions::ShortFormMap, i.e. lookup actionname for its short form.
|
---|
| 1140 | * \return map from short form of action to name of action
|
---|
| 1141 | */
|
---|
| 1142 | map <std::string, std::string> MapOfActions::getShortFormToActionMap()
|
---|
| 1143 | {
|
---|
| 1144 | map <std::string, std::string> result;
|
---|
| 1145 |
|
---|
| 1146 | for (map<std::string, std::string>::iterator iter = ShortFormMap.begin(); iter != ShortFormMap.end(); ++iter)
|
---|
| 1147 | result[iter->second] = iter->first;
|
---|
| 1148 |
|
---|
| 1149 | return result;
|
---|
| 1150 | }
|
---|
[97ebf8] | 1151 |
|
---|
| 1152 |
|
---|
| 1153 | CONSTRUCT_SINGLETON(MapOfActions)
|
---|