source: src/UIElements/Dialog.cpp@ f4b5b7

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

libMolecuilderAction is now a shared lib via libtool.

This is all taken from the example available at http://www.openismus.com/documents/linux/building_libraries/building_libraries/building_libraries.shtml.

Necessary changes:

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