Ignore:
Timestamp:
Apr 20, 2016, 10:58:42 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:
96f14a
Parents:
6af6a62
git-author:
Frederik Heber <heber@…> (03/15/16 10:10:54)
git-committer:
Frederik Heber <heber@…> (04/20/16 22:58:42)
Message:

Added QtObservedBond, managed by QtObservedInstanceBoard.

  • QtObservedBond is special because it observes not only a bond, but also two atoms and a molecule in total.
  • but the general idea is to rather have information duplicate, i.e. the left atom's position is also available via the QtObservedAtom. But in this way QtObservedBond does not depend on the QtObservedAtom being still or already present.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp

    r6af6a62 rb4bd0e  
    6262      *this,
    6363      boost::bind(&QtObservedInstanceBoard::atomcountsubjectKilled, this, _1)),
     64  bondObservedValues(
     65      "bond",
     66      *this,
     67      boost::bind(&QtObservedInstanceBoard::bondcountsubjectKilled, this, _1)),
    6468  moleculeObservedValues(
    6569      "molecule",
     
    6973  qRegisterMetaType<ObservedValue_Index_t>("ObservedValue_Index_t");
    7074  qRegisterMetaType<QtObservedAtom::ptr>("QtObservedAtom::ptr");
     75  qRegisterMetaType<QtObservedBond::ptr>("QtObservedBond::ptr");
    7176  qRegisterMetaType<QtObservedMolecule::ptr>("QtObservedMolecule::ptr");
    7277
     
    8388    World::getInstance().signOff(this, World::MoleculeInserted);
    8489  }
    85   // sign off from all remaining molecules and atoms
     90  // sign off from all remaining molecules, bonds, and atoms
    8691  for (SignedOn_t::iterator iter = AtomSignedOn.begin(); !AtomSignedOn.empty();
    8792      iter = AtomSignedOn.begin()) {
    8893    (*iter)->signOff(this, atom::IndexChanged);
    89     AtomSignedOn.erase(iter);
     94    (*iter)->signOff(this, atom::BondsAdded);
     95    AtomSignedOn.erase(*iter);
    9096  }
    9197
     
    108114  if ( iter != AtomSignedOn.end()) {
    109115    LOG(3, "DEBUG: InstanceBoard got subjectKilled() from atom " << publisher);
    110     AtomSignedOn.erase(iter);
     116    AtomSignedOn.erase(iter); // only remove one
    111117  } else {
    112118    iter = MoleculeSignedOn.find(publisher);
     
    176182          LOG(3, "DEBUG: InformationBoard signOn()s to atom " << _id);
    177183          _atom->signOn(this, atom::IndexChanged);
     184          _atom->signOn(this, atom::BondsAdded);
     185          AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) );
    178186          AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) );
    179187          emit atomInserted(observedatom);
     
    232240        break;
    233241      }
     242      case AtomObservable::BondsAdded:
     243      {
     244        const atom * _atom = dynamic_cast<atom *>(publisher);
     245        const atomId_t _id = _atom->getId();
     246#ifdef LOG_OBSERVER
     247      observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
     248#endif
     249        LOG(3, "DEBUG: InformationBoard got bondInserted signal for atom " << _id);
     250        if (_atom != NULL) {
     251          // find the new bond by simply taking the last added to the list
     252          const BondList &ListOfBonds = _atom->getListOfBonds();
     253          const bond::ptr bondref = ListOfBonds.back();
     254          const bondId_t bondid =
     255              std::make_pair( bondref->leftatom->getId(), bondref->rightatom->getId());
     256          LOG(3, "DEBUG: InformationBoard initializes QtObservedBond for " << bondid);
     257          QtObservedBond::ptr observedbond(
     258              new QtObservedBond(bondid, bondref, *this));
     259          const ObservedValue_Index_t index = observedbond->getIndex();
     260          bondObservedValues.insert(index, observedbond);
     261          bondids_lookup.left.insert( std::make_pair(bondid, index) );
     262          emit bondInserted(observedbond);
     263        } else {
     264          ELOG(1, "QtObservedInstanceBoard got BondsAdded for unknown atom id " << _id);
     265        }
     266        break;
     267      }
    234268      default:
    235269        ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - we cannot get here.");
     
    239273    ASSERT(0, "QtObservedInstanceBoard::recieveNotification() - notification from unknown source.");
    240274  }
    241 }
    242 
    243 void QtObservedInstanceBoard::atomcountsubjectKilled(ObservedValue_Index_t _id)
    244 {
    245   LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << _id);
    246   emit atomRemoved(_id);
    247 }
    248 
    249 void QtObservedInstanceBoard::moleculecountsubjectKilled(ObservedValue_Index_t _id)
    250 {
    251   LOG(3, "DEBUG: InstanceBoard emits moleculeRemoved for " << _id);
    252   emit moleculeRemoved(_id);
    253275}
    254276
     
    262284}
    263285
     286const QtObservedInstanceBoard::bondId_t
     287QtObservedInstanceBoard::getBondIdToIndex(ObservedValue_Index_t _id) const
     288{
     289  typename IdtoIndex_t<bondId_t>::right_const_iterator iter = bondids_lookup.right.find(_id);
     290  ASSERT( iter != bondids_lookup.right.end(),
     291      "QtObservedInstanceBoard::getBondIdToIndex() - index "
     292      +toString(_id)+" is unknown.");
     293  return iter->second;
     294}
     295
    264296const moleculeId_t QtObservedInstanceBoard::getMoleculeIdToIndex(ObservedValue_Index_t _id) const
    265297{
     
    271303}
    272304
     305void QtObservedInstanceBoard::atomcountsubjectKilled(ObservedValue_Index_t _id)
     306{
     307  LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << getAtomIdToIndex(_id));
     308  emit atomRemoved(_id);
     309}
     310
     311void QtObservedInstanceBoard::bondcountsubjectKilled(ObservedValue_Index_t _id)
     312{
     313  LOG(3, "DEBUG: InstanceBoard emits bondRemoved for " << getBondIdToIndex(_id));
     314  emit bondRemoved(_id);
     315}
     316
     317void QtObservedInstanceBoard::moleculecountsubjectKilled(ObservedValue_Index_t _id)
     318{
     319  LOG(3, "DEBUG: InstanceBoard emits moleculeRemoved for " << getMoleculeIdToIndex(_id));
     320  emit moleculeRemoved(_id);
     321}
     322
    273323QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id)
    274324{
     
    279329{
    280330  return atomObservedValues.get(_id);
     331}
     332
     333QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(const bondId_t _id)
     334{
     335  return bondObservedValues.get(bondids_lookup.left.at(_id));
     336}
     337
     338QtObservedBond::ptr QtObservedInstanceBoard::getObservedBond(ObservedValue_Index_t _id)
     339{
     340  return bondObservedValues.get(_id);
    281341}
    282342
     
    307367}
    308368
     369void QtObservedInstanceBoard::markObservedBondAsConnected(ObservedValue_Index_t _id)
     370{
     371  bondObservedValues.markObservedValuesAsConnected(_id);
     372}
     373
     374void QtObservedInstanceBoard::markObservedBondAsDisconnected(ObservedValue_Index_t _id)
     375{
     376  bondObservedValues.markObservedValuesAsDisconnected(_id);
     377}
     378
     379void QtObservedInstanceBoard::markObservedBondForErase(ObservedValue_Index_t _id)
     380{
     381  bondObservedValues.eraseObservedValues(_id);
     382  bondids_lookup.right.erase(_id);
     383}
     384
    309385void QtObservedInstanceBoard::markObservedMoleculeAsConnected(ObservedValue_Index_t _id)
    310386{
Note: See TracChangeset for help on using the changeset viewer.