source: src/UIElements/Dialog.cpp@ 906822

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 906822 was e6317b, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Broken: Merge commit 'Gitosis/stable' into stable

Conflicts:

molecuilder/src/Actions/AnalysisAction/PairCorrelationToPointAction.cpp
molecuilder/src/Actions/AnalysisAction/PairCorrelationToSurfaceAction.cpp
molecuilder/src/Makefile.am

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