source: src/UIElements/Dialog.cpp@ b2a7cc

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

drop unused references to ValueStorage

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