Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/WorldAction/AddEmptyBoundaryAction.cpp

    r9cd6bf rce7fdc  
    1818#endif
    1919
    20 // include headers that implement a archive in simple text format
    21 #include <boost/archive/text_oarchive.hpp>
    22 #include <boost/archive/text_iarchive.hpp>
    23 #include "boost/serialization/vector.hpp"
    24 
    2520#include "CodePatterns/MemDebug.hpp"
    2621
    2722#include "atom.hpp"
    28 #include "Box.hpp"
    2923#include "CodePatterns/Log.hpp"
    30 #include "LinearAlgebra/MatrixContent.hpp"
    3124#include "LinearAlgebra/RealSpaceMatrix.hpp"
    3225#include "LinearAlgebra/Vector.hpp"
     
    5346  getParametersfromValueStorage();
    5447
    55   // create undo domain
    56   std::stringstream undostream;
    57   boost::archive::text_oarchive oa(undostream);
    58   const RealSpaceMatrix &matrix = World::getInstance().getDomain().getM();
    59   oa << matrix;
    60 
    6148  // get maximum and minimum
    62   std::vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
     49  vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
    6350  ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary.");
    64   std::vector<atom *>::iterator AtomRunner = AllAtoms.begin();
     51  vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    6552  Min = (*AtomRunner)->getPosition();
    6653  Max = (*AtomRunner)->getPosition();
     
    8673  // translate all atoms, such that Min is aty (0,0,0)
    8774  AtomRunner = AllAtoms.begin();
    88   for (std::vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    89       AtomRunner != AllAtoms.end();
    90       ++AtomRunner)
     75  for (; AtomRunner != AllAtoms.end(); ++AtomRunner)
    9176    *(*AtomRunner) -= Min - params.boundary;
    9277
     
    9479  LOG(0, "Box domain is now " << World::getInstance().getDomain().getM());
    9580
    96   // create undo state
    97   WorldAddEmptyBoundaryState *UndoState =
    98       new WorldAddEmptyBoundaryState(
    99           undostream.str(),
    100           World::getInstance().getDomain().getM(),
    101           Min,
    102           params
    103           );
    104 
    105   return Action::state_ptr(UndoState);
     81  return Action::success;
    10682}
    10783
    10884Action::state_ptr WorldAddEmptyBoundaryAction::performUndo(Action::state_ptr _state) {
    109   WorldAddEmptyBoundaryState *state = assert_cast<WorldAddEmptyBoundaryState*>(_state.get());
     85//  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    11086
    111   // restore domain
    112   RealSpaceMatrix matrix;
    113   std::stringstream undostream(state->undostring);
    114   boost::archive::text_iarchive ia(undostream);
    115   ia >> matrix;
    116   World::getInstance().setDomain(matrix);
    117 
    118   // give final box size
    119   LOG(0, "Box domain restored to " << World::getInstance().getDomain().getM());
    120 
    121   // restore atoms
    122   std::vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
    123   for (std::vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    124       AtomRunner != AllAtoms.end();
    125       ++AtomRunner)
    126     *(*AtomRunner) += state->Min - state->params.boundary;
    127 
    128   return Action::state_ptr(_state);
     87  return Action::failure;
     88//  string newName = state->mol->getName();
     89//  state->mol->setName(state->lastName);
     90//
     91//  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
    12992}
    13093
    13194Action::state_ptr WorldAddEmptyBoundaryAction::performRedo(Action::state_ptr _state){
    132   WorldAddEmptyBoundaryState *state = assert_cast<WorldAddEmptyBoundaryState*>(_state.get());
    133 
    134   World::getInstance().setDomain(state->newdomain);
    135 
    136   // give final box size
    137   LOG(0, "Box domain is again " << World::getInstance().getDomain().getM());
    138 
    139   // shift atoms
    140   std::vector<atom *> AllAtoms = World::getInstance().getAllAtoms();
    141   for (std::vector<atom *>::iterator AtomRunner = AllAtoms.begin();
    142       AtomRunner != AllAtoms.end();
    143       ++AtomRunner)
    144     *(*AtomRunner) -= state->Min - state->params.boundary;
    145 
    146   return Action::state_ptr(_state);
     95  return Action::failure;
    14796}
    14897
    14998bool WorldAddEmptyBoundaryAction::canUndo() {
    150   return true;
     99  return false;
    151100}
    152101
    153102bool WorldAddEmptyBoundaryAction::shouldUndo() {
    154   return true;
     103  return false;
    155104}
    156105/** =========== end of function ====================== */
Note: See TracChangeset for help on using the changeset viewer.