Ignore:
Timestamp:
Feb 12, 2016, 11:15:40 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:
367489
Parents:
fe493f
git-author:
Frederik Heber <heber@…> (01/20/16 20:02:22)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:40)
Message:

Extended QtObservedMolecule by Center, NonHydrogenCount, and BondCount.

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

Legend:

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

    rfe493f r5a9e34  
    5959  channels +=
    6060      molecule::AtomInserted,
     61      molecule::AtomMoved,
    6162      molecule::AtomRemoved,
    6263      molecule::FormulaChanged,
     
    7677}
    7778
     79static const Observable::channels_t getAllCenterChannels()
     80{
     81  Observable::channels_t channels;
     82  channels +=
     83      molecule::AtomInserted,
     84      molecule::AtomMoved,
     85      molecule::AtomRemoved;
     86  return channels;
     87}
     88
    7889// static instances
    7990const Observable::channels_t QtObservedMolecule::AtomCountChannels(getAllAtomCountChannels());
     91const Observable::channels_t QtObservedMolecule::BondCountChannels(getAllAtomCountChannels());
    8092const Observable::channels_t QtObservedMolecule::BoundingBoxChannels(1, molecule::BoundingBoxChanged);
    8193const Observable::channels_t QtObservedMolecule::FormulaStringChannels(1, molecule::FormulaChanged);
     94const Observable::channels_t QtObservedMolecule::CenterChannels(getAllCenterChannels());
    8295const Observable::channels_t QtObservedMolecule::IndexChannels(1, molecule::IndexChanged);
    8396const Observable::channels_t QtObservedMolecule::NameChannels(1, molecule::MoleculeNameChanged);
     97const Observable::channels_t QtObservedMolecule::NonHydrogenCountChannels(1, molecule::FormulaChanged);
    8498
    8599QtObservedMolecule::QtObservedMolecule(
     
    146160
    147161    board.markObservedMoleculeAsDisconnected(getMolIndex());
     162
     163    emit moleculeRemoved();
    148164  }
    149165}
     
    168184        emit atomcountChanged();
    169185        emit atomInserted(_id);
     186        emit bondcountChanged();
     187        emit boundingboxChanged();
     188        emit centerChanged();
     189        emit tesselationhullChanged();
     190        break;
     191      }
     192      case molecule::AtomMoved:
     193      {
     194        emit boundingboxChanged();
     195        emit centerChanged();
     196        emit tesselationhullChanged();
    170197        break;
    171198      }
     
    175202        emit atomcountChanged();
    176203        emit atomRemoved(_id);
     204        emit bondcountChanged();
     205        emit boundingboxChanged();
     206        emit centerChanged();
     207        emit tesselationhullChanged();
    177208        break;
    178209      }
     
    189220      {
    190221        emit formulaChanged();
     222        emit nononhydrogenChanged();
    191223        break;
    192224      }
     
    267299  const boost::function<int ()> AtomCountUpdater(
    268300      boost::bind(&QtObservedMolecule::updateAtomCount, MolIndexGetter));
     301  const boost::function<int ()> BondCountUpdater(
     302      boost::bind(&QtObservedMolecule::updateBondCount, MolIndexGetter));
     303  const boost::function<Vector ()> MolCenterUpdater(
     304      boost::bind(&QtObservedMolecule::updateCenter, MolIndexGetter));
    269305  const boost::function<std::string ()> MolFormulaUpdater(
    270306      boost::bind(&QtObservedMolecule::updateFormulaString, MolIndexGetter));
    271307  const boost::function<std::string ()> MolNameUpdater(
    272308      boost::bind(&QtObservedMolecule::updateName, MolIndexGetter));
     309  const boost::function<int ()> NonHydrogenCountUpdater(
     310      boost::bind(&QtObservedMolecule::updateNonHydrogenCount, MolIndexGetter));
    273311  const boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater(
    274312      boost::bind(&QtObservedMolecule::updateBoundingBox, MolIndexGetter));
     
    282320      _subjectKilled,
    283321      MolIndexGetter);
     322  _ObservedValues[BondCount] = new ObservedValue_wCallback<int, moleculeId_t>(
     323      _molref,
     324      BondCountUpdater,
     325      "MoleculeBondCount_"+toString(_molid),
     326      BondCountUpdater(),
     327      BondCountChannels,
     328      _subjectKilled,
     329      MolIndexGetter);
    284330  _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t>(
    285331      _molref,
     
    298344      _subjectKilled,
    299345      MolIndexGetter);
     346  _ObservedValues[MolCenter] = new ObservedValue_wCallback<Vector, moleculeId_t>(
     347      _molref,
     348      MolCenterUpdater,
     349      "MoleculeCenter_"+toString(_molid),
     350      MolCenterUpdater(),
     351      CenterChannels,
     352      _subjectKilled,
     353      MolIndexGetter);
    300354  _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>(
    301355      _molref,
     
    306360      _subjectKilled,
    307361      MolIndexGetter);
     362  _ObservedValues[NonHydrogenCount] = new ObservedValue_wCallback<int, moleculeId_t>(
     363      _molref,
     364      NonHydrogenCountUpdater,
     365      "MoleculeNonHydrogenCount_"+toString(_molid),
     366      NonHydrogenCountUpdater(),
     367      NonHydrogenCountChannels,
     368      _subjectKilled,
     369      MolIndexGetter);
    308370}
    309371
     
    313375  delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]);
    314376  delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[AtomCount]);
     377  delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[BondCount]);
    315378  delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[FormulaString]);
     379  delete boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(_ObservedValues[MolCenter]);
    316380  delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);
    317381  delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]);
     382  delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[NonHydrogenCount]);
    318383  _ObservedValues.clear();
    319384}
     
    329394}
    330395
     396int QtObservedMolecule::updateBondCount(
     397    const boost::function<const moleculeId_t ()> &_getMolIndex)
     398{
     399  const molecule * const mol = getMolecule(_getMolIndex());
     400  if (mol != NULL)
     401    return mol->getBondCount();
     402  else
     403    return (int)0;
     404}
     405
    331406molecule::BoundingBoxInfo QtObservedMolecule::updateBoundingBox(
    332407    const boost::function<const moleculeId_t ()> &_getMolIndex)
     
    349424}
    350425
     426Vector QtObservedMolecule::updateCenter(
     427    const boost::function<const moleculeId_t ()> &_getMolIndex)
     428{
     429  const molecule * const mol = getMolecule(_getMolIndex());
     430  if (mol != NULL)
     431    return mol->DetermineCenterOfAll();
     432  else
     433    return zeroVec;
     434}
     435
    351436moleculeId_t QtObservedMolecule::updateIndex()
    352437{
     
    364449}
    365450
     451int QtObservedMolecule::updateNonHydrogenCount(
     452    const boost::function<const moleculeId_t ()> &_getMolIndex)
     453{
     454  const molecule * const mol = getMolecule(_getMolIndex());
     455  if (mol != NULL)
     456    return mol->getNoNonHydrogen();
     457  else
     458    return (int)0;
     459}
     460
    366461int QtObservedMolecule::getAtomCount() const
    367462{
     
    369464}
    370465
     466int QtObservedMolecule::getBondCount() const
     467{
     468  return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[BondCount])->get();
     469}
     470
    371471std::string QtObservedMolecule::getMolFormula() const
    372472{
     
    374474}
    375475
     476Vector QtObservedMolecule::getMolCenter() const
     477{
     478  return boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(ObservedValues[MolCenter])->get();
     479}
     480
    376481moleculeId_t QtObservedMolecule::getMolIndex() const
    377482{
     
    384489}
    385490
     491int QtObservedMolecule::getNonHydrogenCount() const
     492{
     493  return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->get();
     494}
     495
    386496molecule::BoundingBoxInfo QtObservedMolecule::getBoundingBox() const
    387497{
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp

    rfe493f r5a9e34  
    2222#include "CodePatterns/Observer/Observable.hpp"
    2323#include "CodePatterns/Observer/Observer.hpp"
     24
     25#include "LinearAlgebra/Vector.hpp"
    2426
    2527#include "molecule.hpp"
     
    8486  int getAtomCount() const;
    8587
     88  /** Getter to molecule bond count contained in \a ObservedValues.
     89   *
     90   * \return molecule's bond count
     91   */
     92  int getBondCount() const;
     93
     94  /** Getter to molecule center contained in \a ObservedValues.
     95   *
     96   * \return molecule's center
     97   */
     98  Vector getMolCenter() const;
     99
    86100  /** Getter to molecule index contained in \a ObservedValues.
    87101   *
     
    101115   */
    102116  std::string getMolFormula() const;
     117
     118  /** Getter to molecule non-hydrogen atom  count contained in \a ObservedValues.
     119   *
     120   * \return molecule's non-hydrogen atom count
     121   */
     122  int getNonHydrogenCount() const;
    103123
    104124  /** Getter to molecule's bounding box contained in \a ObservedValues.
     
    112132signals:
    113133  void atomcountChanged();
     134  void bondcountChanged();
    114135  void formulaChanged();
    115136  void indexChanged();
    116137  void nameChanged();
     138  void nononhydrogenChanged();
     139  void centerChanged();
    117140  void tesselationhullChanged();
    118141  void boundingboxChanged();
    119142  void atomInserted(const atomId_t);
    120143  void atomRemoved(const atomId_t);
     144  void moleculeRemoved();
    121145
    122146private:
     
    128152  static int updateAtomCount(
    129153      const boost::function<const moleculeId_t ()> &_getMolIndex);
     154  static int updateBondCount(
     155      const boost::function<const moleculeId_t ()> &_getMolIndex);
    130156  static molecule::BoundingBoxInfo updateBoundingBox(
    131157      const boost::function<const moleculeId_t ()> &_getMolIndex);
    132158  static std::string updateFormulaString(
     159      const boost::function<const moleculeId_t ()> &_getMolIndex);
     160  static Vector updateCenter(
    133161      const boost::function<const moleculeId_t ()> &_getMolIndex);
    134162  static moleculeId_t updateIndex();
    135163  static std::string updateName(
    136164      const boost::function<const moleculeId_t ()> &_getMolIndex);
     165  static int updateNonHydrogenCount(
     166      const boost::function<const moleculeId_t ()> &_getMolIndex);
    137167
    138168  //!> list of channels when atom count needs to update
    139169  static const Observable::channels_t AtomCountChannels;
     170  //!> list of channels when bond count needs to update
     171  static const Observable::channels_t BondCountChannels;
    140172  //!> list of channels when bounding box needs to update
    141173  static const Observable::channels_t BoundingBoxChannels;
    142174  //!> list of channels when formula needs to update
    143175  static const Observable::channels_t FormulaStringChannels;
     176  //!> list of channels when the center needs to update
     177  static const Observable::channels_t CenterChannels;
    144178  //!> list of channels when the index needs to update
    145179  static const Observable::channels_t IndexChannels;
    146180  //!> list of channels when the name needs to update
    147181  static const Observable::channels_t NameChannels;
     182  //!> list of channels when the name needs to update
     183  static const Observable::channels_t NonHydrogenCountChannels;
    148184
    149185private:
     
    154190    //!> contains the current molecule's atom count
    155191    AtomCount,
     192    //!> contains the current molecule's number of bonds
     193    BondCount,
     194    //!> contains newest version of the bounding box on request
     195    BoundingBox,
    156196    //!> contains the current molecule's formula
    157197    FormulaString,
     198    //!> contains the current molecule's center
     199    MolCenter,
    158200    //!> contains the current molecule index
    159201    MolIndex,
    160202    //!> contains the current molecule name
    161203    MolName,
    162     //!> contains newest version of the bounding box on request
    163     BoundingBox,
     204    //!> contains the current molecule's non-hydrogen atom count
     205    NonHydrogenCount,
    164206    //!> gives the size of the enumeration
    165207    MAX_ObservedTypes
Note: See TracChangeset for help on using the changeset viewer.