Changeset 536b13 for src/Actions
- Timestamp:
- Jun 20, 2017, 8:01:31 PM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChangeBugEmailaddress, ChemicalSpaceEvaluator, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_oldresults, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps
- Children:
- da7ef9
- Parents:
- 5e17bf
- git-author:
- Frederik Heber <heber@…> (03/23/17 03:37:36)
- git-committer:
- Frederik Heber <frederik.heber@…> (06/20/17 20:01:31)
- Location:
- src/Actions/MoleculeAction
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
r5e17bf r536b13 35 35 //#include "CodePatterns/MemDebug.hpp" 36 36 37 #include "CodePatterns/Assert.hpp" 37 38 #include "CodePatterns/Log.hpp" 38 #include "CodePatterns/Verbose.hpp" 39 40 #include "Actions/UndoRedoHelpers.hpp" 41 #include "Atom/AtomicInfo.hpp" 39 42 #include "LinearAlgebra/Line.hpp" 40 43 #include "LinearAlgebra/RealSpaceMatrix.hpp" … … 58 61 molecule *mol = NULL; 59 62 63 std::vector<AtomicInfo> UndoInfo; 60 64 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 61 65 mol = iter->second; 62 66 LOG(0, "Converting to prinicipal axis system."); 63 67 64 RealSpaceMatrix InertiaTensor = mol->getInertiaTensor(); 68 // gather undo information: store position of all atoms of molecule 69 UndoInfo.reserve(UndoInfo.size()+mol->size()); 70 { 71 for (molecule::const_iterator iter = const_cast<molecule const *>(mol)->begin(); 72 iter != const_cast<molecule const *>(mol)->end(); 73 ++iter) { 74 const atom * const Walker = *iter; 75 UndoInfo.push_back(AtomicInfo(*Walker)); 76 } 77 } 65 78 79 // rotate 80 // RealSpaceMatrix InertiaTensor = mol->getInertiaTensor(); 66 81 mol->RotateToPrincipalAxisSystem(params.Axis.get()); 67 82 68 83 // summing anew for debugging (resulting matrix has to be diagonal!) 69 InertiaTensor = mol->getInertiaTensor();84 RealSpaceMatrix InertiaTensor = mol->getInertiaTensor(); 70 85 } 71 return Action::success; 86 87 MoleculeRotateToPrincipalAxisSystemState *UndoState = 88 new MoleculeRotateToPrincipalAxisSystemState(UndoInfo, params); 89 return ActionState::ptr(UndoState); 72 90 } 73 91 74 92 ActionState::ptr MoleculeRotateToPrincipalAxisSystemAction::performUndo(ActionState::ptr _state) { 75 // MoleculeRotateToPrincipalAxisSystemState *state = assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get()); 93 MoleculeRotateToPrincipalAxisSystemState *state = 94 assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get()); 76 95 77 // string newName = state->mol->getName(); 78 // state->mol->setName(state->lastName);96 // set stored old state 97 SetAtomsFromAtomicInfo(state->undoinfo); 79 98 80 STATUS("Undo of MoleculeRotateToPrincipalAxisSystemAction not implemented."); 81 return Action::failure; 99 return ActionState::ptr(_state); 82 100 } 83 101 84 102 ActionState::ptr MoleculeRotateToPrincipalAxisSystemAction::performRedo(ActionState::ptr _state){ 85 STATUS("Redo of MoleculeRotateToPrincipalAxisSystemAction not implemented."); 86 return Action::failure; 103 MoleculeRotateToPrincipalAxisSystemState *state = 104 assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get()); 105 106 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); 107 iter != World::getInstance().endMoleculeSelection(); ++iter) { 108 molecule * const mol = iter->second; 109 mol->RotateToPrincipalAxisSystem(state->params.Axis.get()); 110 } 111 112 return ActionState::ptr(_state); 87 113 } 88 114 -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.def
r5e17bf r536b13 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 #include <vector> 10 9 11 #include "Actions/Values.hpp" 12 #include "Atom/AtomicInfo.hpp" 10 13 #include "LinearAlgebra/Vector.hpp" 11 14 … … 23 26 (VectorNotZeroValidator()) 24 27 25 # undef statetypes26 # undef statereferences28 #define statetypes (std::vector<AtomicInfo>) 29 #define statereferences (undoinfo) 27 30 28 31 // some defines for all the names, you may use ACTION, STATE and PARAMS
Note:
See TracChangeset
for help on using the changeset viewer.