Changeset 494478
- 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
- Files:
-
- 13 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Makefile.am
r65c323 r494478 147 147 UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp \ 148 148 UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp \ 149 UIElements/ Views/Qt4/Qt3D/ObservedValue_UpdateAtoms.hpp \150 UIElements/ Views/Qt4/Qt3D/ObservedValue_wCallback.hpp149 UIElements/Qt4/InstanceBoard/ObservedValue_UpdateAtoms.hpp \ 150 UIElements/Qt4/InstanceBoard/ObservedValue_wCallback.hpp 151 151 152 152 QTUISOURCE = \ -
src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp
r65c323 r494478 38 38 ++(iter->second.second); 39 39 typename T::ptr _molecule(new T(obsvalues, board)); 40 41 return _molecule;42 }43 44 template <>45 typename QtObservedMolecule::ptr46 ObservedValuesContainer<QtObservedMolecule,moleculeId_t>::get(const moleculeId_t _id)47 {48 typename CountedObservedValues_t::iterator iter = ObservedValues.find(_id);49 ASSERT( iter != ObservedValues.end(),50 "ObservedValuesContainer::getObservedValues() - no observed values present for "51 +NameOfType+" "+toString(_id));52 const ObservedValues_t &obsvalues = iter->second.first;53 // increase refcount54 ++(iter->second.second);55 typename QtObservedMolecule::ptr _molecule(new QtObservedMolecule(obsvalues));56 40 57 41 return _molecule; -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp
r65c323 r494478 48 48 #include "World.hpp" 49 49 50 #include "UIElements/ Views/Qt4/Qt3D/ObservedValue_wCallback.hpp"50 #include "UIElements/Qt4/InstanceBoard/ObservedValue_wCallback.hpp" 51 51 52 52 using namespace boost::assign; -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp
r65c323 r494478 36 36 #include "QtObservedInstanceBoard.hpp" 37 37 38 #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp"39 38 #include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp" 39 #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp" 40 40 41 41 #include "CodePatterns/MemDebug.hpp" … … 134 134 getMolecule(MoleculeById(_id)); 135 135 if (_molecule != NULL) { 136 ObservedValues_t ObservedValues( GLMoleculeObject_molecule::MAX_ObservedTypes);136 ObservedValues_t ObservedValues(QtObservedMolecule::MAX_ObservedTypes); 137 137 LOG(3, "DEBUG: InformationBoard initializes ObservedValues for molecule " << _id); 138 GLMoleculeObject_molecule::initObservedValues(138 QtObservedMolecule::initObservedValues( 139 139 ObservedValues, 140 140 _id, … … 327 327 ++(iter->second); 328 328 329 if (iter->second > GLMoleculeObject_molecule::MAX_ObservedTypes) {329 if (iter->second > QtObservedMolecule::MAX_ObservedTypes) { 330 330 ASSERT( moleculeObservedValues.getRefCount(_molid) == 0, 331 331 "QtObservedInstanceBoard::moleculecountsubjectKilled() - observed Values for molecule " -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp
r65c323 r494478 101 101 friend class GLWorldScene; 102 102 friend class GLMoleculeObject_bond; 103 friend class GLMoleculeObject_molecule;104 103 friend class QtObservedAtom; 104 friend class QtObservedMolecule; 105 105 106 106 //!> indicating whether we are still signedOn to World or not -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp
r65c323 r494478 36 36 #include "QtObservedMolecule.hpp" 37 37 38 #include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp" 39 38 40 #include "CodePatterns/MemDebug.hpp" 41 #include "CodePatterns/Assert.hpp" 42 #include "CodePatterns/Log.hpp" 43 44 #include <boost/assign.hpp> 45 #include <boost/bind.hpp> 46 47 #include "UIElements/Qt4/InstanceBoard/ObservedValue_wCallback.hpp" 48 #include "UIElements/Qt4/InstanceBoard/ObservedValue_UpdateAtoms.hpp" 49 50 #include "Atom/atom.hpp" 51 #include "Descriptors/MoleculeIdDescriptor.hpp" 52 #include "World.hpp" 53 54 using namespace boost::assign; 55 56 static const Observable::channels_t getAllObservedChannels() 57 { 58 Observable::channels_t channels; 59 channels += 60 molecule::AtomInserted, 61 molecule::AtomRemoved, 62 molecule::IndexChanged, 63 molecule::MoleculeNameChanged, 64 molecule::BoundingBoxChanged; 65 return channels; 66 } 67 68 // static instances 69 const Observable::channels_t QtObservedMolecule::BoundingBoxChannels(1, molecule::BoundingBoxChanged); 70 const Observable::channels_t QtObservedMolecule::IndexChannels(1, molecule::IndexChanged); 71 const Observable::channels_t QtObservedMolecule::NameChannels(1, molecule::MoleculeNameChanged); 39 72 40 73 QtObservedMolecule::QtObservedMolecule( 41 const ObservedValues_t &_obsvalues, 74 const ObservedValues_t &_ObservedValues, 75 QtObservedInstanceBoard &_board, 42 76 QWidget * _parent) : 43 77 QWidget(_parent), 44 78 Observer("QtObservedMolecule"), 45 obsvalues(_obsvalues) 46 {} 79 subjectKilledCount(0), 80 AllsignedOnChannels(getAllObservedChannels().size()), 81 signedOffChannels(0), 82 owner(NULL), 83 board(_board), 84 ObservedValues(_ObservedValues) 85 { 86 activateObserver(); 87 } 47 88 48 89 QtObservedMolecule::~QtObservedMolecule() 49 {} 90 { 91 deactivateObserver(); 92 } 93 94 void QtObservedMolecule::deactivateObserver() 95 { 96 if (owner != NULL) { 97 Observable::channels_t channels = getAllObservedChannels(); 98 for (Observable::channels_t::const_iterator iter = channels.begin(); 99 iter != channels.end(); ++iter) 100 owner->signOff(this, *iter); 101 owner = NULL; 102 signedOffChannels = AllsignedOnChannels; 103 } 104 } 105 106 void QtObservedMolecule::activateObserver() 107 { 108 // sign on as observer (obtain non-const instance before) 109 const molecule * const _molecule = getMolecule(getMolIndex()); 110 if (_molecule != NULL) { 111 Observable::channels_t channels = getAllObservedChannels(); 112 owner = static_cast<const Observable *>(_molecule); 113 for (Observable::channels_t::const_iterator iter = channels.begin(); 114 iter != channels.end(); ++iter) 115 owner->signOn(this, *iter); 116 } else 117 signedOffChannels = AllsignedOnChannels; 118 } 50 119 51 120 void QtObservedMolecule::update(Observable *publisher) 52 {} 121 { 122 ASSERT(0, 123 "QtObservedMolecule::update() - general update from unexpected source."); 124 } 53 125 54 126 void QtObservedMolecule::subjectKilled(Observable *publisher) 55 {} 127 { 128 ++signedOffChannels; 129 130 if (signedOffChannels == AllsignedOnChannels) { 131 // remove owner: no more signOff needed 132 owner = NULL; 133 134 board.moleculecountsubjectKilled(getMolIndex()); 135 } 136 } 56 137 57 138 void QtObservedMolecule::recieveNotification(Observable *publisher, Notification_ptr notification) 58 {} 139 { 140 const molecule * const _molecule = getMolecule(getMolIndex()); 141 // when molecule is NULL we will soon get destroyed anyway 142 if (_molecule == NULL) 143 return; 144 if (publisher == dynamic_cast<const Observable*>(_molecule)){ 145 // notification from atom 146 #ifdef LOG_OBSERVER 147 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this)) 148 << " received notification from molecule " << getMolIndex() << " for channel " 149 << notification->getChannelNo() << "."; 150 #endif 151 switch (notification->getChannelNo()) { 152 case molecule::AtomInserted: 153 { 154 const atomId_t _id = _molecule->lastChangedAtomId(); 155 emit atomInserted(_id); 156 break; 157 } 158 case molecule::AtomRemoved: 159 { 160 const atomId_t _id = _molecule->lastChangedAtomId(); 161 emit atomRemoved(_id); 162 break; 163 } 164 case molecule::BoundingBoxChanged: 165 { 166 #ifdef LOG_OBSERVER 167 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that bounding box has changed."; 168 #endif 169 emit tesselationhullChanged(); 170 emit boundingboxChanged(); 171 break; 172 } 173 case molecule::IndexChanged: 174 { 175 #ifdef LOG_OBSERVER 176 const atomId_t _id = _molecule->lastChangedAtomId(); 177 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+"'s index has changed."; 178 #endif 179 emit indexChanged(); 180 break; 181 } 182 case molecule::MoleculeNameChanged: 183 { 184 #ifdef LOG_OBSERVER 185 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that name has changed."; 186 #endif 187 emit nameChanged(); 188 break; 189 } 190 default: 191 break; 192 } 193 } 194 } 195 196 const molecule * const QtObservedMolecule::getMolecule(const moleculeId_t _id) 197 { 198 const molecule * const mol = const_cast<const World &>(World::getInstance()). 199 getMolecule(MoleculeById(_id)); 200 return mol; 201 } 202 203 static molecule::BoundingBoxInfo initBoundingBox() 204 { 205 molecule::BoundingBoxInfo info; 206 info.position = zeroVec; 207 info.radius = 0.; 208 return info; 209 } 210 211 void QtObservedMolecule::initObservedValues( 212 ObservedValues_t &_ObservedValues, 213 const moleculeId_t _molid, 214 const molecule * const _molref, 215 const boost::function<void(const moleculeId_t)> &_subjectKilled) 216 { 217 /* This is an old note from when the code was still part of cstor's initializer body. 218 * TODO: Probably does not apply anymore but has not yet been tested. 219 * 220 * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly 221 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because 222 * the class has not been fully constructed yet. "This" itself seems to be working fine. 223 */ 224 225 ASSERT( _ObservedValues.size() == MAX_ObservedTypes, 226 "QtObservedMolecule::initObservedValues() - given ObservedValues has not correct size."); 227 228 // fill ObservedValues: index first 229 const boost::function<moleculeId_t ()> MolIndexUpdater( 230 boost::bind(&QtObservedMolecule::updateIndex)); 231 232 ObservedValue_wCallback<moleculeId_t> * const IndexObservable = 233 new ObservedValue_wCallback<moleculeId_t>( 234 _molref, 235 MolIndexUpdater, 236 "MoleculeIndex_"+toString(_molid), 237 _molid, 238 IndexChannels, 239 _subjectKilled); 240 _ObservedValues[MolIndex] = IndexObservable; 241 242 const boost::function<const moleculeId_t ()> MolIndexGetter = 243 boost::bind(&ObservedValue_wCallback<moleculeId_t>::get, 244 IndexObservable); 245 246 // fill ObservedValues: then all the other that need index 247 const boost::function<std::string ()> MolNameUpdater( 248 boost::bind(&QtObservedMolecule::updateName, MolIndexGetter)); 249 const boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater( 250 boost::bind(&QtObservedMolecule::updateBoundingBox, MolIndexGetter)); 251 252 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>( 253 _molref, 254 MolNameUpdater, 255 "MoleculeName_"+toString(_molid), 256 MolNameUpdater(), 257 NameChannels, 258 _subjectKilled, 259 MolIndexGetter); 260 _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t>( 261 _molref, 262 BoundingBoxUpdater, 263 "MoleculeBoundingBox_"+toString(_molid), 264 initBoundingBox(), 265 BoundingBoxChannels, 266 _subjectKilled, 267 MolIndexGetter); 268 } 269 270 void QtObservedMolecule::destroyObservedValues( 271 std::vector<boost::any> &_ObservedValues) 272 { 273 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]); 274 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]); 275 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]); 276 _ObservedValues.clear(); 277 } 278 279 molecule::BoundingBoxInfo QtObservedMolecule::updateBoundingBox( 280 const boost::function<const moleculeId_t ()> &_getMolIndex) 281 { 282 const molecule * const mol = getMolecule(_getMolIndex()); 283 if (mol != NULL) 284 return mol->getBoundingBox(); 285 else 286 return molecule::BoundingBoxInfo(); 287 } 288 289 moleculeId_t QtObservedMolecule::updateIndex() 290 { 291 return const_cast<const World &>(World::getInstance()).lastChangedMolId(); 292 } 293 294 std::string QtObservedMolecule::updateName( 295 const boost::function<const moleculeId_t ()> &_getMolIndex) 296 { 297 const molecule * const mol = getMolecule(_getMolIndex()); 298 if (mol != NULL) 299 return mol->getName(); 300 else 301 return std::string(""); 302 } 303 304 moleculeId_t QtObservedMolecule::getMolIndex() const 305 { 306 return boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->get(); 307 } 308 309 std::string QtObservedMolecule::getMolName() const 310 { 311 return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->get(); 312 } 313 314 molecule::BoundingBoxInfo QtObservedMolecule::getBoundingBox() const 315 { 316 return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->get(); 317 } -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp
r65c323 r494478 17 17 #include <QtGui/QWidget> 18 18 19 #include <boost/function.hpp> 19 20 #include <boost/shared_ptr.hpp> 20 21 22 #include "CodePatterns/Observer/Observable.hpp" 21 23 #include "CodePatterns/Observer/Observer.hpp" 22 24 25 #include "molecule.hpp" 23 26 #include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp" 24 27 #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp" … … 41 44 Q_OBJECT 42 45 46 public: 47 48 //!> typedef for instance wrapped in shared ptr 49 typedef boost::shared_ptr<QtObservedMolecule> ptr; 50 51 private: 43 52 //!> ObservedValuesContainer needs to access private cstor and dstor 44 53 friend class ObservedValuesContainer<QtObservedMolecule, moleculeId_t>; … … 46 55 friend class QtObservedInstanceBoard; 47 56 48 //!> typedef for instance wrapped in shared ptr49 typedef boost::shared_ptr<QtObservedMolecule> ptr;50 51 57 /** Cstor of QtObservedMolecule. 52 58 * 53 * \param _obsvalues ref to set of observed values for this instance 59 * \param _ObservedValues ref to set of observed values for this instance 60 * \param _board ref to InstanceBoard for callbacks on occasion of subjectKilled() 54 61 * \param _parent Qt parent to automatically destroy when parent is destroyed 55 62 */ 56 63 QtObservedMolecule( 57 const ObservedValues_t &_obsvalues, 64 const ObservedValues_t &_ObservedValues, 65 QtObservedInstanceBoard &_board, 58 66 QWidget * _parent=0); 59 67 … … 70 78 void recieveNotification(Observable *publisher, Notification_ptr notification); 71 79 80 /** Getter to molecule index contained in \a ObservedValues. 81 * 82 * \return molecule's index 83 */ 84 moleculeId_t getMolIndex() const; 85 86 /** Getter to molecule name contained in \a ObservedValues. 87 * 88 * \return molecule's name 89 */ 90 std::string getMolName() const; 91 92 /** Getter to molecule's bounding box contained in \a ObservedValues. 93 * 94 * \return molecule's bounding box 95 */ 96 molecule::BoundingBoxInfo getBoundingBox() const; 97 98 static const molecule * const getMolecule(const moleculeId_t _id); 99 72 100 signals: 73 74 private slots: 75 101 void indexChanged(); 102 void nameChanged(); 103 void tesselationhullChanged(); 104 void boundingboxChanged(); 105 void atomInserted(const atomId_t); 106 void atomRemoved(const atomId_t); 76 107 77 108 private: 109 110 void activateObserver(); 111 void deactivateObserver(); 112 113 private: 114 static molecule::BoundingBoxInfo updateBoundingBox( 115 const boost::function<const moleculeId_t ()> &_getMolIndex); 116 static moleculeId_t updateIndex(); 117 static std::string updateName( 118 const boost::function<const moleculeId_t ()> &_getMolIndex); 119 120 //!> list of channels when bounding box needs to update 121 static const Observable::channels_t BoundingBoxChannels; 122 //!> list of channels when the index needs to update 123 static const Observable::channels_t IndexChannels; 124 //!> list of channels when the name needs to update 125 static const Observable::channels_t NameChannels; 126 127 private: 128 /** Observed Values **/ 129 130 //!> enumeration of observed values to match with entries in ObservedValues 131 enum ObservedTypes { 132 //!> contains the current molecule index 133 MolIndex, 134 //!> contains the current molecule name 135 MolName, 136 //!> contains newest version of the bounding box on request 137 BoundingBox, 138 //!> gives the size of the enumeration 139 MAX_ObservedTypes 140 }; 141 142 /** Initializes all \a _ObservedValues entries. 143 * 144 * \param _ObservedValues vector of ObservedValue to be filled 145 * \param _moid molecule id 146 * \param _molref reference to molecule 147 * \param _subjectKilled ref to function to call on subjectKilled() 148 */ 149 static void initObservedValues( 150 ObservedValues_t &_ObservedValues, 151 const moleculeId_t _molid, 152 const molecule * const _molref, 153 const boost::function<void(const moleculeId_t)> &_subjectKilled); 154 155 /** Destroys all \a ObservedValues entries. 156 * 157 * \param _ObservedValues vector of ObservedValue to be destroyed 158 */ 159 static void destroyObservedValues( 160 std::vector<boost::any> &_ObservedValues); 161 162 //!> counts how many ObservedValues have already been subjectKilled() 163 mutable size_t subjectKilledCount; 164 165 private: 166 167 //!> we get multiple subjectKilled(), count and call callback() only on last 168 const unsigned int AllsignedOnChannels; 169 unsigned int signedOffChannels; 170 171 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL) 172 const Observable *owner; 173 174 private: 175 176 //!> reference to InstanceBoard for callbacks on subjectKilled() 177 QtObservedInstanceBoard & board; 178 78 179 //!> internal reference to ObservedValues held by QtObservedInstanceBoard 79 const ObservedValues_t &obsvalues;180 ObservedValues_t ObservedValues; 80 181 }; 81 182 -
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.