- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/CopyAction.cpp
rbe21fa r8ea3e7 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include "Actions/UndoRedoHelpers.hpp" 22 23 #include "CodePatterns/Log.hpp" 23 24 #include "CodePatterns/Verbose.hpp" … … 31 32 #include <fstream> 32 33 #include <string> 34 #include <vector> 33 35 34 36 #include "Actions/MoleculeAction/CopyAction.hpp" … … 40 42 #include "Action_impl_pre.hpp" 41 43 /** =========== define the function ====================== */ 42 Action::state_ptr MoleculeCopyAction::performCall() { 43 molecule *copy = NULL; 44 Action::state_ptr MoleculeCopyAction::performCall() 45 { 46 std::vector<moleculeId_t> molecules; 47 for (World::MoleculeSelectionConstIterator iter = World::getInstance().beginMoleculeSelection(); 48 iter != World::getInstance().endMoleculeSelection(); ++iter) { 49 molecule * const copy = (iter->second)->CopyMolecule(); 50 Vector *Center = (iter->second)->DetermineCenterOfAll(); 51 *Center *= -1.; 52 *Center += params.position.get(); 53 copy->Translate(Center); 54 delete(Center); 55 molecules.push_back(copy->getId()); 56 } 44 57 45 copy = params.mol->CopyMolecule(); 46 Vector *Center = params.mol->DetermineCenterOfAll(); 47 *Center *= -1.; 48 *Center += params.position; 49 copy->Translate(Center); 50 delete(Center); 51 52 return Action::state_ptr(new MoleculeCopyState(copy,params)); 58 return Action::state_ptr(new MoleculeCopyState(molecules,params)); 53 59 } 54 60 … … 56 62 MoleculeCopyState *state = assert_cast<MoleculeCopyState*>(_state.get()); 57 63 58 state->copy->removeAtomsinMolecule(); 59 World::getInstance().destroyMolecule(state->copy); 64 RemoveMoleculesWithAtomsByIds(state->copies); 60 65 61 66 return Action::state_ptr(_state); … … 63 68 64 69 Action::state_ptr MoleculeCopyAction::performRedo(Action::state_ptr _state){ 65 MoleculeCopyState *state = assert_cast<MoleculeCopyState*>(_state.get()); 66 67 molecule *copy = state->params.mol->CopyMolecule(); 68 Vector *Center = state->params.mol->DetermineCenterOfAll(); 69 *Center *= -1.; 70 *Center += state->params.position; 71 copy->Translate(Center); 72 delete(Center); 73 74 return Action::state_ptr(new MoleculeCopyState(copy,state->params)); 70 return performCall(); 75 71 } 76 72
Note:
See TracChangeset
for help on using the changeset viewer.