Changeset 494478 for src/UIElements/Views/Qt4/Qt3D
- Timestamp:
- Feb 12, 2016, 11:15:24 PM (9 years ago)
- 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:
- 90821d
- Parents:
- 65c323
- git-author:
- Frederik Heber <heber@…> (10/29/15 12:52:29)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:24)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
r65c323 r494478 94 94 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new index is "+toString(newId)+"."); 95 95 setObjectId(newId); 96 97 emit indexChanged(this, oldId, newId); 96 98 } 97 99 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
r65c323 r494478 56 56 void BondsAdded(const atomId_t _left, const atomId_t _right, const GLMoleculeObject_bond::SideOfBond side); 57 57 void BondsRemoved(const atomId_t _left, const atomId_t _right); 58 void indexChanged(GLMoleculeObject_atom *ob, const atomId_t oldId, const atomId_t newId);58 void indexChanged(GLMoleculeObject_atom*, const atomId_t _oldid, const atomId_t _newid); 59 59 60 60 private: -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp
r65c323 r494478 39 39 #include <Qt3D/qglscenenode.h> 40 40 41 #include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp" 42 41 43 #include "CodePatterns/MemDebug.hpp" 42 43 44 44 45 #include <cmath> … … 55 56 #include "LinearAlgebra/Line.hpp" 56 57 #include "LinearAlgebra/Vector.hpp" 57 #include "UIElements/Qt4/InstanceBoard/ QtObservedInstanceBoard.hpp"58 #include "UIElements/Qt4/InstanceBoard/ObservedValue_wCallback.hpp" 58 59 #include "World.hpp" 59 60 #include "ObservedValue_wCallback.hpp"61 60 62 61 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
r65c323 r494478 40 40 #include <Qt3D/qglbuilder.h> 41 41 42 #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp" 43 42 44 #include "CodePatterns/MemDebug.hpp" 43 45 … … 47 49 #include "CodePatterns/IteratorAdaptors.hpp" 48 50 #include "CodePatterns/Log.hpp" 49 #include "CodePatterns/Observer/Notification.hpp" 50 #include "CodePatterns/Observer/ObserverLog.hpp" 51 52 #include "Atom/atom.hpp" 53 #include "molecule.hpp" 54 #include "Descriptors/AtomIdDescriptor.hpp" 55 #include "Descriptors/MoleculeIdDescriptor.hpp" 56 #include "Element/element.hpp" 51 57 52 #include "LinearAlgebra/Vector.hpp" 58 53 #include "LinkedCell/PointCloudAdaptor.hpp" … … 66 61 #include "World.hpp" 67 62 68 #include "ObservedValue_wCallback.hpp"69 #include "ObservedValue_UpdateAtoms.hpp"70 71 63 using namespace boost::assign; 72 73 #include "GLMoleculeObject_atom.hpp"74 64 75 65 static Observable::channels_t getAllAtomicChangesChannels() … … 80 70 } 81 71 82 static Observable::channels_t getAllAtomicObservedChannels()83 {84 Observable::channels_t channels;85 channels += molecule::AtomInserted, molecule::AtomRemoved, molecule::AtomMoved;86 return channels;87 }88 89 // static instances90 72 const Observable::channels_t GLMoleculeObject_molecule::HullChannels(getAllAtomicChangesChannels()); 91 const Observable::channels_t GLMoleculeObject_molecule::BoundingBoxChannels(1, molecule::BoundingBoxChanged);92 const Observable::channels_t GLMoleculeObject_molecule::IndexChannels(1, molecule::IndexChanged);93 const Observable::channels_t GLMoleculeObject_molecule::NameChannels(1, molecule::MoleculeNameChanged);94 73 95 74 static QGLSceneNode *createMoleculeMesh(const QGeometryData &_geo) … … 104 83 GLMoleculeObject_molecule::GLMoleculeObject_molecule( 105 84 QObject *parent, 106 const moleculeId_t _molid, 107 QtObservedInstanceBoard * _board, 108 std::vector<boost::any> _ObservedValues) : 85 QtObservedInstanceBoard &_board, 86 QtObservedMolecule::ptr _ObservedMolecule) : 109 87 GLMoleculeObject((QGLSceneNode *)NULL, parent), 110 Observer(std::string("GLMoleculeObject_molecule")+toString(_molid)),111 88 owner(NULL), 112 molref( getMolecule(_molid)),89 molref(QtObservedMolecule::getMolecule(_ObservedMolecule->getMolIndex())), 113 90 /* We must not use boost::cref(this) as "this" has not been properly constructed and seemingly 114 91 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because 115 92 * the class has not been fully constructed yet. "This" itself seems to be working fine. 116 93 */ 117 ObservedValues(_ObservedValues),118 subjectKilledCount(0),119 94 TesselationHullUpdater( 120 95 boost::bind(&GLMoleculeObject_molecule::updateTesselationHull, this) … … 123 98 molref, 124 99 TesselationHullUpdater, 125 "MoleculeTesselationHull_"+toString(_ molid),100 "MoleculeTesselationHull_"+toString(_ObservedMolecule->getMolIndex()), 126 101 HullChannels), 127 102 hoverAtomId(-1), 128 AllsignedOnChannels(getAllAtomicObservedChannels().size()), 129 signedOnChannels(0), 130 board(_board) 131 { 132 init(_molid); 103 board(_board), 104 ObservedMolecule(_ObservedMolecule) 105 { 106 init(ObservedMolecule->getMolIndex()); 133 107 } 134 108 … … 136 110 QGLSceneNode *mesh[], 137 111 QObject *parent, 138 const moleculeId_t _molid, 139 QtObservedInstanceBoard * _board, 140 std::vector<boost::any> _ObservedValues) : 112 QtObservedInstanceBoard &_board, 113 QtObservedMolecule::ptr _ObservedMolecule) : 141 114 GLMoleculeObject(mesh, parent), 142 Observer(std::string("GLMoleculeObject_molecule")+toString(_molid)),143 115 owner(NULL), 144 molref( getMolecule(_molid)),116 molref(QtObservedMolecule::getMolecule(_ObservedMolecule->getMolIndex())), 145 117 /* We must not use boost::cref(this) as "this" has not been properly constructed and seemingly 146 118 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because 147 119 * the class has not been fully constructed yet. "This" itself seems to be working fine. 148 120 */ 149 ObservedValues(_ObservedValues),150 subjectKilledCount(0),151 121 TesselationHullUpdater( 152 122 boost::bind(&GLMoleculeObject_molecule::updateTesselationHull, this) … … 155 125 molref, 156 126 TesselationHullUpdater, 157 "MoleculeTesselationHull_"+toString(_ molid),127 "MoleculeTesselationHull_"+toString(_ObservedMolecule->getMolIndex()), 158 128 HullChannels), 159 129 hoverAtomId(-1), 160 AllsignedOnChannels(getAllAtomicObservedChannels().size()), 161 signedOnChannels(0), 162 board(_board) 163 { 164 init(_molid); 130 board(_board), 131 ObservedMolecule(_ObservedMolecule) 132 { 133 init(ObservedMolecule->getMolIndex()); 165 134 } 166 135 … … 175 144 m_visible = false; 176 145 177 activateObserver();178 179 146 connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *))); 180 147 connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed())); 181 connect (this, SIGNAL(TesselationHullChanged()), this, SLOT(resetTesselationHull()), Qt::QueuedConnection); 182 connect (this, SIGNAL(BoundingBoxChanged()), this, SLOT(resetBoundingBox()), Qt::QueuedConnection); 183 connect (this, SIGNAL(IdChanged()), this, SLOT(resetIndex()), Qt::QueuedConnection); 184 connect (this, SIGNAL(AtomInserted(const atomId_t)), this, SLOT(atomInserted(const atomId_t)), Qt::QueuedConnection); 185 connect (this, SIGNAL(AtomRemoved(const atomId_t)), this, SLOT(atomRemoved(const atomId_t)), Qt::QueuedConnection); 186 if (board != NULL) { 187 connect(board, SIGNAL(atomInserted(const atomId_t)), 188 this, SLOT(atomInserted(const atomId_t))); 189 connect(board, SIGNAL(atomRemoved(const atomId_t)), 190 this, SLOT(atomRemoved(const atomId_t))); 191 } 148 connect (ObservedMolecule.get(), SIGNAL(tesselationhullChanged()), this, SLOT(resetTesselationHull())); 149 connect (ObservedMolecule.get(), SIGNAL(boundingboxChanged()), this, SLOT(resetBoundingBox())); 150 connect (ObservedMolecule.get(), SIGNAL(indexChanged()), this, SLOT(resetIndex())); 151 connect (ObservedMolecule.get(), SIGNAL(atomInserted(const atomId_t)), this, SLOT(atomInserted(const atomId_t))); 152 connect (ObservedMolecule.get(), SIGNAL(atomRemoved(const atomId_t)), this, SLOT(atomRemoved(const atomId_t))); 192 153 193 154 connect( this, SIGNAL(clicked()), this, SLOT(wasClicked())); … … 195 156 196 157 GLMoleculeObject_molecule::~GLMoleculeObject_molecule() 197 { 198 deactivateObserver(); 199 board->returnMoleculeObservedValues(getMolIndex(), ObservedValues); 200 } 201 202 void GLMoleculeObject_molecule::deactivateObserver() 203 { 204 if (owner != NULL) { 205 Observable::channels_t channels = getAllAtomicObservedChannels(); 206 for (Observable::channels_t::const_iterator iter = channels.begin(); 207 iter != channels.end(); ++iter) 208 owner->signOff(this, *iter); 209 owner = NULL; 210 signedOnChannels = 0; 211 } 212 } 213 214 void GLMoleculeObject_molecule::activateObserver() 215 { 216 // sign on as observer (obtain non-const instance before) 217 const molecule * const _molecule = getMolecule(getMolIndex()); 218 if (_molecule != NULL) { 219 Observable::channels_t channels = getAllAtomicObservedChannels(); 220 owner = static_cast<const Observable *>(_molecule); 221 for (Observable::channels_t::const_iterator iter = channels.begin(); 222 iter != channels.end(); ++iter) 223 owner->signOn(this, *iter); 224 } else { 225 ELOG(1, "GLMoleculeObject_molecule() - added null object for not present mol id " << getMolIndex()); 226 } 227 228 } 158 {} 229 159 230 160 void GLMoleculeObject_molecule::addAtomBonds( … … 249 179 QGeometryData geo; 250 180 251 const molecule * const molref = getMolecule(getMolIndex()); 181 const molecule * const molref = 182 QtObservedMolecule::getMolecule(ObservedMolecule->getMolIndex()); 252 183 if (molref == NULL) { 253 ELOG(1, "Could not createMoleculeMesh, molecule with id " << getMolIndex() << " already gone."); 184 ELOG(1, "Could not createMoleculeMesh, molecule with id " 185 << ObservedMolecule->getMolIndex() << " already gone."); 254 186 return geo; 255 187 } … … 273 205 // Tesselate the points. 274 206 Tesselation T; 275 PointCloudAdaptor<molecule> cloud(const_cast<molecule *>(molref), getMolName()); 207 PointCloudAdaptor<molecule> cloud( 208 const_cast<molecule *>(molref), 209 ObservedMolecule->getMolName()); 276 210 T(cloud, minradius); 277 211 … … 320 254 } 321 255 322 molecule::BoundingBoxInfo GLMoleculeObject_molecule::initBoundingBox()323 {324 molecule::BoundingBoxInfo info;325 info.position = zeroVec;326 info.radius = 0.;327 return info;328 }329 330 molecule::BoundingBoxInfo GLMoleculeObject_molecule::updateBoundingBox(331 const boost::function<const moleculeId_t ()> &_getMolIndex)332 {333 const molecule * const mol = getMolecule(_getMolIndex());334 return mol->getBoundingBox();335 }336 337 moleculeId_t GLMoleculeObject_molecule::updateIndex()338 {339 return const_cast<const World &>(World::getInstance()).lastChangedMolId();340 }341 342 std::string GLMoleculeObject_molecule::updateName(343 const boost::function<const moleculeId_t ()> &_getMolIndex)344 {345 const molecule * const mol = getMolecule(_getMolIndex());346 return mol->getName();347 }348 349 256 void GLMoleculeObject_molecule::resetTesselationHull() 350 257 { … … 356 263 void GLMoleculeObject_molecule::resetBoundingBox() 357 264 { 358 molecule::BoundingBoxInfo info = getBoundingBox();265 molecule::BoundingBoxInfo info = ObservedMolecule->getBoundingBox(); 359 266 setPosition(QVector3D(info.position[0], info.position[1], info.position[2])); 360 267 setScale(info.radius + 0.3); // getBoundingSphere() only sees atoms as points, so make the box a bit bigger … … 363 270 void GLMoleculeObject_molecule::resetIndex() 364 271 { 365 const atomId_t newId = getMolIndex();272 const atomId_t newId = ObservedMolecule->getMolIndex(); 366 273 const size_t oldId = objectId(); 367 274 ASSERT( newId != oldId, … … 371 278 372 279 emit indexChanged(this, oldId, newId); 373 }374 375 void GLMoleculeObject_molecule::resetName()376 {377 280 } 378 281 … … 418 321 } 419 322 420 void GLMoleculeObject_molecule::update(Observable *publisher)421 {422 ASSERT(0,423 "GLMoleculeObject_molecule::update() - general update from unexpected source.");424 }425 426 void GLMoleculeObject_molecule::subjectKilled(Observable *publisher)427 {428 ++signedOnChannels;429 430 if (signedOnChannels == AllsignedOnChannels) {431 // remove owner: no more signOff needed432 owner = NULL;433 434 board->moleculecountsubjectKilled(getMolIndex());435 }436 }437 438 void GLMoleculeObject_molecule::recieveNotification(Observable *publisher, Notification_ptr notification)439 {440 const molecule * const _molecule = getMolecule(getMolIndex());441 // when molecule is NULL we will soon get destroyed anyway442 if (_molecule == NULL)443 return;444 if (publisher == dynamic_cast<const Observable*>(_molecule)){445 // notification from atom446 #ifdef LOG_OBSERVER447 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this))448 << " received notification from molecule " << getMolIndex() << " for channel "449 << notification->getChannelNo() << ".";450 #endif451 switch (notification->getChannelNo()) {452 case molecule::AtomInserted:453 case molecule::AtomRemoved:454 case molecule::AtomMoved:455 {456 #ifdef LOG_OBSERVER457 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";458 #endif459 emit TesselationHullChanged();460 emit BoundingBoxChanged();461 break;462 }463 case molecule::IndexChanged:464 {465 #ifdef LOG_OBSERVER466 const atomId_t _id = _molecule->lastChangedAtomId();467 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+"'s index has changed.";468 #endif469 emit IdChanged();470 break;471 }472 default:473 break;474 }475 }476 }477 323 478 324 void GLMoleculeObject_molecule::initialize(QGLView *view, QGLPainter *painter) … … 573 419 GLMoleculeObject::meshSphere, 574 420 this, 575 board ->getObservedAtom(_id));421 board.getObservedAtom(_id)); 576 422 ASSERT( atomObject != NULL, 577 423 "GLMoleculeObject_molecule::atomInserted - could not create atom object for "+toString(_id)); … … 582 428 583 429 qRegisterMetaType<atomId_t>("atomId_t"); 584 qRegisterMetaType<bond::ptr>("bond::ptr");585 430 qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond"); 586 431 connect (atomObject, SIGNAL(clicked(atomId_t)), this, SIGNAL(atomClicked(atomId_t))); … … 645 490 if (moleculeObject == this){ 646 491 // Propagate signal. 647 emit hoverChanged( getMolIndex(), 0);492 emit hoverChanged(ObservedMolecule->getMolIndex(), 0); 648 493 } 649 494 } … … 748 593 void GLMoleculeObject_molecule::wasClicked() 749 594 { 750 LOG(4, "INFO: GLMoleculeObject_molecule: atom " << getMolIndex() << " has been clicked"); 751 emit moleculeClicked(getMolIndex()); 595 LOG(4, "INFO: GLMoleculeObject_molecule: atom " 596 << ObservedMolecule->getMolIndex() << " has been clicked"); 597 emit moleculeClicked(ObservedMolecule->getMolIndex()); 752 598 } 753 599 … … 777 623 } 778 624 779 const molecule * const GLMoleculeObject_molecule::getMolecule(const moleculeId_t _id)780 {781 const molecule * const mol = const_cast<const World &>(World::getInstance()).782 getMolecule(MoleculeById(_id));783 return mol;784 }785 786 void GLMoleculeObject_molecule::initObservedValues(787 std::vector<boost::any> &_ObservedValues,788 const moleculeId_t _molid,789 const molecule * const _molref,790 const boost::function<void(const moleculeId_t)> &_subjectKilled)791 {792 /* This is an old note from when the code was still part of cstor's initializer body.793 * TODO: Probably does not apply anymore but has not yet been tested.794 *795 * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly796 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because797 * the class has not been fully constructed yet. "This" itself seems to be working fine.798 */799 800 ASSERT( _ObservedValues.size() == MAX_ObservedTypes,801 "GLMoleculeObject_molecule::initObservedValues() - given ObservedValues has not correct size.");802 803 // fill ObservedValues: index first804 const boost::function<moleculeId_t ()> MolIndexUpdater(805 boost::bind(&GLMoleculeObject_molecule::updateIndex));806 807 ObservedValue_wCallback<moleculeId_t> * const IndexObservable =808 new ObservedValue_wCallback<moleculeId_t>(809 _molref,810 MolIndexUpdater,811 "MoleculeIndex_"+toString(_molid),812 _molid,813 IndexChannels,814 _subjectKilled);815 _ObservedValues[MolIndex] = IndexObservable;816 817 const boost::function<const moleculeId_t ()> MolIndexGetter =818 boost::bind(&ObservedValue_wCallback<moleculeId_t>::get,819 IndexObservable);820 821 // fill ObservedValues: then all the other that need index822 const boost::function<std::string ()> MolNameUpdater(823 boost::bind(&GLMoleculeObject_molecule::updateName, MolIndexGetter));824 const boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater(825 boost::bind(&GLMoleculeObject_molecule::updateBoundingBox, MolIndexGetter));826 827 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>(828 _molref,829 MolNameUpdater,830 "MoleculeName_"+toString(_molid),831 MolNameUpdater(),832 NameChannels,833 _subjectKilled,834 MolIndexGetter);835 _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t>(836 _molref,837 BoundingBoxUpdater,838 "MoleculeBoundingBox_"+toString(_molid),839 initBoundingBox(),840 BoundingBoxChannels,841 _subjectKilled,842 MolIndexGetter);843 }844 845 void GLMoleculeObject_molecule::destroyObservedValues(846 std::vector<boost::any> &_ObservedValues)847 {848 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]);849 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]);850 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);851 _ObservedValues.clear();852 }853 854 moleculeId_t GLMoleculeObject_molecule::getMolIndex() const855 {856 return boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->get();857 }858 859 std::string GLMoleculeObject_molecule::getMolName() const860 {861 return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->get();862 }863 864 molecule::BoundingBoxInfo GLMoleculeObject_molecule::getBoundingBox() const865 {866 return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->get();867 }868 625 869 626 GLMoleculeObject_molecule::atoms_t GLMoleculeObject_molecule::getPresentAtoms() const -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp
r65c323 r494478 18 18 #include <Qt3D/qgeometrydata.h> 19 19 20 #include <vector> 21 #include <boost/any.hpp> 20 #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp" 21 22 #include <map> 23 22 24 #include <boost/function.hpp> 23 25 24 26 #include "CodePatterns/Cacheable.hpp" 25 #include "CodePatterns/Observer/Observer.hpp" 26 #include "CodePatterns/ObservedValue.hpp" 27 #include "CodePatterns/Observer/Observable.hpp" 27 28 28 29 #include "GLMoleculeObject_bond.hpp" 29 30 30 #include " molecule.hpp"31 #include "types.hpp" 31 32 32 33 class atom; 33 34 class bond; 35 class molecule; 34 36 class GLMoleculeObject_atom; 35 37 class GLWorldScene; 36 38 class QtObservedInstanceBoard; 37 39 38 class GLMoleculeObject_molecule : public GLMoleculeObject , public Observer40 class GLMoleculeObject_molecule : public GLMoleculeObject 39 41 { 40 42 Q_OBJECT … … 42 44 GLMoleculeObject_molecule( 43 45 QObject *parent, 44 const moleculeId_t molid, 45 QtObservedInstanceBoard * _board, 46 std::vector<boost::any> _ObservedValues); 46 QtObservedInstanceBoard &_board, 47 QtObservedMolecule::ptr _ObservedMolecule); 47 48 GLMoleculeObject_molecule( 48 49 QGLSceneNode *mesh[], 49 50 QObject *parent, 50 const moleculeId_t molid, 51 QtObservedInstanceBoard * _board, 52 std::vector<boost::any> _ObservedValues); 51 QtObservedInstanceBoard &_board, 52 QtObservedMolecule::ptr _ObservedMolecule); 53 53 virtual ~GLMoleculeObject_molecule(); 54 55 // Observer functions56 void update(Observable *publisher);57 void subjectKilled(Observable *publisher);58 void recieveNotification(Observable *publisher, Notification_ptr notification);59 54 60 55 void initialize(QGLView *view, QGLPainter *painter); … … 76 71 void atomClicked(atomId_t no); 77 72 void moleculeClicked(moleculeId_t no); 78 void TesselationHullChanged();79 void BoundingBoxChanged();80 73 void IsSelectedChanged(); 81 void AtomInserted(const atomId_t _id);82 void AtomRemoved(const atomId_t _id);83 void IdChanged();84 74 85 75 private slots: … … 97 87 void setVisible(bool value); 98 88 99 void activateObserver();100 void deactivateObserver();101 102 89 void resetTesselationHull(); 103 90 void resetBoundingBox(); 104 91 void resetIndex(); 105 void resetName();106 92 107 93 void AtomSelected(const atomId_t _id); … … 111 97 112 98 private: 113 static const molecule * const getMolecule(const moleculeId_t _id);114 115 void init(const moleculeId_t _molid);116 117 private:118 99 void addAtomBonds( 119 100 const bond::ptr &_bond, … … 121 102 ); 122 103 104 void init(const moleculeId_t _molid); 105 123 106 //!> typedef for the internal set of atoms 124 107 typedef std::set<atomId_t> atoms_t; 125 126 static molecule::BoundingBoxInfo initBoundingBox();127 128 QGeometryData updateTesselationHull() const;129 static molecule::BoundingBoxInfo updateBoundingBox(130 const boost::function<const moleculeId_t ()> &_getMolIndex);131 static moleculeId_t updateIndex();132 static std::string updateName(133 const boost::function<const moleculeId_t ()> &_getMolIndex);134 108 135 109 /** Getter to contained atoms contained in \a ObservedValues. … … 139 113 atoms_t getPresentAtoms() const; 140 114 115 private: 116 141 117 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL) 142 118 const Observable * owner; 143 119 144 //!> internal variable for caching molecule ref in cstor 145 const molecule * const molref; 120 QGeometryData updateTesselationHull() const; 146 121 147 122 //!> list of channels when tesselation hull needs to update 148 123 static const Observable::channels_t HullChannels; 149 //!> list of channels when bounding box needs to update150 static const Observable::channels_t BoundingBoxChannels;151 //!> list of channels when the index needs to update152 static const Observable::channels_t IndexChannels;153 //!> list of channels when the name needs to update154 static const Observable::channels_t NameChannels;155 124 156 private: 157 friend class QtObservedInstanceBoard; 158 /** Observed Values **/ 159 160 //!> enumeration of observed values to match with entries in ObservedValues 161 enum ObservedTypes { 162 //!> contains the current molecule index 163 MolIndex, 164 //!> contains the current molecule name 165 MolName, 166 //!> contains newest version of the bounding box on request 167 BoundingBox, 168 //!> gives the size of the enumeration 169 MAX_ObservedTypes 170 }; 171 172 //!> vector with all observed values 173 std::vector<boost::any> ObservedValues; 174 175 /** Initializes all \a _ObservedValues entries. 176 * 177 * \param _ObservedValues vector of ObservedValue to be filled 178 * \param _moid molecule id 179 * \param _molref reference to molecule 180 * \param _subjectKilled ref to function to call on subjectKilled() 181 */ 182 static void initObservedValues( 183 std::vector<boost::any> &_ObservedValues, 184 const moleculeId_t _molid, 185 const molecule * const _molref, 186 const boost::function<void(const moleculeId_t)> &_subjectKilled); 187 188 /** Destroys all \a ObservedValues entries. 189 * 190 * \param _ObservedValues vector of ObservedValue to be destroyed 191 */ 192 static void destroyObservedValues( 193 std::vector<boost::any> &_ObservedValues); 194 195 /** Getter to molecule index contained in \a ObservedValues. 196 * 197 * \return molecule's index 198 */ 199 moleculeId_t getMolIndex() const; 200 201 /** Getter to molecule name contained in \a ObservedValues. 202 * 203 * \return molecule's name 204 */ 205 std::string getMolName() const; 206 207 /** Getter to molecule's bounding box contained in \a ObservedValues. 208 * 209 * \return molecule's bounding box 210 */ 211 molecule::BoundingBoxInfo getBoundingBox() const; 212 213 //!> counts how many ObservedValues have already been subjectKilled() 214 mutable size_t subjectKilledCount; 215 216 private: 125 //!> internal variable for caching molecule ref in cstor 126 const molecule * const molref; 217 127 218 128 boost::function<QGeometryData ()> TesselationHullUpdater; … … 231 141 atomId_t hoverAtomId; 232 142 233 //!> we get multiple subjectKilled(), count and call callback() only on last 234 const unsigned int AllsignedOnChannels; 235 unsigned int signedOnChannels; 143 QtObservedInstanceBoard &board; 236 144 237 QtObserved InstanceBoard * board;145 QtObservedMolecule::ptr ObservedMolecule; 238 146 }; 239 147 -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r65c323 r494478 166 166 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(_molid); 167 167 if (moliter != MoleculesinSceneMap.end()) { 168 // pass signal through 169 GLMoleculeObject_molecule *molObject = moliter->second; 170 QMetaObject::invokeMethod(molObject, // pointer to a QObject 171 "atomInserted", // member name (no parameters here) 172 Qt::QueuedConnection, // connection type 173 Q_ARG(const atomId_t, _atomid)); // parameters 168 // no action, is also caught via QtObservedMolecule by GLMoleculeObject_molecule 174 169 } else { 175 170 // store signal for when it is instantiated … … 194 189 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(_molid); 195 190 if (moliter != MoleculesinSceneMap.end()) { 196 // pass signal through 197 GLMoleculeObject_molecule *molObject = moliter->second; 198 QMetaObject::invokeMethod(molObject, // pointer to a QObject 199 "atomRemoved", // member name (no parameters here) 200 Qt::QueuedConnection, // connection type 201 Q_ARG(const atomId_t, _atomid)); // parameters 191 // no action, is also caught via QtObservedMolecule by GLMoleculeObject_molecule 202 192 } else { 203 193 // store signal for when it is instantiated … … 238 228 GLMoleculeObject::meshEmpty, 239 229 this, 240 _id, 241 board, 242 board->getMoleculeObservedValues(_id)); 230 *board, 231 board->getObservedMolecule(_id)); 243 232 ASSERT( molObject != NULL, 244 233 "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id));
Note:
See TracChangeset
for help on using the changeset viewer.