Changeset fe493f for src/UIElements


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:
5a9e34
Parents:
deb5ee
git-author:
Frederik Heber <heber@…> (01/20/16 20:04:06)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:40)
Message:

Extended QtObservedAtom by Name and Molecule.

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

Legend:

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

    rdeb5ee rfe493f  
    6464  channels +=
    6565      AtomObservable::IndexChanged,
    66       AtomObservable::PositionChanged,
     66      AtomObservable::BondsAdded,
     67      AtomObservable::BondsRemoved,
     68      AtomObservable::MoleculeChanged,
     69      AtomObservable::NameChanged,
    6770      AtomObservable::ElementChanged,
    68       AtomObservable::BondsAdded,
    69       AtomObservable::BondsRemoved;
     71      AtomObservable::PositionChanged;
    7072  return channels;
    7173}
     
    7577QtObservedAtom::AtomIndexChannels(1, AtomObservable::IndexChanged);
    7678const Observable::channels_t
     79QtObservedAtom::AtomBondsChannels(getAtomBondsChannels());
     80const Observable::channels_t
     81QtObservedAtom::AtomElementChannels(1, AtomObservable::ElementChanged);
     82const Observable::channels_t
     83QtObservedAtom::AtomMoleculeIndexChannels(1, AtomObservable::MoleculeChanged);
     84const Observable::channels_t
     85QtObservedAtom::AtomNameChannels(1, AtomObservable::NameChanged);
     86const Observable::channels_t
    7787QtObservedAtom::AtomPositionChannels(1, AtomObservable::PositionChanged);
    78 const Observable::channels_t
    79 QtObservedAtom::AtomElementChannels(1, AtomObservable::ElementChanged);
    80 const Observable::channels_t
    81 QtObservedAtom::AtomBondsChannels(getAtomBondsChannels());
    8288
    8389QtObservedAtom::QtObservedAtom(
     
    120126}
    121127
    122 Vector QtObservedAtom::updatePosition(
    123     const boost::function<const atomId_t ()> &_getAtomIndex)
    124 {
    125   const atom * const _atom = getAtomConst(_getAtomIndex());
    126   if (_atom != NULL) {
    127     return _atom->getPosition();
    128   } else {
    129     return zeroVec;
    130   }
    131 }
    132 
    133 atomicNumber_t QtObservedAtom::updateElement(
    134     const boost::function<const atomId_t ()> &_getAtomIndex)
    135 {
    136   const atom * const _atom = getAtomConst(_getAtomIndex());
    137   if (_atom != NULL) {
    138     return _atom->getElementNo();
    139   } else {
    140     return (atomicNumber_t)-1;
    141   }
    142 }
    143 
    144128QtObservedAtom::ListOfBonds_t QtObservedAtom::updateBonds(
    145129    const boost::function<const atomId_t ()> &_getAtomIndex)
     
    160144}
    161145
     146atomicNumber_t QtObservedAtom::updateElement(
     147    const boost::function<const atomId_t ()> &_getAtomIndex)
     148{
     149  const atom * const _atom = getAtomConst(_getAtomIndex());
     150  if (_atom != NULL) {
     151    return _atom->getElementNo();
     152  } else {
     153    return (atomicNumber_t)-1;
     154  }
     155}
     156
     157moleculeId_t QtObservedAtom::updateMoleculeIndex(
     158    const boost::function<const atomId_t ()> &_getAtomIndex)
     159{
     160  const atom * const _atom = getAtomConst(_getAtomIndex());
     161  if ((_atom != NULL) && (_atom->getMolecule() != NULL)) {
     162    return _atom->getMolecule()->getId();
     163  } else {
     164    return (moleculeId_t)0;
     165  }
     166}
     167
     168std::string QtObservedAtom::updateName(
     169    const boost::function<const atomId_t ()> &_getAtomIndex)
     170{
     171  const atom * const _atom = getAtomConst(_getAtomIndex());
     172  if (_atom != NULL) {
     173    return _atom->getName();
     174  } else {
     175    return std::string("");
     176  }
     177}
     178
     179Vector QtObservedAtom::updatePosition(
     180    const boost::function<const atomId_t ()> &_getAtomIndex)
     181{
     182  const atom * const _atom = getAtomConst(_getAtomIndex());
     183  if (_atom != NULL) {
     184    return _atom->getPosition();
     185  } else {
     186    return zeroVec;
     187  }
     188}
     189
    162190void QtObservedAtom::update(Observable *publisher)
    163191{
     
    174202
    175203    board.markObservedAtomAsDisconnected(getAtomIndex());
     204
     205    emit atomRemoved();
    176206  }
    177207}
     
    184214      emit indexChanged();
    185215      break;
    186     case AtomObservable::PositionChanged:
    187       emit positionChanged();
    188       break;
    189     case AtomObservable::ElementChanged:
    190       emit elementChanged();
    191       break;
    192216    case AtomObservable::BondsAdded:
    193217    case AtomObservable::BondsRemoved:
    194218      emit bondsChanged();
     219      break;
     220    case AtomObservable::ElementChanged:
     221      emit elementChanged();
     222      break;
     223    case AtomObservable::MoleculeChanged:
     224      emit moleculeindexChanged();
     225      break;
     226    case AtomObservable::NameChanged:
     227      emit nameChanged();
     228      break;
     229    case AtomObservable::PositionChanged:
     230      emit positionChanged();
    195231      break;
    196232    default:
     
    264300
    265301  // fill ObservedValues: then all the other that need index
     302  const boost::function<ListOfBonds_t ()> AtomBondsUpdater(
     303      boost::bind(&QtObservedAtom::updateBonds, AtomIndexGetter));
     304  const boost::function<atomicNumber_t ()> AtomElementUpdater(
     305      boost::bind(&QtObservedAtom::updateElement, AtomIndexGetter));
     306  const boost::function<moleculeId_t ()> AtomMoleculeIndexUpdater(
     307      boost::bind(&QtObservedAtom::updateMoleculeIndex, AtomIndexGetter));
     308  const boost::function<std::string ()> AtomNameUpdater(
     309      boost::bind(&QtObservedAtom::updateName, AtomIndexGetter));
    266310  const boost::function<Vector ()> AtomPositionUpdater(
    267311      boost::bind(&QtObservedAtom::updatePosition, AtomIndexGetter));
    268   const boost::function<atomicNumber_t ()> AtomElementUpdater(
    269       boost::bind(&QtObservedAtom::updateElement, AtomIndexGetter));
    270   const boost::function<ListOfBonds_t ()> AtomBondsUpdater(
    271       boost::bind(&QtObservedAtom::updateBonds, AtomIndexGetter));
    272 
     312
     313  _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>(
     314      _atomref,
     315      AtomBondsUpdater,
     316      "AtomBonds_"+toString(_id),
     317      AtomBondsUpdater(),
     318      AtomBondsChannels,
     319      _subjectKilled,
     320      AtomIndexGetter);
     321  _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>(
     322      _atomref,
     323      AtomElementUpdater,
     324      "AtomElement"+toString(_id),
     325      AtomElementUpdater(),
     326      AtomElementChannels,
     327      _subjectKilled,
     328      AtomIndexGetter);
     329  _ObservedValues[AtomMoleculeIndex] = new ObservedValue_wCallback<moleculeId_t, atomId_t>(
     330      _atomref,
     331      AtomMoleculeIndexUpdater,
     332      "AtomMoleculeIndex"+toString(_id),
     333      AtomMoleculeIndexUpdater(),
     334      AtomMoleculeIndexChannels,
     335      _subjectKilled,
     336      AtomIndexGetter);
     337  _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, atomId_t>(
     338      _atomref,
     339      AtomNameUpdater,
     340      "AtomName"+toString(_id),
     341      AtomNameUpdater(),
     342      AtomNameChannels,
     343      _subjectKilled,
     344      AtomIndexGetter);
    273345  _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, atomId_t>(
    274346      _atomref,
     
    279351      _subjectKilled,
    280352      AtomIndexGetter);
    281   _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>(
    282       _atomref,
    283       AtomElementUpdater,
    284       "AtomElement"+toString(_id),
    285       AtomElementUpdater(),
    286       AtomElementChannels,
    287       _subjectKilled,
    288       AtomIndexGetter);
    289   _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>(
    290       _atomref,
    291       AtomBondsUpdater,
    292       "AtomBonds_"+toString(_id),
    293       AtomBondsUpdater(),
    294       AtomBondsChannels,
    295       _subjectKilled,
    296       AtomIndexGetter);
    297353}
    298354
     
    301357{
    302358  delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[AtomIndex]);
     359  delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(_ObservedValues[AtomBonds]);
     360  delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(_ObservedValues[AtomElement]);
     361  delete boost::any_cast<ObservedValue_wCallback<moleculeId_t, atomId_t> *>(_ObservedValues[AtomMoleculeIndex]);
     362  delete boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(_ObservedValues[AtomName]);
    303363  delete boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(_ObservedValues[AtomPosition]);
    304   delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(_ObservedValues[AtomElement]);
    305   delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(_ObservedValues[AtomBonds]);
    306364  _ObservedValues.clear();
    307365}
     
    312370}
    313371
     372QtObservedAtom::ListOfBonds_t QtObservedAtom::getAtomBonds() const
     373{
     374  return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->get();
     375}
     376
     377atomicNumber_t QtObservedAtom::getAtomElement() const
     378{
     379  return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->get();
     380}
     381
     382moleculeId_t QtObservedAtom::getAtomMoleculeIndex() const
     383{
     384  return boost::any_cast<ObservedValue_wCallback<moleculeId_t, atomId_t> *>(ObservedValues[AtomMoleculeIndex])->get();
     385}
     386
     387std::string QtObservedAtom::getAtomName() const
     388{
     389  return boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(ObservedValues[AtomName])->get();
     390}
     391
    314392Vector QtObservedAtom::getAtomPosition() const
    315393{
    316394  return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->get();
    317395}
    318 
    319 atomicNumber_t QtObservedAtom::getAtomElement() const
    320 {
    321   return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->get();
    322 }
    323 
    324 QtObservedAtom::ListOfBonds_t QtObservedAtom::getAtomBonds() const
    325 {
    326   return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->get();
    327 }
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp

    rdeb5ee rfe493f  
    8989  atomId_t getAtomIndex() const;
    9090
    91   /** Getter to atom position contained in \a ObservedValues.
    92    *
    93    * \return atom's position
    94    */
    95   Vector getAtomPosition() const;
    96 
    97   /** Getter to atom element contained in \a ObservedValues.
    98    *
    99    * \return atom's elemnt
    100    */
    101   atomicNumber_t getAtomElement() const;
    102 
    10391  //!> typedef for list of bonds, defined by pairs of atom ids
    10492  typedef std::vector< std::pair<atomId_t, atomId_t> > ListOfBonds_t;
     
    11098  ListOfBonds_t getAtomBonds() const;
    11199
     100  /** Getter to atom element contained in \a ObservedValues.
     101   *
     102   * \return atom's element
     103   */
     104  atomicNumber_t getAtomElement() const;
     105
     106  /** Getter to atom name contained in \a ObservedValues.
     107   *
     108   * \return atom's name
     109   */
     110  std::string getAtomName() const;
     111
     112  /** Getter to atom position contained in \a ObservedValues.
     113   *
     114   * \return atom's position
     115   */
     116  Vector getAtomPosition() const;
     117
     118  /** Getter to atom's molecule index contained in \a ObservedValues.
     119   *
     120   * \return atom's molecule index
     121   */
     122  moleculeId_t getAtomMoleculeIndex() const;
     123
    112124signals:
    113125  void indexChanged();
     126  void bondsChanged();
     127  void elementChanged();
     128  void moleculeindexChanged();
     129  void nameChanged();
    114130  void positionChanged();
    115   void elementChanged();
    116   void bondsChanged();
     131  void atomRemoved();
    117132
    118133//private slots:
     
    127142private:
    128143  static atomId_t updateIndex();
     144  static ListOfBonds_t updateBonds(
     145      const boost::function<const atomId_t ()> &_getAtomIndex);
     146  static atomicNumber_t updateElement(
     147      const boost::function<const atomId_t ()> &_getAtomIndex);
     148  static moleculeId_t updateMoleculeIndex(
     149      const boost::function<const atomId_t ()> &_getAtomIndex);
     150  static std::string updateName(
     151      const boost::function<const atomId_t ()> &_getAtomIndex);
    129152  static Vector updatePosition(
    130       const boost::function<const atomId_t ()> &_getAtomIndex);
    131   static atomicNumber_t updateElement(
    132       const boost::function<const atomId_t ()> &_getAtomIndex);
    133   static ListOfBonds_t updateBonds(
    134153      const boost::function<const atomId_t ()> &_getAtomIndex);
    135154
     
    138157    //!> contains the current atom index
    139158    AtomIndex,
     159    //!> contains the current set of bonds atoms for the atom
     160    AtomBonds,
     161    //!> contains the current atom element
     162    AtomElement,
     163    //!> contains the current atom's molecule index
     164    AtomMoleculeIndex,
     165    //!> contains the current atom position
     166    AtomName,
    140167    //!> contains the current atom position
    141168    AtomPosition,
    142     //!> contains the current atom element
    143     AtomElement,
    144     //!> contains the current set of bonds atoms fort the atom
    145     AtomBonds,
    146169    //!> gives the size of the enumeration
    147170    MAX_ObservedTypes
     
    175198  //!> list of channels when index needs to update
    176199  static const Observable::channels_t AtomIndexChannels;
     200  //!> list of channels when bonds needs to update
     201  static const Observable::channels_t AtomBondsChannels;
     202  //!> list of channels when element needs to update
     203  static const Observable::channels_t AtomElementChannels;
     204  //!> list of channels when molecule index needs to update
     205  static const Observable::channels_t AtomMoleculeIndexChannels;
     206  //!> list of channels when name needs to update
     207  static const Observable::channels_t AtomNameChannels;
    177208  //!> list of channels when position needs to update
    178209  static const Observable::channels_t AtomPositionChannels;
    179   //!> list of channels when element needs to update
    180   static const Observable::channels_t AtomElementChannels;
    181   //!> list of channels when bonds needs to update
    182   static const Observable::channels_t AtomBondsChannels;
    183210
    184211  //!> we get multiple subjectKilled(), count and call callback() only on last
Note: See TracChangeset for help on using the changeset viewer.