/* * 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. */ /* * AtomTextQuery.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/Query/TextQuery.hpp" #include "Helpers/Log.hpp" #include "Helpers/Verbose.hpp" #include "World.hpp" TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) : Dialog::AtomQuery(title,_description) {} TextDialog::AtomTextQuery::~AtomTextQuery() {} bool TextDialog::AtomTextQuery::handle() { int idxOfAtom=-1; bool badInput = false; do{ badInput = false; Log() << Verbose(0) << getTitle(); cin >> idxOfAtom; 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().getAtom(AtomById(idxOfAtom)); if(!tmp && idxOfAtom!=-1){ Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl; badInput = true; } } while(badInput); cin.ignore(std::numeric_limits::max(),'\n'); return (idxOfAtom!=-1); }