source: src/Actions/MapOfActions.cpp@ 81a9bc

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

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

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