[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 |
|
---|
[e212ff] | 8 | /*
|
---|
| 9 | * ClearAllAtomsAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: Aug 09, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[e212ff] | 21 |
|
---|
| 22 | #include "Descriptors/AtomDescriptor.hpp"
|
---|
| 23 | #include "atom.hpp"
|
---|
[ad011c] | 24 | #include "CodePatterns/Log.hpp"
|
---|
| 25 | #include "CodePatterns/Verbose.hpp"
|
---|
[e212ff] | 26 | #include "World.hpp"
|
---|
| 27 |
|
---|
[92d756] | 28 | #include <boost/foreach.hpp>
|
---|
[e212ff] | 29 | #include <iostream>
|
---|
| 30 | #include <string>
|
---|
| 31 |
|
---|
[125002] | 32 | #include "ClearAllAtomsAction.hpp"
|
---|
[e212ff] | 33 |
|
---|
[ce7fdc] | 34 | using namespace MoleCuilder;
|
---|
| 35 |
|
---|
[1fd675] | 36 | // and construct the stuff
|
---|
| 37 | #include "ClearAllAtomsAction.def"
|
---|
| 38 | #include "Action_impl_pre.hpp"
|
---|
| 39 | /** =========== define the function ====================== */
|
---|
[e212ff] | 40 | Action::state_ptr SelectionClearAllAtomsAction::performCall() {
|
---|
[1fd675] | 41 | // obtain information
|
---|
| 42 | getParametersfromValueStorage();
|
---|
| 43 |
|
---|
[e212ff] | 44 | std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
|
---|
[47d041] | 45 | LOG(1, "Clearing atoms selection.");
|
---|
[e212ff] | 46 | World::getInstance().clearAtomSelection();
|
---|
[1fd675] | 47 | return Action::state_ptr(new SelectionClearAllAtomsState(selectedAtoms, params));
|
---|
[e212ff] | 48 | }
|
---|
| 49 |
|
---|
| 50 | Action::state_ptr SelectionClearAllAtomsAction::performUndo(Action::state_ptr _state) {
|
---|
| 51 | SelectionClearAllAtomsState *state = assert_cast<SelectionClearAllAtomsState*>(_state.get());
|
---|
| 52 |
|
---|
| 53 | World::getInstance().clearAtomSelection();
|
---|
[92d756] | 54 | BOOST_FOREACH(atom *_atom, state->selectedAtoms)
|
---|
| 55 | World::getInstance().selectAtom(_atom);
|
---|
[e212ff] | 56 |
|
---|
[1fd675] | 57 | return Action::state_ptr(_state);
|
---|
[e212ff] | 58 | }
|
---|
| 59 |
|
---|
| 60 | Action::state_ptr SelectionClearAllAtomsAction::performRedo(Action::state_ptr _state){
|
---|
[1fd675] | 61 | //SelectionClearAllAtomsState *state = assert_cast<SelectionClearAllAtomsState*>(_state.get());
|
---|
[e212ff] | 62 |
|
---|
| 63 | World::getInstance().clearAtomSelection();
|
---|
| 64 |
|
---|
[1fd675] | 65 | return Action::state_ptr(_state);
|
---|
[e212ff] | 66 | }
|
---|
| 67 |
|
---|
| 68 | bool SelectionClearAllAtomsAction::canUndo() {
|
---|
| 69 | return true;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | bool SelectionClearAllAtomsAction::shouldUndo() {
|
---|
| 73 | return true;
|
---|
| 74 | }
|
---|
[1fd675] | 75 | /** =========== end of function ====================== */
|
---|