/* * 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. */ /* * NotMoleculeByIdAction.cpp * * Created on: May 12, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "Helpers/MemDebug.hpp" #include "molecule.hpp" #include "Helpers/Log.hpp" #include "Helpers/Verbose.hpp" #include "World.hpp" #include #include using namespace std; #include "Actions/SelectionAction/NotMoleculeByIdAction.hpp" // and construct the stuff #include "NotMoleculeByIdAction.def" #include "Action_impl_pre.hpp" /** =========== define the function ====================== */ Action::state_ptr SelectionNotMoleculeByIdAction::performCall() { // obtain information getParametersfromValueStorage(); if (World::getInstance().isSelected(params.mol)) { DoLog(1) && (Log() << Verbose(1) << "Unselecting molecule " << params.mol->name << endl); World::getInstance().unselectMolecule(params.mol); return Action::state_ptr(new SelectionNotMoleculeByIdState(params)); } else { return Action::success; } } Action::state_ptr SelectionNotMoleculeByIdAction::performUndo(Action::state_ptr _state) { SelectionNotMoleculeByIdState *state = assert_cast(_state.get()); if (state->params.mol != NULL) World::getInstance().selectMolecule(state->params.mol); return Action::state_ptr(_state); } Action::state_ptr SelectionNotMoleculeByIdAction::performRedo(Action::state_ptr _state){ SelectionNotMoleculeByIdState *state = assert_cast(_state.get()); if (state->params.mol != NULL) World::getInstance().unselectMolecule(state->params.mol); return Action::state_ptr(_state); } bool SelectionNotMoleculeByIdAction::canUndo() { return true; } bool SelectionNotMoleculeByIdAction::shouldUndo() { return true; } /** =========== end of function ====================== */