Changeset 897a01 for src/UIElements
- Timestamp:
- Apr 11, 2018, 6:29:56 AM (7 years ago)
- 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)
- Location:
- src/UIElements
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp
r8450da r897a01 89 89 QtObservedAtom::AtomPositionChannels(1, AtomObservable::PositionChanged); 90 90 const Observable::channels_t 91 QtObservedAtom::AtomVelocityChannels(1, AtomObservable::VelocityChanged); 92 const Observable::channels_t 93 QtObservedAtom::AtomForceChannels(1, AtomObservable::ForceChanged); 94 const Observable::channels_t 91 95 QtObservedAtom::AtomSelectedChannels(1, AtomObservable::SelectionChanged); 92 96 … … 124 128 boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[AtomName])->noteCallBackIsGone(); 125 129 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(); 126 132 boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[AtomSelected])->noteCallBackIsGone(); 127 133 … … 215 221 inline 216 222 #endif 223 Vector QtObservedAtom::updateVelocity( 224 const atom &_atom) 225 { 226 return _atom.getAtomicVelocity(); 227 } 228 229 #ifdef HAVE_INLINE 230 inline 231 #endif 232 Vector QtObservedAtom::updateForce( 233 const atom &_atom) 234 { 235 return _atom.getAtomicForce(); 236 } 237 238 #ifdef HAVE_INLINE 239 inline 240 #endif 217 241 bool QtObservedAtom::updateSelected( 218 242 const atom &_atom) … … 269 293 boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>( 270 294 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(); 271 299 boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>( 272 300 ObservedValues[MoleculeRef])->forceUpdate(); 273 301 // then tell Qt part about updates 274 302 emit positionChanged(); 303 emit velocityChanged(); 304 emit forceChanged(); 275 305 emit moleculeChanged(); 276 306 } else { … … 296 326 case AtomObservable::PositionChanged: 297 327 emit positionChanged(); 328 break; 329 case AtomObservable::VelocityChanged: 330 emit velocityChanged(); 331 break; 332 case AtomObservable::ForceChanged: 333 emit forceChanged(); 298 334 break; 299 335 case AtomObservable::SelectionChanged: … … 362 398 const boost::function<Vector ()> AtomPositionUpdater( 363 399 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))); 364 404 const boost::function<bool ()> AtomSelectedUpdater( 365 405 boost::bind(&QtObservedAtom::updateSelected, boost::cref(*_atomref))); … … 401 441 AtomPositionUpdater(), 402 442 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, 403 457 _subjectKilled); 404 458 _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>( … … 426 480 delete boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(_ObservedValues[AtomName]); 427 481 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]); 428 484 delete boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(_ObservedValues[AtomSelected]); 429 485 delete boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(_ObservedValues[MoleculeRef]); … … 463 519 } 464 520 521 const Vector& QtObservedAtom::getAtomVelocity() const 522 { 523 return boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomVelocity])->get(); 524 } 525 526 const Vector& QtObservedAtom::getAtomForce() const 527 { 528 return boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomForce])->get(); 529 } 530 465 531 const bool QtObservedAtom::getAtomSelected() const 466 532 { -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp
r8450da r897a01 136 136 const Vector& getAtomPosition() const; 137 137 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 138 150 /** Getter to the observed state of the associated molecule. 139 151 * … … 155 167 void nameChanged(); 156 168 void positionChanged(); 169 void velocityChanged(); 170 void forceChanged(); 157 171 void atomRemoved(); 158 172 void selectedChanged(); … … 174 188 static std::string updateName(const atom &_atom); 175 189 static Vector updatePosition(const atom &_atom); 190 static Vector updateVelocity(const atom &_atom); 191 static Vector updateForce(const atom &_atom); 176 192 static bool updateSelected(const atom &_atom); 177 193 … … 188 204 //!> contains the current atom position 189 205 AtomPosition, 206 //!> contains the current atom velocity 207 AtomVelocity, 208 //!> contains the current atom force 209 AtomForce, 190 210 //!> contains the current atom's selection status 191 211 AtomSelected, … … 253 273 //!> list of channels when position needs to update 254 274 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; 255 279 //!> list of channels when selection needs to update 256 280 static const Observable::channels_t AtomSelectedChannels; -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp
r8450da r897a01 61 61 QGLMaterial *GLMoleculeObject::m_selectionMaterial = NULL; 62 62 QGLMaterial *GLMoleculeObject::m_selectionBoxMaterial = NULL; 63 QGLMaterial *GLMoleculeObject::m_velocityMaterial = NULL; 64 QGLMaterial *GLMoleculeObject::m_forceMaterial = NULL; 63 65 64 66 QGLSceneNode *GLMoleculeObject::meshEmpty[GLMoleculeObject::DETAILTYPES_MAX]; 65 67 QGLSceneNode *GLMoleculeObject::meshSphere[GLMoleculeObject::DETAILTYPES_MAX]; 66 68 QGLSceneNode *GLMoleculeObject::meshCylinder[GLMoleculeObject::DETAILTYPES_MAX]; 69 QGLSceneNode *GLMoleculeObject::meshArrow[GLMoleculeObject::DETAILTYPES_MAX]; 67 70 68 71 double GLMoleculeObject::detailMinDistance[GLMoleculeObject::DETAILTYPES_MAX] = {0, 15, 30, 42}; … … 309 312 m_selectionBoxMaterial->setEmittedLight( QColor(155, 50, 50) ); 310 313 } 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 } 311 324 } 312 325 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp
r8450da r897a01 108 108 static QGLSceneNode *meshSphere[DETAILTYPES_MAX]; 109 109 static QGLSceneNode *meshCylinder[DETAILTYPES_MAX]; 110 static QGLSceneNode *meshArrow[DETAILTYPES_MAX]; 110 111 111 112 protected: … … 130 131 static QGLMaterial *m_selectionMaterial; 131 132 static QGLMaterial *m_selectionBoxMaterial; 133 static QGLMaterial *m_velocityMaterial; 134 static QGLMaterial *m_forceMaterial; 132 135 QGLAbstractEffect *m_effect; 133 136 int m_objectId; -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
r8450da r897a01 50 50 #include "Element/element.hpp" 51 51 #include "Element/periodentafel.hpp" 52 #include "LinearAlgebra/Line.hpp" 52 53 #include "LinearAlgebra/Vector.hpp" 53 54 #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp" … … 57 58 GLMoleculeObject_atom::GLMoleculeObject_atom( 58 59 QGLSceneNode *mesh[], 60 QGLSceneNode *mesharrow[], 59 61 QObject *parent, 60 62 QtObservedAtom::ptr &_ObservedAtom) : 61 63 GLMoleculeObject(mesh, parent), 64 GLMoleculeObjectVelocity(mesharrow, this), 65 GLMoleculeObjectForce(mesharrow, this), 62 66 ObservedAtom(_ObservedAtom) 63 67 { … … 69 73 setObjectId(_id); 70 74 resetPosition(); 75 resetVelocity(); 76 resetForce(); 71 77 resetElement(); 78 79 GLMoleculeObjectVelocity.setMaterial(GLMoleculeObject::m_velocityMaterial); 80 GLMoleculeObjectForce.setMaterial(GLMoleculeObject::m_forceMaterial); 72 81 73 82 m_selected = ObservedAtom->getAtomSelected(); … … 77 86 connect( ObservedAtom.get(), SIGNAL(elementChanged()), this, SLOT(resetElement())); 78 87 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())); 79 90 connect( ObservedAtom.get(), SIGNAL(selectedChanged()), this, SLOT(resetSelected())); 80 91 } … … 95 106 } 96 107 108 static 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 97 119 void GLMoleculeObject_atom::resetPosition() 98 120 { … … 100 122 LOG(4, "INFO: GLMoleculeObject_atom::resetPosition() - new position is "+toString(Position)+"."); 101 123 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 128 static 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 163 void 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 171 void 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()); 102 177 } 103 178 … … 144 219 // call old hook to do the actual paining 145 220 GLMoleculeObject::draw(painter, cameraPlane); 221 GLMoleculeObjectVelocity.draw(painter, cameraPlane); 222 GLMoleculeObjectForce.draw(painter, cameraPlane); 146 223 } 147 224 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
r8450da r897a01 34 34 GLMoleculeObject_atom( 35 35 QGLSceneNode *mesh[], 36 QGLSceneNode *mesharrow[], 36 37 QObject *parent, 37 38 QtObservedAtom::ptr &_ObservedAtom … … 46 47 void resetElement(); 47 48 void resetPosition(); 49 void resetVelocity(); 50 void resetForce(); 48 51 void resetSelected(); 49 52 … … 58 61 59 62 private: 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 60 68 //!> current list of bonds to compare new onw against for changes 61 69 QtObservedAtom::ListOfBonds_t ListOfBonds; -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r8450da r897a01 154 154 int sphereDetails[] = {5, 3, 2, 0}; 155 155 int cylinderDetails[] = {16, 8, 6, 3}; 156 int arrowDetails[] = {8, 5, 3, 0}; 156 157 for (int i=0;i<GLMoleculeObject::DETAILTYPES_MAX;i++){ 157 158 QGLBuilder emptyBuilder; … … 165 166 GLMoleculeObject::meshCylinder[i] = cylinderBuilder.finalizedSceneNode(); 166 167 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); 167 185 } 168 186 connect(board, SIGNAL(moleculeInserted(QtObservedMolecule::ptr)), … … 279 297 atomObject = new GLMoleculeObject_atom( 280 298 GLMoleculeObject::meshSphere, 299 GLMoleculeObject::meshArrow, 281 300 parent, 282 301 _atom); -
src/UIElements/Views/Qt4/QtInfoBox.cpp
r8450da r897a01 65 65 66 66 setMinimumWidth(200); 67 setMinimumHeight( 220);67 setMinimumHeight(350); 68 68 69 69 connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout())); … … 220 220 addInfo(this, "Position y", QString(toString(atomRef->getAtomPosition()[1]).c_str())); 221 221 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())); 222 228 } 223 229
Note:
See TracChangeset
for help on using the changeset viewer.