| [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 | 
 | 
|---|
| [e472eab] | 20 | #include "Helpers/MemDebug.hpp"
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | #include "Descriptors/MoleculeDescriptor.hpp"
 | 
|---|
 | 23 | #include "atom.hpp"
 | 
|---|
| [952f38] | 24 | #include "Helpers/Log.hpp"
 | 
|---|
 | 25 | #include "Helpers/Verbose.hpp"
 | 
|---|
| [e472eab] | 26 | #include "World.hpp"
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | #include <iostream>
 | 
|---|
 | 29 | #include <string>
 | 
|---|
 | 30 | 
 | 
|---|
 | 31 | using namespace std;
 | 
|---|
 | 32 | 
 | 
|---|
| [1fd675] | 33 | #include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
 | 
|---|
| [e472eab] | 34 | 
 | 
|---|
| [1fd675] | 35 | // and construct the stuff
 | 
|---|
 | 36 | #include "NotAllMoleculesAction.def"
 | 
|---|
 | 37 | #include "Action_impl_pre.hpp"
 | 
|---|
 | 38 | /** =========== define the function ====================== */
 | 
|---|
| [e472eab] | 39 | Action::state_ptr SelectionNotAllMoleculesAction::performCall() {
 | 
|---|
| [1fd675] | 40 |   // obtain information
 | 
|---|
 | 41 |   getParametersfromValueStorage();
 | 
|---|
 | 42 | 
 | 
|---|
| [e472eab] | 43 |   std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
 | 
|---|
 | 44 |   DoLog(1) && (Log() << Verbose(1) << "Unselecting all molecules." << endl);
 | 
|---|
 | 45 |   World::getInstance().clearMoleculeSelection();
 | 
|---|
| [1fd675] | 46 |   return Action::state_ptr(new SelectionNotAllMoleculesState(selectedMolecules,params));
 | 
|---|
| [e472eab] | 47 | }
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | Action::state_ptr SelectionNotAllMoleculesAction::performUndo(Action::state_ptr _state) {
 | 
|---|
 | 50 |   SelectionNotAllMoleculesState *state = assert_cast<SelectionNotAllMoleculesState*>(_state.get());
 | 
|---|
 | 51 | 
 | 
|---|
 | 52 |   World::getInstance().clearMoleculeSelection();
 | 
|---|
 | 53 |   for(std::vector<molecule *>::iterator iter = state->selectedMolecules.begin(); iter != state->selectedMolecules.end(); ++iter)
 | 
|---|
 | 54 |     World::getInstance().selectMolecule(*iter);
 | 
|---|
 | 55 | 
 | 
|---|
| [1fd675] | 56 |   return Action::state_ptr(_state);
 | 
|---|
| [e472eab] | 57 | }
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 | Action::state_ptr SelectionNotAllMoleculesAction::performRedo(Action::state_ptr _state){
 | 
|---|
| [1fd675] | 60 |   //SelectionNotAllMoleculesState *state = assert_cast<SelectionNotAllMoleculesState*>(_state.get());
 | 
|---|
| [e472eab] | 61 | 
 | 
|---|
 | 62 |   World::getInstance().clearMoleculeSelection();
 | 
|---|
 | 63 | 
 | 
|---|
| [1fd675] | 64 |   return Action::state_ptr(_state);
 | 
|---|
| [e472eab] | 65 | }
 | 
|---|
 | 66 | 
 | 
|---|
 | 67 | bool SelectionNotAllMoleculesAction::canUndo() {
 | 
|---|
 | 68 |   return true;
 | 
|---|
 | 69 | }
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 | bool SelectionNotAllMoleculesAction::shouldUndo() {
 | 
|---|
 | 72 |   return true;
 | 
|---|
 | 73 | }
 | 
|---|
 | 74 | 
 | 
|---|
 | 75 | const string SelectionNotAllMoleculesAction::getName() {
 | 
|---|
 | 76 |   return NAME;
 | 
|---|
 | 77 | }
 | 
|---|
| [1fd675] | 78 | /** =========== end of function ====================== */
 | 
|---|