Ignore:
Timestamp:
Aug 13, 2010, 4:16:37 PM (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, 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:
bb4408
Parents:
5f1d5b8
Message:

Added "periodic" as optional argument to TranslateAction.

  • entails execution of Box::WrapPeriodically() if true.
  • BUGFIX: friend declaration had wrong signature.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AtomAction/TranslateAction.cpp

    r5f1d5b8 r0adac1  
    3737class AtomTranslateState : public ActionState {
    3838public:
    39   AtomTranslateState(std::vector<atom*> _selectedAtoms, Vector &_v) :
     39  AtomTranslateState(const std::vector<atom*> &_selectedAtoms, const Vector &_v, const bool _periodic) :
    4040    selectedAtoms(_selectedAtoms),
    41     v(_v)
     41    v(_v),
     42    periodic(_periodic)
    4243  {}
    4344  std::vector<atom*> selectedAtoms;
    4445  Vector v;
     46  bool periodic;
    4547};
    4648
     
    5456{}
    5557
    56 void AtomTranslate(Vector &x) {
     58void AtomTranslate(Vector &x, bool periodic = false) {
    5759  ValueStorage::getInstance().setCurrentValue(AtomTranslateAction::NAME, x);
     60  ValueStorage::getInstance().setCurrentValue("periodic", periodic);
    5861  ActionRegistry::getInstance().getActionByName(AtomTranslateAction::NAME)->call(Action::NonInteractive);
    5962};
     
    6366
    6467  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     68  dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
    6569
    6670  return dialog;
     
    6973Action::state_ptr AtomTranslateAction::performCall() {
    7074  Vector v;
     75  bool periodic = false;
     76  Box &domain = World::getInstance().getDomain();
    7177  std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms();
    7278
    7379  ValueStorage::getInstance().queryCurrentValue(NAME, v);
     80  if (!ValueStorage::getInstance().queryCurrentValue("periodic", periodic, true))
     81    periodic = false;
    7482
    7583  // TODO: use AtomSet::translate
    7684  for (std::vector<atom *>::iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter) {
    7785    *(*iter) += v;
     86    if (periodic)
     87      (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition()));
    7888  }
    79   return Action::state_ptr(new AtomTranslateState(selectedAtoms, v));
     89
     90  return Action::state_ptr(new AtomTranslateState(selectedAtoms, v, periodic));
    8091}
    8192
    8293Action::state_ptr AtomTranslateAction::performUndo(Action::state_ptr _state) {
    8394  AtomTranslateState *state = assert_cast<AtomTranslateState*>(_state.get());
     95  Box &domain = World::getInstance().getDomain();
    8496
    8597  for (std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter) {
    8698    *(*iter) -= state->v;
     99    if (state->periodic)
     100      (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition()));
    87101  }
    88102
    89   return Action::state_ptr(new AtomTranslateState(state->selectedAtoms, state->v));
     103  return Action::state_ptr(_state);
    90104}
    91105
    92106Action::state_ptr AtomTranslateAction::performRedo(Action::state_ptr _state){
    93107  AtomTranslateState *state = assert_cast<AtomTranslateState*>(_state.get());
     108  Box &domain = World::getInstance().getDomain();
    94109
    95110  for (std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter) {
    96111    *(*iter) += state->v;
     112    if (state->periodic)
     113      (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition()));
    97114  }
    98115
    99   return Action::state_ptr(new AtomTranslateState(state->selectedAtoms, state->v));
     116  return Action::state_ptr(_state);
    100117}
    101118
Note: See TracChangeset for help on using the changeset viewer.