Changeset 10fa1d for src/Actions


Ignore:
Timestamp:
Aug 28, 2010, 12:57:56 AM (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:
c66537
Parents:
966e12
git-author:
Frederik Heber <heber@…> (08/26/10 21:36:28)
git-committer:
Frederik Heber <heber@…> (08/28/10 00:57:56)
Message:

DOCU: Updated Action Howto to contain the new macro framework.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.hpp

    r966e12 r10fa1d  
    8787 * <H2> Building your own actions </H2>
    8888 *
    89  * Building actions is fairly easy. Simply derive from the abstract Action base class and implement
    90  * the virtual methods. The main code that needs to be executed upon call() should be implemented in
    91  * the performCall() method. Any user interaction should be placed into the dialog returned by
    92  * createDialog(). You should also indicate whether the action supports undo by implementing
    93  * the shouldUndo() and canUndo() methods to return the appropriate flags.
     89 * Building actions is easy. Each specific ...Action is derived from the base class Action.
     90 * In order to create all the reoccuring stuff, macros have been created which you can simply
     91 * include and then don't need to worry about it.
     92 * There are three major virtual functions: performCall(), performUndo(), performRedo() which
     93 * you have to write, to equip your action with some actual capabilities.
     94 * Each Action definition and implementation consists of of three files:
     95 * -# cpp: contains performX() which you have to write, also some boilerplate functions which are
     96 *         constructed automatically when including your def and "Actions/action_impl_pre.hpp"
     97 * -# hpp: boilerplate definitions created simply by including your def and
     98 *         "Actions/action_impl_header.hpp"
     99 * -# def: macro definitions of all your parameters and additional variables needed for the state,
     100 *         also name and category and token of your action.
     101 *
     102 * Best thing to do is look at one of the already present triples and you should soon understand
     103 * what you have to add:
     104 * -# pick the right category, i.e. the right folder in src/Actions
     105 * -# pick the right name
     106 * -# decide which parameters your actions need and what the type, the variable name and the token
     107 *    to reference it from the command-line should be. Check whether already present and fitting
     108 *    tokens exists, e.g. "position" as token for a Vector representing a position.
     109 * -# consider which additional information you need to undo your action
     110 * -# don't forget to include your .def file followed by "action_impl_pre.hpp" in .cpp or
     111 *    "action_impl_header.hpp" in the .hpp
     112 * -# continue to write the functionality of your action in performCall(), undo and redo in performUndo()
     113 *    and performRedo().
     114 * -# You should indicate whether the action supports undo by implementing the shouldUndo() and
     115 *    canUndo() methods to return the appropriate flags.
     116 *
     117 * <H3> Specific notes on the macros </H3>
     118 *
     119 * The following functions are created by the macros, i.e. you don't need to worry about it:
     120 *
     121 * Any user interaction should be placed into the dialog returned by fillDialog().
    94122 *
    95123 * Also, create the global function to allow for easy calling of your function internally (i.e.
     
    135163 *
    136164 * <ul>
    137  *  <li/> derive YourAction from Action
    138  *  <li/> pass name and flag for registry to the base constructor
    139  *  <li/> implement createDialog(), performCall(), performUndo(), performRedo()
    140  *  <li/> implement the global function call/macro.
    141  *  <li/> implement the functions that return the flags for the undo mechanism
    142  *  <li/> Derive YourActionState from ActionState as necessary
     165 *  <li/> create parameter tupels (type, token, reference), put into def. Access them later in
     166 *        the performX() via the structure params.###.
     167 *  <li/> think of name, category and token for your action, put into def
     168 *  <li/> create additional state variables tupels (type, reference) for storing extra information
     169 *        that you need for undo/redo in the ActionState. You can always access the parameters
     170 *        of your Action by state.params.### (i.e. they are copied to the state by default).
     171 *  <li/> implement performCall(), first line should be calling of getParametersfromValueStorage().
     172 *  <li/> performUndo(), performRedo()
     173 *  <li/> implement the functions that return the flags for the undo mechanism, i.e. true/false.
    143174 * </ul>
    144175 *
     
    146177 *
    147178 * <ul>
    148  *  <li/> createDialog():
    149  *  <ul>
    150  *   <li/> Call makeDialog() from the UIFactory.
    151  *   <li/> Call any needed Dialog->Query...() for the values you need with specific keywords.
    152  *   <li/> if the action needs to save a state return a custom state object
    153  *   <li/> otherwise return Action::success
    154  *  </ul>
    155179 *  <li/> performCall():
    156180 *  <ul>
    157  *   <li/> obtain parameters you need by ValueStorage::getCurrentValue, matching
    158  *         key words from createDialog().
     181 *   <li/> first line should be calling of getParametersfromValueStorage().
     182 *   <li/> Access your parameters by the structure params.### (where ### stands for the reference/
     183 *         variable name chosen in the tupel).
    159184 *   <li/> do whatever is needed to make the action work
    160185 *   <li/> if the action was abborted return Action::failure
     
    165190 *  <ul>
    166191 *   <li/> typecast the ActionState pointer to a Pointer to YourActionState if necessary
    167  *   <li/> undo the action using the information from the state
     192 *   <li/> undo the action using the extra information and the Action's parameters in the state
    168193 *   <li/> produce a new state that can be used for redoing and return it
    169194 *  </ul>
     
    171196 *  <ul>
    172197 *   <li/> take the ActionState produced by performUndo and typecast it to a pointer to YourActionState if necessary
    173  *   <li/> redo the undone action using the information from the state
     198 *   <li/> redo the undone action using the extra information and the Action's parameters in the state
    174199 *   <li/> produce a new state that can be used by performUndo() and return it
    175200 *  </ul>
Note: See TracChangeset for help on using the changeset viewer.