[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[bcf653] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[e472eab] | 8 | /*
|
---|
| 9 | * NotAllAtomsAction.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 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[e472eab] | 21 |
|
---|
| 22 | #include "Descriptors/AtomDescriptor.hpp"
|
---|
[6f0841] | 23 | #include "Atom/atom.hpp"
|
---|
[ad011c] | 24 | #include "CodePatterns/Log.hpp"
|
---|
| 25 | #include "CodePatterns/Verbose.hpp"
|
---|
[e472eab] | 26 | #include "World.hpp"
|
---|
| 27 |
|
---|
[92d756] | 28 | #include <boost/foreach.hpp>
|
---|
[e472eab] | 29 | #include <iostream>
|
---|
| 30 | #include <string>
|
---|
| 31 |
|
---|
[125002] | 32 | #include "NotAllAtomsAction.hpp"
|
---|
[e472eab] | 33 |
|
---|
[ce7fdc] | 34 | using namespace MoleCuilder;
|
---|
| 35 |
|
---|
[1fd675] | 36 | // and construct the stuff
|
---|
| 37 | #include "NotAllAtomsAction.def"
|
---|
| 38 | #include "Action_impl_pre.hpp"
|
---|
| 39 | /** =========== define the function ====================== */
|
---|
[e472eab] | 40 | Action::state_ptr SelectionNotAllAtomsAction::performCall() {
|
---|
| 41 | std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
|
---|
[47d041] | 42 | LOG(1, "Unselecting all atoms.");
|
---|
[e472eab] | 43 | World::getInstance().clearAtomSelection();
|
---|
[47d041] | 44 | LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected.");
|
---|
[1fd675] | 45 | return Action::state_ptr(new SelectionNotAllAtomsState(selectedAtoms, params));
|
---|
[e472eab] | 46 | }
|
---|
| 47 |
|
---|
| 48 | Action::state_ptr SelectionNotAllAtomsAction::performUndo(Action::state_ptr _state) {
|
---|
[53fb71] | 49 | SelectionNotAllAtomsState *state = assert_cast<SelectionNotAllAtomsState*>(_state.get());
|
---|
[e472eab] | 50 |
|
---|
| 51 | World::getInstance().clearAtomSelection();
|
---|
[92d756] | 52 | BOOST_FOREACH(atom *_atom, state->unselectedAtoms)
|
---|
| 53 | World::getInstance().selectAtom(_atom);
|
---|
[e472eab] | 54 |
|
---|
[1fd675] | 55 | return Action::state_ptr(_state);
|
---|
[e472eab] | 56 | }
|
---|
| 57 |
|
---|
| 58 | Action::state_ptr SelectionNotAllAtomsAction::performRedo(Action::state_ptr _state){
|
---|
[1fd675] | 59 | //SelectionNotAllAtomsState *state = assert_cast<SelectionNotAllAtomsState*>(_state.get());
|
---|
[e472eab] | 60 |
|
---|
| 61 | World::getInstance().clearAtomSelection();
|
---|
| 62 |
|
---|
[1fd675] | 63 | return Action::state_ptr(_state);
|
---|
[e472eab] | 64 | }
|
---|
| 65 |
|
---|
| 66 | bool SelectionNotAllAtomsAction::canUndo() {
|
---|
| 67 | return true;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | bool SelectionNotAllAtomsAction::shouldUndo() {
|
---|
| 71 | return true;
|
---|
| 72 | }
|
---|
[1fd675] | 73 | /** =========== end of function ====================== */
|
---|