source: src/UIElements/Dialog.hpp@ 36166d

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 36166d was 5ec8e3, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Merge branch 'VectorRefactoring' into StructureRefactoring

Conflicts:

molecuilder/src/Makefile.am

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