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:
6af6a62
Parents:
ee3fb8
git-author:
Frederik Heber <heber@…> (03/23/16 09:56:51)
git-committer:
Frederik Heber <heber@…> (04/20/16 08:53:33)
Message:

QtObservedMolecule also uses new index internally.

Location:
src/UIElements/Qt4/InstanceBoard
Files:
2 edited

Legend:

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

    ree3fb8 rbf6245  
    114114  ObservedValues(QtObservedMolecule::MAX_ObservedTypes)
    115115{
    116   boost::function<void (const atomId_t)> moleculeSubjectKilled(
     116  boost::function<void (ObservedValue_Index_t)> moleculeSubjectKilled(
    117117      boost::bind(&QtObservedMolecule::countValuesSubjectKilled,
    118118          boost::ref(*this),
    119           _1));
     119          boost::bind(&QtObservedMolecule::getIndex, boost::ref(*this))));
    120120  initObservedValues(ObservedValues, _id, _mol, moleculeSubjectKilled);
    121121
     
    125125QtObservedMolecule::~QtObservedMolecule()
    126126{
    127   boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->noteCallBackIsGone();
    128   boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->noteCallBackIsGone();
    129   boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[BondCount])->noteCallBackIsGone();
    130   boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->noteCallBackIsGone();
    131   boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->noteCallBackIsGone();
    132   boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(ObservedValues[MolCenter])->noteCallBackIsGone();
    133   boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->noteCallBackIsGone();
    134   boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->noteCallBackIsGone();
    135   boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(ObservedValues[MolSelected])->noteCallBackIsGone();
     127  boost::any_cast<ObservedValue_wCallback<moleculeId_t, ObservedValue_Index_t> *>(ObservedValues[MolIndex])->noteCallBackIsGone();
     128  boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(ObservedValues[AtomCount])->noteCallBackIsGone();
     129  boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(ObservedValues[BondCount])->noteCallBackIsGone();
     130  boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, ObservedValue_Index_t> *>(ObservedValues[BoundingBox])->noteCallBackIsGone();
     131  boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[FormulaString])->noteCallBackIsGone();
     132  boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[MolCenter])->noteCallBackIsGone();
     133  boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[MolName])->noteCallBackIsGone();
     134  boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(ObservedValues[NonHydrogenCount])->noteCallBackIsGone();
     135  boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[MolSelected])->noteCallBackIsGone();
    136136
    137137  deactivateObserver();
     
    180180  ++signedOffChannels;
    181181
    182   checkForRemoval();
    183 }
    184 
    185 void QtObservedMolecule::countValuesSubjectKilled(const moleculeId_t _id)
    186 {
    187   ASSERT( _id == getMolIndex(),
    188       "QtObservedAtom::countValuesSubjectKilled() - molecule "+toString(getMolIndex())
     182  checkForRemoval(getIndex());
     183}
     184
     185void QtObservedMolecule::countValuesSubjectKilled(ObservedValue_Index_t _id)
     186{
     187  ASSERT( _id == getIndex(),
     188      "QtObservedAtom::countValuesSubjectKilled() - molecule "+toString(getIndex())
    189189      +" received countValuesSubjectKilled for molecule id "+toString(_id)+".");
    190190
    191191  ++subjectKilledCount;
    192192
    193   checkForRemoval();
    194 }
    195 
    196 void QtObservedMolecule::checkForRemoval()
     193  checkForRemoval(_id);
     194}
     195
     196void QtObservedMolecule::checkForRemoval(ObservedValue_Index_t _id)
    197197{
    198198  if ((signedOffChannels == AllsignedOnChannels) && (subjectKilledCount == MAX_ObservedTypes)) {
     
    203203
    204204    if (!BoardIsGone) {
    205       board.markObservedMoleculeAsDisconnected(getIndex());
    206       board.markObservedMoleculeForErase(getIndex());
     205      board.markObservedMoleculeAsDisconnected(_id);
     206      board.markObservedMoleculeForErase(_id);
    207207    }
    208208  }
     
    321321    const moleculeId_t _molid,
    322322    const molecule * const _molref,
    323     const boost::function<void(const moleculeId_t)> &_subjectKilled)
    324 {
    325   /* This is an old note from when the code was still part of cstor's initializer body.
    326    * TODO: Probably does not apply anymore but has not yet been tested.
    327    *
    328    * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly
    329    * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because
    330    * the class has not been fully constructed yet. "This" itself seems to be working fine.
    331    */
    332 
     323    const boost::function<void(ObservedValue_Index_t)> &_subjectKilled)
     324{
    333325  ASSERT( _ObservedValues.size() == MAX_ObservedTypes,
    334326      "QtObservedMolecule::initObservedValues() - given ObservedValues has not correct size.");
    335327
    336328  // fill ObservedValues: index first
     329  const boost::function<ObservedValue_Index_t ()> MolIndexGetter =
     330      boost::bind(&QtObservedMolecule::getIndex,
     331          boost::cref(*this));
     332
     333  // fill ObservedValues: then all the other that need index
    337334  const boost::function<moleculeId_t ()> MolIndexUpdater(
    338335      boost::bind(&QtObservedMolecule::updateIndex, boost::cref(*_molref)));
    339 
    340   ObservedValue_wCallback<moleculeId_t> * const IndexObservable =
    341       new ObservedValue_wCallback<moleculeId_t>(
    342         _molref,
    343         MolIndexUpdater,
    344         "MoleculeIndex_"+toString(_molid),
    345         _molid,
    346         IndexChannels,
    347         _subjectKilled);
    348   _ObservedValues[MolIndex] = IndexObservable;
    349 
    350   const boost::function<const moleculeId_t ()> MolIndexGetter =
    351       boost::bind(&ObservedValue_wCallback<moleculeId_t>::get,
    352           IndexObservable);
    353 
    354   // fill ObservedValues: then all the other that need index
    355336  const boost::function<int ()> AtomCountUpdater(
    356337      boost::bind(&QtObservedMolecule::updateAtomCount, boost::cref(*_molref)));
     
    370351      boost::bind(&QtObservedMolecule::updateSelected, boost::cref(*_molref)));
    371352
    372   _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, moleculeId_t>(
     353  _ObservedValues[MolIndex] = new ObservedValue_wCallback<moleculeId_t, ObservedValue_Index_t>(
     354        _molref,
     355        MolIndexUpdater,
     356        "MoleculeIndex_"+toString(_molid),
     357        _molid,
     358        IndexChannels,
     359        _subjectKilled,
     360        MolIndexGetter);
     361  _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>(
    373362      _molref,
    374363      AtomCountUpdater,
     
    378367      _subjectKilled,
    379368      MolIndexGetter);
    380   _ObservedValues[BondCount] = new ObservedValue_wCallback<int, moleculeId_t>(
     369  _ObservedValues[BondCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>(
    381370      _molref,
    382371      BondCountUpdater,
     
    386375      _subjectKilled,
    387376      MolIndexGetter);
    388   _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t>(
     377  _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, ObservedValue_Index_t>(
    389378      _molref,
    390379      BoundingBoxUpdater,
     
    394383      _subjectKilled,
    395384      MolIndexGetter);
    396   _ObservedValues[FormulaString] = new ObservedValue_wCallback<std::string, moleculeId_t>(
     385  _ObservedValues[FormulaString] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>(
    397386      _molref,
    398387      MolFormulaUpdater,
     
    402391      _subjectKilled,
    403392      MolIndexGetter);
    404   _ObservedValues[MolCenter] = new ObservedValue_wCallback<Vector, moleculeId_t>(
     393  _ObservedValues[MolCenter] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
    405394      _molref,
    406395      MolCenterUpdater,
     
    410399      _subjectKilled,
    411400      MolIndexGetter);
    412   _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>(
     401  _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>(
    413402      _molref,
    414403      MolNameUpdater,
     
    418407      _subjectKilled,
    419408      MolIndexGetter);
    420   _ObservedValues[NonHydrogenCount] = new ObservedValue_wCallback<int, moleculeId_t>(
     409  _ObservedValues[NonHydrogenCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>(
    421410      _molref,
    422411      NonHydrogenCountUpdater,
     
    426415      _subjectKilled,
    427416      MolIndexGetter);
    428   _ObservedValues[MolSelected] = new ObservedValue_wCallback<bool, moleculeId_t>(
     417  _ObservedValues[MolSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>(
    429418      _molref,
    430419      SelectedUpdater,
     
    439428    std::vector<boost::any> &_ObservedValues)
    440429{
    441   delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]);
    442   delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[AtomCount]);
    443   delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[BondCount]);
    444   delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);
    445   delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[FormulaString]);
    446   delete boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(_ObservedValues[MolCenter]);
    447   delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]);
    448   delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[NonHydrogenCount]);
    449   delete boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(_ObservedValues[MolSelected]);
     430  delete boost::any_cast<ObservedValue_wCallback<moleculeId_t, ObservedValue_Index_t> *>(_ObservedValues[MolIndex]);
     431  delete boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(_ObservedValues[AtomCount]);
     432  delete boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(_ObservedValues[BondCount]);
     433  delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, ObservedValue_Index_t> *>(_ObservedValues[BoundingBox]);
     434  delete boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(_ObservedValues[FormulaString]);
     435  delete boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(_ObservedValues[MolCenter]);
     436  delete boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(_ObservedValues[MolName]);
     437  delete boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(_ObservedValues[NonHydrogenCount]);
     438  delete boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(_ObservedValues[MolSelected]);
    450439  _ObservedValues.clear();
    451440}
     
    532521const int& QtObservedMolecule::getAtomCount() const
    533522{
    534   return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->get();
     523  return boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(ObservedValues[AtomCount])->get();
    535524}
    536525
    537526const int& QtObservedMolecule::getBondCount() const
    538527{
    539   return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[BondCount])->get();
     528  return boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(ObservedValues[BondCount])->get();
    540529}
    541530
    542531const std::string& QtObservedMolecule::getMolFormula() const
    543532{
    544   return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->get();
     533  return boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[FormulaString])->get();
    545534}
    546535
    547536const Vector& QtObservedMolecule::getMolCenter() const
    548537{
    549   return boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(ObservedValues[MolCenter])->get();
     538  return boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[MolCenter])->get();
    550539}
    551540
    552541const moleculeId_t& QtObservedMolecule::getMolIndex() const
    553542{
    554   return boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->get();
     543  return boost::any_cast<ObservedValue_wCallback<moleculeId_t, ObservedValue_Index_t> *>(ObservedValues[MolIndex])->get();
    555544}
    556545
    557546const std::string& QtObservedMolecule::getMolName() const
    558547{
    559   return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->get();
     548  return boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[MolName])->get();
    560549}
    561550
    562551const int& QtObservedMolecule::getNonHydrogenCount() const
    563552{
    564   return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->get();
     553  return boost::any_cast<ObservedValue_wCallback<int, ObservedValue_Index_t> *>(ObservedValues[NonHydrogenCount])->get();
    565554}
    566555
    567556const molecule::BoundingBoxInfo& QtObservedMolecule::getBoundingBox() const
    568557{
    569   return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->get();
     558  return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, ObservedValue_Index_t> *>(ObservedValues[BoundingBox])->get();
    570559}
    571560
    572561const bool& QtObservedMolecule::getMolSelected() const
    573562{
    574   return boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(ObservedValues[MolSelected])->get();
    575 }
     563  return boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[MolSelected])->get();
     564}
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp

    ree3fb8 rbf6245  
    244244      const moleculeId_t _molid,
    245245      const molecule * const _molref,
    246       const boost::function<void(const moleculeId_t)> &_subjectKilled);
     246      const boost::function<void(ObservedValue_Index_t)> &_subjectKilled);
    247247
    248248  /** Destroys all \a ObservedValues entries.
     
    265265   * \param _id id to check against ours
    266266   */
    267   void countValuesSubjectKilled(const atomId_t _id);
     267  void countValuesSubjectKilled(ObservedValue_Index_t _id);
    268268
    269269  //!> counts how many ObservedValues have already been subjectKilled()
     
    273273   * this instance and all its internal observed values.
    274274   *
    275    */
    276   void checkForRemoval();
     275   * \param _id id to check against ours
     276   */
     277  void checkForRemoval(ObservedValue_Index_t _id);
    277278
    278279private:
Note: See TracChangeset for help on using the changeset viewer.