/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * MoleculeTextQuery.cpp * * Created on: Oct 25, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "Helpers/MemDebug.hpp" #include #include #include #include "TextUI/TextDialog.hpp" #include "Helpers/Log.hpp" #include "Helpers/Verbose.hpp" #include "World.hpp" TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) : Dialog::MoleculeQuery(title,_description) {} TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {} bool TextDialog::MoleculeTextQuery::handle() { int idxOfMol=0; bool badInput = false; do{ badInput = false; Log() << Verbose(0) << getTitle(); cin >> idxOfMol; if(cin.fail()){ badInput = true; cin.clear(); cin.ignore(std::numeric_limits::max(),'\n'); Log() << Verbose(0) << "Input was not a number!" << endl; continue; } tmp = World::getInstance().getMolecule(MoleculeById(idxOfMol)); if(!tmp && idxOfMol!=-1){ Log() << Verbose(0) << "Invalid Molecule Index" << endl; badInput = true; } } while(badInput); cin.ignore(std::numeric_limits::max(),'\n'); return (idxOfMol!=-1); }