source: src/UIElements/Menu/MenuDescription.cpp

Candidate_v1.6.1
Last change on this file was 987145, checked in by Frederik Heber <frederik.heber@…>, 8 years ago

Added four GeometryActions to convert atom positions into vectors.

  • added reverse switch to distance and plane to vector Actions.
  • InputToVector has coordinates to differentiate from position option. This eases use with CommandLineParser where option names need to be unique.
  • Property mode set to 100644
File size: 8.0 KB
RevLine 
[8bcf3f]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
[0aa122]4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
[94d5ac6]5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
[8bcf3f]21 */
22
23/*
24 * MenuDescription.cpp
25 *
26 * Created on: Oct 26, 2010
27 * Author: heber
28 */
29
[d2b28f]30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
[9eb71b3]35//#include "CodePatterns/MemDebug.hpp"
[d2b28f]36
[ffb9ad]37#include <iostream>
[8bcf3f]38#include <map>
39#include <string>
40
[628577]41//#include "Actions/ActionQueue.hpp"
[8bcf3f]42#include "Menu/MenuDescription.hpp"
43
[ad011c]44#include "CodePatterns/Singleton_impl.hpp"
[c82d0c]45
46MenuDescription::TextMap *MenuDescription::MenuDescriptionsMap = NULL;
47MenuDescription::IterableMap *MenuDescription::MenuPositionMap = NULL;
48MenuDescription::TextMap *MenuDescription::MenuNameMap = NULL;
49
50
[8bcf3f]51/** Constructor of class MenuDescription.
52 *
53 */
54MenuDescription::MenuDescription()
55{
[c82d0c]56 // allocate maps
57 MenuDescriptionsMap = new TextMap();
58 MenuPositionMap = new IterableMap();
59 MenuNameMap = new TextMap();
60
[ffb9ad]61 // put each menu into its place, "" means top level
[c82d0c]62 MenuPositionMap->insert(std::make_pair("analysis",TopPosition("tools",1)));
[987145]63 MenuPositionMap->insert(std::make_pair("atom",TopPosition("edit",2)));
64 MenuPositionMap->insert(std::make_pair("bond",TopPosition("edit",3)));
[c82d0c]65 MenuPositionMap->insert(std::make_pair("command",TopPosition("",3)));
66 MenuPositionMap->insert(std::make_pair("edit",TopPosition("",2)));
[a88452]67 MenuPositionMap->insert(std::make_pair("fill",TopPosition("tools",5)));
[c82d0c]68 MenuPositionMap->insert(std::make_pair("fragmentation",TopPosition("tools",3)));
[987145]69 MenuPositionMap->insert(std::make_pair("geometry",TopPosition("edit",5)));
[d09093]70 MenuPositionMap->insert(std::make_pair("graph",TopPosition("tools",4)));
[987145]71 MenuPositionMap->insert(std::make_pair("molecule",TopPosition("edit",4)));
[f5724f]72 MenuPositionMap->insert(std::make_pair("potential",TopPosition("tools",7)));
[987145]73 MenuPositionMap->insert(std::make_pair("parser",TopPosition("edit",6)));
74 MenuPositionMap->insert(std::make_pair("selection",TopPosition("edit",1)));
[c82d0c]75 MenuPositionMap->insert(std::make_pair("tesselation",TopPosition("tools",2)));
[4dc309]76 MenuPositionMap->insert(std::make_pair("shape",TopPosition("tools",6)));
[c82d0c]77 MenuPositionMap->insert(std::make_pair("tools",TopPosition("",4)));
78 MenuPositionMap->insert(std::make_pair("world",TopPosition("",1)));
[8bcf3f]79
80 // put menu description into each menu category
[c82d0c]81 MenuDescriptionsMap->insert(std::make_pair("analysis","Analysis (pair correlation, volume)"));
82 MenuDescriptionsMap->insert(std::make_pair("atom","Edit atoms"));
[f63e41]83 MenuDescriptionsMap->insert(std::make_pair("bond","Edit bonds"));
[c82d0c]84 MenuDescriptionsMap->insert(std::make_pair("command","Configuration"));
85 MenuDescriptionsMap->insert(std::make_pair("edit","Edit"));
[a88452]86 MenuDescriptionsMap->insert(std::make_pair("fill","Fill"));
[c82d0c]87 MenuDescriptionsMap->insert(std::make_pair("fragmentation","Fragmentation"));
[987145]88 MenuDescriptionsMap->insert(std::make_pair("geometry","Geometry"));
[d09093]89 MenuDescriptionsMap->insert(std::make_pair("graph","Graph"));
[c82d0c]90 MenuDescriptionsMap->insert(std::make_pair("molecule","Parse files into system"));
91 MenuDescriptionsMap->insert(std::make_pair("parser","Edit molecules (load, parse, save)"));
[f5724f]92 MenuDescriptionsMap->insert(std::make_pair("potential","Fit potentials and parse, save homologies"));
[c82d0c]93 MenuDescriptionsMap->insert(std::make_pair("selection","Select atoms/molecules"));
94 MenuDescriptionsMap->insert(std::make_pair("tesselation","Tesselate molecules"));
[4dc309]95 MenuDescriptionsMap->insert(std::make_pair("shape","Edit shapes"));
[c82d0c]96 MenuDescriptionsMap->insert(std::make_pair("tools","Various tools"));
97 MenuDescriptionsMap->insert(std::make_pair("world","Edit world"));
[8bcf3f]98
99 // put menu name into each menu category
[c82d0c]100 MenuNameMap->insert(std::make_pair("analysis","Analysis"));
101 MenuNameMap->insert(std::make_pair("atom","Atoms"));
[f63e41]102 MenuNameMap->insert(std::make_pair("bond","Bonds"));
[c82d0c]103 MenuNameMap->insert(std::make_pair("command","Configuration"));
104 MenuNameMap->insert(std::make_pair("edit","Edit"));
[a88452]105 MenuNameMap->insert(std::make_pair("fill","Fill"));
[c82d0c]106 MenuNameMap->insert(std::make_pair("fragmentation","Fragmentation"));
[987145]107 MenuNameMap->insert(std::make_pair("geometry","Geometry"));
[d09093]108 MenuNameMap->insert(std::make_pair("graph","Graph"));
[c82d0c]109 MenuNameMap->insert(std::make_pair("molecule","Molecules"));
110 MenuNameMap->insert(std::make_pair("parser","Input/Output"));
[f5724f]111 MenuNameMap->insert(std::make_pair("potential","PotentialFitting"));
[c82d0c]112 MenuNameMap->insert(std::make_pair("selection","Selection"));
113 MenuNameMap->insert(std::make_pair("tesselation","Tesselation"));
[4dc309]114 MenuNameMap->insert(std::make_pair("shape","Shape"));
[c82d0c]115 MenuNameMap->insert(std::make_pair("tools","Tools"));
116 MenuNameMap->insert(std::make_pair("world","Globals"));
[8bcf3f]117}
118
119/** Destructor of class MenuDescription.
120 *
121 */
122MenuDescription::~MenuDescription()
[c82d0c]123{
[ad7270]124 //std::cout << "MenuDescription: clearing maps ... " << std::endl;
[c82d0c]125 for (IterableMap::iterator iter = MenuPositionMap->begin(); !MenuPositionMap->empty(); iter = MenuPositionMap->begin())
126 MenuPositionMap->erase(iter);
127 delete MenuNameMap;
128 delete MenuDescriptionsMap;
129 delete MenuPositionMap;
130}
[8bcf3f]131
132/** Getter for MenuDescriptionsMap.
133 * \param token name of menu
134 * \return description string of the menu or empty
135 */
[b59da6]136const std::string MenuDescription::getDescription(const std::string &token) const
[8bcf3f]137{
[c82d0c]138 if (MenuDescriptionsMap->find(token) != MenuDescriptionsMap->end())
139 return MenuDescriptionsMap->find(token)->second;
[8bcf3f]140 else
141 return std::string();
142}
143
[c82d0c]144/** Getter for MenuNameMap->
[8bcf3f]145 * \param token name of menu
146 * \return description string of the menu or empty
147 */
[b59da6]148const std::string MenuDescription::getName(const std::string &token) const
[8bcf3f]149{
[c82d0c]150 if (MenuNameMap->find(token) != MenuNameMap->end())
151 return MenuNameMap->find(token)->second;
[8bcf3f]152 else
153 return std::string();
154}
155
[c82d0c]156///** Constructs a multimap of all menus running over all actions belonging to it.
157// * \return multimap with which actions belongs to which menu.
158// */
159//std::multimap <std::string, std::string> MenuDescription::getMenuItemsMap() const
160//{
161// std::multimap <std::string, std::string> result;
162//
[690741]163// ActionQueue &AQ = ActionQueue::getInstance();
164// ActionQueue::ActionTokens_t tokens = AQ.getListOfActions();
165// for (ActionQueue::ActionTokens_t::const_iterator iter = tokens.begin();
166// iter != tokens.end(); ++iter) {
167// const ActionTrait &CurrentTrait = AQ.getActionsTrait(*iter);
168// std::cout << "Inserting " << *iter << " into menu " << CurrentTrait.getMenuName() << std::endl;
169// result.insert( std::pair<std::string, std::string> (CurrentTrait.getMenuName(), *iter));
[c82d0c]170// }
171// // TODO: MenuPosition is not yet realized.
172// return result;
173//}
[e4afb4]174
[8bcf3f]175/** Forward iterator from beginning of list of descriptions.
176 * \return iterator
177 */
178MenuDescription::iterator MenuDescription::getBeginIter()
179{
[c82d0c]180 return MenuPositionMap->begin();
[8bcf3f]181}
182
183/** Forward iterator at end of list of descriptions.
184 * \return iterator
185 */
186MenuDescription::iterator MenuDescription::getEndIter()
187{
[c82d0c]188 return MenuPositionMap->end();
[8bcf3f]189}
190
191/** Constant forward iterator from beginning of list of descriptions.
192 * \return constant iterator
193 */
194MenuDescription::const_iterator MenuDescription::getBeginIter() const
195{
[c82d0c]196 return MenuPositionMap->begin();
[8bcf3f]197}
198
199/** Constant forward iterator at end of list of descriptions.
200 * \return constant iterator
201 */
202MenuDescription::const_iterator MenuDescription::getEndIter() const
203{
[c82d0c]204 return MenuPositionMap->end();
[8bcf3f]205}
206
[c82d0c]207CONSTRUCT_SINGLETON(MenuDescription)
Note: See TracBrowser for help on using the repository browser.