source: src/UIElements/Dialog.hpp@ 56fb09

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
Last change on this file since 56fb09 was 13892b, checked in by Frederik Heber <heber@…>, 15 years ago

Merge branch 'UIElementsExplained' into stable

  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 * Dialog.hpp
3 *
4 * Created on: Jan 5, 2010
5 * Author: crueger
6 */
7
8#ifndef DIALOG_HPP_
9#define DIALOG_HPP_
10
11#include<string>
12#include<list>
13#include<vector>
14
15class atom;
16class element;
17class molecule;
18class Vector;
19
20
21/** Dialog is one of the two main classes of the UIFactory base class.
22 *
23 * The Dialog is meant for asking the user for information needed to perform actions he
24 * desires, such as asking for a position in space or a length.
25 *
26 * For this purpose there is the base class Query and numerous specializations for each
27 * of the types to be asked. There are primitives integer, doubles and string, but also
28 * advanced types such as element, molecule or Vector. There is also an empty query for
29 * displaying text.
30 */
31class Dialog
32{
33public:
34 Dialog();
35 virtual ~Dialog();
36
37 virtual void queryEmpty(const char *, std::string = "")=0;
38 virtual void queryBoolean(const char *, bool *, std::string = "")=0;
39 virtual void queryInt(const char *, int *, std::string = "")=0;
40 virtual void queryDouble(const char*,double *, std::string = "")=0;
41 virtual void queryString(const char*, std::string *, std::string = "")=0;
42 virtual void queryAtom(const char*,atom**,std::string = "")=0;
43 virtual void queryMolecule(const char*,molecule**, std::string = "")=0;
44 virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0;
45 virtual void queryBox(const char*,double ** const, std::string = "")=0;
46 virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0;
47
48 virtual bool display();
49
50 virtual bool checkAll();
51 virtual void setAll();
52
53protected:
54 // methodology for handling queries
55 // all queries are stored and then performed at appropriate times
56
57 //these queries can be handled by this dialog
58
59 //TODO: Find a way to reduce complexity...
60 //needs O(N*M) query classes, where N is the number of query types and M is the number of GUIs
61 //usual approach for reducing inheritance complexity (strategy pattern) does not work,
62 //due to lack of common code for query types as well as GUI-Types (all subtypes differ a lot)
63
64 //base class for all queries
65 class Query {
66 friend class Dialog;
67 public:
68 Query(std::string _title, std::string _description = "");
69 virtual ~Query();
70 virtual bool handle()=0;
71 virtual void setResult()=0;
72 protected:
73 const std::string getTitle() const;
74 const std::string getDescription() const;
75 private:
76 std::string title; //!< short title of the query
77 std::string description; //!< longer description for tooltips or for help
78 };
79
80 // Empty Query is just meant for showing text, such as version, help, initial message or alike
81 class EmptyQuery : public Query {
82 public:
83 EmptyQuery(std::string title, std::string _description = "");
84 virtual ~EmptyQuery();
85 virtual bool handle()=0;
86 virtual void setResult();
87 };
88
89 //Specialized classes for certain types. GUI-Types are not specialized at this time
90 class BooleanQuery : public Query {
91 public:
92 BooleanQuery(std::string title,bool *_target, std::string _description = "");
93 virtual ~BooleanQuery();
94 virtual bool handle()=0;
95 virtual void setResult();
96 protected:
97 bool tmp;
98 private:
99 bool *target;
100 };
101
102 class IntQuery : public Query {
103 public:
104 IntQuery(std::string title,int *_target, std::string _description = "");
105 virtual ~IntQuery();
106 virtual bool handle()=0;
107 virtual void setResult();
108 protected:
109 int tmp;
110 private:
111 int *target;
112 };
113
114 class DoubleQuery : public Query {
115 public:
116 DoubleQuery(std::string title,double *_target, std::string _description = "");
117 virtual ~DoubleQuery();
118 virtual bool handle()=0;
119 virtual void setResult();
120 protected:
121 double tmp;
122 private:
123 double *target;
124 };
125
126 class StringQuery : public Query {
127 public:
128 StringQuery(std::string title,std::string *_target, std::string _description = "");
129 virtual ~StringQuery();
130 virtual bool handle()=0;
131 virtual void setResult();
132 protected:
133 std::string tmp;
134 private:
135 std::string *target;
136 };
137
138 class MoleculeQuery : public Query {
139 public:
140 MoleculeQuery(std::string title, molecule **_target, std::string _description = "");
141 virtual ~MoleculeQuery();
142 virtual bool handle()=0;
143 virtual void setResult();
144 protected:
145 molecule *tmp;
146 private:
147 molecule **target;
148 };
149
150 class AtomQuery : public Query {
151 public:
152 AtomQuery(std::string title, atom **_target, std::string _description = "");
153 virtual ~AtomQuery();
154 virtual bool handle()=0;
155 virtual void setResult();
156 protected:
157 atom *tmp;
158 private:
159 atom **target;
160 };
161
162 class VectorQuery : public Query {
163 public:
164 VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
165 virtual ~VectorQuery();
166 virtual bool handle()=0;
167 virtual void setResult();
168 protected:
169 Vector *tmp;
170 const double *const cellSize;
171 bool check;
172 private:
173 Vector *target;
174 };
175
176 class BoxQuery : public Query {
177 public:
178 BoxQuery(std::string title,double ** const _cellSize, std::string _description = "");
179 virtual ~BoxQuery();
180 virtual bool handle()=0;
181 virtual void setResult();
182 protected:
183 double *tmp;
184 private:
185 double **target;
186 };
187
188 class ElementQuery : public Query {
189 public:
190 ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
191 virtual ~ElementQuery();
192 virtual bool handle()=0;
193 virtual void setResult();
194 protected:
195 std::vector<element *> elements;
196 private:
197 std::vector<element *> * const target;
198 };
199
200void registerQuery(Query* query);
201
202private:
203 std::list<Query*> queries;
204
205};
206
207
208#endif /* DIALOG_HPP_ */
Note: See TracBrowser for help on using the repository browser.