Changeset c8165c for src/Actions


Ignore:
Timestamp:
May 8, 2017, 2:01:48 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
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.
Message:

Merge branch 'Docu_Python_wait' into Candidate_v1.6.1

Conflicts:

tests/Python/AllActions/options.dat

  • two options introduced at same place, both get in.
Location:
src/Actions
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.hpp

    r73faf4 rc8165c  
    2929 */
    3030#ifndef STATUS
    31 #define STATUS(msg) pushStatus(msg)
     31#define STATUS(msg) \
     32  pushStatus(msg); \
     33  LOG(0, "STATUS: " << msg)
    3234#endif
    3335
  • src/Actions/GlobalListOfActions.hpp

    r73faf4 rc8165c  
    8888  (MoleculeLoad) \
    8989  (MoleculeRemove) \
     90  (MoleculeRotateAroundBond) \
    9091  (MoleculeRotateAroundSelfByAngle) \
    9192  (MoleculeRotateToPrincipalAxisSystem) \
  • src/Actions/Makefile.am

    r73faf4 rc8165c  
    339339  Actions/MoleculeAction/LoadAction.cpp \
    340340  Actions/MoleculeAction/RemoveAction.cpp \
     341  Actions/MoleculeAction/RotateAroundBondAction.cpp \
    341342  Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp \
    342343  Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp \
     
    357358  Actions/MoleculeAction/LoadAction.hpp \
    358359  Actions/MoleculeAction/RemoveAction.hpp \
     360  Actions/MoleculeAction/RotateAroundBondAction.hpp \
    359361  Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp \
    360362  Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp \
     
    375377  Actions/MoleculeAction/LoadAction.def \
    376378  Actions/MoleculeAction/RemoveAction.def \
     379  Actions/MoleculeAction/RotateAroundBondAction.def \
    377380  Actions/MoleculeAction/RotateAroundSelfByAngleAction.def \
    378381  Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.def \
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp

    r73faf4 rc8165c  
    3535//#include "CodePatterns/MemDebug.hpp"
    3636
     37#include "CodePatterns/Assert.hpp"
    3738#include "CodePatterns/Log.hpp"
    38 #include "CodePatterns/Verbose.hpp"
     39
     40#include "Actions/UndoRedoHelpers.hpp"
     41#include "Atom/AtomicInfo.hpp"
    3942#include "LinearAlgebra/Line.hpp"
    4043#include "LinearAlgebra/RealSpaceMatrix.hpp"
     
    5861  molecule *mol = NULL;
    5962
     63  std::vector<AtomicInfo> UndoInfo;
    6064  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
    6165    mol = iter->second;
    6266    LOG(0, "Converting to prinicipal axis system.");
    6367
    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    }
    6578
     79    // rotate
     80//    RealSpaceMatrix InertiaTensor = mol->getInertiaTensor();
    6681    mol->RotateToPrincipalAxisSystem(params.Axis.get());
    6782
    6883    // summing anew for debugging (resulting matrix has to be diagonal!)
    69     InertiaTensor = mol->getInertiaTensor();
     84    RealSpaceMatrix InertiaTensor = mol->getInertiaTensor();
    7085  }
    71   return Action::success;
     86
     87  MoleculeRotateToPrincipalAxisSystemState *UndoState =
     88      new MoleculeRotateToPrincipalAxisSystemState(UndoInfo, params);
     89  return ActionState::ptr(UndoState);
    7290}
    7391
    7492ActionState::ptr MoleculeRotateToPrincipalAxisSystemAction::performUndo(ActionState::ptr _state) {
    75 //  MoleculeRotateToPrincipalAxisSystemState *state = assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
     93  MoleculeRotateToPrincipalAxisSystemState *state =
     94      assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
    7695
    77 //  string newName = state->mol->getName();
    78 //  state->mol->setName(state->lastName);
     96  // set stored old state
     97  SetAtomsFromAtomicInfo(state->undoinfo);
    7998
    80   STATUS("Undo of MoleculeRotateToPrincipalAxisSystemAction not implemented.");
    81   return Action::failure;
     99  return ActionState::ptr(_state);
    82100}
    83101
    84102ActionState::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);
    87113}
    88114
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.def

    r73faf4 rc8165c  
    77
    88// all includes and forward declarations necessary for non-integral types below
     9#include <vector>
     10
    911#include "Actions/Values.hpp"
     12#include "Atom/AtomicInfo.hpp"
    1013#include "LinearAlgebra/Vector.hpp"
    1114
     
    2326(VectorNotZeroValidator())
    2427
    25 #undef statetypes
    26 #undef statereferences
     28#define statetypes (std::vector<AtomicInfo>)
     29#define statereferences (undoinfo)
    2730
    2831// some defines for all the names, you may use ACTION, STATE and PARAMS
  • src/Actions/PotentialAction/ParsePotentialsAction.cpp

    r73faf4 rc8165c  
    7373        deserialize();
    7474      } 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)) {
    7676          STATUS("Missing value when parsing information for potential "+*key+".");
    77         else
     77        } else
    7878          STATUS("Missing value parsing information for potential with unknown key.");
    7979        return Action::failure;
    8080      } 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)) {
    8282          STATUS("Illegal key parsing information for potential "+*key+".");
    83         else
     83        } else {
    8484          STATUS("Illegal key parsing information for potential with unknown key.");
     85        }
    8586        return Action::failure;
    8687      }
  • src/Actions/WorldAction/StepWorldTimeAction.cpp

    r73faf4 rc8165c  
    4747using namespace MoleCuilder;
    4848
    49 // if both are given, we use backwards
    50 static int getSteps(const unsigned int _forward, const unsigned int _backward)
    51 {
    52   int steps = 0;
    53   if (_backward > 0)
    54     steps = -_backward;
    55   else
    56     steps = _forward;
    57 
    58   return steps;
    59 }
    60 
    6149// and construct the stuff
    6250#include "StepWorldTimeAction.def"
     
    6957  WorldStepWorldTimeState *UndoState = new WorldStepWorldTimeState(oldtime, params);
    7058
    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) {
    7460    ELOG(1, "Cannot step back before time step #0.");
    7561    delete UndoState;
    7662    return Action::failure;
    7763  }
    78   World::getInstance().setTime(oldtime+steps);
     64  World::getInstance().setTime(oldtime+params.steps.get());
    7965  LOG(0, "Current time step is now: " << WorldTime::getTime() << ".");
    8066  return ActionState::ptr(UndoState);
     
    9379  WorldStepWorldTimeState *state = assert_cast<WorldStepWorldTimeState*>(_state.get());
    9480
    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());
    10082  LOG(0, "Current time step is now: " << WorldTime::getTime() << ".");
    10183
  • src/Actions/WorldAction/StepWorldTimeAction.def

    r73faf4 rc8165c  
    1414// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1515// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    16 #define paramtypes (unsigned int)(unsigned int)
    17 #define paramtokens ("steps-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)
    2121#define paramvalids \
    22 (DummyValidator< unsigned int >()) \
    23 (DummyValidator< unsigned int >())
     22(DummyValidator< int >())
    2423
    2524#define statetypes (unsigned int)
Note: See TracChangeset for help on using the changeset viewer.