| [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 |
|
|---|
| [e472eab] | 8 | /*
|
|---|
| 9 | * NotAllMoleculesAction.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"
|
|---|
| 23 | #include "atom.hpp"
|
|---|
| [ad011c] | 24 | #include "CodePatterns/Log.hpp"
|
|---|
| 25 | #include "CodePatterns/Verbose.hpp"
|
|---|
| [e472eab] | 26 | #include "World.hpp"
|
|---|
| 27 |
|
|---|
| [92d756] | 28 | #include <boost/foreach.hpp>
|
|---|
| [e472eab] | 29 | #include <iostream>
|
|---|
| 30 | #include <string>
|
|---|
| 31 |
|
|---|
| 32 | using namespace std;
|
|---|
| 33 |
|
|---|
| [125002] | 34 | #include "NotAllMoleculesAction.hpp"
|
|---|
| [e472eab] | 35 |
|
|---|
| [1fd675] | 36 | // and construct the stuff
|
|---|
| 37 | #include "NotAllMoleculesAction.def"
|
|---|
| 38 | #include "Action_impl_pre.hpp"
|
|---|
| 39 | /** =========== define the function ====================== */
|
|---|
| [e472eab] | 40 | Action::state_ptr SelectionNotAllMoleculesAction::performCall() {
|
|---|
| [1fd675] | 41 | // obtain information
|
|---|
| 42 | getParametersfromValueStorage();
|
|---|
| 43 |
|
|---|
| [b7fbf0] | 44 | // check whether molecules are present at all
|
|---|
| 45 | if (World::getInstance().numMolecules() == 0) {
|
|---|
| 46 | ELOG(1, "No molecules present in the world to select!");
|
|---|
| 47 | return Action::failure;
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| [e472eab] | 50 | std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
|
|---|
| 51 | DoLog(1) && (Log() << Verbose(1) << "Unselecting all molecules." << endl);
|
|---|
| 52 | World::getInstance().clearMoleculeSelection();
|
|---|
| [aa4b2d] | 53 | DoLog(0) && (Log() << Verbose(0) << World::getInstance().countSelectedMolecules() << " molecules remain selected." << endl);
|
|---|
| [1fd675] | 54 | return Action::state_ptr(new SelectionNotAllMoleculesState(selectedMolecules,params));
|
|---|
| [e472eab] | 55 | }
|
|---|
| 56 |
|
|---|
| 57 | Action::state_ptr SelectionNotAllMoleculesAction::performUndo(Action::state_ptr _state) {
|
|---|
| 58 | SelectionNotAllMoleculesState *state = assert_cast<SelectionNotAllMoleculesState*>(_state.get());
|
|---|
| 59 |
|
|---|
| 60 | World::getInstance().clearMoleculeSelection();
|
|---|
| [92d756] | 61 | BOOST_FOREACH(molecule *_mol, state->unselectedMolecules)
|
|---|
| 62 | World::getInstance().selectMolecule(_mol);
|
|---|
| [e472eab] | 63 |
|
|---|
| [1fd675] | 64 | return Action::state_ptr(_state);
|
|---|
| [e472eab] | 65 | }
|
|---|
| 66 |
|
|---|
| 67 | Action::state_ptr SelectionNotAllMoleculesAction::performRedo(Action::state_ptr _state){
|
|---|
| [1fd675] | 68 | //SelectionNotAllMoleculesState *state = assert_cast<SelectionNotAllMoleculesState*>(_state.get());
|
|---|
| [e472eab] | 69 |
|
|---|
| 70 | World::getInstance().clearMoleculeSelection();
|
|---|
| 71 |
|
|---|
| [1fd675] | 72 | return Action::state_ptr(_state);
|
|---|
| [e472eab] | 73 | }
|
|---|
| 74 |
|
|---|
| 75 | bool SelectionNotAllMoleculesAction::canUndo() {
|
|---|
| 76 | return true;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | bool SelectionNotAllMoleculesAction::shouldUndo() {
|
|---|
| 80 | return true;
|
|---|
| 81 | }
|
|---|
| [1fd675] | 82 | /** =========== end of function ====================== */
|
|---|