Changeset 8688ef for src/UIElements/Views/Qt4/Qt3D
- Timestamp:
- Feb 12, 2016, 11:15:05 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:
- 16bd37
- Parents:
- 7a205a
- git-author:
- Frederik Heber <heber@…> (10/17/15 12:40:14)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:05)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
r7a205a r8688ef 65 65 66 66 #include "ObservedValue_wCallback.hpp" 67 #include "ObservedValue_UpdateAtoms.hpp" 67 68 68 69 using namespace boost::assign; … … 109 110 * the class has not been fully constructed yet. "This" itself seems to be working fine. 110 111 */ 111 MolIndexUpdater( 112 boost::bind(&GLMoleculeObject_molecule::updateIndex, this) 113 ), 114 MolNameUpdater( 115 boost::bind(&GLMoleculeObject_molecule::updateName, this) 116 ), 112 ObservedValues(MAX_ObservedTypes), 113 subjectKilledCount(0), 117 114 TesselationHullUpdater( 118 115 boost::bind(&GLMoleculeObject_molecule::updateTesselationHull, this) 119 116 ), 120 BoundingBoxUpdater(121 boost::bind(&GLMoleculeObject_molecule::updateBoundingBox, this)122 ),123 PresentAtomsUpdater(124 boost::bind(&GLMoleculeObject_molecule::updateAtoms, this)125 ),126 ObservedValues(MAX_ObservedTypes),127 subjectKilledCount(0),128 117 TesselationHull( 129 118 molref, … … 133 122 hoverAtomId(-1) 134 123 { 135 initObservedValues(_molid); 124 boost::function<void()> subjectKilled = 125 boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this); 126 initObservedValues(ObservedValues, _molid, molref, subjectKilled); 136 127 137 128 setObjectId(_molid); … … 166 157 * the class has not been fully constructed yet. "This" itself seems to be working fine. 167 158 */ 168 MolIndexUpdater( 169 boost::bind(&GLMoleculeObject_molecule::updateIndex, this) 170 ), 171 MolNameUpdater( 172 boost::bind(&GLMoleculeObject_molecule::updateName, this) 173 ), 159 ObservedValues(MAX_ObservedTypes), 160 subjectKilledCount(0), 174 161 TesselationHullUpdater( 175 162 boost::bind(&GLMoleculeObject_molecule::updateTesselationHull, this) 176 163 ), 177 BoundingBoxUpdater(178 boost::bind(&GLMoleculeObject_molecule::updateBoundingBox, this)179 ),180 PresentAtomsUpdater(181 boost::bind(&GLMoleculeObject_molecule::updateAtoms, this)182 ),183 ObservedValues(MAX_ObservedTypes),184 subjectKilledCount(0),185 164 TesselationHull( 186 165 molref, … … 190 169 hoverAtomId(-1) 191 170 { 192 initObservedValues(_molid); 171 boost::function<void()> subjectKilled = 172 boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this); 173 initObservedValues(ObservedValues, _molid, molref, subjectKilled); 193 174 194 175 setObjectId(_molid); … … 216 197 { 217 198 deactivateObserver(); 218 destroyObservedValues( );199 destroyObservedValues(ObservedValues); 219 200 } 220 201 … … 366 347 } 367 348 368 molecule::BoundingBoxInfo GLMoleculeObject_molecule::initBoundingBox() const349 molecule::BoundingBoxInfo GLMoleculeObject_molecule::initBoundingBox() 369 350 { 370 351 molecule::BoundingBoxInfo info; … … 374 355 } 375 356 376 molecule::BoundingBoxInfo GLMoleculeObject_molecule::updateBoundingBox() const 377 { 378 return getBoundingBox(); 379 } 380 381 GLMoleculeObject_molecule::atoms_t GLMoleculeObject_molecule::updateAtoms() 382 { 383 atoms_t current_atomset = getPresentAtoms(); 384 const molecule * const mol = getMolecule(getMolIndex()); 385 if (mol != NULL) { 386 const atomId_t id = mol->lastChangedAtomId(); 387 if (mol->containsAtom(id)) 388 current_atomset.insert(id); 389 else 390 current_atomset.erase(id); 391 } 392 return current_atomset; 393 } 394 395 moleculeId_t GLMoleculeObject_molecule::updateIndex() const 357 molecule::BoundingBoxInfo GLMoleculeObject_molecule::updateBoundingBox( 358 const boost::function<const moleculeId_t ()> &_getMolIndex) 359 { 360 const molecule * const mol = getMolecule(_getMolIndex()); 361 return mol->getBoundingBox(); 362 } 363 364 moleculeId_t GLMoleculeObject_molecule::updateIndex() 396 365 { 397 366 return const_cast<const World &>(World::getInstance()).lastChangedMolId(); 398 367 } 399 368 400 std::string GLMoleculeObject_molecule::updateName() const 401 { 402 const molecule * const mol = getMolecule(getMolIndex()); 369 std::string GLMoleculeObject_molecule::updateName( 370 const boost::function<const moleculeId_t ()> &_getMolIndex) 371 { 372 const molecule * const mol = getMolecule(_getMolIndex()); 403 373 return mol->getName(); 404 374 } … … 540 510 case World::AtomRemoved: 541 511 { 542 const atomId_t _id = _molecule->lastChangedAtomId();512 // const atomId_t _id = _molecule->lastChangedAtomId(); 543 513 #ifdef LOG_OBSERVER 544 514 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed."; … … 882 852 } 883 853 884 void GLMoleculeObject_molecule::initObservedValues(const moleculeId_t _molid) 885 { 886 // fill ObservedValues 887 boost::function<void()> subjectKilled = 888 boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this); 889 ObservedValues[MolIndex] = new ObservedValue_wCallback<moleculeId_t>( 890 molref, 891 MolIndexUpdater, 892 "MoleculeIndex_"+toString(_molid), 893 _molid, 894 IndexChannels, 895 subjectKilled); 896 ObservedValues[MolName] = new ObservedValue_wCallback<std::string>( 897 molref, 854 void GLMoleculeObject_molecule::initObservedValues( 855 std::vector<boost::any> &_ObservedValues, 856 const moleculeId_t _molid, 857 const molecule * const _molref, 858 const boost::function<void()> &_subjectKilled) 859 { 860 /* This is an old note from when the code was still part of cstor's initializer body. 861 * TODO: Probably does not apply anymore but has not yet been tested. 862 * 863 * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly 864 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because 865 * the class has not been fully constructed yet. "This" itself seems to be working fine. 866 */ 867 868 ASSERT( _ObservedValues.size() == MAX_ObservedTypes, 869 "GLMoleculeObject_molecule::initObservedValues() - given ObservedValues has not correct size."); 870 871 // fill ObservedValues: index first 872 const boost::function<moleculeId_t ()> MolIndexUpdater( 873 boost::bind(&GLMoleculeObject_molecule::updateIndex)); 874 875 ObservedValue_wCallback<moleculeId_t> * const IndexObservable = 876 new ObservedValue_wCallback<moleculeId_t>( 877 _molref, 878 MolIndexUpdater, 879 "MoleculeIndex_"+toString(_molid), 880 _molid, 881 IndexChannels, 882 _subjectKilled); 883 _ObservedValues[MolIndex] = IndexObservable; 884 885 const boost::function<const moleculeId_t ()> MolIndexGetter = 886 boost::bind(&ObservedValue_wCallback<moleculeId_t>::get, 887 IndexObservable); 888 889 // fill ObservedValues: then all the other that need index 890 const boost::function<std::string ()> MolNameUpdater( 891 boost::bind(&GLMoleculeObject_molecule::updateName, MolIndexGetter)); 892 const boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater( 893 boost::bind(&GLMoleculeObject_molecule::updateBoundingBox, MolIndexGetter)); 894 895 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string>( 896 _molref, 898 897 MolNameUpdater, 899 898 "MoleculeName_"+toString(_molid), 900 updateName(),899 MolNameUpdater(), 901 900 NameChannels, 902 subjectKilled);903 ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo>(904 molref,901 _subjectKilled); 902 _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo>( 903 _molref, 905 904 BoundingBoxUpdater, 906 905 "MoleculeBoundingBox_"+toString(_molid), 907 906 initBoundingBox(), 908 907 BoundingBoxChannels, 909 subjectKilled); 910 ObservedValues[PresentAtoms] = new ObservedValue_wCallback<atoms_t>( 911 molref, 912 PresentAtomsUpdater, 908 _subjectKilled); 909 _ObservedValues[PresentAtoms] = new ObservedValue_UpdateAtoms( 910 _molref, 913 911 "MoleculeAtoms_"+toString(_molid), 914 updateAtoms(),915 912 AtomsChannels, 916 subjectKilled); 917 } 918 919 void GLMoleculeObject_molecule::destroyObservedValues() 920 { 921 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex]); 922 delete boost::any_cast<ObservedValue_wCallback<std::string> *>(ObservedValues[MolName]); 923 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo> *>(ObservedValues[BoundingBox]); 924 delete boost::any_cast<ObservedValue_wCallback<atoms_t> *>(ObservedValues[PresentAtoms]); 925 ObservedValues.clear(); 913 _subjectKilled, 914 MolIndexGetter); 915 } 916 917 void GLMoleculeObject_molecule::destroyObservedValues( 918 std::vector<boost::any> &_ObservedValues) 919 { 920 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]); 921 delete boost::any_cast<ObservedValue_wCallback<std::string> *>(_ObservedValues[MolName]); 922 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo> *>(_ObservedValues[BoundingBox]); 923 delete boost::any_cast<ObservedValue_UpdateAtoms *>(_ObservedValues[PresentAtoms]); 924 _ObservedValues.clear(); 926 925 } 927 926 … … 943 942 GLMoleculeObject_molecule::atoms_t GLMoleculeObject_molecule::getPresentAtoms() const 944 943 { 945 return boost::any_cast<ObservedValue_ wCallback<atoms_t>*>(ObservedValues[PresentAtoms])->get();946 } 944 return boost::any_cast<ObservedValue_UpdateAtoms *>(ObservedValues[PresentAtoms])->get(); 945 } -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp
r7a205a r8688ef 20 20 #include <vector> 21 21 #include <boost/any.hpp> 22 #include <boost/function.hpp> 22 23 23 24 #include "CodePatterns/Cacheable.hpp" … … 114 115 typedef std::set<atomId_t> atoms_t; 115 116 116 molecule::BoundingBoxInfo initBoundingBox() const;117 static molecule::BoundingBoxInfo initBoundingBox(); 117 118 118 119 QGeometryData updateTesselationHull() const; 119 molecule::BoundingBoxInfo updateBoundingBox() const; 120 atoms_t updateAtoms(); 121 moleculeId_t updateIndex() const; 122 std::string updateName() const; 120 static molecule::BoundingBoxInfo updateBoundingBox( 121 const boost::function<const moleculeId_t ()> &_getMolIndex); 122 static moleculeId_t updateIndex(); 123 static std::string updateName( 124 const boost::function<const moleculeId_t ()> &_getMolIndex); 123 125 124 126 //!> the Observable we are signed on, also indicates whether we are sign on (not NULL) … … 138 140 //!> list of channels when the name needs to update 139 141 static const Observable::channels_t NameChannels; 140 141 boost::function<moleculeId_t ()> MolIndexUpdater;142 boost::function<std::string ()> MolNameUpdater;143 boost::function<QGeometryData ()> TesselationHullUpdater;144 boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater;145 boost::function<atoms_t ()> PresentAtomsUpdater;146 142 147 143 private: … … 165 161 std::vector<boost::any> ObservedValues; 166 162 167 /** Initializes all \a ObservedValues entries. 168 * 163 /** Initializes all \a _ObservedValues entries. 164 * 165 * \param _ObservedValues vector of ObservedValue to be filled 169 166 * \param _moid molecule id 170 */ 171 void initObservedValues(const moleculeId_t _molid); 167 * \param _molref reference to molecule 168 * \param _subjectKilled ref to function to call on subjectKilled() 169 */ 170 static void initObservedValues( 171 std::vector<boost::any> &_ObservedValues, 172 const moleculeId_t _molid, 173 const molecule * const _molref, 174 const boost::function<void()> &_subjectKilled); 172 175 173 176 /** Destroys all \a ObservedValues entries. 174 177 * 175 */ 176 void destroyObservedValues(); 178 * \param _ObservedValues vector of ObservedValue to be destroyed 179 */ 180 static void destroyObservedValues( 181 std::vector<boost::any> &_ObservedValues); 177 182 178 183 /** Getter to molecule index contained in \a ObservedValues. … … 212 217 mutable size_t subjectKilledCount; 213 218 219 private: 220 221 boost::function<QGeometryData ()> TesselationHullUpdater; 222 214 223 //!> contains current version of the tesselation hull on request 215 224 Cacheable<QGeometryData> TesselationHull; 216 225 217 private:218 226 //!> contains the set of atoms displayed 219 227 atoms_t DisplayedAtoms;
Note:
See TracChangeset
for help on using the changeset viewer.