source: src/UIElements/Dialog.cpp@ 5079a0

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

Actions put into libMolecuilderActions, UIElements into libMolecuilderUI

  • due to great number of Actions it is sensible to put them into their own library
  • this is advantageous overall, but right now especially as all the unit tests do not depend on this lib.
  • it was also needed as Actions depend on UIElements and to resolve to correct ordering, UIElements have to be available before the libMolecuilderActions is aded (if compiled into libmolecuilder it is appended after!)
  • Property mode set to 100644
File size: 4.0 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 break;
43 }
44 if (retval){
45 // if all queries succeeded we can set the targets to appropriate values
46 for(iter=queries.begin(); iter!=queries.end(); iter++) {
47 (*iter)->setResult();
48 }
49 }
50 return retval;
51}
52
53/****************** Query types Infrastructure **************************/
54
55// Base class
56Dialog::Query::Query(string _title, string _description) :
57 title(_title),
58 description(_description)
59{}
60
61Dialog::Query::~Query() {}
62
63const std::string Dialog::Query::getTitle() const{
64 return title;
65}
66
67const std::string Dialog::Query::getDescription() const{
68 return description;
69}
70// empty Queries
71
72Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
73 Query(title, description)
74{}
75
76Dialog::EmptyQuery::~EmptyQuery() {}
77
78void Dialog::EmptyQuery::setResult() {
79}
80
81// Int Queries
82
83Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) :
84 Query(title, description), target(_target)
85{}
86
87Dialog::IntQuery::~IntQuery() {}
88
89void Dialog::IntQuery::setResult() {
90 *target = tmp;
91}
92
93// Int Queries
94
95Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) :
96 Query(title, description), target(_target)
97{}
98
99Dialog::BooleanQuery::~BooleanQuery() {}
100
101void Dialog::BooleanQuery::setResult() {
102 *target = tmp;
103}
104
105// String Queries
106
107Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) :
108 Query(title, _description), target(_target)
109{}
110
111Dialog::StringQuery::~StringQuery() {};
112
113void Dialog::StringQuery::setResult() {
114 *target = tmp;
115}
116
117// Double Queries
118
119Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) :
120 Query(title, _description), target(_target)
121{}
122
123Dialog::DoubleQuery::~DoubleQuery() {};
124
125void Dialog::DoubleQuery::setResult() {
126 *target = tmp;
127}
128
129
130// Atom Queries
131
132Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) :
133 Query(title, _description),
134 tmp(0),
135 target(_target)
136
137{}
138
139Dialog::AtomQuery::~AtomQuery() {}
140
141void Dialog::AtomQuery::setResult() {
142 *target = tmp;
143}
144
145// Molecule Queries
146
147Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) :
148 Query(title, _description),
149 tmp(0),
150 target(_target)
151
152{}
153
154Dialog::MoleculeQuery::~MoleculeQuery() {}
155
156void Dialog::MoleculeQuery::setResult() {
157 *target = tmp;
158}
159
160// Vector Queries
161
162Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) :
163 Query(title, _description),
164 cellSize(_cellSize),
165 check(_check),
166 target(_target)
167{
168tmp = new Vector();
169}
170
171Dialog::VectorQuery::~VectorQuery()
172{
173 delete tmp;
174}
175
176void Dialog::VectorQuery::setResult() {
177 *target = *tmp;
178}
179
180// Box Queries
181
182Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) :
183 Query(title, _description),
184 target(_cellSize)
185{
186 tmp = new double[6];
187}
188
189Dialog::BoxQuery::~BoxQuery()
190{
191 delete[] tmp;
192}
193
194void Dialog::BoxQuery::setResult() {
195 for (int i=0;i<6;i++)
196 *target[i] = tmp[i];
197}
198
199// Element Queries
200Dialog::ElementQuery::ElementQuery(std::string title, const element **_target, std::string _description) :
201 Query(title, _description),
202 tmp(0),
203 target(_target)
204 {}
205
206Dialog::ElementQuery::~ElementQuery(){}
207
208void Dialog::ElementQuery::setResult(){
209 *target=tmp;
210}
Note: See TracBrowser for help on using the repository browser.