1 | /*
|
---|
2 | * SubgraphDissectionAction.cpp
|
---|
3 | *
|
---|
4 | * Created on: May 9, 2010
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "Helpers/MemDebug.hpp"
|
---|
9 |
|
---|
10 | #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
|
---|
11 | #include "atom.hpp"
|
---|
12 | #include "config.hpp"
|
---|
13 | #include "log.hpp"
|
---|
14 | #include "molecule.hpp"
|
---|
15 | #include "Descriptors/MoleculeDescriptor.hpp"
|
---|
16 | #include "stackclass.hpp"
|
---|
17 | #include "World.hpp"
|
---|
18 |
|
---|
19 | #include <iostream>
|
---|
20 | #include <string>
|
---|
21 |
|
---|
22 | using namespace std;
|
---|
23 |
|
---|
24 | #include "UIElements/UIFactory.hpp"
|
---|
25 | #include "UIElements/Dialog.hpp"
|
---|
26 | #include "UIElements/ValueStorage.hpp"
|
---|
27 |
|
---|
28 | const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect";
|
---|
29 |
|
---|
30 | FragmentationSubgraphDissectionAction::FragmentationSubgraphDissectionAction() :
|
---|
31 | Action(NAME)
|
---|
32 | {}
|
---|
33 |
|
---|
34 | FragmentationSubgraphDissectionAction::~FragmentationSubgraphDissectionAction()
|
---|
35 | {}
|
---|
36 |
|
---|
37 | Dialog* FragmentationSubgraphDissectionAction::createDialog() {
|
---|
38 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
39 |
|
---|
40 | dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
|
---|
41 |
|
---|
42 | return dialog;
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
|
---|
47 | DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
|
---|
48 | // @TODO rather do the dissection afterwards
|
---|
49 | MoleculeListClass *molecules = World::getInstance().getMolecules();
|
---|
50 | molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig());
|
---|
51 | return Action::success;
|
---|
52 | }
|
---|
53 |
|
---|
54 | Action::state_ptr FragmentationSubgraphDissectionAction::performUndo(Action::state_ptr _state) {
|
---|
55 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
---|
56 |
|
---|
57 | return Action::failure;
|
---|
58 | // string newName = state->mol->getName();
|
---|
59 | // state->mol->setName(state->lastName);
|
---|
60 | //
|
---|
61 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
---|
62 | }
|
---|
63 |
|
---|
64 | Action::state_ptr FragmentationSubgraphDissectionAction::performRedo(Action::state_ptr _state){
|
---|
65 | return Action::failure;
|
---|
66 | }
|
---|
67 |
|
---|
68 | bool FragmentationSubgraphDissectionAction::canUndo() {
|
---|
69 | return false;
|
---|
70 | }
|
---|
71 |
|
---|
72 | bool FragmentationSubgraphDissectionAction::shouldUndo() {
|
---|
73 | return false;
|
---|
74 | }
|
---|
75 |
|
---|
76 | const string FragmentationSubgraphDissectionAction::getName() {
|
---|
77 | return NAME;
|
---|
78 | }
|
---|