Changeset 7e2adc for src


Ignore:
Timestamp:
Aug 5, 2015, 5:32:13 PM (9 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:
b9e47e
Parents:
a9161d
git-author:
Frederik Heber <heber@…> (07/19/15 20:47:41)
git-committer:
Frederik Heber <heber@…> (08/05/15 17:32:13)
Message:

FIX: GLMoleculeObject_bond had both flipped ids and the side.

  • in essence, both do the same thing. We removed all switches that check the sides as flipped ids are actually nice and look good in the observerLog. We keep the side variable as it might come handy for checking which one we are.
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp

    ra9161d r7e2adc  
    7878  leftatomId(bondIds.first),
    7979  rightatomId(bondIds.second),
    80   leftatomref(getAtom(leftatomId)),
    81   rightatomref(getAtom(rightatomId)),
    82   bondref(*leftatomref->getBond(rightatomref)),
     80  leftowner(getAtom(leftatomId)),
     81  rightowner(getAtom(rightatomId)),
     82  bondowner(getAtom(leftatomId)->getBond(getAtom(rightatomId)).get()),
    8383  BondSide(side),
    8484  leftPosition(
    85       leftatomref,
     85      leftowner,
    8686      boost::bind(&GLMoleculeObject_bond::updateLeftPosition, this),
    8787      "BondleftPosition_"+toString(leftatomId),
     
    8989      BondPositionChannels),
    9090  rightPosition(
    91       rightatomref,
     91      rightowner,
    9292      boost::bind(&GLMoleculeObject_bond::updateRightPosition, this),
    9393      "BondrightPosition_"+toString(rightatomId),
     
    9595      BondPositionChannels),
    9696  leftElement(
    97       leftatomref,
     97      leftowner,
    9898      boost::bind(&GLMoleculeObject_bond::updateLeftElement, this),
    9999      "BondleftElement"+toString(leftatomId),
     
    101101      BondElementChannels),
    102102  rightElement(
    103       rightatomref,
     103      rightowner,
    104104      boost::bind(&GLMoleculeObject_bond::updateRightElement, this),
    105105      "BondrightElement"+toString(rightatomId),
     
    107107      BondElementChannels),
    108108  Degree(
    109       &bondref,
     109      bondowner,
    110110      boost::bind(&GLMoleculeObject_bond::updateDegree, this),
    111111      "BondDegree"+toString(leftatomId)+"_"+toString(rightatomId),
     
    116116{
    117117  // sign on as observer (obtain non-const instance before)
    118   bondref.signOn(this, BondObservable::BondRemoved);
    119   bondref.signOn(this, BondObservable::DegreeChanged);
     118  bondowner->signOn(this, BondObservable::BondRemoved);
     119  bondowner->signOn(this, BondObservable::DegreeChanged);
    120120  bond_enabled = true;
    121   leftatomref->signOn(this, AtomObservable::PositionChanged);
    122   leftatomref->signOn(this, AtomObservable::ElementChanged);
     121  leftowner->signOn(this, AtomObservable::PositionChanged);
     122  leftowner->signOn(this, AtomObservable::ElementChanged);
    123123  leftobservable_enabled = true;
    124   rightatomref->signOn(this, AtomObservable::PositionChanged);
    125   rightatomref->signOn(this, AtomObservable::ElementChanged);
     124  rightowner->signOn(this, AtomObservable::PositionChanged);
     125  rightowner->signOn(this, AtomObservable::ElementChanged);
    126126  rightobservable_enabled = true;
    127127
     
    140140      leftatomId << "," << rightatomId << "] and side " << BondSide << ".");
    141141  // signOff() if not already done
    142   removeLeftAtom();
    143   removeRightAtom();
    144142  removeChannels();
    145143}
    146144
    147 void GLMoleculeObject_bond::removeLeftAtom()
     145void GLMoleculeObject_bond::removeChannels()
    148146{
    149147  // at this point both atoms should still be alive, hence we may safely sign off
    150148  // from the AtomObservable itself
     149  if (bond_enabled) {
     150    if (bondowner != NULL) {
     151      bondowner->signOff(this, BondObservable::BondRemoved);
     152      bondowner->signOff(this, BondObservable::DegreeChanged);
     153    }
     154    bond_enabled = false;
     155  }
    151156  if (leftobservable_enabled) {
    152     const atom * const _leftatom = const_cast<const World &>(World::getInstance()).
    153         getAtom(AtomById(leftatomId));
    154     if (_leftatom != NULL) {
    155       _leftatom->signOff(this);
    156     } else {
    157       ELOG(2, "Left atom of bond with id "+toString(leftatomId)+" is already gone.");
    158     }
    159   }
    160 }
    161 
    162 void GLMoleculeObject_bond::removeRightAtom()
    163 {
    164   // at this point both atoms should still be alive, hence we may safely sign off
    165   // from the AtomObservable itself
     157    if (leftowner != NULL) {
     158      leftowner->signOff(this, AtomObservable::PositionChanged);
     159      leftowner->signOff(this, AtomObservable::ElementChanged);
     160    }
     161    leftobservable_enabled = false;
     162  }
    166163  if (rightobservable_enabled) {
    167     const atom * const _rightatom = const_cast<const World &>(World::getInstance()).
    168         getAtom(AtomById(rightatomId));
    169     if (_rightatom != NULL) {
    170       _rightatom->signOff(this);
    171     } else {
    172       ELOG(2, "Right atom of bond with id "+toString(rightatomId)+" is already gone.");
    173     }
    174   }
    175 }
    176 
    177 void GLMoleculeObject_bond::removeChannels()
    178 {
    179   // at this point both atoms should still be alive, hence we may safely sign off
    180   // from the AtomObservable itself
    181   if (leftobservable_enabled) {
    182     const atom * const _leftatom = const_cast<const World &>(World::getInstance()).
    183         getAtom(AtomById(leftatomId));
    184     if (_leftatom != NULL) {
    185       _leftatom->signOff(this, AtomObservable::PositionChanged);
    186       _leftatom->signOff(this, AtomObservable::ElementChanged);
    187     } else {
    188       ELOG(2, "Left atom of bond with id "+toString(leftatomId)+" is already gone.");
    189     }
    190     leftobservable_enabled = false;
    191   }
    192   if (rightobservable_enabled) {
    193     const atom * const _rightatom = const_cast<const World &>(World::getInstance()).
    194         getAtom(AtomById(rightatomId));
    195     if (_rightatom != NULL) {
    196       _rightatom->signOff(this, AtomObservable::PositionChanged);
    197       _rightatom->signOff(this, AtomObservable::ElementChanged);
    198     } else {
    199       ELOG(2, "Right atom of bond with id "+toString(rightatomId)+" is already gone.");
     164    if (rightowner != NULL) {
     165      rightowner->signOff(this, AtomObservable::PositionChanged);
     166      rightowner->signOff(this, AtomObservable::ElementChanged);
    200167    }
    201168    rightobservable_enabled = false;
    202169  }
    203   if (bond_enabled) {
    204     const atom * const _leftatom = const_cast<const World &>(World::getInstance()).
    205         getAtom(AtomById(leftatomId));
    206     const atom * const _rightatom = const_cast<const World &>(World::getInstance()).
    207         getAtom(AtomById(rightatomId));
    208     if ((_leftatom != NULL) && (_rightatom != NULL)) {
    209       bond::ptr _bond = _leftatom->getBond(_rightatom);
    210       if (_bond != NULL) {
    211         _bond->signOff(this, BondObservable::BondRemoved);
    212         _bond->signOff(this, BondObservable::DegreeChanged);
    213       }
    214     }
    215     bond_enabled = false;
    216   }
    217170}
    218171
     
    220173{
    221174  // sign off
    222   switch (BondSide) {
    223     case left:
    224       emit BondRemoved(leftatomId, rightatomId);
    225       break;
    226     case right:
    227       emit BondRemoved(rightatomId, leftatomId);
    228       break;
    229     default:
    230       ASSERT(0,
    231           "GLMoleculeObject_bond::removeMe() - side is not a valid argument: "
    232           +toString(BondSide)+".");
    233       break;
    234   }
     175  emit BondRemoved(leftatomId, rightatomId);
    235176}
    236177
     
    242183void GLMoleculeObject_bond::subjectKilled(Observable *publisher)
    243184{
    244   // assume subjectKilled() is from Observable's own subjectKilled(), not notifications
    245   // but we must always signOff from all other sources!
    246   if (publisher == static_cast<const Observable*>(&bondref)) {
     185  // we signOff from all other sources
     186  removeChannels();
     187  // then indicate to remove us
     188  removeMe();
     189}
     190
     191void GLMoleculeObject_bond::recieveNotification(Observable *publisher, Notification_ptr notification)
     192{
    247193#ifdef LOG_OBSERVER
    248     observerLog().addMessage() << "++ subjectKilled of Observer "
    249         << observerLog().getName(static_cast<Observer*>(this))
    250         << " from bond.";
    251 #endif
    252     removeLeftAtom();
    253     removeRightAtom();
    254   } else if (publisher == static_cast<const Observable*>(leftatomref)) {
    255 #ifdef LOG_OBSERVER
    256     observerLog().addMessage() << "++ subjectKilled of Observer "
    257         << observerLog().getName(static_cast<Observer*>(this))
    258         << " from leftatom " << leftatomId << ".";
    259 #endif
    260     removeRightAtom();
    261   } else   if (publisher == static_cast<const Observable*>(rightatomref)) {
    262 #ifdef LOG_OBSERVER
    263     observerLog().addMessage() << "++ subjectKilled of Observer " <<
    264         observerLog().getName(static_cast<Observer*>(this))
    265         << " from rightatom " << rightatomId << ".";
    266 #endif
    267     removeLeftAtom();
    268   } else {
    269 #ifdef LOG_OBSERVER
    270     observerLog().addMessage() << "++ subjectKilled of Observer "
    271         << observerLog().getName(static_cast<Observer*>(this))
    272         << " from unknown source.";
    273 #endif
    274     ASSERT(0, "GLMoleculeObject_bond::recieveNotification() - notification from unknown source.");
    275   }
    276   // then indicate to remove us
    277   removeChannels();
    278   removeMe();
    279 }
    280 
    281 void GLMoleculeObject_bond::recieveNotification(Observable *publisher, Notification_ptr notification)
    282 {
    283 #ifdef LOG_OBSERVER
    284   if (publisher == static_cast<const Observable *>(&bondref)) {
     194  if (publisher == static_cast<const Observable *>(bondowner)) {
    285195    observerLog().addMessage() << "++ Update of Observer "
    286196        << observerLog().getName(static_cast<Observer*>(this))
    287197        << " received notification from bond for channel "
    288198        << notification->getChannelNo() << ".";
    289   } else if (publisher == static_cast<const Observable * const>(leftatomref)) {
     199  } else if (publisher == static_cast<const Observable * const>(leftowner)) {
    290200    observerLog().addMessage() << "++ Update of Observer "
    291201        << observerLog().getName(static_cast<Observer*>(this))
    292202        << " received notification from leftatom " << leftatomId << " for channel "
    293203        << notification->getChannelNo() << ".";
    294   } else if (publisher == static_cast<const Observable * const>(rightatomref)) {
     204  } else if (publisher == static_cast<const Observable * const>(rightowner)) {
    295205    observerLog().addMessage() << "++ Update of Observer "
    296206        << observerLog().getName(static_cast<Observer*>(this))
    297207        << " received notification from rightatom " << rightatomId << " for channel "
    298208        << notification->getChannelNo() << ".";
    299   } else
    300     observerLog().addMessage() << "++ Update of Observer "
    301         << observerLog().getName(static_cast<Observer*>(this))
    302         << " received notification from unknown source.";
     209  }
    303210#endif
    304   if (publisher == static_cast<const Observable *>(&bondref)){
     211  if (publisher == static_cast<const Observable *>(bondowner)){
    305212    switch (notification->getChannelNo()) {
    306213    case BondObservable::BondRemoved:
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp

    ra9161d r7e2adc  
    7373   *
    7474   * We remove from all other Observables in a controlled manner.
    75    * However, we assume that either bond, leftobservable, or rightobservable
    76    * called subjectKilled(). Hence, we may still signOff() from all noifications
    77    * but not from the calling Observable.
    7875   *
    79    * removeLeftAtom(), removeRightAtom(), removeBond(), and removeChannels()
    80    * must have been called before (or one of the subjects has been killed).
     76   * removeBond(), and removeChannels() must have been called before (or one of
     77   * the subjects has been killed).
    8178   *
    8279   */
    8380  void removeMe();
    84   void removeLeftAtom();
    85   void removeRightAtom();
    8681  void removeChannels();
    8782
     
    10196  const atomId_t rightatomId;
    10297
     98  //!> contains ref to Observable of left atom
     99  const Observable * const leftowner;
     100  //!> contains ref to Observable of right atom
     101  const Observable * const rightowner;
    103102  //!> temporary variable used in cstor
    104   const atom * const leftatomref;
    105   //!> temporary variable used in cstor
    106   const atom * const rightatomref;
    107   //!> temporary variable used in cstor
    108   const bond &bondref;
     103  const Observable * const bondowner;
    109104
    110105  const enum SideOfBond BondSide;
Note: See TracChangeset for help on using the changeset viewer.