/* * 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. */ /* * CenterOnEdgeAction.cpp * * Created on: May 8, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "atom.hpp" #include "CodePatterns/Log.hpp" #include "LinearAlgebra/Vector.hpp" #include "World.hpp" #include "LinearAlgebra/RealSpaceMatrix.hpp" #include #include #include "Actions/WorldAction/CenterOnEdgeAction.hpp" using namespace MoleCuilder; // and construct the stuff #include "CenterOnEdgeAction.def" #include "Action_impl_pre.hpp" /** =========== define the function ====================== */ Action::state_ptr WorldCenterOnEdgeAction::performCall() { Vector Min; Vector Max; // obtain information getParametersfromValueStorage(); // get maximum and minimum vector AllAtoms = World::getInstance().getAllAtoms(); ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present."); vector::iterator AtomRunner = AllAtoms.begin(); Min = (*AtomRunner)->getPosition(); Max = (*AtomRunner)->getPosition(); for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { for (int i=0;iat(i) > Max[i]) Max[i] = (*AtomRunner)->at(i); if ((*AtomRunner)->at(i) < Min[i]) Min[i] = (*AtomRunner)->at(i); } } // set new box size RealSpaceMatrix domain; for (int i=0;i=1. ? tmp : 1.0; domain.at(i,i) = tmp; } World::getInstance().setDomain(domain); // translate all atoms, such that Min is aty (0,0,0) for (vector::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) *(*AtomRunner) -= Min; // give final box size LOG(0, "Box domain is now " << World::getInstance().getDomain().getM()); return Action::success; } Action::state_ptr WorldCenterOnEdgeAction::performUndo(Action::state_ptr _state) { // ParserLoadXyzState *state = assert_cast(_state.get()); return Action::failure; // string newName = state->mol->getName(); // state->mol->setName(state->lastName); // // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); } Action::state_ptr WorldCenterOnEdgeAction::performRedo(Action::state_ptr _state){ return Action::failure; } bool WorldCenterOnEdgeAction::canUndo() { return false; } bool WorldCenterOnEdgeAction::shouldUndo() { return false; } /** =========== end of function ====================== */