Changeset ee3fb8 for src/UIElements


Ignore:
Timestamp:
Apr 20, 2016, 8:53:33 AM (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:
bf6245
Parents:
62a127
git-author:
Frederik Heber <heber@…> (03/22/16 11:58:35)
git-committer:
Frederik Heber <heber@…> (04/20/16 08:53:33)
Message:

QtObservedAtom uses new index internally.

  • thus we don't have to jump through the loops with constructing prior an IndexGetter in initObservedValues().
Location:
src/UIElements/Qt4/InstanceBoard
Files:
2 edited

Legend:

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

    r62a127 ree3fb8  
    106106  ObservedValues(QtObservedAtom::MAX_ObservedTypes)
    107107{
    108   boost::function<void (const atomId_t)> atomSubjectKilled(
     108  boost::function<void (ObservedValue_Index_t)> atomSubjectKilled(
    109109      boost::bind(&QtObservedAtom::countValuesSubjectKilled,
    110110          boost::ref(*this),
    111           _1));
     111          boost::bind(&QtObservedAtom::getIndex, boost::ref(*this))));
    112112  initObservedValues( ObservedValues, _id, _atom, atomSubjectKilled);
    113113
     
    117117QtObservedAtom::~QtObservedAtom()
    118118{
    119   boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex])->noteCallBackIsGone();
    120   boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->noteCallBackIsGone();
    121   boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->noteCallBackIsGone();
    122   boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, atomId_t> *>(ObservedValues[AtomMolecule])->noteCallBackIsGone();
    123   boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(ObservedValues[AtomName])->noteCallBackIsGone();
    124   boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->noteCallBackIsGone();
    125   boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(ObservedValues[AtomSelected])->noteCallBackIsGone();
     119  boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(ObservedValues[AtomIndex])->noteCallBackIsGone();
     120  boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(ObservedValues[AtomBonds])->noteCallBackIsGone();
     121  boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(ObservedValues[AtomElement])->noteCallBackIsGone();
     122  boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(ObservedValues[AtomMolecule])->noteCallBackIsGone();
     123  boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[AtomName])->noteCallBackIsGone();
     124  boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomPosition])->noteCallBackIsGone();
     125  boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[AtomSelected])->noteCallBackIsGone();
    126126
    127127  deactivateObserver();
     
    229229  ++signedOffChannels;
    230230
    231   checkForRemoval();
    232 }
    233 
    234 void QtObservedAtom::countValuesSubjectKilled(const atomId_t _id)
    235 {
    236   ASSERT( _id == getAtomIndex(),
    237       "QtObservedAtom::countValuesSubjectKilled() - atom "+toString(getAtomIndex())
     231  checkForRemoval(getIndex());
     232}
     233
     234void QtObservedAtom::countValuesSubjectKilled(ObservedValue_Index_t _id)
     235{
     236  ASSERT( _id == getIndex(),
     237      "QtObservedAtom::countValuesSubjectKilled() - atom "+toString(getIndex())
    238238      +" received countValuesSubjectKilled for atom id "+toString(_id)+".");
    239239
    240240  ++subjectKilledCount;
    241241
    242   checkForRemoval();
    243 }
    244 
    245 #ifdef HAVE_INLINE
    246 inline
    247 #endif
    248 void QtObservedAtom::checkForRemoval()
     242  checkForRemoval(_id);
     243}
     244
     245#ifdef HAVE_INLINE
     246inline
     247#endif
     248void QtObservedAtom::checkForRemoval(ObservedValue_Index_t _id)
    249249{
    250250  if ((signedOffChannels == AllsignedOnChannels) && (subjectKilledCount == MAX_ObservedTypes)) {
     
    255255
    256256    if (!BoardIsGone) {
    257       board.markObservedAtomAsDisconnected(getIndex());
    258       board.markObservedAtomForErase(getIndex());
     257      board.markObservedAtomAsDisconnected(_id);
     258      board.markObservedAtomForErase(_id);
    259259    }
    260260  }
     
    332332    const atomId_t _id,
    333333    const atom * const _atomref,
    334     const boost::function<void(const atomId_t)> &_subjectKilled)
    335 {
    336   /* This is an old note from when the code was still part of cstor's initializer body.
    337    * TODO: Probably does not apply anymore but has not yet been tested.
    338    *
    339    * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly
    340    * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because
    341    * the class has not been fully constructed yet. "This" itself seems to be working fine.
    342    */
    343 
     334    const boost::function<void(ObservedValue_Index_t)> &_subjectKilled)
     335{
    344336  ASSERT( _ObservedValues.size() == MAX_ObservedTypes,
    345337      "QtObservedAtom::initObservedValues() - given ObservedValues has not correct size.");
    346338
    347339  // fill ObservedValues: index first
     340  const boost::function<ObservedValue_Index_t ()> IndexGetter =
     341      boost::bind(&QtObservedAtom::getIndex,
     342          boost::cref(*this));
     343
     344  // fill ObservedValues: then all the other that need index
    348345  const boost::function<atomId_t ()> AtomIndexUpdater(
    349346      boost::bind(&QtObservedAtom::updateIndex, boost::cref(*_atomref)));
    350 
    351   ObservedValue_wCallback<atomId_t> * const IndexObservable =
    352       new ObservedValue_wCallback<atomId_t>(
    353           _atomref,
    354           AtomIndexUpdater,
    355           "AtomIndex_"+toString(_id),
    356           _id,
    357           AtomIndexChannels,
    358           _subjectKilled);
    359   _ObservedValues[AtomIndex] = IndexObservable;
    360 
    361   const boost::function<const atomId_t ()> AtomIndexGetter =
    362       boost::bind(&ObservedValue_wCallback<atomId_t>::get,
    363           IndexObservable);
    364 
    365   // fill ObservedValues: then all the other that need index
    366347  const boost::function<ListOfBonds_t ()> AtomBondsUpdater(
    367348      boost::bind(&QtObservedAtom::updateBonds, boost::cref(*_atomref)));
     
    377358      boost::bind(&QtObservedAtom::updateSelected, boost::cref(*_atomref)));
    378359
    379   _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>(
     360  _ObservedValues[AtomIndex] = new ObservedValue_wCallback<atomId_t, ObservedValue_Index_t>(
     361      _atomref,
     362      AtomIndexUpdater,
     363      "AtomIndex_"+toString(_id),
     364      _id,
     365      AtomIndexChannels,
     366      _subjectKilled,
     367      IndexGetter);
     368  _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t>(
    380369      _atomref,
    381370      AtomBondsUpdater,
     
    384373      AtomBondsChannels,
    385374      _subjectKilled,
    386       AtomIndexGetter);
    387   _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>(
     375      IndexGetter);
     376  _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>(
    388377      _atomref,
    389378      AtomElementUpdater,
     
    392381      AtomElementChannels,
    393382      _subjectKilled,
    394       AtomIndexGetter);
    395   _ObservedValues[AtomMolecule] = new ObservedValue_wCallback<QtObservedMolecule*, atomId_t>(
     383      IndexGetter);
     384  _ObservedValues[AtomMolecule] = new ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t>(
    396385      _atomref,
    397386      AtomMoleculeUpdater,
     
    400389      AtomMoleculeChannels,
    401390      _subjectKilled,
    402       AtomIndexGetter);
    403   _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, atomId_t>(
     391      IndexGetter);
     392  _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>(
    404393      _atomref,
    405394      AtomNameUpdater,
     
    408397      AtomNameChannels,
    409398      _subjectKilled,
    410       AtomIndexGetter);
    411   _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, atomId_t>(
     399      IndexGetter);
     400  _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
    412401      _atomref,
    413402      AtomPositionUpdater,
     
    416405      AtomPositionChannels,
    417406      _subjectKilled,
    418       AtomIndexGetter);
    419   _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, atomId_t>(
     407      IndexGetter);
     408  _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>(
    420409      _atomref,
    421410      AtomSelectedUpdater,
     
    424413      AtomSelectedChannels,
    425414      _subjectKilled,
    426       AtomIndexGetter);
     415      IndexGetter);
    427416}
    428417
     
    430419    std::vector<boost::any> &_ObservedValues)
    431420{
    432   delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[AtomIndex]);
    433   delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(_ObservedValues[AtomBonds]);
    434   delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(_ObservedValues[AtomElement]);
    435   delete boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, atomId_t> *>(_ObservedValues[AtomMolecule]);
    436   delete boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(_ObservedValues[AtomName]);
    437   delete boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(_ObservedValues[AtomPosition]);
    438   delete boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(_ObservedValues[AtomSelected]);
     421  delete boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(_ObservedValues[AtomIndex]);
     422  delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(_ObservedValues[AtomBonds]);
     423  delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(_ObservedValues[AtomElement]);
     424  delete boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(_ObservedValues[AtomMolecule]);
     425  delete boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(_ObservedValues[AtomName]);
     426  delete boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(_ObservedValues[AtomPosition]);
     427  delete boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(_ObservedValues[AtomSelected]);
    439428  _ObservedValues.clear();
    440429}
     
    449438const atomId_t& QtObservedAtom::getAtomIndex() const
    450439{
    451   return boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex])->get();
     440  return boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(ObservedValues[AtomIndex])->get();
    452441}
    453442
    454443const QtObservedAtom::ListOfBonds_t& QtObservedAtom::getAtomBonds() const
    455444{
    456   return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->get();
     445  return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(ObservedValues[AtomBonds])->get();
    457446}
    458447
    459448const atomicNumber_t& QtObservedAtom::getAtomElement() const
    460449{
    461   return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->get();
     450  return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(ObservedValues[AtomElement])->get();
    462451}
    463452
    464453QtObservedMolecule* const QtObservedAtom::getAtomMolecule() const
    465454{
    466   return boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, atomId_t> *>(ObservedValues[AtomMolecule])->get();
     455  return boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(ObservedValues[AtomMolecule])->get();
    467456}
    468457
    469458const std::string& QtObservedAtom::getAtomName() const
    470459{
    471   return boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(ObservedValues[AtomName])->get();
     460  return boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[AtomName])->get();
    472461}
    473462
    474463const Vector& QtObservedAtom::getAtomPosition() const
    475464{
    476   return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->get();
     465  return boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomPosition])->get();
    477466}
    478467
    479468const bool QtObservedAtom::getAtomSelected() const
    480469{
    481   return boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(ObservedValues[AtomSelected])->get();
    482 }
     470  return boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[AtomSelected])->get();
     471}
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp

    r62a127 ree3fb8  
    207207      const atomId_t _id,
    208208      const atom * const _atomref,
    209       const boost::function<void(const atomId_t)> &_subjectKilled);
     209      const boost::function<void(ObservedValue_Index_t)> &_subjectKilled);
    210210
    211211  /** Destroys all \a ObservedValues entries.
     
    227227   * \param _id id to check against ours
    228228   */
    229   void countValuesSubjectKilled(const atomId_t _id);
     229  void countValuesSubjectKilled(ObservedValue_Index_t _id);
    230230
    231231  //!> counts how many ObservedValues have already been subjectKilled()
     
    235235   * this instance and all its internal observed values.
    236236   *
    237    */
    238   void checkForRemoval();
     237   * \param _id id to check against ours
     238   */
     239  void checkForRemoval(ObservedValue_Index_t _id);
    239240
    240241private:
Note: See TracChangeset for help on using the changeset viewer.