source: src/Actions/MapOfActions.cpp@ 7d8342

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 7d8342 was c449d9, checked in by Frederik Heber <heber@…>, 14 years ago

Added new Action ConstructBondGraphAction.

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