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

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

Added Undo/Redo actions to MapOfActions.

  • ActionHistory:UndoAction and ::RedoAction now have ::NAME[], "undo", "redo"
  • added as command line arguments
  • TESTFIX: added translation of atom test (Simple_configuration/9)
  • TESTFIX: added undo/redo for this translation test

From now on, undo/redo should be tested within the testsuite by adding under the
same test case block another one with additional "--undo" and "--undo --redo"
added to check for correct implementation of ::performUndo() and ::performRedo()
as well.

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