Changes in / [0c5eeb:0d1ad0]
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MapOfActions.cpp
r0c5eeb r0d1ad0 22 22 #include "verbose.hpp" 23 23 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"65 24 #include "Actions/Values.hpp" 66 25 … … 140 99 DescriptionMap["save-bonds"] = "name of the bonds file to write to"; 141 100 DescriptionMap["save-temperature"] = "name of the temperature file to write to"; 142 DescriptionMap["SaveXyz"] = "save world as xyz file";143 101 DescriptionMap["scale-box"] = "scale box and atomic positions inside"; 144 102 DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs"; … … 287 245 DefaultValue["periodic"] = "0"; 288 246 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 247 248 // list of generic actions 340 249 generic.insert("add-atom"); 341 250 generic.insert("bond-file"); … … 419 328 } 420 329 421 422 void 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 474 330 /** Adds all options to the CommandLineParser. 475 331 * -
src/Actions/MapOfActions.hpp
r0c5eeb r0d1ad0 11 11 #include "Helpers/Assert.hpp" 12 12 #include <boost/program_options.hpp> 13 14 13 #include <map> 15 14 #include <set> … … 21 20 namespace po = boost::program_options; 22 21 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 the29 * mediator.30 *31 * An Action is described to the user by:32 * -# a name (this is the most important information)33 * -# a description34 * -# a shortform (single letter for use on the command line)35 * -# a text menu it resides in36 * -# the type of its argument37 * -# the command line category38 *39 * The Action::NAME is the most important information because every Action40 * registers itself automatically with the ActionRegistry and can be retrieved41 * 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 class46 * Query.47 *48 * And note also that MapOfActions actually contains more than just all49 * Actions: There are a number of names that actually are just arguments to50 * 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, consisting55 * of two files SuperDuperAction.cpp and SuperDuperAction.hpp.56 *57 * Furthermore, let's say you Action needs two values: a double value as a58 * 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 an63 * extra argument requesting the arguments, or one should be the argument of64 * your action. I.e. your action name is "super-duper", then the use may65 * call your action like this:66 *67 * ./molecuilder --super-duper 4 --output-file test.dat68 *69 * Here, we have picked the threshold as the value for your action and the70 * 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.dat74 *75 * It depends on what possible arguments are already there (don't make up76 * new ones if present ones actually make sense for your action) and which77 * 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 request82 * the necessary information from the user, either via a command line83 * argument (--output-file) via a text dialog (referenced by "output-file")84 * or via a graphical dialog (same reference). And therein, the names85 * 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 reference89 * 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 already92 * present in the MapOfActions. They have to appear in Query's in the93 * code of your Action.94 * -# With this name create entries in the following maps for the action95 * name and for each names of a desired addtional argument if not present:96 * -# DescriptionMap, a catchy description of what your action does97 * -# TypeMap, see MapOfActions::OptionTypes for possible types of the single98 * argument it takes.99 * -# MenuContainsActionMap, in which menu should your action appear100 * -# ShortFormMap (optional), single letter for command line call101 * -# DefaultValueMap (optional), the default value (always a string)102 * -# add to one of the command line sets by the following categories103 * -# generic - generic options (i.e. not one of the others)104 * -# config - action/argument only considers internal bevahior, user105 * does not have to see it while still having full functionality106 * -# hidden - this should be hidden from the user107 * -# visible - this should be visible to the user108 * -# inputfile - this should only be parsed from an input file, not109 * from command line110 * -# add to a menu, i.e. make an entry in MenuContainsActionMap.111 * -# add header file SuperDuperAction.hpp to MapOfActions.cpp and instantiate112 * 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 text118 * menu and the graphical user interface.119 *120 */121 22 class MapOfActions : public Singleton<MapOfActions> { 122 23 friend class Singleton<MapOfActions>; … … 126 27 127 28 // getter for the action descriptions and short forms 128 std::string getDescription(st d::string actionname);129 std::string getKeyAndShortForm(st d::string actionname);130 std::string getShortForm(st d::string actionname);131 std::map <std::string, std::string> getShortFormToActionMap();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(); 132 33 133 34 void AddOptionsToParser(); 134 35 135 36 // check presence and getter for action type 136 bool hasValue(st d::string actionname);137 bool isShortFormPresent(st d::string shortform);138 enum OptionTypes getValueType(st d::string actionname);37 bool hasValue(string actionname); 38 bool isShortFormPresent(string shortform); 39 enum OptionTypes getValueType(string actionname); 139 40 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(); 41 set<string> generic; 42 set<string> config; 43 set<string> hidden; 44 set<string> visible; 45 set<string> inputfile; 150 46 151 47 private: … … 155 51 156 52 // lookup list from our configs to the ones of CommandLineParser 157 std::map< std::set<std::string> *, po::options_description *> CmdParserLookup;53 map< set<std::string> *, po::options_description *> CmdParserLookup; 158 54 159 55 // map of the action names and their description 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;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; 164 60 }; 165 61 -
src/Actions/MoleculeAction/ChangeNameAction.cpp
r0c5eeb r0d1ad0 36 36 }; 37 37 38 const char MoleculeChangeNameAction::NAME[] = " change-molname";38 const char MoleculeChangeNameAction::NAME[] = "Change filename of Molecule"; 39 39 40 40 MoleculeChangeNameAction::MoleculeChangeNameAction() : -
src/Makefile.am
r0c5eeb r0d1ad0 102 102 Patterns/Singleton.hpp 103 103 104 # all these files are only used for legacy reasons while the transition is in progress 105 # they are only needed to keep the program usable at any point of the transition and will be 106 # deleted once everything is fully refactored 107 LEGACYSOURCE = Legacy/oldmenu.cpp 108 LEGACYHEADER = Legacy/oldmenu.hpp 109 104 110 DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \ 105 111 Descriptors/AtomIdDescriptor.cpp \ … … 139 145 ${DESCRIPTORSOURCE} \ 140 146 ${HELPERSOURCE} \ 147 ${LEGACYSOURCE} \ 141 148 ${EXCEPTIONSOURCE} \ 142 149 bond.cpp \ … … 186 193 ${DESCRIPTORHEADER} \ 187 194 ${EXCEPTIONHEADER} \ 195 ${LEGACYHEADER} \ 188 196 bond.hpp \ 189 197 bondgraph.hpp \ -
src/UIElements/CommandLineUI/CommandLineWindow.cpp
r0c5eeb r0d1ad0 13 13 #include "CommandLineUI/CommandLineStatusIndicator.hpp" 14 14 15 #include "Actions/Action.hpp"16 #include "Actions/MapOfActions.hpp"17 15 #include "Actions/ActionRegistry.hpp" 18 16 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" 17 #include "Actions/AnalysisAction/PairCorrelationAction.hpp" 18 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 19 #include "Actions/AtomAction/AddAction.hpp" 20 #include "Actions/AtomAction/ChangeElementAction.hpp" 21 #include "Actions/AtomAction/RemoveAction.hpp" 22 #include "Actions/CmdAction/BondLengthTableAction.hpp" 23 #include "Actions/CmdAction/ElementDbAction.hpp" 24 #include "Actions/CmdAction/FastParsingAction.hpp" 25 #include "Actions/CmdAction/HelpAction.hpp" 26 #include "Actions/CmdAction/VerboseAction.hpp" 27 #include "Actions/CmdAction/VersionAction.hpp" 28 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 29 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 30 #include "Actions/FragmentationAction/FragmentationAction.hpp" 31 #include "Actions/MoleculeAction/BondFileAction.hpp" 32 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 33 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp" 34 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp" 35 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp" 36 #include "Actions/MoleculeAction/SaveBondsAction.hpp" 37 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp" 38 #include "Actions/MoleculeAction/TranslateAction.hpp" 39 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp" 40 #include "Actions/ParserAction/LoadXyzAction.hpp" 41 #include "Actions/ParserAction/SaveXyzAction.hpp" 42 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp" 43 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp" 44 #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp" 45 #include "Actions/WorldAction/BoundInBoxAction.hpp" 46 #include "Actions/WorldAction/CenterInBoxAction.hpp" 47 #include "Actions/WorldAction/CenterOnEdgeAction.hpp" 48 #include "Actions/WorldAction/ChangeBoxAction.hpp" 49 #include "Actions/WorldAction/InputAction.hpp" 50 #include "Actions/WorldAction/OutputAction.hpp" 51 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 52 #include "Actions/WorldAction/RepeatBoxAction.hpp" 53 #include "Actions/WorldAction/ScaleBoxAction.hpp" 54 #include "Actions/WorldAction/SetDefaultNameAction.hpp" 55 #include "Actions/WorldAction/SetGaussianBasisAction.hpp" 19 56 #include "CommandLineParser.hpp" 20 57 … … 27 64 { 28 65 // create and register all command line callable actions 29 MapOfActions::getInstance().populateActions(); 66 populateAnalysisActions(); 67 populateAtomActions(); 68 populateCmdActions(); 69 populateFragmentationActions(); 70 populateMoleculeActions(); 71 populateParserActions(); 72 populateTesselationActions(); 73 populateWorldActions(); 30 74 31 75 // Add status indicators etc... … … 53 97 } 54 98 99 void CommandLineWindow::populateAnalysisActions() 100 { 101 new AnalysisMolecularVolumeAction(); 102 new AnalysisPairCorrelationAction(); 103 new AnalysisPrincipalAxisSystemAction(); 104 } 105 106 void CommandLineWindow::populateAtomActions() 107 { 108 new AtomAddAction(); 109 new AtomChangeElementAction(); 110 new AtomRemoveAction(); 111 } 112 113 void CommandLineWindow::populateCmdActions() 114 { 115 new CommandLineBondLengthTableAction(); 116 new CommandLineElementDbAction(); 117 new CommandLineFastParsingAction(); 118 new CommandLineHelpAction(); 119 new CommandLineVerboseAction(); 120 new CommandLineVersionAction(); 121 } 122 123 void CommandLineWindow::populateFragmentationActions() 124 { 125 new FragmentationDepthFirstSearchAction(); 126 new FragmentationFragmentationAction(); 127 new FragmentationSubgraphDissectionAction(); 128 } 129 130 void CommandLineWindow::populateMoleculeActions() 131 { 132 new MoleculeBondFileAction(); 133 new MoleculeChangeNameAction(); 134 new MoleculeFillWithMoleculeAction(); 135 new MoleculeLinearInterpolationofTrajectoriesAction(); 136 new MoleculeSaveAdjacencyAction(); 137 new MoleculeSaveBondsAction(); 138 new MoleculeSaveTemperatureAction(); 139 new MoleculeTranslateAction(); 140 new MoleculeVerletIntegrationAction(); 141 } 142 143 void CommandLineWindow::populateParserActions() 144 { 145 new ParserLoadXyzAction(); 146 new ParserSaveXyzAction(); 147 } 148 149 void CommandLineWindow::populateTesselationActions() 150 { 151 new TesselationConvexEnvelopeAction(); 152 new TesselationNonConvexEnvelopeAction(); 153 } 154 155 void CommandLineWindow::populateWorldActions() 156 { 157 new WorldAddEmptyBoundaryAction(); 158 new WorldBoundInBoxAction(); 159 new WorldCenterInBoxAction(); 160 new WorldCenterOnEdgeAction(); 161 new WorldChangeBoxAction(); 162 new WorldInputAction(); 163 new WorldOutputAction(); 164 new WorldRemoveSphereOfAtomsAction(); 165 new WorldRepeatBoxAction(); 166 new WorldScaleBoxAction(); 167 new WorldSetDefaultNameAction(); 168 new WorldSetGaussianBasisAction(); 169 } -
src/UIElements/TextUI/TextWindow.cpp
r0c5eeb r0d1ad0 12 12 #include <boost/bind.hpp> 13 13 14 15 // TODO: When done with refactoring most of these wont be needed anymore 16 #include "analysis_correlation.hpp" 17 #include "atom.hpp" 18 #include "bond.hpp" 19 #include "bondgraph.hpp" 20 #include "boundary.hpp" 21 #include "config.hpp" 22 #include "element.hpp" 23 #include "ellipsoid.hpp" 24 #include "helpers.hpp" 25 #include "leastsquaremin.hpp" 26 #include "linkedcell.hpp" 27 #include "log.hpp" 28 #include "memoryusageobserver.hpp" 29 #include "molecule.hpp" 30 #include "periodentafel.hpp" 31 #include "World.hpp" 32 33 #include "Legacy/oldmenu.hpp" 34 14 35 #include "Menu/Menu.hpp" 15 36 #include "Menu/TextMenu.hpp" … … 19 40 #include "Menu/SubMenuItem.hpp" 20 41 #include "TextUI/TextStatusIndicator.hpp" 21 #include "Actions/MapOfActions.hpp"22 42 #include "Actions/MethodAction.hpp" 43 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 23 44 #include "Actions/ErrorAction.hpp" 24 45 #include "Actions/ActionRegistry.hpp" … … 26 47 #include "Views/MethodStringView.hpp" 27 48 28 #include "defs.hpp"29 #include "log.hpp"30 #include "verbose.hpp"31 32 // all needed due to config::SaveAll()33 #include "config.hpp"34 #include "periodentafel.hpp"35 36 // config::SaveAll() and enumerate()37 #include "molecule.hpp"38 39 49 #include <iostream> 40 #include <map>41 50 42 51 using namespace std; … … 45 54 TextWindow::TextWindow() 46 55 { 47 char ConfigFileName[MAXSTRINGSIZE];48 map <std::string, TextMenu *> NametoTextMenuMap;49 50 // populate all actions51 MapOfActions::getInstance().populateActions();56 MoleculeListClass *molecules = World::getInstance().getMolecules(); 57 config *configuration = World::getInstance().getConfig(); 58 periodentafel *periode = World::getInstance().getPeriode(); 59 char *ConfigFileName = NULL; 60 old_menu = new oldmenu; 52 61 53 62 // build the main menu 54 63 main_menu = new TextMenu(Log() << Verbose(0), "Main Menu"); 55 64 56 moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate, World::getInstance().getMolecules(),_1));65 moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,molecules,_1)); 57 66 new DisplayMenuItem(main_menu,moleculeView,"Molecule List"); 58 67 … … 67 76 new SeperatorItem(main_menu); 68 77 69 Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen, World::getInstance().getMolecules()));78 Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen,molecules)); 70 79 new ActionMenuItem('a',"set molecule (in)active",main_menu,setMoleculeAction); 71 80 72 TextMenu *AnalysisMenu = new TextMenu(Log() << Verbose(0), "Analysis"); 73 NametoTextMenuMap.insert( pair <std::string, TextMenu *> ("analysis", AnalysisMenu) ); 74 new SubMenuItem('A',"Analysis (pair correlation, volume)",main_menu,AnalysisMenu); 81 TextMenu *editMoleculesMenu = new TextMenu(Log() << Verbose(0), "Edit Molecules"); 82 new SubMenuItem('e',"edit molecules (load, parse, save)",main_menu,editMoleculesMenu); 75 83 76 TextMenu *CommandMenu = new TextMenu(Log() << Verbose(0), "Configuration"); 77 NametoTextMenuMap.insert( pair <std::string, TextMenu *> ("command", CommandMenu) ); 78 new SubMenuItem('c',"configuration",main_menu,CommandMenu); 84 Action *manipulateMoleculeAction = new MethodAction("manipulateMoleculeAction",boost::bind(&oldmenu::ManipulateMolecules,old_menu,periode, molecules, configuration)); 85 new ActionMenuItem('g',"globally manipulate atoms in molecule",main_menu,manipulateMoleculeAction); 79 86 80 TextMenu *AtomMenu = new TextMenu(Log() << Verbose(0), "Atoms"); 81 NametoTextMenuMap.insert( pair <std::string, TextMenu *> ("atom", AtomMenu) ); 82 new SubMenuItem('e',"edit atoms",main_menu,AtomMenu); 87 Action *mergeMoleculeAction = new MethodAction("mergeMoleculeAction",boost::bind(&oldmenu::MergeMolecules,old_menu,periode, molecules)); 88 new ActionMenuItem('M',"Merge molecules",main_menu,mergeMoleculeAction); 83 89 84 TextMenu *FragmentationMenu = new TextMenu(Log() << Verbose(0), "Fragmentation"); 85 NametoTextMenuMap.insert( pair <std::string, TextMenu *> ("fragmentation", FragmentationMenu) ); 86 new SubMenuItem('f',"fragmentation",main_menu,FragmentationMenu); 87 88 TextMenu *ParserMenu = new TextMenu(Log() << Verbose(0), "Parse files"); 89 NametoTextMenuMap.insert( pair <std::string, TextMenu *> ("parser", ParserMenu) ); 90 new SubMenuItem('p',"parse files into system",main_menu,ParserMenu); 91 92 TextMenu *MoleculesMenu = new TextMenu(Log() << Verbose(0), "Edit Molecules"); 93 NametoTextMenuMap.insert( pair <std::string, TextMenu *> ("analysis", AnalysisMenu) ); 94 new SubMenuItem('m',"edit molecules (load, parse, save)",main_menu,MoleculesMenu); 95 96 TextMenu *TesselationMenu = new TextMenu(Log() << Verbose(0), "Tesselate Molecules"); 97 NametoTextMenuMap.insert( pair <std::string, TextMenu *> ("tesselation", TesselationMenu) ); 98 new SubMenuItem('t',"tesselate molecules",main_menu,TesselationMenu); 99 100 TextMenu *WorldMenu = new TextMenu(Log() << Verbose(0), "World"); 101 NametoTextMenuMap.insert( pair <std::string, TextMenu *> ("world", WorldMenu) ); 102 new SubMenuItem('w',"edit world",main_menu,WorldMenu); 90 Action *manipulateAtomsAction = new MethodAction("manipulateAtomsAction",boost::bind(&oldmenu::ManipulateAtoms,old_menu,periode, molecules, configuration)); 91 new ActionMenuItem('m',"manipulate atoms",main_menu,manipulateAtomsAction); 103 92 104 93 new SeperatorItem(main_menu); 105 94 106 Action *saveConfigAction = new MethodAction("saveConfigAction",boost::bind(&config::SaveAll,World::getInstance().getConfig(), ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules())); 95 Action *editConfigAction = new MethodAction("editConfigAction",boost::bind(&config::Edit,configuration)); 96 new ActionMenuItem('c',"edit the current configuration",main_menu,editConfigAction); 97 98 new SeperatorItem(main_menu); 99 100 Action *saveConfigAction = new MethodAction("saveConfigAction",boost::bind(&config::SaveAll,configuration, ConfigFileName, periode, molecules)); 107 101 new ActionMenuItem('s',"save current setup to config file",main_menu,saveConfigAction); 102 103 Action *doTestAction = new MethodAction("doTestAction",boost::bind(&oldmenu::testroutine,old_menu,molecules)); 104 new ActionMenuItem('T',"call the current test routine",main_menu,doTestAction); 108 105 109 106 quitAction = new MethodAction("quitAction",boost::bind(&TextMenu::doQuit,main_menu),false); 110 107 new ActionMenuItem('q',"quit",main_menu,quitAction); 111 108 112 // go through all menus and create them 113 for (map <std::string, TextMenu *>::iterator MenuRunner = NametoTextMenuMap.begin(); MenuRunner != NametoTextMenuMap.end(); ++MenuRunner) { 114 cout << "Creating Menu " << MenuRunner->first << "." << endl; 115 populateMenu(MenuRunner->second, MenuRunner->first); 116 } 109 // call all functions used to build the submenus 110 111 populateEditMoleculesMenu(editMoleculesMenu); 112 113 Action *returnFromEditMoleculeAction = new TextMenu::LeaveAction(editMoleculesMenu); 114 MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",editMoleculesMenu,returnFromEditMoleculeAction); 115 116 editMoleculesMenu->addDefault(returnItem); 117 117 118 118 // Add status indicators etc... … … 123 123 TextWindow::~TextWindow() 124 124 { 125 delete old_menu; 125 126 delete quitAction; 126 127 delete moleculeView; … … 133 134 } 134 135 135 char TextWindow::getSuitableShortForm(set <char> &ShortcutList, const std::string name) const 136 void TextWindow::populateEditMoleculesMenu(Menu* editMoleculesMenu) 136 137 { 137 for (std::string::const_iterator CharRunner = name.begin(); CharRunner != name.end(); ++CharRunner) { 138 if (ShortcutList.find(*CharRunner) == ShortcutList.end()) 139 return *CharRunner; 140 } 141 DoeLog(1) && (eLog() << Verbose(1) << "Could not find a suitable shortform for TextWindow::getSuitableShortForm()." << endl); 142 return ((char)(ShortcutList.size() % 10) + '0'); 138 MoleculeListClass *molecules = World::getInstance().getMolecules(); 139 periodentafel *periode = World::getInstance().getPeriode(); 140 141 // build the EditMoleculesMenu 142 Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode)); 143 new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction); 144 145 Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode)); 146 new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction); 147 148 Action *changeFilenameAction = new MoleculeChangeNameAction(); 149 new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction); 150 151 Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules)); 152 new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction); 153 154 Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules)); 155 new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction); 156 157 Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules)); 158 new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction); 159 143 160 } 144 145 void TextWindow::populateMenu(TextMenu* Menu, const std::string &MenuName)146 {147 Action *ActionItem = NULL;148 set <char> ShortcutList;149 // through all actions for this menu150 pair < multimap <std::string, std::string>::iterator, multimap <std::string, std::string>::iterator > MenuActions = MapOfActions::getInstance().MenuContainsActionMap.equal_range(MenuName);151 for (multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) {152 cout << " Adding " << MenuRunner->second << " to submenu " << MenuName << endl;153 ActionItem = ActionRegistry::getInstance().getActionByName(MenuRunner->second);154 new ActionMenuItem(getSuitableShortForm(ShortcutList, MenuRunner->second),MapOfActions::getInstance().getDescription(MenuRunner->second).c_str(),Menu,ActionItem);155 }156 // finally add default quit item157 Action *returnFromAction = new TextMenu::LeaveAction(Menu);158 MenuItem *returnFromItem = new ActionMenuItem('q',"return to Main menu",Menu,returnFromAction);159 Menu->addDefault(returnFromItem);160 } -
src/UIElements/TextUI/TextWindow.hpp
r0c5eeb r0d1ad0 11 11 #include "MainWindow.hpp" 12 12 13 #include <set>14 15 13 class TextMenu; 16 14 class Action; 15 class oldmenu; 17 16 class StringView; 18 17 class TextStatusIndicator; … … 28 27 private: 29 28 // populaters 30 char getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const; 31 void populateMenu(TextMenu* Menu, const std::string &name); 29 void populateEditMoleculesMenu(Menu* editMoleculesMenu); 32 30 33 31 TextMenu *main_menu; … … 38 36 StringView *moleculeView; 39 37 TextStatusIndicator *statusIndicator; 38 39 // This class still contains a lot of scattered functionality 40 oldmenu *old_menu; 40 41 }; 41 42 -
src/builder.cpp
r0c5eeb r0d1ad0 114 114 // print version check whether arguments are present at all 115 115 cout << ESPACKVersion << endl; 116 if (argc < 2) { 117 cout << "Obtain help with " << argv[0] << " -h." << endl; 118 cleanUp(); 119 Memory::getState(); 120 return(1); 121 } 122 116 123 117 124 setVerbosity(0); … … 138 145 } 139 146 // handle remaining arguments by CommandLineParser 140 if (argc>1) {141 MapOfActions::getInstance().AddOptionsToParser();142 map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap();143 CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap);147 MapOfActions::getInstance().AddOptionsToParser(); 148 map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap(); 149 CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap); 150 if (!CommandLineParser::getInstance().isEmpty()) { 144 151 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl); 145 152 UIFactory::registerFactory(new CommandLineUIFactory::description());
Note:
See TracChangeset
for help on using the changeset viewer.