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 | * BondFileAction.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 "CodePatterns/MemDebug.hpp"
|
---|
21 |
|
---|
22 | #include "Graph/BondGraph.hpp"
|
---|
23 | #include "CodePatterns/Log.hpp"
|
---|
24 | #include "molecule.hpp"
|
---|
25 | #include "CodePatterns/Verbose.hpp"
|
---|
26 | #include "World.hpp"
|
---|
27 |
|
---|
28 | #include <iostream>
|
---|
29 | #include <fstream>
|
---|
30 | #include <string>
|
---|
31 |
|
---|
32 | #include "Actions/MoleculeAction/BondFileAction.hpp"
|
---|
33 |
|
---|
34 | using namespace MoleCuilder;
|
---|
35 |
|
---|
36 | // and construct the stuff
|
---|
37 | #include "BondFileAction.def"
|
---|
38 | #include "Action_impl_pre.hpp"
|
---|
39 | /** =========== define the function ====================== */
|
---|
40 | Action::state_ptr MoleculeBondFileAction::performCall() {
|
---|
41 | molecule *mol = NULL;
|
---|
42 |
|
---|
43 | if(World::getInstance().countSelectedMolecules() == 1) {
|
---|
44 | mol = World::getInstance().beginMoleculeSelection()->second;
|
---|
45 | LOG(0, "STATUS: Parsing bonds from " << params.bondfile
|
---|
46 | << ", skipping " << params.skiplines << "lines"
|
---|
47 | << ", adding " << params.id_offset << " to each id.");
|
---|
48 | ifstream input(params.bondfile.string().c_str());
|
---|
49 | World::AtomComposite Set = mol->getAtomSet();
|
---|
50 | World::getInstance().getBondGraph()->CreateAdjacencyListFromDbondFile(Set, &input, params.skiplines, params.id_offset);
|
---|
51 | input.close();
|
---|
52 | mol->getBondCount();
|
---|
53 | return Action::success;
|
---|
54 | } else
|
---|
55 | return Action::failure;
|
---|
56 | }
|
---|
57 |
|
---|
58 | Action::state_ptr MoleculeBondFileAction::performUndo(Action::state_ptr _state) {
|
---|
59 | // MoleculeBondFileState *state = assert_cast<MoleculeBondFileState*>(_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 MoleculeBondFileAction::performRedo(Action::state_ptr _state){
|
---|
68 | return Action::failure;
|
---|
69 | }
|
---|
70 |
|
---|
71 | bool MoleculeBondFileAction::canUndo() {
|
---|
72 | return true;
|
---|
73 | }
|
---|
74 |
|
---|
75 | bool MoleculeBondFileAction::shouldUndo() {
|
---|
76 | return true;
|
---|
77 | }
|
---|
78 | /** =========== end of function ====================== */
|
---|