Changeset 25aa214


Ignore:
Timestamp:
Dec 19, 2025, 11:29:38 PM (9 days ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.1, stable
Children:
98ad30
Parents:
d2be22
git-author:
Frederik Heber <frederik.heber@…> (11/16/25 11:19:01)
git-committer:
Frederik Heber <frederik.heber@…> (12/19/25 23:29:38)
Message:

FIX: fragmentation hydrogens do not trigger AtomInserted.

  • we had already switched off position and element changes. However, the fragmentation hydrogens could still be briefly seen on creation because the AtomInserted notification is still triggered. The World::createAtom allows now to suppress the notifcation. The switch options are put into an enum to make them very verbose in the code. This should really only be used by the HydrogenPool.
Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Filling/unittests/IsVoidNode_FillPredicateUnitTest.cpp

    rd2be22 r25aa214  
    8080  // create some atoms as "neighbours"
    8181  atoms.resize((size_t)5, NULL);
    82   std::generate_n(atoms.begin(), (size_t)5, boost::bind(&World::createAtom, World::getPointer()) );
     82  std::generate_n(atoms.begin(), (size_t)5, boost::bind(
     83    static_cast<atom* (World::*)(World::CreateAtomNotificationType)>(&World::createAtom),
     84    World::getPointer(),
     85    World::CreateAtomNotificationType::NOTIFY_ON_CREATE_ATOM)
     86  );
    8387
    8488  // position them
  • src/Filling/unittests/Ops_FillPredicateUnitTest.cpp

    rd2be22 r25aa214  
    7979  // create some atoms as "neighbours"
    8080  atoms.resize((size_t)5, NULL);
    81   std::generate_n(atoms.begin(), (size_t)5, boost::bind(&World::createAtom, World::getPointer()) );
     81  std::generate_n(atoms.begin(), (size_t)5, boost::bind(
     82    static_cast<atom* (World::*)(World::CreateAtomNotificationType)>(&World::createAtom),
     83    World::getPointer(),
     84    World::CreateAtomNotificationType::NOTIFY_ON_CREATE_ATOM)  );
    8285
    8386  // position them
  • src/Fragmentation/Exporters/HydrogenPool.cpp

    rd2be22 r25aa214  
    6060{
    6161  // get new hydrogen from world, but remove its observers
    62   atom * const Walker = World::getInstance().createAtom();
     62  atom * const Walker = World::getInstance().createAtom(World::CreateAtomNotificationType::DO_NOT_NOTIFY);
    6363  Walker->setType(HYDROGEN);  // set element
    6464  Walker->setName(std::string("H_")+toString(HydrogenCount));
  • src/Fragmentation/Exporters/unittests/SaturationDistanceMaximizerUnitTest.cpp

    rd2be22 r25aa214  
    8787  // prepare SaturatedBonds each with degree one
    8888  atomVector.resize((size_t)MaxAtoms);
    89   std::generate_n(atomVector.begin(), MaxAtoms,
    90       boost::bind(&World::createAtom, boost::ref(World::getInstance())));
     89  std::generate_n(atomVector.begin(), MaxAtoms, boost::bind(
     90      static_cast<atom* (World::*)(World::CreateAtomNotificationType)>(&World::createAtom),
     91      World::getPointer(),
     92      World::CreateAtomNotificationType::NOTIFY_ON_CREATE_ATOM));
    9193  std::list<bond*> bondVector;
    9294  SaturationDistanceMaximizer::PositionContainers_t PositionContainers;
  • src/World.cpp

    rd2be22 r25aa214  
    391391}
    392392
    393 atom *World::createAtom(){
     393atom *World::createAtom(const CreateAtomNotificationType _notify){
    394394  OBSERVE;
    395395  atomId_t id = atomIdPool.getNextId();
     
    401401  _lastchangedatom = res;
    402402  _lastchangedatomid = res->getId();
    403   NOTIFY(AtomInserted);
     403  if (_notify == NOTIFY_ON_CREATE_ATOM)
     404    NOTIFY(AtomInserted);
    404405  return res;
    405406}
  • src/World.hpp

    rd2be22 r25aa214  
    337337  void destroyMolecule(moleculeId_t);
    338338
     339  /** Enumeration of a notification boolean switch that makes it more readible.
     340   */
     341  enum CreateAtomNotificationType {
     342    NOTIFY_ON_CREATE_ATOM,  //!< default
     343    DO_NOT_NOTIFY           //!< this should only be used by the \a HydrogenPool for fragmentation hydrogens
     344  };
     345
    339346  /**
    340347   * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores
    341348   * the atom in the World. If the atom is not destroyed it will automatically be destroyed when the world ends.
    342    */
    343   atom *createAtom();
     349   *
     350   * \param _notify - if do not notify, then the AtomInserted channel receives no update, used by \a HydrogenPool.
     351   */
     352  atom *createAtom(const CreateAtomNotificationType _notify = NOTIFY_ON_CREATE_ATOM);
    344353
    345354  /**
  • src/unittests/AtomIdSetUnitTest.cpp

    rd2be22 r25aa214  
    6363
    6464  atomVector.resize((size_t)MaxAtoms);
    65   std::generate_n(atomVector.begin(), MaxAtoms,
    66       boost::bind(&World::createAtom, boost::ref(World::getInstance())));
     65  std::generate_n(atomVector.begin(), MaxAtoms, boost::bind(
     66    static_cast<atom* (World::*)(World::CreateAtomNotificationType)>(&World::createAtom),
     67    World::getPointer(),
     68    World::CreateAtomNotificationType::NOTIFY_ON_CREATE_ATOM)
     69  );
    6770}
    6871
  • src/unittests/MoleculeUnitTest.cpp

    rd2be22 r25aa214  
    6464
    6565  atomVector.resize((size_t)MaxAtoms);
    66   std::generate_n(atomVector.begin(), MaxAtoms,
    67       boost::bind(&World::createAtom, boost::ref(World::getInstance())));
     66  std::generate_n(atomVector.begin(), MaxAtoms, boost::bind(
     67    static_cast<atom* (World::*)(World::CreateAtomNotificationType)>(&World::createAtom),
     68    World::getPointer(),
     69    World::CreateAtomNotificationType::NOTIFY_ON_CREATE_ATOM)
     70  );
    6871  std::for_each(atomVector.begin(), atomVector.end(),
    6972      boost::bind(static_cast<void (AtomInfo::*)(int)>(&AtomInfo::setType), _1, (atomicNumber_t)1));
Note: See TracChangeset for help on using the changeset viewer.