Ignore:
Timestamp:
Jun 12, 2016, 8:48:21 AM (10 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/CenterInBoxAction.cpp

    r996ef1 r25d9d9  
    5353#include <vector>
    5454
    55 #include "Actions/WorldAction/CenterInBoxAction.hpp"
     55#include "Actions/MoleculeAction/CenterInBoxAction.hpp"
    5656
    5757using namespace MoleCuilder;
     
    6161#include "Action_impl_pre.hpp"
    6262/** =========== define the function ====================== */
    63 ActionState::ptr WorldCenterInBoxAction::performCall() {
     63ActionState::ptr MoleculeCenterInBoxAction::performCall() {
    6464  // create undo state
    6565  std::stringstream undostream;
     
    6969  std::vector< boost::shared_ptr<Vector> > OldPositions;
    7070  {
    71     std::vector<const molecule*> AllMolecules = const_cast<const World &>(World::getInstance()).
    72         getAllMolecules();
    73     for (std::vector<const molecule*>::iterator MolRunner = AllMolecules.begin();
    74         MolRunner != AllMolecules.end();
     71    std::vector<const molecule*> SelectedMolecules = const_cast<const World &>(World::getInstance()).
     72        getSelectedMolecules();
     73    for (std::vector<const molecule*>::iterator MolRunner = SelectedMolecules.begin();
     74        MolRunner != SelectedMolecules.end();
    7575        ++MolRunner) {
    7676      for(molecule::const_iterator AtomRunner = (*MolRunner)->begin();
     
    9090
    9191  // center atoms
    92   std::vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
    93   for (std::vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     92  std::vector<molecule*> SelectedMolecules = World::getInstance().getSelectedMolecules();
     93  for (std::vector<molecule*>::iterator MolRunner = SelectedMolecules.begin(); MolRunner != SelectedMolecules.end(); ++MolRunner) {
    9494    (*MolRunner)->CenterInBox();
    9595  }
     
    9999
    100100  // create undo state
    101   WorldCenterInBoxState *UndoState =
    102       new WorldCenterInBoxState(
     101  MoleculeCenterInBoxState *UndoState =
     102      new MoleculeCenterInBoxState(
    103103          undostream.str(),
    104104          OldPositions,
     
    109109}
    110110
    111 ActionState::ptr WorldCenterInBoxAction::performUndo(ActionState::ptr _state) {
    112   WorldCenterInBoxState *state = assert_cast<WorldCenterInBoxState*>(_state.get());
     111ActionState::ptr MoleculeCenterInBoxAction::performUndo(ActionState::ptr _state) {
     112  MoleculeCenterInBoxState *state = assert_cast<MoleculeCenterInBoxState*>(_state.get());
    113113
    114114  // restore domain
     
    121121  // place atoms on old positions
    122122  std::vector< boost::shared_ptr<Vector> >::const_iterator OldPositionsIter = state->OldPositions.begin();
    123   std::vector<molecule*> AllMolecules = World::getInstance().getAllMolecules();
    124   for (std::vector<molecule*>::iterator MolRunner = AllMolecules.begin();
    125       MolRunner != AllMolecules.end();
     123  std::vector<molecule*> SelectedMolecules = World::getInstance().getSelectedMolecules();
     124  for (std::vector<molecule*>::iterator MolRunner = SelectedMolecules.begin();
     125      MolRunner != SelectedMolecules.end();
    126126      ++MolRunner) {
    127127    for(molecule::iterator AtomRunner = (*MolRunner)->begin();
     
    140140}
    141141
    142 ActionState::ptr WorldCenterInBoxAction::performRedo(ActionState::ptr _state){
    143   WorldCenterInBoxState *state = assert_cast<WorldCenterInBoxState*>(_state.get());
     142ActionState::ptr MoleculeCenterInBoxAction::performRedo(ActionState::ptr _state){
     143  MoleculeCenterInBoxState *state = assert_cast<MoleculeCenterInBoxState*>(_state.get());
    144144
    145145  // set new domain
     
    147147
    148148  // center atoms
    149   std::vector<molecule *> AllMolecules = World::getInstance().getAllMolecules();
    150   for (std::vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) {
     149  std::vector<molecule *> SelectedMolecules = World::getInstance().getSelectedMolecules();
     150  for (std::vector<molecule*>::iterator MolRunner = SelectedMolecules.begin(); MolRunner != SelectedMolecules.end(); ++MolRunner) {
    151151    (*MolRunner)->CenterInBox();
    152152  }
     
    158158}
    159159
    160 bool WorldCenterInBoxAction::canUndo() {
     160bool MoleculeCenterInBoxAction::canUndo() {
    161161  return true;
    162162}
    163163
    164 bool WorldCenterInBoxAction::shouldUndo() {
     164bool MoleculeCenterInBoxAction::shouldUndo() {
    165165  return true;
    166166}
Note: See TracChangeset for help on using the changeset viewer.