| [bcf653] | 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 |  | 
|---|
| [97ebf8] | 8 | /* | 
|---|
|  | 9 | * ScaleBoxAction.cpp | 
|---|
|  | 10 | * | 
|---|
|  | 11 | *  Created on: May 8, 2010 | 
|---|
|  | 12 | *      Author: heber | 
|---|
|  | 13 | */ | 
|---|
|  | 14 |  | 
|---|
| [bf3817] | 15 | // include config.h | 
|---|
|  | 16 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 17 | #include <config.h> | 
|---|
|  | 18 | #endif | 
|---|
|  | 19 |  | 
|---|
| [112b09] | 20 | #include "Helpers/MemDebug.hpp" | 
|---|
|  | 21 |  | 
|---|
| [97ebf8] | 22 | #include "atom.hpp" | 
|---|
| [952f38] | 23 | #include "Helpers/Log.hpp" | 
|---|
| [57f243] | 24 | #include "LinearAlgebra/Vector.hpp" | 
|---|
| [952f38] | 25 | #include "Helpers/Verbose.hpp" | 
|---|
| [97ebf8] | 26 | #include "World.hpp" | 
|---|
| [84c494] | 27 | #include "Box.hpp" | 
|---|
| [cca9ef] | 28 | #include "LinearAlgebra/RealSpaceMatrix.hpp" | 
|---|
| [97ebf8] | 29 |  | 
|---|
|  | 30 | #include <iostream> | 
|---|
|  | 31 | #include <string> | 
|---|
|  | 32 |  | 
|---|
|  | 33 | using namespace std; | 
|---|
|  | 34 |  | 
|---|
| [1fd675] | 35 | #include "Actions/WorldAction/ScaleBoxAction.hpp" | 
|---|
| [22e780] | 36 |  | 
|---|
| [1fd675] | 37 | // and construct the stuff | 
|---|
|  | 38 | #include "ScaleBoxAction.def" | 
|---|
|  | 39 | #include "Action_impl_pre.hpp" | 
|---|
|  | 40 | /** =========== define the function ====================== */ | 
|---|
| [22e780] | 41 | Action::state_ptr WorldScaleBoxAction::performCall() { | 
|---|
| [97ebf8] | 42 | double x[NDIM]; | 
|---|
|  | 43 |  | 
|---|
| [1fd675] | 44 | // obtain information | 
|---|
|  | 45 | getParametersfromValueStorage(); | 
|---|
| [22e780] | 46 |  | 
|---|
|  | 47 | DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl); | 
|---|
|  | 48 | for (int i=0;i<NDIM;i++) | 
|---|
| [1fd675] | 49 | x[i] = params.Scaler[i]; | 
|---|
| [22e780] | 50 | vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); | 
|---|
|  | 51 | for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { | 
|---|
| [d74077] | 52 | (*AtomRunner)->ScaleAll(x); | 
|---|
| [97ebf8] | 53 | } | 
|---|
| [22e780] | 54 |  | 
|---|
| [cca9ef] | 55 | RealSpaceMatrix M = World::getInstance().getDomain().getM(); | 
|---|
|  | 56 | RealSpaceMatrix scale; | 
|---|
| [22e780] | 57 |  | 
|---|
|  | 58 | for (int i=0;i<NDIM;i++) { | 
|---|
|  | 59 | scale.at(i,i) = x[i]; | 
|---|
|  | 60 | } | 
|---|
|  | 61 | M *= scale; | 
|---|
|  | 62 | World::getInstance().setDomain(M); | 
|---|
|  | 63 |  | 
|---|
|  | 64 | return Action::success; | 
|---|
| [97ebf8] | 65 | } | 
|---|
|  | 66 |  | 
|---|
|  | 67 | Action::state_ptr WorldScaleBoxAction::performUndo(Action::state_ptr _state) { | 
|---|
|  | 68 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); | 
|---|
|  | 69 |  | 
|---|
|  | 70 | return Action::failure; | 
|---|
|  | 71 | //  string newName = state->mol->getName(); | 
|---|
|  | 72 | //  state->mol->setName(state->lastName); | 
|---|
|  | 73 | // | 
|---|
|  | 74 | //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); | 
|---|
|  | 75 | } | 
|---|
|  | 76 |  | 
|---|
|  | 77 | Action::state_ptr WorldScaleBoxAction::performRedo(Action::state_ptr _state){ | 
|---|
|  | 78 | return Action::failure; | 
|---|
|  | 79 | } | 
|---|
|  | 80 |  | 
|---|
|  | 81 | bool WorldScaleBoxAction::canUndo() { | 
|---|
|  | 82 | return false; | 
|---|
|  | 83 | } | 
|---|
|  | 84 |  | 
|---|
|  | 85 | bool WorldScaleBoxAction::shouldUndo() { | 
|---|
|  | 86 | return false; | 
|---|
|  | 87 | } | 
|---|
| [1fd675] | 88 | /** =========== end of function ====================== */ | 
|---|