[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 |
|
---|
[97ebf8] | 8 | /*
|
---|
| 9 | * SaveAdjacencyAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: May 10, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 21 |
|
---|
[1a3c26] | 22 | #include "bondgraph.hpp"
|
---|
| 23 | #include "config.hpp"
|
---|
[ad011c] | 24 | #include "CodePatterns/Log.hpp"
|
---|
[1a3c26] | 25 | #include "molecule.hpp"
|
---|
[ad011c] | 26 | #include "CodePatterns/Verbose.hpp"
|
---|
[1a3c26] | 27 | #include "World.hpp"
|
---|
| 28 |
|
---|
[97ebf8] | 29 |
|
---|
| 30 | #include <iostream>
|
---|
| 31 | #include <fstream>
|
---|
| 32 | #include <string>
|
---|
| 33 |
|
---|
| 34 | using namespace std;
|
---|
| 35 |
|
---|
[1fd675] | 36 | #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
|
---|
[e58fad1] | 37 |
|
---|
[1fd675] | 38 | // and construct the stuff
|
---|
| 39 | #include "SaveAdjacencyAction.def"
|
---|
| 40 | #include "Action_impl_pre.hpp"
|
---|
| 41 | /** =========== define the function ====================== */
|
---|
[97ebf8] | 42 | Action::state_ptr MoleculeSaveAdjacencyAction::performCall() {
|
---|
| 43 | molecule *mol = NULL;
|
---|
| 44 |
|
---|
[1fd675] | 45 | // obtain information
|
---|
| 46 | getParametersfromValueStorage();
|
---|
[97ebf8] | 47 |
|
---|
[e58fad1] | 48 | for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
|
---|
| 49 | mol = iter->second;
|
---|
[1fd675] | 50 | DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << params.adjacencyfile << "." << endl);
|
---|
[97ebf8] | 51 | World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
|
---|
| 52 | // TODO: sollte stream nicht filename benutzen, besser fuer unit test
|
---|
[e4afb4] | 53 | mol->StoreAdjacencyToFile(params.adjacencyfile.leaf(), params.adjacencyfile.branch_path().string());
|
---|
[97ebf8] | 54 | }
|
---|
[e58fad1] | 55 | return Action::success;
|
---|
[97ebf8] | 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 | }
|
---|
[1fd675] | 79 | /** =========== end of function ====================== */
|
---|