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