source: src/UIElements/Dialog.hpp@ 3037be

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 3037be was 7cd6e7, checked in by Frederik Heber <heber@…>, 15 years ago

Add all possible versions of queries where the user is asked for multiples of the same.

  • Note that these are correctly implemented in TextUI and CommandLineUI, but not yet in QT4.
  • Property mode set to 100644
File size: 7.3 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
15#include "vector.hpp"
16
17class atom;
18class Box;
19class element;
20class molecule;
21
22
23/** Dialog is one of the two main classes of the UIFactory base class.
24 *
25 * The Dialog is meant for asking the user for information needed to perform actions he
26 * desires, such as asking for a position in space or a length.
27 *
28 * For this purpose there is the base class Query and numerous specializations for each
29 * of the types to be asked. There are primitives integer, doubles and string, but also
30 * advanced types such as element, molecule or Vector. There is also an empty query for
31 * displaying text.
32 */
33class Dialog
34{
35public:
36 Dialog();
37 virtual ~Dialog();
38
39 virtual void queryEmpty(const char *, std::string = "")=0;
40 virtual void queryBoolean(const char *, std::string = "")=0;
41 virtual void queryInt(const char *, std::string = "")=0;
42 virtual void queryInts(const char *, std::string = "")=0;
43 virtual void queryDouble(const char*, std::string = "")=0;
44 virtual void queryDoubles(const char*, std::string = "")=0;
45 virtual void queryString(const char*, std::string = "")=0;
46 virtual void queryStrings(const char*, std::string = "")=0;
47 virtual void queryAtom(const char*,std::string = "")=0;
48 virtual void queryAtoms(const char*,std::string = "")=0;
49 virtual void queryMolecule(const char*, std::string = "")=0;
50 virtual void queryMolecules(const char*, std::string = "")=0;
51 virtual void queryVector(const char*,bool, std::string = "")=0;
52 virtual void queryVectors(const char*,bool, std::string = "")=0;
53 virtual void queryBox(const char*, std::string = "")=0;
54 virtual void queryElement(const char*, std::string = "")=0;
55 virtual void queryElements(const char*, std::string = "")=0;
56
57 virtual bool display();
58
59 virtual bool checkAll();
60 virtual void setAll();
61
62protected:
63 // methodology for handling queries
64 // all queries are stored and then performed at appropriate times
65
66 //these queries can be handled by this dialog
67
68 //TODO: Find a way to reduce complexity...
69 //needs O(N*M) query classes, where N is the number of query types and M is the number of GUIs
70 //usual approach for reducing inheritance complexity (strategy pattern) does not work,
71 //due to lack of common code for query types as well as GUI-Types (all subtypes differ a lot)
72
73 //base class for all queries
74 class Query {
75 friend class Dialog;
76 public:
77 Query(std::string _title, std::string _description = "");
78 virtual ~Query();
79 virtual bool handle()=0;
80 virtual void setResult()=0;
81 protected:
82 const std::string getTitle() const;
83 const std::string getDescription() const;
84 private:
85 std::string title; //!< short title of the query
86 std::string description; //!< longer description for tooltips or for help
87 };
88
89 // Empty Query is just meant for showing text, such as version, help, initial message or alike
90 class EmptyQuery : public Query {
91 public:
92 EmptyQuery(std::string title, std::string _description = "");
93 virtual ~EmptyQuery();
94 virtual bool handle()=0;
95 virtual void setResult();
96 };
97
98 //Specialized classes for certain types. GUI-Types are not specialized at this time
99 class BooleanQuery : public Query {
100 public:
101 BooleanQuery(std::string title, std::string _description = "");
102 virtual ~BooleanQuery();
103 virtual bool handle()=0;
104 virtual void setResult();
105 protected:
106 bool tmp;
107 };
108
109 class IntQuery : public Query {
110 public:
111 IntQuery(std::string title, std::string _description = "");
112 virtual ~IntQuery();
113 virtual bool handle()=0;
114 virtual void setResult();
115 protected:
116 int tmp;
117 };
118
119 class IntsQuery : public Query {
120 public:
121 IntsQuery(std::string title, std::string _description = "");
122 virtual ~IntsQuery();
123 virtual bool handle()=0;
124 virtual void setResult();
125 protected:
126 int temp;
127 std::vector<int> tmp;
128 };
129
130 class DoubleQuery : public Query {
131 public:
132 DoubleQuery(std::string title, std::string _description = "");
133 virtual ~DoubleQuery();
134 virtual bool handle()=0;
135 virtual void setResult();
136 protected:
137 double tmp;
138 };
139
140 class DoublesQuery : public Query {
141 public:
142 DoublesQuery(std::string title, std::string _description = "");
143 virtual ~DoublesQuery();
144 virtual bool handle()=0;
145 virtual void setResult();
146 protected:
147 double temp;
148 std::vector<double> tmp;
149 };
150
151 class StringQuery : public Query {
152 public:
153 StringQuery(std::string title, std::string _description = "");
154 virtual ~StringQuery();
155 virtual bool handle()=0;
156 virtual void setResult();
157 protected:
158 std::string tmp;
159 };
160
161 class StringsQuery : public Query {
162 public:
163 StringsQuery(std::string title, std::string _description = "");
164 virtual ~StringsQuery();
165 virtual bool handle()=0;
166 virtual void setResult();
167 protected:
168 std::string temp;
169 std::vector<std::string> tmp;
170 };
171
172 class MoleculeQuery : public Query {
173 public:
174 MoleculeQuery(std::string title, std::string _description = "");
175 virtual ~MoleculeQuery();
176 virtual bool handle()=0;
177 virtual void setResult();
178 protected:
179 molecule *tmp;
180 };
181
182 class MoleculesQuery : public Query {
183 public:
184 MoleculesQuery(std::string title, std::string _description = "");
185 virtual ~MoleculesQuery();
186 virtual bool handle()=0;
187 virtual void setResult();
188 protected:
189 molecule * temp;
190 std::vector<molecule *> tmp;
191 };
192
193 class AtomQuery : public Query {
194 public:
195 AtomQuery(std::string title, std::string _description = "");
196 virtual ~AtomQuery();
197 virtual bool handle()=0;
198 virtual void setResult();
199 protected:
200 atom *tmp;
201 };
202
203 class AtomsQuery : public Query {
204 public:
205 AtomsQuery(std::string title, std::string _description = "");
206 virtual ~AtomsQuery();
207 virtual bool handle()=0;
208 virtual void setResult();
209 protected:
210 atom *temp;
211 std::vector<atom *> tmp;
212 };
213
214 class VectorQuery : public Query {
215 public:
216 VectorQuery(std::string title,bool _check, std::string _description = "");
217 virtual ~VectorQuery();
218 virtual bool handle()=0;
219 virtual void setResult();
220 protected:
221 Vector tmp;
222 bool check;
223 };
224
225 class VectorsQuery : public Query {
226 public:
227 VectorsQuery(std::string title,bool _check, std::string _description = "");
228 virtual ~VectorsQuery();
229 virtual bool handle()=0;
230 virtual void setResult();
231 protected:
232 Vector temp;
233 std::vector<Vector> tmp;
234 bool check;
235 };
236
237 class BoxQuery : public Query {
238 public:
239 BoxQuery(std::string title, std::string _description = "");
240 virtual ~BoxQuery();
241 virtual bool handle()=0;
242 virtual void setResult();
243 protected:
244 double* tmp;
245 };
246
247 class ElementQuery : public Query {
248 public:
249 ElementQuery(std::string title, std::string _description = "");
250 virtual ~ElementQuery();
251 virtual bool handle()=0;
252 virtual void setResult();
253 protected:
254 element * tmp;
255 };
256
257 class ElementsQuery : public Query {
258 public:
259 ElementsQuery(std::string title, std::string _description = "");
260 virtual ~ElementsQuery();
261 virtual bool handle()=0;
262 virtual void setResult();
263 protected:
264 element *temp;
265 std::vector<element *> tmp;
266 };
267
268void registerQuery(Query* query);
269
270private:
271 std::list<Query*> queries;
272
273};
274
275
276#endif /* DIALOG_HPP_ */
Note: See TracBrowser for help on using the repository browser.