Changeset c00d35 for src


Ignore:
Timestamp:
Feb 3, 2011, 9:51:18 AM (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:
0b15bb
Parents:
cb9de4
git-author:
Frederik Heber <heber@…> (12/29/10 16:30:04)
git-committer:
Frederik Heber <heber@…> (02/03/11 09:51:18)
Message:

RotateAroundSelfByAngle now acts on all selected molecules.

Location:
src/Actions/MoleculeAction
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp

    rcb9de4 rc00d35  
    4141/** =========== define the function ====================== */
    4242Action::state_ptr MoleculeRotateAroundSelfByAngleAction::performCall() {
    43   molecule *mol = NULL;
    44 
    4543  // obtain information
    4644  getParametersfromValueStorage();
    4745
    48   // check whether a single atom and molecule is selected
    49   if (World::getInstance().getSelectedMolecules().size() != 1)
    50     return Action::failure;
    51   mol = World::getInstance().beginMoleculeSelection()->second;
    52 
    53   // check whether Axis is valid
    54   if (params.Axis.IsZero())
     46  // check whether a molecule is selected
     47  std::vector<molecule *> selectedMolecules = World::getInstance().getSelectedMolecules();
     48  if (selectedMolecules.size() == 0)
    5549    return Action::failure;
    5650
    57   // convert from degrees to radian
    58   params.angle *= M_PI/180.;
     51  // go through all selected molecules
     52  BOOST_FOREACH(molecule *mol, selectedMolecules) {
     53    // check whether Axis is valid
     54    if (params.Axis.IsZero())
     55      return Action::failure;
    5956
    60   // Creation Line that is the rotation axis
    61   Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
    62   Line RotationAxis(*CenterOfGravity, params.Axis);
    63   delete(CenterOfGravity);
    64   DoLog(0) && (Log() << Verbose(0) << "Rotate around self by " << params.angle << " along " << RotationAxis << "." << endl);
     57    // convert from degrees to radian
     58    params.angle *= M_PI/180.;
    6559
    66   for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    67     (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), params.angle));
     60    // Creation Line that is the rotation axis
     61    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
     62    Line RotationAxis(*CenterOfGravity, params.Axis);
     63    delete(CenterOfGravity);
     64    DoLog(0) && (Log() << Verbose(0) << "Rotate " << mol->getName() << " around self by " << params.angle << " along " << RotationAxis << "." << endl);
     65
     66    for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     67      (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), params.angle));
     68    }
     69    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    6870  }
    69   DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    7071
    71   return Action::state_ptr(new MoleculeRotateAroundSelfByAngleState(mol, params));
     72  return Action::state_ptr(new MoleculeRotateAroundSelfByAngleState(selectedMolecules, params));
    7273}
    7374
     
    7576  MoleculeRotateAroundSelfByAngleState *state = assert_cast<MoleculeRotateAroundSelfByAngleState*>(_state.get());
    7677
    77   Vector *CenterOfGravity = state->mol->DetermineCenterOfGravity();
    78   Line RotationAxis(*CenterOfGravity, state->params.Axis);
    79   delete(CenterOfGravity);
     78  BOOST_FOREACH(molecule *mol, state->selectedMolecules) {
     79    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
     80    Line RotationAxis(*CenterOfGravity, state->params.Axis);
     81    delete(CenterOfGravity);
    8082
    81   for (molecule::iterator iter = state->mol->begin(); iter != state->mol->end(); ++iter) {
    82     (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), -state->params.angle));
     83    for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     84      (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), -state->params.angle));
     85    }
    8386  }
    8487
     
    8992  MoleculeRotateAroundSelfByAngleState *state = assert_cast<MoleculeRotateAroundSelfByAngleState*>(_state.get());
    9093
    91   Vector *CenterOfGravity = state->mol->DetermineCenterOfGravity();
    92   Line RotationAxis(*CenterOfGravity, state->params.Axis);
    93   delete(CenterOfGravity);
     94  BOOST_FOREACH(molecule *mol, state->selectedMolecules) {
     95    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
     96    Line RotationAxis(*CenterOfGravity, state->params.Axis);
     97    delete(CenterOfGravity);
    9498
    95   for (molecule::iterator iter = state->mol->begin(); iter != state->mol->end(); ++iter) {
    96     (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), state->params.angle));
     99    for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     100      (*iter)->setPosition(RotationAxis.rotateVector((*iter)->getPosition(), state->params.angle));
     101    }
    97102  }
    98103
  • src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.def

    rcb9de4 rc00d35  
    1919#define paramreferences (angle)(Axis)
    2020
    21 #define statetypes (molecule * const)
    22 #define statereferences (mol)
     21#define statetypes (std::vector<molecule*>)
     22#define statereferences (selectedMolecules)
    2323
    2424// some defines for all the names, you may use ACTION, STATE and PARAMS
Note: See TracChangeset for help on using the changeset viewer.