Changeset e4afb4 for src/UIElements


Ignore:
Timestamp:
Oct 30, 2010, 8:42:44 PM (15 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Huge refactoring: Introduction of Traits to Actions.

This change is really big but the introduction of the Trait concept (at least
in its current light form) is so fundamental that lots of pieces had to be
changed in order to get everything working.

The main point why it was necessary to add these traits in the first place was
to comfortably allow for adding extension of Actions information-wise, i.e.
with stuff that is only important for the QtUI, such as icons, or tooltips, ...
This extra information should not be stored with Action itself, as it has
nothing to do with the workings of the Action. And neither should it get
stored with some blown-out-of-proportions MapOfActions class ...

The gist of the change is as follows:

  • OptionTrait contains the token, description, shortform and type of an option, such as ("position", "position in space, none, typeid(Vector)).
  • ActionTrait is the derived form for actions where additionally MenuPosition and MenuName are stored (and probably more to come for the GUI), also we have a set of OptionTrait instances, one for each option of the Action.
  • Action then contains this ActionTrait, specialized for each Action.
  • the preprocessor macros have been enhanced to gather all this information from the .def files.
  • MapOfActions is gone. Completely. Most of its use was to store this extra information and the ValueStorage part now is just in class ValueStorage.
  • ValueStorage is no more an interface to MapOfActions but as the name says a (type-safe) ValueStorage.

Listing the (remaining) changes in alphabetical order of the class:

  • Action
    • member value ::name dropped, ::getName() uses ActionTraits::getName()
    • new define NODEFAULT which is used in paramdefaults in .def files
    • all derived actions classes such as Process, Calculations, MakroAction,... have been adapated to use the ActionTrait concept as well.
  • ActionHistory
    • extraced RedoAction and UndoAction, shifted implementation into their own object files and they use .def files as well (i.e. streamlined with method used for other actions)
  • MenuDescription
    • contain information on Menus such as name, ...
    • new unit test checks for consistency
  • molecule
    • const member functions: Copy(), Output() and OutputBonds()
  • OptionRegistry
    • new registry class for options only
    • we want the same type throughout the code for each token, e.g. "position"
    • the registry containts checks for consistency
  • OptionTrait
    • default values are specified in paramdefaults, none are given by NODEFAULT
    • introduced default for translate-atoms, point-correlation, pair-correlation
  • Registry pattern
    • new unit test, but only sceleton code so far
  • ...Query, also ...Pipe
    • atoms, molecule and elements are now all const
    • also ValueStorage's signatures all have const therein
  • ValueStorage
    • set/queryCurrentValue from MapOfActions
    • at times VectorValue has been in .def files where Vector was in the signature. This is cleared. Such stuff is only present for e.g. BoxVector being queried as a Vector. But this is a feature and intended.
  • World
    • most of the (un)selection functions now work on const atoms and molecules
    • in one case we need a const_cast to remove this, but this is intentional, as the vector of selected atoms stores non-const pointers and this is ok.

There is only one test which had to be changed slightly because a specific
option token as "position" must now have the same type everywhere, e.g. always
Vector.

  • TESTFIX: Simple_configuration/2: --position -> --domain-position (and associated to BoxVector)
Location:
src/UIElements
Files:
3 added
34 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/UIElements/CommandLineUI/CommandLineParser.hpp

    r23359f re4afb4  
    1414
    1515#include "Patterns/Singleton.hpp"
     16#include "UIElements/CommandLineUI/TypeEnumContainer.hpp"
    1617
    17 #include <list>
     18#include <map>
     19
     20class Action;
     21class OptionTrait;
    1822
    1923/** This class is a wrapper for boost::program_options.
     
    9296
    9397  // 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();
    95102
    96103  // Checks whether there have been any commands on the command line.
     
    102109   * -# hidden options: options which the user is not shown on "help"
    103110   */
    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;
    108122
    109123  po::options_description visible;
     
    125139  po::options_description config_file_options;
    126140
     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
    127150  // Sets the options from the three cases.
    128151  void setOptions(int _argc, char **_argv);
     
    133156  // as boost's program_options does not care about of order of appearance but we do for actions,
    134157  // 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;
    136161
    137162  // argument counter and array passed on from main()
  • src/UIElements/CommandLineUI/CommandLineWindow.cpp

    r23359f re4afb4  
    2828#include "Actions/ActionRegistry.hpp"
    2929
    30 #include "CommandLineParser.hpp"
     30#include "UIElements/CommandLineUI/CommandLineParser.hpp"
    3131
    3232#include <iostream>
  • src/UIElements/CommandLineUI/Query/AtomCommandLineQuery.cpp

    r23359f re4afb4  
    2626#include "CommandLineUI/CommandLineDialog.hpp"
    2727
    28 #include "CommandLineParser.hpp"
     28#include "CommandLineUI/CommandLineParser.hpp"
    2929#include "Helpers/Log.hpp"
    3030#include "Helpers/Verbose.hpp"
  • src/UIElements/CommandLineUI/Query/AtomsCommandLineQuery.cpp

    r23359f re4afb4  
    2424#include "CommandLineUI/CommandLineDialog.hpp"
    2525
     26#include "CommandLineUI/CommandLineParser.hpp"
    2627#include "Helpers/Log.hpp"
    2728#include "Helpers/Verbose.hpp"
    28 #include "CommandLineParser.hpp"
    2929#include "World.hpp"
    3030
  • src/UIElements/CommandLineUI/Query/BooleanCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727
    2828CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/BoxCommandLineQuery.cpp

    r23359f re4afb4  
    2323
    2424#include "Actions/Values.hpp"
     25#include "CommandLineUI/CommandLineParser.hpp"
    2526#include "Helpers/Log.hpp"
    2627#include "Helpers/Verbose.hpp"
    2728#include "LinearAlgebra/Matrix.hpp"
    28 #include "CommandLineParser.hpp"
    2929
    3030CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/DoubleCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727
    2828
  • src/UIElements/CommandLineUI/Query/DoublesCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727
    2828CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/ElementCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727#include "element.hpp"
    2828#include "periodentafel.hpp"
  • src/UIElements/CommandLineUI/Query/ElementsCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727#include "element.hpp"
    2828#include "periodentafel.hpp"
  • src/UIElements/CommandLineUI/Query/EmptyCommandLineQuery.cpp

    r23359f re4afb4  
    2424#include "CommandLineUI/CommandLineDialog.hpp"
    2525
     26#include "CommandLineUI/CommandLineParser.hpp"
    2627#include "Helpers/Log.hpp"
    2728#include "Helpers/Verbose.hpp"
    28 #include "CommandLineParser.hpp"
    2929
    3030CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/FileCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727
    2828CommandLineDialog::FileCommandLineQuery::FileCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/IntCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727
    2828CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/IntsCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727
    2828CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/MoleculeCommandLineQuery.cpp

    r23359f re4afb4  
    2424#include "CommandLineUI/CommandLineDialog.hpp"
    2525
     26#include "CommandLineUI/CommandLineParser.hpp"
    2627#include "Helpers/Log.hpp"
    2728#include "Helpers/Verbose.hpp"
    28 #include "CommandLineParser.hpp"
    2929
    3030CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/MoleculesCommandLineQuery.cpp

    r23359f re4afb4  
    2424#include "CommandLineUI/CommandLineDialog.hpp"
    2525
     26#include "CommandLineUI/CommandLineParser.hpp"
    2627#include "Helpers/Log.hpp"
    2728#include "Helpers/Verbose.hpp"
    28 #include "CommandLineParser.hpp"
    2929#include "World.hpp"
    3030
  • src/UIElements/CommandLineUI/Query/StringCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727
    2828CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) :
  • src/UIElements/CommandLineUI/Query/StringsCommandLineQuery.cpp

    r23359f re4afb4  
    2222#include "CommandLineUI/CommandLineDialog.hpp"
    2323
     24#include "CommandLineUI/CommandLineParser.hpp"
    2425#include "Helpers/Log.hpp"
    2526#include "Helpers/Verbose.hpp"
    26 #include "CommandLineParser.hpp"
    2727
    2828CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) :
     
    3434bool CommandLineDialog::StringsCommandLineQuery::handle() {
    3535  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> >();
    3737    return true;
    3838  } else {
  • src/UIElements/CommandLineUI/Query/VectorCommandLineQuery.cpp

    r23359f re4afb4  
    2323
    2424#include "Actions/Values.hpp"
     25#include "CommandLineUI/CommandLineParser.hpp"
    2526#include "Helpers/Log.hpp"
    2627#include "Helpers/Verbose.hpp"
    27 #include "CommandLineParser.hpp"
    2828#include "LinearAlgebra/Vector.hpp"
    2929#include "Box.hpp"
  • src/UIElements/CommandLineUI/Query/VectorsCommandLineQuery.cpp

    r23359f re4afb4  
    2525
    2626#include "Actions/Values.hpp"
     27#include "CommandLineUI/CommandLineParser.hpp"
    2728#include "Helpers/Log.hpp"
    2829#include "Helpers/Verbose.hpp"
    29 #include "CommandLineParser.hpp"
    3030#include "World.hpp"
    3131
  • src/UIElements/Dialog.cpp

    r23359f re4afb4  
    126126}
    127127
    128 template <> void Dialog::query<atom *>(const char *token, std::string description)
     128template <> void Dialog::query<const atom *>(const char *token, std::string description)
    129129{
    130130  queryAtom(token, description);
    131131}
    132132
    133 template <> void Dialog::query< std::vector<atom *> >(const char *token, std::string description)
     133template <> void Dialog::query< std::vector<const atom *> >(const char *token, std::string description)
    134134{
    135135  queryAtoms(token, description);
    136136}
    137137
    138 template <> void Dialog::query<molecule *>(const char *token, std::string description)
     138template <> void Dialog::query<const molecule *>(const char *token, std::string description)
    139139{
    140140  queryMolecule(token, description);
    141141}
    142142
    143 template <> void Dialog::query< std::vector<molecule *> >(const char *token, std::string description)
     143template <> void Dialog::query< std::vector<const molecule *> >(const char *token, std::string description)
    144144{
    145145  queryMolecules(token, description);
  • src/UIElements/Dialog.hpp

    r23359f re4afb4  
    3333 * string, but also advanced types such as element, molecule or Vector. There
    3434 * 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 *
    35139 */
    36140class Dialog
     
    210314    virtual void setResult();
    211315  protected:
    212     molecule *tmp;
     316    const molecule *tmp;
    213317  };
    214318
     
    220324    virtual void setResult();
    221325  protected:
    222     molecule * temp;
    223     std::vector<molecule *> tmp;
     326    const molecule * temp;
     327    std::vector<const molecule *> tmp;
    224328  };
    225329
     
    231335    virtual void setResult();
    232336  protected:
    233     atom *tmp;
     337    const atom *tmp;
    234338  };
    235339
     
    241345    virtual void setResult();
    242346  protected:
    243     atom *temp;
    244     std::vector<atom *> tmp;
     347    const atom *temp;
     348    std::vector<const atom *> tmp;
    245349  };
    246350
  • src/UIElements/Makefile.am

    r23359f re4afb4  
    123123  CommandLineUI/Query/VectorsCommandLineQuery.cpp \
    124124  CommandLineUI/CommandLineDialog.cpp \
     125  CommandLineUI/CommandLineParser.cpp \
    125126  CommandLineUI/CommandLineStatusIndicator.cpp \
    126127  CommandLineUI/CommandLineUIFactory.cpp \
    127   CommandLineUI/CommandLineWindow.cpp
     128  CommandLineUI/CommandLineWindow.cpp \
     129  CommandLineUI/TypeEnumContainer.cpp
     130 
    128131COMMANDLINEUIHEADER = \
    129132  CommandLineUI/CommandLineDialog.hpp \
     133  CommandLineUI/CommandLineParser.hpp \
    130134  CommandLineUI/CommandLineStatusIndicator.hpp \
    131135  CommandLineUI/CommandLineUIFactory.hpp \
    132   CommandLineUI/CommandLineWindow.hpp
     136  CommandLineUI/CommandLineWindow.hpp \
     137  CommandLineUI/TypeEnumContainer.cpp
    133138
    134139lib_LTLIBRARIES = libMolecuilderUI-@MOLECUILDER_API_VERSION@.la
  • src/UIElements/Menu/MenuDescription.cpp

    r23359f re4afb4  
    1616#include <string>
    1717
     18#include "Actions/ActionRegistry.hpp"
    1819#include "Menu/MenuDescription.hpp"
    1920
     
    8788}
    8889
     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 */
     93std::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
    89105/** Forward iterator from beginning of list of descriptions.
    90106 * \return iterator
  • src/UIElements/Menu/MenuDescription.hpp

    r23359f re4afb4  
    3232  const std::string getName(std::string token) const;
    3333
     34  std::multimap <std::string, std::string> getMenuItemsMap() const;
     35
    3436  // iterators
    3537  iterator getBeginIter();
     
    4244  std::map<std::string, std::string> MenuDescriptionsMap;
    4345  std::map<std::string, std::string> MenuNameMap;
     46  std::multimap <std::string, std::string> MenuItemMap;
    4447};
    4548
  • src/UIElements/Menu/TextMenu.cpp

    r23359f re4afb4  
    122122/****************************** Contained Actions ****************/
    123123
    124 const string TextMenu::LeaveAction::nameBase = "Leave menu: ";
    125 
    126 TextMenu::LeaveAction::LeaveAction(TextMenu* _menu) :
    127   Action(nameBase+_menu->getTitle()),
     124TextMenu::LeaveAction::LeaveAction(TextMenu* _menu, const ActionTraits & LeaveActionTrait) :
     125  Action(LeaveActionTrait, false),
    128126  menu(_menu)
    129127{}
  • src/UIElements/Menu/TextMenu.hpp

    r23359f re4afb4  
    1515#include "Menu/Menu.hpp"
    1616#include "Actions/Action.hpp"
     17#include "Actions/ActionTraits.hpp"
    1718#include "defs.hpp"
    1819
     
    2930  class LeaveAction : public Action {
    3031  public:
    31     LeaveAction(TextMenu*);
     32    LeaveAction(TextMenu*, const ActionTraits &_trait);
    3233    virtual ~LeaveAction();
    3334
     
    4344    virtual Action::state_ptr performRedo(Action::state_ptr);
    4445
     46    ActionTraits *LeaveActionTrait;
    4547    TextMenu* menu;
    46 
    47     static const string nameBase;
    4848  };
    4949
  • src/UIElements/Qt4/Pipe/AtomQtQueryPipe.cpp

    r23359f re4afb4  
    2727
    2828
    29 AtomQtQueryPipe::AtomQtQueryPipe(atom **_content, QtDialog *_dialog, QComboBox *_theBox) :
     29AtomQtQueryPipe::AtomQtQueryPipe(const atom **_content, QtDialog *_dialog, QComboBox *_theBox) :
    3030  content(_content),
    3131  dialog(_dialog),
  • src/UIElements/Qt4/Pipe/AtomsQtQueryPipe.cpp

    r23359f re4afb4  
    2929
    3030
    31 AtomsQtQueryPipe::AtomsQtQueryPipe(std::vector<atom *>*_content, QtDialog *_dialog, QListWidget *_theList) :
     31AtomsQtQueryPipe::AtomsQtQueryPipe(std::vector<const atom *>*_content, QtDialog *_dialog, QListWidget *_theList) :
    3232  content(_content),
    3333  dialog(_dialog),
     
    4141  // clear target and put all atoms therein
    4242  (*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)
    4444    (*content).push_back(*iter);
    4545  dialog->update();
  • src/UIElements/Qt4/Pipe/MoleculeQtQueryPipe.cpp

    r23359f re4afb4  
    2626
    2727
    28 MoleculeQtQueryPipe::MoleculeQtQueryPipe(molecule **_content, QtDialog *_dialog, QComboBox *_theBox) :
     28MoleculeQtQueryPipe::MoleculeQtQueryPipe(const molecule **_content, QtDialog *_dialog, QComboBox *_theBox) :
    2929  content(_content),
    3030  dialog(_dialog),
  • src/UIElements/Qt4/Pipe/MoleculesQtQueryPipe.cpp

    r23359f re4afb4  
    2828
    2929
    30 MoleculesQtQueryPipe::MoleculesQtQueryPipe(std::vector<molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox) :
     30MoleculesQtQueryPipe::MoleculesQtQueryPipe(std::vector<const molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox) :
    3131  content(_content),
    3232  dialog(_dialog),
  • src/UIElements/Qt4/QtDialog.hpp

    r23359f re4afb4  
    445445  Q_OBJECT
    446446public:
    447   AtomQtQueryPipe(atom **_content, QtDialog *_dialog, QComboBox *_theBox);
     447  AtomQtQueryPipe(const atom **_content, QtDialog *_dialog, QComboBox *_theBox);
    448448  virtual ~AtomQtQueryPipe();
    449449
     
    452452
    453453private:
    454   atom **content;
     454  const atom **content;
    455455  QtDialog *dialog;
    456456  QComboBox *theBox;
     
    462462  Q_OBJECT
    463463public:
    464   AtomsQtQueryPipe(std::vector<atom *>*_content, QtDialog *_dialog, QListWidget *_theList);
     464  AtomsQtQueryPipe(std::vector<const atom *>*_content, QtDialog *_dialog, QListWidget *_theList);
    465465  virtual ~AtomsQtQueryPipe();
    466466
     
    471471
    472472private:
    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;
    476476  QtDialog *dialog;
    477477  QListWidget *theList;
     
    482482  Q_OBJECT
    483483public:
    484   MoleculeQtQueryPipe(molecule **_content, QtDialog *_dialog, QComboBox *_theBox);
     484  MoleculeQtQueryPipe(const molecule **_content, QtDialog *_dialog, QComboBox *_theBox);
    485485  virtual ~MoleculeQtQueryPipe();
    486486
     
    489489
    490490private:
    491   molecule **content;
     491  const molecule **content;
    492492  QtDialog *dialog;
    493493  QComboBox *theBox;
     
    498498  Q_OBJECT
    499499public:
    500   MoleculesQtQueryPipe(std::vector<molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox);
     500  MoleculesQtQueryPipe(std::vector<const molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox);
    501501  virtual ~MoleculesQtQueryPipe();
    502502
     
    505505
    506506private:
    507   std::vector<molecule *>*content;
     507  std::vector<const molecule *>*content;
    508508  QtDialog *dialog;
    509509  QComboBox *theBox;
  • src/UIElements/Qt4/QtMainWindow.cpp

    r23359f re4afb4  
    3838#include "Actions/Action.hpp"
    3939#include "Actions/ActionRegistry.hpp"
    40 #include "Actions/MapOfActions.hpp"
     40#include "Actions/ValueStorage.hpp"
     41#include "Menu/MenuDescription.hpp"
    4142#include "Menu/Menu.hpp"
    4243#include "Menu/Qt4/QtMenu.hpp"
     
    6566  // go through all menus and create them
    6667  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());
    7072    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);
    7375  }
    7476
     
    118120  set <char> ShortcutList;
    119121  // 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);
    121125  for (std::multimap <std::string, std::string>::const_iterator MenuRunner = MenuActions.first; MenuRunner != MenuActions.second; ++MenuRunner) {
    122126    cout << " Adding " << MenuRunner->second << " to submenu " << MenuName << endl;
  • src/UIElements/TextUI/TextWindow.cpp

    r23359f re4afb4  
    2121
    2222#include <boost/bind.hpp>
     23#include <boost/shared_ptr.hpp>
    2324
    2425#include "Menu/Menu.hpp"
     26#include "Menu/MenuDescription.hpp"
    2527#include "Menu/TextMenu.hpp"
    2628#include "Menu/ActionMenuItem.hpp"
     
    3032#include "TextUI/TextStatusIndicator.hpp"
    3133#include "TextUI/TextWindow.hpp"
    32 #include "Actions/MapOfActions.hpp"
    3334#include "Actions/MethodAction.hpp"
    3435#include "Actions/ErrorAction.hpp"
    3536#include "Actions/ActionRegistry.hpp"
     37#include "Actions/ActionTraits.hpp"
    3638#include "Parser/ChangeTracker.hpp"
    3739#include "Views/StreamStringView.hpp"
     
    7779  new SeperatorItem(main_menu);
    7880
    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);
    8386  }
    8487
     
    8992  new ActionMenuItem('s',"save current setup to config files",main_menu,saveConfigAction);
    9093
    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);
    9296  new ActionMenuItem('q',"quit",main_menu,quitAction);
    9397
     
    104108TextWindow::~TextWindow()
    105109{
     110  for (std::list<Action *>::iterator iter = returnFromActions.begin(); !returnFromActions.empty(); ++iter)
     111    delete (*iter);
     112  returnFromActions.clear();
    106113  delete quitAction;
    107114  delete moleculeView;
     
    144151  ShortcutList.insert('q');
    145152  // 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) {
    148157    ActionItem = ActionRegistry::getInstance().getActionByName(MenuRunner->second);
    149158    new ActionMenuItem(getSuitableShortForm(ShortcutList, MenuRunner->second),ActionItem->Traits.getDescription().c_str(),Menu,ActionItem);
    150159  }
    151160  // 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);
    153164  MenuItem *returnFromItem = new ActionMenuItem('q',"return to Main menu",Menu,returnFromAction);
    154165  Menu->addDefault(returnFromItem);
  • src/UIElements/TextUI/TextWindow.hpp

    r23359f re4afb4  
    3636
    3737  // some actions only needed in textMenus
     38  std::list<Action *> returnFromActions;
    3839  Action *quitAction;
    3940  // all views that are contained in the main Menu
Note: See TracChangeset for help on using the changeset viewer.