[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 | * SuspendInWaterAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: May 12, 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 |
|
---|
[1a3c26] | 22 | #include "boundary.hpp"
|
---|
| 23 | #include "config.hpp"
|
---|
[952f38] | 24 | #include "Helpers/Log.hpp"
|
---|
| 25 | #include "Helpers/Verbose.hpp"
|
---|
[1a3c26] | 26 | #include "World.hpp"
|
---|
[97ebf8] | 27 |
|
---|
| 28 | #include <iostream>
|
---|
| 29 | #include <string>
|
---|
| 30 |
|
---|
| 31 | using namespace std;
|
---|
| 32 |
|
---|
[1fd675] | 33 | #include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
|
---|
[b9b26b] | 34 |
|
---|
[1fd675] | 35 | // and construct the stuff
|
---|
| 36 | #include "SuspendInWaterAction.def"
|
---|
| 37 | #include "Action_impl_pre.hpp"
|
---|
| 38 | /** =========== define the function ====================== */
|
---|
[97ebf8] | 39 | Action::state_ptr MoleculeSuspendInWaterAction::performCall() {
|
---|
| 40 | molecule *mol = NULL;
|
---|
| 41 | double volume = 0.;
|
---|
| 42 |
|
---|
[1fd675] | 43 | // obtain information
|
---|
| 44 | getParametersfromValueStorage();
|
---|
[97ebf8] | 45 |
|
---|
[b9b26b] | 46 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
---|
| 47 | mol = iter->second;
|
---|
[97ebf8] | 48 | DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
|
---|
[1fd675] | 49 | if (params.density < 1.0) {
|
---|
[97ebf8] | 50 | DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3!" << endl);
|
---|
| 51 | } else {
|
---|
[1fd675] | 52 | PrepareClustersinWater(World::getInstance().getConfig(), mol, volume, params.density); // if volume == 0, will calculate from ConvexEnvelope
|
---|
[97ebf8] | 53 | }
|
---|
| 54 | }
|
---|
[b9b26b] | 55 | return Action::success;
|
---|
[97ebf8] | 56 | }
|
---|
| 57 |
|
---|
| 58 | Action::state_ptr MoleculeSuspendInWaterAction::performUndo(Action::state_ptr _state) {
|
---|
| 59 | // MoleculeSuspendInWaterState *state = assert_cast<MoleculeSuspendInWaterState*>(_state.get());
|
---|
| 60 |
|
---|
| 61 | // string newName = state->mol->getName();
|
---|
| 62 | // state->mol->setName(state->lastName);
|
---|
| 63 |
|
---|
| 64 | return Action::failure;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | Action::state_ptr MoleculeSuspendInWaterAction::performRedo(Action::state_ptr _state){
|
---|
| 68 | // Undo and redo have to do the same for this action
|
---|
| 69 | return performUndo(_state);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | bool MoleculeSuspendInWaterAction::canUndo() {
|
---|
| 73 | return false;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | bool MoleculeSuspendInWaterAction::shouldUndo() {
|
---|
| 77 | return false;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | const string MoleculeSuspendInWaterAction::getName() {
|
---|
| 81 | return NAME;
|
---|
| 82 | }
|
---|
[1fd675] | 83 | /** =========== end of function ====================== */
|
---|