/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 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 "CodePatterns/MemDebug.hpp" #include #include #include #include "TextUI/Query/TextQuery.hpp" #include "CodePatterns/Log.hpp" #include "CodePatterns/Verbose.hpp" #include "World.hpp" TextDialog::AtomTextQuery::AtomTextQuery(Parameter ¶m, std::string title, std::string _description) : Dialog::AtomQuery(param, title,_description) {} TextDialog::AtomTextQuery::~AtomTextQuery() {} bool TextDialog::AtomTextQuery::handle() { int idxOfAtom=-1; bool badInput = false; do{ badInput = false; std::cout << getDescription() << ": "; std::cin >> idxOfAtom; if(std::cin.fail()){ badInput = true; std::cin.clear(); std::cin.ignore(std::numeric_limits::max(),'\n'); std::cout << "Input was not a number!" << std::endl; continue; } const atom * temp_atom = World::getInstance().getAtom(AtomById(idxOfAtom)); if(!temp_atom && idxOfAtom!=-1){ std::cout << "Invalid Atom Index" << idxOfAtom << std::endl; badInput = true; } tmp.set(temp_atom); } while(badInput); std::cin.ignore(std::numeric_limits::max(),'\n'); return (idxOfAtom!=-1); }