source: src/Actions/MapOfActions.cpp@ 1fd675

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 1fd675 was 53d01c, checked in by Frederik Heber <heber@…>, 15 years ago

Renamed dir Actions/CmdAction -> Actions/CommandAction, renamed class CommandLine... -> Command...

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