source: src/Actions/MapOfActions.cpp@ 353e82

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 353e82 was 353e82, checked in by Frederik Heber <heber@…>, 15 years ago

Merge branch 'AddMoreActions' into stable

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