source: src/UIElements/Dialog.hpp@ e4decc

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 e4decc was 9ee38b, checked in by Frederik Heber <heber@…>, 15 years ago

Extended macro framework.

Extensions:

  • all central definitions reside in .def files
    • This if file is necessary because we need the definitions at two places: hpp and cpp
    • And as we always use the same define names, we have to undefine them at the end of both (otherwise we get compiler warnings and are prone to dumb mistakes of forgotten defines seeming present)
  • the .hpp is just a very tiny header, that should be possible to batch- construct inside Makefile as well
  • .cpp includes some Action_...hpp files and implements the function

For later (i.e. when ActionRegistry becomes prototype copier)

  • instead of waiting for clone(), for now we simply call the prototype.
  • in the action command we must not yet prefix paramreferences with "params."

Changes:

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