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