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