/* * 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. */ /* * AtomsQtQueryPipe.cpp * * Created on: Oct 25, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "UIElements/Qt4/Pipe/AtomsQtQueryPipe.hpp" #include "UIElements/Qt4/QtDialog.hpp" #include #include #include "Descriptors/AtomIdDescriptor.hpp" #include "CodePatterns/MemDebug.hpp" #include "World.hpp" AtomsQtQueryPipe::AtomsQtQueryPipe(Parameter > &_content, QtDialog *_dialog, QListWidget *_theList) : content(_content), dialog(_dialog), theList(_theList) {} AtomsQtQueryPipe::~AtomsQtQueryPipe() {} void AtomsQtQueryPipe::update() { // clear target and put all atoms therein std::vector temp_atoms; for (std::set::iterator iter = currentList.begin(); iter != currentList.end(); ++iter) temp_atoms.push_back(*iter); content.set(temp_atoms); dialog->update(); } void AtomsQtQueryPipe::add() { QList items = theList->selectedItems(); for (QList::iterator iter = items.begin();iter != items.end();++iter) { const int index = (*iter)->text().toInt(); atom *Walker = World::getInstance().getAtom(AtomById(index)); if (Walker) { currentList.insert(Walker); if (lookup.find(index) != lookup.end()) lookup.insert(pair(index, Walker)); } } update(); } void AtomsQtQueryPipe::remove() { QList items = theList->selectedItems(); for (QList::iterator iter = items.begin();iter != items.end();++iter) { const int index = (*iter)->text().toInt(); atom *Walker = World::getInstance().getAtom(AtomById(index)); if (Walker) { currentList.erase(Walker); } } update(); }