| [c449d9] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [94d5ac6] | 5 |  * 
 | 
|---|
 | 6 |  *
 | 
|---|
 | 7 |  *   This file is part of MoleCuilder.
 | 
|---|
 | 8 |  *
 | 
|---|
 | 9 |  *    MoleCuilder is free software: you can redistribute it and/or modify
 | 
|---|
 | 10 |  *    it under the terms of the GNU General Public License as published by
 | 
|---|
 | 11 |  *    the Free Software Foundation, either version 2 of the License, or
 | 
|---|
 | 12 |  *    (at your option) any later version.
 | 
|---|
 | 13 |  *
 | 
|---|
 | 14 |  *    MoleCuilder is distributed in the hope that it will be useful,
 | 
|---|
 | 15 |  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 16 |  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 17 |  *    GNU General Public License for more details.
 | 
|---|
 | 18 |  *
 | 
|---|
 | 19 |  *    You should have received a copy of the GNU General Public License
 | 
|---|
 | 20 |  *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
 | 
|---|
| [c449d9] | 21 |  */
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 | /*
 | 
|---|
| [d4a44c] | 24 |  * CreateAdjacencyAction.cpp
 | 
|---|
| [c449d9] | 25 |  *
 | 
|---|
 | 26 |  *  Created on: May 9, 2010
 | 
|---|
 | 27 |  *      Author: heber
 | 
|---|
 | 28 |  */
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | // include config.h
 | 
|---|
 | 31 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 32 | #include <config.h>
 | 
|---|
 | 33 | #endif
 | 
|---|
 | 34 | 
 | 
|---|
| [ad011c] | 35 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| [c449d9] | 36 | 
 | 
|---|
| [ad011c] | 37 | #include "CodePatterns/Log.hpp"
 | 
|---|
| [fa9d1d] | 38 | 
 | 
|---|
 | 39 | #include "Descriptors/AtomSelectionDescriptor.hpp"
 | 
|---|
| [129204] | 40 | #include "Graph/BondGraph.hpp"
 | 
|---|
| [c449d9] | 41 | #include "molecule.hpp"
 | 
|---|
 | 42 | #include "World.hpp"
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | #include <iostream>
 | 
|---|
| [34c43a] | 45 | #include <list>
 | 
|---|
| [c449d9] | 46 | #include <string>
 | 
|---|
 | 47 | 
 | 
|---|
| [d09093] | 48 | #include "Actions/GraphAction/CreateAdjacencyAction.hpp"
 | 
|---|
| [c449d9] | 49 | 
 | 
|---|
| [ce7fdc] | 50 | using namespace MoleCuilder;
 | 
|---|
 | 51 | 
 | 
|---|
| [c449d9] | 52 | // and construct the stuff
 | 
|---|
| [d4a44c] | 53 | #include "CreateAdjacencyAction.def"
 | 
|---|
| [c449d9] | 54 | #include "Action_impl_pre.hpp"
 | 
|---|
 | 55 | /** =========== define the function ====================== */
 | 
|---|
| [d09093] | 56 | Action::state_ptr GraphCreateAdjacencyAction::performCall() {
 | 
|---|
| [f71baf] | 57 |   BondGraph *BG = World::getInstance().getBondGraph();
 | 
|---|
| [d09093] | 58 |   ASSERT(BG != NULL, "GraphCreateAdjacencyAction: BondGraph is NULL.");
 | 
|---|
| [fa9d1d] | 59 | 
 | 
|---|
 | 60 |   World::AtomComposite Set = World::getInstance().getAllAtoms(AtomsBySelection());
 | 
|---|
 | 61 |   BG->CreateAdjacency(Set);
 | 
|---|
 | 62 | 
 | 
|---|
 | 63 |   size_t BondCount = 0;
 | 
|---|
 | 64 |   std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
 | 
|---|
 | 65 |   for (std::vector<molecule *>::const_iterator iter = molecules.begin();
 | 
|---|
 | 66 |       iter != molecules.end(); ++iter)
 | 
|---|
 | 67 |     BondCount += (*iter)->getBondCount();
 | 
|---|
 | 68 |   LOG(0, "STATUS: Recognized " << BondCount << " bonds.");
 | 
|---|
| [c449d9] | 69 | 
 | 
|---|
 | 70 |   return Action::success;
 | 
|---|
 | 71 | }
 | 
|---|
 | 72 | 
 | 
|---|
| [d09093] | 73 | Action::state_ptr GraphCreateAdjacencyAction::performUndo(Action::state_ptr _state) {
 | 
|---|
 | 74 | //  GraphCreateAdjacencyState *state = assert_cast<GraphCreateAdjacencyState*>(_state.get());
 | 
|---|
| [c449d9] | 75 | 
 | 
|---|
 | 76 |   return Action::success;
 | 
|---|
 | 77 | }
 | 
|---|
 | 78 | 
 | 
|---|
| [d09093] | 79 | Action::state_ptr GraphCreateAdjacencyAction::performRedo(Action::state_ptr _state){
 | 
|---|
| [c449d9] | 80 |   return Action::success;
 | 
|---|
 | 81 | }
 | 
|---|
 | 82 | 
 | 
|---|
| [d09093] | 83 | bool GraphCreateAdjacencyAction::canUndo() {
 | 
|---|
| [c449d9] | 84 |   return false;
 | 
|---|
 | 85 | }
 | 
|---|
 | 86 | 
 | 
|---|
| [d09093] | 87 | bool GraphCreateAdjacencyAction::shouldUndo() {
 | 
|---|
| [c449d9] | 88 |   return false;
 | 
|---|
 | 89 | }
 | 
|---|
 | 90 | /** =========== end of function ====================== */
 | 
|---|