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
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
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/>.
21 */
22
23/*
24 * MenuDescription.cpp
25 *
26 * Created on: Oct 26, 2010
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35//#include "CodePatterns/MemDebug.hpp"
36
37#include <iostream>
38#include <map>
39#include <string>
40
41//#include "Actions/ActionQueue.hpp"
42#include "Menu/MenuDescription.hpp"
43
44#include "CodePatterns/Singleton_impl.hpp"
45
46MenuDescription::TextMap *MenuDescription::MenuDescriptionsMap = NULL;
47MenuDescription::IterableMap *MenuDescription::MenuPositionMap = NULL;
48MenuDescription::TextMap *MenuDescription::MenuNameMap = NULL;
49
50
51/** Constructor of class MenuDescription.
52 *
53 */
54MenuDescription::MenuDescription()
55{
56 // allocate maps
57 MenuDescriptionsMap = new TextMap();
58 MenuPositionMap = new IterableMap();
59 MenuNameMap = new TextMap();
60
61 // put each menu into its place, "" means top level
62 MenuPositionMap->insert(std::make_pair("analysis",TopPosition("tools",1)));
63 MenuPositionMap->insert(std::make_pair("atom",TopPosition("edit",2)));
64 MenuPositionMap->insert(std::make_pair("bond",TopPosition("edit",3)));
65 MenuPositionMap->insert(std::make_pair("command",TopPosition("",3)));
66 MenuPositionMap->insert(std::make_pair("edit",TopPosition("",2)));
67 MenuPositionMap->insert(std::make_pair("fill",TopPosition("tools",5)));
68 MenuPositionMap->insert(std::make_pair("fragmentation",TopPosition("tools",3)));
69 MenuPositionMap->insert(std::make_pair("geometry",TopPosition("edit",5)));
70 MenuPositionMap->insert(std::make_pair("graph",TopPosition("tools",4)));
71 MenuPositionMap->insert(std::make_pair("molecule",TopPosition("edit",4)));
72 MenuPositionMap->insert(std::make_pair("potential",TopPosition("tools",7)));
73 MenuPositionMap->insert(std::make_pair("parser",TopPosition("edit",6)));
74 MenuPositionMap->insert(std::make_pair("selection",TopPosition("edit",1)));
75 MenuPositionMap->insert(std::make_pair("tesselation",TopPosition("tools",2)));
76 MenuPositionMap->insert(std::make_pair("shape",TopPosition("tools",6)));
77 MenuPositionMap->insert(std::make_pair("tools",TopPosition("",4)));
78 MenuPositionMap->insert(std::make_pair("world",TopPosition("",1)));
79
80 // put menu description into each menu category
81 MenuDescriptionsMap->insert(std::make_pair("analysis","Analysis (pair correlation, volume)"));
82 MenuDescriptionsMap->insert(std::make_pair("atom","Edit atoms"));
83 MenuDescriptionsMap->insert(std::make_pair("bond","Edit bonds"));
84 MenuDescriptionsMap->insert(std::make_pair("command","Configuration"));
85 MenuDescriptionsMap->insert(std::make_pair("edit","Edit"));
86 MenuDescriptionsMap->insert(std::make_pair("fill","Fill"));
87 MenuDescriptionsMap->insert(std::make_pair("fragmentation","Fragmentation"));
88 MenuDescriptionsMap->insert(std::make_pair("geometry","Geometry"));
89 MenuDescriptionsMap->insert(std::make_pair("graph","Graph"));
90 MenuDescriptionsMap->insert(std::make_pair("molecule","Parse files into system"));
91 MenuDescriptionsMap->insert(std::make_pair("parser","Edit molecules (load, parse, save)"));
92 MenuDescriptionsMap->insert(std::make_pair("potential","Fit potentials and parse, save homologies"));
93 MenuDescriptionsMap->insert(std::make_pair("selection","Select atoms/molecules"));
94 MenuDescriptionsMap->insert(std::make_pair("tesselation","Tesselate molecules"));
95 MenuDescriptionsMap->insert(std::make_pair("shape","Edit shapes"));
96 MenuDescriptionsMap->insert(std::make_pair("tools","Various tools"));
97 MenuDescriptionsMap->insert(std::make_pair("world","Edit world"));
98
99 // put menu name into each menu category
100 MenuNameMap->insert(std::make_pair("analysis","Analysis"));
101 MenuNameMap->insert(std::make_pair("atom","Atoms"));
102 MenuNameMap->insert(std::make_pair("bond","Bonds"));
103 MenuNameMap->insert(std::make_pair("command","Configuration"));
104 MenuNameMap->insert(std::make_pair("edit","Edit"));
105 MenuNameMap->insert(std::make_pair("fill","Fill"));
106 MenuNameMap->insert(std::make_pair("fragmentation","Fragmentation"));
107 MenuNameMap->insert(std::make_pair("geometry","Geometry"));
108 MenuNameMap->insert(std::make_pair("graph","Graph"));
109 MenuNameMap->insert(std::make_pair("molecule","Molecules"));
110 MenuNameMap->insert(std::make_pair("parser","Input/Output"));
111 MenuNameMap->insert(std::make_pair("potential","PotentialFitting"));
112 MenuNameMap->insert(std::make_pair("selection","Selection"));
113 MenuNameMap->insert(std::make_pair("tesselation","Tesselation"));
114 MenuNameMap->insert(std::make_pair("shape","Shape"));
115 MenuNameMap->insert(std::make_pair("tools","Tools"));
116 MenuNameMap->insert(std::make_pair("world","Globals"));
117}
118
119/** Destructor of class MenuDescription.
120 *
121 */
122MenuDescription::~MenuDescription()
123{
124 //std::cout << "MenuDescription: clearing maps ... " << std::endl;
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}
131
132/** Getter for MenuDescriptionsMap.
133 * \param token name of menu
134 * \return description string of the menu or empty
135 */
136const std::string MenuDescription::getDescription(const std::string &token) const
137{
138 if (MenuDescriptionsMap->find(token) != MenuDescriptionsMap->end())
139 return MenuDescriptionsMap->find(token)->second;
140 else
141 return std::string();
142}
143
144/** Getter for MenuNameMap->
145 * \param token name of menu
146 * \return description string of the menu or empty
147 */
148const std::string MenuDescription::getName(const std::string &token) const
149{
150 if (MenuNameMap->find(token) != MenuNameMap->end())
151 return MenuNameMap->find(token)->second;
152 else
153 return std::string();
154}
155
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//
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));
170// }
171// // TODO: MenuPosition is not yet realized.
172// return result;
173//}
174
175/** Forward iterator from beginning of list of descriptions.
176 * \return iterator
177 */
178MenuDescription::iterator MenuDescription::getBeginIter()
179{
180 return MenuPositionMap->begin();
181}
182
183/** Forward iterator at end of list of descriptions.
184 * \return iterator
185 */
186MenuDescription::iterator MenuDescription::getEndIter()
187{
188 return MenuPositionMap->end();
189}
190
191/** Constant forward iterator from beginning of list of descriptions.
192 * \return constant iterator
193 */
194MenuDescription::const_iterator MenuDescription::getBeginIter() const
195{
196 return MenuPositionMap->begin();
197}
198
199/** Constant forward iterator at end of list of descriptions.
200 * \return constant iterator
201 */
202MenuDescription::const_iterator MenuDescription::getEndIter() const
203{
204 return MenuPositionMap->end();
205}
206
207CONSTRUCT_SINGLETON(MenuDescription)
Note: See TracBrowser for help on using the repository browser.