[8bcf3f] | 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 |
|
---|
| 8 | /*
|
---|
| 9 | * MenuDescription.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: Oct 26, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | #include <map>
|
---|
| 16 | #include <string>
|
---|
| 17 |
|
---|
[e4afb4] | 18 | #include "Actions/ActionRegistry.hpp"
|
---|
[8bcf3f] | 19 | #include "Menu/MenuDescription.hpp"
|
---|
| 20 |
|
---|
| 21 | /** Constructor of class MenuDescription.
|
---|
| 22 | *
|
---|
| 23 | */
|
---|
| 24 | MenuDescription::MenuDescription()
|
---|
| 25 | {
|
---|
| 26 | // put each menu into set
|
---|
| 27 | MenuSet.insert("analysis");
|
---|
| 28 | MenuSet.insert("atom");
|
---|
| 29 | MenuSet.insert("command");
|
---|
| 30 | MenuSet.insert("fragmentation");
|
---|
| 31 | MenuSet.insert("molecule");
|
---|
| 32 | MenuSet.insert("parser");
|
---|
| 33 | MenuSet.insert("selection");
|
---|
| 34 | MenuSet.insert("tesselation");
|
---|
| 35 | MenuSet.insert("world");
|
---|
| 36 |
|
---|
| 37 | // put menu description into each menu category
|
---|
| 38 | MenuDescriptionsMap["analysis"] = "Analysis (pair correlation, volume)";
|
---|
| 39 | MenuDescriptionsMap["atom"] = "Edit atoms";
|
---|
| 40 | MenuDescriptionsMap["command"] = "Configuration";
|
---|
| 41 | MenuDescriptionsMap["fragmentation"] = "Fragmentation";
|
---|
| 42 | MenuDescriptionsMap["molecule"] = "Parse files into system";
|
---|
| 43 | MenuDescriptionsMap["parser"] = "Edit molecules (load, parse, save)";
|
---|
| 44 | MenuDescriptionsMap["selection"] = "Select atoms/molecules";
|
---|
| 45 | MenuDescriptionsMap["tesselation"] = "Tesselate molecules";
|
---|
| 46 | MenuDescriptionsMap["world"] = "Edit world";
|
---|
| 47 |
|
---|
| 48 | // put menu name into each menu category
|
---|
| 49 | MenuNameMap["analysis"] = "Analysis";
|
---|
| 50 | MenuNameMap["atom"] = "Atoms";
|
---|
| 51 | MenuNameMap["command"] = "configuration options";
|
---|
| 52 | MenuNameMap["fragmentation"] = "Fragmentation";
|
---|
| 53 | MenuNameMap["molecule"] = "Molecules";
|
---|
| 54 | MenuNameMap["parser"] = "Input/Output";
|
---|
| 55 | MenuNameMap["selection"] = "Selection";
|
---|
| 56 | MenuNameMap["tesselation"] = "Tesselation";
|
---|
| 57 | MenuNameMap["world"] = "Globals";
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | /** Destructor of class MenuDescription.
|
---|
| 61 | *
|
---|
| 62 | */
|
---|
| 63 | MenuDescription::~MenuDescription()
|
---|
| 64 | {}
|
---|
| 65 |
|
---|
| 66 | /** Getter for MenuDescriptionsMap.
|
---|
| 67 | * \param token name of menu
|
---|
| 68 | * \return description string of the menu or empty
|
---|
| 69 | */
|
---|
| 70 | const std::string MenuDescription::getDescription(std::string token) const
|
---|
| 71 | {
|
---|
| 72 | if (MenuDescriptionsMap.find(token) != MenuDescriptionsMap.end())
|
---|
| 73 | return MenuDescriptionsMap.find(token)->second;
|
---|
| 74 | else
|
---|
| 75 | return std::string();
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | /** Getter for MenuNameMap.
|
---|
| 79 | * \param token name of menu
|
---|
| 80 | * \return description string of the menu or empty
|
---|
| 81 | */
|
---|
| 82 | const std::string MenuDescription::getName(std::string token) const
|
---|
| 83 | {
|
---|
| 84 | if (MenuNameMap.find(token) != MenuNameMap.end())
|
---|
| 85 | return MenuNameMap.find(token)->second;
|
---|
| 86 | else
|
---|
| 87 | return std::string();
|
---|
| 88 | }
|
---|
| 89 |
|
---|
[e4afb4] | 90 | /** Constructs a multimap of all menus running over all actions belonging to it.
|
---|
| 91 | * \return multimap with which actions belongs to which menu.
|
---|
| 92 | */
|
---|
| 93 | std::multimap <std::string, std::string> MenuDescription::getMenuItemsMap() const
|
---|
| 94 | {
|
---|
| 95 | std::multimap <std::string, std::string> result;
|
---|
| 96 |
|
---|
| 97 | ActionRegistry &AR = ActionRegistry::getInstance();
|
---|
| 98 | for (ActionRegistry::const_iterator iter = AR.getBeginIter();iter != AR.getEndIter();++iter) {
|
---|
| 99 | result.insert( std::pair<std::string, std::string> ((iter->second)->Traits.getMenuName(), (iter->second)->getName()));
|
---|
| 100 | }
|
---|
| 101 | // TODO: MenuPosition is not yet realized.
|
---|
| 102 | return result;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[8bcf3f] | 105 | /** Forward iterator from beginning of list of descriptions.
|
---|
| 106 | * \return iterator
|
---|
| 107 | */
|
---|
| 108 | MenuDescription::iterator MenuDescription::getBeginIter()
|
---|
| 109 | {
|
---|
| 110 | return MenuSet.begin();
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | /** Forward iterator at end of list of descriptions.
|
---|
| 114 | * \return iterator
|
---|
| 115 | */
|
---|
| 116 | MenuDescription::iterator MenuDescription::getEndIter()
|
---|
| 117 | {
|
---|
| 118 | return MenuSet.end();
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | /** Constant forward iterator from beginning of list of descriptions.
|
---|
| 122 | * \return constant iterator
|
---|
| 123 | */
|
---|
| 124 | MenuDescription::const_iterator MenuDescription::getBeginIter() const
|
---|
| 125 | {
|
---|
| 126 | return MenuSet.begin();
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | /** Constant forward iterator at end of list of descriptions.
|
---|
| 130 | * \return constant iterator
|
---|
| 131 | */
|
---|
| 132 | MenuDescription::const_iterator MenuDescription::getEndIter() const
|
---|
| 133 | {
|
---|
| 134 | return MenuSet.end();
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 |
|
---|