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