source: src/UIElements/Dialog.cpp@ 94d131

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 94d131 was 94d131, checked in by Frederik Heber <heber@…>, 15 years ago

Helpful messages added to find failing queries in CommandLineUI.

  • all ..CommandLineQuery() functions give missing warning on failure
  • Dialog::display() admonished which query failed (and needed to friend of its own Query subclass for that ...)
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * Dialog.cpp
3 *
4 * Created on: Jan 5, 2010
5 * Author: crueger
6 */
7
8#include <cassert>
9
10#include "Dialog.hpp"
11
12#include "atom.hpp"
13#include "element.hpp"
14#include "molecule.hpp"
15#include "vector.hpp"
16
17using namespace std;
18
19Dialog::Dialog()
20{
21}
22
23Dialog::~Dialog()
24{
25 list<Query*>::iterator iter;
26 for(iter=queries.begin();iter!=queries.end();iter++){
27 delete (*iter);
28 }
29}
30
31void Dialog::registerQuery(Query *query){
32 queries.push_back(query);
33}
34
35bool Dialog::display(){
36 list<Query*>::iterator iter;
37 bool retval = true;
38 for(iter=queries.begin(); iter!=queries.end(); iter++){
39 retval &= (*iter)->handle();
40 // if any query fails (is canceled), we can end the handling process
41 if(!retval) {
42 DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl);
43 break;
44 }
45 }
46 if (retval){
47 // if all queries succeeded we can set the targets to appropriate values
48 for(iter=queries.begin(); iter!=queries.end(); iter++) {
49 (*iter)->setResult();
50 }
51 }
52 return retval;
53}
54
55/****************** Query types Infrastructure **************************/
56
57// Base class
58Dialog::Query::Query(string _title, string _description) :
59 title(_title),
60 description(_description)
61{}
62
63Dialog::Query::~Query() {}
64
65const std::string Dialog::Query::getTitle() const{
66 return title;
67}
68
69const std::string Dialog::Query::getDescription() const{
70 return description;
71}
72// empty Queries
73
74Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
75 Query(title, description)
76{}
77
78Dialog::EmptyQuery::~EmptyQuery() {}
79
80void Dialog::EmptyQuery::setResult() {
81}
82
83// Int Queries
84
85Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) :
86 Query(title, description), target(_target)
87{}
88
89Dialog::IntQuery::~IntQuery() {}
90
91void Dialog::IntQuery::setResult() {
92 *target = tmp;
93}
94
95// Int Queries
96
97Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) :
98 Query(title, description), target(_target)
99{}
100
101Dialog::BooleanQuery::~BooleanQuery() {}
102
103void Dialog::BooleanQuery::setResult() {
104 *target = tmp;
105}
106
107// String Queries
108
109Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) :
110 Query(title, _description), target(_target)
111{}
112
113Dialog::StringQuery::~StringQuery() {};
114
115void Dialog::StringQuery::setResult() {
116 *target = tmp;
117}
118
119// Double Queries
120
121Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) :
122 Query(title, _description), target(_target)
123{}
124
125Dialog::DoubleQuery::~DoubleQuery() {};
126
127void Dialog::DoubleQuery::setResult() {
128 *target = tmp;
129}
130
131
132// Atom Queries
133
134Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) :
135 Query(title, _description),
136 tmp(0),
137 target(_target)
138
139{}
140
141Dialog::AtomQuery::~AtomQuery() {}
142
143void Dialog::AtomQuery::setResult() {
144 *target = tmp;
145}
146
147// Molecule Queries
148
149Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) :
150 Query(title, _description),
151 tmp(0),
152 target(_target)
153
154{}
155
156Dialog::MoleculeQuery::~MoleculeQuery() {}
157
158void Dialog::MoleculeQuery::setResult() {
159 *target = tmp;
160}
161
162// Vector Queries
163
164Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) :
165 Query(title, _description),
166 cellSize(_cellSize),
167 check(_check),
168 target(_target)
169{
170 tmp = new Vector();
171}
172
173Dialog::VectorQuery::~VectorQuery()
174{
175 delete tmp;
176}
177
178void Dialog::VectorQuery::setResult() {
179 *target = *tmp;
180}
181
182// Box Queries
183
184Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) :
185 Query(title, _description),
186 target(_cellSize)
187{
188 tmp = new double[6];
189}
190
191Dialog::BoxQuery::~BoxQuery()
192{
193 delete[] tmp;
194}
195
196void Dialog::BoxQuery::setResult() {
197 for (int i=0;i<6;i++) {
198 (*target)[i] = tmp[i];
199 }
200}
201
202// Element Queries
203Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) :
204 Query(title, _description),
205 target(_target)
206 {}
207
208Dialog::ElementQuery::~ElementQuery(){}
209
210void Dialog::ElementQuery::setResult(){
211 *target=elements;
212}
Note: See TracBrowser for help on using the repository browser.