Changeset 16bd37 for src/UIElements
- 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:
- 099f67
- Parents:
- 8688ef
- git-author:
- Frederik Heber <heber@…> (10/17/15 12:55:30)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:05)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
r8688ef r16bd37 86 86 owner(NULL) 87 87 { 88 initObservedValues(_id); 88 boost::function<void()> subjectKilled = 89 boost::bind(&GLMoleculeObject_atom::countsubjectKilled, this); 90 initObservedValues(ObservedValues, _id, atomref, subjectKilled); 89 91 90 92 setObjectId(_id); … … 136 138 { 137 139 deactivateObserver(); 138 destroyObservedValues( );140 destroyObservedValues(ObservedValues); 139 141 } 140 142 … … 259 261 } 260 262 261 atomId_t GLMoleculeObject_atom::updateIndex() const263 atomId_t GLMoleculeObject_atom::updateIndex() 262 264 { 263 265 return const_cast<const World &>(World::getInstance()).lastChangedAtomId(); 264 266 } 265 267 266 Vector GLMoleculeObject_atom::updatePosition() const 267 { 268 const atom * const _atom = getAtom(getAtomIndex()); 268 Vector GLMoleculeObject_atom::updatePosition( 269 const boost::function<const atomId_t ()> &_getAtomIndex) 270 { 271 const atom * const _atom = getAtomConst(_getAtomIndex()); 269 272 if (_atom != NULL) { 270 273 return _atom->getPosition(); … … 274 277 } 275 278 276 atomicNumber_t GLMoleculeObject_atom::updateElement() const 277 { 278 const atom * const _atom = getAtom(getAtomIndex()); 279 atomicNumber_t GLMoleculeObject_atom::updateElement( 280 const boost::function<const atomId_t ()> &_getAtomIndex) 281 { 282 const atom * const _atom = getAtomConst(_getAtomIndex()); 279 283 if (_atom != NULL) { 280 284 return _atom->getElementNo(); … … 284 288 } 285 289 286 GLMoleculeObject_atom::ListOfBonds_t GLMoleculeObject_atom::updateBonds() const 290 GLMoleculeObject_atom::ListOfBonds_t GLMoleculeObject_atom::updateBonds( 291 const boost::function<const atomId_t ()> &_getAtomIndex) 287 292 { 288 293 ListOfBonds_t ListOfBonds; 289 const atom * const _atom = getAtom (getAtomIndex());294 const atom * const _atom = getAtomConst(_getAtomIndex()); 290 295 if (_atom != NULL) { 291 // make sure positionis up-to-date296 // make sure bonds is up-to-date 292 297 const BondList ListBonds = _atom->getListOfBonds(); 293 298 for (BondList::const_iterator iter = ListBonds.begin(); … … 298 303 (*iter)->rightatom->getId()) ); 299 304 } else { 300 ELOG(2, "Atom with id "+toString( getAtomIndex())+" is already gone.");305 ELOG(2, "Atom with id "+toString(_getAtomIndex())+" is already gone."); 301 306 } 302 307 return ListOfBonds; … … 351 356 } 352 357 353 void GLMoleculeObject_atom::initObservedValues(const atomId_t _id) 354 { 355 // fill ObservedValues 356 boost::function<void()> subjectKilled = 357 boost::bind(&GLMoleculeObject_atom::countsubjectKilled, this); 358 ObservedValues[AtomIndex] = new ObservedValue_wCallback<atomId_t>( 359 atomref, 360 boost::bind(&GLMoleculeObject_atom::updateIndex, this), 361 "AtomIndex_"+toString(_id), 362 _id, 363 AtomIndexChannels, 364 subjectKilled); 365 ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector>( 366 atomref, 367 boost::bind(&GLMoleculeObject_atom::updatePosition, this), 358 void GLMoleculeObject_atom::initObservedValues( 359 std::vector<boost::any> &_ObservedValues, 360 const atomId_t _id, 361 const atom * const _atomref, 362 const boost::function<void()> &_subjectKilled) 363 { 364 /* This is an old note from when the code was still part of cstor's initializer body. 365 * TODO: Probably does not apply anymore but has not yet been tested. 366 * 367 * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly 368 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because 369 * the class has not been fully constructed yet. "This" itself seems to be working fine. 370 */ 371 372 ASSERT( _ObservedValues.size() == MAX_ObservedTypes, 373 "GLMoleculeObject_atom::initObservedValues() - given ObservedValues has not correct size."); 374 375 // fill ObservedValues: index first 376 const boost::function<atomId_t ()> AtomIndexUpdater( 377 boost::bind(&GLMoleculeObject_atom::updateIndex)); 378 379 ObservedValue_wCallback<atomId_t> * const IndexObservable = 380 new ObservedValue_wCallback<atomId_t>( 381 _atomref, 382 boost::bind(&GLMoleculeObject_atom::updateIndex), 383 "AtomIndex_"+toString(_id), 384 _id, 385 AtomIndexChannels, 386 _subjectKilled); 387 _ObservedValues[AtomIndex] = IndexObservable; 388 389 const boost::function<const atomId_t ()> AtomIndexGetter = 390 boost::bind(&ObservedValue_wCallback<atomId_t>::get, 391 IndexObservable); 392 393 // fill ObservedValues: then all the other that need index 394 const boost::function<Vector ()> AtomPositionUpdater( 395 boost::bind(&GLMoleculeObject_atom::updatePosition, AtomIndexGetter)); 396 const boost::function<atomicNumber_t ()> AtomElementUpdater( 397 boost::bind(&GLMoleculeObject_atom::updateElement, AtomIndexGetter)); 398 const boost::function<ListOfBonds_t ()> AtomBondsUpdater( 399 boost::bind(&GLMoleculeObject_atom::updateBonds, AtomIndexGetter)); 400 401 _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector>( 402 _atomref, 403 AtomPositionUpdater, 368 404 "AtomPosition_"+toString(_id), 369 updatePosition(),405 AtomPositionUpdater(), 370 406 AtomPositionChannels, 371 subjectKilled);372 ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t>(373 atomref,374 boost::bind(&GLMoleculeObject_atom::updateElement, this),407 _subjectKilled); 408 _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t>( 409 _atomref, 410 AtomElementUpdater, 375 411 "AtomElement"+toString(_id), 376 updateElement(),412 AtomElementUpdater(), 377 413 AtomElementChannels, 378 subjectKilled);379 ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t>(380 atomref,381 boost::bind(&GLMoleculeObject_atom::updateBonds, this),414 _subjectKilled); 415 _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t>( 416 _atomref, 417 AtomBondsUpdater, 382 418 "AtomBonds_"+toString(_id), 383 updateBonds(),419 AtomBondsUpdater(), 384 420 AtomBondsChannels, 385 subjectKilled); 386 } 387 388 void GLMoleculeObject_atom::destroyObservedValues() 389 { 390 delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex]); 391 delete boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[AtomPosition]); 392 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[AtomElement]); 393 delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t> *>(ObservedValues[AtomBonds]); 394 ObservedValues.clear(); 421 _subjectKilled); 422 } 423 424 void GLMoleculeObject_atom::destroyObservedValues( 425 std::vector<boost::any> &_ObservedValues) 426 { 427 delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[AtomIndex]); 428 delete boost::any_cast<ObservedValue_wCallback<Vector> *>(_ObservedValues[AtomPosition]); 429 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(_ObservedValues[AtomElement]); 430 delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t> *>(_ObservedValues[AtomBonds]); 431 _ObservedValues.clear(); 395 432 } 396 433 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
r8688ef r16bd37 76 76 static atom * const getAtom(const atomId_t _id); 77 77 78 atomId_t updateIndex() const; 79 Vector updatePosition() const; 80 atomicNumber_t updateElement() const; 81 ListOfBonds_t updateBonds() const; 78 static atomId_t updateIndex(); 79 static Vector updatePosition( 80 const boost::function<const atomId_t ()> &_getAtomIndex); 81 static atomicNumber_t updateElement( 82 const boost::function<const atomId_t ()> &_getAtomIndex); 83 static ListOfBonds_t updateBonds( 84 const boost::function<const atomId_t ()> &_getAtomIndex); 82 85 83 86 void activateObserver(); … … 114 117 /** Initializes all \a ObservedValues entries. 115 118 * 119 * \param _ObservedValues vector of ObservedValue to be filled 116 120 * \param _id atom id 121 * \param _atomref reference to atom 122 * \param _subjectKilled ref to function to call on subjectKilled() 117 123 */ 118 void initObservedValues(const atomId_t _id); 124 static void initObservedValues( 125 std::vector<boost::any> &_ObservedValues, 126 const atomId_t _id, 127 const atom * const _atomref, 128 const boost::function<void()> &_subjectKilled); 119 129 120 130 /** Destroys all \a ObservedValues entries. 121 131 * 132 * \param _ObservedValues vector of ObservedValue to be destroyed 122 133 */ 123 void destroyObservedValues(); 134 static void destroyObservedValues( 135 std::vector<boost::any> &_ObservedValues); 124 136 125 137 /** Getter to atom index contained in \a ObservedValues.
Note:
See TracChangeset
for help on using the changeset viewer.