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