| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010 University of Bonn. All rights reserved.
 | 
|---|
| 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | /*
 | 
|---|
| 9 |  * CenterInBoxAction.cpp
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *  Created on: May 8, 2010
 | 
|---|
| 12 |  *      Author: heber
 | 
|---|
| 13 |  */
 | 
|---|
| 14 | 
 | 
|---|
| 15 | // include config.h
 | 
|---|
| 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 17 | #include <config.h>
 | 
|---|
| 18 | #endif
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #include "Box.hpp"
 | 
|---|
| 23 | #include "CodePatterns/Log.hpp"
 | 
|---|
| 24 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
 | 
|---|
| 25 | #include "molecule.hpp"
 | 
|---|
| 26 | #include "World.hpp"
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #include <iostream>
 | 
|---|
| 29 | #include <string>
 | 
|---|
| 30 | 
 | 
|---|
| 31 | #include "Actions/WorldAction/CenterInBoxAction.hpp"
 | 
|---|
| 32 | 
 | 
|---|
| 33 | using namespace MoleCuilder;
 | 
|---|
| 34 | 
 | 
|---|
| 35 | // and construct the stuff
 | 
|---|
| 36 | #include "CenterInBoxAction.def"
 | 
|---|
| 37 | #include "Action_impl_pre.hpp"
 | 
|---|
| 38 | /** =========== define the function ====================== */
 | 
|---|
| 39 | Action::state_ptr WorldCenterInBoxAction::performCall() {
 | 
|---|
| 40 |   // obtain information
 | 
|---|
| 41 |   getParametersfromValueStorage();
 | 
|---|
| 42 | 
 | 
|---|
| 43 |   World::getInstance().setDomain(params.cell_size.getM());
 | 
|---|
| 44 | 
 | 
|---|
| 45 |   // center
 | 
|---|
| 46 |   vector<molecule *> AllMolecules = World::getInstance().getAllMolecules();
 | 
|---|
| 47 |   for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
 | 
|---|
| 48 |     (*MolRunner)->CenterInBox();
 | 
|---|
| 49 |   }
 | 
|---|
| 50 | 
 | 
|---|
| 51 |   // give final box size
 | 
|---|
| 52 |   LOG(0, "Box domain is now " << World::getInstance().getDomain().getM());
 | 
|---|
| 53 | 
 | 
|---|
| 54 |   return Action::success;
 | 
|---|
| 55 | }
 | 
|---|
| 56 | 
 | 
|---|
| 57 | Action::state_ptr WorldCenterInBoxAction::performUndo(Action::state_ptr _state) {
 | 
|---|
| 58 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
 | 
|---|
| 59 | 
 | 
|---|
| 60 |   return Action::failure;
 | 
|---|
| 61 | //  string newName = state->mol->getName();
 | 
|---|
| 62 | //  state->mol->setName(state->lastName);
 | 
|---|
| 63 | //
 | 
|---|
| 64 | //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
 | 
|---|
| 65 | }
 | 
|---|
| 66 | 
 | 
|---|
| 67 | Action::state_ptr WorldCenterInBoxAction::performRedo(Action::state_ptr _state){
 | 
|---|
| 68 |   return Action::failure;
 | 
|---|
| 69 | }
 | 
|---|
| 70 | 
 | 
|---|
| 71 | bool WorldCenterInBoxAction::canUndo() {
 | 
|---|
| 72 |   return false;
 | 
|---|
| 73 | }
 | 
|---|
| 74 | 
 | 
|---|
| 75 | bool WorldCenterInBoxAction::shouldUndo() {
 | 
|---|
| 76 |   return false;
 | 
|---|
| 77 | }
 | 
|---|
| 78 | /** =========== end of function ====================== */
 | 
|---|