[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 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 21 |
|
---|
[97ebf8] | 22 | #include "atom.hpp"
|
---|
[ad011c] | 23 | #include "CodePatterns/Log.hpp"
|
---|
[57f243] | 24 | #include "LinearAlgebra/Vector.hpp"
|
---|
[ad011c] | 25 | #include "CodePatterns/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 |
|
---|
[3bd460a] | 64 | // give final box size
|
---|
| 65 | LOG(0, "Box domain is now " << World::getInstance().getDomain().getM());
|
---|
| 66 |
|
---|
[22e780] | 67 | return Action::success;
|
---|
[97ebf8] | 68 | }
|
---|
| 69 |
|
---|
| 70 | Action::state_ptr WorldScaleBoxAction::performUndo(Action::state_ptr _state) {
|
---|
| 71 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
---|
| 72 |
|
---|
| 73 | return Action::failure;
|
---|
| 74 | // string newName = state->mol->getName();
|
---|
| 75 | // state->mol->setName(state->lastName);
|
---|
| 76 | //
|
---|
| 77 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | Action::state_ptr WorldScaleBoxAction::performRedo(Action::state_ptr _state){
|
---|
| 81 | return Action::failure;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | bool WorldScaleBoxAction::canUndo() {
|
---|
| 85 | return false;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | bool WorldScaleBoxAction::shouldUndo() {
|
---|
| 89 | return false;
|
---|
| 90 | }
|
---|
[1fd675] | 91 | /** =========== end of function ====================== */
|
---|