[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 |
|
---|
[2218d94] | 8 | /*
|
---|
| 9 | * ClearAllMoleculesAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: Aug 09, 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"
|
---|
[2218d94] | 21 |
|
---|
| 22 | #include "Descriptors/MoleculeDescriptor.hpp"
|
---|
| 23 | #include "atom.hpp"
|
---|
[ad011c] | 24 | #include "CodePatterns/Log.hpp"
|
---|
| 25 | #include "CodePatterns/Verbose.hpp"
|
---|
[2218d94] | 26 | #include "World.hpp"
|
---|
| 27 |
|
---|
[92d756] | 28 | #include <boost/foreach.hpp>
|
---|
[2218d94] | 29 | #include <iostream>
|
---|
| 30 | #include <string>
|
---|
| 31 |
|
---|
| 32 | using namespace std;
|
---|
| 33 |
|
---|
[125002] | 34 | #include "ClearAllMoleculesAction.hpp"
|
---|
[2218d94] | 35 |
|
---|
[1fd675] | 36 | // and construct the stuff
|
---|
| 37 | #include "ClearAllMoleculesAction.def"
|
---|
| 38 | #include "Action_impl_pre.hpp"
|
---|
| 39 | /** =========== define the function ====================== */
|
---|
[2218d94] | 40 | Action::state_ptr SelectionClearAllMoleculesAction::performCall() {
|
---|
[1fd675] | 41 | // obtain information
|
---|
| 42 | getParametersfromValueStorage();
|
---|
| 43 |
|
---|
[2218d94] | 44 | std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
|
---|
| 45 | DoLog(1) && (Log() << Verbose(1) << "Clearing molecule selection." << endl);
|
---|
| 46 | World::getInstance().clearMoleculeSelection();
|
---|
[1fd675] | 47 | return Action::state_ptr(new SelectionClearAllMoleculesState(selectedMolecules,params));
|
---|
[2218d94] | 48 | }
|
---|
| 49 |
|
---|
| 50 | Action::state_ptr SelectionClearAllMoleculesAction::performUndo(Action::state_ptr _state) {
|
---|
| 51 | SelectionClearAllMoleculesState *state = assert_cast<SelectionClearAllMoleculesState*>(_state.get());
|
---|
| 52 |
|
---|
| 53 | World::getInstance().clearMoleculeSelection();
|
---|
[92d756] | 54 | BOOST_FOREACH(molecule *_mol, state->selectedMolecules)
|
---|
| 55 | World::getInstance().selectMolecule(_mol);
|
---|
[2218d94] | 56 |
|
---|
[1fd675] | 57 | return Action::state_ptr(_state);
|
---|
[2218d94] | 58 | }
|
---|
| 59 |
|
---|
| 60 | Action::state_ptr SelectionClearAllMoleculesAction::performRedo(Action::state_ptr _state){
|
---|
[1fd675] | 61 | //SelectionClearAllMoleculesState *state = assert_cast<SelectionClearAllMoleculesState*>(_state.get());
|
---|
[2218d94] | 62 |
|
---|
| 63 | World::getInstance().clearMoleculeSelection();
|
---|
| 64 |
|
---|
[1fd675] | 65 | return Action::state_ptr(_state);
|
---|
[2218d94] | 66 | }
|
---|
| 67 |
|
---|
| 68 | bool SelectionClearAllMoleculesAction::canUndo() {
|
---|
| 69 | return true;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | bool SelectionClearAllMoleculesAction::shouldUndo() {
|
---|
| 73 | return true;
|
---|
| 74 | }
|
---|
[1fd675] | 75 | /** =========== end of function ====================== */
|
---|