Ignore:
Timestamp:
Jun 12, 2016, 8:48:21 AM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Fix_BoundInBox_CenterInBox_MoleculeActions
Parents:
996ef1
git-author:
Frederik Heber <heber@…> (06/11/16 16:43:54)
git-committer:
Frederik Heber <heber@…> (06/12/16 08:48:21)
Message:

FIX: CenterInBox and BoundInBox are actions acting on molecules, not world.

  • just stumbled over this when realizing that center-in-box does not center all selected atoms within the box but each of the currently present molecules individually.
  • this is also changed to act only on selected molecules.
  • TEST: extended regression test to only test centering and bounding of some molecules (and not only all).
  • TESTFIX: needed to change regression tests on all molecules to prepend action with select-all-molecules.
  • Needed to renamed python action in boxmaker.py.in.
  • DOCU: Corrected description in userguide.
File:
1 moved

Legend:

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

    r996ef1 r25d9d9  
    4545#include <vector>
    4646
    47 #include "Actions/WorldAction/BoundInBoxAction.hpp"
     47#include "Actions/MoleculeAction/BoundInBoxAction.hpp"
    4848
    4949using namespace MoleCuilder;
     
    5353#include "Action_impl_pre.hpp"
    5454/** =========== define the function ====================== */
    55 ActionState::ptr WorldBoundInBoxAction::performCall() {
     55ActionState::ptr MoleculeBoundInBoxAction::performCall() {
    5656  // create undo state
    5757  std::vector< boost::shared_ptr<Vector> > OldPositions;
    5858  {
    59     std::vector<const molecule*> AllMolecules = const_cast<const World &>(World::getInstance()).
    60         getAllMolecules();
    61     for (vector<const molecule*>::iterator MolRunner = AllMolecules.begin();
    62         MolRunner != AllMolecules.end();
     59    std::vector<const molecule*> SelectedMolecules = const_cast<const World &>(World::getInstance()).
     60        getSelectedMolecules();
     61    for (vector<const molecule*>::iterator MolRunner = SelectedMolecules.begin();
     62        MolRunner != SelectedMolecules.end();
    6363        ++MolRunner) {
    6464      for(molecule::const_iterator AtomRunner = (*MolRunner)->begin();
     
    7373    }
    7474  }
    75   WorldBoundInBoxState *undoState = new WorldBoundInBoxState(OldPositions, params);
     75  MoleculeBoundInBoxState *undoState = new MoleculeBoundInBoxState(OldPositions, params);
    7676
    7777  // center
    78   std::vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
    79   for (std::vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     78  std::vector<molecule*> SelectedMolecules = World::getInstance().getSelectedMolecules();
     79  for (std::vector<molecule*>::iterator MolRunner = SelectedMolecules.begin(); MolRunner != SelectedMolecules.end(); ++MolRunner) {
    8080    (*MolRunner)->BoundInBox();
    8181  }
     
    8383}
    8484
    85 ActionState::ptr WorldBoundInBoxAction::performUndo(ActionState::ptr _state) {
    86   WorldBoundInBoxState *state = assert_cast<WorldBoundInBoxState*>(_state.get());
     85ActionState::ptr MoleculeBoundInBoxAction::performUndo(ActionState::ptr _state) {
     86  MoleculeBoundInBoxState *state = assert_cast<MoleculeBoundInBoxState*>(_state.get());
    8787
    8888  // place atoms on old positions
    8989  std::vector< boost::shared_ptr<Vector> >::const_iterator OldPositionsIter = state->OldPositions.begin();
    90   std::vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
    91   for (std::vector<molecule*>::iterator MolRunner = AllMolecules.begin();
    92       MolRunner != AllMolecules.end();
     90  std::vector<molecule*> SelectedMolecules = World::getInstance().getSelectedMolecules();
     91  for (std::vector<molecule*>::iterator MolRunner = SelectedMolecules.begin();
     92      MolRunner != SelectedMolecules.end();
    9393      ++MolRunner) {
    9494    for(molecule::iterator AtomRunner = (*MolRunner)->begin();
     
    9696        ++AtomRunner) {
    9797      ASSERT(OldPositionsIter != state->OldPositions.end(),
    98           "WorldBoundInBoxAction::performUndo() - too few positions stored in UndoState.");
     98          "MoleculeBoundInBoxAction::performUndo() - too few positions stored in UndoState.");
    9999      (*AtomRunner)->setPosition(**(OldPositionsIter++));
    100100    }
     
    104104}
    105105
    106 ActionState::ptr WorldBoundInBoxAction::performRedo(ActionState::ptr _state){
    107 //  WorldBoundInBoxState *state = assert_cast<WorldBoundInBoxState*>(_state.get());
     106ActionState::ptr MoleculeBoundInBoxAction::performRedo(ActionState::ptr _state){
     107//  MoleculeBoundInBoxState *state = assert_cast<MoleculeBoundInBoxState*>(_state.get());
    108108
    109109  // center
    110   std::vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
    111   for (std::vector<molecule*>::iterator MolRunner = AllMolecules.begin();
    112       MolRunner != AllMolecules.end();
     110  std::vector<molecule*> SelectedMolecules = World::getInstance().getSelectedMolecules();
     111  for (std::vector<molecule*>::iterator MolRunner = SelectedMolecules.begin();
     112      MolRunner != SelectedMolecules.end();
    113113      ++MolRunner) {
    114114    (*MolRunner)->BoundInBox();
     
    118118}
    119119
    120 bool WorldBoundInBoxAction::canUndo() {
     120bool MoleculeBoundInBoxAction::canUndo() {
    121121  return true;
    122122}
    123123
    124 bool WorldBoundInBoxAction::shouldUndo() {
     124bool MoleculeBoundInBoxAction::shouldUndo() {
    125125  return true;
    126126}
Note: See TracChangeset for help on using the changeset viewer.