Changeset 897a01 for src/UIElements/Qt4


Ignore:
Timestamp:
Apr 11, 2018, 6:29:56 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.6.1, ChemicalSpaceEvaluator, Gui_displays_atomic_force_velocity, PythonUI_with_named_parameters, TremoloParser_IncreasedPrecision
Children:
8ac6d0e
Parents:
8450da
git-author:
Frederik Heber <frederik.heber@…> (08/08/17 21:26:57)
git-committer:
Frederik Heber <frederik.heber@…> (04/11/18 06:29:56)
Message:

Arrows display velocity and force of each atom.

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

Legend:

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

    r8450da r897a01  
    8989QtObservedAtom::AtomPositionChannels(1, AtomObservable::PositionChanged);
    9090const Observable::channels_t
     91QtObservedAtom::AtomVelocityChannels(1, AtomObservable::VelocityChanged);
     92const Observable::channels_t
     93QtObservedAtom::AtomForceChannels(1, AtomObservable::ForceChanged);
     94const Observable::channels_t
    9195QtObservedAtom::AtomSelectedChannels(1, AtomObservable::SelectionChanged);
    9296
     
    124128  boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[AtomName])->noteCallBackIsGone();
    125129  boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomPosition])->noteCallBackIsGone();
     130  boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomVelocity])->noteCallBackIsGone();
     131  boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomForce])->noteCallBackIsGone();
    126132  boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[AtomSelected])->noteCallBackIsGone();
    127133
     
    215221inline
    216222#endif
     223Vector QtObservedAtom::updateVelocity(
     224    const atom &_atom)
     225{
     226  return _atom.getAtomicVelocity();
     227}
     228
     229#ifdef HAVE_INLINE
     230inline
     231#endif
     232Vector QtObservedAtom::updateForce(
     233    const atom &_atom)
     234{
     235  return _atom.getAtomicForce();
     236}
     237
     238#ifdef HAVE_INLINE
     239inline
     240#endif
    217241bool QtObservedAtom::updateSelected(
    218242    const atom &_atom)
     
    269293    boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(
    270294        ObservedValues[AtomPosition])->forceUpdate();
     295    boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(
     296        ObservedValues[AtomVelocity])->forceUpdate();
     297    boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(
     298        ObservedValues[AtomForce])->forceUpdate();
    271299    boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(
    272300        ObservedValues[MoleculeRef])->forceUpdate();
    273301    // then tell Qt part about updates
    274302    emit positionChanged();
     303    emit velocityChanged();
     304    emit forceChanged();
    275305    emit moleculeChanged();
    276306  } else {
     
    296326      case AtomObservable::PositionChanged:
    297327        emit positionChanged();
     328        break;
     329      case AtomObservable::VelocityChanged:
     330        emit velocityChanged();
     331        break;
     332      case AtomObservable::ForceChanged:
     333        emit forceChanged();
    298334        break;
    299335      case AtomObservable::SelectionChanged:
     
    362398  const boost::function<Vector ()> AtomPositionUpdater(
    363399      boost::bind(&QtObservedAtom::updatePosition, boost::cref(*_atomref)));
     400  const boost::function<Vector ()> AtomVelocityUpdater(
     401      boost::bind(&QtObservedAtom::updateVelocity, boost::cref(*_atomref)));
     402  const boost::function<Vector ()> AtomForceUpdater(
     403      boost::bind(&QtObservedAtom::updateForce, boost::cref(*_atomref)));
    364404  const boost::function<bool ()> AtomSelectedUpdater(
    365405      boost::bind(&QtObservedAtom::updateSelected, boost::cref(*_atomref)));
     
    401441      AtomPositionUpdater(),
    402442      AtomPositionChannels,
     443      _subjectKilled);
     444  _ObservedValues[AtomVelocity] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
     445      _atomref,
     446      AtomVelocityUpdater,
     447      "AtomVelocity_"+toString(_id),
     448      AtomVelocityUpdater(),
     449      AtomVelocityChannels,
     450      _subjectKilled);
     451  _ObservedValues[AtomForce] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
     452      _atomref,
     453      AtomForceUpdater,
     454      "AtomForce_"+toString(_id),
     455      AtomForceUpdater(),
     456      AtomForceChannels,
    403457      _subjectKilled);
    404458  _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>(
     
    426480  delete boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(_ObservedValues[AtomName]);
    427481  delete boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(_ObservedValues[AtomPosition]);
     482  delete boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(_ObservedValues[AtomVelocity]);
     483  delete boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(_ObservedValues[AtomForce]);
    428484  delete boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(_ObservedValues[AtomSelected]);
    429485  delete boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(_ObservedValues[MoleculeRef]);
     
    463519}
    464520
     521const Vector& QtObservedAtom::getAtomVelocity() const
     522{
     523  return boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomVelocity])->get();
     524}
     525
     526const Vector& QtObservedAtom::getAtomForce() const
     527{
     528  return boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomForce])->get();
     529}
     530
    465531const bool QtObservedAtom::getAtomSelected() const
    466532{
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp

    r8450da r897a01  
    136136  const Vector& getAtomPosition() const;
    137137
     138  /** Getter to atom velocity contained in \a ObservedValues.
     139   *
     140   * \return atom's velocity
     141   */
     142  const Vector& getAtomVelocity() const;
     143
     144  /** Getter to atom force contained in \a ObservedValues.
     145   *
     146   * \return atom's force
     147   */
     148  const Vector& getAtomForce() const;
     149
    138150  /** Getter to the observed state of the associated molecule.
    139151   *
     
    155167  void nameChanged();
    156168  void positionChanged();
     169  void velocityChanged();
     170  void forceChanged();
    157171  void atomRemoved();
    158172  void selectedChanged();
     
    174188  static std::string updateName(const atom &_atom);
    175189  static Vector updatePosition(const atom &_atom);
     190  static Vector updateVelocity(const atom &_atom);
     191  static Vector updateForce(const atom &_atom);
    176192  static bool updateSelected(const atom &_atom);
    177193
     
    188204    //!> contains the current atom position
    189205    AtomPosition,
     206    //!> contains the current atom velocity
     207    AtomVelocity,
     208    //!> contains the current atom force
     209    AtomForce,
    190210    //!> contains the current atom's selection status
    191211    AtomSelected,
     
    253273  //!> list of channels when position needs to update
    254274  static const Observable::channels_t AtomPositionChannels;
     275  //!> list of channels when velocity needs to update
     276  static const Observable::channels_t AtomVelocityChannels;
     277  //!> list of channels when force needs to update
     278  static const Observable::channels_t AtomForceChannels;
    255279  //!> list of channels when selection needs to update
    256280  static const Observable::channels_t AtomSelectedChannels;
Note: See TracChangeset for help on using the changeset viewer.