| 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 |
|
|---|
| 8 | /*
|
|---|
| 9 | * SaveAdjacencyAction.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: May 10, 2010
|
|---|
| 12 | * Author: heber
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #include "Helpers/MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include "bondgraph.hpp"
|
|---|
| 23 | #include "config.hpp"
|
|---|
| 24 | #include "Helpers/Log.hpp"
|
|---|
| 25 | #include "molecule.hpp"
|
|---|
| 26 | #include "Helpers/Verbose.hpp"
|
|---|
| 27 | #include "World.hpp"
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | #include <iostream>
|
|---|
| 31 | #include <fstream>
|
|---|
| 32 | #include <string>
|
|---|
| 33 |
|
|---|
| 34 | using namespace std;
|
|---|
| 35 |
|
|---|
| 36 | #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
|
|---|
| 37 |
|
|---|
| 38 | // and construct the stuff
|
|---|
| 39 | #include "SaveAdjacencyAction.def"
|
|---|
| 40 | #include "Action_impl_pre.hpp"
|
|---|
| 41 | /** =========== define the function ====================== */
|
|---|
| 42 | Action::state_ptr MoleculeSaveAdjacencyAction::performCall() {
|
|---|
| 43 | molecule *mol = NULL;
|
|---|
| 44 |
|
|---|
| 45 | // obtain information
|
|---|
| 46 | getParametersfromValueStorage();
|
|---|
| 47 |
|
|---|
| 48 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
|---|
| 49 | mol = iter->second;
|
|---|
| 50 | DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << params.adjacencyfile << "." << endl);
|
|---|
| 51 | World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
|
|---|
| 52 | // TODO: sollte stream nicht filename benutzen, besser fuer unit test
|
|---|
| 53 | mol->StoreAdjacencyToFile(params.adjacencyfile);
|
|---|
| 54 | }
|
|---|
| 55 | return Action::success;
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | Action::state_ptr MoleculeSaveAdjacencyAction::performUndo(Action::state_ptr _state) {
|
|---|
| 59 | // MoleculeSaveAdjacencyState *state = assert_cast<MoleculeSaveAdjacencyState*>(_state.get());
|
|---|
| 60 |
|
|---|
| 61 | // string newName = state->mol->getName();
|
|---|
| 62 | // state->mol->setName(state->lastName);
|
|---|
| 63 |
|
|---|
| 64 | return Action::failure;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | Action::state_ptr MoleculeSaveAdjacencyAction::performRedo(Action::state_ptr _state){
|
|---|
| 68 | // Undo and redo have to do the same for this action
|
|---|
| 69 | return performUndo(_state);
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | bool MoleculeSaveAdjacencyAction::canUndo() {
|
|---|
| 73 | return false;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | bool MoleculeSaveAdjacencyAction::shouldUndo() {
|
|---|
| 77 | return false;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | const string MoleculeSaveAdjacencyAction::getName() {
|
|---|
| 81 | return NAME;
|
|---|
| 82 | }
|
|---|
| 83 | /** =========== end of function ====================== */
|
|---|