[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 | * AllMoleculesAction.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/MoleculeDescriptor.hpp"
|
---|
[92d756] | 23 | #include "Descriptors/MoleculeSelectionDescriptor.hpp"
|
---|
[6f0841] | 24 | #include "Atom/atom.hpp"
|
---|
[ad011c] | 25 | #include "CodePatterns/Log.hpp"
|
---|
| 26 | #include "CodePatterns/Verbose.hpp"
|
---|
[e472eab] | 27 | #include "World.hpp"
|
---|
| 28 |
|
---|
[92d756] | 29 | #include <boost/foreach.hpp>
|
---|
[e472eab] | 30 | #include <iostream>
|
---|
| 31 | #include <string>
|
---|
| 32 |
|
---|
[125002] | 33 | #include "AllMoleculesAction.hpp"
|
---|
[e472eab] | 34 |
|
---|
[ce7fdc] | 35 | using namespace MoleCuilder;
|
---|
| 36 |
|
---|
[1fd675] | 37 | // and construct the stuff
|
---|
| 38 | #include "AllMoleculesAction.def"
|
---|
| 39 | #include "Action_impl_pre.hpp"
|
---|
| 40 | /** =========== define the function ====================== */
|
---|
[e472eab] | 41 | Action::state_ptr SelectionAllMoleculesAction::performCall() {
|
---|
| 42 | std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
|
---|
[47d041] | 43 | LOG(1, "Selecting all molecules.");
|
---|
[e472eab] | 44 | World::getInstance().selectAllMolecules(AllMolecules());
|
---|
[47d041] | 45 | LOG(0, World::getInstance().countSelectedMolecules() << " molecules selected.");
|
---|
[1fd675] | 46 | return Action::state_ptr(new SelectionAllMoleculesState(selectedMolecules,params));
|
---|
[e472eab] | 47 | }
|
---|
| 48 |
|
---|
| 49 | Action::state_ptr SelectionAllMoleculesAction::performUndo(Action::state_ptr _state) {
|
---|
| 50 | SelectionAllMoleculesState *state = assert_cast<SelectionAllMoleculesState*>(_state.get());
|
---|
| 51 |
|
---|
| 52 | World::getInstance().clearMoleculeSelection();
|
---|
[92d756] | 53 | BOOST_FOREACH(molecule *_mol, state->selectedMolecules)
|
---|
| 54 | World::getInstance().selectMolecule(_mol);
|
---|
[e472eab] | 55 |
|
---|
[1fd675] | 56 | return Action::state_ptr(_state);
|
---|
[e472eab] | 57 | }
|
---|
| 58 |
|
---|
| 59 | Action::state_ptr SelectionAllMoleculesAction::performRedo(Action::state_ptr _state){
|
---|
[1fd675] | 60 | //SelectionAllMoleculesState *state = assert_cast<SelectionAllMoleculesState*>(_state.get());
|
---|
[e472eab] | 61 |
|
---|
| 62 | World::getInstance().selectAllMolecules(AllMolecules());
|
---|
| 63 |
|
---|
[1fd675] | 64 | return Action::state_ptr(_state);
|
---|
[e472eab] | 65 | }
|
---|
| 66 |
|
---|
| 67 | bool SelectionAllMoleculesAction::canUndo() {
|
---|
| 68 | return true;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | bool SelectionAllMoleculesAction::shouldUndo() {
|
---|
| 72 | return true;
|
---|
| 73 | }
|
---|
[1fd675] | 74 | /** =========== end of function ====================== */
|
---|