- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/UIElements/CommandLineDialog.cpp ¶
r97ebf8 r86466e 10 10 #include <iostream> 11 11 12 #include <Descriptors/AtomDescriptor.hpp>13 #include <Descriptors/AtomIdDescriptor.hpp>14 12 #include <Descriptors/MoleculeDescriptor.hpp> 15 13 #include <Descriptors/MoleculeIdDescriptor.hpp> 16 14 #include "UIElements/CommandLineDialog.hpp" 17 15 18 #include "element.hpp"19 16 #include "periodentafel.hpp" 17 #include "atom.hpp" 20 18 #include "CommandLineParser.hpp" 21 19 #include "defs.hpp" 20 #include "molecule.hpp" 22 21 #include "log.hpp" 23 #include "periodentafel.hpp"24 22 #include "verbose.hpp" 25 23 #include "World.hpp" 26 27 #include "atom.hpp"28 #include "element.hpp"29 #include "molecule.hpp"30 #include "vector.hpp"31 24 32 25 using namespace std; … … 50 43 } 51 44 52 void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){53 registerQuery(new BooleanCommandLineQuery(title,target, _description));54 }55 56 45 void CommandLineDialog::queryDouble(const char* title, double* target, string _description){ 57 46 registerQuery(new DoubleCommandLineQuery(title,target, _description)); … … 62 51 } 63 52 64 void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) { 65 registerQuery(new AtomCommandLineQuery(title,target, _description)); 66 } 67 68 void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) { 69 registerQuery(new MoleculeCommandLineQuery(title,target, _description)); 53 void CommandLineDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules, string _description) { 54 registerQuery(new MoleculeCommandLineQuery(title,target,molecules, _description)); 70 55 } 71 56 72 57 void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) { 73 58 registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description)); 74 }75 76 void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) {77 registerQuery(new BoxCommandLineQuery(title,cellSize,_description));78 59 } 79 60 … … 109 90 } 110 91 111 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :112 Dialog::BooleanQuery(title,_target, _description)113 {}114 115 CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}116 117 bool CommandLineDialog::BooleanCommandLineQuery::handle() {118 bool badInput = false;119 char input = ' ';120 do{121 badInput = false;122 Log() << Verbose(0) << getTitle();123 cin >> input;124 if ((input == 'y' ) || (input == 'Y')) {125 tmp = true;126 } else if ((input == 'n' ) || (input == 'N')) {127 tmp = false;128 } else {129 badInput=true;130 cin.clear();131 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');132 Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;133 }134 } while(badInput);135 // clear the input buffer of anything still in the line136 cin.ignore(std::numeric_limits<streamsize>::max(),'\n');137 return true;138 }139 140 92 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) : 141 93 Dialog::StringQuery(title,_target, _description) … … 166 118 } 167 119 168 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) : 169 Dialog::AtomQuery(title,_target, _description) 170 {} 171 172 CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {} 173 174 bool CommandLineDialog::AtomCommandLineQuery::handle() { 175 int IdxOfAtom = -1; 176 if (CommandLineParser::getInstance().vm.count(getTitle())) { 177 IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>(); 178 tmp = World::getInstance().getAtom(AtomById(IdxOfAtom)); 179 return true; 180 } else 181 return false; 182 } 183 184 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) : 185 Dialog::MoleculeQuery(title,_target, _description) 120 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, MoleculeListClass *_molecules, string _description) : 121 Dialog::MoleculeQuery(title,_target,_molecules, _description) 186 122 {} 187 123 … … 210 146 temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >(); 211 147 assert((temp.size() == 3) && "Vector from command line does not have three components."); 148 tmp = new Vector; 212 149 for (int i=0;i<NDIM;i++) 213 150 tmp->at(i) = temp[i]; … … 217 154 } 218 155 219 220 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) :221 Dialog::BoxQuery(title,_cellSize, _description)222 {}223 224 CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()225 {}226 227 bool CommandLineDialog::BoxCommandLineQuery::handle() {228 vector<double> temp;229 if (CommandLineParser::getInstance().vm.count(getTitle())) {230 temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();231 assert((temp.size() == 6) && "Symmetric box matrix from command line does not have six components.");232 for (int i=0;i<6;i++)233 tmp[i] = temp[i];234 return true;235 } else236 return false;237 }238 156 239 157 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) : … … 245 163 246 164 bool CommandLineDialog::ElementCommandLineQuery::handle() { 247 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? 248 int Z; 165 int Z = -1; 249 166 if (CommandLineParser::getInstance().vm.count(getTitle())) { 250 vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >(); 251 vector<int>::iterator ElementRunner = AllElements.begin(); 252 Z = *ElementRunner; 253 // TODO: So far, this does not really erase the element in the parsed list. 254 AllElements.erase(ElementRunner); 167 Z = CommandLineParser::getInstance().vm[getTitle()].as<int>(); 255 168 tmp = World::getInstance().getPeriode()->FindElement(Z); 256 169 return true;
Note:
See TracChangeset
for help on using the changeset viewer.