| [a2ab15] | 1 | /* | 
|---|
|  | 2 | * CommandLineDialog.cpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: May 8, 2010 | 
|---|
|  | 5 | *      Author: heber | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
| [112b09] | 8 | #include "Helpers/MemDebug.hpp" | 
|---|
| [a2ab15] | 9 |  | 
|---|
|  | 10 | #include <iostream> | 
|---|
| [104524] | 11 | #include <vector> | 
|---|
| [a2ab15] | 12 |  | 
|---|
| [97ebf8] | 13 | #include <Descriptors/AtomDescriptor.hpp> | 
|---|
|  | 14 | #include <Descriptors/AtomIdDescriptor.hpp> | 
|---|
| [d90762] | 15 | #include <Descriptors/MoleculeDescriptor.hpp> | 
|---|
|  | 16 | #include <Descriptors/MoleculeIdDescriptor.hpp> | 
|---|
| [5079a0] | 17 | #include "CommandLineUI/CommandLineDialog.hpp" | 
|---|
| [a2ab15] | 18 |  | 
|---|
| [0286bc] | 19 | #include "Actions/Values.hpp" | 
|---|
|  | 20 |  | 
|---|
| [97ebf8] | 21 | #include "element.hpp" | 
|---|
| [a2ab15] | 22 | #include "periodentafel.hpp" | 
|---|
| [d90762] | 23 | #include "CommandLineParser.hpp" | 
|---|
|  | 24 | #include "defs.hpp" | 
|---|
| [952f38] | 25 | #include "Helpers/Log.hpp" | 
|---|
| [57f243] | 26 | #include "LinearAlgebra/Matrix.hpp" | 
|---|
| [97ebf8] | 27 | #include "periodentafel.hpp" | 
|---|
| [952f38] | 28 | #include "Helpers/Verbose.hpp" | 
|---|
| [d90762] | 29 | #include "World.hpp" | 
|---|
| [84c494] | 30 | #include "Box.hpp" | 
|---|
| [a2ab15] | 31 |  | 
|---|
| [97ebf8] | 32 | #include "atom.hpp" | 
|---|
|  | 33 | #include "element.hpp" | 
|---|
|  | 34 | #include "molecule.hpp" | 
|---|
| [57f243] | 35 | #include "LinearAlgebra/Vector.hpp" | 
|---|
| [97ebf8] | 36 |  | 
|---|
| [a2ab15] | 37 | using namespace std; | 
|---|
|  | 38 |  | 
|---|
|  | 39 |  | 
|---|
|  | 40 | CommandLineDialog::CommandLineDialog() | 
|---|
|  | 41 | { | 
|---|
|  | 42 | } | 
|---|
|  | 43 |  | 
|---|
|  | 44 | CommandLineDialog::~CommandLineDialog() | 
|---|
|  | 45 | { | 
|---|
|  | 46 | } | 
|---|
|  | 47 |  | 
|---|
|  | 48 |  | 
|---|
| [86466e] | 49 | void CommandLineDialog::queryEmpty(const char* title, string _description){ | 
|---|
|  | 50 | registerQuery(new EmptyCommandLineQuery(title, _description)); | 
|---|
| [a2ab15] | 51 | } | 
|---|
|  | 52 |  | 
|---|
| [75dc28] | 53 | void CommandLineDialog::queryInt(const char* title, string _description){ | 
|---|
|  | 54 | registerQuery(new IntCommandLineQuery(title, _description)); | 
|---|
| [a2ab15] | 55 | } | 
|---|
|  | 56 |  | 
|---|
| [7cd6e7] | 57 | void CommandLineDialog::queryInts(const char* title, string _description){ | 
|---|
|  | 58 | registerQuery(new IntsCommandLineQuery(title, _description)); | 
|---|
|  | 59 | } | 
|---|
|  | 60 |  | 
|---|
| [75dc28] | 61 | void CommandLineDialog::queryBoolean(const char* title, string _description){ | 
|---|
|  | 62 | registerQuery(new BooleanCommandLineQuery(title, _description)); | 
|---|
| [97ebf8] | 63 | } | 
|---|
|  | 64 |  | 
|---|
| [75dc28] | 65 | void CommandLineDialog::queryDouble(const char* title, string _description){ | 
|---|
|  | 66 | registerQuery(new DoubleCommandLineQuery(title, _description)); | 
|---|
| [a2ab15] | 67 | } | 
|---|
|  | 68 |  | 
|---|
| [7cd6e7] | 69 | void CommandLineDialog::queryDoubles(const char* title, string _description){ | 
|---|
|  | 70 | registerQuery(new DoublesCommandLineQuery(title, _description)); | 
|---|
|  | 71 | } | 
|---|
|  | 72 |  | 
|---|
| [75dc28] | 73 | void CommandLineDialog::queryString(const char* title, string _description){ | 
|---|
|  | 74 | registerQuery(new StringCommandLineQuery(title, _description)); | 
|---|
| [a2ab15] | 75 | } | 
|---|
|  | 76 |  | 
|---|
| [75dc28] | 77 | void CommandLineDialog::queryStrings(const char* title, string _description){ | 
|---|
|  | 78 | registerQuery(new StringsCommandLineQuery(title, _description)); | 
|---|
| [cd8e55] | 79 | } | 
|---|
|  | 80 |  | 
|---|
| [75dc28] | 81 | void CommandLineDialog::queryAtom(const char* title, string _description) { | 
|---|
|  | 82 | registerQuery(new AtomCommandLineQuery(title, _description)); | 
|---|
| [97ebf8] | 83 | } | 
|---|
|  | 84 |  | 
|---|
| [7cd6e7] | 85 | void CommandLineDialog::queryAtoms(const char* title, string _description) { | 
|---|
|  | 86 | registerQuery(new AtomsCommandLineQuery(title, _description)); | 
|---|
|  | 87 | } | 
|---|
|  | 88 |  | 
|---|
| [75dc28] | 89 | void CommandLineDialog::queryMolecule(const char* title, string _description) { | 
|---|
|  | 90 | registerQuery(new MoleculeCommandLineQuery(title, _description)); | 
|---|
| [a2ab15] | 91 | } | 
|---|
|  | 92 |  | 
|---|
| [7cd6e7] | 93 | void CommandLineDialog::queryMolecules(const char* title, string _description) { | 
|---|
|  | 94 | registerQuery(new MoleculesCommandLineQuery(title, _description)); | 
|---|
|  | 95 | } | 
|---|
|  | 96 |  | 
|---|
| [75dc28] | 97 | void CommandLineDialog::queryVector(const char* title, bool check, string _description) { | 
|---|
|  | 98 | registerQuery(new VectorCommandLineQuery(title,check, _description)); | 
|---|
| [86466e] | 99 | } | 
|---|
|  | 100 |  | 
|---|
| [7cd6e7] | 101 | void CommandLineDialog::queryVectors(const char* title, bool check, string _description) { | 
|---|
|  | 102 | registerQuery(new VectorsCommandLineQuery(title,check, _description)); | 
|---|
|  | 103 | } | 
|---|
|  | 104 |  | 
|---|
| [75dc28] | 105 | void CommandLineDialog::queryBox(const char* title, string _description) { | 
|---|
|  | 106 | registerQuery(new BoxCommandLineQuery(title,_description)); | 
|---|
| [97ebf8] | 107 | } | 
|---|
|  | 108 |  | 
|---|
| [75dc28] | 109 | void CommandLineDialog::queryElement(const char* title, string _description){ | 
|---|
|  | 110 | registerQuery(new ElementCommandLineQuery(title, _description)); | 
|---|
| [a2ab15] | 111 | } | 
|---|
|  | 112 |  | 
|---|
| [7cd6e7] | 113 | void CommandLineDialog::queryElements(const char* title, string _description){ | 
|---|
|  | 114 | registerQuery(new ElementsCommandLineQuery(title, _description)); | 
|---|
|  | 115 | } | 
|---|
|  | 116 |  | 
|---|
| [a2ab15] | 117 | /************************** Query Infrastructure ************************/ | 
|---|
|  | 118 |  | 
|---|
| [86466e] | 119 | CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) : | 
|---|
|  | 120 | Dialog::EmptyQuery(title, _description) | 
|---|
|  | 121 | {} | 
|---|
|  | 122 |  | 
|---|
|  | 123 | CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {} | 
|---|
|  | 124 |  | 
|---|
|  | 125 | bool CommandLineDialog::EmptyCommandLineQuery::handle() { | 
|---|
|  | 126 | cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n"; | 
|---|
|  | 127 | return true; | 
|---|
|  | 128 | } | 
|---|
|  | 129 |  | 
|---|
| [75dc28] | 130 | CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) : | 
|---|
|  | 131 | Dialog::IntQuery(title, _description) | 
|---|
| [a2ab15] | 132 | {} | 
|---|
|  | 133 |  | 
|---|
| [86466e] | 134 | CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {} | 
|---|
| [a2ab15] | 135 |  | 
|---|
| [86466e] | 136 | bool CommandLineDialog::IntCommandLineQuery::handle() { | 
|---|
| [d90762] | 137 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 138 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>(); | 
|---|
|  | 139 | return true; | 
|---|
| [94d131] | 140 | } else { | 
|---|
|  | 141 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integer for " << getTitle() << "." << endl); | 
|---|
| [d90762] | 142 | return false; | 
|---|
| [94d131] | 143 | } | 
|---|
| [a2ab15] | 144 | } | 
|---|
|  | 145 |  | 
|---|
| [7cd6e7] | 146 | CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) : | 
|---|
|  | 147 | Dialog::IntsQuery(title, _description) | 
|---|
|  | 148 | {} | 
|---|
|  | 149 |  | 
|---|
|  | 150 | CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {} | 
|---|
|  | 151 |  | 
|---|
|  | 152 | bool CommandLineDialog::IntsCommandLineQuery::handle() { | 
|---|
|  | 153 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 154 | tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); | 
|---|
|  | 155 | return true; | 
|---|
|  | 156 | } else { | 
|---|
|  | 157 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl); | 
|---|
|  | 158 | return false; | 
|---|
|  | 159 | } | 
|---|
|  | 160 | } | 
|---|
|  | 161 |  | 
|---|
| [75dc28] | 162 | CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) : | 
|---|
|  | 163 | Dialog::BooleanQuery(title, _description) | 
|---|
| [97ebf8] | 164 | {} | 
|---|
|  | 165 |  | 
|---|
|  | 166 | CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {} | 
|---|
|  | 167 |  | 
|---|
|  | 168 | bool CommandLineDialog::BooleanCommandLineQuery::handle() { | 
|---|
| [0286bc] | 169 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 170 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>(); | 
|---|
|  | 171 | return true; | 
|---|
| [94d131] | 172 | } else { | 
|---|
|  | 173 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing boolean for " << getTitle() << "." << endl); | 
|---|
| [0286bc] | 174 | return false; | 
|---|
| [94d131] | 175 | } | 
|---|
| [97ebf8] | 176 | } | 
|---|
|  | 177 |  | 
|---|
| [75dc28] | 178 | CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) : | 
|---|
|  | 179 | Dialog::StringQuery(title, _description) | 
|---|
| [a2ab15] | 180 | {} | 
|---|
|  | 181 |  | 
|---|
| [86466e] | 182 | CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {} | 
|---|
| [a2ab15] | 183 |  | 
|---|
| [86466e] | 184 | bool CommandLineDialog::StringCommandLineQuery::handle() { | 
|---|
| [d90762] | 185 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
| [86466e] | 186 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>(); | 
|---|
| [d90762] | 187 | return true; | 
|---|
| [94d131] | 188 | } else { | 
|---|
|  | 189 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl); | 
|---|
| [d90762] | 190 | return false; | 
|---|
| [94d131] | 191 | } | 
|---|
| [a2ab15] | 192 | } | 
|---|
|  | 193 |  | 
|---|
| [75dc28] | 194 | CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) : | 
|---|
|  | 195 | Dialog::StringsQuery(title, _description) | 
|---|
| [cd8e55] | 196 | {} | 
|---|
|  | 197 |  | 
|---|
|  | 198 | CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {} | 
|---|
|  | 199 |  | 
|---|
|  | 200 | bool CommandLineDialog::StringsCommandLineQuery::handle() { | 
|---|
|  | 201 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
| [b9c847] | 202 | tmp = CommandLineParser::getInstance().vm[getTitle()].as< vector<string> >(); | 
|---|
| [cd8e55] | 203 | return true; | 
|---|
|  | 204 | } else { | 
|---|
| [7cd6e7] | 205 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl); | 
|---|
| [cd8e55] | 206 | return false; | 
|---|
|  | 207 | } | 
|---|
|  | 208 | } | 
|---|
|  | 209 |  | 
|---|
| [75dc28] | 210 | CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) : | 
|---|
|  | 211 | Dialog::DoubleQuery(title, _description) | 
|---|
| [a2ab15] | 212 | {} | 
|---|
|  | 213 |  | 
|---|
| [86466e] | 214 | CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {} | 
|---|
| [a2ab15] | 215 |  | 
|---|
| [86466e] | 216 | bool CommandLineDialog::DoubleCommandLineQuery::handle() { | 
|---|
| [d90762] | 217 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 218 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>(); | 
|---|
|  | 219 | return true; | 
|---|
| [94d131] | 220 | } else { | 
|---|
|  | 221 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing double for " << getTitle() << "." << endl); | 
|---|
| [d90762] | 222 | return false; | 
|---|
| [94d131] | 223 | } | 
|---|
| [a2ab15] | 224 | } | 
|---|
|  | 225 |  | 
|---|
| [7cd6e7] | 226 | CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) : | 
|---|
|  | 227 | Dialog::DoublesQuery(title, _description) | 
|---|
|  | 228 | {} | 
|---|
|  | 229 |  | 
|---|
|  | 230 | CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {} | 
|---|
|  | 231 |  | 
|---|
|  | 232 | bool CommandLineDialog::DoublesCommandLineQuery::handle() { | 
|---|
|  | 233 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 234 | tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >(); | 
|---|
|  | 235 | return true; | 
|---|
|  | 236 | } else { | 
|---|
|  | 237 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl); | 
|---|
|  | 238 | return false; | 
|---|
|  | 239 | } | 
|---|
|  | 240 | } | 
|---|
|  | 241 |  | 
|---|
| [75dc28] | 242 | CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) : | 
|---|
|  | 243 | Dialog::AtomQuery(title, _description) | 
|---|
| [97ebf8] | 244 | {} | 
|---|
|  | 245 |  | 
|---|
|  | 246 | CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {} | 
|---|
|  | 247 |  | 
|---|
|  | 248 | bool CommandLineDialog::AtomCommandLineQuery::handle() { | 
|---|
|  | 249 | int IdxOfAtom = -1; | 
|---|
|  | 250 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 251 | IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>(); | 
|---|
|  | 252 | tmp = World::getInstance().getAtom(AtomById(IdxOfAtom)); | 
|---|
|  | 253 | return true; | 
|---|
| [94d131] | 254 | } else { | 
|---|
|  | 255 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atom for " << getTitle() << "." << endl); | 
|---|
| [97ebf8] | 256 | return false; | 
|---|
| [94d131] | 257 | } | 
|---|
| [97ebf8] | 258 | } | 
|---|
|  | 259 |  | 
|---|
| [7cd6e7] | 260 | CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) : | 
|---|
|  | 261 | Dialog::AtomsQuery(title, _description) | 
|---|
|  | 262 | {} | 
|---|
|  | 263 |  | 
|---|
|  | 264 | CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {} | 
|---|
|  | 265 |  | 
|---|
|  | 266 | bool CommandLineDialog::AtomsCommandLineQuery::handle() { | 
|---|
|  | 267 | std::vector<int> IdxOfAtom; | 
|---|
|  | 268 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 269 | IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); | 
|---|
|  | 270 | for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) { | 
|---|
|  | 271 | temp = World::getInstance().getAtom(AtomById(*iter)); | 
|---|
|  | 272 | if (temp) | 
|---|
|  | 273 | tmp.push_back(temp); | 
|---|
|  | 274 | } | 
|---|
|  | 275 | return true; | 
|---|
|  | 276 | } else { | 
|---|
|  | 277 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl); | 
|---|
|  | 278 | return false; | 
|---|
|  | 279 | } | 
|---|
|  | 280 | } | 
|---|
|  | 281 |  | 
|---|
| [75dc28] | 282 | CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) : | 
|---|
|  | 283 | Dialog::MoleculeQuery(title, _description) | 
|---|
| [a2ab15] | 284 | {} | 
|---|
|  | 285 |  | 
|---|
| [86466e] | 286 | CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {} | 
|---|
| [a2ab15] | 287 |  | 
|---|
| [86466e] | 288 | bool CommandLineDialog::MoleculeCommandLineQuery::handle() { | 
|---|
| [d90762] | 289 | int IdxOfMol = -1; | 
|---|
|  | 290 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 291 | IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>(); | 
|---|
| [7cd6e7] | 292 | tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); | 
|---|
| [d90762] | 293 | return true; | 
|---|
| [94d131] | 294 | } else { | 
|---|
|  | 295 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl); | 
|---|
| [d90762] | 296 | return false; | 
|---|
| [94d131] | 297 | } | 
|---|
| [a2ab15] | 298 | } | 
|---|
|  | 299 |  | 
|---|
| [7cd6e7] | 300 | CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) : | 
|---|
|  | 301 | Dialog::MoleculesQuery(title, _description) | 
|---|
|  | 302 | {} | 
|---|
|  | 303 |  | 
|---|
|  | 304 | CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {} | 
|---|
|  | 305 |  | 
|---|
|  | 306 | bool CommandLineDialog::MoleculesCommandLineQuery::handle() { | 
|---|
|  | 307 | std::vector<int> IdxOfMol; | 
|---|
|  | 308 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 309 | IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); | 
|---|
|  | 310 | for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) { | 
|---|
|  | 311 | temp = World::getInstance().getMolecule(MoleculeById(*iter)); | 
|---|
|  | 312 | if (temp) | 
|---|
|  | 313 | tmp.push_back(temp); | 
|---|
|  | 314 | } | 
|---|
|  | 315 | return true; | 
|---|
|  | 316 | } else { | 
|---|
|  | 317 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl); | 
|---|
|  | 318 | return false; | 
|---|
|  | 319 | } | 
|---|
|  | 320 | } | 
|---|
|  | 321 |  | 
|---|
| [75dc28] | 322 | CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) : | 
|---|
|  | 323 | Dialog::VectorQuery(title,_check, _description) | 
|---|
| [a2ab15] | 324 | {} | 
|---|
|  | 325 |  | 
|---|
| [86466e] | 326 | CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery() | 
|---|
| [a2ab15] | 327 | {} | 
|---|
|  | 328 |  | 
|---|
| [86466e] | 329 | bool CommandLineDialog::VectorCommandLineQuery::handle() { | 
|---|
| [0286bc] | 330 | VectorValue temp; | 
|---|
| [d90762] | 331 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
| [0286bc] | 332 | temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >(); | 
|---|
| [7cd6e7] | 333 | tmp[0] = temp.x; | 
|---|
|  | 334 | tmp[1] = temp.y; | 
|---|
|  | 335 | tmp[2] = temp.z; | 
|---|
| [8bc733] | 336 | if ((check) && (!World::getInstance().getDomain().isInside(tmp))) { | 
|---|
| [7cd6e7] | 337 | DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl); | 
|---|
| [8bc733] | 338 | return false; | 
|---|
| [7cd6e7] | 339 | } | 
|---|
| [d90762] | 340 | return true; | 
|---|
| [94d131] | 341 | } else { | 
|---|
|  | 342 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vector for " << getTitle() << "." << endl); | 
|---|
| [d90762] | 343 | return false; | 
|---|
| [94d131] | 344 | } | 
|---|
| [a2ab15] | 345 | } | 
|---|
|  | 346 |  | 
|---|
| [7cd6e7] | 347 | CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) : | 
|---|
|  | 348 | Dialog::VectorsQuery(title,_check, _description) | 
|---|
|  | 349 | {} | 
|---|
|  | 350 |  | 
|---|
|  | 351 | CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery() | 
|---|
|  | 352 | {} | 
|---|
|  | 353 |  | 
|---|
|  | 354 | bool CommandLineDialog::VectorsCommandLineQuery::handle() { | 
|---|
|  | 355 | std::vector<VectorValue> temporary; | 
|---|
|  | 356 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 357 | temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >(); | 
|---|
|  | 358 | for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) { | 
|---|
|  | 359 | temp[0] = (*iter).x; | 
|---|
|  | 360 | temp[1] = (*iter).y; | 
|---|
|  | 361 | temp[2] = (*iter).z; | 
|---|
|  | 362 | if ((!check) || (World::getInstance().getDomain().isInside(temp))) | 
|---|
|  | 363 | tmp.push_back(temp); | 
|---|
|  | 364 | else | 
|---|
|  | 365 | DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl); | 
|---|
|  | 366 | } | 
|---|
|  | 367 | return true; | 
|---|
|  | 368 | } else { | 
|---|
|  | 369 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl); | 
|---|
|  | 370 | return false; | 
|---|
|  | 371 | } | 
|---|
|  | 372 | } | 
|---|
| [a2ab15] | 373 |  | 
|---|
| [75dc28] | 374 | CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) : | 
|---|
|  | 375 | Dialog::BoxQuery(title, _description) | 
|---|
| [97ebf8] | 376 | {} | 
|---|
|  | 377 |  | 
|---|
|  | 378 | CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery() | 
|---|
|  | 379 | {} | 
|---|
|  | 380 |  | 
|---|
|  | 381 | bool CommandLineDialog::BoxCommandLineQuery::handle() { | 
|---|
| [0286bc] | 382 | BoxValue temp; | 
|---|
| [97ebf8] | 383 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
| [0286bc] | 384 | temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >(); | 
|---|
| [8bc733] | 385 | Matrix M; | 
|---|
|  | 386 | M.set(0,0, temp.xx); | 
|---|
| [8467df] | 387 | M.set(0,1, temp.yx); | 
|---|
|  | 388 | M.set(0,2, temp.zx); | 
|---|
|  | 389 | M.set(1,0, temp.yx); | 
|---|
| [8bc733] | 390 | M.set(1,1, temp.yy); | 
|---|
| [8467df] | 391 | M.set(1,2, temp.zy); | 
|---|
|  | 392 | M.set(2,0, temp.zx); | 
|---|
|  | 393 | M.set(2,1, temp.zy); | 
|---|
| [8bc733] | 394 | M.set(2,2, temp.zz); | 
|---|
|  | 395 | tmp.setM(M); | 
|---|
| [97ebf8] | 396 | return true; | 
|---|
| [94d131] | 397 | } else { | 
|---|
|  | 398 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing symmetric box matrix for " << getTitle() << "." << endl); | 
|---|
| [97ebf8] | 399 | return false; | 
|---|
| [94d131] | 400 | } | 
|---|
| [97ebf8] | 401 | } | 
|---|
|  | 402 |  | 
|---|
| [75dc28] | 403 | CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) : | 
|---|
| [3731b4] | 404 | Dialog::ElementQuery(title, _description) | 
|---|
| [a2ab15] | 405 | {} | 
|---|
|  | 406 |  | 
|---|
| [86466e] | 407 | CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery() | 
|---|
| [a2ab15] | 408 | {} | 
|---|
|  | 409 |  | 
|---|
| [86466e] | 410 | bool CommandLineDialog::ElementCommandLineQuery::handle() { | 
|---|
| [97ebf8] | 411 | // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? | 
|---|
| [104524] | 412 | periodentafel *periode = World::getInstance().getPeriode(); | 
|---|
| [7cd6e7] | 413 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
|  | 414 | int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >(); | 
|---|
|  | 415 | tmp = periode->FindElement(Z); | 
|---|
|  | 416 | ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery"); | 
|---|
|  | 417 | return true; | 
|---|
|  | 418 | } else { | 
|---|
|  | 419 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl); | 
|---|
|  | 420 | return false; | 
|---|
|  | 421 | } | 
|---|
|  | 422 | } | 
|---|
|  | 423 |  | 
|---|
|  | 424 | CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) : | 
|---|
|  | 425 | Dialog::ElementsQuery(title, _description) | 
|---|
|  | 426 | {} | 
|---|
|  | 427 |  | 
|---|
|  | 428 | CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery() | 
|---|
|  | 429 | {} | 
|---|
|  | 430 |  | 
|---|
|  | 431 | bool CommandLineDialog::ElementsCommandLineQuery::handle() { | 
|---|
|  | 432 | // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? | 
|---|
|  | 433 | periodentafel *periode = World::getInstance().getPeriode(); | 
|---|
| [d90762] | 434 | if (CommandLineParser::getInstance().vm.count(getTitle())) { | 
|---|
| [97ebf8] | 435 | vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >(); | 
|---|
| [104524] | 436 | for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) { | 
|---|
| [7cd6e7] | 437 | temp = periode->FindElement(*ZRunner); | 
|---|
|  | 438 | ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery"); | 
|---|
|  | 439 | tmp.push_back(temp); | 
|---|
| [104524] | 440 | } | 
|---|
| [d90762] | 441 | return true; | 
|---|
| [94d131] | 442 | } else { | 
|---|
| [7cd6e7] | 443 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl); | 
|---|
| [d90762] | 444 | return false; | 
|---|
| [94d131] | 445 | } | 
|---|
| [a2ab15] | 446 | } | 
|---|