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, 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

Location:
src/Actions/FragmentationAction
Files:
6 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
  • src/Actions/FragmentationAction/DepthFirstSearchAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationDepthFirstSearch(double distance);
     14
    1315class FragmentationDepthFirstSearchAction : public Action {
     16  friend void FragmentationDepthFirstSearch(double distance);
     17
    1418public:
    1519  FragmentationDepthFirstSearchAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/FragmentationAction/FragmentationAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "bondgraph.hpp"
     
    2526#include "UIElements/UIFactory.hpp"
    2627#include "UIElements/Dialog.hpp"
    27 #include "Actions/MapOfActions.hpp"
     28#include "UIElements/ValueStorage.hpp"
    2829
    2930const char FragmentationFragmentationAction::NAME[] = "fragment-mol";
     
    3637{}
    3738
     39void FragmentationFragmentation(std::string &path, double distance, int order) {
     40  ValueStorage::getInstance().setCurrentValue(FragmentationFragmentationAction::NAME, path);
     41  ValueStorage::getInstance().setCurrentValue("distance", distance);
     42  ValueStorage::getInstance().setCurrentValue("order", order);
     43  ActionRegistry::getInstance().getActionByName(FragmentationFragmentationAction::NAME)->call(Action::NonInteractive);
     44};
     45
     46Dialog* FragmentationFragmentationAction::createDialog() {
     47  Dialog *dialog = UIFactory::getInstance().makeDialog();
     48
     49  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     50  dialog->queryDouble("distance", ValueStorage::getInstance().getDescription("distance"));
     51  dialog->queryInt("order", ValueStorage::getInstance().getDescription("order"));
     52
     53  return dialog;
     54}
     55
    3856Action::state_ptr FragmentationFragmentationAction::performCall() {
    39   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4057  clock_t start,end;
    4158  molecule *mol = NULL;
     
    4663  int ExitFlag = 0;
    4764
    48   cout << "pre-dialog"<< endl;
    49   dialog->queryString(NAME, &path, MapOfActions::getInstance().getDescription(NAME));
    50   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    51   dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance"));
    52   dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order"));
     65  ValueStorage::getInstance().queryCurrentValue(NAME, path);
     66  ValueStorage::getInstance().queryCurrentValue("distance", distance);
     67  ValueStorage::getInstance().queryCurrentValue("order", order);
    5368
    54   if(dialog->display()) {
    55     cout << "POST-dialog"<< endl;
     69  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     70    mol = iter->second;
    5671    ASSERT(mol != NULL, "No molecule has been picked for fragmentation.");
    5772    DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << distance << " angstroem, order of " << order << "." << endl);
     
    6681    end = clock();
    6782    DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    68     delete dialog;
    69     return Action::success;
    70   } else {
    71     delete dialog;
    72     return Action::failure;
    7383  }
     84  return Action::success;
    7485}
    7586
    7687Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) {
    77 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    78 
    79   return Action::failure;
    80 //  string newName = state->mol->getName();
    81 //  state->mol->setName(state->lastName);
    82 //
    83 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     88  return Action::success;
    8489}
    8590
    8691Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){
    87   return Action::failure;
     92  return Action::success;
    8893}
    8994
    9095bool FragmentationFragmentationAction::canUndo() {
    91   return false;
     96  return true;
    9297}
    9398
    9499bool FragmentationFragmentationAction::shouldUndo() {
    95   return false;
     100  return true;
    96101}
    97102
  • src/Actions/FragmentationAction/FragmentationAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationFragmentation(std::string &path, double distance, int order);
     14
    1315class FragmentationFragmentationAction : public Action {
     16  friend void FragmentationFragmentation(std::string &path, double distance, int order);
     17
    1418public:
    1519  FragmentationFragmentationAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/FragmentationAction/SubgraphDissectionAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "atom.hpp"
    1213#include "config.hpp"
     
    2425#include "UIElements/UIFactory.hpp"
    2526#include "UIElements/Dialog.hpp"
    26 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2728
    2829const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect";
     
    3536{}
    3637
    37 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
     38void FragmentationSubgraphDissection() {
     39  ActionRegistry::getInstance().getActionByName(FragmentationSubgraphDissectionAction::NAME)->call(Action::NonInteractive);
     40};
     41
     42Dialog* FragmentationSubgraphDissectionAction::createDialog() {
    3843  Dialog *dialog = UIFactory::getInstance().makeDialog();
    3944
    4045  dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));
    4146
    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   }
     47  return dialog;
     48}
     49
     50
     51Action::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;
    5357}
    5458
  • src/Actions/FragmentationAction/SubgraphDissectionAction.hpp

    r7067bd6 r677e13  
    1111#include "Actions/Action.hpp"
    1212
     13void FragmentationSubgraphDissection();
     14
    1315class FragmentationSubgraphDissectionAction : public Action {
     16  friend void FragmentationSubgraphDissection();
     17
    1418public:
    1519  FragmentationSubgraphDissectionAction();
     
    2125  virtual const std::string getName();
    2226private:
     27  virtual Dialog * createDialog();
    2328  virtual Action::state_ptr performCall();
    2429  virtual Action::state_ptr performUndo(Action::state_ptr);
Note: See TracChangeset for help on using the changeset viewer.