source: src/Actions/FragmentationAction/DepthFirstSearchAction.cpp@ 3037be

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 3037be was f394a6, checked in by Frederik Heber <heber@…>, 15 years ago

converted DepthFirstSearchAction to createDialog() and implemented trivial Undo/Redo.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * DepthFirstSearchAction.cpp
3 *
4 * Created on: May 9, 2010
5 * Author: heber
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
11#include "atom.hpp"
12#include "bondgraph.hpp"
13#include "config.hpp"
14#include "log.hpp"
15#include "molecule.hpp"
16#include "Descriptors/MoleculeDescriptor.hpp"
17#include "Descriptors/MoleculeIdDescriptor.hpp"
18#include "stackclass.hpp"
19#include "verbose.hpp"
20#include "World.hpp"
21
22#include <iostream>
23#include <string>
24
25using namespace std;
26
27#include "UIElements/UIFactory.hpp"
28#include "UIElements/Dialog.hpp"
29#include "UIElements/ValueStorage.hpp"
30
31const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search";
32
33FragmentationDepthFirstSearchAction::FragmentationDepthFirstSearchAction() :
34 Action(NAME)
35{}
36
37FragmentationDepthFirstSearchAction::~FragmentationDepthFirstSearchAction()
38{}
39
40Dialog* FragmentationDepthFirstSearchAction::createDialog() {
41 Dialog *dialog = UIFactory::getInstance().makeDialog();
42
43 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
44
45 return dialog;
46}
47
48Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
49 double distance;
50
51 ValueStorage::getInstance().queryCurrentValue(NAME, distance);
52
53 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
54 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
55 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis
56 int *MinimumRingSize = new int[mol->getAtomCount()];
57 atom **ListOfAtoms = NULL;
58 class StackClass<bond *> *BackEdgeStack = NULL;
59 class StackClass<bond *> *LocalBackEdgeStack = NULL;
60 mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
61 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
62 if (Subgraphs != NULL) {
63 int FragmentCounter = 0;
64 while (Subgraphs->next != NULL) {
65 Subgraphs = Subgraphs->next;
66 ListOfAtoms = NULL;
67 Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms
68 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
69 Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
70 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
71 delete(LocalBackEdgeStack);
72 delete(Subgraphs->previous);
73 delete[](ListOfAtoms); // and here we remove it
74 FragmentCounter++;
75 }
76 delete(Subgraphs);
77 }
78 delete(BackEdgeStack);
79 delete[](MinimumRingSize);
80 return Action::success;
81}
82
83Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
84 return Action::success;
85}
86
87Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
88 return Action::success;
89}
90
91bool FragmentationDepthFirstSearchAction::canUndo() {
92 return true;
93}
94
95bool FragmentationDepthFirstSearchAction::shouldUndo() {
96 return true;
97}
98
99const string FragmentationDepthFirstSearchAction::getName() {
100 return NAME;
101}
Note: See TracBrowser for help on using the repository browser.