Changeset e4afb4 for src/UIElements
- Timestamp:
- Oct 30, 2010, 8:42:44 PM (15 years ago)
- 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, Candidate_v1.7.0, Candidate_v1.7.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:
- 76cec6, c38826
- Parents:
- 23359f
- git-author:
- Frederik Heber <heber@…> (10/30/10 19:55:54)
- git-committer:
- Frederik Heber <heber@…> (10/30/10 20:42:44)
- Location:
- src/UIElements
- Files:
-
- 3 added
- 34 edited
- 1 moved
-
CommandLineUI/CommandLineParser.cpp (added)
-
CommandLineUI/CommandLineParser.hpp (moved) (moved from src/CommandLineParser.hpp ) (5 diffs)
-
CommandLineUI/CommandLineWindow.cpp (modified) (1 diff)
-
CommandLineUI/Query/AtomCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/AtomsCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/BooleanCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/BoxCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/DoubleCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/DoublesCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/ElementCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/ElementsCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/EmptyCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/FileCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/IntCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/IntsCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/MoleculeCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/MoleculesCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/StringCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/StringsCommandLineQuery.cpp (modified) (2 diffs)
-
CommandLineUI/Query/VectorCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/Query/VectorsCommandLineQuery.cpp (modified) (1 diff)
-
CommandLineUI/TypeEnumContainer.cpp (added)
-
CommandLineUI/TypeEnumContainer.hpp (added)
-
Dialog.cpp (modified) (1 diff)
-
Dialog.hpp (modified) (5 diffs)
-
Makefile.am (modified) (1 diff)
-
Menu/MenuDescription.cpp (modified) (2 diffs)
-
Menu/MenuDescription.hpp (modified) (2 diffs)
-
Menu/TextMenu.cpp (modified) (1 diff)
-
Menu/TextMenu.hpp (modified) (3 diffs)
-
Qt4/Pipe/AtomQtQueryPipe.cpp (modified) (1 diff)
-
Qt4/Pipe/AtomsQtQueryPipe.cpp (modified) (2 diffs)
-
Qt4/Pipe/MoleculeQtQueryPipe.cpp (modified) (1 diff)
-
Qt4/Pipe/MoleculesQtQueryPipe.cpp (modified) (1 diff)
-
Qt4/QtDialog.hpp (modified) (8 diffs)
-
Qt4/QtMainWindow.cpp (modified) (3 diffs)
-
TextUI/TextWindow.cpp (modified) (6 diffs)
-
TextUI/TextWindow.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/CommandLineUI/CommandLineParser.hpp
r23359f re4afb4 14 14 15 15 #include "Patterns/Singleton.hpp" 16 #include "UIElements/CommandLineUI/TypeEnumContainer.hpp" 16 17 17 #include <list> 18 #include <map> 19 20 class Action; 21 class OptionTrait; 18 22 19 23 /** This class is a wrapper for boost::program_options. … … 92 96 93 97 // Parses the command line arguments in CommandLineParser::**argv with currently known options. 94 void Run(int _argc, char **_argv, std::map <std::string, std::string> &ShortFormToActionMap); 98 void Run(int _argc, char **_argv); 99 100 // Initialises all options from ActionRegistry. 101 void InitializeCommandArguments(); 95 102 96 103 // Checks whether there have been any commands on the command line. … … 102 109 * -# hidden options: options which the user is not shown on "help" 103 110 */ 104 po::options_description generic; 105 po::options_description config; 106 po::options_description hidden; 107 po::positional_options_description inputfile; 111 po::options_description analysis; 112 po::options_description atom; 113 po::options_description command; 114 po::options_description edit; 115 po::options_description fragmentation; 116 po::options_description molecule; 117 po::options_description parser; 118 po::options_description selection; 119 po::options_description tesselation; 120 po::options_description world; 121 po::options_description options; 108 122 109 123 po::options_description visible; … … 125 139 po::options_description config_file_options; 126 140 141 // adds options to the parser 142 void AddOptionToParser(const OptionTrait * const currentOption, po::options_description* OptionList); 143 144 // creates a map from short forms to action tokens needed to parse command line 145 std::map <std::string, std::string> getShortFormToActionMap(); 146 147 // lookup list from "configmenus" to the ones of CommandLineParser 148 std::map< std::string , po::options_description *> CmdParserLookup; 149 127 150 // Sets the options from the three cases. 128 151 void setOptions(int _argc, char **_argv); … … 133 156 // as boost's program_options does not care about of order of appearance but we do for actions, 134 157 // we have to have a list and a function to obtain it. 135 void scanforSequenceOfArguments(std::map <std::string, std::string> &ShortFormToActionMap); 158 void scanforSequenceOfArguments(); 159 160 TypeEnumContainer TypeToEnums; 136 161 137 162 // argument counter and array passed on from main() -
src/UIElements/CommandLineUI/CommandLineWindow.cpp
r23359f re4afb4 28 28 #include "Actions/ActionRegistry.hpp" 29 29 30 #include " CommandLineParser.hpp"30 #include "UIElements/CommandLineUI/CommandLineParser.hpp" 31 31 32 32 #include <iostream> -
src/UIElements/CommandLineUI/Query/AtomCommandLineQuery.cpp
r23359f re4afb4 26 26 #include "CommandLineUI/CommandLineDialog.hpp" 27 27 28 #include "CommandLine Parser.hpp"28 #include "CommandLineUI/CommandLineParser.hpp" 29 29 #include "Helpers/Log.hpp" 30 30 #include "Helpers/Verbose.hpp" -
src/UIElements/CommandLineUI/Query/AtomsCommandLineQuery.cpp
r23359f re4afb4 24 24 #include "CommandLineUI/CommandLineDialog.hpp" 25 25 26 #include "CommandLineUI/CommandLineParser.hpp" 26 27 #include "Helpers/Log.hpp" 27 28 #include "Helpers/Verbose.hpp" 28 #include "CommandLineParser.hpp"29 29 #include "World.hpp" 30 30 -
src/UIElements/CommandLineUI/Query/BooleanCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 28 28 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/BoxCommandLineQuery.cpp
r23359f re4afb4 23 23 24 24 #include "Actions/Values.hpp" 25 #include "CommandLineUI/CommandLineParser.hpp" 25 26 #include "Helpers/Log.hpp" 26 27 #include "Helpers/Verbose.hpp" 27 28 #include "LinearAlgebra/Matrix.hpp" 28 #include "CommandLineParser.hpp"29 29 30 30 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/DoubleCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 28 28 -
src/UIElements/CommandLineUI/Query/DoublesCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 28 28 CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/ElementCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 #include "element.hpp" 28 28 #include "periodentafel.hpp" -
src/UIElements/CommandLineUI/Query/ElementsCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 #include "element.hpp" 28 28 #include "periodentafel.hpp" -
src/UIElements/CommandLineUI/Query/EmptyCommandLineQuery.cpp
r23359f re4afb4 24 24 #include "CommandLineUI/CommandLineDialog.hpp" 25 25 26 #include "CommandLineUI/CommandLineParser.hpp" 26 27 #include "Helpers/Log.hpp" 27 28 #include "Helpers/Verbose.hpp" 28 #include "CommandLineParser.hpp"29 29 30 30 CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/FileCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 28 28 CommandLineDialog::FileCommandLineQuery::FileCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/IntCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 28 28 CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/IntsCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 28 28 CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/MoleculeCommandLineQuery.cpp
r23359f re4afb4 24 24 #include "CommandLineUI/CommandLineDialog.hpp" 25 25 26 #include "CommandLineUI/CommandLineParser.hpp" 26 27 #include "Helpers/Log.hpp" 27 28 #include "Helpers/Verbose.hpp" 28 #include "CommandLineParser.hpp"29 29 30 30 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/MoleculesCommandLineQuery.cpp
r23359f re4afb4 24 24 #include "CommandLineUI/CommandLineDialog.hpp" 25 25 26 #include "CommandLineUI/CommandLineParser.hpp" 26 27 #include "Helpers/Log.hpp" 27 28 #include "Helpers/Verbose.hpp" 28 #include "CommandLineParser.hpp"29 29 #include "World.hpp" 30 30 -
src/UIElements/CommandLineUI/Query/StringCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 28 28 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) : -
src/UIElements/CommandLineUI/Query/StringsCommandLineQuery.cpp
r23359f re4afb4 22 22 #include "CommandLineUI/CommandLineDialog.hpp" 23 23 24 #include "CommandLineUI/CommandLineParser.hpp" 24 25 #include "Helpers/Log.hpp" 25 26 #include "Helpers/Verbose.hpp" 26 #include "CommandLineParser.hpp"27 27 28 28 CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) : … … 34 34 bool CommandLineDialog::StringsCommandLineQuery::handle() { 35 35 if (CommandLineParser::getInstance().vm.count(getTitle())) { 36 tmp = CommandLineParser::getInstance().vm[getTitle()].as< vector<string> >();36 tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<std::string> >(); 37 37 return true; 38 38 } else { -
src/UIElements/CommandLineUI/Query/VectorCommandLineQuery.cpp
r23359f re4afb4 23 23 24 24 #include "Actions/Values.hpp" 25 #include "CommandLineUI/CommandLineParser.hpp" 25 26 #include "Helpers/Log.hpp" 26 27 #include "Helpers/Verbose.hpp" 27 #include "CommandLineParser.hpp"28 28 #include "LinearAlgebra/Vector.hpp" 29 29 #include "Box.hpp" -
src/UIElements/CommandLineUI/Query/VectorsCommandLineQuery.cpp
r23359f re4afb4 25 25 26 26 #include "Actions/Values.hpp" 27 #include "CommandLineUI/CommandLineParser.hpp" 27 28 #include "Helpers/Log.hpp" 28 29 #include "Helpers/Verbose.hpp" 29 #include "CommandLineParser.hpp"30 30 #include "World.hpp" 31 31 -
src/UIElements/Dialog.cpp
r23359f re4afb4 126 126 } 127 127 128 template <> void Dialog::query< atom *>(const char *token, std::string description)128 template <> void Dialog::query<const atom *>(const char *token, std::string description) 129 129 { 130 130 queryAtom(token, description); 131 131 } 132 132 133 template <> void Dialog::query< std::vector< atom *> >(const char *token, std::string description)133 template <> void Dialog::query< std::vector<const atom *> >(const char *token, std::string description) 134 134 { 135 135 queryAtoms(token, description); 136 136 } 137 137 138 template <> void Dialog::query< molecule *>(const char *token, std::string description)138 template <> void Dialog::query<const molecule *>(const char *token, std::string description) 139 139 { 140 140 queryMolecule(token, description); 141 141 } 142 142 143 template <> void Dialog::query< std::vector< molecule *> >(const char *token, std::string description)143 template <> void Dialog::query< std::vector<const molecule *> >(const char *token, std::string description) 144 144 { 145 145 queryMolecules(token, description); -
src/UIElements/Dialog.hpp
r23359f re4afb4 33 33 * string, but also advanced types such as element, molecule or Vector. There 34 34 * is also an empty query for displaying text. 35 * 36 * Note that the templatization of Dialog::query() allows for easy implementation 37 * of new types that correspond to/are derived from old ones. 38 * 39 * <H3>How do Dialogs operate?</H3> 40 * 41 * Dialogs are initiated by Action::FillDialog() function calls. Within Action::Call() 42 * a dialog is created and passed on to FillDialog(), which is specialized in each 43 * specific Action to ask for the specific parameter it needs. 44 * 45 * Dialogs are derived for each of the UI types 46 * -# CommandLineDialog 47 * -# QtDialog 48 * -# TextDialog 49 * 50 * This "asking" for parameters is done via the Query class. There are four types 51 * of Query types: 52 * -# Query, members in class Dialog 53 * -# CommandLineQuery, members in class CommandLineDialog 54 * -# QtQuery, members in class QtDialog 55 * -# TextQuery, members in class TextDialog 56 * Each embodies a certain way of asking the user for the specific type of parameter 57 * needed, e.g. a file via the TextMenu interface would be done in member functions of 58 * TextDialog::FileTextQuery. 59 * 60 * 61 * Generally, the sequence of events is as follows: 62 * -# Action::fillDialog() calls upon Dialog::query<T> for some type T, let's say T 63 * stands for double 64 * -# Dialog::query<double> call a function queryDouble() 65 * -# depending on the currently used UIFactory, the Dialog above is actually either 66 * of the three specialized types, let's say CommandLine. And we see that within 67 * CommandLineDialog we have the respective method ueryDouble() that registers 68 * a new instance of the class CommandLineDialog::DoubleCommandLineQuery. 69 * -# The Query's are first registered, as multiple parameters may be needed for 70 * a single Action and we don't want the popping up of a dialog window for each 71 * alone. Rather, we want to merge the Query's into a single Dialog. Therefore, 72 * they are first registered and then executed in sequence. This is done in 73 * Dialog::display(), i.e. when the dialog is finally shown to the user. 74 * -# Then each of the registered Query's, here our CommandLineDialog:: 75 * DoubleCommandLineQuery, constructor is called. 76 * -# This will call the constructor of its base class, where the actual value 77 * is stored and later stored into the ValueStorage class by 78 * Dialog::Query::setResult(). 79 * -# Also, e.g. for the Qt interface, the buttons, labels and so forth are 80 * created and added to the dialog. 81 * -# Now the users enters information for each UI something different happens: 82 * -# CommandLine: The actual value retrieval is done by the CommandLineParser and 83 * the boost::program_options library, the value is stored therein for the moment. 84 * (see here: http://www.boost.org/doc/libs/1_44_0/doc/html/program_options/) 85 * -# TextMenu: The value is requested via std::cin from the user. 86 * -# QtMenu: The users enters the value in a Dialog. Due to Qt necessities a 87 * Pipe class obtains the value from the Dialog with Qt's signal/slot mechanism 88 * and put it into Dialog::...Query value. 89 * -# in our case DoubleCommandLineQuery::handle() will be called. The value is 90 * retrieved and put into Dialog::DoubleQuery::tmp 91 * -# Finally, for each Query, also Dialog::DoubleQuery, setResult() is called which 92 * puts the value as a string into the ValueStorage under a given token that is 93 * associated with a type (and thereby we assure type-safety). 94 * 95 * <H3>Regarding derived types of types with already present queries</H3> 96 * 97 * Example: We have got a derived Vector class, called BoxVector, that is by any means 98 * a Vector but with one difference: it is always bound to lie within the current domain. 99 * With regards to type-casting it to and from a string however, nothing is different 100 * between Vector and BoxVector. 101 * 102 * So, do we need a new Query for this? 103 * No. 104 * 105 * We just have to do this: 106 * -# add a specialization of Dialog::query<BoxVector> where queryVector()is used. 107 * @code 108 * template <> void Dialog::query<BoxVector>(const char *token, std::string description) { 109 * queryVector(token, false, description); 110 * } 111 * @endcode 112 * -# make sure that 113 * -# ValueStorage::setCurrentValue() the specialization for class Vector has an 114 * if case also for BoxVector and does something appropriate. 115 * -# ValueStorage::queryCurrentValue() has another specialization doing the same 116 * as for Vector but for BoxVector in its signature. 117 * 118 * And that's all. 119 * 120 * 121 * <H3>Adding new queries</H3> 122 * 123 * Check first whether you really need a new query or whether we can derive it and re-use 124 * one of the present ones. 125 * 126 * Due to the three present UI interfaces we have to add a specific Query for each, here 127 * is a list: 128 * -# add ValueStorage::setCurrentValue() and ValueStorage::queryCurrentValue() for 129 * both types 130 * -# add Dialog::query...() 131 * -# add Dialog::query<>() specialization calling the above function 132 * -# add CommandLineDialog::query...(), TextDialog::query...(), and QtDialog::query...(), 133 * i.e. for each of the three interface 134 * -# add Dialog::...Query class with tmp value of desired type 135 * -# add CommandLineDialog::...Query, TextDialog::...Query, QtDialog::...Query 136 * -# you probably also need a QtDialog::...QueryPipe() to handle the signal/slot stuff, 137 * Qt's moc does not like nested classes. Hence, this has to go extra. 138 * 35 139 */ 36 140 class Dialog … … 210 314 virtual void setResult(); 211 315 protected: 212 molecule *tmp;316 const molecule *tmp; 213 317 }; 214 318 … … 220 324 virtual void setResult(); 221 325 protected: 222 molecule * temp;223 std::vector< molecule *> tmp;326 const molecule * temp; 327 std::vector<const molecule *> tmp; 224 328 }; 225 329 … … 231 335 virtual void setResult(); 232 336 protected: 233 atom *tmp;337 const atom *tmp; 234 338 }; 235 339 … … 241 345 virtual void setResult(); 242 346 protected: 243 atom *temp;244 std::vector< atom *> tmp;347 const atom *temp; 348 std::vector<const atom *> tmp; 245 349 }; 246 350 -
src/UIElements/Makefile.am
r23359f re4afb4 123 123 CommandLineUI/Query/VectorsCommandLineQuery.cpp \ 124 124 CommandLineUI/CommandLineDialog.cpp \ 125 CommandLineUI/CommandLineParser.cpp \ 125 126 CommandLineUI/CommandLineStatusIndicator.cpp \ 126 127 CommandLineUI/CommandLineUIFactory.cpp \ 127 CommandLineUI/CommandLineWindow.cpp 128 CommandLineUI/CommandLineWindow.cpp \ 129 CommandLineUI/TypeEnumContainer.cpp 130 128 131 COMMANDLINEUIHEADER = \ 129 132 CommandLineUI/CommandLineDialog.hpp \ 133 CommandLineUI/CommandLineParser.hpp \ 130 134 CommandLineUI/CommandLineStatusIndicator.hpp \ 131 135 CommandLineUI/CommandLineUIFactory.hpp \ 132 CommandLineUI/CommandLineWindow.hpp 136 CommandLineUI/CommandLineWindow.hpp \ 137 CommandLineUI/TypeEnumContainer.cpp 133 138 134 139 lib_LTLIBRARIES = libMolecuilderUI-@MOLECUILDER_API_VERSION@.la -
src/UIElements/Menu/MenuDescription.cpp
r23359f re4afb4 16 16 #include <string> 17 17 18 #include "Actions/ActionRegistry.hpp" 18 19 #include "Menu/MenuDescription.hpp" 19 20 … … 87 88 } 88 89 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 89 105 /** Forward iterator from beginning of list of descriptions. 90 106 * \return iterator -
src/UIElements/Menu/MenuDescription.hpp
r23359f re4afb4 32 32 const std::string getName(std::string token) const; 33 33 34 std::multimap <std::string, std::string> getMenuItemsMap() const; 35 34 36 // iterators 35 37 iterator getBeginIter(); … … 42 44 std::map<std::string, std::string> MenuDescriptionsMap; 43 45 std::map<std::string, std::string> MenuNameMap; 46 std::multimap <std::string, std::string> MenuItemMap; 44 47 }; 45 48 -
src/UIElements/Menu/TextMenu.cpp
r23359f re4afb4 122 122 /****************************** Contained Actions ****************/ 123 123 124 const string TextMenu::LeaveAction::nameBase = "Leave menu: "; 125 126 TextMenu::LeaveAction::LeaveAction(TextMenu* _menu) : 127 Action(nameBase+_menu->getTitle()), 124 TextMenu::LeaveAction::LeaveAction(TextMenu* _menu, const ActionTraits & LeaveActionTrait) : 125 Action(LeaveActionTrait, false), 128 126 menu(_menu) 129 127 {} -
src/UIElements/Menu/TextMenu.hpp
r23359f re4afb4 15 15 #include "Menu/Menu.hpp" 16 16 #include "Actions/Action.hpp" 17 #include "Actions/ActionTraits.hpp" 17 18 #include "defs.hpp" 18 19 … … 29 30 class LeaveAction : public Action { 30 31 public: 31 LeaveAction(TextMenu* );32 LeaveAction(TextMenu*, const ActionTraits &_trait); 32 33 virtual ~LeaveAction(); 33 34 … … 43 44 virtual Action::state_ptr performRedo(Action::state_ptr); 44 45 46 ActionTraits *LeaveActionTrait; 45 47 TextMenu* menu; 46 47 static const string nameBase;48 48 }; 49 49 -
src/UIElements/Qt4/Pipe/AtomQtQueryPipe.cpp
r23359f re4afb4 27 27 28 28 29 AtomQtQueryPipe::AtomQtQueryPipe( atom **_content, QtDialog *_dialog, QComboBox *_theBox) :29 AtomQtQueryPipe::AtomQtQueryPipe(const atom **_content, QtDialog *_dialog, QComboBox *_theBox) : 30 30 content(_content), 31 31 dialog(_dialog), -
src/UIElements/Qt4/Pipe/AtomsQtQueryPipe.cpp
r23359f re4afb4 29 29 30 30 31 AtomsQtQueryPipe::AtomsQtQueryPipe(std::vector< atom *>*_content, QtDialog *_dialog, QListWidget *_theList) :31 AtomsQtQueryPipe::AtomsQtQueryPipe(std::vector<const atom *>*_content, QtDialog *_dialog, QListWidget *_theList) : 32 32 content(_content), 33 33 dialog(_dialog), … … 41 41 // clear target and put all atoms therein 42 42 (*content).clear(); 43 for (std::set< atom *>::iterator iter = currentList.begin(); iter != currentList.end(); ++iter)43 for (std::set<const atom *>::iterator iter = currentList.begin(); iter != currentList.end(); ++iter) 44 44 (*content).push_back(*iter); 45 45 dialog->update(); -
src/UIElements/Qt4/Pipe/MoleculeQtQueryPipe.cpp
r23359f re4afb4 26 26 27 27 28 MoleculeQtQueryPipe::MoleculeQtQueryPipe( molecule **_content, QtDialog *_dialog, QComboBox *_theBox) :28 MoleculeQtQueryPipe::MoleculeQtQueryPipe(const molecule **_content, QtDialog *_dialog, QComboBox *_theBox) : 29 29 content(_content), 30 30 dialog(_dialog), -
src/UIElements/Qt4/Pipe/MoleculesQtQueryPipe.cpp
r23359f re4afb4 28 28 29 29 30 MoleculesQtQueryPipe::MoleculesQtQueryPipe(std::vector< molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox) :30 MoleculesQtQueryPipe::MoleculesQtQueryPipe(std::vector<const molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox) : 31 31 content(_content), 32 32 dialog(_dialog), -
src/UIElements/Qt4/QtDialog.hpp
r23359f re4afb4 445 445 Q_OBJECT 446 446 public: 447 AtomQtQueryPipe( atom **_content, QtDialog *_dialog, QComboBox *_theBox);447 AtomQtQueryPipe(const atom **_content, QtDialog *_dialog, QComboBox *_theBox); 448 448 virtual ~AtomQtQueryPipe(); 449 449 … … 452 452 453 453 private: 454 atom **content;454 const atom **content; 455 455 QtDialog *dialog; 456 456 QComboBox *theBox; … … 462 462 Q_OBJECT 463 463 public: 464 AtomsQtQueryPipe(std::vector< atom *>*_content, QtDialog *_dialog, QListWidget *_theList);464 AtomsQtQueryPipe(std::vector<const atom *>*_content, QtDialog *_dialog, QListWidget *_theList); 465 465 virtual ~AtomsQtQueryPipe(); 466 466 … … 471 471 472 472 private: 473 std::vector< atom *>*content;474 std::map<int, atom *> lookup;475 std::set< atom *> currentList;473 std::vector<const atom *>*content; 474 std::map<int, const atom *> lookup; 475 std::set<const atom *> currentList; 476 476 QtDialog *dialog; 477 477 QListWidget *theList; … … 482 482 Q_OBJECT 483 483 public: 484 MoleculeQtQueryPipe( molecule **_content, QtDialog *_dialog, QComboBox *_theBox);484 MoleculeQtQueryPipe(const molecule **_content, QtDialog *_dialog, QComboBox *_theBox); 485 485 virtual ~MoleculeQtQueryPipe(); 486 486 … … 489 489 490 490 private: 491 molecule **content;491 const molecule **content; 492 492 QtDialog *dialog; 493 493 QComboBox *theBox; … … 498 498 Q_OBJECT 499 499 public: 500 MoleculesQtQueryPipe(std::vector< molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox);500 MoleculesQtQueryPipe(std::vector<const molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox); 501 501 virtual ~MoleculesQtQueryPipe(); 502 502 … … 505 505 506 506 private: 507 std::vector< molecule *>*content;507 std::vector<const molecule *>*content; 508 508 QtDialog *dialog; 509 509 QComboBox *theBox; -
src/UIElements/Qt4/QtMainWindow.cpp
r23359f re4afb4 38 38 #include "Actions/Action.hpp" 39 39 #include "Actions/ActionRegistry.hpp" 40 #include "Actions/MapOfActions.hpp" 40 #include "Actions/ValueStorage.hpp" 41 #include "Menu/MenuDescription.hpp" 41 42 #include "Menu/Menu.hpp" 42 43 #include "Menu/Qt4/QtMenu.hpp" … … 65 66 // go through all menus and create them 66 67 QtMenu *Menu = NULL; 67 for(std::map<std::string, std::pair<std::string,std::string> >::iterator iter = MapOfActions::getInstance().MenuDescription.begin(); iter != MapOfActions::getInstance().MenuDescription.end(); ++iter) { 68 cout << "Creating menu " << iter->first << endl; 69 Menu = new QtMenu(iter->first.c_str()); 68 MenuDescription menudescriptions; 69 for(MenuDescription::const_iterator iter = menudescriptions.getBeginIter(); iter != menudescriptions.getEndIter(); ++iter) { 70 cout << "Creating menu " << *iter << endl; 71 Menu = new QtMenu(menudescriptions.getName(*iter).c_str()); 70 72 MenuBar->addMenu(Menu); 71 NametoTextMenuMap.insert( pair <std::string, QtMenu *> ( iter->first, Menu) );72 //new SubMenuItem(getSuitableShortForm( iter->first),iter->second.first,main_menu,Menu);73 NametoTextMenuMap.insert( pair <std::string, QtMenu *> (menudescriptions.getName(*iter), Menu) ); 74 //new SubMenuItem(getSuitableShortForm(menudescriptions.getName(iter->first.c_str())),menudescriptions.getName(iter->first.c_str()),main_menu,Menu); 73 75 } 74 76 … … 118 120 set <char> ShortcutList; 119 121 // through all actions for this menu 120 std::pair < std::multimap <std::string, std::string>::iterator, std::multimap <std::string, std::string>::iterator > MenuActions = MapOfActions::getInstance().MenuContainsActionMap.equal_range(MenuName); 122 MenuDescription md; 123 std::multimap <std::string, std::string> MenuItems = md.getMenuItemsMap(); 124 std::pair < std::multimap <std::string, std::string>::iterator, std::multimap <std::string, std::string>::iterator > MenuActions = MenuItems.equal_range(MenuName); 121 125 for (std::multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) { 122 126 cout << " Adding " << MenuRunner->second << " to submenu " << MenuName << endl; -
src/UIElements/TextUI/TextWindow.cpp
r23359f re4afb4 21 21 22 22 #include <boost/bind.hpp> 23 #include <boost/shared_ptr.hpp> 23 24 24 25 #include "Menu/Menu.hpp" 26 #include "Menu/MenuDescription.hpp" 25 27 #include "Menu/TextMenu.hpp" 26 28 #include "Menu/ActionMenuItem.hpp" … … 30 32 #include "TextUI/TextStatusIndicator.hpp" 31 33 #include "TextUI/TextWindow.hpp" 32 #include "Actions/MapOfActions.hpp"33 34 #include "Actions/MethodAction.hpp" 34 35 #include "Actions/ErrorAction.hpp" 35 36 #include "Actions/ActionRegistry.hpp" 37 #include "Actions/ActionTraits.hpp" 36 38 #include "Parser/ChangeTracker.hpp" 37 39 #include "Views/StreamStringView.hpp" … … 77 79 new SeperatorItem(main_menu); 78 80 79 for(map<std::string, pair<std::string,std::string> >::iterator iter = MapOfActions::getInstance().MenuDescription.begin(); iter != MapOfActions::getInstance().MenuDescription.end(); ++iter) { 80 TextMenu *Menu = new TextMenu(Log() << Verbose(0), iter->second.second); 81 NametoTextMenuMap.insert( pair <std::string, TextMenu *> (iter->first, Menu) ); 82 new SubMenuItem(getSuitableShortForm(ShortcutList,iter->first),iter->second.first.c_str(),main_menu,Menu); 81 MenuDescription menudescriptions; 82 for(MenuDescription::const_iterator iter = menudescriptions.getBeginIter(); iter != menudescriptions.getEndIter(); ++iter) { 83 TextMenu *Menu = new TextMenu((ostream &)std::cout, menudescriptions.getDescription(*iter)); 84 NametoTextMenuMap.insert( pair <std::string, TextMenu *> (*iter, Menu) ); 85 new SubMenuItem(getSuitableShortForm(ShortcutList,*iter),menudescriptions.getDescription(*iter).c_str(),main_menu,Menu); 83 86 } 84 87 … … 89 92 new ActionMenuItem('s',"save current setup to config files",main_menu,saveConfigAction); 90 93 91 quitAction = new MethodAction("quitAction",boost::bind(&TextMenu::doQuit,main_menu),false); 94 ActionTraits quitTrait(OptionTrait("quitAction", &typeid(void), "quits the program")); 95 quitAction = new MethodAction(quitTrait,boost::bind(&TextMenu::doQuit,main_menu),false); 92 96 new ActionMenuItem('q',"quit",main_menu,quitAction); 93 97 … … 104 108 TextWindow::~TextWindow() 105 109 { 110 for (std::list<Action *>::iterator iter = returnFromActions.begin(); !returnFromActions.empty(); ++iter) 111 delete (*iter); 112 returnFromActions.clear(); 106 113 delete quitAction; 107 114 delete moleculeView; … … 144 151 ShortcutList.insert('q'); 145 152 // through all actions for this menu 146 pair < multimap <std::string, std::string>::iterator, multimap <std::string, std::string>::iterator > MenuActions = MapOfActions::getInstance().MenuContainsActionMap.equal_range(MenuName); 147 for (multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) { 153 MenuDescription md; 154 std::multimap <std::string, std::string> MenuItems = md.getMenuItemsMap(); 155 std::pair < std::multimap <std::string, std::string>::iterator, std::multimap <std::string, std::string>::iterator > MenuActions = MenuItems.equal_range(MenuName); 156 for (std::multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) { 148 157 ActionItem = ActionRegistry::getInstance().getActionByName(MenuRunner->second); 149 158 new ActionMenuItem(getSuitableShortForm(ShortcutList, MenuRunner->second),ActionItem->Traits.getDescription().c_str(),Menu,ActionItem); 150 159 } 151 160 // finally add default quit item 152 Action *returnFromAction = new TextMenu::LeaveAction(Menu); 161 ActionTraits LeaveActionTraits("Leave menu: "+Menu->getTitle()); 162 Action *returnFromAction = new TextMenu::LeaveAction(Menu, LeaveActionTraits); 163 //returnFromActions.push_back(returnFromAction); 153 164 MenuItem *returnFromItem = new ActionMenuItem('q',"return to Main menu",Menu,returnFromAction); 154 165 Menu->addDefault(returnFromItem); -
src/UIElements/TextUI/TextWindow.hpp
r23359f re4afb4 36 36 37 37 // some actions only needed in textMenus 38 std::list<Action *> returnFromActions; 38 39 Action *quitAction; 39 40 // all views that are contained in the main Menu
Note:
See TracChangeset
for help on using the changeset viewer.
