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

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 9cd807 was bf3817, checked in by Frederik Heber <heber@…>, 14 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

  • is now topmost in front of MemDebug.hpp (and any other).
  • Property mode set to 100644
File size: 6.4 KB
Line 
1/*
2 * Dialog.cpp
3 *
4 * Created on: Jan 5, 2010
5 * Author: crueger
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include "Helpers/MemDebug.hpp"
14
15#include "Dialog.hpp"
16#include "Actions/ValueStorage.hpp"
17
18#include "Helpers/Verbose.hpp"
19#include "atom.hpp"
20#include "element.hpp"
21#include "molecule.hpp"
22#include "LinearAlgebra/Vector.hpp"
23#include "LinearAlgebra/Matrix.hpp"
24#include "Box.hpp"
25
26using namespace std;
27
28Dialog::Dialog()
29{
30}
31
32Dialog::~Dialog()
33{
34 list<Query*>::iterator iter;
35 for(iter=queries.begin();iter!=queries.end();iter++){
36 delete (*iter);
37 }
38}
39
40void Dialog::registerQuery(Query *query){
41 queries.push_back(query);
42}
43
44bool Dialog::display(){
45 if(checkAll()){
46 setAll();
47 return true;
48 }
49 else{
50 return false;
51 }
52}
53
54bool Dialog::checkAll(){
55 list<Query*>::iterator iter;
56 bool retval = true;
57 for(iter=queries.begin(); iter!=queries.end(); iter++){
58 retval &= (*iter)->handle();
59 // if any query fails (is canceled), we can end the handling process
60 if(!retval) {
61 DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl);
62 break;
63 }
64 }
65 return retval;
66}
67
68void Dialog::setAll(){
69 list<Query*>::iterator iter;
70 for(iter=queries.begin(); iter!=queries.end(); iter++) {
71 (*iter)->setResult();
72 }
73}
74
75bool Dialog::hasQueries(){
76 return queries.size();
77}
78
79/****************** Query types Infrastructure **************************/
80
81// Base class
82Dialog::Query::Query(string _title, string _description) :
83 title(_title),
84 description(_description)
85{}
86
87Dialog::Query::~Query() {}
88
89const std::string Dialog::Query::getTitle() const{
90 return title;
91}
92
93const std::string Dialog::Query::getDescription() const{
94 return description;
95}
96// empty Queries
97
98Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
99 Query(title, description)
100{}
101
102Dialog::EmptyQuery::~EmptyQuery() {}
103
104void Dialog::EmptyQuery::setResult() {
105}
106
107// Int Queries
108
109Dialog::IntQuery::IntQuery(string title, std::string description) :
110 Query(title, description)
111{}
112
113Dialog::IntQuery::~IntQuery() {}
114
115void Dialog::IntQuery::setResult() {
116 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
117}
118
119// Ints Queries
120
121Dialog::IntsQuery::IntsQuery(string title, std::string description) :
122 Query(title, description)
123{}
124
125Dialog::IntsQuery::~IntsQuery() {}
126
127void Dialog::IntsQuery::setResult() {
128 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
129}
130
131// Bool Queries
132
133Dialog::BooleanQuery::BooleanQuery(string title,std::string description) :
134 Query(title, description)
135{}
136
137Dialog::BooleanQuery::~BooleanQuery() {}
138
139void Dialog::BooleanQuery::setResult() {
140 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
141}
142
143// String Queries
144
145Dialog::StringQuery::StringQuery(string title,std::string _description) :
146 Query(title, _description)
147{}
148
149Dialog::StringQuery::~StringQuery() {};
150
151void Dialog::StringQuery::setResult() {
152 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
153}
154
155// Strings Queries
156
157Dialog::StringsQuery::StringsQuery(string title,std::string _description) :
158 Query(title, _description)
159{}
160
161Dialog::StringsQuery::~StringsQuery() {};
162
163void Dialog::StringsQuery::setResult() {
164 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
165}
166
167// Double Queries
168
169Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) :
170 Query(title, _description)
171{}
172
173Dialog::DoubleQuery::~DoubleQuery() {};
174
175void Dialog::DoubleQuery::setResult() {
176 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
177}
178
179// Doubles Queries
180
181Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) :
182 Query(title, _description)
183{}
184
185Dialog::DoublesQuery::~DoublesQuery() {};
186
187void Dialog::DoublesQuery::setResult() {
188 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
189}
190
191
192// Atom Queries
193
194Dialog::AtomQuery::AtomQuery(string title, std::string _description) :
195 Query(title, _description),
196 tmp(0)
197{}
198
199Dialog::AtomQuery::~AtomQuery() {}
200
201void Dialog::AtomQuery::setResult() {
202 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
203}
204
205// Atoms Queries
206
207Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) :
208 Query(title, _description),
209 tmp(0)
210{}
211
212Dialog::AtomsQuery::~AtomsQuery() {}
213
214void Dialog::AtomsQuery::setResult() {
215 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
216}
217
218// Molecule Queries
219
220Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) :
221 Query(title, _description),
222 tmp(0)
223{}
224
225Dialog::MoleculeQuery::~MoleculeQuery() {}
226
227void Dialog::MoleculeQuery::setResult() {
228 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
229}
230
231// Molecules Queries
232
233Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) :
234 Query(title, _description),
235 tmp(0)
236{}
237
238Dialog::MoleculesQuery::~MoleculesQuery() {}
239
240void Dialog::MoleculesQuery::setResult() {
241 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
242}
243
244// Vector Queries
245
246Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) :
247 Query(title, _description),
248 check(_check)
249{}
250
251Dialog::VectorQuery::~VectorQuery()
252{}
253
254void Dialog::VectorQuery::setResult() {
255 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
256}
257
258// Vectors Queries
259
260Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) :
261 Query(title, _description),
262 check(_check)
263{}
264
265Dialog::VectorsQuery::~VectorsQuery()
266{}
267
268void Dialog::VectorsQuery::setResult() {
269 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
270}
271
272// Box Queries
273
274Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) :
275 Query(title, _description)
276{}
277
278Dialog::BoxQuery::~BoxQuery()
279{}
280
281void Dialog::BoxQuery::setResult() {
282 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
283}
284
285// Element Queries
286Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) :
287 Query(title, _description)
288 {}
289
290Dialog::ElementQuery::~ElementQuery(){}
291
292void Dialog::ElementQuery::setResult(){
293 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
294}
295
296// Elements Queries
297Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) :
298 Query(title, _description)
299 {}
300
301Dialog::ElementsQuery::~ElementsQuery(){}
302
303void Dialog::ElementsQuery::setResult(){
304 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
305}
Note: See TracBrowser for help on using the repository browser.