source: src/UIElements/Dialog.cpp@ e5f64de

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

Added copyright note to each .cpp file and an extensive one to builder.cpp.

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