Changeset 0adac1 for src/Actions/AtomAction/TranslateAction.cpp
- Timestamp:
- Aug 13, 2010, 4:16:37 PM (14 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:
- bb4408
- Parents:
- 5f1d5b8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/AtomAction/TranslateAction.cpp
r5f1d5b8 r0adac1 37 37 class AtomTranslateState : public ActionState { 38 38 public: 39 AtomTranslateState( std::vector<atom*> _selectedAtoms, Vector &_v) :39 AtomTranslateState(const std::vector<atom*> &_selectedAtoms, const Vector &_v, const bool _periodic) : 40 40 selectedAtoms(_selectedAtoms), 41 v(_v) 41 v(_v), 42 periodic(_periodic) 42 43 {} 43 44 std::vector<atom*> selectedAtoms; 44 45 Vector v; 46 bool periodic; 45 47 }; 46 48 … … 54 56 {} 55 57 56 void AtomTranslate(Vector &x ) {58 void AtomTranslate(Vector &x, bool periodic = false) { 57 59 ValueStorage::getInstance().setCurrentValue(AtomTranslateAction::NAME, x); 60 ValueStorage::getInstance().setCurrentValue("periodic", periodic); 58 61 ActionRegistry::getInstance().getActionByName(AtomTranslateAction::NAME)->call(Action::NonInteractive); 59 62 }; … … 63 66 64 67 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 68 dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic")); 65 69 66 70 return dialog; … … 69 73 Action::state_ptr AtomTranslateAction::performCall() { 70 74 Vector v; 75 bool periodic = false; 76 Box &domain = World::getInstance().getDomain(); 71 77 std::vector<atom *> selectedAtoms = World::getInstance().getSelectedAtoms(); 72 78 73 79 ValueStorage::getInstance().queryCurrentValue(NAME, v); 80 if (!ValueStorage::getInstance().queryCurrentValue("periodic", periodic, true)) 81 periodic = false; 74 82 75 83 // TODO: use AtomSet::translate 76 84 for (std::vector<atom *>::iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter) { 77 85 *(*iter) += v; 86 if (periodic) 87 (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition())); 78 88 } 79 return Action::state_ptr(new AtomTranslateState(selectedAtoms, v)); 89 90 return Action::state_ptr(new AtomTranslateState(selectedAtoms, v, periodic)); 80 91 } 81 92 82 93 Action::state_ptr AtomTranslateAction::performUndo(Action::state_ptr _state) { 83 94 AtomTranslateState *state = assert_cast<AtomTranslateState*>(_state.get()); 95 Box &domain = World::getInstance().getDomain(); 84 96 85 97 for (std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter) { 86 98 *(*iter) -= state->v; 99 if (state->periodic) 100 (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition())); 87 101 } 88 102 89 return Action::state_ptr( new AtomTranslateState(state->selectedAtoms, state->v));103 return Action::state_ptr(_state); 90 104 } 91 105 92 106 Action::state_ptr AtomTranslateAction::performRedo(Action::state_ptr _state){ 93 107 AtomTranslateState *state = assert_cast<AtomTranslateState*>(_state.get()); 108 Box &domain = World::getInstance().getDomain(); 94 109 95 110 for (std::vector<atom *>::iterator iter = state->selectedAtoms.begin(); iter != state->selectedAtoms.end(); ++iter) { 96 111 *(*iter) += state->v; 112 if (state->periodic) 113 (*iter)->setPosition(domain.WrapPeriodically((*iter)->getPosition())); 97 114 } 98 115 99 return Action::state_ptr( new AtomTranslateState(state->selectedAtoms, state->v));116 return Action::state_ptr(_state); 100 117 } 101 118
Note:
See TracChangeset
for help on using the changeset viewer.