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 |
|
---|
19 | using namespace std;
|
---|
20 |
|
---|
21 |
|
---|
22 | TextDialog::TextDialog()
|
---|
23 | {
|
---|
24 | }
|
---|
25 |
|
---|
26 | TextDialog::~TextDialog()
|
---|
27 | {
|
---|
28 | }
|
---|
29 |
|
---|
30 |
|
---|
31 | void TextDialog::queryInt(const char* title, int* target){
|
---|
32 | registerQuery(new IntTextQuery(title,target));
|
---|
33 | }
|
---|
34 |
|
---|
35 | void TextDialog::queryDouble(const char* title, double* target){
|
---|
36 | registerQuery(new DoubleTextQuery(title,target));
|
---|
37 | }
|
---|
38 |
|
---|
39 | void TextDialog::queryString(const char* title, string* target){
|
---|
40 | registerQuery(new StringTextQuery(title,target));
|
---|
41 | }
|
---|
42 |
|
---|
43 | void TextDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules) {
|
---|
44 | registerQuery(new MoleculeTextQuery(title,target,molecules));
|
---|
45 | }
|
---|
46 |
|
---|
47 | void TextDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check) {
|
---|
48 | registerQuery(new VectorTextQuery(title,target,cellSize,check));
|
---|
49 | }
|
---|
50 |
|
---|
51 | void TextDialog::queryElement(const char* title, element **target){
|
---|
52 | registerQuery(new ElementTextQuery(title,target));
|
---|
53 | }
|
---|
54 |
|
---|
55 | /************************** Query Infrastructure ************************/
|
---|
56 |
|
---|
57 | TextDialog::IntTextQuery::IntTextQuery(string title,int *_target) :
|
---|
58 | Dialog::IntQuery(title,_target)
|
---|
59 | {}
|
---|
60 |
|
---|
61 | TextDialog::IntTextQuery::~IntTextQuery() {}
|
---|
62 |
|
---|
63 | bool TextDialog::IntTextQuery::handle() {
|
---|
64 | Log() << Verbose(0) << getTitle();
|
---|
65 | cin >> tmp;
|
---|
66 | return true;
|
---|
67 | }
|
---|
68 |
|
---|
69 | TextDialog::StringTextQuery::StringTextQuery(string title,string *_target) :
|
---|
70 | Dialog::StringQuery(title,_target)
|
---|
71 | {}
|
---|
72 |
|
---|
73 | TextDialog::StringTextQuery::~StringTextQuery() {}
|
---|
74 |
|
---|
75 | bool TextDialog::StringTextQuery::handle() {
|
---|
76 | Log() << Verbose(0) << getTitle();
|
---|
77 | cin >> tmp;
|
---|
78 | return true;
|
---|
79 | }
|
---|
80 |
|
---|
81 | TextDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target) :
|
---|
82 | Dialog::DoubleQuery(title,_target)
|
---|
83 | {}
|
---|
84 |
|
---|
85 | TextDialog::DoubleTextQuery::~DoubleTextQuery() {}
|
---|
86 |
|
---|
87 | bool TextDialog::DoubleTextQuery::handle() {
|
---|
88 | Log() << Verbose(0) << getTitle();
|
---|
89 | cin >> tmp;
|
---|
90 | return true;
|
---|
91 | }
|
---|
92 |
|
---|
93 | TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, MoleculeListClass *_molecules) :
|
---|
94 | Dialog::MoleculeQuery(title,_target,_molecules)
|
---|
95 | {}
|
---|
96 |
|
---|
97 | TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {}
|
---|
98 |
|
---|
99 | bool 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 |
|
---|
113 | TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check) :
|
---|
114 | Dialog::VectorQuery(title,_target,_cellSize,_check)
|
---|
115 | {}
|
---|
116 |
|
---|
117 | TextDialog::VectorTextQuery::~VectorTextQuery()
|
---|
118 | {}
|
---|
119 |
|
---|
120 | bool TextDialog::VectorTextQuery::handle() {
|
---|
121 | Log() << Verbose(0) << getTitle();
|
---|
122 | tmp->AskPosition(cellSize,check);
|
---|
123 | return true;
|
---|
124 | }
|
---|
125 |
|
---|
126 |
|
---|
127 | TextDialog::ElementTextQuery::ElementTextQuery(std::string title, element **target) :
|
---|
128 | Dialog::ElementQuery(title,target)
|
---|
129 | {}
|
---|
130 |
|
---|
131 | TextDialog::ElementTextQuery::~ElementTextQuery()
|
---|
132 | {}
|
---|
133 |
|
---|
134 | bool 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 | }
|
---|