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