[c449d9] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[d103d3] | 4 | * Copyright (C) 2010-2011 University of Bonn. All rights reserved.
|
---|
[c449d9] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
[d4a44c] | 9 | * CreateAdjacencyAction.cpp
|
---|
[c449d9] | 10 | *
|
---|
| 11 | * Created on: May 9, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[c449d9] | 21 |
|
---|
[ad011c] | 22 | #include "CodePatterns/Log.hpp"
|
---|
[fa9d1d] | 23 |
|
---|
| 24 | #include "Descriptors/AtomSelectionDescriptor.hpp"
|
---|
[129204] | 25 | #include "Graph/BondGraph.hpp"
|
---|
[c449d9] | 26 | #include "molecule.hpp"
|
---|
| 27 | #include "World.hpp"
|
---|
| 28 |
|
---|
| 29 | #include <iostream>
|
---|
[34c43a] | 30 | #include <list>
|
---|
[c449d9] | 31 | #include <string>
|
---|
| 32 |
|
---|
[d09093] | 33 | #include "Actions/GraphAction/CreateAdjacencyAction.hpp"
|
---|
[c449d9] | 34 |
|
---|
[ce7fdc] | 35 | using namespace MoleCuilder;
|
---|
| 36 |
|
---|
[c449d9] | 37 | // and construct the stuff
|
---|
[d4a44c] | 38 | #include "CreateAdjacencyAction.def"
|
---|
[c449d9] | 39 | #include "Action_impl_pre.hpp"
|
---|
| 40 | /** =========== define the function ====================== */
|
---|
[d09093] | 41 | Action::state_ptr GraphCreateAdjacencyAction::performCall() {
|
---|
[c449d9] | 42 | // obtain information
|
---|
| 43 | getParametersfromValueStorage();
|
---|
| 44 |
|
---|
[f71baf] | 45 | BondGraph *BG = World::getInstance().getBondGraph();
|
---|
[d09093] | 46 | ASSERT(BG != NULL, "GraphCreateAdjacencyAction: BondGraph is NULL.");
|
---|
[fa9d1d] | 47 |
|
---|
| 48 | World::AtomComposite Set = World::getInstance().getAllAtoms(AtomsBySelection());
|
---|
| 49 | BG->CreateAdjacency(Set);
|
---|
| 50 |
|
---|
| 51 | size_t BondCount = 0;
|
---|
| 52 | std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
|
---|
| 53 | for (std::vector<molecule *>::const_iterator iter = molecules.begin();
|
---|
| 54 | iter != molecules.end(); ++iter)
|
---|
| 55 | BondCount += (*iter)->getBondCount();
|
---|
| 56 | LOG(0, "STATUS: Recognized " << BondCount << " bonds.");
|
---|
[c449d9] | 57 |
|
---|
| 58 | return Action::success;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[d09093] | 61 | Action::state_ptr GraphCreateAdjacencyAction::performUndo(Action::state_ptr _state) {
|
---|
| 62 | // GraphCreateAdjacencyState *state = assert_cast<GraphCreateAdjacencyState*>(_state.get());
|
---|
[c449d9] | 63 |
|
---|
| 64 | return Action::success;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[d09093] | 67 | Action::state_ptr GraphCreateAdjacencyAction::performRedo(Action::state_ptr _state){
|
---|
[c449d9] | 68 | return Action::success;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[d09093] | 71 | bool GraphCreateAdjacencyAction::canUndo() {
|
---|
[c449d9] | 72 | return false;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[d09093] | 75 | bool GraphCreateAdjacencyAction::shouldUndo() {
|
---|
[c449d9] | 76 | return false;
|
---|
| 77 | }
|
---|
| 78 | /** =========== end of function ====================== */
|
---|