| 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 |  * SuspendInWaterAction.cpp
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *  Created on: May 12, 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 "boundary.hpp"
 | 
|---|
| 23 | #include "config.hpp"
 | 
|---|
| 24 | #include "CodePatterns/Log.hpp"
 | 
|---|
| 25 | #include "CodePatterns/Verbose.hpp"
 | 
|---|
| 26 | #include "World.hpp"
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #include <iostream>
 | 
|---|
| 29 | #include <string>
 | 
|---|
| 30 | 
 | 
|---|
| 31 | using namespace std;
 | 
|---|
| 32 | 
 | 
|---|
| 33 | #include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
 | 
|---|
| 34 | 
 | 
|---|
| 35 | // and construct the stuff
 | 
|---|
| 36 | #include "SuspendInWaterAction.def"
 | 
|---|
| 37 | #include "Action_impl_pre.hpp"
 | 
|---|
| 38 | /** =========== define the function ====================== */
 | 
|---|
| 39 | Action::state_ptr MoleculeSuspendInWaterAction::performCall() {
 | 
|---|
| 40 |   molecule *mol = NULL;
 | 
|---|
| 41 |   double volume = 0.;
 | 
|---|
| 42 | 
 | 
|---|
| 43 |   // obtain information
 | 
|---|
| 44 |   getParametersfromValueStorage();
 | 
|---|
| 45 | 
 | 
|---|
| 46 |   for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
 | 
|---|
| 47 |     mol = iter->second;
 | 
|---|
| 48 |     DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
 | 
|---|
| 49 |     if (params.density < 1.0) {
 | 
|---|
| 50 |       DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3!" << endl);
 | 
|---|
| 51 |     } else {
 | 
|---|
| 52 |       PrepareClustersinWater(World::getInstance().getConfig(), mol, volume, params.density);  // if volume == 0, will calculate from ConvexEnvelope
 | 
|---|
| 53 |     }
 | 
|---|
| 54 |   }
 | 
|---|
| 55 |   return Action::success;
 | 
|---|
| 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 | /** =========== end of function ====================== */
 | 
|---|