Changeset c8165c for src/Actions
- Timestamp:
- May 8, 2017, 2:01:48 PM (8 years ago)
- Branches:
- ForceAnnealing_goodresults, ForceAnnealing_tocheck
- Children:
- db0833
- Parents:
- 73faf4 (diff), c1446cd (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. - Location:
- src/Actions
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/Action.hpp
r73faf4 rc8165c 29 29 */ 30 30 #ifndef STATUS 31 #define STATUS(msg) pushStatus(msg) 31 #define STATUS(msg) \ 32 pushStatus(msg); \ 33 LOG(0, "STATUS: " << msg) 32 34 #endif 33 35 -
src/Actions/GlobalListOfActions.hpp
r73faf4 rc8165c 88 88 (MoleculeLoad) \ 89 89 (MoleculeRemove) \ 90 (MoleculeRotateAroundBond) \ 90 91 (MoleculeRotateAroundSelfByAngle) \ 91 92 (MoleculeRotateToPrincipalAxisSystem) \ -
src/Actions/Makefile.am
r73faf4 rc8165c 339 339 Actions/MoleculeAction/LoadAction.cpp \ 340 340 Actions/MoleculeAction/RemoveAction.cpp \ 341 Actions/MoleculeAction/RotateAroundBondAction.cpp \ 341 342 Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp \ 342 343 Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp \ … … 357 358 Actions/MoleculeAction/LoadAction.hpp \ 358 359 Actions/MoleculeAction/RemoveAction.hpp \ 360 Actions/MoleculeAction/RotateAroundBondAction.hpp \ 359 361 Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp \ 360 362 Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp \ … … 375 377 Actions/MoleculeAction/LoadAction.def \ 376 378 Actions/MoleculeAction/RemoveAction.def \ 379 Actions/MoleculeAction/RotateAroundBondAction.def \ 377 380 Actions/MoleculeAction/RotateAroundSelfByAngleAction.def \ 378 381 Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.def \ -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
r73faf4 rc8165c 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
r73faf4 rc8165c 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 -
src/Actions/PotentialAction/ParsePotentialsAction.cpp
r73faf4 rc8165c 73 73 deserialize(); 74 74 } catch (SerializerMissingValueException &e) { 75 if (const std::string *key = boost::get_error_info<SerializerKey>(e)) 75 if (const std::string *key = boost::get_error_info<SerializerKey>(e)) { 76 76 STATUS("Missing value when parsing information for potential "+*key+"."); 77 else77 } else 78 78 STATUS("Missing value parsing information for potential with unknown key."); 79 79 return Action::failure; 80 80 } catch (SerializerIllegalKeyException &e) { 81 if (const std::string *key = boost::get_error_info<SerializerKey>(e)) 81 if (const std::string *key = boost::get_error_info<SerializerKey>(e)) { 82 82 STATUS("Illegal key parsing information for potential "+*key+"."); 83 else83 } else { 84 84 STATUS("Illegal key parsing information for potential with unknown key."); 85 } 85 86 return Action::failure; 86 87 } -
src/Actions/WorldAction/StepWorldTimeAction.cpp
r73faf4 rc8165c 47 47 using namespace MoleCuilder; 48 48 49 // if both are given, we use backwards50 static int getSteps(const unsigned int _forward, const unsigned int _backward)51 {52 int steps = 0;53 if (_backward > 0)54 steps = -_backward;55 else56 steps = _forward;57 58 return steps;59 }60 61 49 // and construct the stuff 62 50 #include "StepWorldTimeAction.def" … … 69 57 WorldStepWorldTimeState *UndoState = new WorldStepWorldTimeState(oldtime, params); 70 58 71 const int steps = getSteps(params.steps_forward.get(), params.steps_backward.get()); 72 73 if ((oldtime + steps) < 0) { 59 if ((oldtime + params.steps.get()) < 0) { 74 60 ELOG(1, "Cannot step back before time step #0."); 75 61 delete UndoState; 76 62 return Action::failure; 77 63 } 78 World::getInstance().setTime(oldtime+ steps);64 World::getInstance().setTime(oldtime+params.steps.get()); 79 65 LOG(0, "Current time step is now: " << WorldTime::getTime() << "."); 80 66 return ActionState::ptr(UndoState); … … 93 79 WorldStepWorldTimeState *state = assert_cast<WorldStepWorldTimeState*>(_state.get()); 94 80 95 const int steps = getSteps( 96 state->params.steps_forward.get(), 97 state->params.steps_backward.get()); 98 99 World::getInstance().setTime(state->oldtime+steps); 81 World::getInstance().setTime(state->oldtime+state->params.steps.get()); 100 82 LOG(0, "Current time step is now: " << WorldTime::getTime() << "."); 101 83 -
src/Actions/WorldAction/StepWorldTimeAction.def
r73faf4 rc8165c 14 14 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 15 15 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 16 #define paramtypes ( unsigned int)(unsignedint)17 #define paramtokens ("step s-forward")("steps-backward")18 #define paramdescriptions ("how many steps to take forward or backward")("how many steps to take forward or backward")19 #define paramdefaults (PARAM_DEFAULT(1)) (PARAM_DEFAULT(0))20 #define paramreferences (steps _forward)(steps_backward)16 #define paramtypes (int) 17 #define paramtokens ("step-world-time") 18 #define paramdescriptions ("how many steps to take forward (positive) or backward (negative)") 19 #define paramdefaults (PARAM_DEFAULT(1)) 20 #define paramreferences (steps) 21 21 #define paramvalids \ 22 (DummyValidator< unsigned int >()) \ 23 (DummyValidator< unsigned int >()) 22 (DummyValidator< int >()) 24 23 25 24 #define statetypes (unsigned int)
Note:
See TracChangeset
for help on using the changeset viewer.