source: src/UIElements/Dialog.cpp@ c31fbd

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 c31fbd was 7d9416, checked in by Frederik Heber <heber@…>, 13 years ago

Turned query<Box> into query<RealSpaceMatrix>

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