source: src/UIElements/Dialog.cpp@ 8ea3e7

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 Candidate_v1.7.0 Candidate_v1.7.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 8ea3e7 was e45c1d, checked in by Frederik Heber <heber@…>, 14 years ago

Added ParameterExceptions, is caught by Dialog::checkAll() for the moment.

  • Property mode set to 100644
File size: 6.4 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
[0aa122]4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
[bcf653]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
[ad011c]20#include "CodePatterns/MemDebug.hpp"
[112b09]21
[5079a0]22#include "Dialog.hpp"
[861874]23#include "Actions/ValueStorage.hpp"
[f5a86a]24
[ad011c]25#include "CodePatterns/Log.hpp"
26#include "CodePatterns/Verbose.hpp"
[8df74d]27
[e45c1d]28#include "Parameters/ParameterExceptions.hpp"
29
[8df74d]30class Atom;
31class Box;
32class element;
[cca9ef]33class RealSpaceMatrix;
[8df74d]34class molecule;
35class Vector;
[2ededc2]36
[f5a86a]37using namespace std;
38
39Dialog::Dialog()
40{
41}
42
43Dialog::~Dialog()
44{
[45f5d6]45 list<Query*>::iterator iter;
46 for(iter=queries.begin();iter!=queries.end();iter++){
47 delete (*iter);
48 }
[f5a86a]49}
50
[45f5d6]51void Dialog::registerQuery(Query *query){
52 queries.push_back(query);
53}
[f5a86a]54
[45f5d6]55bool Dialog::display(){
[d3a5ea]56 if(checkAll()){
57 setAll();
58 return true;
59 }
60 else{
61 return false;
62 }
63}
64
65bool Dialog::checkAll(){
[45f5d6]66 list<Query*>::iterator iter;
67 bool retval = true;
68 for(iter=queries.begin(); iter!=queries.end(); iter++){
[e45c1d]69 try {
70 retval &= (*iter)->handle();
71 } catch (ParameterException &e) {
72 if( const std::string *name=boost::get_error_info<ParameterName>(e) )
73 ELOG(1, "The following parameter value is not valid: " << *name << ".");
74 retval = false;
75 break;
76 }
[45f5d6]77 // if any query fails (is canceled), we can end the handling process
[94d131]78 if(!retval) {
[47d041]79 ELOG(1, "The following query failed: " << (**iter).getTitle() << ".");
[45f5d6]80 break;
[94d131]81 }
[45f5d6]82 }
83 return retval;
[f5a86a]84}
85
[d3a5ea]86void Dialog::setAll(){
87 list<Query*>::iterator iter;
88 for(iter=queries.begin(); iter!=queries.end(); iter++) {
[e45c1d]89 try {
90 (*iter)->setResult();
91 } catch (ParameterException &e) {
92 if( const std::string *name=boost::get_error_info<ParameterName>(e) )
93 ELOG(1, "The following parameter value is not valid: " << *name << ".");
94 break;
95 }
[d3a5ea]96 }
97}
98
[c508ef5]99bool Dialog::hasQueries(){
100 return queries.size();
101}
102
[f10b0c]103template <> void Dialog::query<void *>(Parameter<void *> &param, const char *token, std::string description)
[9ee38b]104{
105 queryEmpty(token, description);
106}
107
[f10b0c]108template <> void Dialog::query<bool>(Parameter<bool> &param, const char *token, std::string description)
[9ee38b]109{
[f10b0c]110 queryBoolean(param, token, description);
[9ee38b]111}
112
[f10b0c]113template <> void Dialog::query<int>(Parameter<int> &param, const char *token, std::string description)
[9ee38b]114{
[f10b0c]115 queryInt(param, token, description);
[9ee38b]116}
117
[f10b0c]118template <> void Dialog::query< std::vector<int> >(Parameter<std::vector<int> > &param, const char *token, std::string description)
[9ee38b]119{
[f10b0c]120 queryInts(param, token, description);
[9ee38b]121}
122
[f10b0c]123template <> void Dialog::query<unsigned int>(Parameter<unsigned int> &param, const char *token, std::string description)
[838cd0]124{
[f10b0c]125 queryUnsignedInt(param, token, description);
[838cd0]126}
127
[f10b0c]128template <> void Dialog::query< std::vector<unsigned int> >(Parameter<std::vector<unsigned int> > &param, const char *token, std::string description)
[12948c]129{
[f10b0c]130 queryUnsignedInts(param, token, description);
[12948c]131}
132
[f10b0c]133template <> void Dialog::query<double>(Parameter<double> &param, const char *token, std::string description)
[9ee38b]134{
[f10b0c]135 queryDouble(param, token, description);
[9ee38b]136}
137
[f10b0c]138template <> void Dialog::query< std::vector<double> >(Parameter<std::vector<double> > &param, const char *token, std::string description)
[9ee38b]139{
[f10b0c]140 queryDoubles(param, token, description);
[9ee38b]141}
142
[f10b0c]143template <> void Dialog::query<std::string>(Parameter<std::string> &param, const char *token, std::string description)
[9ee38b]144{
[f10b0c]145 queryString(param, token, description);
[9ee38b]146}
147
[f10b0c]148template <> void Dialog::query< std::vector<std::string> >(Parameter<std::vector<std::string> > &param, const char *token, std::string description)
[9ee38b]149{
[f10b0c]150 queryStrings(param, token, description);
[9ee38b]151}
152
[f10b0c]153template <> void Dialog::query<const atom *>(Parameter<const atom *> &param, const char *token, std::string description)
[9ee38b]154{
[f10b0c]155 queryAtom(param, token, description);
[9ee38b]156}
157
[f10b0c]158template <> void Dialog::query< std::vector<const atom *> >(Parameter<std::vector<const atom *> > &param, const char *token, std::string description)
[9ee38b]159{
[f10b0c]160 queryAtoms(param, token, description);
[9ee38b]161}
162
[f10b0c]163template <> void Dialog::query<const molecule *>(Parameter<const molecule *> &param, const char *token, std::string description)
[9ee38b]164{
[f10b0c]165 queryMolecule(param, token, description);
[9ee38b]166}
167
[f10b0c]168template <> void Dialog::query< std::vector<const molecule *> >(Parameter<std::vector<const molecule *> > &param, const char *token, std::string description)
[9ee38b]169{
[f10b0c]170 queryMolecules(param, token, description);
[9ee38b]171}
172
[f10b0c]173template <> void Dialog::query<Vector>(Parameter<Vector> &param, const char *token, std::string description)
[9ee38b]174{
[f10b0c]175 queryVector(param, token, false, description);
[9ee38b]176}
177
[f10b0c]178template <> void Dialog::query< std::vector<Vector> >(Parameter<std::vector<Vector> > &param, const char *token, std::string description)
[9ee38b]179{
[f10b0c]180 queryVectors(param, token, false, description);
[9ee38b]181}
182
[f10b0c]183template <> void Dialog::query<BoxVector>(Parameter<BoxVector> &param, const char *token, std::string description)
[72f611]184{
[f10b0c]185 ASSERT(0, "TODO: query<BoxVector>");
186 //queryVector(param, token, true, description);
[72f611]187}
188
[f10b0c]189template <> void Dialog::query< std::vector<BoxVector> >(Parameter<std::vector<BoxVector> > &param, const char *token, std::string description)
[72f611]190{
[f10b0c]191 ASSERT(0, "TODO: query<vector<BoxVector> >");
192 //queryVectors(param, token, true, description);
[72f611]193}
194
[f10b0c]195template <> void Dialog::query<Box>(Parameter<Box> &param, const char *token, std::string description)
[9ee38b]196{
[f10b0c]197 queryBox(param, token, description);
[9ee38b]198}
199
[f10b0c]200template <> void Dialog::query<const element *>(Parameter<const element *> &param, const char *token, std::string description)
[9ee38b]201{
[f10b0c]202 queryElement(param, token, description);
[9ee38b]203}
204
[f10b0c]205template <> void Dialog::query< std::vector<const element *> >(Parameter<std::vector<const element *> > &param, const char *token, std::string description)
[9ee38b]206{
[f10b0c]207 queryElements(param, token, description);
[9ee38b]208}
209
[f10b0c]210template <> void Dialog::query< boost::filesystem::path >(Parameter<boost::filesystem::path> &param, const char *token, std::string description)
[6f5dfe]211{
[f10b0c]212 queryFile(param, token, description);
[6f5dfe]213}
214
[f10b0c]215template <> void Dialog::query< RandomNumberDistribution_Parameters >(Parameter<RandomNumberDistribution_Parameters> &param, const char *token, std::string description)
[0275ad]216{
[f10b0c]217 queryRandomNumberDistribution_Parameters(param, token, description);
[0275ad]218}
219
[8df74d]220/************************** Query Infrastructure ************************/
221/* ---> shifted to folder Query */
222/************************************************************************/
Note: See TracBrowser for help on using the repository browser.