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