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