Changeset 9cd6bf
- Timestamp:
- Oct 14, 2011, 9:43:40 AM (13 years ago)
- 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, 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:
- e670e4
- Parents:
- a8b10a
- git-author:
- Frederik Heber <heber@…> (09/12/11 09:07:45)
- git-committer:
- Frederik Heber <heber@…> (10/14/11 09:43:40)
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
ra8b10a r9cd6bf 18 18 #endif 19 19 20 // include headers that implement a archive in simple text format 21 #include <boost/archive/text_oarchive.hpp> 22 #include <boost/archive/text_iarchive.hpp> 23 #include "boost/serialization/vector.hpp" 24 20 25 #include "CodePatterns/MemDebug.hpp" 21 26 22 27 #include "atom.hpp" 28 #include "Box.hpp" 23 29 #include "CodePatterns/Log.hpp" 30 #include "LinearAlgebra/MatrixContent.hpp" 24 31 #include "LinearAlgebra/RealSpaceMatrix.hpp" 25 32 #include "LinearAlgebra/Vector.hpp" … … 46 53 getParametersfromValueStorage(); 47 54 55 // create undo domain 56 std::stringstream undostream; 57 boost::archive::text_oarchive oa(undostream); 58 const RealSpaceMatrix &matrix = World::getInstance().getDomain().getM(); 59 oa << matrix; 60 48 61 // get maximum and minimum 49 vector<atom *> AllAtoms = World::getInstance().getAllAtoms();62 std::vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 50 63 ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary."); 51 vector<atom *>::iterator AtomRunner = AllAtoms.begin();64 std::vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 52 65 Min = (*AtomRunner)->getPosition(); 53 66 Max = (*AtomRunner)->getPosition(); … … 73 86 // translate all atoms, such that Min is aty (0,0,0) 74 87 AtomRunner = AllAtoms.begin(); 75 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) 88 for (std::vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 89 AtomRunner != AllAtoms.end(); 90 ++AtomRunner) 76 91 *(*AtomRunner) -= Min - params.boundary; 77 92 … … 79 94 LOG(0, "Box domain is now " << World::getInstance().getDomain().getM()); 80 95 81 return Action::success; 96 // create undo state 97 WorldAddEmptyBoundaryState *UndoState = 98 new WorldAddEmptyBoundaryState( 99 undostream.str(), 100 World::getInstance().getDomain().getM(), 101 Min, 102 params 103 ); 104 105 return Action::state_ptr(UndoState); 82 106 } 83 107 84 108 Action::state_ptr WorldAddEmptyBoundaryAction::performUndo(Action::state_ptr _state) { 85 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());109 WorldAddEmptyBoundaryState *state = assert_cast<WorldAddEmptyBoundaryState*>(_state.get()); 86 110 87 return Action::failure; 88 // string newName = state->mol->getName(); 89 // state->mol->setName(state->lastName); 90 // 91 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 111 // restore domain 112 RealSpaceMatrix matrix; 113 std::stringstream undostream(state->undostring); 114 boost::archive::text_iarchive ia(undostream); 115 ia >> matrix; 116 World::getInstance().setDomain(matrix); 117 118 // give final box size 119 LOG(0, "Box domain restored to " << World::getInstance().getDomain().getM()); 120 121 // restore atoms 122 std::vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 123 for (std::vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 124 AtomRunner != AllAtoms.end(); 125 ++AtomRunner) 126 *(*AtomRunner) += state->Min - state->params.boundary; 127 128 return Action::state_ptr(_state); 92 129 } 93 130 94 131 Action::state_ptr WorldAddEmptyBoundaryAction::performRedo(Action::state_ptr _state){ 95 return Action::failure; 132 WorldAddEmptyBoundaryState *state = assert_cast<WorldAddEmptyBoundaryState*>(_state.get()); 133 134 World::getInstance().setDomain(state->newdomain); 135 136 // give final box size 137 LOG(0, "Box domain is again " << World::getInstance().getDomain().getM()); 138 139 // shift atoms 140 std::vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 141 for (std::vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 142 AtomRunner != AllAtoms.end(); 143 ++AtomRunner) 144 *(*AtomRunner) -= state->Min - state->params.boundary; 145 146 return Action::state_ptr(_state); 96 147 } 97 148 98 149 bool WorldAddEmptyBoundaryAction::canUndo() { 99 return false;150 return true; 100 151 } 101 152 102 153 bool WorldAddEmptyBoundaryAction::shouldUndo() { 103 return false;154 return true; 104 155 } 105 156 /** =========== end of function ====================== */ -
src/Actions/WorldAction/AddEmptyBoundaryAction.def
ra8b10a r9cd6bf 8 8 // all includes and forward declarations necessary for non-integral types below 9 9 #include "Actions/Values.hpp" 10 #include "LinearAlgebra/RealSpaceMatrix.hpp" 10 11 #include "LinearAlgebra/Vector.hpp" 11 12 … … 19 20 #define paramreferences (boundary) 20 21 21 # undef statetypes22 # undef statereferences22 #define statetypes (std::string)(RealSpaceMatrix)(Vector) 23 #define statereferences (undostring)(newdomain)(Min) 23 24 24 25 // some defines for all the names, you may use ACTION, STATE and PARAMS -
tests/regression/Domain/AddEmptyBoundary/testsuite-domain-add-empty-boundary.at
ra8b10a r9cd6bf 15 15 16 16 AT_SETUP([Domain - center and add empty boundary with Undo]) 17 AT_XFAIL_IF([/bin/true]) 18 AT_KEYWORDS([domain add-empty-boundar undo]) 17 AT_KEYWORDS([domain add-empty-boundary undo]) 19 18 20 19 file=test.conf … … 22 21 AT_CHECK([chmod u+w $file], 0) 23 22 AT_CHECK([../../molecuilder -i $file -c "5, 10, 15" --undo], 0, [stdout], [stderr]) 24 AT_CHECK([fgrep "Box domain is now" stdout], 0, [ignore], [ignore])25 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Domain/AddEmptyBoundary/post/test .conf], 0, [stdout], [stderr])23 AT_CHECK([fgrep "Box domain restored to" stdout], 0, [ignore], [ignore]) 24 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Domain/AddEmptyBoundary/post/test-undo.conf], 0, [stdout], [stderr]) 26 25 27 26 AT_CLEANUP … … 29 28 30 29 AT_SETUP([Domain - center and add empty boundary with Redo]) 31 AT_XFAIL_IF([/bin/true])32 30 AT_KEYWORDS([domain add-empty-boundary redo]) 33 31
Note:
See TracChangeset
for help on using the changeset viewer.