| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * CreateAdjacencyAction.cpp
|
|---|
| 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 |
|
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include "CodePatterns/Log.hpp"
|
|---|
| 23 |
|
|---|
| 24 | #include "Descriptors/AtomSelectionDescriptor.hpp"
|
|---|
| 25 | #include "Graph/BondGraph.hpp"
|
|---|
| 26 | #include "molecule.hpp"
|
|---|
| 27 | #include "World.hpp"
|
|---|
| 28 |
|
|---|
| 29 | #include <iostream>
|
|---|
| 30 | #include <list>
|
|---|
| 31 | #include <string>
|
|---|
| 32 |
|
|---|
| 33 | #include "Actions/GraphAction/CreateAdjacencyAction.hpp"
|
|---|
| 34 |
|
|---|
| 35 | using namespace MoleCuilder;
|
|---|
| 36 |
|
|---|
| 37 | // and construct the stuff
|
|---|
| 38 | #include "CreateAdjacencyAction.def"
|
|---|
| 39 | #include "Action_impl_pre.hpp"
|
|---|
| 40 | /** =========== define the function ====================== */
|
|---|
| 41 | Action::state_ptr GraphCreateAdjacencyAction::performCall() {
|
|---|
| 42 | // obtain information
|
|---|
| 43 | getParametersfromValueStorage();
|
|---|
| 44 |
|
|---|
| 45 | BondGraph *BG = World::getInstance().getBondGraph();
|
|---|
| 46 | ASSERT(BG != NULL, "GraphCreateAdjacencyAction: BondGraph is NULL.");
|
|---|
| 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.");
|
|---|
| 57 |
|
|---|
| 58 | return Action::success;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | Action::state_ptr GraphCreateAdjacencyAction::performUndo(Action::state_ptr _state) {
|
|---|
| 62 | // GraphCreateAdjacencyState *state = assert_cast<GraphCreateAdjacencyState*>(_state.get());
|
|---|
| 63 |
|
|---|
| 64 | return Action::success;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | Action::state_ptr GraphCreateAdjacencyAction::performRedo(Action::state_ptr _state){
|
|---|
| 68 | return Action::success;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | bool GraphCreateAdjacencyAction::canUndo() {
|
|---|
| 72 | return false;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | bool GraphCreateAdjacencyAction::shouldUndo() {
|
|---|
| 76 | return false;
|
|---|
| 77 | }
|
|---|
| 78 | /** =========== end of function ====================== */
|
|---|