Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/UIElements/CommandLineDialog.cpp

    r97ebf8 r86466e  
    1010#include <iostream>
    1111
    12 #include <Descriptors/AtomDescriptor.hpp>
    13 #include <Descriptors/AtomIdDescriptor.hpp>
    1412#include <Descriptors/MoleculeDescriptor.hpp>
    1513#include <Descriptors/MoleculeIdDescriptor.hpp>
    1614#include "UIElements/CommandLineDialog.hpp"
    1715
    18 #include "element.hpp"
    1916#include "periodentafel.hpp"
     17#include "atom.hpp"
    2018#include "CommandLineParser.hpp"
    2119#include "defs.hpp"
     20#include "molecule.hpp"
    2221#include "log.hpp"
    23 #include "periodentafel.hpp"
    2422#include "verbose.hpp"
    2523#include "World.hpp"
    26 
    27 #include "atom.hpp"
    28 #include "element.hpp"
    29 #include "molecule.hpp"
    30 #include "vector.hpp"
    3124
    3225using namespace std;
     
    5043}
    5144
    52 void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){
    53   registerQuery(new BooleanCommandLineQuery(title,target, _description));
    54 }
    55 
    5645void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
    5746  registerQuery(new DoubleCommandLineQuery(title,target, _description));
     
    6251}
    6352
    64 void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) {
    65   registerQuery(new AtomCommandLineQuery(title,target, _description));
    66 }
    67 
    68 void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) {
    69   registerQuery(new MoleculeCommandLineQuery(title,target, _description));
     53void CommandLineDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules, string _description) {
     54  registerQuery(new MoleculeCommandLineQuery(title,target,molecules, _description));
    7055}
    7156
    7257void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) {
    7358  registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description));
    74 }
    75 
    76 void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) {
    77   registerQuery(new BoxCommandLineQuery(title,cellSize,_description));
    7859}
    7960
     
    10990}
    11091
    111 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :
    112     Dialog::BooleanQuery(title,_target, _description)
    113 {}
    114 
    115 CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
    116 
    117 bool CommandLineDialog::BooleanCommandLineQuery::handle() {
    118   bool badInput = false;
    119   char input = ' ';
    120   do{
    121     badInput = false;
    122     Log() << Verbose(0) << getTitle();
    123     cin >> input;
    124     if ((input == 'y' ) || (input == 'Y')) {
    125       tmp = true;
    126     } else if ((input == 'n' ) || (input == 'N')) {
    127       tmp = false;
    128     } else {
    129       badInput=true;
    130       cin.clear();
    131       cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    132       Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;
    133     }
    134   } while(badInput);
    135   // clear the input buffer of anything still in the line
    136   cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    137   return true;
    138 }
    139 
    14092CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
    14193    Dialog::StringQuery(title,_target, _description)
     
    166118}
    167119
    168 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) :
    169     Dialog::AtomQuery(title,_target, _description)
    170 {}
    171 
    172 CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
    173 
    174 bool CommandLineDialog::AtomCommandLineQuery::handle() {
    175   int IdxOfAtom = -1;
    176   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    177     IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>();
    178     tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
    179     return true;
    180   } else
    181     return false;
    182 }
    183 
    184 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) :
    185     Dialog::MoleculeQuery(title,_target, _description)
     120CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, MoleculeListClass *_molecules, string _description) :
     121    Dialog::MoleculeQuery(title,_target,_molecules, _description)
    186122{}
    187123
     
    210146    temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
    211147    assert((temp.size() == 3) && "Vector from command line does not have three components.");
     148    tmp = new Vector;
    212149    for (int i=0;i<NDIM;i++)
    213150      tmp->at(i) = temp[i];
     
    217154}
    218155
    219 
    220 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) :
    221     Dialog::BoxQuery(title,_cellSize, _description)
    222 {}
    223 
    224 CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()
    225 {}
    226 
    227 bool CommandLineDialog::BoxCommandLineQuery::handle() {
    228   vector<double> temp;
    229   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    230     temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
    231     assert((temp.size() == 6) && "Symmetric box matrix from command line does not have six components.");
    232     for (int i=0;i<6;i++)
    233       tmp[i] = temp[i];
    234     return true;
    235   } else
    236     return false;
    237 }
    238156
    239157CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) :
     
    245163
    246164bool CommandLineDialog::ElementCommandLineQuery::handle() {
    247   // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    248   int Z;
     165  int Z = -1;
    249166  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    250     vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
    251     vector<int>::iterator ElementRunner = AllElements.begin();
    252     Z = *ElementRunner;
    253     // TODO: So far, this does not really erase the element in the parsed list.
    254     AllElements.erase(ElementRunner);
     167    Z = CommandLineParser::getInstance().vm[getTitle()].as<int>();
    255168    tmp = World::getInstance().getPeriode()->FindElement(Z);
    256169    return true;
Note: See TracChangeset for help on using the changeset viewer.