source: src/UIElements/TextDialog.cpp@ 5a7243

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

Added a method to query Elements using the Dialog structure

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * TextDialog.cpp
3 *
4 * Created on: Jan 5, 2010
5 * Author: crueger
6 */
7
8#include <iostream>
9
10#include "UIElements/TextDialog.hpp"
11
12#include "World.hpp"
13#include "periodentafel.hpp"
14#include "atom.hpp"
15#include "molecule.hpp"
16#include "log.hpp"
17#include "verbose.hpp"
18
19using namespace std;
20
21
22TextDialog::TextDialog()
23{
24}
25
26TextDialog::~TextDialog()
27{
28}
29
30
31void TextDialog::queryInt(const char* title, int* target){
32 registerQuery(new IntTextQuery(title,target));
33}
34
35void TextDialog::queryDouble(const char* title, double* target){
36 registerQuery(new DoubleTextQuery(title,target));
37}
38
39void TextDialog::queryString(const char* title, string* target){
40 registerQuery(new StringTextQuery(title,target));
41}
42
43void TextDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules) {
44 registerQuery(new MoleculeTextQuery(title,target,molecules));
45}
46
47void TextDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check) {
48 registerQuery(new VectorTextQuery(title,target,cellSize,check));
49}
50
51void TextDialog::queryElement(const char* title, element **target){
52 registerQuery(new ElementTextQuery(title,target));
53}
54
55/************************** Query Infrastructure ************************/
56
57TextDialog::IntTextQuery::IntTextQuery(string title,int *_target) :
58 Dialog::IntQuery(title,_target)
59{}
60
61TextDialog::IntTextQuery::~IntTextQuery() {}
62
63bool TextDialog::IntTextQuery::handle() {
64 Log() << Verbose(0) << getTitle();
65 cin >> tmp;
66 return true;
67}
68
69TextDialog::StringTextQuery::StringTextQuery(string title,string *_target) :
70 Dialog::StringQuery(title,_target)
71{}
72
73TextDialog::StringTextQuery::~StringTextQuery() {}
74
75bool TextDialog::StringTextQuery::handle() {
76 Log() << Verbose(0) << getTitle();
77 cin >> tmp;
78 return true;
79}
80
81TextDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target) :
82 Dialog::DoubleQuery(title,_target)
83{}
84
85TextDialog::DoubleTextQuery::~DoubleTextQuery() {}
86
87bool TextDialog::DoubleTextQuery::handle() {
88 Log() << Verbose(0) << getTitle();
89 cin >> tmp;
90 return true;
91}
92
93TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, MoleculeListClass *_molecules) :
94 Dialog::MoleculeQuery(title,_target,_molecules)
95{}
96
97TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {}
98
99bool TextDialog::MoleculeTextQuery::handle() {
100 int idxOfMol;
101 Log() << Verbose(0) << getTitle();
102 cin >> idxOfMol;
103 tmp = molecules->ReturnIndex(idxOfMol);
104 while(!tmp && (idxOfMol !=-1)) {
105 Log() << Verbose(0) << "Invalid Molecule Index" << endl;
106 Log() << Verbose(0) << getTitle();
107 cin >> idxOfMol;
108 tmp = molecules->ReturnIndex(idxOfMol);
109 }
110 return (idxOfMol!=-1);
111}
112
113TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check) :
114 Dialog::VectorQuery(title,_target,_cellSize,_check)
115{}
116
117TextDialog::VectorTextQuery::~VectorTextQuery()
118{}
119
120bool TextDialog::VectorTextQuery::handle() {
121 Log() << Verbose(0) << getTitle();
122 tmp->AskPosition(cellSize,check);
123 return true;
124}
125
126
127TextDialog::ElementTextQuery::ElementTextQuery(std::string title, element **target) :
128 Dialog::ElementQuery(title,target)
129{}
130
131TextDialog::ElementTextQuery::~ElementTextQuery()
132{}
133
134bool TextDialog::ElementTextQuery::handle() {
135 int Z;
136 Log() << Verbose(0) << getTitle();
137 cin >> Z;
138 tmp = World::get()->getPeriode()->FindElement(Z);
139 return tmp;
140}
Note: See TracBrowser for help on using the repository browser.