| 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 "Actions/MapOfActions.hpp" | 
|---|
| 27 |  | 
|---|
| 28 | const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect"; | 
|---|
| 29 |  | 
|---|
| 30 | FragmentationSubgraphDissectionAction::FragmentationSubgraphDissectionAction() : | 
|---|
| 31 | Action(NAME) | 
|---|
| 32 | {} | 
|---|
| 33 |  | 
|---|
| 34 | FragmentationSubgraphDissectionAction::~FragmentationSubgraphDissectionAction() | 
|---|
| 35 | {} | 
|---|
| 36 |  | 
|---|
| 37 | Action::state_ptr FragmentationSubgraphDissectionAction::performCall() { | 
|---|
| 38 | Dialog *dialog = UIFactory::getInstance().makeDialog(); | 
|---|
| 39 |  | 
|---|
| 40 | dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); | 
|---|
| 41 |  | 
|---|
| 42 | if(dialog->display()) { | 
|---|
| 43 | DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); | 
|---|
| 44 | // @TODO rather do the dissection afterwards | 
|---|
| 45 | MoleculeListClass *molecules = World::getInstance().getMolecules(); | 
|---|
| 46 | molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); | 
|---|
| 47 | delete dialog; | 
|---|
| 48 | return Action::success; | 
|---|
| 49 | } else { | 
|---|
| 50 | delete dialog; | 
|---|
| 51 | return Action::failure; | 
|---|
| 52 | } | 
|---|
| 53 | } | 
|---|
| 54 |  | 
|---|
| 55 | Action::state_ptr FragmentationSubgraphDissectionAction::performUndo(Action::state_ptr _state) { | 
|---|
| 56 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); | 
|---|
| 57 |  | 
|---|
| 58 | return Action::failure; | 
|---|
| 59 | //  string newName = state->mol->getName(); | 
|---|
| 60 | //  state->mol->setName(state->lastName); | 
|---|
| 61 | // | 
|---|
| 62 | //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 | Action::state_ptr FragmentationSubgraphDissectionAction::performRedo(Action::state_ptr _state){ | 
|---|
| 66 | return Action::failure; | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | bool FragmentationSubgraphDissectionAction::canUndo() { | 
|---|
| 70 | return false; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | bool FragmentationSubgraphDissectionAction::shouldUndo() { | 
|---|
| 74 | return false; | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | const string FragmentationSubgraphDissectionAction::getName() { | 
|---|
| 78 | return NAME; | 
|---|
| 79 | } | 
|---|