| [bcf653] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
| [d103d3] | 4 | * Copyright (C)  2010-2011 University of Bonn. All rights reserved. | 
|---|
| [bcf653] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
| [97ebf8] | 8 | /* | 
|---|
|  | 9 | * BondFileAction.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 |  | 
|---|
| [632508] | 22 | #include "Graph/BondGraph.hpp" | 
|---|
| [ad011c] | 23 | #include "CodePatterns/Log.hpp" | 
|---|
| [1a3c26] | 24 | #include "molecule.hpp" | 
|---|
| [ad011c] | 25 | #include "CodePatterns/Verbose.hpp" | 
|---|
| [1a3c26] | 26 | #include "World.hpp" | 
|---|
| [97ebf8] | 27 |  | 
|---|
|  | 28 | #include <iostream> | 
|---|
|  | 29 | #include <fstream> | 
|---|
|  | 30 | #include <string> | 
|---|
|  | 31 |  | 
|---|
| [1fd675] | 32 | #include "Actions/MoleculeAction/BondFileAction.hpp" | 
|---|
| [eacc3b] | 33 |  | 
|---|
| [ce7fdc] | 34 | using namespace MoleCuilder; | 
|---|
|  | 35 |  | 
|---|
| [1fd675] | 36 | // and construct the stuff | 
|---|
|  | 37 | #include "BondFileAction.def" | 
|---|
|  | 38 | #include "Action_impl_pre.hpp" | 
|---|
|  | 39 | /** =========== define the function ====================== */ | 
|---|
| [97ebf8] | 40 | Action::state_ptr MoleculeBondFileAction::performCall() { | 
|---|
|  | 41 | molecule *mol = NULL; | 
|---|
|  | 42 |  | 
|---|
| [1fd675] | 43 | // obtain information | 
|---|
|  | 44 | getParametersfromValueStorage(); | 
|---|
| [97ebf8] | 45 |  | 
|---|
| [eacc3b] | 46 | if(World::getInstance().countSelectedMolecules() == 1) { | 
|---|
|  | 47 | mol = World::getInstance().beginMoleculeSelection()->second; | 
|---|
| [0cbad2] | 48 | LOG(0, "STATUS: Parsing bonds from " << params.bondfile | 
|---|
|  | 49 | << ", skipping " << params.skiplines << "lines" | 
|---|
|  | 50 | << ", adding " << params.id_offset << " to each id."); | 
|---|
| [e4afb4] | 51 | ifstream input(params.bondfile.string().c_str()); | 
|---|
| [9317be] | 52 | World::AtomComposite Set = mol->getAtomSet(); | 
|---|
| [0cbad2] | 53 | World::getInstance().getBondGraph()->CreateAdjacencyListFromDbondFile(Set, &input, params.skiplines, params.id_offset); | 
|---|
| [97ebf8] | 54 | input.close(); | 
|---|
| [0cbad2] | 55 | mol->getBondCount(); | 
|---|
| [97ebf8] | 56 | return Action::success; | 
|---|
| [eacc3b] | 57 | } else | 
|---|
|  | 58 | return Action::failure; | 
|---|
| [97ebf8] | 59 | } | 
|---|
|  | 60 |  | 
|---|
|  | 61 | Action::state_ptr MoleculeBondFileAction::performUndo(Action::state_ptr _state) { | 
|---|
|  | 62 | //  MoleculeBondFileState *state = assert_cast<MoleculeBondFileState*>(_state.get()); | 
|---|
|  | 63 |  | 
|---|
|  | 64 | //  string newName = state->mol->getName(); | 
|---|
|  | 65 | //  state->mol->setName(state->lastName); | 
|---|
|  | 66 |  | 
|---|
|  | 67 | return Action::failure; | 
|---|
|  | 68 | } | 
|---|
|  | 69 |  | 
|---|
|  | 70 | Action::state_ptr MoleculeBondFileAction::performRedo(Action::state_ptr _state){ | 
|---|
| [e69c87] | 71 | return Action::failure; | 
|---|
| [97ebf8] | 72 | } | 
|---|
|  | 73 |  | 
|---|
|  | 74 | bool MoleculeBondFileAction::canUndo() { | 
|---|
| [e69c87] | 75 | return true; | 
|---|
| [97ebf8] | 76 | } | 
|---|
|  | 77 |  | 
|---|
|  | 78 | bool MoleculeBondFileAction::shouldUndo() { | 
|---|
| [e69c87] | 79 | return true; | 
|---|
| [97ebf8] | 80 | } | 
|---|
| [1fd675] | 81 | /** =========== end of function ====================== */ | 
|---|