[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 |
|
---|
[770287] | 8 | /*
|
---|
| 9 | * AllAtomsOfMoleculeAction.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 |
|
---|
[770287] | 20 | #include "Helpers/MemDebug.hpp"
|
---|
| 21 |
|
---|
| 22 | #include "Descriptors/AtomDescriptor.hpp"
|
---|
| 23 | #include "atom.hpp"
|
---|
| 24 | #include "molecule.hpp"
|
---|
| 25 | #include "Helpers/Log.hpp"
|
---|
| 26 | #include "Helpers/Verbose.hpp"
|
---|
| 27 | #include "World.hpp"
|
---|
| 28 |
|
---|
| 29 | #include <iostream>
|
---|
| 30 | #include <string>
|
---|
| 31 |
|
---|
| 32 | using namespace std;
|
---|
| 33 |
|
---|
[1fd675] | 34 | #include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp"
|
---|
[770287] | 35 |
|
---|
[1fd675] | 36 | // and construct the stuff
|
---|
| 37 | #include "AllAtomsOfMoleculeAction.def"
|
---|
| 38 | #include "Action_impl_pre.hpp"
|
---|
| 39 | /** =========== define the function ====================== */
|
---|
[770287] | 40 | Action::state_ptr SelectionAllAtomsOfMoleculeAction::performCall() {
|
---|
| 41 | std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
|
---|
| 42 |
|
---|
[1fd675] | 43 | // obtain information
|
---|
| 44 | getParametersfromValueStorage();
|
---|
[770287] | 45 |
|
---|
[1fd675] | 46 | DoLog(1) && (Log() << Verbose(1) << "Selecting all atoms of molecule " << params.mol->getName() << "." << endl);
|
---|
| 47 | World::getInstance().selectAtomsOfMolecule(params.mol);
|
---|
| 48 | return Action::state_ptr(new SelectionAllAtomsOfMoleculeState(selectedAtoms, params));
|
---|
[770287] | 49 | }
|
---|
| 50 |
|
---|
| 51 | Action::state_ptr SelectionAllAtomsOfMoleculeAction::performUndo(Action::state_ptr _state) {
|
---|
| 52 | SelectionAllAtomsOfMoleculeState *state = assert_cast<SelectionAllAtomsOfMoleculeState*>(_state.get());
|
---|
| 53 |
|
---|
| 54 | World::getInstance().clearAtomSelection();
|
---|
| 55 | for(std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter)
|
---|
| 56 | World::getInstance().selectAtom(*iter);
|
---|
| 57 |
|
---|
[1fd675] | 58 | return Action::state_ptr(_state);
|
---|
[770287] | 59 | }
|
---|
| 60 |
|
---|
| 61 | Action::state_ptr SelectionAllAtomsOfMoleculeAction::performRedo(Action::state_ptr _state){
|
---|
| 62 | SelectionAllAtomsOfMoleculeState *state = assert_cast<SelectionAllAtomsOfMoleculeState*>(_state.get());
|
---|
| 63 |
|
---|
[1fd675] | 64 | World::getInstance().selectAtomsOfMolecule(state->params.mol);
|
---|
[770287] | 65 |
|
---|
[1fd675] | 66 | return Action::state_ptr(_state);
|
---|
[770287] | 67 | }
|
---|
| 68 |
|
---|
| 69 | bool SelectionAllAtomsOfMoleculeAction::canUndo() {
|
---|
| 70 | return true;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | bool SelectionAllAtomsOfMoleculeAction::shouldUndo() {
|
---|
| 74 | return true;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | const string SelectionAllAtomsOfMoleculeAction::getName() {
|
---|
| 78 | return NAME;
|
---|
| 79 | }
|
---|
[1fd675] | 80 | /** =========== end of function ====================== */
|
---|