Ignore:
Timestamp:
Jul 28, 2010, 9:21:14 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
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, Candidate_v1.7.0, Candidate_v1.7.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
Children:
400170, a7b777c
Parents:
7067bd6 (diff), 0430e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'stable' into StructureRefactoring

Conflicts:

src/Makefile.am

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/DepthFirstSearchAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "bondgraph.hpp"
     
    2728#include "UIElements/UIFactory.hpp"
    2829#include "UIElements/Dialog.hpp"
    29 #include "Actions/MapOfActions.hpp"
     30#include "UIElements/ValueStorage.hpp"
    3031
    3132const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search";
     
    3839{}
    3940
     41void FragmentationDepthFirstSearch(double distance) {
     42  ValueStorage::getInstance().setCurrentValue(FragmentationDepthFirstSearchAction::NAME, distance);
     43  ActionRegistry::getInstance().getActionByName(FragmentationDepthFirstSearchAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog* FragmentationDepthFirstSearchAction::createDialog() {
     47  Dialog *dialog = UIFactory::getInstance().makeDialog();
     48
     49  dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME));
     50
     51  return dialog;
     52}
     53
    4054Action::state_ptr FragmentationDepthFirstSearchAction::performCall() {
    41   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4255  double distance;
    4356
    44   dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));
     57  ValueStorage::getInstance().queryCurrentValue(NAME, distance);
    4558
    46   if(dialog->display()) {
    47     DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    48     molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
    49     MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    50     int *MinimumRingSize = new int[mol->getAtomCount()];
    51     atom **ListOfAtoms = NULL;
    52     class StackClass<bond *> *BackEdgeStack = NULL;
    53     class StackClass<bond *> *LocalBackEdgeStack = NULL;
    54     mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    55     Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    56     if (Subgraphs != NULL) {
    57       int FragmentCounter = 0;
    58       while (Subgraphs->next != NULL) {
    59         Subgraphs = Subgraphs->next;
    60         ListOfAtoms = NULL;
    61         Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
    62         LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
    63         Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
    64         Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
    65         delete(LocalBackEdgeStack);
    66         delete(Subgraphs->previous);
    67         delete[](ListOfAtoms);  // and here we remove it
    68         FragmentCounter++;
    69       }
    70       delete(Subgraphs);
     59  DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
     60  molecule * const mol = World::getInstance().getMolecule(MoleculeById(0));
     61  MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
     62  int *MinimumRingSize = new int[mol->getAtomCount()];
     63  atom **ListOfAtoms = NULL;
     64  class StackClass<bond *> *BackEdgeStack = NULL;
     65  class StackClass<bond *> *LocalBackEdgeStack = NULL;
     66  mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
     67  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
     68  if (Subgraphs != NULL) {
     69    int FragmentCounter = 0;
     70    while (Subgraphs->next != NULL) {
     71      Subgraphs = Subgraphs->next;
     72      ListOfAtoms = NULL;
     73      Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false);  // we want to keep the created ListOfLocalAtoms
     74      LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
     75      Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack);
     76      Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
     77      delete(LocalBackEdgeStack);
     78      delete(Subgraphs->previous);
     79      delete[](ListOfAtoms);  // and here we remove it
     80      FragmentCounter++;
    7181    }
    72     delete(BackEdgeStack);
    73     delete[](MinimumRingSize);
    74     delete dialog;
    75     return Action::success;
    76   } else {
    77     delete dialog;
    78     return Action::failure;
     82    delete(Subgraphs);
    7983  }
     84  delete(BackEdgeStack);
     85  delete[](MinimumRingSize);
     86  return Action::success;
    8087}
    8188
    8289Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) {
    83 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    84 
    85   return Action::failure;
    86 //  string newName = state->mol->getName();
    87 //  state->mol->setName(state->lastName);
    88 //
    89 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     90  return Action::success;
    9091}
    9192
    9293Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){
    93   return Action::failure;
     94  return Action::success;
    9495}
    9596
    9697bool FragmentationDepthFirstSearchAction::canUndo() {
    97   return false;
     98  return true;
    9899}
    99100
    100101bool FragmentationDepthFirstSearchAction::shouldUndo() {
    101   return false;
     102  return true;
    102103}
    103104
Note: See TracChangeset for help on using the changeset viewer.