Changeset 8d56a6 for src


Ignore:
Timestamp:
Jun 21, 2018, 8:31:25 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.6.1, ChemicalSpaceEvaluator
Children:
d83d64, f5ea10
Parents:
3e334e (diff), 4fc0ea (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'TremoloParser_IncreasedPrecision' into Candidate_v1.6.1

Conflicts:

tests/Python/ForceAnnealing/post/five_carbon_test_bondgraph.data
tests/Python/ForceAnnealing/post/five_carbon_test_no-bondgraph.data

Location:
src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.hpp

    r3e334e r8d56a6  
    1414#endif
    1515
     16#include <algorithm>
    1617#include <iosfwd>
    1718#include <string>
     
    2425 */
    2526#define NOPARAM_DEFAULT BOOST_PP_NIL
     27
     28namespace MoleCuilder {
     29  //!> helps normalizing Action's tokens for use as Python parameter names
     30#ifdef HAVE_INLINE
     31  inline
     32#endif
     33  std::string normalizeToken(std::string _token) {
     34    std::replace(_token.begin(), _token.end(), '-', '_');
     35    return _token;
     36  }
     37} /* namespace MoleCuilder */
    2638
    2739/** Nicely visible short-hand for push a status message
  • src/Actions/Action_impl_pre.hpp

    r3e334e r8d56a6  
    173173    output << \
    174174    BOOST_PP_IF(n, ", ", "") \
     175    << normalizeToken( BOOST_PP_SEQ_ELEM(n, paramtokens) ) \
     176    << "=" \
    175177    << "\"" << params. \
    176178        BOOST_PP_SEQ_ELEM(n, paramreferences) \
    177         .getAsStringUnvalidated() \
    178     << "\"";
     179          .getAsStringUnvalidated() \
     180    << "\""; \
    179181
    180182// print an initialiser list, i.e. "var( token, valid (,default) )(,)"
  • src/Actions/Action_impl_python.hpp

    r3e334e r8d56a6  
    7777  BOOST_PP_COMMA_IF(n) \
    7878  boost::python::arg( \
    79   BOOST_PP_SEQ_ELEM(n, STRINGLIST) \
     79                  MoleCuilder::normalizeToken( BOOST_PP_SEQ_ELEM(n, STRINGLIST) ).c_str() \
    8080  ) \
    8181  = \
     
    9292  BOOST_PP_COMMA_IF(n) \
    9393  boost::python::arg( \
    94   BOOST_PP_SEQ_ELEM(n, STRINGLIST) \
     94                  MoleCuilder::normalizeToken( BOOST_PP_SEQ_ELEM(n, STRINGLIST) ).c_str() \
    9595  )
    9696
  • src/Actions/MakroAction_impl_pre.hpp

    r3e334e r8d56a6  
    165165    output << \
    166166    BOOST_PP_IF(n, ", ", "") \
     167          << normalizeToken( BOOST_PP_SEQ_ELEM(n, paramtokens) ) \
     168          << "=" \
    167169    << "\"" << params. \
    168170        BOOST_PP_SEQ_ELEM(n, paramreferences) \
  • src/Atom/atom_atominfo.cpp

    r3e334e r8d56a6  
    191191{
    192192  OBSERVE;
    193   NOTIFY(AtomObservable::PositionChanged);
    194193  VectorTrajectory_t::iterator iter = AtomicPosition.find(_step);
    195194  if (iter !=  AtomicPosition.end()) {
    196195    iter->second[i] = value;
    197196  } else {
     197    NOTIFY(TrajectoryChanged);
    198198    Vector newPos;
    199199    newPos[i] = value;
     
    206206        +" present after all?");
    207207  }
     208  if (WorldTime::getTime() == _step)
     209    NOTIFY(AtomObservable::PositionChanged);
    208210}
    209211
     
    278280    iter->second = _newvelocity;
    279281  } else {
     282    NOTIFY(TrajectoryChanged);
    280283#ifndef NDEBUG
    281284    std::pair<VectorTrajectory_t::iterator, bool> inserter =
     
    320323    iter->second = _newforce;
    321324  } else {
     325    NOTIFY(TrajectoryChanged);
    322326#ifndef NDEBUG
    323327    std::pair<VectorTrajectory_t::iterator, bool> inserter =
  • src/Parser/TremoloParser.cpp

    r3e334e r8d56a6  
    510510      << currentAtom->GetTrueFather()->getId() << " at time step " << _timestep);
    511511
     512  // note down default precision
     513  std::streamsize defaultprecision=file->precision();
     514  std::streamsize highprecision=10;
     515
    512516  for (usedFields_t::iterator it = usedFields_save.begin(); it != usedFields_save.end(); it++) {
    513517    currentField = knownKeys[it->substr(0, it->find("="))];
     
    516520        // for the moment, assume there are always three dimensions
    517521        LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getPositionAtStep(_timestep));
     522        file->precision(highprecision);
    518523        *file << currentAtom->atStep(0, _timestep) << "\t";
    519524        *file << currentAtom->atStep(1, _timestep) << "\t";
    520525        *file << currentAtom->atStep(2, _timestep) << "\t";
     526        file->precision(defaultprecision);
    521527        break;
    522528      case TremoloKey::u :
    523529        // for the moment, assume there are always three dimensions
    524530        LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getAtomicVelocityAtStep(_timestep));
     531        file->precision(highprecision);
    525532        *file << currentAtom->getAtomicVelocityAtStep(_timestep)[0] << "\t";
    526533        *file << currentAtom->getAtomicVelocityAtStep(_timestep)[1] << "\t";
    527534        *file << currentAtom->getAtomicVelocityAtStep(_timestep)[2] << "\t";
     535        file->precision(defaultprecision);
    528536        break;
    529537      case TremoloKey::F :
    530538        // for the moment, assume there are always three dimensions
    531539        LOG(3, "Writing for type " << knownKeyNames[currentField] << ": " << currentAtom->getAtomicForceAtStep(_timestep));
     540        file->precision(highprecision);
    532541        *file << currentAtom->getAtomicForceAtStep(_timestep)[0] << "\t";
    533542        *file << currentAtom->getAtomicForceAtStep(_timestep)[1] << "\t";
    534543        *file << currentAtom->getAtomicForceAtStep(_timestep)[2] << "\t";
     544        file->precision(defaultprecision);
    535545        break;
    536546      case TremoloKey::type :
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp

    r3e334e r8d56a6  
    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

    r3e334e r8d56a6  
    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;
  • src/UIElements/Qt4/QtMainWindow.hpp

    r3e334e r8d56a6  
    3232class QtMoleculeList;
    3333class QtShapeController;
     34class QtTimeLine;
    3435class StringView;
    3536class GLWorldView;
     
    3839class QtToolBar;
    3940class QCloseEvent;
    40 class QSlider;
    4141
    4242class QtObservedInstanceBoard;
     
    7070  QtMenu<QMenuBar> *MainMenu;
    7171  QtToolBar *toolbar;
    72   QSlider *timeline;
     72  QtTimeLine *timeline;
    7373  QtLogBox *logBox;
    7474  QtLogBox *errorlogBox;
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp

    r3e334e r8d56a6  
    6161QGLMaterial *GLMoleculeObject::m_selectionMaterial = NULL;
    6262QGLMaterial *GLMoleculeObject::m_selectionBoxMaterial = NULL;
     63QGLMaterial *GLMoleculeObject::m_velocityMaterial = NULL;
     64QGLMaterial *GLMoleculeObject::m_forceMaterial = NULL;
    6365
    6466QGLSceneNode *GLMoleculeObject::meshEmpty[GLMoleculeObject::DETAILTYPES_MAX];
    6567QGLSceneNode *GLMoleculeObject::meshSphere[GLMoleculeObject::DETAILTYPES_MAX];
    6668QGLSceneNode *GLMoleculeObject::meshCylinder[GLMoleculeObject::DETAILTYPES_MAX];
     69QGLSceneNode *GLMoleculeObject::meshArrow[GLMoleculeObject::DETAILTYPES_MAX];
    6770
    6871double GLMoleculeObject::detailMinDistance[GLMoleculeObject::DETAILTYPES_MAX] = {0, 15, 30, 42};
     
    309312    m_selectionBoxMaterial->setEmittedLight( QColor(155, 50, 50) );
    310313  }
     314  if (!m_velocityMaterial){
     315    m_velocityMaterial = new QGLMaterial(NULL);
     316    QColor colorvelocity(50,50,255,255);
     317    m_velocityMaterial->setColor(colorvelocity);
     318  }
     319  if (!m_forceMaterial){
     320    m_forceMaterial = new QGLMaterial(NULL);
     321    QColor colorforce(50,255,50,255);
     322    m_forceMaterial->setColor(colorforce);
     323  }
    311324}
    312325
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp

    r3e334e r8d56a6  
    108108   static QGLSceneNode *meshSphere[DETAILTYPES_MAX];
    109109   static QGLSceneNode *meshCylinder[DETAILTYPES_MAX];
     110   static QGLSceneNode *meshArrow[DETAILTYPES_MAX];
    110111
    111112protected:
     
    130131   static QGLMaterial *m_selectionMaterial;
    131132   static QGLMaterial *m_selectionBoxMaterial;
     133   static QGLMaterial *m_velocityMaterial;
     134   static QGLMaterial *m_forceMaterial;
    132135   QGLAbstractEffect *m_effect;
    133136   int m_objectId;
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp

    r3e334e r8d56a6  
    5050#include "Element/element.hpp"
    5151#include "Element/periodentafel.hpp"
     52#include "LinearAlgebra/Line.hpp"
    5253#include "LinearAlgebra/Vector.hpp"
    5354#include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp"
     
    5758GLMoleculeObject_atom::GLMoleculeObject_atom(
    5859    QGLSceneNode *mesh[],
     60    QGLSceneNode *mesharrow[],
    5961    QObject *parent,
    6062    QtObservedAtom::ptr &_ObservedAtom) :
    6163  GLMoleculeObject(mesh, parent),
     64  GLMoleculeObjectVelocity(mesharrow, this),
     65  GLMoleculeObjectForce(mesharrow, this),
    6266  ObservedAtom(_ObservedAtom)
    6367{
     
    6973  setObjectId(_id);
    7074  resetPosition();
     75  resetVelocity();
     76  resetForce();
    7177  resetElement();
     78
     79  GLMoleculeObjectVelocity.setMaterial(GLMoleculeObject::m_velocityMaterial);
     80  GLMoleculeObjectForce.setMaterial(GLMoleculeObject::m_forceMaterial);
    7281
    7382  m_selected = ObservedAtom->getAtomSelected();
     
    7786  connect( ObservedAtom.get(), SIGNAL(elementChanged()), this, SLOT(resetElement()));
    7887  connect( ObservedAtom.get(), SIGNAL(positionChanged()), this, SLOT(resetPosition()));
     88  connect( ObservedAtom.get(), SIGNAL(velocityChanged()), this, SLOT(resetVelocity()));
     89  connect( ObservedAtom.get(), SIGNAL(forceChanged()), this, SLOT(resetForce()));
    7990  connect( ObservedAtom.get(), SIGNAL(selectedChanged()), this, SLOT(resetSelected()));
    8091}
     
    95106}
    96107
     108static void setArrow(
     109    const Vector &_position,
     110    const Vector &_arrow,
     111    const double _offset,
     112    GLMoleculeObject &_obj)
     113{
     114  // set position (cylinder offset is in its barymetric center)
     115  Vector OneFourth(_position + (_offset/_arrow.Norm()+.75) * _arrow);
     116  _obj.setPosition(QVector3D(OneFourth[0], OneFourth[1], OneFourth[2]));
     117}
     118
    97119void GLMoleculeObject_atom::resetPosition()
    98120{
     
    100122  LOG(4, "INFO: GLMoleculeObject_atom::resetPosition() - new position is "+toString(Position)+".");
    101123  setPosition(QVector3D(Position[0], Position[1], Position[2]));
     124  setArrow(Position, 10.*ObservedAtom->getAtomVelocity(), scaleX(), GLMoleculeObjectVelocity);
     125  setArrow(Position, 10.*ObservedAtom->getAtomForce(), scaleX(), GLMoleculeObjectForce);
     126}
     127
     128static void alignArrow(
     129    const Vector &_arrow,
     130    GLMoleculeObject &_obj)
     131{
     132  if (_arrow.IsZero()) {
     133    _obj.setScaleZ(0.);
     134    return;
     135  }
     136  // calculate position
     137  Vector Z(unitVec[2]); // cylinder are initially aligned along the Z axis
     138  Vector b;
     139  Vector OtherAxis;
     140  double alpha;
     141  // construct rotation axis
     142  b = -1.*_arrow;
     143  b.VectorProduct(Z);
     144  Line axis(zeroVec, b);
     145  // calculate rotation angle
     146  alpha = _arrow.Angle(Z);
     147  // construct other axis to check right-hand rule
     148  OtherAxis = b;
     149  OtherAxis.VectorProduct(Z);
     150  // assure right-hand rule for the rotation
     151  if (_arrow.ScalarProduct(OtherAxis) < MYEPSILON)
     152    alpha = M_PI-alpha;
     153  // check
     154  Vector a_rotated = axis.rotateVector(_arrow, alpha);
     155  LOG(5, "DEBUG: Aligning arrow " << _arrow << " to " << a_rotated
     156      << " around " << b << " by " << alpha/M_PI*180. << ".");
     157
     158  _obj.setScaleZ(10.*_arrow.Norm());
     159  _obj.setRotationVector(QVector3D(b[0], b[1], b[2]));
     160  _obj.setRotationAngle(alpha/M_PI*180.);
     161}
     162
     163void GLMoleculeObject_atom::resetVelocity()
     164{
     165  const Vector Velocity = ObservedAtom->getAtomVelocity();
     166  LOG(4, "INFO: GLMoleculeObject_atom::resetVelocity() - new velocity is "+toString(Velocity)+".");
     167  alignArrow(Velocity, GLMoleculeObjectVelocity);
     168//  GLMoleculeObjectForce.setScaleZ(Velocity.Norm());
     169}
     170
     171void GLMoleculeObject_atom::resetForce()
     172{
     173  const Vector Force = ObservedAtom->getAtomForce();
     174  LOG(4, "INFO: GLMoleculeObject_atom::resetForce() - new force is "+toString(Force)+".");
     175  alignArrow(Force, GLMoleculeObjectForce);
     176//  GLMoleculeObjectForce.setScaleZ(Force.Norm());
    102177}
    103178
     
    144219  // call old hook to do the actual paining
    145220  GLMoleculeObject::draw(painter, cameraPlane);
     221  GLMoleculeObjectVelocity.draw(painter, cameraPlane);
     222  GLMoleculeObjectForce.draw(painter, cameraPlane);
    146223}
    147224
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp

    r3e334e r8d56a6  
    3434  GLMoleculeObject_atom(
    3535      QGLSceneNode *mesh[],
     36      QGLSceneNode *mesharrow[],
    3637      QObject *parent,
    3738      QtObservedAtom::ptr &_ObservedAtom
     
    4647  void resetElement();
    4748  void resetPosition();
     49  void resetVelocity();
     50  void resetForce();
    4851  void resetSelected();
    4952
     
    5861
    5962private:
     63  //!> internal GLMoleculeObject to represent the atom's velocity as an arrow
     64  GLMoleculeObject GLMoleculeObjectVelocity;
     65  //!> internal GLMoleculeObject to represent the atom's force as an arrow
     66  GLMoleculeObject GLMoleculeObjectForce;
     67
    6068  //!> current list of bonds to compare new onw against for changes
    6169  QtObservedAtom::ListOfBonds_t ListOfBonds;
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r3e334e r8d56a6  
    154154  int sphereDetails[] = {5, 3, 2, 0};
    155155  int cylinderDetails[] = {16, 8, 6, 3};
     156  int arrowDetails[] = {8, 5, 3, 0};
    156157  for (int i=0;i<GLMoleculeObject::DETAILTYPES_MAX;i++){
    157158    QGLBuilder emptyBuilder;
     
    165166    GLMoleculeObject::meshCylinder[i] = cylinderBuilder.finalizedSceneNode();
    166167    GLMoleculeObject::meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true);
     168    {
     169      QGLBuilder builderCyl;
     170      builderCyl << QGLCylinder(.15,.15,1.6,arrowDetails[i]);
     171      QGLSceneNode *cyl = builderCyl.finalizedSceneNode();
     172      QGLBuilder builderCone;
     173      builderCone << QGLCylinder(0,.4,0.4,arrowDetails[i]);
     174      QGLSceneNode *cone = builderCone.finalizedSceneNode();
     175      {
     176        QMatrix4x4 mat;
     177        mat.translate(0.0f, 0.0f, 1.0f);
     178        cone->setLocalTransform(mat);
     179      }
     180      GLMoleculeObject::meshArrow[i] = new QGLSceneNode(this);
     181      GLMoleculeObject::meshArrow[i]->addNode(cyl);
     182      GLMoleculeObject::meshArrow[i]->addNode(cone);
     183    }
     184    GLMoleculeObject::meshArrow[i]->setOption(QGLSceneNode::CullBoundingBox, true);
    167185  }
    168186  connect(board, SIGNAL(moleculeInserted(QtObservedMolecule::ptr)),
     
    279297    atomObject = new GLMoleculeObject_atom(
    280298            GLMoleculeObject::meshSphere,
     299            GLMoleculeObject::meshArrow,
    281300            parent,
    282301            _atom);
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp

    r3e334e r8d56a6  
    9393//  connect(this, SIGNAL(TimeChanged()), worldscene, SIGNAL(updated()));
    9494  connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled()));
    95   connect(worldscene, SIGNAL(changed()), this, SIGNAL(changed()));
     95  connect(this, SIGNAL(changed()), this, SLOT(changeSignalled()));
    9696  connect(worldscene, SIGNAL(hoverChanged(const atomId_t)), this, SLOT(sceneHoverSignalled(const atomId_t)));
    9797  connect(worldscene, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SLOT(sceneHoverSignalled(const moleculeId_t, int)));
    9898  //connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
    99   connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
     99  connect(worldscene, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
    100100  connect(this, SIGNAL(moleculesVisibilityChanged(ObservedValue_Index_t,bool)),
    101101      worldscene, SLOT(moleculesVisibilityChanged(ObservedValue_Index_t,bool)));
     
    104104  WorldTime::getInstance().signOn(this, WorldTime::TimeChanged);
    105105  AtomObserver::getInstance().signOn(this, AtomObservable::PositionChanged);
     106  AtomObserver::getInstance().signOn(this, AtomObservable::VelocityChanged);
     107  AtomObserver::getInstance().signOn(this, AtomObservable::ForceChanged);
    106108
    107109  ShapeRegistry::getInstance().signOn(this);
     
    124126  WorldTime::getInstance().signOff(this, WorldTime::TimeChanged);
    125127  AtomObserver::getInstance().signOff(this, AtomObservable::PositionChanged);
     128  AtomObserver::getInstance().signOff(this, AtomObservable::VelocityChanged);
     129  AtomObserver::getInstance().signOff(this, AtomObservable::ForceChanged);
    126130  ShapeRegistry::getInstance().signOff(this);
    127131  ShapeRegistry::getInstance().signOff(this, ShapeRegistry::ShapeInserted);
     
    341345      observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that WorldTime's time has changed.";
    342346#endif
     347        needsRedraw = false;
    343348        emit changed();
    344349        emit TimeChanged();
     
    353358      case ShapeRegistry::ShapeInserted:
    354359      {
     360        needsRedraw = false;
    355361        emit ShapeAdded(ShapeRegistry::getInstance().lastChanged()->getName());
    356362        break;
     
    358364      case ShapeRegistry::ShapeRemoved:
    359365      {
     366        needsRedraw = false;
    360367        emit ShapeRemoved(ShapeRegistry::getInstance().lastChanged()->getName());
    361368        break;
     
    363370      case ShapeRegistry::SelectionChanged:
    364371      {
     372        needsRedraw = false;
    365373        worldscene->updateSelectedShapes();
    366374        break;
     
    375383void GLWorldView::checkChanges()
    376384{
     385  needsRedraw = false;
    377386  updateGL();
    378   needsRedraw = false;
    379387}
    380388
     
    385393  setdreiBeinStatus(!status);
    386394  // realize
    387   updateGL();
    388395  needsRedraw = true;
     396  emit changed();
    389397}
    390398
     
    403411  setDomainStatus(!status);
    404412  // realize
    405   updateGL();
    406413  needsRedraw = true;
     414  emit changed();
    407415}
    408416
     
    417425void GLWorldView::sceneChangeSignalled()
    418426{
    419   if (!needsRedraw){
     427  if (needsRedraw){
    420428    redrawTimer->singleShot(0, this, SLOT(checkChanges()));
    421429    needsRedraw = true;
     
    432440void GLWorldView::paintGL(QGLPainter *painter)
    433441{
    434   if (changesPresent) {
     442  if (changesPresent)
    435443    initializeGL(painter);
    436     changesPresent = false;
    437   }
    438444
    439445  QVector3D cameraDir = camera()->center() - camera()->eye();
     
    492498{
    493499  changesPresent = true;
     500  updateGL();
    494501}
    495502
     
    548555  setStereoType(QGLView::Hardware);
    549556  camera()->setEyeSeparation(0.0);
    550   updateGL();
     557  emit changed();
    551558}
    552559
     
    555562  setStereoType(QGLView::Hardware);
    556563  camera()->setEyeSeparation(defaultEyeSeparation);
    557   updateGL();
     564  emit changed();
    558565}
    559566
     
    562569  setStereoType(QGLView::LeftRight);
    563570  camera()->setEyeSeparation(defaultEyeSeparation);
    564   updateGL();
     571  emit changed();
    565572}
    566573
     
    569576  setStereoType(QGLView::RightLeft);
    570577  camera()->setEyeSeparation(defaultEyeSeparation);
    571   updateGL();
     578  emit changed();
    572579}
    573580
     
    576583  setStereoType(QGLView::TopBottom);
    577584  camera()->setEyeSeparation(defaultEyeSeparation);
    578   updateGL();
     585  emit changed();
    579586}
    580587
     
    583590  setStereoType(QGLView::BottomTop);
    584591  camera()->setEyeSeparation(defaultEyeSeparation);
    585   updateGL();
     592  emit changed();
    586593}
    587594
     
    590597  setStereoType(QGLView::RedCyanAnaglyph);
    591598  camera()->setEyeSeparation(defaultEyeSeparation);
    592   updateGL();
     599  emit changed();
    593600}
    594601
     
    714721void GLWorldView::sceneHoverSignalled(const atomId_t _id)
    715722{
     723  needsRedraw = true;
     724  emit changed();
    716725  emit hoverChanged(_id);
    717726}
     
    719728void GLWorldView::sceneHoverSignalled(const moleculeId_t _id, int _i)
    720729{
     730  needsRedraw = true;
     731  emit changed();
    721732  emit hoverChanged(_id, _i);
    722733}
  • src/UIElements/Views/Qt4/QtInfoBox.cpp

    r3e334e r8d56a6  
    6565
    6666  setMinimumWidth(200);
    67   setMinimumHeight(220);
     67  setMinimumHeight(350);
    6868
    6969  connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
     
    220220  addInfo(this, "Position y", QString(toString(atomRef->getAtomPosition()[1]).c_str()));
    221221  addInfo(this, "Position z", QString(toString(atomRef->getAtomPosition()[2]).c_str()));
     222  addInfo(this, "Velocity x", QString(toString(atomRef->getAtomVelocity()[0]).c_str()));
     223  addInfo(this, "Velocity y", QString(toString(atomRef->getAtomVelocity()[1]).c_str()));
     224  addInfo(this, "Velocity z", QString(toString(atomRef->getAtomVelocity()[2]).c_str()));
     225  addInfo(this, "Force x", QString(toString(atomRef->getAtomForce()[0]).c_str()));
     226  addInfo(this, "Force y", QString(toString(atomRef->getAtomForce()[1]).c_str()));
     227  addInfo(this, "Force z", QString(toString(atomRef->getAtomForce()[2]).c_str()));
    222228}
    223229
  • src/UIElements/Views/Qt4/QtTimeLine.cpp

    r3e334e r8d56a6  
    4747
    4848QtTimeLine::QtTimeLine(QWidget * _parent) :
    49     QSlider (Qt::Horizontal, _parent),
     49    QWidget(_parent),
    5050    Observer("QtTimeLine"),
    5151    atomobserver_enlisted(false),
    5252    worldtime_enlisted(false),
    53     WorldTime_change(false)
     53    SetWorldTime_called(false)
    5454{
     55  slider = new QSlider(Qt::Horizontal, this);
    5556  // set initial values
    56   QSlider::setMinimum(0);
    57   QSlider::setMaximum(0);
    58   WorldTime_change = true;
    59   QSlider::setValue(0);
    60   QSlider::setTickInterval(1);
    61   QSlider::setSingleStep(1);
    62   QSlider::setTracking(true);
     57  slider->setMinimum(0);
     58  slider->setMaximum(0);
     59  slider->setValue(0);
     60  slider->setTickInterval(1);
     61  slider->setSingleStep(1);
     62  slider->setTracking(true);
     63
     64  spinbox = new QSpinBox(this);
     65  spinbox->setMinimum(0);
     66  spinbox->setMaximum(0);
     67  spinbox->setValue(0);
     68
     69  layout = new QHBoxLayout(this);
     70  layout->addWidget(slider);
     71  layout->addWidget(spinbox);
    6372
    6473  // sign on to observable
     
    6978
    7079  // connect to QSlider's valueChanged() signal
    71   bool result = connect(this,SIGNAL(valueChanged(int)),this,SLOT(StepUpdate(int)), Qt::DirectConnection);
     80  bool result = connect(slider,SIGNAL(valueChanged(int)),this,SLOT(StepUpdate(int)));
     81  result = result && connect(spinbox,SIGNAL(valueChanged(int)),this,SLOT(StepUpdate(int)));
    7282  if (!result)
    7383    ELOG(0, "Could not connect to QSlider::valueChanged.");
     
    8696  boost::recursive_mutex::scoped_lock lock(refill_mutex);
    8797
    88   QSlider::paintEvent(event);
     98//  layout->paintEvent(event);
    8999}
    90100
     
    111121
    112122  if (static_cast<WorldTime *>(publisher) == WorldTime::getPointer()) {
     123    SetWorldTime_called = false;
    113124    const int timestep = WorldTime::getTime();
    114125    // check whether we are beyond maximum
    115     if (timestep > QSlider::maximum())
    116       QSlider::setMaximum(timestep);
     126    if (timestep > slider->maximum()) {
     127      slider->setMaximum(timestep);
     128      spinbox->setMaximum(timestep);
     129    }
    117130    // set slider position to new time step
    118     WorldTime_change = true;
    119     QSlider::setValue( timestep );
     131    slider->setValue( timestep );
     132    spinbox->setValue( timestep );
    120133  } else
    121134    //if (static_cast<AtomObserver *>(publisher) == AtomObserver::getPointer())
     
    124137    const atom *_atom = dynamic_cast<const atom *>(publisher);
    125138    const int MaxTrajectory = _atom->getTrajectorySize()-1;
    126     if (MaxTrajectory > QSlider::maximum())
    127       QSlider::setMaximum(MaxTrajectory);
     139    if (MaxTrajectory > slider->maximum()) {
     140      slider->setMaximum(MaxTrajectory);
     141      spinbox->setMaximum(MaxTrajectory);
     142    }
    128143  }
    129144}
     
    133148  boost::recursive_mutex::scoped_lock lock(refill_mutex);
    134149
    135   if (WorldTime_change)
    136     WorldTime_change = false;
    137   else
    138     MoleCuilder::WorldSetWorldTime(position);
     150  if (!SetWorldTime_called) {
     151    if (WorldTime::getTime() != (unsigned int)position) {
     152      SetWorldTime_called = true;
     153      MoleCuilder::WorldSetWorldTime(position);
     154    }
     155  }
    139156}
  • src/UIElements/Views/Qt4/QtTimeLine.hpp

    r3e334e r8d56a6  
    1414#endif
    1515
     16#include <QtGui/QHBoxLayout>
    1617#include <QtGui/QSlider>
     18#include <QtGui/QSpinBox>
    1719
    1820#include <boost/thread/recursive_mutex.hpp>
     
    2022#include "CodePatterns/Observer/Observer.hpp"
    2123
    22 class QtTimeLine : public QSlider, public Observer
     24class QtTimeLine : public QWidget, public Observer
    2325{
    2426  Q_OBJECT
     
    4244  //!> whether WorldTime knows about us or not
    4345  bool worldtime_enlisted;
    44   //!> states whether value was set by observing WorldTime (and not by slider)
    45   bool WorldTime_change;
     46
     47  QSlider *slider;
     48  QSpinBox *spinbox;
     49  QHBoxLayout *layout;
     50
     51  //!> states whether we are expecting a notification from the worldtime
     52  bool SetWorldTime_called;
    4653
    4754  mutable boost::recursive_mutex refill_mutex;
Note: See TracChangeset for help on using the changeset viewer.