Ignore:
Timestamp:
Apr 6, 2012, 11:44:50 AM (14 years ago)
Author:
Frederik Heber <heber@…>
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:
cc9119
Parents:
57dd40
git-author:
Frederik Heber <heber@…> (04/05/12 09:38:33)
git-committer:
Frederik Heber <heber@…> (04/06/12 11:44:50)
Message:

Filler::operator() has param vector of Cluster's that is filled with inserted ones to allow for undoing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FillAction/FillSphericalSurfaceAction.cpp

    r57dd40 r42b6de  
    2020#include "CodePatterns/MemDebug.hpp"
    2121
     22#include "Actions/UndoRedoHelpers.hpp"
     23#include "Atom/AtomicInfo.hpp"
    2224#include "Atom/CopyAtoms/CopyAtoms_withBonds.hpp"
    2325#include "CodePatterns/Log.hpp"
     
    8284
    8385  // create predicate, mesh, and filler
     86  std::vector<AtomicInfo> clonedatoms;
    8487  bool successflag = false;
    8588  {
     
    101104      ClusterInterface::Cluster_impl cluster( new Cluster( filler->getAtomIds(), filler->getBoundingShape() ) );
    102105      CopyAtoms_withBonds copyMethod;
    103       successflag = (*fillerFunction)(copyMethod, cluster);
     106      Filler::ClusterVector_t ClonedClusters;
     107      successflag = (*fillerFunction)(copyMethod, cluster, ClonedClusters);
    104108      delete fillerFunction;
     109
     110      // append each cluster's atoms to clonedatoms
     111      for (Filler::ClusterVector_t::const_iterator iter = ClonedClusters.begin();
     112          iter != ClonedClusters.end(); ++iter) {
     113        const AtomIdSet &atoms = (*iter)->getAtomIds();
     114        clonedatoms.reserve(clonedatoms.size()+atoms.size());
     115        for (AtomIdSet::const_iterator atomiter = atoms.begin(); atomiter != atoms.end(); ++atomiter)
     116          clonedatoms.push_back( AtomicInfo(*(*atomiter)) );
     117      }
     118      if (!successflag) {
     119        ELOG(1, "Insertion failed, removing inserted clusters again.");
     120        RemoveAtomsFromAtomicInfo(clonedatoms);
     121        clonedatoms.clear();
     122      }
    105123    }
     124
    106125
    107126    // remove
     
    112131
    113132  if (successflag)
    114     return Action::success;
     133    return Action::state_ptr(new FillSphericalSurfaceState(clonedatoms,params));
    115134  else
    116135    return Action::failure;
     
    118137
    119138Action::state_ptr FillSphericalSurfaceAction::performUndo(Action::state_ptr _state) {
    120   return Action::failure;
     139  FillSphericalSurfaceState *state = assert_cast<FillSphericalSurfaceState*>(_state.get());
     140
     141  // remove all created atoms
     142  RemoveAtomsFromAtomicInfo(state->clonedatoms);
     143
     144  return Action::state_ptr(_state);
    121145}
    122146
    123147Action::state_ptr FillSphericalSurfaceAction::performRedo(Action::state_ptr _state){
    124   return Action::failure;
     148  FillSphericalSurfaceState *state = assert_cast<FillSphericalSurfaceState*>(_state.get());
     149
     150  if (AddAtomsFromAtomicInfo(state->clonedatoms))
     151    return Action::state_ptr(_state);
     152  else
     153    return Action::failure;
    125154}
    126155
    127156bool FillSphericalSurfaceAction::canUndo() {
    128   return false;
     157  return true;
    129158}
    130159
    131160bool FillSphericalSurfaceAction::shouldUndo() {
    132   return false;
     161  return true;
    133162}
    134163/** =========== end of function ====================== */
Note: See TracChangeset for help on using the changeset viewer.