| [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 |  | 
|---|
| [e472eab] | 8 | /* | 
|---|
|  | 9 | * AllAtomsAction.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 |  | 
|---|
| [e472eab] | 20 | #include "Helpers/MemDebug.hpp" | 
|---|
|  | 21 |  | 
|---|
|  | 22 | #include "Descriptors/AtomDescriptor.hpp" | 
|---|
|  | 23 | #include "atom.hpp" | 
|---|
| [952f38] | 24 | #include "Helpers/Log.hpp" | 
|---|
|  | 25 | #include "Helpers/Verbose.hpp" | 
|---|
| [e472eab] | 26 | #include "World.hpp" | 
|---|
|  | 27 |  | 
|---|
| [92d756] | 28 | #include <boost/foreach.hpp> | 
|---|
| [e472eab] | 29 | #include <iostream> | 
|---|
|  | 30 | #include <string> | 
|---|
|  | 31 |  | 
|---|
|  | 32 | using namespace std; | 
|---|
|  | 33 |  | 
|---|
| [125002] | 34 | #include "AllAtomsAction.hpp" | 
|---|
| [e472eab] | 35 |  | 
|---|
| [1fd675] | 36 | // and construct the stuff | 
|---|
|  | 37 | #include "AllAtomsAction.def" | 
|---|
|  | 38 | #include "Action_impl_pre.hpp" | 
|---|
|  | 39 | /** =========== define the function ====================== */ | 
|---|
| [e472eab] | 40 | Action::state_ptr SelectionAllAtomsAction::performCall() { | 
|---|
| [1fd675] | 41 | // obtain information | 
|---|
|  | 42 | getParametersfromValueStorage(); | 
|---|
|  | 43 |  | 
|---|
| [e472eab] | 44 | std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms(); | 
|---|
|  | 45 | DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms." << endl); | 
|---|
|  | 46 | World::getInstance().selectAllAtoms(AllAtoms()); | 
|---|
| [1fd675] | 47 | return Action::state_ptr(new SelectionAllAtomsState(selectedAtoms,params)); | 
|---|
| [e472eab] | 48 | } | 
|---|
|  | 49 |  | 
|---|
|  | 50 | Action::state_ptr SelectionAllAtomsAction::performUndo(Action::state_ptr _state) { | 
|---|
|  | 51 | SelectionAllAtomsState *state = assert_cast<SelectionAllAtomsState*>(_state.get()); | 
|---|
|  | 52 |  | 
|---|
|  | 53 | World::getInstance().clearAtomSelection(); | 
|---|
| [92d756] | 54 |  | 
|---|
|  | 55 | BOOST_FOREACH(atom *_atom, state->selectedAtoms) | 
|---|
|  | 56 | World::getInstance().selectAtom(_atom); | 
|---|
| [e472eab] | 57 |  | 
|---|
| [1fd675] | 58 | return Action::state_ptr(_state); | 
|---|
| [e472eab] | 59 | } | 
|---|
|  | 60 |  | 
|---|
|  | 61 | Action::state_ptr SelectionAllAtomsAction::performRedo(Action::state_ptr _state){ | 
|---|
| [1fd675] | 62 | //SelectionAllAtomsState *state = assert_cast<SelectionAllAtomsState*>(_state.get()); | 
|---|
| [e472eab] | 63 |  | 
|---|
|  | 64 | World::getInstance().selectAllAtoms(AllAtoms()); | 
|---|
|  | 65 |  | 
|---|
| [1fd675] | 66 | return Action::state_ptr(_state); | 
|---|
| [e472eab] | 67 | } | 
|---|
|  | 68 |  | 
|---|
|  | 69 | bool SelectionAllAtomsAction::canUndo() { | 
|---|
|  | 70 | return true; | 
|---|
|  | 71 | } | 
|---|
|  | 72 |  | 
|---|
|  | 73 | bool SelectionAllAtomsAction::shouldUndo() { | 
|---|
|  | 74 | return true; | 
|---|
|  | 75 | } | 
|---|
| [1fd675] | 76 | /** =========== end of function ====================== */ | 
|---|