/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * * * This file is part of MoleCuilder. * * MoleCuilder is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MoleCuilder is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MoleCuilder. If not, see . */ /* * ClearAllMoleculesAction.cpp * * Created on: Aug 09, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "Descriptors/MoleculeDescriptor.hpp" #include "Atom/atom.hpp" #include "CodePatterns/Log.hpp" #include "CodePatterns/Verbose.hpp" #include "World.hpp" #include #include #include #include "ClearAllMoleculesAction.hpp" using namespace MoleCuilder; // and construct the stuff #include "ClearAllMoleculesAction.def" #include "Action_impl_pre.hpp" /** =========== define the function ====================== */ ActionState::ptr SelectionClearAllMoleculesAction::performCall() { const std::vector selectedMolecules = const_cast(World::getInstance()).getSelectedMolecules(); LOG(1, "Clearing molecule selection."); World::getInstance().clearMoleculeSelection(); LOG(0, World::getInstance().countSelectedMolecules() << " molecules remain selected."); return ActionState::ptr(new SelectionClearAllMoleculesState(selectedMolecules,params)); } ActionState::ptr SelectionClearAllMoleculesAction::performUndo(ActionState::ptr _state) { SelectionClearAllMoleculesState *state = assert_cast(_state.get()); World::getInstance().clearMoleculeSelection(); BOOST_FOREACH(const molecule *_mol, state->selectedMolecules) World::getInstance().selectMolecule(_mol); return ActionState::ptr(_state); } ActionState::ptr SelectionClearAllMoleculesAction::performRedo(ActionState::ptr _state){ //SelectionClearAllMoleculesState *state = assert_cast(_state.get()); World::getInstance().clearMoleculeSelection(); return ActionState::ptr(_state); } bool SelectionClearAllMoleculesAction::canUndo() { return true; } bool SelectionClearAllMoleculesAction::shouldUndo() { return true; } /** =========== end of function ====================== */