Changeset b0acc3 for src/Actions


Ignore:
Timestamp:
Jun 26, 2010, 10:14:22 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
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
Children:
b2531f
Parents:
b80021 (diff), 326bbe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'stable' into QT4Refactoring

Conflicts:

molecuilder/src/Makefile.am

  • molecuilder/src/Makefile.am: No more present (in stable) Legacy was conflicting
Location:
src/Actions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MapOfActions.cpp

    rb80021 rb0acc3  
    2222#include "verbose.hpp"
    2323
     24#include "Actions/ActionRegistry.hpp"
     25#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
     26#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
     27#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
     28#include "Actions/AtomAction/AddAction.hpp"
     29#include "Actions/AtomAction/ChangeElementAction.hpp"
     30#include "Actions/AtomAction/RemoveAction.hpp"
     31#include "Actions/CmdAction/BondLengthTableAction.hpp"
     32#include "Actions/CmdAction/ElementDbAction.hpp"
     33#include "Actions/CmdAction/FastParsingAction.hpp"
     34#include "Actions/CmdAction/HelpAction.hpp"
     35#include "Actions/CmdAction/VerboseAction.hpp"
     36#include "Actions/CmdAction/VersionAction.hpp"
     37#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
     38#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
     39#include "Actions/FragmentationAction/FragmentationAction.hpp"
     40#include "Actions/MoleculeAction/BondFileAction.hpp"
     41#include "Actions/MoleculeAction/ChangeNameAction.hpp"
     42#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
     43#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
     44#include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
     45#include "Actions/MoleculeAction/SaveBondsAction.hpp"
     46#include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
     47#include "Actions/MoleculeAction/TranslateAction.hpp"
     48#include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
     49#include "Actions/ParserAction/LoadXyzAction.hpp"
     50#include "Actions/ParserAction/SaveXyzAction.hpp"
     51#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
     52#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
     53#include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
     54#include "Actions/WorldAction/BoundInBoxAction.hpp"
     55#include "Actions/WorldAction/CenterInBoxAction.hpp"
     56#include "Actions/WorldAction/CenterOnEdgeAction.hpp"
     57#include "Actions/WorldAction/ChangeBoxAction.hpp"
     58#include "Actions/WorldAction/InputAction.hpp"
     59#include "Actions/WorldAction/OutputAction.hpp"
     60#include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
     61#include "Actions/WorldAction/RepeatBoxAction.hpp"
     62#include "Actions/WorldAction/ScaleBoxAction.hpp"
     63#include "Actions/WorldAction/SetDefaultNameAction.hpp"
     64#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
    2465#include "Actions/Values.hpp"
    2566
     
    99140  DescriptionMap["save-bonds"] = "name of the bonds file to write to";
    100141  DescriptionMap["save-temperature"] = "name of the temperature file to write to";
     142  DescriptionMap["SaveXyz"] = "save world as xyz file";
    101143  DescriptionMap["scale-box"] = "scale box and atomic positions inside";
    102144  DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
     
    245287  DefaultValue["periodic"] = "0";
    246288
    247 
    248   // list of generic actions
     289  // put action into each menu category
     290  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") );
     291  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") );
     292  MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") );
     293
     294  MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "add-atom") );
     295  MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "change-element") );
     296  MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "remove-atom") );
     297
     298  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "bond-table") );
     299  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "element-db") );
     300  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "fastparsing") );
     301  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "verbose") );
     302  MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "version") );
     303
     304  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "depth-first-search") );
     305  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "fragment-mol") );
     306  MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "subgraph-dissect") );
     307
     308  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "bond-file") );
     309  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "change-molname") );
     310  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") );
     311  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") );
     312  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") );
     313  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") );
     314  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-bonds") );
     315  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-temperature") );
     316  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "suspend-in-water") );
     317  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "translate-mol") );
     318  MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "verlet-integrate") );
     319
     320  MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") );
     321  MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") );
     322
     323  MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") );
     324  MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "nonconvex-envelope") );
     325
     326  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "boundary") );
     327  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "bound-in-box") );
     328  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-in-box") );
     329  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-edge") );
     330  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "change-box") );
     331  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
     332  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
     333  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") );
     334  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
     335  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
     336  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") );
     337  MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") );
     338
     339  // put actions into command line category
    249340        generic.insert("add-atom");
    250341  generic.insert("bond-file");
     
    328419}
    329420
     421
     422void MapOfActions::populateActions()
     423{
     424  new AnalysisMolecularVolumeAction();
     425  new AnalysisPairCorrelationAction();
     426  new AnalysisPrincipalAxisSystemAction();
     427
     428  new AtomAddAction();
     429  new AtomChangeElementAction();
     430  new AtomRemoveAction();
     431
     432  new CommandLineBondLengthTableAction();
     433  new CommandLineElementDbAction();
     434  new CommandLineFastParsingAction();
     435  new CommandLineHelpAction();
     436  new CommandLineVerboseAction();
     437  new CommandLineVersionAction();
     438
     439  new FragmentationDepthFirstSearchAction();
     440  new FragmentationFragmentationAction();
     441  new FragmentationSubgraphDissectionAction();
     442
     443  new MoleculeBondFileAction();
     444  new MoleculeChangeNameAction();
     445  new MoleculeFillWithMoleculeAction();
     446  new MoleculeLinearInterpolationofTrajectoriesAction();
     447  new MoleculeSaveAdjacencyAction();
     448  new MoleculeSaveBondsAction();
     449  new MoleculeSaveTemperatureAction();
     450  new MoleculeTranslateAction();
     451  new MoleculeVerletIntegrationAction();
     452
     453  new ParserLoadXyzAction();
     454  new ParserSaveXyzAction();
     455
     456  new TesselationConvexEnvelopeAction();
     457  new TesselationNonConvexEnvelopeAction();
     458
     459  new WorldAddEmptyBoundaryAction();
     460  new WorldBoundInBoxAction();
     461  new WorldCenterInBoxAction();
     462  new WorldCenterOnEdgeAction();
     463  new WorldChangeBoxAction();
     464  new WorldInputAction();
     465  new WorldOutputAction();
     466  new WorldRemoveSphereOfAtomsAction();
     467  new WorldRepeatBoxAction();
     468  new WorldScaleBoxAction();
     469  new WorldSetDefaultNameAction();
     470  new WorldSetGaussianBasisAction();
     471}
     472
     473
    330474/** Adds all options to the CommandLineParser.
    331475 *
  • src/Actions/MapOfActions.hpp

    rb80021 rb0acc3  
    1111#include "Helpers/Assert.hpp"
    1212#include <boost/program_options.hpp>
     13
    1314#include <map>
    1415#include <set>
     
    2021namespace po = boost::program_options;
    2122
     23/** Central class for adding functionality to the code.
     24 *
     25 * In Molecuilder everything that can be done - such as adding atoms,
     26 * translating molecules, saving bind information - is an Action.
     27 *
     28 * In order to reference Action's with what the user sees, this class is the
     29 * mediator.
     30 *
     31 * An Action is described to the user by:
     32 * -# a name (this is the most important information)
     33 * -# a description
     34 * -# a shortform (single letter for use on the command line)
     35 * -# a text menu it resides in
     36 * -# the type of its argument
     37 * -# the command line category
     38 *
     39 * The Action::NAME is the most important information because every Action
     40 * registers itself automatically with the ActionRegistry and can be retrieved
     41 * therefrom and from this MapOfActions simply by knowing its name alone.
     42 *
     43 * In the constructor of MapOfActions all this is set.
     44 *
     45 * Note that Action will require input from the user. This is done via class
     46 * Query.
     47 *
     48 * And note also that MapOfActions actually contains more than just all
     49 * Actions: There are a number of names that actually are just arguments to
     50 * actions (e.g. "output-file").
     51 *
     52 * <h1> Howto add an Action</h1>
     53 *
     54 * Let us assume your new action (class) is called SuperDuperAction, consisting
     55 * of two files SuperDuperAction.cpp and SuperDuperAction.hpp.
     56 *
     57 * Furthermore, let's say you Action needs two values: a double value as a
     58 * upper threshold and a string which is the name of the output file.
     59 *
     60 * <h2> Command Line preliminaries </h2>
     61 *
     62 * You have to decide whether (for the command line) it makes sense to have an
     63 * extra argument requesting the arguments, or one should be the argument of
     64 * your action. I.e. your action name is "super-duper", then the use may
     65 * call your action like this:
     66 *
     67 * ./molecuilder --super-duper 4 --output-file test.dat
     68 *
     69 * Here, we have picked the threshold as the value for your action and the
     70 * name of the output file is given by an additional argument. Of course,
     71 * it can be the other way round or by two arguments such as here:
     72 *
     73 * ./molecuilder --super-duper --threshold 4 --output-file test.dat
     74 *
     75 * It depends on what possible arguments are already there (don't make up
     76 * new ones if present ones actually make sense for your action) and which
     77 * argument is more natural or closer to what your action does.
     78 *
     79 * <h2> Menu preliminaries </h2>
     80 *
     81 * Whatever you decide, your action will need some Query dialogs to request
     82 * the necessary information from the user, either via a command line
     83 * argument (--output-file) via a text dialog (referenced by "output-file")
     84 * or via a graphical dialog (same reference). And therein, the names
     85 * of the arguments have to re-appear.
     86 *
     87 * Then, the following steps have to be done to incorporate your Action:
     88 * -# create a unique name for your action (no capital letters) to reference
     89 *    it, this name has to appear in the file SuperDuperAction.cpp, e.g.
     90 *    "super-duper"
     91 * -# pick names the other required arguments, best if they are already
     92 *    present in the MapOfActions. They have to appear in Query's in the
     93 *    code of your Action.
     94 * -# With this name create entries in the following maps for the action
     95 *    name and for each names of a desired addtional argument if not present:
     96 *   -# DescriptionMap, a catchy description of what your action does
     97 *   -# TypeMap, see MapOfActions::OptionTypes for possible types of the single
     98 *      argument it takes.
     99 *   -# MenuContainsActionMap, in which menu should your action appear
     100 *   -# ShortFormMap (optional), single letter for command line call
     101 *   -# DefaultValueMap (optional), the default value (always a string)
     102 * -# add to one of the command line sets by the following categories
     103 *   -# generic - generic options (i.e. not one of the others)
     104 *   -# config - action/argument only considers internal bevahior, user
     105 *      does not have to see it while still having full functionality
     106 *   -# hidden - this should be hidden from the user
     107 *   -# visible - this should be visible to the user
     108 *   -# inputfile - this should only be parsed from an input file, not
     109 *      from command line
     110 * -# add to a menu, i.e. make an entry in MenuContainsActionMap.
     111 * -# add header file SuperDuperAction.hpp to MapOfActions.cpp and instantiate
     112 *    your action in populateMenu() (mind the sorting: 1. menu,
     113 *    2. alphabetical)
     114 *
     115 *  And that's.
     116 *
     117 *  Now, your action can be called from the command line, within the text
     118 *  menu and the graphical user interface.
     119 *
     120 */
    22121class MapOfActions : public Singleton<MapOfActions> {
    23122  friend class Singleton<MapOfActions>;
     
    27126
    28127  // getter for the action descriptions and short forms
    29   std::string getDescription(string actionname);
    30   std::string getKeyAndShortForm(string actionname);
    31   std::string getShortForm(string actionname);
    32   map <std::string, std::string> getShortFormToActionMap();
     128  std::string getDescription(std::string actionname);
     129  std::string getKeyAndShortForm(std::string actionname);
     130  std::string getShortForm(std::string actionname);
     131  std::map <std::string, std::string> getShortFormToActionMap();
    33132
    34133  void AddOptionsToParser();
    35134
    36135  // check presence and getter for action type
    37   bool hasValue(string actionname);
    38   bool isShortFormPresent(string shortform);
    39   enum OptionTypes getValueType(string actionname);
     136  bool hasValue(std::string actionname);
     137  bool isShortFormPresent(std::string shortform);
     138  enum OptionTypes getValueType(std::string actionname);
    40139
    41   set<string> generic;
    42   set<string> config;
    43   set<string> hidden;
    44   set<string> visible;
    45   set<string> inputfile;
     140  std::set<std::string> generic;
     141  std::set<std::string> config;
     142  std::set<std::string> hidden;
     143  std::set<std::string> visible;
     144  std::set<std::string> inputfile;
     145
     146  std::multimap <std::string, std::string> MenuContainsActionMap;
     147
     148  // instantiates and puts all known actions into the ActionRegistry
     149  void populateActions();
    46150
    47151private:
     
    51155
    52156  // lookup list from our configs to the ones of CommandLineParser
    53   map< set<std::string> *, po::options_description *> CmdParserLookup;
     157  std::map< std::set<std::string> *, po::options_description *> CmdParserLookup;
    54158
    55159  // map of the action names and their description
    56   map<std::string, std::string> DefaultValue;
    57   map<std::string, std::string> DescriptionMap;
    58   map<std::string, std::string> ShortFormMap;
    59   map<std::string, enum OptionTypes > TypeMap;
     160  std::map<std::string, std::string> DefaultValue;
     161  std::map<std::string, std::string> DescriptionMap;
     162  std::map<std::string, std::string> ShortFormMap;
     163  std::map<std::string, enum OptionTypes > TypeMap;
    60164};
    61165
  • src/Actions/MoleculeAction/ChangeNameAction.cpp

    rb80021 rb0acc3  
    3636};
    3737
    38 const char MoleculeChangeNameAction::NAME[] = "Change filename of Molecule";
     38const char MoleculeChangeNameAction::NAME[] = "change-molname";
    3939
    4040MoleculeChangeNameAction::MoleculeChangeNameAction() :
Note: See TracChangeset for help on using the changeset viewer.