Changeset 7c7c4a


Ignore:
Timestamp:
Feb 12, 2016, 11:15:04 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:
2831b3
Parents:
e25448
git-author:
Frederik Heber <heber@…> (10/16/15 11:51:16)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:04)
Message:

FIX: All ObservedValue's of GLMoleculeObject_atom/bond/molecule wrapped into vector.

  • the idea is that a GLMoleculeObject may only remove itself _after_ each and every contained Observer has gotten the subjectKilled() signal from the Observables. Only then will destroying the Object and its members thereby not cause any signOff() which try to access Observables or their channels which are no longer present. This can be imagined as a graph where we have to start destroying object at the very bottom.
  • This is the avoid the following conflict: A superior object gets note of a molecule to be removed. It sends the visual representation a signal to remove itself, which causes it to use signOff(). On a parallel track (in another thread) we have the observed object calling subjectKilled() to inform any Observer about its immediate destruction. These two tracks collide. Now, we let first pass all subjectKilled() and when the last Observable has gotten its signal, we begin destroying the visual rep.
  • rerouted signal/slots accordingly.
Location:
src/UIElements
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Makefile.am

    re25448 r7c7c4a  
    225225        UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp \
    226226        UIElements/Views/Qt4/Qt3D/GLMoleculeObject_shape.hpp \
     227  UIElements/Views/Qt4/Qt3D/ObservedValue_wCallback.hpp \
    227228  UIElements/Views/Qt4/QDebugStream.hpp
    228229
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp

    re25448 r7c7c4a  
    5757#include "WorldTime.hpp"
    5858
     59#include "ObservedValue_wCallback.hpp"
     60
    5961using namespace boost::assign;
    6062
     
    8082  Observer(std::string("GLMoleculeObject_atom")+toString(_id)),
    8183  atomref(getAtom(_id)),
    82   AtomIndex(
    83       atomref,
    84       boost::bind(&GLMoleculeObject_atom::updateIndex, this),
    85       "AtomIndex_"+toString(_id),
    86       _id,
    87       AtomIndexChannels),
    88   AtomPosition(
    89       atomref,
    90       boost::bind(&GLMoleculeObject_atom::updatePosition, this),
    91       "AtomPosition_"+toString(_id),
    92       updatePosition(),
    93       AtomPositionChannels),
    94   AtomElement(
    95       atomref,
    96       boost::bind(&GLMoleculeObject_atom::updateElement, this),
    97       "AtomElement"+toString(_id),
    98       updateElement(),
    99       AtomElementChannels),
    100   AtomBonds(
    101       atomref,
    102       boost::bind(&GLMoleculeObject_atom::updateBonds, this),
    103       "AtomBonds_"+toString(_id),
    104       updateBonds(),
    105       AtomBondsChannels),
     84  ObservedValues(MAX_ObservedTypes),
     85  subjectKilledCount(0),
    10686  owner(NULL)
    10787{
     88  initObservedValues(_id);
     89
    10890  setObjectId(_id);
    10991  resetPosition();
     
    154136{
    155137  deactivateObserver();
     138  destroyObservedValues();
    156139}
    157140
    158141void GLMoleculeObject_atom::resetIndex()
    159142{
    160   const atomId_t newId = AtomIndex.get();
     143  const atomId_t newId = getAtomIndex();
    161144  const size_t oldId = objectId();
    162145  ASSERT( newId != oldId,
     
    170153void GLMoleculeObject_atom::resetPosition()
    171154{
    172   const Vector Position = AtomPosition.get();
     155  const Vector Position = getAtomPosition();
    173156  LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new position is "+toString(Position)+".");
    174157  setPosition(QVector3D(Position[0], Position[1], Position[2]));
     
    179162  size_t elementno = 0;
    180163  const element * const _type = World::getInstance().
    181       getPeriode()->FindElement(AtomElement.get());
     164      getPeriode()->FindElement(getAtomElement());
    182165  if (_type != NULL) {
    183166    elementno = _type->getAtomicNumber();
     
    205188void GLMoleculeObject_atom::resetBonds()
    206189{
    207   ListOfBonds_t ListOfBonds_new = AtomBonds.get();
     190  ListOfBonds_t ListOfBonds_new = getAtomBonds();
    208191  std::sort(ListOfBonds_new.begin(), ListOfBonds_new.end());
    209192  ListOfBonds_t BondsToAdd;
     
    220203      iter != BondsToAdd.end();
    221204      ++iter) {
    222     const GLMoleculeObject_bond::SideOfBond side = (iter->first == AtomIndex.get()) ?
     205    const GLMoleculeObject_bond::SideOfBond side = (iter->first == getAtomIndex()) ?
    223206        GLMoleculeObject_bond::left : GLMoleculeObject_bond::right;
    224207    emit BondsAdded(iter->first, iter->second, side);
     
    259242void GLMoleculeObject_atom::wasClicked()
    260243{
    261   LOG(4, "INFO: GLMoleculeObject_atom: atom " << AtomIndex.get() << " has been clicked");
    262   emit clicked(AtomIndex.get());
     244  LOG(4, "INFO: GLMoleculeObject_atom: atom " << getAtomIndex() << " has been clicked");
     245  emit clicked(getAtomIndex());
    263246}
    264247
     
    283266Vector GLMoleculeObject_atom::updatePosition() const
    284267{
    285   const atom * const _atom = getAtom(AtomIndex.get());
     268  const atom * const _atom = getAtom(getAtomIndex());
    286269  if (_atom != NULL) {
    287270    return _atom->getPosition();
     
    293276atomicNumber_t GLMoleculeObject_atom::updateElement() const
    294277{
    295   const atom * const _atom = getAtom(AtomIndex.get());
     278  const atom * const _atom = getAtom(getAtomIndex());
    296279  if (_atom != NULL) {
    297280    return _atom->getElementNo();
     
    304287{
    305288  ListOfBonds_t ListOfBonds;
    306   const atom * const _atom = getAtom(AtomIndex.get());
     289  const atom * const _atom = getAtom(getAtomIndex());
    307290  if (_atom != NULL) {
    308291    // make sure position is up-to-date
     
    315298          (*iter)->rightatom->getId()) );
    316299  } else {
    317     ELOG(2, "Atom with id "+toString(AtomIndex.get())+" is already gone.");
     300    ELOG(2, "Atom with id "+toString(getAtomIndex())+" is already gone.");
    318301  }
    319302  return ListOfBonds;
     
    328311{
    329312  deactivateObserver();
     313
     314  countsubjectKilled();
    330315}
    331316
     
    357342    ASSERT(0, "GLMoleculeObject_atom::recieveNotification() - received notification from unexpected source.");
    358343}
     344
     345void GLMoleculeObject_atom::countsubjectKilled()
     346{
     347  ++subjectKilledCount;
     348
     349  if (subjectKilledCount > ObservedValues.size())
     350    emit InstanceRemoved(getAtomIndex());
     351}
     352
     353void GLMoleculeObject_atom::initObservedValues(const atomId_t _id)
     354{
     355  // fill ObservedValues
     356  boost::function<void()> subjectKilled =
     357      boost::bind(&GLMoleculeObject_atom::countsubjectKilled, this);
     358  ObservedValues[AtomIndex] = new ObservedValue_wCallback<atomId_t>(
     359      atomref,
     360      boost::bind(&GLMoleculeObject_atom::updateIndex, this),
     361      "AtomIndex_"+toString(_id),
     362      _id,
     363      AtomIndexChannels,
     364      subjectKilled);
     365  ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector>(
     366      atomref,
     367      boost::bind(&GLMoleculeObject_atom::updatePosition, this),
     368      "AtomPosition_"+toString(_id),
     369      updatePosition(),
     370      AtomPositionChannels,
     371      subjectKilled);
     372  ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t>(
     373      atomref,
     374      boost::bind(&GLMoleculeObject_atom::updateElement, this),
     375      "AtomElement"+toString(_id),
     376      updateElement(),
     377      AtomElementChannels,
     378      subjectKilled);
     379  ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t>(
     380      atomref,
     381      boost::bind(&GLMoleculeObject_atom::updateBonds, this),
     382      "AtomBonds_"+toString(_id),
     383      updateBonds(),
     384      AtomBondsChannels,
     385      subjectKilled);
     386}
     387
     388void GLMoleculeObject_atom::destroyObservedValues()
     389{
     390  delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex]);
     391  delete boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[AtomPosition]);
     392  delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[AtomElement]);
     393  delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t> *>(ObservedValues[AtomBonds]);
     394  ObservedValues.clear();
     395}
     396
     397atomId_t GLMoleculeObject_atom::getAtomIndex() const
     398{
     399  return boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex])->get();
     400}
     401
     402Vector GLMoleculeObject_atom::getAtomPosition() const
     403{
     404  return boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[AtomPosition])->get();
     405}
     406
     407atomicNumber_t GLMoleculeObject_atom::getAtomElement() const
     408{
     409  return boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[AtomElement])->get();
     410}
     411
     412GLMoleculeObject_atom::ListOfBonds_t GLMoleculeObject_atom::getAtomBonds() const
     413{
     414  return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t> *>(ObservedValues[AtomBonds])->get();
     415}
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp

    re25448 r7c7c4a  
    1515
    1616#include "GLMoleculeObject.hpp"
     17
     18#include <vector>
     19#include <boost/any.hpp>
    1720
    1821#include "CodePatterns/ObservedValue.hpp"
     
    6164  void elementChanged();
    6265  void bondsChanged();
     66  void InstanceRemoved(const atomId_t);
    6367
    6468private:
     
    8892  atom * const atomref;
    8993
    90   //!> cached value of the atom's id
    91   ObservedValue<atomId_t> AtomIndex;
    92   //!> cached value of the atom's position
    93   ObservedValue<Vector> AtomPosition;
    94   //!> cached value of the atom's element
    95   ObservedValue<atomicNumber_t> AtomElement;
    96   //!> cached value of the atom's id
    97   ObservedValue<ListOfBonds_t> AtomBonds;
     94private:
     95  /** Observed Values **/
     96
     97  //!> enumeration of observed values to match with entries in ObservedValues
     98  enum ObservedTypes {
     99    //!> contains the current atom index
     100    AtomIndex,
     101    //!> contains the current atom position
     102    AtomPosition,
     103    //!> contains the current atom element
     104    AtomElement,
     105    //!> contains the current set of bonds atoms fort the atom
     106    AtomBonds,
     107    //!> gives the size of the enumeration
     108    MAX_ObservedTypes
     109  };
     110
     111  //!> vector with all observed values
     112  std::vector<boost::any> ObservedValues;
     113
     114  /** Initializes all \a ObservedValues entries.
     115   *
     116   * \param _id atom id
     117   */
     118  void initObservedValues(const atomId_t _id);
     119
     120  /** Destroys all \a ObservedValues entries.
     121   *
     122   */
     123  void destroyObservedValues();
     124
     125  /** Getter to atom index contained in \a ObservedValues.
     126   *
     127   * \return atom's index
     128   */
     129  atomId_t getAtomIndex() const;
     130
     131  /** Getter to atom position contained in \a ObservedValues.
     132   *
     133   * \return atom's position
     134   */
     135  Vector getAtomPosition() const;
     136
     137  /** Getter to atom element contained in \a ObservedValues.
     138   *
     139   * \return atom's elemnt
     140   */
     141  atomicNumber_t getAtomElement() const;
     142
     143  /** Getter to atom bonds contained in \a ObservedValues.
     144   *
     145   * \return atom's bonds
     146   */
     147  ListOfBonds_t getAtomBonds() const;
     148
     149  /** Counts how many ObservedValues got subjectKilled.
     150   *
     151   * This is used to give InstanceRemoved() signal only when each and every
     152   * ObservedValue (and the instance itself) has been subjectKilled by the
     153   * monitored Observable. Only then can we safely remove the instance.
     154   *
     155   */
     156  void countsubjectKilled();
     157
     158  //!> counts how many ObservedValues have already been subjectKilled()
     159  mutable size_t subjectKilledCount;
     160
     161private:
    98162
    99163  //!> list of channels when index needs to update
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp

    re25448 r7c7c4a  
    5757#include "World.hpp"
    5858
     59#include "ObservedValue_wCallback.hpp"
     60
    5961
    6062// static entities
     
    8284  bondowner(getAtom(leftatomId)->getBond(getAtom(rightatomId)).get()),
    8385  BondSide(side),
    84   leftPosition(
    85       leftowner,
    86       boost::bind(&GLMoleculeObject_bond::updateLeftPosition, this),
    87       "BondleftPosition_"+toString(leftatomId),
    88       updateLeftPosition(),
    89       BondPositionChannels),
    90   rightPosition(
    91       rightowner,
    92       boost::bind(&GLMoleculeObject_bond::updateRightPosition, this),
    93       "BondrightPosition_"+toString(rightatomId),
    94       updateRightPosition(),
    95       BondPositionChannels),
    96   leftElement(
    97       leftowner,
    98       boost::bind(&GLMoleculeObject_bond::updateLeftElement, this),
    99       "BondleftElement"+toString(leftatomId),
    100       updateLeftElement(),
    101       BondElementChannels),
    102   rightElement(
    103       rightowner,
    104       boost::bind(&GLMoleculeObject_bond::updateRightElement, this),
    105       "BondrightElement"+toString(rightatomId),
    106       updateRightElement(),
    107       BondElementChannels),
    108   Degree(
    109       bondowner,
    110       boost::bind(&GLMoleculeObject_bond::updateDegree, this),
    111       "BondDegree"+toString(leftatomId)+"_"+toString(rightatomId),
    112       updateDegree(),
    113       BondDegreeChannels),
     86  ObservedValues(MAX_ObservedTypes),
     87  subjectKilledCount(0),
    11488  leftobservable_enabled(false),
    11589  rightobservable_enabled(false)
    11690{
     91  initObservedValues();
     92
    11793  // sign on as observer (obtain non-const instance before)
    11894  bondowner->signOn(this, BondObservable::BondRemoved);
     
    141117  // signOff() if not already done
    142118  removeChannels();
     119  destroyObservedValues();
    143120}
    144121
     
    170147}
    171148
    172 void GLMoleculeObject_bond::removeMe()
    173 {
    174   // sign off
    175   emit BondRemoved(leftatomId, rightatomId);
    176 }
    177 
    178149void GLMoleculeObject_bond::update(Observable *publisher)
    179150{
     
    185156  // we signOff from all other sources
    186157  removeChannels();
    187   // then indicate to remove us
    188   removeMe();
     158  // check whether we should be removed
     159  countsubjectKilled();
    189160}
    190161
     
    278249void GLMoleculeObject_bond::resetElement()
    279250{
    280   size_t elementno = rightElement.get();
     251  size_t elementno = getrightElement();
    281252  QGLMaterial *elementmaterial = getMaterial(elementno);
    282253  setMaterial(elementmaterial);
     
    285256void GLMoleculeObject_bond::resetWidth()
    286257{
    287   const double factor = 1.0f+.5f*(Degree.get()-1);
     258  const double factor = 1.0f+.5f*(getDegree()-1);
    288259  LOG(2, "DEBUG: GLMoleculeObject_bond::resetWidth() - setting bond's width to " << factor << ".");
    289260  setScaleX(factor);
     
    295266void GLMoleculeObject_bond::resetPosition()
    296267{
    297   Vector Position = leftPosition.get();
    298   Vector OtherPosition = rightPosition.get();
     268  Vector Position = getleftPosition();
     269  Vector OtherPosition = getrightPosition();
    299270  const double distance =
    300271      Position.distance(OtherPosition)/2.;
     
    346317  return _atom;
    347318}
     319
     320void GLMoleculeObject_bond::countsubjectKilled()
     321{
     322  ++subjectKilledCount;
     323
     324  if (subjectKilledCount > ObservedValues.size())
     325    emit BondRemoved(leftatomId, rightatomId);
     326}
     327
     328void GLMoleculeObject_bond::initObservedValues()
     329{
     330  // fill ObservedValues
     331  boost::function<void()> subjectKilled =
     332      boost::bind(&GLMoleculeObject_bond::countsubjectKilled, this);
     333  ObservedValues[leftPosition] = new ObservedValue_wCallback<Vector>(
     334      leftowner,
     335      boost::bind(&GLMoleculeObject_bond::updateLeftPosition, this),
     336      "BondleftPosition_"+toString(leftatomId),
     337      updateLeftPosition(),
     338      BondPositionChannels,
     339      subjectKilled);
     340  ObservedValues[rightPosition] = new ObservedValue_wCallback<Vector>(
     341      rightowner,
     342      boost::bind(&GLMoleculeObject_bond::updateRightPosition, this),
     343      "BondrightPosition_"+toString(rightatomId),
     344      updateRightPosition(),
     345      BondPositionChannels,
     346      subjectKilled);
     347  ObservedValues[leftElement] = new ObservedValue_wCallback<atomicNumber_t>(
     348      leftowner,
     349      boost::bind(&GLMoleculeObject_bond::updateLeftElement, this),
     350      "BondleftElement"+toString(leftatomId),
     351      updateLeftElement(),
     352      BondElementChannels,
     353      subjectKilled);
     354  ObservedValues[rightElement] = new ObservedValue_wCallback<atomicNumber_t>(
     355      rightowner,
     356      boost::bind(&GLMoleculeObject_bond::updateRightElement, this),
     357      "BondrightElement"+toString(rightatomId),
     358      updateRightElement(),
     359      BondElementChannels,
     360      subjectKilled);
     361  ObservedValues[Degree] = new ObservedValue_wCallback<int>(
     362      bondowner,
     363      boost::bind(&GLMoleculeObject_bond::updateDegree, this),
     364      "BondDegree"+toString(leftatomId)+"_"+toString(rightatomId),
     365      updateDegree(),
     366      BondDegreeChannels,
     367      subjectKilled);
     368}
     369
     370void GLMoleculeObject_bond::destroyObservedValues()
     371{
     372  delete boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[leftPosition]);
     373  delete boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[rightPosition]);
     374  delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[leftElement]);
     375  delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[rightElement]);
     376  delete boost::any_cast<ObservedValue_wCallback<int> *>(ObservedValues[Degree]);
     377  ObservedValues.clear();
     378}
     379
     380Vector GLMoleculeObject_bond::getleftPosition() const
     381{
     382  return boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[leftPosition])->get();
     383}
     384
     385Vector GLMoleculeObject_bond::getrightPosition() const
     386{
     387  return boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[rightPosition])->get();
     388}
     389
     390atomicNumber_t GLMoleculeObject_bond::getleftElement() const
     391{
     392  return boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[leftElement])->get();
     393}
     394
     395atomicNumber_t GLMoleculeObject_bond::getrightElement() const
     396{
     397  return boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[rightElement])->get();
     398}
     399
     400int GLMoleculeObject_bond::getDegree() const
     401{
     402  return boost::any_cast<ObservedValue_wCallback<int> *>(ObservedValues[Degree])->get();
     403}
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp

    re25448 r7c7c4a  
    1515
    1616#include "GLMoleculeObject.hpp"
     17
     18#include <vector>
     19#include <boost/any.hpp>
    1720
    1821#include "CodePatterns/Observer/Observer.hpp"
     
    7073
    7174private:
    72   /** This must be called from subjectKilled() only.
    73    *
    74    * We remove from all other Observables in a controlled manner.
    75    *
    76    * removeBond(), and removeChannels() must have been called before (or one of
    77    * the subjects has been killed).
    78    *
    79    */
    80   void removeMe();
    8175  void removeChannels();
    8276
     
    10599  const enum SideOfBond BondSide;
    106100
    107   ObservedValue<Vector> leftPosition;
    108   ObservedValue<Vector> rightPosition;
    109   ObservedValue<atomicNumber_t> leftElement;
    110   ObservedValue<atomicNumber_t> rightElement;
    111   ObservedValue<int> Degree;
     101
     102private:
     103  /** Observed Values **/
     104
     105  //!> enumeration of observed values to match with entries in ObservedValues
     106  enum ObservedTypes {
     107    //!> contains the position of the left atom
     108    leftPosition,
     109    //!> contains the position of the right atom
     110    rightPosition,
     111    //!> contains the element of the left atom
     112    leftElement,
     113    //!> contains the element of the right atom
     114    rightElement,
     115    //!> contains the degree of the bond
     116    Degree,
     117    //!> gives the size of the enumeration
     118    MAX_ObservedTypes
     119  };
     120
     121  //!> vector with all observed values
     122  std::vector<boost::any> ObservedValues;
     123
     124  /** Initializes all \a ObservedValues entries.
     125   *
     126   */
     127  void initObservedValues();
     128
     129  /** Destroys all \a ObservedValues entries.
     130   *
     131   */
     132  void destroyObservedValues();
     133
     134  /** Getter to left atom's position contained in \a ObservedValues.
     135   *
     136   * \return left atom's position
     137   */
     138  Vector getleftPosition() const;
     139
     140  /** Getter to right atom's position contained in \a ObservedValues.
     141   *
     142   * \return right atom's position
     143   */
     144  Vector getrightPosition() const;
     145
     146  /** Getter to left atom's element contained in \a ObservedValues.
     147   *
     148   * \return left atom's element
     149   */
     150  atomicNumber_t getleftElement() const;
     151
     152  /** Getter to rightatom's element contained in \a ObservedValues.
     153   *
     154   * \return right atom's element
     155   */
     156  atomicNumber_t getrightElement() const;
     157
     158  /** Getter to bond's degree contained in \a ObservedValues.
     159   *
     160   * \return bond's degree
     161   */
     162  int getDegree() const;
     163
     164  /** Counts how many ObservedValues got subjectKilled.
     165   *
     166   * This is used to give InstanceRemoved() signal only when each and every
     167   * ObservedValue (and the instance itself) has been subjectKilled by the
     168   * monitored Observable. Only then can we safely remove the instance.
     169   *
     170   */
     171  void countsubjectKilled();
     172
     173  //!> counts how many ObservedValues have already been subjectKilled()
     174  mutable size_t subjectKilledCount;
     175
     176private:
    112177
    113178  //!> indicate whether we are signed in to leftobservable
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp

    re25448 r7c7c4a  
    6363#include "Atom/TesselPoint.hpp"
    6464#include "World.hpp"
     65
     66#include "ObservedValue_wCallback.hpp"
    6567
    6668using namespace boost::assign;
     
    122124      boost::bind(&GLMoleculeObject_molecule::updateAtoms, this)
    123125      ),
    124   MolIndex(
    125       molref,
    126       MolIndexUpdater,
    127       "MoleculeIndex_"+toString(_molid),
    128       _molid,
    129       IndexChannels),
    130   MolName(
    131       molref,
    132       MolNameUpdater,
    133       "MoleculeName_"+toString(_molid),
    134       updateName(),
    135       NameChannels),
     126  ObservedValues(MAX_ObservedTypes),
     127  subjectKilledCount(0),
    136128  TesselationHull(
    137129      molref,
     
    139131      "MoleculeTesselationHull_"+toString(_molid),
    140132      HullChannels),
    141   BoundingBox(
    142       molref,
    143       BoundingBoxUpdater,
    144       "MoleculeBoundingBox_"+toString(_molid),
    145       initBoundingBox(),
    146       BoundingBoxChannels),
    147   PresentAtoms(
    148       molref,
    149       PresentAtomsUpdater,
    150       "MoleculeAtoms_"+toString(_molid),
    151       updateAtoms(),
    152       AtomsChannels),
    153133  hoverAtomId(-1)
    154134{
     135  initObservedValues(_molid);
     136
    155137  setObjectId(_molid);
    156138  setMaterial(getMaterial(1));
     
    199181      boost::bind(&GLMoleculeObject_molecule::updateAtoms, this)
    200182      ),
    201   MolIndex(
    202       molref,
    203       MolIndexUpdater,
    204       "MoleculeIndex_"+toString(_molid),
    205       _molid,
    206       IndexChannels),
    207   MolName(
    208       molref,
    209       MolNameUpdater,
    210       "MoleculeName_"+toString(_molid),
    211       updateName(),
    212       NameChannels),
     183  ObservedValues(MAX_ObservedTypes),
     184  subjectKilledCount(0),
    213185  TesselationHull(
    214186      molref,
     
    216188      "MoleculeTesselationHull_"+toString(_molid),
    217189      HullChannels),
    218   BoundingBox(
    219       molref,
    220       BoundingBoxUpdater,
    221       "MoleculeBoundingBox_"+toString(_molid),
    222       initBoundingBox(),
    223       BoundingBoxChannels),
    224   PresentAtoms(
    225       molref,
    226       PresentAtomsUpdater,
    227       "MoleculeAtoms_"+toString(_molid),
    228       atoms_t(),
    229       AtomsChannels),
    230190  hoverAtomId(-1)
    231191{
     192  initObservedValues(_molid);
     193
    232194  setObjectId(_molid);
    233195  setMaterial(getMaterial(1));
     
    254216{
    255217  deactivateObserver();
     218  destroyObservedValues();
    256219}
    257220
     
    270233{
    271234  // sign on as observer (obtain non-const instance before)
    272   const molecule * const _molecule = getMolecule(MolIndex.get());
     235  const molecule * const _molecule = getMolecule(getMolIndex());
    273236  if (_molecule != NULL) {
    274237    owner = static_cast<const Observable *>(_molecule);
     
    278241    owner->signOn(this, molecule::IndexChanged);
    279242  } else {
    280     ELOG(1, "GLMoleculeObject_molecule() - added null object for not present mol id " << MolIndex.get());
     243    ELOG(1, "GLMoleculeObject_molecule() - added null object for not present mol id " << getMolIndex());
    281244  }
    282245
     
    332295  QGeometryData geo;
    333296
    334   const molecule * const molref = getMolecule(MolIndex.get());
     297  const molecule * const molref = getMolecule(getMolIndex());
    335298  if (molref == NULL) {
    336     ELOG(1, "Could not createMoleculeMesh, molecule with id " << MolIndex.get() << " already gone.");
     299    ELOG(1, "Could not createMoleculeMesh, molecule with id " << getMolIndex() << " already gone.");
    337300    return geo;
    338301  }
     
    353316
    354317  // we need at least three points for tesselation
    355   if (PresentAtoms.get().size() >= 3) {
     318  if (getPresentAtoms().size() >= 3) {
    356319    // Tesselate the points.
    357320    Tesselation T;
    358     PointCloudAdaptor<molecule> cloud(const_cast<molecule *>(molref), MolName.get());
     321    PointCloudAdaptor<molecule> cloud(const_cast<molecule *>(molref), getMolName());
    359322    T(cloud, minradius);
    360323
     
    413376molecule::BoundingBoxInfo GLMoleculeObject_molecule::updateBoundingBox() const
    414377{
    415   return BoundingBox.get();
     378  return getBoundingBox();
    416379}
    417380
    418381GLMoleculeObject_molecule::atoms_t GLMoleculeObject_molecule::updateAtoms()
    419382{
    420   const molecule * const mol = getMolecule(MolIndex.get());
     383  const molecule * const mol = getMolecule(getMolIndex());
    421384  if (mol != NULL) {
    422385    const atomId_t id = mol->lastChangedAtomId();
     
    436399std::string GLMoleculeObject_molecule::updateName() const
    437400{
    438   const molecule * const mol = getMolecule(MolIndex.get());
     401  const molecule * const mol = getMolecule(getMolIndex());
    439402  return mol->getName();
    440403}
     
    448411void GLMoleculeObject_molecule::resetBoundingBox()
    449412{
    450   molecule::BoundingBoxInfo info = BoundingBox.get();
     413  molecule::BoundingBoxInfo info = getBoundingBox();
    451414  setPosition(QVector3D(info.position[0], info.position[1], info.position[2]));
    452415  setScale(info.radius + 0.3); // getBoundingSphere() only sees atoms as points, so make the box a bit bigger
     
    455418void GLMoleculeObject_molecule::resetAtoms()
    456419{
    457   const atoms_t atoms = PresentAtoms.get();
     420  const atoms_t atoms = getPresentAtoms();
    458421  std::vector<atomId_t> InsertedAtoms;
    459422  std::vector<atomId_t> RemovedAtoms;
     
    479442void GLMoleculeObject_molecule::resetIndex()
    480443{
    481   const atomId_t newId = MolIndex.get();
     444  const atomId_t newId = getMolIndex();
    482445  const size_t oldId = objectId();
    483446  ASSERT( newId != oldId,
     
    544507  // remove owner: no more signOff needed
    545508  owner = NULL;
     509
     510  countsubjectKilled();
    546511}
    547512
    548513void GLMoleculeObject_molecule::recieveNotification(Observable *publisher, Notification_ptr notification)
    549514{
    550   const molecule * const _molecule = getMolecule(MolIndex.get());
     515  const molecule * const _molecule = getMolecule(getMolIndex());
    551516  // when molecule is NULL we will soon get destroyed anyway
    552517  if (_molecule == NULL)
     
    556521#ifdef LOG_OBSERVER
    557522    observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this))
    558           << " received notification from molecule " << MolIndex.get() << " for channel "
     523          << " received notification from molecule " << getMolIndex() << " for channel "
    559524          << notification->getChannelNo() << ".";
    560525#endif
     
    577542        observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed.";
    578543  #endif
    579         emit AtomRemoved(_id);
    580544        emit TesselationHullChanged();
    581545        emit BoundingBoxChanged();
     
    719683  connect (atomObject, SIGNAL(BondsRemoved(const atomId_t, const atomId_t)), this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
    720684  connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, const atomId_t, const atomId_t)), this, SLOT(changeAtomId(GLMoleculeObject_atom*, const atomId_t, const atomId_t)));
     685  connect (atomObject, SIGNAL(InstanceRemoved(const atomId_t)), this, SIGNAL(AtomRemoved(const atomId_t)));
    721686
    722687  if (m_objectId  == -1)
     
    773738    if (moleculeObject == this){
    774739      // Propagate signal.
    775       emit hoverChanged(MolIndex.get(), 0);
     740      emit hoverChanged(getMolIndex(), 0);
    776741    }
    777742  }
     
    871836void GLMoleculeObject_molecule::wasClicked()
    872837{
    873   LOG(4, "INFO: GLMoleculeObject_molecule: atom " << MolIndex.get() << " has been clicked");
    874   emit moleculeClicked(MolIndex.get());
     838  LOG(4, "INFO: GLMoleculeObject_molecule: atom " << getMolIndex() << " has been clicked");
     839  emit moleculeClicked(getMolIndex());
    875840}
    876841
     
    906871  return mol;
    907872}
     873
     874void GLMoleculeObject_molecule::countsubjectKilled()
     875{
     876  ++subjectKilledCount;
     877
     878  if (subjectKilledCount > ObservedValues.size())
     879    emit InstanceRemoved(getMolIndex());
     880}
     881
     882void GLMoleculeObject_molecule::initObservedValues(const moleculeId_t _molid)
     883{
     884  // fill ObservedValues
     885  boost::function<void()> subjectKilled =
     886      boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this);
     887  ObservedValues[MolIndex] = new ObservedValue_wCallback<moleculeId_t>(
     888      molref,
     889      MolIndexUpdater,
     890      "MoleculeIndex_"+toString(_molid),
     891      _molid,
     892      IndexChannels,
     893      subjectKilled);
     894  ObservedValues[MolName] = new ObservedValue_wCallback<std::string>(
     895      molref,
     896      MolNameUpdater,
     897      "MoleculeName_"+toString(_molid),
     898      updateName(),
     899      NameChannels,
     900      subjectKilled);
     901  ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo>(
     902      molref,
     903      BoundingBoxUpdater,
     904      "MoleculeBoundingBox_"+toString(_molid),
     905      initBoundingBox(),
     906      BoundingBoxChannels,
     907      subjectKilled);
     908  ObservedValues[PresentAtoms] = new ObservedValue_wCallback<atoms_t>(
     909      molref,
     910      PresentAtomsUpdater,
     911      "MoleculeAtoms_"+toString(_molid),
     912      updateAtoms(),
     913      AtomsChannels,
     914      subjectKilled);
     915}
     916
     917void GLMoleculeObject_molecule::destroyObservedValues()
     918{
     919  delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex]);
     920  delete boost::any_cast<ObservedValue_wCallback<std::string> *>(ObservedValues[MolName]);
     921  delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo> *>(ObservedValues[BoundingBox]);
     922  delete boost::any_cast<ObservedValue_wCallback<atoms_t> *>(ObservedValues[PresentAtoms]);
     923  ObservedValues.clear();
     924}
     925
     926moleculeId_t GLMoleculeObject_molecule::getMolIndex() const
     927{
     928  return boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->get();
     929}
     930
     931std::string GLMoleculeObject_molecule::getMolName() const
     932{
     933  return boost::any_cast<ObservedValue_wCallback<std::string> *>(ObservedValues[MolName])->get();
     934}
     935
     936molecule::BoundingBoxInfo GLMoleculeObject_molecule::getBoundingBox() const
     937{
     938  return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo> *>(ObservedValues[BoundingBox])->get();
     939}
     940
     941GLMoleculeObject_molecule::atoms_t GLMoleculeObject_molecule::getPresentAtoms() const
     942{
     943  return boost::any_cast<ObservedValue_wCallback<atoms_t> *>(ObservedValues[PresentAtoms])->get();
     944}
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp

    re25448 r7c7c4a  
    1717
    1818#include <Qt3D/qgeometrydata.h>
     19
     20#include <vector>
     21#include <boost/any.hpp>
    1922
    2023#include "CodePatterns/Cacheable.hpp"
     
    6871  void AtomRemoved(const atomId_t _id);
    6972  void IdChanged();
     73  void InstanceRemoved(const moleculeId_t);
    7074
    7175private slots:
     
    141145  boost::function<atoms_t ()> PresentAtomsUpdater;
    142146
    143   //!> contains the current molecule index
    144   ObservedValue<moleculeId_t> MolIndex;
    145   //!> contains the current molecule name
    146   ObservedValue<std::string> MolName;
     147private:
     148  /** Observed Values **/
     149
     150  //!> enumeration of observed values to match with entries in ObservedValues
     151  enum ObservedTypes {
     152    //!> contains the current molecule index
     153    MolIndex,
     154    //!> contains the current molecule name
     155    MolName,
     156    //!> contains newest version of the bounding box on request
     157    BoundingBox,
     158    //!> contains the current live set of atoms for the molecule
     159    PresentAtoms,
     160    //!> gives the size of the enumeration
     161    MAX_ObservedTypes
     162  };
     163
     164  //!> vector with all observed values
     165  std::vector<boost::any> ObservedValues;
     166
     167  /** Initializes all \a ObservedValues entries.
     168   *
     169   * \param _moid molecule id
     170   */
     171  void initObservedValues(const moleculeId_t _molid);
     172
     173  /** Destroys all \a ObservedValues entries.
     174   *
     175   */
     176  void destroyObservedValues();
     177
     178  /** Getter to molecule index contained in \a ObservedValues.
     179   *
     180   * \return molecule's index
     181   */
     182  moleculeId_t getMolIndex() const;
     183
     184  /** Getter to molecule name contained in \a ObservedValues.
     185   *
     186   * \return molecule's name
     187   */
     188  std::string getMolName() const;
     189
     190  /** Getter to molecule's bounding box contained in \a ObservedValues.
     191   *
     192   * \return molecule's bounding box
     193   */
     194  molecule::BoundingBoxInfo getBoundingBox() const;
     195
     196  /** Getter to contained atoms contained in \a ObservedValues.
     197   *
     198   * \return molecule's contained atoms
     199   */
     200  atoms_t getPresentAtoms() const;
     201
     202  /** Counts how many ObservedValues got subjectKilled.
     203   *
     204   * This is used to give InstanceRemoved() signal only when each and every
     205   * ObservedValue (and the instance itself) has been subjectKilled by the
     206   * monitored Observable. Only then can we safely remove the instance.
     207   *
     208   */
     209  void countsubjectKilled();
     210
     211  //!> counts how many ObservedValues have already been subjectKilled()
     212  mutable size_t subjectKilledCount;
     213
    147214  //!> contains current version of the tesselation hull on request
    148215  Cacheable<QGeometryData> TesselationHull;
    149   //!> contains newest version of the bounding box on request
    150   ObservedValue<molecule::BoundingBoxInfo> BoundingBox;
    151   //!> contains the current live set of atoms for the molecule
    152   ObservedValue<atoms_t> PresentAtoms;
    153 
     216
     217private:
    154218  //!> contains the set of atoms displayed
    155219  atoms_t DisplayedAtoms;
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    re25448 r7c7c4a  
    9191  }
    9292  connect(this, SIGNAL(moleculePreparedInserted(const moleculeId_t)), this, SLOT(moleculeInserted(const moleculeId_t)));
    93   connect(this, SIGNAL(moleculePreparedRemoved(const moleculeId_t)), this, SLOT(moleculeRemoved(const moleculeId_t)));
    9493
    9594//  connect(this, SIGNAL(updated()), this, SLOT(update()));
     
    116115//      moliter != molecules.end();
    117116//      moliter++) {
     117//    boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    118118//    // check whether molecule already exists
    119119//    const moleculeId_t molid = (*moliter)->getId();
     
    123123//  }
    124124//
     125//  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    125126//  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.begin();
    126127//  for (;iter != MoleculesinSceneMap.end();) {
     
    182183void GLWorldScene::atomInserted(const moleculeId_t _molid, const atomId_t _atomid)
    183184{
     185  boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
     186
    184187  LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_atomid)+".");
    185 
    186   boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    187188
    188189  // check of molecule is already present
     
    268269
    269270  // add new object
     271  LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << _id);
    270272  GLMoleculeObject_molecule *molObject =
    271273      new GLMoleculeObject_molecule(GLMoleculeObject::meshEmpty, this, _id);
     
    344346  connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));
    345347  connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
    346   connect (molObject, SIGNAL(indexChanged(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t)), this, SLOT(changeMoleculeId(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t)));
     348  connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));
     349  connect (molObject, SIGNAL(InstanceRemoved(const moleculeId_t)), this, SLOT(moleculeRemoved(const moleculeId_t)));
    347350
    348351  emit changed();
     
    350353}
    351354
    352 /** Prepares removing a molecule from the scene.
    353  *
    354  * \sa moleculePrepareInserted()
     355/** Removes a molecule from the scene.
     356 *
     357 * * \sa moleculePrepareRemoved()
    355358 *
    356359 * @param _id id of molecule to remove
    357360 */
    358 void GLWorldScene::moleculePrepareRemoved(const moleculeId_t _id)
     361void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
    359362{
    360363  LOG(3, "INFO: GLWorldScene: Received signal moleculePrepareRemoved for molecule "+toString(_id)+".");
     
    363366
    364367  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
    365   if ( iter == MoleculesinSceneMap.end())
     368  if ( iter == MoleculesinSceneMap.end()) {
    366369    RemovalMolecules.insert(_id);
    367 
    368   emit moleculePreparedRemoved(_id);
    369 }
    370 
    371 /** Removes a molecule from the scene.
    372  *
    373  * * \sa moleculePrepareRemoved()
    374  *
    375  * @param _id id of molecule to remove
    376  */
    377 void GLWorldScene::moleculeRemoved(const moleculeId_t _id)
    378 {
    379   boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    380 
    381   MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
    382   GLMoleculeObject_molecule *molObject = iter->second;
    383   molObject->disconnect();
    384   MoleculesinSceneMap.erase(iter);
    385   delete molObject;
     370  } else {
     371    LOG(1, "DEBUG: Removing GLMoleculeObject_molecule to id " << _id);
     372    GLMoleculeObject_molecule *molObject = iter->second;
     373    molObject->disconnect();
     374    MoleculesinSceneMap.erase(iter);
     375    delete molObject;
     376  }
    386377
    387378  // remove any possible state changes left
     
    397388void GLWorldScene::moleculesVisibilityChanged(const moleculeId_t _id, bool _visible)
    398389{
     390  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    399391  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
    400392  ASSERT( iter != MoleculesinSceneMap.end(),
     
    506498
    507499  {
     500    boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    508501    // Remove from map.
    509502    MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(oldId);
     
    525518
    526519  {
     520    boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);
    527521    // Remove and re-insert from map if present.
    528522    MoleculeMissedStateMap_t::iterator iter = MoleculeMissedStateMap.find(oldId);
     
    537531void GLWorldScene::AtomSelected(const moleculeId_t _molid, const atomId_t _id)
    538532{
     533  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    539534  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
    540535  if (iter != MoleculesinSceneMap.end())
     
    550545void GLWorldScene::AtomUnselected(const moleculeId_t _molid, const atomId_t _id)
    551546{
     547  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    552548  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
    553549  if (iter != MoleculesinSceneMap.end())
     
    563559void GLWorldScene::MoleculeSelected(const moleculeId_t _molid)
    564560{
    565   MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
     561  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
     562MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
    566563  if (iter != MoleculesinSceneMap.end())
    567564    QMetaObject::invokeMethod(iter->second,        // pointer to a QObject
     
    575572void GLWorldScene::MoleculeUnselected(const moleculeId_t _molid)
    576573{
     574  boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);
    577575  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molid);
    578576  if (iter != MoleculesinSceneMap.end())
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    re25448 r7c7c4a  
    8383  void hoverChanged(const moleculeId_t, int);
    8484  void moleculePreparedInserted(const moleculeId_t _id);
    85   void moleculePreparedRemoved(const moleculeId_t _id);
    8685
    8786private slots:
    8887  void atomClicked(atomId_t no);
    8988  void moleculeClicked(moleculeId_t no);
    90   void moleculePrepareRemoved(const moleculeId_t _id);
    9189  void moleculePrepareInserted(const moleculeId_t _id);
    9290  void moleculeRemoved(const moleculeId_t _id);
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp

    re25448 r7c7c4a  
    9393  connect(this, SIGNAL(atomInserted(const moleculeId_t, const atomId_t)), worldscene, SLOT(atomInserted(const moleculeId_t, const atomId_t)), Qt::DirectConnection);
    9494  connect(this, SIGNAL(moleculeInserted(const moleculeId_t)), worldscene, SLOT(moleculePrepareInserted(const moleculeId_t)), Qt::DirectConnection);
    95   connect(this, SIGNAL(moleculeRemoved(const moleculeId_t)), worldscene, SLOT(moleculePrepareRemoved(const moleculeId_t)), Qt::DirectConnection);
    9695  //connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
    9796  connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
     
    370369
    371370  if (mol != NULL) {
    372 
    373     // sign off
    374     signOffFromMolecule(mol);
     371    ObservedMolecules.erase(mol);
     372//
     373//    // sign off
     374//    signOffFromMolecule(mol);
    375375
    376376    // emit removed signal
Note: See TracChangeset for help on using the changeset viewer.