source: src/Actions/MapOfActions.cpp@ 994713

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

Made all member variables of class element private, added accessor functions and periodentafel is friend.

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