[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 |
|
---|
[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 |
|
---|
| 32 | using namespace std;
|
---|
| 33 |
|
---|
[125002] | 34 | #include "NotMoleculeOfAtomAction.hpp"
|
---|
[75a80f] | 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() {
|
---|
[1fd675] | 41 | // obtain information
|
---|
| 42 | getParametersfromValueStorage();
|
---|
[75a80f] | 43 |
|
---|
[92d756] | 44 | std::vector<molecule *> unselectedMolecules = World::getInstance().getSelectedMolecules();
|
---|
[c42e60] | 45 | DoLog(1) && (Log() << Verbose(1) << "Unselecting molecule to currently selected atoms." << endl);
|
---|
| 46 | World::getInstance().unselectAllMolecules(MoleculesByAtomSelection());
|
---|
[92d756] | 47 | return Action::state_ptr(new SelectionNotMoleculeOfAtomState(unselectedMolecules, params));
|
---|
[75a80f] | 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();
|
---|
[92d756] | 54 | BOOST_FOREACH(molecule *_mol, state->unselectedMolecules)
|
---|
| 55 | World::getInstance().selectMolecule(_mol);
|
---|
[75a80f] | 56 |
|
---|
[1fd675] | 57 | return Action::state_ptr(_state);
|
---|
[75a80f] | 58 | }
|
---|
| 59 |
|
---|
| 60 | Action::state_ptr SelectionNotMoleculeOfAtomAction::performRedo(Action::state_ptr _state){
|
---|
[c42e60] | 61 | //SelectionNotMoleculeOfAtomState *state = assert_cast<SelectionNotMoleculeOfAtomState*>(_state.get());
|
---|
[75a80f] | 62 |
|
---|
[c42e60] | 63 | World::getInstance().unselectAllMolecules(MoleculesByAtomSelection());
|
---|
[75a80f] | 64 |
|
---|
[1fd675] | 65 | return Action::state_ptr(_state);
|
---|
[75a80f] | 66 | }
|
---|
| 67 |
|
---|
| 68 | bool SelectionNotMoleculeOfAtomAction::canUndo() {
|
---|
| 69 | return true;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | bool SelectionNotMoleculeOfAtomAction::shouldUndo() {
|
---|
| 73 | return true;
|
---|
| 74 | }
|
---|
[1fd675] | 75 | /** =========== end of function ====================== */
|
---|