| [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>
 | 
|---|
 | 13 | 
 | 
|---|
| [97ebf8] | 14 | class atom;
 | 
|---|
 | 15 | class element;
 | 
|---|
| [7aa000] | 16 | class molecule;
 | 
|---|
| [2ededc2] | 17 | class Vector;
 | 
|---|
| [45f5d6] | 18 | 
 | 
|---|
| [f5a86a] | 19 | class Dialog
 | 
|---|
 | 20 | {
 | 
|---|
 | 21 | public:
 | 
|---|
 | 22 |   Dialog();
 | 
|---|
 | 23 |   virtual ~Dialog();
 | 
|---|
 | 24 | 
 | 
|---|
| [86466e] | 25 |   virtual void queryEmpty(const char *, std::string = "")=0;
 | 
|---|
| [97ebf8] | 26 |   virtual void queryBoolean(const char *, bool *, std::string = "")=0;
 | 
|---|
| [a2ab15] | 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;
 | 
|---|
| [97ebf8] | 30 |   virtual void queryAtom(const char*,atom**,std::string = "")=0;
 | 
|---|
 | 31 |   virtual void queryMolecule(const char*,molecule**, std::string = "")=0;
 | 
|---|
| [a2ab15] | 32 |   virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0;
 | 
|---|
| [97ebf8] | 33 |   virtual void queryBox(const char*,double ** const, std::string = "")=0;
 | 
|---|
| [a2ab15] | 34 |   virtual void queryElement(const char*,const element **, std::string = "")=0;
 | 
|---|
| [f5a86a] | 35 | 
 | 
|---|
| [45f5d6] | 36 |   virtual bool display();
 | 
|---|
| [f5a86a] | 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
 | 
|---|
| [45f5d6] | 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:
 | 
|---|
| [a2ab15] | 52 |     Query(std::string _title, std::string _description = "");
 | 
|---|
| [5a7243] | 53 |     virtual ~Query();
 | 
|---|
| [45f5d6] | 54 |     virtual bool handle()=0;
 | 
|---|
 | 55 |     virtual void setResult()=0;
 | 
|---|
 | 56 |   protected:
 | 
|---|
 | 57 |     const std::string getTitle() const;
 | 
|---|
| [a2ab15] | 58 |     const std::string getDescription() const;
 | 
|---|
| [45f5d6] | 59 |   private:
 | 
|---|
| [a2ab15] | 60 |     std::string title;  //!< short title of the query
 | 
|---|
 | 61 |     std::string description; //!< longer description for tooltips or for help
 | 
|---|
| [f5a86a] | 62 |   };
 | 
|---|
 | 63 | 
 | 
|---|
| [86466e] | 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 | 
 | 
|---|
| [45f5d6] | 73 |   //Specialized classes for certain types. GUI-Types are not specialized at this time
 | 
|---|
| [97ebf8] | 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 | 
 | 
|---|
| [45f5d6] | 86 |   class IntQuery : public Query {
 | 
|---|
 | 87 |   public:
 | 
|---|
| [a2ab15] | 88 |     IntQuery(std::string title,int *_target, std::string _description = "");
 | 
|---|
| [5a7243] | 89 |     virtual ~IntQuery();
 | 
|---|
| [45f5d6] | 90 |     virtual bool handle()=0;
 | 
|---|
 | 91 |     virtual void setResult();
 | 
|---|
 | 92 |   protected:
 | 
|---|
 | 93 |     int tmp;
 | 
|---|
 | 94 |   private:
 | 
|---|
 | 95 |     int *target;
 | 
|---|
 | 96 |   };
 | 
|---|
 | 97 | 
 | 
|---|
| [2ededc2] | 98 |   class DoubleQuery : public Query {
 | 
|---|
 | 99 |   public:
 | 
|---|
| [a2ab15] | 100 |     DoubleQuery(std::string title,double *_target, std::string _description = "");
 | 
|---|
| [5a7243] | 101 |     virtual ~DoubleQuery();
 | 
|---|
| [2ededc2] | 102 |     virtual bool handle()=0;
 | 
|---|
 | 103 |     virtual void setResult();
 | 
|---|
 | 104 |   protected:
 | 
|---|
 | 105 |     double tmp;
 | 
|---|
 | 106 |   private:
 | 
|---|
 | 107 |     double *target;
 | 
|---|
 | 108 |   };
 | 
|---|
 | 109 | 
 | 
|---|
| [45f5d6] | 110 |   class StringQuery : public Query {
 | 
|---|
 | 111 |   public:
 | 
|---|
| [a2ab15] | 112 |     StringQuery(std::string title,std::string *_target, std::string _description = "");
 | 
|---|
| [5a7243] | 113 |     virtual ~StringQuery();
 | 
|---|
| [45f5d6] | 114 |     virtual bool handle()=0;
 | 
|---|
 | 115 |     virtual void setResult();
 | 
|---|
 | 116 |   protected:
 | 
|---|
 | 117 |     std::string tmp;
 | 
|---|
 | 118 |   private:
 | 
|---|
 | 119 |     std::string *target;
 | 
|---|
 | 120 |   };
 | 
|---|
 | 121 | 
 | 
|---|
| [7aa000] | 122 |   class MoleculeQuery : public Query {
 | 
|---|
 | 123 |   public:
 | 
|---|
| [97ebf8] | 124 |     MoleculeQuery(std::string title, molecule **_target, std::string _description = "");
 | 
|---|
| [5a7243] | 125 |     virtual ~MoleculeQuery();
 | 
|---|
| [7aa000] | 126 |     virtual bool handle()=0;
 | 
|---|
 | 127 |     virtual void setResult();
 | 
|---|
 | 128 |   protected:
 | 
|---|
 | 129 |     molecule *tmp;
 | 
|---|
 | 130 |   private:
 | 
|---|
 | 131 |     molecule **target;
 | 
|---|
 | 132 |   };
 | 
|---|
 | 133 | 
 | 
|---|
| [97ebf8] | 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 | 
 | 
|---|
| [2ededc2] | 146 |   class VectorQuery : public Query {
 | 
|---|
 | 147 |   public:
 | 
|---|
| [a2ab15] | 148 |       VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
 | 
|---|
| [5a7243] | 149 |       virtual ~VectorQuery();
 | 
|---|
| [2ededc2] | 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 | 
 | 
|---|
| [97ebf8] | 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 | 
 | 
|---|
| [5a7243] | 172 |   class ElementQuery : public Query {
 | 
|---|
 | 173 |   public:
 | 
|---|
| [a2ab15] | 174 |     ElementQuery(std::string title, const element**_target, std::string _description = "");
 | 
|---|
| [5a7243] | 175 |     virtual ~ElementQuery();
 | 
|---|
 | 176 |     virtual bool handle()=0;
 | 
|---|
 | 177 |     virtual void setResult();
 | 
|---|
 | 178 |   protected:
 | 
|---|
| [5605032] | 179 |     const element *tmp;
 | 
|---|
| [5a7243] | 180 |   private:
 | 
|---|
| [5605032] | 181 |     const element **target;
 | 
|---|
| [5a7243] | 182 |   };
 | 
|---|
 | 183 | 
 | 
|---|
| [45f5d6] | 184 | void registerQuery(Query* query);
 | 
|---|
 | 185 | 
 | 
|---|
 | 186 | private:
 | 
|---|
 | 187 |   std::list<Query*> queries;
 | 
|---|
| [f5a86a] | 188 | 
 | 
|---|
 | 189 | };
 | 
|---|
 | 190 | 
 | 
|---|
| [a2ab15] | 191 | 
 | 
|---|
| [f5a86a] | 192 | #endif /* DIALOG_HPP_ */
 | 
|---|