Ignore:
Timestamp:
Feb 12, 2016, 11:15:39 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:
ca1535
Parents:
ab628c
git-author:
Frederik Heber <heber@…> (10/29/15 21:55:51)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:39)
Message:

Added AtomCount and FormulaChanged to QtObservedMolecule.

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

Legend:

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

    rab628c r1b6415a  
    6060      molecule::AtomInserted,
    6161      molecule::AtomRemoved,
     62      molecule::FormulaChanged,
    6263      molecule::IndexChanged,
    6364      molecule::MoleculeNameChanged,
     
    6667}
    6768
     69static const Observable::channels_t getAllAtomCountChannels()
     70{
     71  Observable::channels_t channels;
     72  channels +=
     73      molecule::AtomInserted,
     74      molecule::AtomRemoved;
     75  return channels;
     76}
     77
    6878// static instances
     79const Observable::channels_t QtObservedMolecule::AtomCountChannels(getAllAtomCountChannels());
    6980const Observable::channels_t QtObservedMolecule::BoundingBoxChannels(1, molecule::BoundingBoxChanged);
     81const Observable::channels_t QtObservedMolecule::FormulaStringChannels(1, molecule::FormulaChanged);
    7082const Observable::channels_t QtObservedMolecule::IndexChannels(1, molecule::IndexChanged);
    7183const Observable::channels_t QtObservedMolecule::NameChannels(1, molecule::MoleculeNameChanged);
     
    154166      {
    155167        const atomId_t _id = _molecule->lastChangedAtomId();
     168        emit atomcountChanged();
    156169        emit atomInserted(_id);
    157170        break;
     
    160173      {
    161174        const atomId_t _id = _molecule->lastChangedAtomId();
     175        emit atomcountChanged();
    162176        emit atomRemoved(_id);
    163177        break;
     
    170184        emit tesselationhullChanged();
    171185        emit boundingboxChanged();
     186        break;
     187      }
     188      case molecule::FormulaChanged:
     189      {
     190        emit formulaChanged();
    172191        break;
    173192      }
     
    246265
    247266  // fill ObservedValues: then all the other that need index
     267  const boost::function<int ()> AtomCountUpdater(
     268      boost::bind(&QtObservedMolecule::updateAtomCount, MolIndexGetter));
     269  const boost::function<std::string ()> MolFormulaUpdater(
     270      boost::bind(&QtObservedMolecule::updateFormulaString, MolIndexGetter));
    248271  const boost::function<std::string ()> MolNameUpdater(
    249272      boost::bind(&QtObservedMolecule::updateName, MolIndexGetter));
     
    251274      boost::bind(&QtObservedMolecule::updateBoundingBox, MolIndexGetter));
    252275
    253   _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>(
     276  _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, moleculeId_t>(
    254277      _molref,
    255       MolNameUpdater,
    256       "MoleculeName_"+toString(_molid),
    257       MolNameUpdater(),
    258       NameChannels,
     278      AtomCountUpdater,
     279      "MoleculeAtomCount_"+toString(_molid),
     280      AtomCountUpdater(),
     281      AtomCountChannels,
    259282      _subjectKilled,
    260283      MolIndexGetter);
     
    267290      _subjectKilled,
    268291      MolIndexGetter);
     292  _ObservedValues[FormulaString] = new ObservedValue_wCallback<std::string, moleculeId_t>(
     293      _molref,
     294      MolFormulaUpdater,
     295      "MoleculeFormula_"+toString(_molid),
     296      MolFormulaUpdater(),
     297      FormulaStringChannels,
     298      _subjectKilled,
     299      MolIndexGetter);
     300  _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>(
     301      _molref,
     302      MolNameUpdater,
     303      "MoleculeName_"+toString(_molid),
     304      MolNameUpdater(),
     305      NameChannels,
     306      _subjectKilled,
     307      MolIndexGetter);
    269308}
    270309
     
    273312{
    274313  delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]);
     314  delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[AtomCount]);
     315  delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[FormulaString]);
     316  delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);
    275317  delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]);
    276   delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);
    277318  _ObservedValues.clear();
     319}
     320
     321int QtObservedMolecule::updateAtomCount(
     322    const boost::function<const moleculeId_t ()> &_getMolIndex)
     323{
     324  const molecule * const mol = getMolecule(_getMolIndex());
     325  if (mol != NULL)
     326    return mol->getAtomCount();
     327  else
     328    return (int)0;
    278329}
    279330
     
    288339}
    289340
     341std::string QtObservedMolecule::updateFormulaString(
     342    const boost::function<const moleculeId_t ()> &_getMolIndex)
     343{
     344  const molecule * const mol = getMolecule(_getMolIndex());
     345  if (mol != NULL)
     346    return mol->getFormula().toString();
     347  else
     348    return std::string("");
     349}
     350
    290351moleculeId_t QtObservedMolecule::updateIndex()
    291352{
     
    303364}
    304365
     366int QtObservedMolecule::getAtomCount() const
     367{
     368  return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->get();
     369}
     370
     371std::string QtObservedMolecule::getMolFormula() const
     372{
     373  return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->get();
     374}
     375
    305376moleculeId_t QtObservedMolecule::getMolIndex() const
    306377{
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp

    rab628c r1b6415a  
    7878  void recieveNotification(Observable *publisher, Notification_ptr notification);
    7979
     80  /** Getter to molecule atom count contained in \a ObservedValues.
     81   *
     82   * \return molecule's atom count
     83   */
     84  int getAtomCount() const;
     85
    8086  /** Getter to molecule index contained in \a ObservedValues.
    8187   *
     
    9096  std::string getMolName() const;
    9197
     98  /** Getter to molecule formula contained in \a ObservedValues.
     99   *
     100   * \return molecule's formula
     101   */
     102  std::string getMolFormula() const;
     103
    92104  /** Getter to molecule's bounding box contained in \a ObservedValues.
    93105   *
     
    99111
    100112signals:
     113  void atomcountChanged();
     114  void formulaChanged();
    101115  void indexChanged();
    102116  void nameChanged();
     
    112126
    113127private:
     128  static int updateAtomCount(
     129      const boost::function<const moleculeId_t ()> &_getMolIndex);
    114130  static molecule::BoundingBoxInfo updateBoundingBox(
     131      const boost::function<const moleculeId_t ()> &_getMolIndex);
     132  static std::string updateFormulaString(
    115133      const boost::function<const moleculeId_t ()> &_getMolIndex);
    116134  static moleculeId_t updateIndex();
     
    118136      const boost::function<const moleculeId_t ()> &_getMolIndex);
    119137
     138  //!> list of channels when atom count needs to update
     139  static const Observable::channels_t AtomCountChannels;
    120140  //!> list of channels when bounding box needs to update
    121141  static const Observable::channels_t BoundingBoxChannels;
     142  //!> list of channels when formula needs to update
     143  static const Observable::channels_t FormulaStringChannels;
    122144  //!> list of channels when the index needs to update
    123145  static const Observable::channels_t IndexChannels;
     
    130152  //!> enumeration of observed values to match with entries in ObservedValues
    131153  enum ObservedTypes {
     154    //!> contains the current molecule's atom count
     155    AtomCount,
     156    //!> contains the current molecule's formula
     157    FormulaString,
    132158    //!> contains the current molecule index
    133159    MolIndex,
Note: See TracChangeset for help on using the changeset viewer.