source: src/UIElements/Dialog.cpp@ e3e6e2

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since e3e6e2 was 9ee38b, checked in by Frederik Heber <heber@…>, 15 years ago

Extended macro framework.

Extensions:

  • all central definitions reside in .def files
    • This if file is necessary because we need the definitions at two places: hpp and cpp
    • And as we always use the same define names, we have to undefine them at the end of both (otherwise we get compiler warnings and are prone to dumb mistakes of forgotten defines seeming present)
  • the .hpp is just a very tiny header, that should be possible to batch- construct inside Makefile as well
  • .cpp includes some Action_...hpp files and implements the function

For later (i.e. when ActionRegistry becomes prototype copier)

  • instead of waiting for clone(), for now we simply call the prototype.
  • in the action command we must not yet prefix paramreferences with "params."

Changes:

  • Dialog::query<> is a template which is specialized for every present query...() function. We need it to automatize fillDialog()
  • all AnalysisAction's are now converted, i.e. framework is functional with parameters and queries (MolecularVolume had none).
  • Property mode set to 100644
File size: 8.8 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 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 "Helpers/MemDebug.hpp"
21
22#include "Dialog.hpp"
23#include "Actions/ValueStorage.hpp"
24
25#include "Helpers/Verbose.hpp"
26#include "atom.hpp"
27#include "Box.hpp"
28#include "element.hpp"
29#include "molecule.hpp"
30#include "LinearAlgebra/Vector.hpp"
31#include "LinearAlgebra/Matrix.hpp"
32
33using namespace std;
34
35Dialog::Dialog()
36{
37}
38
39Dialog::~Dialog()
40{
41 list<Query*>::iterator iter;
42 for(iter=queries.begin();iter!=queries.end();iter++){
43 delete (*iter);
44 }
45}
46
47void Dialog::registerQuery(Query *query){
48 queries.push_back(query);
49}
50
51bool Dialog::display(){
52 if(checkAll()){
53 setAll();
54 return true;
55 }
56 else{
57 return false;
58 }
59}
60
61bool Dialog::checkAll(){
62 list<Query*>::iterator iter;
63 bool retval = true;
64 for(iter=queries.begin(); iter!=queries.end(); iter++){
65 retval &= (*iter)->handle();
66 // if any query fails (is canceled), we can end the handling process
67 if(!retval) {
68 DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl);
69 break;
70 }
71 }
72 return retval;
73}
74
75void Dialog::setAll(){
76 list<Query*>::iterator iter;
77 for(iter=queries.begin(); iter!=queries.end(); iter++) {
78 (*iter)->setResult();
79 }
80}
81
82bool Dialog::hasQueries(){
83 return queries.size();
84}
85
86template <> void Dialog::query<void *>(const char *token, std::string description)
87{
88 queryEmpty(token, description);
89}
90
91template <> void Dialog::query<bool>(const char *token, std::string description)
92{
93 queryBoolean(token, description);
94}
95
96template <> void Dialog::query<int>(const char *token, std::string description)
97{
98 queryInt(token, description);
99}
100
101template <> void Dialog::query< std::vector<int> >(const char *token, std::string description)
102{
103 queryInts(token, description);
104}
105
106template <> void Dialog::query<double>(const char *token, std::string description)
107{
108 queryDouble(token, description);
109}
110
111template <> void Dialog::query< std::vector<double> >(const char *token, std::string description)
112{
113 queryDoubles(token, description);
114}
115
116template <> void Dialog::query<std::string>(const char *token, std::string description)
117{
118 queryString(token, description);
119}
120
121template <> void Dialog::query< std::vector<std::string> >(const char *token, std::string description)
122{
123 queryStrings(token, description);
124}
125
126template <> void Dialog::query<atom *>(const char *token, std::string description)
127{
128 queryAtom(token, description);
129}
130
131template <> void Dialog::query< std::vector<atom *> >(const char *token, std::string description)
132{
133 queryAtoms(token, description);
134}
135
136template <> void Dialog::query<molecule *>(const char *token, std::string description)
137{
138 queryMolecule(token, description);
139}
140
141template <> void Dialog::query< std::vector<molecule *> >(const char *token, std::string description)
142{
143 queryMolecules(token, description);
144}
145
146template <> void Dialog::query<Vector>(const char *token, std::string description)
147{
148 queryVector(token, false, description);
149}
150
151template <> void Dialog::query< std::vector<Vector> >(const char *token, std::string description)
152{
153 queryVectors(token, false, description);
154}
155
156template <> void Dialog::query<Box>(const char *token, std::string description)
157{
158 queryBox(token, description);
159}
160
161template <> void Dialog::query<const element *>(const char *token, std::string description)
162{
163 queryElement(token, description);
164}
165
166template <> void Dialog::query< std::vector<const element *> >(const char *token, std::string description)
167{
168 queryElements(token, description);
169}
170
171/****************** Query types Infrastructure **************************/
172
173// Base class
174Dialog::Query::Query(string _title, string _description) :
175 title(_title),
176 description(_description)
177{}
178
179Dialog::Query::~Query() {}
180
181const std::string Dialog::Query::getTitle() const{
182 return title;
183}
184
185const std::string Dialog::Query::getDescription() const{
186 return description;
187}
188// empty Queries
189
190Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
191 Query(title, description)
192{}
193
194Dialog::EmptyQuery::~EmptyQuery() {}
195
196void Dialog::EmptyQuery::setResult() {
197}
198
199// Int Queries
200
201Dialog::IntQuery::IntQuery(string title, std::string description) :
202 Query(title, description)
203{}
204
205Dialog::IntQuery::~IntQuery() {}
206
207void Dialog::IntQuery::setResult() {
208 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
209}
210
211// Ints Queries
212
213Dialog::IntsQuery::IntsQuery(string title, std::string description) :
214 Query(title, description)
215{}
216
217Dialog::IntsQuery::~IntsQuery() {}
218
219void Dialog::IntsQuery::setResult() {
220 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
221}
222
223// Bool Queries
224
225Dialog::BooleanQuery::BooleanQuery(string title,std::string description) :
226 Query(title, description)
227{}
228
229Dialog::BooleanQuery::~BooleanQuery() {}
230
231void Dialog::BooleanQuery::setResult() {
232 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
233}
234
235// String Queries
236
237Dialog::StringQuery::StringQuery(string title,std::string _description) :
238 Query(title, _description)
239{}
240
241Dialog::StringQuery::~StringQuery() {};
242
243void Dialog::StringQuery::setResult() {
244 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
245}
246
247// Strings Queries
248
249Dialog::StringsQuery::StringsQuery(string title,std::string _description) :
250 Query(title, _description)
251{}
252
253Dialog::StringsQuery::~StringsQuery() {};
254
255void Dialog::StringsQuery::setResult() {
256 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
257}
258
259// Double Queries
260
261Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) :
262 Query(title, _description)
263{}
264
265Dialog::DoubleQuery::~DoubleQuery() {};
266
267void Dialog::DoubleQuery::setResult() {
268 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
269}
270
271// Doubles Queries
272
273Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) :
274 Query(title, _description)
275{}
276
277Dialog::DoublesQuery::~DoublesQuery() {};
278
279void Dialog::DoublesQuery::setResult() {
280 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
281}
282
283
284// Atom Queries
285
286Dialog::AtomQuery::AtomQuery(string title, std::string _description) :
287 Query(title, _description),
288 tmp(0)
289{}
290
291Dialog::AtomQuery::~AtomQuery() {}
292
293void Dialog::AtomQuery::setResult() {
294 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
295}
296
297// Atoms Queries
298
299Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) :
300 Query(title, _description),
301 tmp(0)
302{}
303
304Dialog::AtomsQuery::~AtomsQuery() {}
305
306void Dialog::AtomsQuery::setResult() {
307 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
308}
309
310// Molecule Queries
311
312Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) :
313 Query(title, _description),
314 tmp(0)
315{}
316
317Dialog::MoleculeQuery::~MoleculeQuery() {}
318
319void Dialog::MoleculeQuery::setResult() {
320 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
321}
322
323// Molecules Queries
324
325Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) :
326 Query(title, _description),
327 tmp(0)
328{}
329
330Dialog::MoleculesQuery::~MoleculesQuery() {}
331
332void Dialog::MoleculesQuery::setResult() {
333 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
334}
335
336// Vector Queries
337
338Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) :
339 Query(title, _description),
340 check(_check)
341{}
342
343Dialog::VectorQuery::~VectorQuery()
344{}
345
346void Dialog::VectorQuery::setResult() {
347 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
348}
349
350// Vectors Queries
351
352Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) :
353 Query(title, _description),
354 check(_check)
355{}
356
357Dialog::VectorsQuery::~VectorsQuery()
358{}
359
360void Dialog::VectorsQuery::setResult() {
361 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
362}
363
364// Box Queries
365
366Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) :
367 Query(title, _description)
368{}
369
370Dialog::BoxQuery::~BoxQuery()
371{}
372
373void Dialog::BoxQuery::setResult() {
374 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
375}
376
377// Element Queries
378Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) :
379 Query(title, _description)
380 {}
381
382Dialog::ElementQuery::~ElementQuery(){}
383
384void Dialog::ElementQuery::setResult(){
385 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
386}
387
388// Elements Queries
389Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) :
390 Query(title, _description)
391 {}
392
393Dialog::ElementsQuery::~ElementsQuery(){}
394
395void Dialog::ElementsQuery::setResult(){
396 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
397}
Note: See TracBrowser for help on using the repository browser.