source: src/Actions/MapOfActions.cpp@ c7f5c2

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since c7f5c2 was 22c44bf, checked in by Frederik Heber <heber@…>, 15 years ago

Changed RotateAroundOriginByAngleAction from acting on molecules to acting on selected atoms.

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