source: src/UIElements/Dialog.cpp@ 9d5531

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

VectorQuery: removed obsolete _check parameter

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