Changeset e4afb4 for src/UIElements/Dialog.hpp
- 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, 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.