1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Dialog.cpp
|
---|
10 | *
|
---|
11 | * Created on: Jan 5, 2010
|
---|
12 | * Author: crueger
|
---|
13 | */
|
---|
14 |
|
---|
15 | // include config.h
|
---|
16 | #ifdef HAVE_CONFIG_H
|
---|
17 | #include <config.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #include "CodePatterns/MemDebug.hpp"
|
---|
21 |
|
---|
22 | #include "Dialog.hpp"
|
---|
23 | #include "Actions/ValueStorage.hpp"
|
---|
24 |
|
---|
25 | #include "CodePatterns/Log.hpp"
|
---|
26 | #include "CodePatterns/Verbose.hpp"
|
---|
27 |
|
---|
28 | class Atom;
|
---|
29 | class Box;
|
---|
30 | class element;
|
---|
31 | class RealSpaceMatrix;
|
---|
32 | class molecule;
|
---|
33 | class Vector;
|
---|
34 |
|
---|
35 | using namespace std;
|
---|
36 |
|
---|
37 | Dialog::Dialog()
|
---|
38 | {
|
---|
39 | }
|
---|
40 |
|
---|
41 | Dialog::~Dialog()
|
---|
42 | {
|
---|
43 | list<Query*>::iterator iter;
|
---|
44 | for(iter=queries.begin();iter!=queries.end();iter++){
|
---|
45 | delete (*iter);
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | void Dialog::registerQuery(Query *query){
|
---|
50 | queries.push_back(query);
|
---|
51 | }
|
---|
52 |
|
---|
53 | bool Dialog::display(){
|
---|
54 | if(checkAll()){
|
---|
55 | setAll();
|
---|
56 | return true;
|
---|
57 | }
|
---|
58 | else{
|
---|
59 | return false;
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | bool Dialog::checkAll(){
|
---|
64 | list<Query*>::iterator iter;
|
---|
65 | bool retval = true;
|
---|
66 | for(iter=queries.begin(); iter!=queries.end(); iter++){
|
---|
67 | retval &= (*iter)->handle();
|
---|
68 | // if any query fails (is canceled), we can end the handling process
|
---|
69 | if(!retval) {
|
---|
70 | ELOG(1, "The following query failed: " << (**iter).getTitle() << ".");
|
---|
71 | break;
|
---|
72 | }
|
---|
73 | }
|
---|
74 | return retval;
|
---|
75 | }
|
---|
76 |
|
---|
77 | void Dialog::setAll(){
|
---|
78 | list<Query*>::iterator iter;
|
---|
79 | for(iter=queries.begin(); iter!=queries.end(); iter++) {
|
---|
80 | (*iter)->setResult();
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | bool Dialog::hasQueries(){
|
---|
85 | return queries.size();
|
---|
86 | }
|
---|
87 |
|
---|
88 | template <> void Dialog::query<void *>(const char *token, std::string description)
|
---|
89 | {
|
---|
90 | queryEmpty(token, description);
|
---|
91 | }
|
---|
92 |
|
---|
93 | template <> void Dialog::query<bool>(const char *token, std::string description)
|
---|
94 | {
|
---|
95 | queryBoolean(token, description);
|
---|
96 | }
|
---|
97 |
|
---|
98 | template <> void Dialog::query<int>(const char *token, std::string description)
|
---|
99 | {
|
---|
100 | queryInt(token, description);
|
---|
101 | }
|
---|
102 |
|
---|
103 | template <> void Dialog::query< std::vector<int> >(const char *token, std::string description)
|
---|
104 | {
|
---|
105 | queryInts(token, description);
|
---|
106 | }
|
---|
107 |
|
---|
108 | template <> void Dialog::query<unsigned int>(const char *token, std::string description)
|
---|
109 | {
|
---|
110 | queryUnsignedInt(token, description);
|
---|
111 | }
|
---|
112 |
|
---|
113 | template <> void Dialog::query< std::vector<unsigned int> >(const char *token, std::string description)
|
---|
114 | {
|
---|
115 | queryUnsignedInts(token, description);
|
---|
116 | }
|
---|
117 |
|
---|
118 | template <> void Dialog::query<double>(const char *token, std::string description)
|
---|
119 | {
|
---|
120 | queryDouble(token, description);
|
---|
121 | }
|
---|
122 |
|
---|
123 | template <> void Dialog::query< std::vector<double> >(const char *token, std::string description)
|
---|
124 | {
|
---|
125 | queryDoubles(token, description);
|
---|
126 | }
|
---|
127 |
|
---|
128 | template <> void Dialog::query<std::string>(const char *token, std::string description)
|
---|
129 | {
|
---|
130 | queryString(token, description);
|
---|
131 | }
|
---|
132 |
|
---|
133 | template <> void Dialog::query< std::vector<std::string> >(const char *token, std::string description)
|
---|
134 | {
|
---|
135 | queryStrings(token, description);
|
---|
136 | }
|
---|
137 |
|
---|
138 | template <> void Dialog::query<const atom *>(const char *token, std::string description)
|
---|
139 | {
|
---|
140 | queryAtom(token, description);
|
---|
141 | }
|
---|
142 |
|
---|
143 | template <> void Dialog::query< std::vector<const atom *> >(const char *token, std::string description)
|
---|
144 | {
|
---|
145 | queryAtoms(token, description);
|
---|
146 | }
|
---|
147 |
|
---|
148 | template <> void Dialog::query<const molecule *>(const char *token, std::string description)
|
---|
149 | {
|
---|
150 | queryMolecule(token, description);
|
---|
151 | }
|
---|
152 |
|
---|
153 | template <> void Dialog::query< std::vector<const molecule *> >(const char *token, std::string description)
|
---|
154 | {
|
---|
155 | queryMolecules(token, description);
|
---|
156 | }
|
---|
157 |
|
---|
158 | template <> void Dialog::query<Vector>(const char *token, std::string description)
|
---|
159 | {
|
---|
160 | queryVector(token, false, description);
|
---|
161 | }
|
---|
162 |
|
---|
163 | template <> void Dialog::query< std::vector<Vector> >(const char *token, std::string description)
|
---|
164 | {
|
---|
165 | queryVectors(token, false, description);
|
---|
166 | }
|
---|
167 |
|
---|
168 | template <> void Dialog::query<BoxVector>(const char *token, std::string description)
|
---|
169 | {
|
---|
170 | queryVector(token, true, description);
|
---|
171 | }
|
---|
172 |
|
---|
173 | template <> void Dialog::query< std::vector<BoxVector> >(const char *token, std::string description)
|
---|
174 | {
|
---|
175 | queryVectors(token, true, description);
|
---|
176 | }
|
---|
177 |
|
---|
178 | template <> void Dialog::query<Box>(const char *token, std::string description)
|
---|
179 | {
|
---|
180 | queryBox(token, description);
|
---|
181 | }
|
---|
182 |
|
---|
183 | template <> void Dialog::query<const element *>(const char *token, std::string description)
|
---|
184 | {
|
---|
185 | queryElement(token, description);
|
---|
186 | }
|
---|
187 |
|
---|
188 | template <> void Dialog::query< std::vector<const element *> >(const char *token, std::string description)
|
---|
189 | {
|
---|
190 | queryElements(token, description);
|
---|
191 | }
|
---|
192 |
|
---|
193 | template <> void Dialog::query< boost::filesystem::path >(const char *token, std::string description)
|
---|
194 | {
|
---|
195 | queryFile(token, description);
|
---|
196 | }
|
---|
197 |
|
---|
198 | template <> void Dialog::query< std::vector<boost::filesystem::path> >(const char *token, std::string description)
|
---|
199 | {
|
---|
200 | queryFiles(token, description);
|
---|
201 | }
|
---|
202 |
|
---|
203 | template <> void Dialog::query< RandomNumberDistribution_Parameters >(const char *token, std::string description)
|
---|
204 | {
|
---|
205 | queryRandomNumberDistribution_Parameters(token, description);
|
---|
206 | }
|
---|
207 |
|
---|
208 | /************************** Query Infrastructure ************************/
|
---|
209 | /* ---> shifted to folder Query */
|
---|
210 | /************************************************************************/
|
---|