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, 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.