Ignore:
Timestamp:
Feb 12, 2016, 11:15:06 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:
15c8a9
Parents:
099f67
git-author:
Frederik Heber <heber@…> (01/25/16 11:01:10)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:06)
Message:

Changed GLMoleculeObject_...:countSubjectKilled() to taking id parameter.

  • this is a precursor for when the ObservedValues reside with QtInstanceInformationBoard.
  • enhanced ObservedValue_wCallback to take a bound getIndex function().
  • additionally, we route internally to ObservedValue::get() and this gets us out of the painful situation where we need to supply an index getter to the ObservedValue that monitors the index (and hence must be present already to bind to its get function).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp

    r099f67 r026bef  
    8989  rightobservable_enabled(false)
    9090{
    91   boost::function<void()> subjectKilled =
    92       boost::bind(&GLMoleculeObject_bond::countsubjectKilled, this);
    93   initObservedValues(ObservedValues, bondIds.first, bondIds.second, leftowner, rightowner, bondowner, subjectKilled);
    94 
     91  boost::function<void(const atomId_t &)> leftsubjectKilled =
     92      boost::bind(
     93          static_cast<void (GLMoleculeObject_bond::*) (const atomId_t &)>(
     94              &GLMoleculeObject_bond::countsubjectKilled),
     95          this, _1);
     96  boost::function<void(const atomId_t &)> rightsubjectKilled =
     97      boost::bind(
     98          static_cast<void (GLMoleculeObject_bond::*) (const atomId_t &)>(
     99              &GLMoleculeObject_bond::countsubjectKilled)
     100              , this, _1);
     101  boost::function<void(const bondIds_t &)> bondsubjectKilled =
     102      boost::bind(
     103          static_cast<void (GLMoleculeObject_bond::*) (const bondIds_t &)>(
     104              &GLMoleculeObject_bond::countsubjectKilled)
     105              , this, _1);
     106  initObservedValues(
     107      ObservedValues,
     108      bondIds.first,
     109      bondIds.second,
     110      leftowner,
     111      rightowner,
     112      bondowner,
     113      leftsubjectKilled,
     114      rightsubjectKilled,
     115      bondsubjectKilled);
     116
     117  init();
     118}
     119
     120GLMoleculeObject_bond::GLMoleculeObject_bond(
     121    QGLSceneNode *mesh[],
     122    QObject *parent,
     123    const bondIds_t bondIds,
     124    const enum SideOfBond side,
     125    std::vector<boost::any> &_ObservedValues) :
     126  GLMoleculeObject(mesh, parent),
     127  Observer(std::string("GLMoleculeObject_bond")
     128      +toString(bondIds.first)
     129      +std::string("-")
     130      +toString(bondIds.second)),
     131  leftowner(getAtomConst(bondIds.first)),
     132  rightowner(getAtomConst(bondIds.second)),
     133  bondowner(getAtomConst(bondIds.first)->getBond(getAtomConst(bondIds.second)).get()),
     134  BondSide(side),
     135  ObservedValues(_ObservedValues),
     136  subjectKilledCount(0),
     137  leftobservable_enabled(false),
     138  rightobservable_enabled(false)
     139{
     140  init();
     141}
     142
     143void GLMoleculeObject_bond::init()
     144{
    95145  // sign on as observer (obtain non-const instance before)
    96146  bondowner->signOn(this, BondObservable::BondRemoved);
     
    159209  removeChannels();
    160210  // check whether we should be removed
    161   countsubjectKilled();
     211  countsubjectKilled(std::make_pair(getleftIndex(), getrightIndex()));
    162212}
    163213
     
    339389}
    340390
     391static GLMoleculeObject_bond::bondIds_t getBondIdsForIds(
     392    const boost::function<const atomId_t ()> _left,
     393    const boost::function<const atomId_t ()> _right)
     394{
     395  return std::make_pair( _left(), _right());
     396}
     397
    341398void GLMoleculeObject_bond::initObservedValues(
    342399    std::vector<boost::any> &_ObservedValues,
     
    346403    const Observable * const _rightowner,
    347404    const Observable * const _bondowner,
    348     const boost::function<void()> &_subjectKilled)
     405    const boost::function<void(const atomId_t &)> &_leftsubjectKilled,
     406    const boost::function<void(const atomId_t &)> &_rightsubjectKilled,
     407    const boost::function<void(const bondIds_t &)> &_bondsubjectKilled)
    349408{
    350409  /* This is an old note from when the code was still part of cstor's initializer body.
     
    372431        _leftatomId,
    373432        IndexChannels,
    374         _subjectKilled);
     433        _leftsubjectKilled);
    375434  _ObservedValues[leftIndex] = LeftIndexObservable;
    376435  ObservedValue_wCallback<atomId_t> * const RightIndexObservable =
     
    381440        _rightatomId,
    382441        IndexChannels,
    383         _subjectKilled);
     442        _rightsubjectKilled);
    384443  _ObservedValues[rightIndex] = RightIndexObservable;
    385444
     
    402461  const boost::function<int ()> DegreeUpdater(
    403462      boost::bind(&GLMoleculeObject_bond::updateDegree, LeftIndexGetter, RightIndexGetter));
    404 
    405   _ObservedValues[leftPosition] = new ObservedValue_wCallback<Vector>(
     463  const boost::function<bondIds_t ()> BondIdGetter(
     464      boost::bind(&getBondIdsForIds, LeftIndexGetter, RightIndexGetter));
     465
     466  _ObservedValues[leftPosition] = new ObservedValue_wCallback<Vector, atomId_t>(
    406467      _leftowner,
    407468      LeftPositionUpdater,
     
    409470      LeftPositionUpdater(),
    410471      BondPositionChannels,
    411       _subjectKilled);
    412   _ObservedValues[rightPosition] = new ObservedValue_wCallback<Vector>(
     472      _leftsubjectKilled,
     473      LeftIndexGetter);
     474  _ObservedValues[rightPosition] = new ObservedValue_wCallback<Vector, atomId_t>(
    413475      _rightowner,
    414476      RightPositionUpdater,
     
    416478      RightPositionUpdater(),
    417479      BondPositionChannels,
    418       _subjectKilled);
    419   _ObservedValues[leftElement] = new ObservedValue_wCallback<atomicNumber_t>(
     480      _rightsubjectKilled,
     481      RightIndexGetter);
     482  _ObservedValues[leftElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>(
    420483      _leftowner,
    421484      LeftElementUpdater,
     
    423486      LeftElementUpdater(),
    424487      BondElementChannels,
    425       _subjectKilled);
    426   _ObservedValues[rightElement] = new ObservedValue_wCallback<atomicNumber_t>(
     488      _leftsubjectKilled,
     489      LeftIndexGetter);
     490  _ObservedValues[rightElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>(
    427491      _rightowner,
    428492      RightElementUpdater,
     
    430494      RightElementUpdater(),
    431495      BondElementChannels,
    432       _subjectKilled);
    433   _ObservedValues[Degree] = new ObservedValue_wCallback<int>(
     496      _rightsubjectKilled,
     497      RightIndexGetter);
     498  _ObservedValues[Degree] = new ObservedValue_wCallback<int, bondIds_t>(
    434499      _bondowner,
    435500      DegreeUpdater,
     
    437502      DegreeUpdater(),
    438503      BondDegreeChannels,
    439       _subjectKilled);
     504      _bondsubjectKilled,
     505      BondIdGetter);
    440506}
    441507
     
    445511  delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[leftIndex]);
    446512  delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[rightIndex]);
    447   delete boost::any_cast<ObservedValue_wCallback<Vector> *>(_ObservedValues[leftPosition]);
    448   delete boost::any_cast<ObservedValue_wCallback<Vector> *>(_ObservedValues[rightPosition]);
    449   delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(_ObservedValues[leftElement]);
    450   delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(_ObservedValues[rightElement]);
    451   delete boost::any_cast<ObservedValue_wCallback<int> *>(_ObservedValues[Degree]);
     513  delete boost::any_cast<ObservedValue_wCallback<Vector,atomId_t> *>(_ObservedValues[leftPosition]);
     514  delete boost::any_cast<ObservedValue_wCallback<Vector,atomId_t> *>(_ObservedValues[rightPosition]);
     515  delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t,atomId_t> *>(_ObservedValues[leftElement]);
     516  delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t,atomId_t> *>(_ObservedValues[rightElement]);
     517  delete boost::any_cast<ObservedValue_wCallback<int, bondIds_t> *>(_ObservedValues[Degree]);
    452518  _ObservedValues.clear();
    453519}
     
    465531Vector GLMoleculeObject_bond::getleftPosition() const
    466532{
    467   return boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[leftPosition])->get();
     533  return boost::any_cast<ObservedValue_wCallback<Vector,atomId_t> *>(ObservedValues[leftPosition])->get();
    468534}
    469535
    470536Vector GLMoleculeObject_bond::getrightPosition() const
    471537{
    472   return boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[rightPosition])->get();
     538  return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[rightPosition])->get();
    473539}
    474540
    475541atomicNumber_t GLMoleculeObject_bond::getleftElement() const
    476542{
    477   return boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[leftElement])->get();
     543  return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[leftElement])->get();
    478544}
    479545
    480546atomicNumber_t GLMoleculeObject_bond::getrightElement() const
    481547{
    482   return boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[rightElement])->get();
     548  return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[rightElement])->get();
    483549}
    484550
    485551int GLMoleculeObject_bond::getDegree() const
    486552{
    487   return boost::any_cast<ObservedValue_wCallback<int> *>(ObservedValues[Degree])->get();
    488 }
     553  return boost::any_cast<ObservedValue_wCallback<int, bondIds_t> *>(ObservedValues[Degree])->get();
     554}
Note: See TracChangeset for help on using the changeset viewer.