source: src/UIElements/Dialog.hpp@ 6f5dfe

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 6f5dfe was 6f5dfe, checked in by Frederik Heber <heber@…>, 14 years ago

Added boost::filesystem usage for input files.

  • parameters for Action input now have type boost::filesystem.
  • rewritten Actions to use boost::filesystems
  • in the progress of writing FileQtQuery to present a file dialog.
  • Property mode set to 100644
File size: 7.8 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 actions he
29 * 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 for each
32 * of the types to be asked. There are primitives integer, doubles and string, but also
33 * advanced types such as element, molecule or Vector. There is also an empty query for
34 * 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 class Query {
83 friend class Dialog;
84 public:
85 Query(std::string _title, std::string _description = "");
86 virtual ~Query();
87 virtual bool handle()=0;
88 virtual void setResult()=0;
89 protected:
90 const std::string getTitle() const;
91 const std::string getDescription() const;
92 private:
93 std::string title; //!< short title of the query
94 std::string description; //!< longer description for tooltips or for help
95 };
96
97 // Empty Query is just meant for showing text, such as version, help, initial message or alike
98 class EmptyQuery : public Query {
99 public:
100 EmptyQuery(std::string title, std::string _description = "");
101 virtual ~EmptyQuery();
102 virtual bool handle()=0;
103 virtual void setResult();
104 };
105
106 //Specialized classes for certain types. GUI-Types are not specialized at this time
107 class BooleanQuery : public Query {
108 public:
109 BooleanQuery(std::string title, std::string _description = "");
110 virtual ~BooleanQuery();
111 virtual bool handle()=0;
112 virtual void setResult();
113 protected:
114 bool tmp;
115 };
116
117 class IntQuery : public Query {
118 public:
119 IntQuery(std::string title, std::string _description = "");
120 virtual ~IntQuery();
121 virtual bool handle()=0;
122 virtual void setResult();
123 protected:
124 int tmp;
125 };
126
127 class IntsQuery : public Query {
128 public:
129 IntsQuery(std::string title, std::string _description = "");
130 virtual ~IntsQuery();
131 virtual bool handle()=0;
132 virtual void setResult();
133 protected:
134 int temp;
135 std::vector<int> tmp;
136 };
137
138 class DoubleQuery : public Query {
139 public:
140 DoubleQuery(std::string title, std::string _description = "");
141 virtual ~DoubleQuery();
142 virtual bool handle()=0;
143 virtual void setResult();
144 protected:
145 double tmp;
146 };
147
148 class DoublesQuery : public Query {
149 public:
150 DoublesQuery(std::string title, std::string _description = "");
151 virtual ~DoublesQuery();
152 virtual bool handle()=0;
153 virtual void setResult();
154 protected:
155 double temp;
156 std::vector<double> tmp;
157 };
158
159 class StringQuery : public Query {
160 public:
161 StringQuery(std::string title, std::string _description = "");
162 virtual ~StringQuery();
163 virtual bool handle()=0;
164 virtual void setResult();
165 protected:
166 std::string tmp;
167 };
168
169 class StringsQuery : public Query {
170 public:
171 StringsQuery(std::string title, std::string _description = "");
172 virtual ~StringsQuery();
173 virtual bool handle()=0;
174 virtual void setResult();
175 protected:
176 std::string temp;
177 std::vector<std::string> tmp;
178 };
179
180 class MoleculeQuery : public Query {
181 public:
182 MoleculeQuery(std::string title, std::string _description = "");
183 virtual ~MoleculeQuery();
184 virtual bool handle()=0;
185 virtual void setResult();
186 protected:
187 molecule *tmp;
188 };
189
190 class MoleculesQuery : public Query {
191 public:
192 MoleculesQuery(std::string title, std::string _description = "");
193 virtual ~MoleculesQuery();
194 virtual bool handle()=0;
195 virtual void setResult();
196 protected:
197 molecule * temp;
198 std::vector<molecule *> tmp;
199 };
200
201 class AtomQuery : public Query {
202 public:
203 AtomQuery(std::string title, std::string _description = "");
204 virtual ~AtomQuery();
205 virtual bool handle()=0;
206 virtual void setResult();
207 protected:
208 atom *tmp;
209 };
210
211 class AtomsQuery : public Query {
212 public:
213 AtomsQuery(std::string title, std::string _description = "");
214 virtual ~AtomsQuery();
215 virtual bool handle()=0;
216 virtual void setResult();
217 protected:
218 atom *temp;
219 std::vector<atom *> tmp;
220 };
221
222 class VectorQuery : public Query {
223 public:
224 VectorQuery(std::string title,bool _check, std::string _description = "");
225 virtual ~VectorQuery();
226 virtual bool handle()=0;
227 virtual void setResult();
228 protected:
229 Vector tmp;
230 bool check;
231 };
232
233 class VectorsQuery : public Query {
234 public:
235 VectorsQuery(std::string title,bool _check, std::string _description = "");
236 virtual ~VectorsQuery();
237 virtual bool handle()=0;
238 virtual void setResult();
239 protected:
240 Vector temp;
241 std::vector<Vector> tmp;
242 bool check;
243 };
244
245 class BoxQuery : public Query {
246 public:
247 BoxQuery(std::string title, std::string _description = "");
248 virtual ~BoxQuery();
249 virtual bool handle()=0;
250 virtual void setResult();
251 protected:
252 Box tmp;
253 };
254
255 class ElementQuery : public Query {
256 public:
257 ElementQuery(std::string title, std::string _description = "");
258 virtual ~ElementQuery();
259 virtual bool handle()=0;
260 virtual void setResult();
261 protected:
262 const element * tmp;
263 };
264
265 class ElementsQuery : public Query {
266 public:
267 ElementsQuery(std::string title, std::string _description = "");
268 virtual ~ElementsQuery();
269 virtual bool handle()=0;
270 virtual void setResult();
271 protected:
272 const element *temp;
273 std::vector<const element *> tmp;
274 };
275
276 class FileQuery : public Query {
277 public:
278 FileQuery(std::string title, std::string _description = "");
279 virtual ~FileQuery();
280 virtual bool handle()=0;
281 virtual void setResult();
282 protected:
283 boost::filesystem::path tmp;
284 };
285
286void registerQuery(Query* query);
287
288private:
289 std::list<Query*> queries;
290
291};
292
293
294#endif /* DIALOG_HPP_ */
Note: See TracBrowser for help on using the repository browser.