| 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 |  | 
|---|
| 8 | /* | 
|---|
| 9 | * NotMoleculeOfAtomAction.cpp | 
|---|
| 10 | * | 
|---|
| 11 | *  Created on: May 12, 2010 | 
|---|
| 12 | *      Author: heber | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | // include config.h | 
|---|
| 16 | #ifdef HAVE_CONFIG_H | 
|---|
| 17 | #include <config.h> | 
|---|
| 18 | #endif | 
|---|
| 19 |  | 
|---|
| 20 | #include "Helpers/MemDebug.hpp" | 
|---|
| 21 |  | 
|---|
| 22 | #include "Descriptors/MoleculeDescriptor.hpp" | 
|---|
| 23 | #include "Descriptors/MoleculeOfAtomSelectionDescriptor.hpp" | 
|---|
| 24 | #include "Helpers/Log.hpp" | 
|---|
| 25 | #include "Helpers/Verbose.hpp" | 
|---|
| 26 | #include "World.hpp" | 
|---|
| 27 |  | 
|---|
| 28 | #include <boost/foreach.hpp> | 
|---|
| 29 | #include <iostream> | 
|---|
| 30 | #include <string> | 
|---|
| 31 |  | 
|---|
| 32 | using namespace std; | 
|---|
| 33 |  | 
|---|
| 34 | #include "NotMoleculeOfAtomAction.hpp" | 
|---|
| 35 |  | 
|---|
| 36 | // and construct the stuff | 
|---|
| 37 | #include "NotMoleculeOfAtomAction.def" | 
|---|
| 38 | #include "Action_impl_pre.hpp" | 
|---|
| 39 | /** =========== define the function ====================== */ | 
|---|
| 40 | Action::state_ptr SelectionNotMoleculeOfAtomAction::performCall() { | 
|---|
| 41 | // obtain information | 
|---|
| 42 | getParametersfromValueStorage(); | 
|---|
| 43 |  | 
|---|
| 44 | std::vector<molecule *> unselectedMolecules = World::getInstance().getSelectedMolecules(); | 
|---|
| 45 | DoLog(1) && (Log() << Verbose(1) << "Unselecting molecule to currently selected atoms." << endl); | 
|---|
| 46 | World::getInstance().unselectAllMolecules(MoleculesByAtomSelection()); | 
|---|
| 47 | return Action::state_ptr(new SelectionNotMoleculeOfAtomState(unselectedMolecules, params)); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | Action::state_ptr SelectionNotMoleculeOfAtomAction::performUndo(Action::state_ptr _state) { | 
|---|
| 51 | SelectionNotMoleculeOfAtomState *state = assert_cast<SelectionNotMoleculeOfAtomState*>(_state.get()); | 
|---|
| 52 |  | 
|---|
| 53 | World::getInstance().clearMoleculeSelection(); | 
|---|
| 54 | BOOST_FOREACH(molecule *_mol, state->unselectedMolecules) | 
|---|
| 55 | World::getInstance().selectMolecule(_mol); | 
|---|
| 56 |  | 
|---|
| 57 | return Action::state_ptr(_state); | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | Action::state_ptr SelectionNotMoleculeOfAtomAction::performRedo(Action::state_ptr _state){ | 
|---|
| 61 | //SelectionNotMoleculeOfAtomState *state = assert_cast<SelectionNotMoleculeOfAtomState*>(_state.get()); | 
|---|
| 62 |  | 
|---|
| 63 | World::getInstance().unselectAllMolecules(MoleculesByAtomSelection()); | 
|---|
| 64 |  | 
|---|
| 65 | return Action::state_ptr(_state); | 
|---|
| 66 | } | 
|---|
| 67 |  | 
|---|
| 68 | bool SelectionNotMoleculeOfAtomAction::canUndo() { | 
|---|
| 69 | return true; | 
|---|
| 70 | } | 
|---|
| 71 |  | 
|---|
| 72 | bool SelectionNotMoleculeOfAtomAction::shouldUndo() { | 
|---|
| 73 | return true; | 
|---|
| 74 | } | 
|---|
| 75 | /** =========== end of function ====================== */ | 
|---|