source: src/UIElements/Dialog.hpp@ 23359f

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 23359f was 4cf323d, checked in by Frederik Heber <heber@…>, 14 years ago

Renamed QT -> Qt in files, dirs, and class names.

  • Property mode set to 100644
File size: 9.1 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 <boost/filesystem.hpp>
16
17#include "Box.hpp"
18#include "LinearAlgebra/Vector.hpp"
19
20class atom;
21class Box;
22class element;
23class molecule;
24
25
26/** Dialog is one of the two main classes of the UIFactory base class.
27 *
28 * The Dialog is meant for asking the user for information needed to perform
29 * actions he desires, such as asking for a position in space or a length.
30 *
31 * For this purpose there is the base class Query and numerous specializations
32 * for each of the types to be asked. There are primitives integer, doubles and
33 * string, but also advanced types such as element, molecule or Vector. There
34 * is also an empty query for displaying text.
35 */
36class Dialog
37{
38public:
39 Dialog();
40 virtual ~Dialog();
41
42 template <class T> void query(const char *, std::string = "");
43
44 virtual void queryEmpty(const char *, std::string = "")=0;
45 virtual void queryBoolean(const char *, std::string = "")=0;
46 virtual void queryInt(const char *, std::string = "")=0;
47 virtual void queryInts(const char *, std::string = "")=0;
48 virtual void queryDouble(const char*, std::string = "")=0;
49 virtual void queryDoubles(const char*, std::string = "")=0;
50 virtual void queryString(const char*, std::string = "")=0;
51 virtual void queryStrings(const char*, std::string = "")=0;
52 virtual void queryAtom(const char*,std::string = "")=0;
53 virtual void queryAtoms(const char*,std::string = "")=0;
54 virtual void queryMolecule(const char*, std::string = "")=0;
55 virtual void queryMolecules(const char*, std::string = "")=0;
56 virtual void queryVector(const char*,bool, std::string = "")=0;
57 virtual void queryVectors(const char*,bool, std::string = "")=0;
58 virtual void queryBox(const char*, std::string = "")=0;
59 virtual void queryElement(const char*, std::string = "")=0;
60 virtual void queryElements(const char*, std::string = "")=0;
61 virtual void queryFile(const char*, std::string = "")=0;
62
63 virtual bool display();
64
65 virtual bool checkAll();
66 virtual void setAll();
67
68 virtual bool hasQueries();
69
70protected:
71 // methodology for handling queries
72 // all queries are stored and then performed at appropriate times
73
74 //these queries can be handled by this dialog
75
76 //TODO: Find a way to reduce complexity...
77 //needs O(N*M) query classes, where N is the number of query types and M is the number of GUIs
78 //usual approach for reducing inheritance complexity (strategy pattern) does not work,
79 //due to lack of common code for query types as well as GUI-Types (all subtypes differ a lot)
80
81 /** Base class for all queries.
82 *
83 *
84 * <h1>How to add another query?</h1>
85 *
86 * Let's say we want to query for a type called \a Value.
87 *
88 * Then, we do the following:
89 * -# Add a class ValueQuery inside class Dialog, the class contains
90 * -# constructor/destructor (latter virtual! because of derived class)
91 * -# virtual bool handle() and virtual void setResult()
92 * -# a protected member tmp of type Value (NOTE: herein the result is stored)
93 * -# if temporaries for conversion are needed put them in here
94 * -# add a function queryValue
95 * -# now, for each of the GUIs we basically have to repeat the above, i.e.
96 * add the class and the function that implement the virtual ones above.
97 * -# QT: an extra class called ValueQtQueryPipe that actually handles
98 * showing dialogs to obtain the value and placing it into the \a tmp
99 * variable (via a given pointer to it as reference). handle() will
100 * simply return true. This is needed because of a restriction of Qt4:
101 * its meta-object-compiler does not like nested classes.
102 * -# CommandLine: nothing special, handle() imports value from \a
103 * CommandLineParser and sets the tmp variable.
104 * -# Text: nothing special, handle() queries the user and sets the tmp
105 * variable
106 */
107 class Query {
108 friend class Dialog;
109 public:
110 Query(std::string _title, std::string _description = "");
111 virtual ~Query();
112 virtual bool handle()=0;
113 virtual void setResult()=0;
114 protected:
115 const std::string getTitle() const;
116 const std::string getDescription() const;
117 private:
118 std::string title; //!< short title of the query
119 std::string description; //!< longer description for tooltips or for help
120 };
121
122 // Empty Query is just meant for showing text, such as version, help, initial message or alike
123 class EmptyQuery : public Query {
124 public:
125 EmptyQuery(std::string title, std::string _description = "");
126 virtual ~EmptyQuery();
127 virtual bool handle()=0;
128 virtual void setResult();
129 };
130
131 //Specialized classes for certain types. GUI-Types are not specialized at this time
132 class BooleanQuery : public Query {
133 public:
134 BooleanQuery(std::string title, std::string _description = "");
135 virtual ~BooleanQuery();
136 virtual bool handle()=0;
137 virtual void setResult();
138 protected:
139 bool tmp;
140 };
141
142 class IntQuery : public Query {
143 public:
144 IntQuery(std::string title, std::string _description = "");
145 virtual ~IntQuery();
146 virtual bool handle()=0;
147 virtual void setResult();
148 protected:
149 int tmp;
150 };
151
152 class IntsQuery : public Query {
153 public:
154 IntsQuery(std::string title, std::string _description = "");
155 virtual ~IntsQuery();
156 virtual bool handle()=0;
157 virtual void setResult();
158 protected:
159 int temp;
160 std::vector<int> tmp;
161 };
162
163 class DoubleQuery : public Query {
164 public:
165 DoubleQuery(std::string title, std::string _description = "");
166 virtual ~DoubleQuery();
167 virtual bool handle()=0;
168 virtual void setResult();
169 protected:
170 double tmp;
171 };
172
173 class DoublesQuery : public Query {
174 public:
175 DoublesQuery(std::string title, std::string _description = "");
176 virtual ~DoublesQuery();
177 virtual bool handle()=0;
178 virtual void setResult();
179 protected:
180 double temp;
181 std::vector<double> tmp;
182 };
183
184 class StringQuery : public Query {
185 public:
186 StringQuery(std::string title, std::string _description = "");
187 virtual ~StringQuery();
188 virtual bool handle()=0;
189 virtual void setResult();
190 protected:
191 std::string tmp;
192 };
193
194 class StringsQuery : public Query {
195 public:
196 StringsQuery(std::string title, std::string _description = "");
197 virtual ~StringsQuery();
198 virtual bool handle()=0;
199 virtual void setResult();
200 protected:
201 std::string temp;
202 std::vector<std::string> tmp;
203 };
204
205 class MoleculeQuery : public Query {
206 public:
207 MoleculeQuery(std::string title, std::string _description = "");
208 virtual ~MoleculeQuery();
209 virtual bool handle()=0;
210 virtual void setResult();
211 protected:
212 molecule *tmp;
213 };
214
215 class MoleculesQuery : public Query {
216 public:
217 MoleculesQuery(std::string title, std::string _description = "");
218 virtual ~MoleculesQuery();
219 virtual bool handle()=0;
220 virtual void setResult();
221 protected:
222 molecule * temp;
223 std::vector<molecule *> tmp;
224 };
225
226 class AtomQuery : public Query {
227 public:
228 AtomQuery(std::string title, std::string _description = "");
229 virtual ~AtomQuery();
230 virtual bool handle()=0;
231 virtual void setResult();
232 protected:
233 atom *tmp;
234 };
235
236 class AtomsQuery : public Query {
237 public:
238 AtomsQuery(std::string title, std::string _description = "");
239 virtual ~AtomsQuery();
240 virtual bool handle()=0;
241 virtual void setResult();
242 protected:
243 atom *temp;
244 std::vector<atom *> tmp;
245 };
246
247 class VectorQuery : public Query {
248 public:
249 VectorQuery(std::string title,bool _check, std::string _description = "");
250 virtual ~VectorQuery();
251 virtual bool handle()=0;
252 virtual void setResult();
253 protected:
254 Vector tmp;
255 bool check;
256 };
257
258 class VectorsQuery : public Query {
259 public:
260 VectorsQuery(std::string title,bool _check, std::string _description = "");
261 virtual ~VectorsQuery();
262 virtual bool handle()=0;
263 virtual void setResult();
264 protected:
265 Vector temp;
266 std::vector<Vector> tmp;
267 bool check;
268 };
269
270 class BoxQuery : public Query {
271 public:
272 BoxQuery(std::string title, std::string _description = "");
273 virtual ~BoxQuery();
274 virtual bool handle()=0;
275 virtual void setResult();
276 protected:
277 Box tmp;
278 };
279
280 class ElementQuery : public Query {
281 public:
282 ElementQuery(std::string title, std::string _description = "");
283 virtual ~ElementQuery();
284 virtual bool handle()=0;
285 virtual void setResult();
286 protected:
287 const element * tmp;
288 };
289
290 class ElementsQuery : public Query {
291 public:
292 ElementsQuery(std::string title, std::string _description = "");
293 virtual ~ElementsQuery();
294 virtual bool handle()=0;
295 virtual void setResult();
296 protected:
297 const element *temp;
298 std::vector<const element *> tmp;
299 };
300
301 class FileQuery : public Query {
302 public:
303 FileQuery(std::string title, std::string _description = "");
304 virtual ~FileQuery();
305 virtual bool handle()=0;
306 virtual void setResult();
307 protected:
308 boost::filesystem::path tmp;
309 };
310
311void registerQuery(Query* query);
312
313private:
314 std::list<Query*> queries;
315
316};
317
318
319#endif /* DIALOG_HPP_ */
Note: See TracBrowser for help on using the repository browser.