| [f5a86a] | 1 | /*
 | 
|---|
 | 2 |  * TextDialog.cpp
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  *  Created on: Jan 5, 2010
 | 
|---|
 | 5 |  *      Author: crueger
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | #include <iostream>
 | 
|---|
 | 9 | 
 | 
|---|
| [7aa000] | 10 | #include "UIElements/TextDialog.hpp"
 | 
|---|
 | 11 | 
 | 
|---|
| [5a7243] | 12 | #include "World.hpp"
 | 
|---|
 | 13 | #include "periodentafel.hpp"
 | 
|---|
| [7aa000] | 14 | #include "atom.hpp"
 | 
|---|
 | 15 | #include "molecule.hpp"
 | 
|---|
| [f5a86a] | 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 | 
 | 
|---|
| [7aa000] | 30 | 
 | 
|---|
| [45f5d6] | 31 | void TextDialog::queryInt(const char* title, int* target){
 | 
|---|
 | 32 |   registerQuery(new IntTextQuery(title,target));
 | 
|---|
 | 33 | }
 | 
|---|
 | 34 | 
 | 
|---|
| [2ededc2] | 35 | void TextDialog::queryDouble(const char* title, double* target){
 | 
|---|
 | 36 |   registerQuery(new DoubleTextQuery(title,target));
 | 
|---|
 | 37 | }
 | 
|---|
 | 38 | 
 | 
|---|
| [45f5d6] | 39 | void TextDialog::queryString(const char* title, string* target){
 | 
|---|
 | 40 |   registerQuery(new StringTextQuery(title,target));
 | 
|---|
| [f5a86a] | 41 | }
 | 
|---|
 | 42 | 
 | 
|---|
| [7aa000] | 43 | void TextDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules) {
 | 
|---|
 | 44 |   registerQuery(new MoleculeTextQuery(title,target,molecules));
 | 
|---|
 | 45 | }
 | 
|---|
 | 46 | 
 | 
|---|
| [2ededc2] | 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 | 
 | 
|---|
| [5605032] | 51 | void TextDialog::queryElement(const char* title, const element **target){
 | 
|---|
| [5a7243] | 52 |   registerQuery(new ElementTextQuery(title,target));
 | 
|---|
 | 53 | }
 | 
|---|
 | 54 | 
 | 
|---|
| [7aa000] | 55 | /************************** Query Infrastructure ************************/
 | 
|---|
 | 56 | 
 | 
|---|
| [45f5d6] | 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() {
 | 
|---|
| [7aa000] | 64 |   Log() << Verbose(0) << getTitle();
 | 
|---|
| [45f5d6] | 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() {
 | 
|---|
| [7aa000] | 76 |   Log() << Verbose(0) << getTitle();
 | 
|---|
| [45f5d6] | 77 |   cin >> tmp;
 | 
|---|
 | 78 |   return true;
 | 
|---|
| [f5a86a] | 79 | }
 | 
|---|
| [7aa000] | 80 | 
 | 
|---|
| [2ededc2] | 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 | 
 | 
|---|
| [7aa000] | 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 | }
 | 
|---|
| [2ededc2] | 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() {
 | 
|---|
| [5a7243] | 121 |  Log() << Verbose(0) << getTitle();
 | 
|---|
| [2ededc2] | 122 |  tmp->AskPosition(cellSize,check);
 | 
|---|
| [5a7243] | 123 |  return true;
 | 
|---|
 | 124 | }
 | 
|---|
 | 125 | 
 | 
|---|
 | 126 | 
 | 
|---|
| [5605032] | 127 | TextDialog::ElementTextQuery::ElementTextQuery(std::string title, const element **target) :
 | 
|---|
| [5a7243] | 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;
 | 
|---|
| [5605032] | 138 |   tmp = World::getInstance().getPeriode()->FindElement(Z);
 | 
|---|
| [5a7243] | 139 |   return tmp;
 | 
|---|
| [2ededc2] | 140 | }
 | 
|---|