[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 |
|
---|
[125002] | 32 | #include "ClearAllMoleculesAction.hpp"
|
---|
[2218d94] | 33 |
|
---|
[ce7fdc] | 34 | using namespace MoleCuilder;
|
---|
| 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();
|
---|
[47d041] | 45 | LOG(1, "Clearing molecule selection.");
|
---|
[2218d94] | 46 | World::getInstance().clearMoleculeSelection();
|
---|
[47d041] | 47 | LOG(0, World::getInstance().countSelectedMolecules() << " molecules remain selected.");
|
---|
[1fd675] | 48 | return Action::state_ptr(new SelectionClearAllMoleculesState(selectedMolecules,params));
|
---|
[2218d94] | 49 | }
|
---|
| 50 |
|
---|
| 51 | Action::state_ptr SelectionClearAllMoleculesAction::performUndo(Action::state_ptr _state) {
|
---|
| 52 | SelectionClearAllMoleculesState *state = assert_cast<SelectionClearAllMoleculesState*>(_state.get());
|
---|
| 53 |
|
---|
| 54 | World::getInstance().clearMoleculeSelection();
|
---|
[92d756] | 55 | BOOST_FOREACH(molecule *_mol, state->selectedMolecules)
|
---|
| 56 | World::getInstance().selectMolecule(_mol);
|
---|
[2218d94] | 57 |
|
---|
[1fd675] | 58 | return Action::state_ptr(_state);
|
---|
[2218d94] | 59 | }
|
---|
| 60 |
|
---|
| 61 | Action::state_ptr SelectionClearAllMoleculesAction::performRedo(Action::state_ptr _state){
|
---|
[1fd675] | 62 | //SelectionClearAllMoleculesState *state = assert_cast<SelectionClearAllMoleculesState*>(_state.get());
|
---|
[2218d94] | 63 |
|
---|
| 64 | World::getInstance().clearMoleculeSelection();
|
---|
| 65 |
|
---|
[1fd675] | 66 | return Action::state_ptr(_state);
|
---|
[2218d94] | 67 | }
|
---|
| 68 |
|
---|
| 69 | bool SelectionClearAllMoleculesAction::canUndo() {
|
---|
| 70 | return true;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | bool SelectionClearAllMoleculesAction::shouldUndo() {
|
---|
| 74 | return true;
|
---|
| 75 | }
|
---|
[1fd675] | 76 | /** =========== end of function ====================== */
|
---|