source: src/Actions/MapOfActions.cpp@ 03c902

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

Actions may now have optional parameters.

  • an additional parameter in ValueStorage::queryCurrentValue() states whether value is optional or not in which case no assertion is thrown but wrong returned
  • new function MapOfActions::isCurrentValuePresent()
  • Property mode set to 100644
File size: 50.9 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
616bool MapOfActions::isCurrentValuePresent(const char *name) const
617{
618 return (CurrentValue.find(name) != CurrentValue.end());
619}
620
621void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
622{
623 int atomID = -1;
624 if (typeid( atom ) == *TypeMap[name]) {
625 if (CurrentValue.find(name) == CurrentValue.end())
626 throw MissingValueException(__FILE__, __LINE__);
627 atomID = lexical_cast<int>(CurrentValue[name].c_str());
628 CurrentValue.erase(name);
629 } else
630 throw IllegalTypeException(__FILE__,__LINE__);
631 _T = World::getInstance().getAtom(AtomById(atomID));
632}
633
634void MapOfActions::queryCurrentValue(const char * name, const element * &_T) {
635 int Z = -1;
636 if (typeid(const element ) == *TypeMap[name]) {
637 if (CurrentValue.find(name) == CurrentValue.end())
638 throw MissingValueException(__FILE__, __LINE__);
639 Z = lexical_cast<int>(CurrentValue[name].c_str());
640 CurrentValue.erase(name);
641 } else
642 throw IllegalTypeException(__FILE__,__LINE__);
643 _T = World::getInstance().getPeriode()->FindElement(Z);
644}
645
646void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) {
647 int molID = -1;
648 if (typeid( molecule ) == *TypeMap[name]) {
649 if (CurrentValue.find(name) == CurrentValue.end())
650 throw MissingValueException(__FILE__, __LINE__);
651 molID = lexical_cast<int>(CurrentValue[name].c_str());
652 CurrentValue.erase(name);
653 } else
654 throw IllegalTypeException(__FILE__,__LINE__);
655 _T = World::getInstance().getMolecule(MoleculeById(molID));
656}
657
658void MapOfActions::queryCurrentValue(const char * name, class Box &_T) {
659 Matrix M;
660 double tmp;
661 if (typeid( BoxValue ) == *TypeMap[name]) {
662 if (CurrentValue.find(name) == CurrentValue.end())
663 throw MissingValueException(__FILE__, __LINE__);
664 std::istringstream stream(CurrentValue[name]);
665 stream >> tmp;
666 M.set(0,0,tmp);
667 stream >> tmp;
668 M.set(0,1,tmp);
669 M.set(1,0,tmp);
670 stream >> tmp;
671 M.set(0,2,tmp);
672 M.set(2,0,tmp);
673 stream >> tmp;
674 M.set(1,1,tmp);
675 stream >> tmp;
676 M.set(1,2,tmp);
677 M.set(2,1,tmp);
678 stream >> tmp;
679 M.set(2,2,tmp);
680 _T = M;
681 CurrentValue.erase(name);
682 } else
683 throw IllegalTypeException(__FILE__,__LINE__);
684}
685
686void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) {
687 if (typeid( VectorValue ) == *TypeMap[name]) {
688 std::istringstream stream(CurrentValue[name]);
689 CurrentValue.erase(name);
690 stream >> _T[0];
691 stream >> _T[1];
692 stream >> _T[2];
693 } else
694 throw IllegalTypeException(__FILE__,__LINE__);
695}
696
697void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T)
698{
699 int atomID = -1;
700 atom *Walker = NULL;
701 if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
702 if (CurrentValue.find(name) == CurrentValue.end())
703 throw MissingValueException(__FILE__, __LINE__);
704 std::istringstream stream(CurrentValue[name]);
705 CurrentValue.erase(name);
706 while (!stream.fail()) {
707 stream >> atomID >> ws;
708 Walker = World::getInstance().getAtom(AtomById(atomID));
709 if (Walker != NULL)
710 _T.push_back(Walker);
711 atomID = -1;
712 Walker = NULL;
713 }
714 } else
715 throw IllegalTypeException(__FILE__,__LINE__);
716}
717
718void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
719{
720 int Z = -1;
721 const element *elemental = NULL;
722 if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
723 if (CurrentValue.find(name) == CurrentValue.end())
724 throw MissingValueException(__FILE__, __LINE__);
725 std::istringstream stream(CurrentValue[name]);
726 CurrentValue.erase(name);
727 while (!stream.fail()) {
728 stream >> Z >> ws;
729 elemental = World::getInstance().getPeriode()->FindElement(Z);
730 if (elemental != NULL)
731 _T.push_back(elemental);
732 Z = -1;
733 }
734 } else
735 throw IllegalTypeException(__FILE__,__LINE__);
736}
737
738void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T)
739{
740 int molID = -1;
741 molecule *mol = NULL;
742 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
743 if (CurrentValue.find(name) == CurrentValue.end())
744 throw MissingValueException(__FILE__, __LINE__);
745 std::istringstream stream(CurrentValue[name]);
746 CurrentValue.erase(name);
747 while (!stream.fail()) {
748 stream >> molID >> ws;
749 mol = World::getInstance().getMolecule(MoleculeById(molID));
750 if (mol != NULL)
751 _T.push_back(mol);
752 molID = -1;
753 mol = NULL;
754 }
755 } else
756 throw IllegalTypeException(__FILE__,__LINE__);
757}
758
759
760void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
761{
762 if (typeid( atom ) == *TypeMap[name]) {
763 std::ostringstream stream;
764 stream << _T->getId();
765 CurrentValue[name] = stream.str();
766 } else
767 throw IllegalTypeException(__FILE__,__LINE__);
768}
769
770void MapOfActions::setCurrentValue(const char * name, const element * &_T)
771{
772 if (typeid(const element ) == *TypeMap[name]) {
773 std::ostringstream stream;
774 stream << _T->Z;
775 CurrentValue[name] = stream.str();
776 } else
777 throw IllegalTypeException(__FILE__,__LINE__);
778}
779
780void MapOfActions::setCurrentValue(const char * name, class molecule * &_T)
781{
782 if (typeid( molecule ) == *TypeMap[name]) {
783 std::ostringstream stream;
784 stream << _T->getId();
785 CurrentValue[name] = stream.str();
786 } else
787 throw IllegalTypeException(__FILE__,__LINE__);
788}
789
790void MapOfActions::setCurrentValue(const char * name, class Box &_T)
791{
792 const Matrix &M = _T.getM();
793 if (typeid( BoxValue ) == *TypeMap[name]) {
794 std::ostringstream stream;
795 stream << M.at(0,0) << " ";
796 stream << M.at(0,1) << " ";
797 stream << M.at(0,2) << " ";
798 stream << M.at(1,1) << " ";
799 stream << M.at(1,2) << " ";
800 stream << M.at(2,2) << " ";
801 CurrentValue[name] = stream.str();
802 } else
803 throw IllegalTypeException(__FILE__,__LINE__);
804}
805
806void MapOfActions::setCurrentValue(const char * name, class Vector &_T)
807{
808 if (typeid( VectorValue ) == *TypeMap[name]){
809 std::ostringstream stream;
810 stream << _T[0] << " ";
811 stream << _T[1] << " ";
812 stream << _T[2] << " ";
813 CurrentValue[name] = stream.str();
814 } else
815 throw IllegalTypeException(__FILE__,__LINE__);
816}
817
818void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T)
819{
820 if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
821 std::ostringstream stream;
822 for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
823 stream << (*iter)->getId() << " ";
824 }
825 CurrentValue[name] = stream.str();
826 } else
827 throw IllegalTypeException(__FILE__,__LINE__);
828}
829
830void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
831{
832 if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
833 std::ostringstream stream;
834 for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
835 stream << (*iter)->Z << " ";
836 }
837 CurrentValue[name] = stream.str();
838 } else
839 throw IllegalTypeException(__FILE__,__LINE__);
840}
841
842void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T)
843{
844 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
845 std::ostringstream stream;
846 for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
847 stream << (*iter)->getId() << " ";
848 }
849 CurrentValue[name] = stream.str();
850 } else
851 throw IllegalTypeException(__FILE__,__LINE__);
852}
853
854
855
856void MapOfActions::populateActions()
857{
858 new AnalysisMolecularVolumeAction();
859 new AnalysisPairCorrelationAction();
860 new AnalysisPointCorrelationAction();
861 new AnalysisPrincipalAxisSystemAction();
862 new AnalysisSurfaceCorrelationAction();
863
864 new AtomAddAction();
865 new AtomChangeElementAction();
866 new AtomRemoveAction();
867 new AtomRotateAroundOriginByAngleAction();
868 new AtomTranslateAction();
869
870 new CommandLineBondLengthTableAction();
871 new CommandLineElementDbAction();
872 new CommandLineFastParsingAction();
873 new CommandLineHelpAction();
874 new CommandLineVerboseAction();
875 new CommandLineVersionAction();
876
877 new FragmentationDepthFirstSearchAction();
878 new FragmentationFragmentationAction();
879 new FragmentationSubgraphDissectionAction();
880
881 new MoleculeBondFileAction();
882 new MoleculeChangeNameAction();
883 new MoleculeFillWithMoleculeAction();
884 new MoleculeLinearInterpolationofTrajectoriesAction();
885 new MoleculeRotateAroundSelfByAngleAction();
886 new MoleculeRotateToPrincipalAxisSystemAction();
887 new MoleculeSaveAdjacencyAction();
888 new MoleculeSaveBondsAction();
889 new MoleculeSaveTemperatureAction();
890 new MoleculeSuspendInWaterAction();
891 new MoleculeVerletIntegrationAction();
892
893 new ParserLoadXyzAction();
894 new ParserSaveXyzAction();
895
896 new SelectionClearAllAtomsAction();
897 new SelectionClearAllMoleculesAction();
898 new SelectionAllAtomsAction();
899 new SelectionAllAtomsInsideCuboidAction();
900 new SelectionAllAtomsInsideSphereAction();
901 new SelectionAllAtomsOfMoleculeAction();
902 new SelectionAllMoleculesAction();
903 new SelectionAtomByIdAction();
904 new SelectionMoleculeByIdAction();
905 new SelectionMoleculeOfAtomAction();
906 new SelectionNotAllAtomsAction();
907 new SelectionNotAllAtomsInsideCuboidAction();
908 new SelectionNotAllAtomsInsideSphereAction();
909 new SelectionNotAllAtomsOfMoleculeAction();
910 new SelectionNotAllMoleculesAction();
911 new SelectionNotAtomByIdAction();
912 new SelectionNotMoleculeByIdAction();
913 new SelectionNotMoleculeOfAtomAction();
914
915 new TesselationConvexEnvelopeAction();
916 new TesselationNonConvexEnvelopeAction();
917
918 new WorldAddEmptyBoundaryAction();
919 new WorldBoundInBoxAction();
920 new WorldCenterInBoxAction();
921 new WorldCenterOnEdgeAction();
922 new WorldChangeBoxAction();
923 new WorldInputAction();
924 new WorldOutputAction();
925 new WorldRepeatBoxAction();
926 new WorldScaleBoxAction();
927 new WorldSetDefaultNameAction();
928 new WorldSetGaussianBasisAction();
929 new WorldSetOutputFormatsAction();
930}
931
932/** Adds all options to the CommandLineParser.
933 *
934 */
935void MapOfActions::AddOptionsToParser()
936{
937 // add other options
938 for (map< set<string>*, po::options_description* >::iterator ListRunner = CmdParserLookup.begin(); ListRunner != CmdParserLookup.end(); ++ListRunner) {
939 for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
940 if (hasValue(*OptionRunner)) {
941 DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl);
942 switch(TypeEnumMap[TypeMap[*OptionRunner]]) {
943 default:
944 case None:
945 ListRunner->second->add_options()
946 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
947 ;
948 break;
949 case Boolean:
950 ListRunner->second->add_options()
951 (getKeyAndShortForm(*OptionRunner).c_str(),
952 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
953 po::value< bool >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
954 po::value< bool >(),
955 getDescription(*OptionRunner).c_str())
956 ;
957 break;
958 case Box:
959 ListRunner->second->add_options()
960 (getKeyAndShortForm(*OptionRunner).c_str(),
961 po::value<BoxValue>(),
962 getDescription(*OptionRunner).c_str())
963 ;
964 break;
965 case Integer:
966 ListRunner->second->add_options()
967 (getKeyAndShortForm(*OptionRunner).c_str(),
968 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
969 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
970 po::value< int >(),
971 getDescription(*OptionRunner).c_str())
972 ;
973 break;
974 case ListOfIntegers:
975 ListRunner->second->add_options()
976 (getKeyAndShortForm(*OptionRunner).c_str(),
977 po::value< vector<int> >()->multitoken(),
978 getDescription(*OptionRunner).c_str())
979 ;
980 break;
981 case Double:
982 ListRunner->second->add_options()
983 (getKeyAndShortForm(*OptionRunner).c_str(),
984 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
985 po::value< double >()->default_value(lexical_cast<double>(CurrentValue[*OptionRunner].c_str())) :
986 po::value< double >(),
987 getDescription(*OptionRunner).c_str())
988 ;
989 break;
990 case ListOfDoubles:
991 ListRunner->second->add_options()
992 (getKeyAndShortForm(*OptionRunner).c_str(),
993 po::value< vector<double> >()->multitoken(),
994 getDescription(*OptionRunner).c_str())
995 ;
996 break;
997 case String:
998 ListRunner->second->add_options()
999 (getKeyAndShortForm(*OptionRunner).c_str(),
1000 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
1001 po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) :
1002 po::value< std::string >(),
1003 getDescription(*OptionRunner).c_str())
1004 ;
1005 break;
1006 case ListOfStrings:
1007 ListRunner->second->add_options()
1008 (getKeyAndShortForm(*OptionRunner).c_str(),
1009 po::value< vector<std::string> >()->multitoken(),
1010 getDescription(*OptionRunner).c_str())
1011 ;
1012 break;
1013 case Vector:
1014 ListRunner->second->add_options()
1015 (getKeyAndShortForm(*OptionRunner).c_str(),
1016 po::value<VectorValue>(),
1017 getDescription(*OptionRunner).c_str())
1018 ;
1019 break;
1020 case ListOfVectors:
1021 ListRunner->second->add_options()
1022 (getKeyAndShortForm(*OptionRunner).c_str(),
1023 po::value< vector<VectorValue> >()->multitoken(),
1024 getDescription(*OptionRunner).c_str())
1025 ;
1026 break;
1027 case Molecule:
1028 ListRunner->second->add_options()
1029 (getKeyAndShortForm(*OptionRunner).c_str(),
1030 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
1031 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
1032 po::value< int >(),
1033 getDescription(*OptionRunner).c_str())
1034 ;
1035 break;
1036 case ListOfMolecules:
1037 ListRunner->second->add_options()
1038 (getKeyAndShortForm(*OptionRunner).c_str(),
1039 po::value< vector<int> >()->multitoken(),
1040 getDescription(*OptionRunner).c_str())
1041 ;
1042 break;
1043 case Atom:
1044 ListRunner->second->add_options()
1045 (getKeyAndShortForm(*OptionRunner).c_str(),
1046 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
1047 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
1048 po::value< int >(),
1049 getDescription(*OptionRunner).c_str())
1050 ;
1051 break;
1052 case ListOfAtoms:
1053 ListRunner->second->add_options()
1054 (getKeyAndShortForm(*OptionRunner).c_str(),
1055 po::value< vector<int> >()->multitoken(),
1056 getDescription(*OptionRunner).c_str())
1057 ;
1058 break;
1059 case Element:
1060 ListRunner->second->add_options()
1061 (getKeyAndShortForm(*OptionRunner).c_str(),
1062 po::value< int >(),
1063 getDescription(*OptionRunner).c_str())
1064 ;
1065 break;
1066 case ListOfElements:
1067 ListRunner->second->add_options()
1068 (getKeyAndShortForm(*OptionRunner).c_str(),
1069 po::value< vector<int> >()->multitoken(),
1070 getDescription(*OptionRunner).c_str())
1071 ;
1072 break;
1073 }
1074 } else {
1075 DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
1076 ListRunner->second->add_options()
1077 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
1078 ;
1079 }
1080 }
1081 }
1082}
1083
1084/** Getter for MapOfActions:DescriptionMap.
1085 * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
1086 * \param actionname name of the action to lookup
1087 * \return Description of the action
1088 */
1089std::string MapOfActions::getDescription(string actionname)
1090{
1091 ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescription");
1092 return DescriptionMap[actionname];
1093}
1094
1095/** Specific Getter for a MapOfActions:ShortFormMap.
1096 * If action has a short for, then combination is as "actionname,ShortForm" (this is
1097 * the desired format for boost::program_options). If no short form exists in the map,
1098 * just actionname will be returned
1099 * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
1100 * \param actionname name of the action to lookup
1101 * \return actionname,ShortForm or Description of the action
1102 */
1103std::string MapOfActions::getKeyAndShortForm(string actionname)
1104{
1105 stringstream output;
1106 ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescriptionAndShortForm");
1107 output << actionname;
1108 if (ShortFormMap.find(actionname) != DescriptionMap.end())
1109 output << "," << ShortFormMap[actionname];
1110 return output.str();
1111}
1112
1113/** Getter for MapOfActions:ShortFormMap.
1114 * Note that we assert when action does not exist CommandLineParser::ShortFormMap.
1115 * \param actionname name of the action to lookup
1116 * \return ShortForm of the action
1117 */
1118std::string MapOfActions::getShortForm(string actionname)
1119{
1120 ASSERT(ShortFormMap.find(actionname) != ShortFormMap.end(), "Unknown action name passed to MapOfActions::getShortForm");
1121 return ShortFormMap[actionname];
1122}
1123
1124/** Returns whether the given action needs a value or not.
1125 * \param actionname name of the action to look up
1126 * \return true - value is needed, false - no value is stored in MapOfActions::TypeMap
1127 */
1128bool MapOfActions::hasValue(string actionname)
1129{
1130 return (TypeMap.find(actionname) != TypeMap.end());
1131}
1132
1133/** Getter for MapOfActions::TypeMap.
1134 * \param actionname name of the action to look up
1135 * \return type of the action
1136 */
1137std::string MapOfActions::getValueType(string actionname)
1138{
1139 return TypeMap[actionname]->name();
1140}
1141
1142/** Searches whether action is registered with CommandLineParser.
1143 * Note that this method is only meant transitionally for ParseCommandLineOptions' removal.
1144 * I.e. All actions that are already handled by the new CommandLineUIFactory can be checked
1145 * by this function.
1146 * \param shortform command short form to look for
1147 * \return true - action has been registered, false - action has not been registered.
1148 */
1149bool MapOfActions::isShortFormPresent(string shortform)
1150{
1151 bool result = false;
1152 string actionname;
1153 for (map<std::string, std::string>::iterator ShortFormRunner = ShortFormMap.begin(); ShortFormRunner != ShortFormMap.end(); ++ShortFormRunner)
1154 if (ShortFormRunner->second == shortform) {
1155 actionname = ShortFormRunner->first;
1156 break;
1157 }
1158 result = result || (generic.find(actionname) != generic.end());
1159 result = result || (config.find(actionname) != config.end());
1160 result = result || (hidden.find(actionname) != hidden.end());
1161 result = result || (visible.find(actionname) != visible.end());
1162 result = result || (inputfile.find(actionname) != inputfile.end());
1163 return result;
1164}
1165
1166/** Returns the inverse to MapOfActions::ShortFormMap, i.e. lookup actionname for its short form.
1167 * \return map from short form of action to name of action
1168 */
1169map <std::string, std::string> MapOfActions::getShortFormToActionMap()
1170{
1171 map <std::string, std::string> result;
1172
1173 for (map<std::string, std::string>::iterator iter = ShortFormMap.begin(); iter != ShortFormMap.end(); ++iter)
1174 result[iter->second] = iter->first;
1175
1176 return result;
1177}
1178
1179
1180CONSTRUCT_SINGLETON(MapOfActions)
Note: See TracBrowser for help on using the repository browser.