source: src/UIElements/Dialog.cpp@ 52575c

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 52575c was 852ea3, checked in by Michael Ankele <ankele@…>, 12 years ago

further query merging (QtQuery added, handle() won't use param.set())

  • Property mode set to 100644
File size: 6.3 KB
Line 
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
24#include "CodePatterns/Log.hpp"
25#include "CodePatterns/Verbose.hpp"
26
27#include "Parameters/ParameterExceptions.hpp"
28
29class Atom;
30class element;
31class RealSpaceMatrix;
32class molecule;
33class Vector;
34
35using namespace std;
36
37Dialog::Dialog()
38{
39}
40
41Dialog::~Dialog()
42{
43 list<Query*>::iterator iter;
44 for(iter=queries.begin();iter!=queries.end();iter++){
45 delete (*iter);
46 }
47}
48
49void Dialog::registerQuery(Query *query){
50 queries.push_back(query);
51}
52
53bool Dialog::display(){
54 handleAll();
55 if(checkAll()){
56 setAll();
57 return true;
58 }
59 else{
60 return false;
61 }
62}
63
64void Dialog::handleAll(){
65 list<Query*>::iterator iter;
66 for(iter=queries.begin(); iter!=queries.end(); iter++){
67 try{
68 (*iter)->handle();
69 }catch(...){
70 // if any query fails (is canceled), we can end the handling process
71 ELOG(1, "The following query failed: " << (**iter).getTitle() << ".");
72 break;
73 }
74 }
75}
76
77bool Dialog::checkAll(){
78 list<Query*>::iterator iter;
79 bool retval = true;
80 for(iter=queries.begin(); iter!=queries.end(); iter++){
81 retval &= (*iter)->isValid();
82 // if any query fails (is canceled), we can end the handling process
83 if(!retval) {
84 ELOG(1, "The following query failed: " << (**iter).getTitle() << ".");
85 break;
86 }
87 }
88 return retval;
89}
90
91void Dialog::setAll(){
92 list<Query*>::iterator iter;
93 for(iter=queries.begin(); iter!=queries.end(); iter++) {
94 try {
95 (*iter)->setResult();
96 } catch (ParameterException &e) {
97 if( const std::string *name=boost::get_error_info<ParameterName>(e) )
98 ELOG(1, "The following parameter value is not valid: " << *name << ".");
99 break;
100 }
101 }
102}
103
104bool Dialog::hasQueries(){
105 return queries.size();
106}
107
108/*template <> void Dialog::query<Dialog::EmptyType>(Parameter<Dialog::EmptyType> &param, const char *token, std::string description)
109{
110 queryEmpty(param, token, description);
111}*/
112
113template <> void Dialog::query<bool>(Parameter<bool> &param, const char *token, std::string description)
114{
115 queryBoolean(param, token, description);
116}
117
118template <> void Dialog::query<int>(Parameter<int> &param, const char *token, std::string description)
119{
120 queryInt(param, token, description);
121}
122
123template <> void Dialog::query< std::vector<int> >(Parameter<std::vector<int> > &param, const char *token, std::string description)
124{
125 queryInts(param, token, description);
126}
127
128template <> void Dialog::query<unsigned int>(Parameter<unsigned int> &param, const char *token, std::string description)
129{
130 queryUnsignedInt(param, token, description);
131}
132
133template <> void Dialog::query< std::vector<unsigned int> >(Parameter<std::vector<unsigned int> > &param, const char *token, std::string description)
134{
135 queryUnsignedInts(param, token, description);
136}
137
138template <> void Dialog::query<double>(Parameter<double> &param, const char *token, std::string description)
139{
140 queryDouble(param, token, description);
141}
142
143template <> void Dialog::query< std::vector<double> >(Parameter<std::vector<double> > &param, const char *token, std::string description)
144{
145 queryDoubles(param, token, description);
146}
147
148template <> void Dialog::query<std::string>(Parameter<std::string> &param, const char *token, std::string description)
149{
150 queryString(param, token, description);
151}
152
153template <> void Dialog::query< std::vector<std::string> >(Parameter<std::vector<std::string> > &param, const char *token, std::string description)
154{
155 queryStrings(param, token, description);
156}
157
158template <> void Dialog::query<const atom *>(Parameter<const atom *> &param, const char *token, std::string description)
159{
160 queryAtom(param, token, description);
161}
162
163template <> void Dialog::query< std::vector<const atom *> >(Parameter<std::vector<const atom *> > &param, const char *token, std::string description)
164{
165 queryAtoms(param, token, description);
166}
167
168template <> void Dialog::query<const molecule *>(Parameter<const molecule *> &param, const char *token, std::string description)
169{
170 queryMolecule(param, token, description);
171}
172
173template <> void Dialog::query< std::vector<const molecule *> >(Parameter<std::vector<const molecule *> > &param, const char *token, std::string description)
174{
175 queryMolecules(param, token, description);
176}
177
178template <> void Dialog::query<Vector>(Parameter<Vector> &param, const char *token, std::string description)
179{
180 queryVector(param, token, description);
181}
182
183template <> void Dialog::query< std::vector<Vector> >(Parameter<std::vector<Vector> > &param, const char *token, std::string description)
184{
185 queryVectors(param, token, description);
186}
187
188template <> void Dialog::query<RealSpaceMatrix>(Parameter<RealSpaceMatrix> &param, const char *token, std::string description)
189{
190 queryRealSpaceMatrix(param, token, description);
191}
192
193template <> void Dialog::query<const element *>(Parameter<const element *> &param, const char *token, std::string description)
194{
195 queryElement(param, token, description);
196}
197
198template <> void Dialog::query< std::vector<const element *> >(Parameter<std::vector<const element *> > &param, const char *token, std::string description)
199{
200 queryElements(param, token, description);
201}
202
203template <> void Dialog::query< boost::filesystem::path >(Parameter<boost::filesystem::path> &param, const char *token, std::string description)
204{
205 queryFile(param, token, description);
206}
207
208template <> void Dialog::query< std::vector<boost::filesystem::path> >(Parameter<std::vector< boost::filesystem::path> > &param, const char *token, std::string description)
209{
210 queryFiles(param, token, description);
211}
212
213template <> void Dialog::query< RandomNumberDistribution_Parameters >(Parameter<RandomNumberDistribution_Parameters> &param, const char *token, std::string description)
214{
215 queryRandomNumberDistribution_Parameters(param, token, description);
216}
217
218/************************** Query Infrastructure ************************/
219/* ---> shifted to folder Query */
220/************************************************************************/
Note: See TracBrowser for help on using the repository browser.