Changes in src/UIElements/Dialog.cpp [112b09:c508ef5]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Dialog.cpp
r112b09 rc508ef5 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 #include <cassert>11 12 10 #include "Dialog.hpp" 13 11 #include "ValueStorage.hpp" 12 13 #include "verbose.hpp" 14 14 #include "atom.hpp" 15 15 #include "element.hpp" 16 16 #include "molecule.hpp" 17 17 #include "vector.hpp" 18 #include "Matrix.hpp" 19 #include "Box.hpp" 18 20 19 21 using namespace std; … … 36 38 37 39 bool Dialog::display(){ 40 if(checkAll()){ 41 setAll(); 42 return true; 43 } 44 else{ 45 return false; 46 } 47 } 48 49 bool Dialog::checkAll(){ 38 50 list<Query*>::iterator iter; 39 51 bool retval = true; … … 41 53 retval &= (*iter)->handle(); 42 54 // if any query fails (is canceled), we can end the handling process 43 if(!retval) 55 if(!retval) { 56 DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl); 44 57 break; 45 }46 if (retval){47 // if all queries succeeded we can set the targets to appropriate values48 for(iter=queries.begin(); iter!=queries.end(); iter++) {49 (*iter)->setResult();50 58 } 51 59 } 52 60 return retval; 61 } 62 63 void Dialog::setAll(){ 64 list<Query*>::iterator iter; 65 for(iter=queries.begin(); iter!=queries.end(); iter++) { 66 (*iter)->setResult(); 67 } 68 } 69 70 bool Dialog::hasQueries(){ 71 return queries.size(); 53 72 } 54 73 … … 83 102 // Int Queries 84 103 85 Dialog::IntQuery::IntQuery(string title, int *_target,std::string description) :86 Query(title, description) , target(_target)104 Dialog::IntQuery::IntQuery(string title, std::string description) : 105 Query(title, description) 87 106 {} 88 107 … … 90 109 91 110 void Dialog::IntQuery::setResult() { 92 *target = tmp; 93 } 94 95 // Int Queries 96 97 Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) : 98 Query(title, description), target(_target) 111 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 112 } 113 114 // Ints Queries 115 116 Dialog::IntsQuery::IntsQuery(string title, std::string description) : 117 Query(title, description) 118 {} 119 120 Dialog::IntsQuery::~IntsQuery() {} 121 122 void Dialog::IntsQuery::setResult() { 123 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 124 } 125 126 // Bool Queries 127 128 Dialog::BooleanQuery::BooleanQuery(string title,std::string description) : 129 Query(title, description) 99 130 {} 100 131 … … 102 133 103 134 void Dialog::BooleanQuery::setResult() { 104 *target = tmp;135 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 105 136 } 106 137 107 138 // String Queries 108 139 109 Dialog::StringQuery::StringQuery(string title,st ring *_target, std::string _description) :110 Query(title, _description) , target(_target)140 Dialog::StringQuery::StringQuery(string title,std::string _description) : 141 Query(title, _description) 111 142 {} 112 143 … … 114 145 115 146 void Dialog::StringQuery::setResult() { 116 *target = tmp; 147 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 148 } 149 150 // Strings Queries 151 152 Dialog::StringsQuery::StringsQuery(string title,std::string _description) : 153 Query(title, _description) 154 {} 155 156 Dialog::StringsQuery::~StringsQuery() {}; 157 158 void Dialog::StringsQuery::setResult() { 159 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 117 160 } 118 161 119 162 // Double Queries 120 163 121 Dialog::DoubleQuery::DoubleQuery(string title, double *_target,std::string _description) :122 Query(title, _description) , target(_target)164 Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) : 165 Query(title, _description) 123 166 {} 124 167 … … 126 169 127 170 void Dialog::DoubleQuery::setResult() { 128 *target = tmp; 171 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 172 } 173 174 // Doubles Queries 175 176 Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) : 177 Query(title, _description) 178 {} 179 180 Dialog::DoublesQuery::~DoublesQuery() {}; 181 182 void Dialog::DoublesQuery::setResult() { 183 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 129 184 } 130 185 … … 132 187 // Atom Queries 133 188 134 Dialog::AtomQuery::AtomQuery(string title, atom **_target,std::string _description) :189 Dialog::AtomQuery::AtomQuery(string title, std::string _description) : 135 190 Query(title, _description), 136 tmp(0), 137 target(_target) 138 191 tmp(0) 139 192 {} 140 193 … … 142 195 143 196 void Dialog::AtomQuery::setResult() { 144 *target = tmp; 197 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 198 } 199 200 // Atoms Queries 201 202 Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) : 203 Query(title, _description), 204 tmp(0) 205 {} 206 207 Dialog::AtomsQuery::~AtomsQuery() {} 208 209 void Dialog::AtomsQuery::setResult() { 210 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 145 211 } 146 212 147 213 // Molecule Queries 148 214 149 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target,std::string _description) :215 Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) : 150 216 Query(title, _description), 151 tmp(0), 152 target(_target) 153 217 tmp(0) 154 218 {} 155 219 … … 157 221 158 222 void Dialog::MoleculeQuery::setResult() { 159 *target = tmp; 223 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 224 } 225 226 // Molecules Queries 227 228 Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) : 229 Query(title, _description), 230 tmp(0) 231 {} 232 233 Dialog::MoleculesQuery::~MoleculesQuery() {} 234 235 void Dialog::MoleculesQuery::setResult() { 236 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 160 237 } 161 238 162 239 // Vector Queries 163 240 164 Dialog::VectorQuery::VectorQuery(std::string title, Vector *_target,const double *const _cellSize,bool _check, std::string _description) :241 Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) : 165 242 Query(title, _description), 166 cellSize(_cellSize), 167 check(_check), 168 target(_target) 169 { 170 tmp = new Vector(); 171 } 243 check(_check) 244 {} 172 245 173 246 Dialog::VectorQuery::~VectorQuery() 174 { 175 delete tmp; 176 } 247 {} 177 248 178 249 void Dialog::VectorQuery::setResult() { 179 *target = *tmp; 250 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 251 } 252 253 // Vectors Queries 254 255 Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) : 256 Query(title, _description), 257 check(_check) 258 {} 259 260 Dialog::VectorsQuery::~VectorsQuery() 261 {} 262 263 void Dialog::VectorsQuery::setResult() { 264 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 180 265 } 181 266 182 267 // Box Queries 183 268 184 Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) : 185 Query(title, _description), 186 target(_cellSize) 187 { 188 tmp = new double[6]; 189 } 269 Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) : 270 Query(title, _description) 271 {} 190 272 191 273 Dialog::BoxQuery::~BoxQuery() 192 { 193 delete[] tmp; 194 } 274 {} 195 275 196 276 void Dialog::BoxQuery::setResult() { 197 for (int i=0;i<6;i++) { 198 (*target)[i] = tmp[i]; 199 } 277 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 200 278 } 201 279 202 280 // Element Queries 203 Dialog::ElementQuery::ElementQuery(std::string title, const element **_target, std::string _description) : 204 Query(title, _description), 205 tmp(0), 206 target(_target) 281 Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) : 282 Query(title, _description) 207 283 {} 208 284 … … 210 286 211 287 void Dialog::ElementQuery::setResult(){ 212 *target=tmp; 213 } 288 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 289 } 290 291 // Elements Queries 292 Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) : 293 Query(title, _description) 294 {} 295 296 Dialog::ElementsQuery::~ElementsQuery(){} 297 298 void Dialog::ElementsQuery::setResult(){ 299 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 300 }
Note:
See TracChangeset
for help on using the changeset viewer.