Changeset 026bef for src/UIElements/Views
- Timestamp:
- Feb 12, 2016, 11:15:06 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:
- 15c8a9
- Parents:
- 099f67
- git-author:
- Frederik Heber <heber@…> (01/25/16 11:01:10)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:06)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
r099f67 r026bef 78 78 GLMoleculeObject_atom::AtomBondsChannels(getAtomBondsChannels()); 79 79 80 GLMoleculeObject_atom::GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atomId_t _id) : 80 GLMoleculeObject_atom::GLMoleculeObject_atom( 81 QGLSceneNode *mesh[], 82 QObject *parent, 83 const atomId_t _id) : 81 84 GLMoleculeObject(mesh, parent), 82 85 Observer(std::string("GLMoleculeObject_atom")+toString(_id)), … … 86 89 owner(NULL) 87 90 { 88 boost::function<void( )> subjectKilled =89 boost::bind(&GLMoleculeObject_atom::countsubjectKilled, this );91 boost::function<void(const atomId_t)> subjectKilled = 92 boost::bind(&GLMoleculeObject_atom::countsubjectKilled, this, _id); 90 93 initObservedValues(ObservedValues, _id, atomref, subjectKilled); 91 94 95 init(_id); 96 } 97 98 GLMoleculeObject_atom::GLMoleculeObject_atom( 99 QGLSceneNode *mesh[], 100 QObject *parent, 101 const atomId_t _id, 102 std::vector<boost::any> _ObservedValues) : 103 GLMoleculeObject(mesh, parent), 104 Observer(std::string("GLMoleculeObject_atom")+toString(_id)), 105 atomref(getAtom(_id)), 106 ObservedValues(_ObservedValues), 107 subjectKilledCount(0), 108 owner(NULL) 109 { 110 init(_id); 111 } 112 113 void GLMoleculeObject_atom::init(const atomId_t _id) 114 { 92 115 setObjectId(_id); 93 116 resetPosition(); … … 317 340 deactivateObserver(); 318 341 319 countsubjectKilled( );342 countsubjectKilled(getAtomIndex()); 320 343 } 321 344 … … 348 371 } 349 372 350 void GLMoleculeObject_atom::countsubjectKilled( )373 void GLMoleculeObject_atom::countsubjectKilled(const atomId_t) 351 374 { 352 375 ++subjectKilledCount; … … 360 383 const atomId_t _id, 361 384 const atom * const _atomref, 362 const boost::function<void( )> &_subjectKilled)385 const boost::function<void(const atomId_t)> &_subjectKilled) 363 386 { 364 387 /* This is an old note from when the code was still part of cstor's initializer body. … … 399 422 boost::bind(&GLMoleculeObject_atom::updateBonds, AtomIndexGetter)); 400 423 401 _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector >(424 _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, atomId_t>( 402 425 _atomref, 403 426 AtomPositionUpdater, … … 405 428 AtomPositionUpdater(), 406 429 AtomPositionChannels, 407 _subjectKilled); 408 _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t>( 430 _subjectKilled, 431 AtomIndexGetter); 432 _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>( 409 433 _atomref, 410 434 AtomElementUpdater, … … 412 436 AtomElementUpdater(), 413 437 AtomElementChannels, 414 _subjectKilled); 415 _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t>( 438 _subjectKilled, 439 AtomIndexGetter); 440 _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>( 416 441 _atomref, 417 442 AtomBondsUpdater, … … 419 444 AtomBondsUpdater(), 420 445 AtomBondsChannels, 421 _subjectKilled); 446 _subjectKilled, 447 AtomIndexGetter); 422 448 } 423 449 … … 426 452 { 427 453 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]);454 delete boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(_ObservedValues[AtomPosition]); 455 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(_ObservedValues[AtomElement]); 456 delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(_ObservedValues[AtomBonds]); 431 457 _ObservedValues.clear(); 432 458 } … … 439 465 Vector GLMoleculeObject_atom::getAtomPosition() const 440 466 { 441 return boost::any_cast<ObservedValue_wCallback<Vector > *>(ObservedValues[AtomPosition])->get();467 return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->get(); 442 468 } 443 469 444 470 atomicNumber_t GLMoleculeObject_atom::getAtomElement() const 445 471 { 446 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t > *>(ObservedValues[AtomElement])->get();472 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->get(); 447 473 } 448 474 449 475 GLMoleculeObject_atom::ListOfBonds_t GLMoleculeObject_atom::getAtomBonds() const 450 476 { 451 return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t > *>(ObservedValues[AtomBonds])->get();452 } 477 return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->get(); 478 } -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
r099f67 r026bef 34 34 Q_OBJECT 35 35 public: 36 GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atomId_t id); 36 GLMoleculeObject_atom( 37 QGLSceneNode *mesh[], 38 QObject *parent, 39 const atomId_t id 40 ); 41 GLMoleculeObject_atom( 42 QGLSceneNode *mesh[], 43 QObject *parent, 44 const atomId_t id, 45 std::vector<boost::any> _ObservedValues 46 ); 37 47 virtual ~GLMoleculeObject_atom(); 38 48 … … 86 96 void activateObserver(); 87 97 void deactivateObserver(); 98 99 void init(const atomId_t _id); 88 100 89 101 private: … … 126 138 const atomId_t _id, 127 139 const atom * const _atomref, 128 const boost::function<void( )> &_subjectKilled);140 const boost::function<void(const atomId_t)> &_subjectKilled); 129 141 130 142 /** Destroys all \a ObservedValues entries. … … 165 177 * monitored Observable. Only then can we safely remove the instance. 166 178 * 167 */ 168 void countsubjectKilled(); 179 * \param _atomid id of atom who signalled subjectKilled() 180 */ 181 void countsubjectKilled(const atomId_t _atomid); 169 182 170 183 //!> counts how many ObservedValues have already been subjectKilled() -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp
r099f67 r026bef 89 89 rightobservable_enabled(false) 90 90 { 91 boost::function<void()> subjectKilled = 92 boost::bind(&GLMoleculeObject_bond::countsubjectKilled, this); 93 initObservedValues(ObservedValues, bondIds.first, bondIds.second, leftowner, rightowner, bondowner, subjectKilled); 94 91 boost::function<void(const atomId_t &)> leftsubjectKilled = 92 boost::bind( 93 static_cast<void (GLMoleculeObject_bond::*) (const atomId_t &)>( 94 &GLMoleculeObject_bond::countsubjectKilled), 95 this, _1); 96 boost::function<void(const atomId_t &)> rightsubjectKilled = 97 boost::bind( 98 static_cast<void (GLMoleculeObject_bond::*) (const atomId_t &)>( 99 &GLMoleculeObject_bond::countsubjectKilled) 100 , this, _1); 101 boost::function<void(const bondIds_t &)> bondsubjectKilled = 102 boost::bind( 103 static_cast<void (GLMoleculeObject_bond::*) (const bondIds_t &)>( 104 &GLMoleculeObject_bond::countsubjectKilled) 105 , this, _1); 106 initObservedValues( 107 ObservedValues, 108 bondIds.first, 109 bondIds.second, 110 leftowner, 111 rightowner, 112 bondowner, 113 leftsubjectKilled, 114 rightsubjectKilled, 115 bondsubjectKilled); 116 117 init(); 118 } 119 120 GLMoleculeObject_bond::GLMoleculeObject_bond( 121 QGLSceneNode *mesh[], 122 QObject *parent, 123 const bondIds_t bondIds, 124 const enum SideOfBond side, 125 std::vector<boost::any> &_ObservedValues) : 126 GLMoleculeObject(mesh, parent), 127 Observer(std::string("GLMoleculeObject_bond") 128 +toString(bondIds.first) 129 +std::string("-") 130 +toString(bondIds.second)), 131 leftowner(getAtomConst(bondIds.first)), 132 rightowner(getAtomConst(bondIds.second)), 133 bondowner(getAtomConst(bondIds.first)->getBond(getAtomConst(bondIds.second)).get()), 134 BondSide(side), 135 ObservedValues(_ObservedValues), 136 subjectKilledCount(0), 137 leftobservable_enabled(false), 138 rightobservable_enabled(false) 139 { 140 init(); 141 } 142 143 void GLMoleculeObject_bond::init() 144 { 95 145 // sign on as observer (obtain non-const instance before) 96 146 bondowner->signOn(this, BondObservable::BondRemoved); … … 159 209 removeChannels(); 160 210 // check whether we should be removed 161 countsubjectKilled( );211 countsubjectKilled(std::make_pair(getleftIndex(), getrightIndex())); 162 212 } 163 213 … … 339 389 } 340 390 391 static GLMoleculeObject_bond::bondIds_t getBondIdsForIds( 392 const boost::function<const atomId_t ()> _left, 393 const boost::function<const atomId_t ()> _right) 394 { 395 return std::make_pair( _left(), _right()); 396 } 397 341 398 void GLMoleculeObject_bond::initObservedValues( 342 399 std::vector<boost::any> &_ObservedValues, … … 346 403 const Observable * const _rightowner, 347 404 const Observable * const _bondowner, 348 const boost::function<void()> &_subjectKilled) 405 const boost::function<void(const atomId_t &)> &_leftsubjectKilled, 406 const boost::function<void(const atomId_t &)> &_rightsubjectKilled, 407 const boost::function<void(const bondIds_t &)> &_bondsubjectKilled) 349 408 { 350 409 /* This is an old note from when the code was still part of cstor's initializer body. … … 372 431 _leftatomId, 373 432 IndexChannels, 374 _ subjectKilled);433 _leftsubjectKilled); 375 434 _ObservedValues[leftIndex] = LeftIndexObservable; 376 435 ObservedValue_wCallback<atomId_t> * const RightIndexObservable = … … 381 440 _rightatomId, 382 441 IndexChannels, 383 _ subjectKilled);442 _rightsubjectKilled); 384 443 _ObservedValues[rightIndex] = RightIndexObservable; 385 444 … … 402 461 const boost::function<int ()> DegreeUpdater( 403 462 boost::bind(&GLMoleculeObject_bond::updateDegree, LeftIndexGetter, RightIndexGetter)); 404 405 _ObservedValues[leftPosition] = new ObservedValue_wCallback<Vector>( 463 const boost::function<bondIds_t ()> BondIdGetter( 464 boost::bind(&getBondIdsForIds, LeftIndexGetter, RightIndexGetter)); 465 466 _ObservedValues[leftPosition] = new ObservedValue_wCallback<Vector, atomId_t>( 406 467 _leftowner, 407 468 LeftPositionUpdater, … … 409 470 LeftPositionUpdater(), 410 471 BondPositionChannels, 411 _subjectKilled); 412 _ObservedValues[rightPosition] = new ObservedValue_wCallback<Vector>( 472 _leftsubjectKilled, 473 LeftIndexGetter); 474 _ObservedValues[rightPosition] = new ObservedValue_wCallback<Vector, atomId_t>( 413 475 _rightowner, 414 476 RightPositionUpdater, … … 416 478 RightPositionUpdater(), 417 479 BondPositionChannels, 418 _subjectKilled); 419 _ObservedValues[leftElement] = new ObservedValue_wCallback<atomicNumber_t>( 480 _rightsubjectKilled, 481 RightIndexGetter); 482 _ObservedValues[leftElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>( 420 483 _leftowner, 421 484 LeftElementUpdater, … … 423 486 LeftElementUpdater(), 424 487 BondElementChannels, 425 _subjectKilled); 426 _ObservedValues[rightElement] = new ObservedValue_wCallback<atomicNumber_t>( 488 _leftsubjectKilled, 489 LeftIndexGetter); 490 _ObservedValues[rightElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>( 427 491 _rightowner, 428 492 RightElementUpdater, … … 430 494 RightElementUpdater(), 431 495 BondElementChannels, 432 _subjectKilled); 433 _ObservedValues[Degree] = new ObservedValue_wCallback<int>( 496 _rightsubjectKilled, 497 RightIndexGetter); 498 _ObservedValues[Degree] = new ObservedValue_wCallback<int, bondIds_t>( 434 499 _bondowner, 435 500 DegreeUpdater, … … 437 502 DegreeUpdater(), 438 503 BondDegreeChannels, 439 _subjectKilled); 504 _bondsubjectKilled, 505 BondIdGetter); 440 506 } 441 507 … … 445 511 delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[leftIndex]); 446 512 delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[rightIndex]); 447 delete boost::any_cast<ObservedValue_wCallback<Vector > *>(_ObservedValues[leftPosition]);448 delete boost::any_cast<ObservedValue_wCallback<Vector > *>(_ObservedValues[rightPosition]);449 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t > *>(_ObservedValues[leftElement]);450 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t > *>(_ObservedValues[rightElement]);451 delete boost::any_cast<ObservedValue_wCallback<int > *>(_ObservedValues[Degree]);513 delete boost::any_cast<ObservedValue_wCallback<Vector,atomId_t> *>(_ObservedValues[leftPosition]); 514 delete boost::any_cast<ObservedValue_wCallback<Vector,atomId_t> *>(_ObservedValues[rightPosition]); 515 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t,atomId_t> *>(_ObservedValues[leftElement]); 516 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t,atomId_t> *>(_ObservedValues[rightElement]); 517 delete boost::any_cast<ObservedValue_wCallback<int, bondIds_t> *>(_ObservedValues[Degree]); 452 518 _ObservedValues.clear(); 453 519 } … … 465 531 Vector GLMoleculeObject_bond::getleftPosition() const 466 532 { 467 return boost::any_cast<ObservedValue_wCallback<Vector > *>(ObservedValues[leftPosition])->get();533 return boost::any_cast<ObservedValue_wCallback<Vector,atomId_t> *>(ObservedValues[leftPosition])->get(); 468 534 } 469 535 470 536 Vector GLMoleculeObject_bond::getrightPosition() const 471 537 { 472 return boost::any_cast<ObservedValue_wCallback<Vector > *>(ObservedValues[rightPosition])->get();538 return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[rightPosition])->get(); 473 539 } 474 540 475 541 atomicNumber_t GLMoleculeObject_bond::getleftElement() const 476 542 { 477 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t > *>(ObservedValues[leftElement])->get();543 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[leftElement])->get(); 478 544 } 479 545 480 546 atomicNumber_t GLMoleculeObject_bond::getrightElement() const 481 547 { 482 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t > *>(ObservedValues[rightElement])->get();548 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[rightElement])->get(); 483 549 } 484 550 485 551 int GLMoleculeObject_bond::getDegree() const 486 552 { 487 return boost::any_cast<ObservedValue_wCallback<int > *>(ObservedValues[Degree])->get();488 } 553 return boost::any_cast<ObservedValue_wCallback<int, bondIds_t> *>(ObservedValues[Degree])->get(); 554 } -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp
r099f67 r026bef 39 39 typedef std::pair<atomId_t, atomId_t> bondIds_t; 40 40 41 GLMoleculeObject_bond(QGLSceneNode *mesh[], QObject *parent, const bondIds_t bondIds, const enum SideOfBond side); 41 GLMoleculeObject_bond( 42 QGLSceneNode *mesh[], 43 QObject *parent, 44 const bondIds_t bondIds, 45 const enum SideOfBond side); 46 GLMoleculeObject_bond( 47 QGLSceneNode *mesh[], 48 QObject *parent, 49 const bondIds_t bondIds, 50 const enum SideOfBond side, 51 std::vector<boost::any> &_ObservedValues); 42 52 virtual ~GLMoleculeObject_bond(); 43 53 … … 73 83 74 84 private: 85 86 void init(); 87 75 88 void removeChannels(); 76 89 … … 136 149 * \param _rightowner reference to right atom 137 150 * \param _bondowner reference to bond 138 * \param _subjectKilled ref to function to call on subjectKilled() 151 * \param _leftsubjectKilled ref to function to call on subjectKilled() for left atom 152 * \param _rightsubjectKilled ref to function to call on subjectKilled() for right atom 153 * \param _bondsubjectKilled ref to function to call on subjectKilled() for bond 139 154 */ 140 155 static void initObservedValues( … … 145 160 const Observable * const _rightowner, 146 161 const Observable * const _bondowner, 147 const boost::function<void()> &_subjectKilled); 162 const boost::function<void(const atomId_t &)> &_leftsubjectKilled, 163 const boost::function<void(const atomId_t &)> &_rightsubjectKilled, 164 const boost::function<void(const bondIds_t &)> &_bondsubjectKilled); 148 165 149 166 /** Destroys all \a ObservedValues entries. … … 202 219 * monitored Observable. Only then can we safely remove the instance. 203 220 * 204 */ 221 * \param _bondIds bond ids whose bond has called subjectKilled() 222 */ 223 void countsubjectKilled( 224 const bondIds_t &_bondIds) 225 { 226 countsubjectKilled(); 227 } 228 229 void countsubjectKilled( 230 const atomId_t &_atomid) 231 { 232 countsubjectKilled(); 233 } 234 205 235 void countsubjectKilled(); 206 236 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
r099f67 r026bef 122 122 hoverAtomId(-1) 123 123 { 124 boost::function<void( )> subjectKilled =125 boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this );124 boost::function<void(const moleculeId_t)> subjectKilled = 125 boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this, _molid); 126 126 initObservedValues(ObservedValues, _molid, molref, subjectKilled); 127 127 … … 138 138 connect (this, SIGNAL(TesselationHullChanged()), this, SLOT(resetTesselationHull()), Qt::QueuedConnection); 139 139 connect (this, SIGNAL(BoundingBoxChanged()), this, SLOT(resetBoundingBox()), Qt::QueuedConnection); 140 connect (this, SIGNAL(IsSelectedChanged()), this, SLOT(resetIsSelected()), Qt::QueuedConnection);141 140 connect (this, SIGNAL(IdChanged()), this, SLOT(resetIndex()), Qt::QueuedConnection); 142 141 connect (this, SIGNAL(AtomInserted(const atomId_t)), this, SLOT(atomInserted(const atomId_t)), Qt::QueuedConnection); … … 148 147 } 149 148 150 GLMoleculeObject_molecule::GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const moleculeId_t _molid) : 149 GLMoleculeObject_molecule::GLMoleculeObject_molecule( 150 QGLSceneNode *mesh[], 151 QObject *parent, 152 const moleculeId_t _molid) : 151 153 GLMoleculeObject(mesh, parent), 152 154 Observer(std::string("GLMoleculeObject_molecule")+toString(_molid)), … … 169 171 hoverAtomId(-1) 170 172 { 171 boost::function<void( )> subjectKilled =172 boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this );173 boost::function<void(const moleculeId_t)> subjectKilled = 174 boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this, _molid); 173 175 initObservedValues(ObservedValues, _molid, molref, subjectKilled); 174 176 … … 480 482 owner = NULL; 481 483 482 countsubjectKilled( );484 countsubjectKilled(getMolIndex()); 483 485 } 484 486 … … 844 846 } 845 847 846 void GLMoleculeObject_molecule::countsubjectKilled( )848 void GLMoleculeObject_molecule::countsubjectKilled(const moleculeId_t) 847 849 { 848 850 ++subjectKilledCount; … … 856 858 const moleculeId_t _molid, 857 859 const molecule * const _molref, 858 const boost::function<void( )> &_subjectKilled)860 const boost::function<void(const moleculeId_t)> &_subjectKilled) 859 861 { 860 862 /* This is an old note from when the code was still part of cstor's initializer body. … … 893 895 boost::bind(&GLMoleculeObject_molecule::updateBoundingBox, MolIndexGetter)); 894 896 895 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string >(897 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>( 896 898 _molref, 897 899 MolNameUpdater, … … 899 901 MolNameUpdater(), 900 902 NameChannels, 901 _subjectKilled); 902 _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo>( 903 _subjectKilled, 904 MolIndexGetter); 905 _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t>( 903 906 _molref, 904 907 BoundingBoxUpdater, … … 906 909 initBoundingBox(), 907 910 BoundingBoxChannels, 908 _subjectKilled); 911 _subjectKilled, 912 MolIndexGetter); 909 913 _ObservedValues[PresentAtoms] = new ObservedValue_UpdateAtoms( 910 914 _molref, … … 919 923 { 920 924 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]);925 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]); 926 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]); 923 927 delete boost::any_cast<ObservedValue_UpdateAtoms *>(_ObservedValues[PresentAtoms]); 924 928 _ObservedValues.clear(); … … 932 936 std::string GLMoleculeObject_molecule::getMolName() const 933 937 { 934 return boost::any_cast<ObservedValue_wCallback<std::string > *>(ObservedValues[MolName])->get();938 return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->get(); 935 939 } 936 940 937 941 molecule::BoundingBoxInfo GLMoleculeObject_molecule::getBoundingBox() const 938 942 { 939 return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo > *>(ObservedValues[BoundingBox])->get();943 return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->get(); 940 944 } 941 945 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp
r099f67 r026bef 39 39 Q_OBJECT 40 40 public: 41 GLMoleculeObject_molecule(QObject *parent, const moleculeId_t molid); 42 GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const moleculeId_t molid); 41 GLMoleculeObject_molecule( 42 QObject *parent, 43 const moleculeId_t molid); 44 GLMoleculeObject_molecule( 45 QGLSceneNode *mesh[], 46 QObject *parent, 47 const moleculeId_t molid); 43 48 virtual ~GLMoleculeObject_molecule(); 44 49 … … 172 177 const moleculeId_t _molid, 173 178 const molecule * const _molref, 174 const boost::function<void( )> &_subjectKilled);179 const boost::function<void(const moleculeId_t)> &_subjectKilled); 175 180 176 181 /** Destroys all \a ObservedValues entries. … … 211 216 * monitored Observable. Only then can we safely remove the instance. 212 217 * 213 */ 214 void countsubjectKilled(); 218 * \param _molid molecule id who signalled subjectKilled() 219 */ 220 void countsubjectKilled(const moleculeId_t _molid); 215 221 216 222 //!> counts how many ObservedValues have already been subjectKilled() -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r099f67 r026bef 90 90 GLMoleculeObject::meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true); 91 91 } 92 connect(this, SIGNAL(moleculePreparedInserted(const moleculeId_t)), this, SLOT(moleculeInserted(const moleculeId_t)));93 92 94 93 // connect(this, SIGNAL(updated()), this, SLOT(update())); … … 220 219 } 221 220 222 /** Prepres insertion of a molecule into the scene. 223 * 224 * This function takes up the insertion information, i.e. a molecule has been 225 * inserted and its id, and takes some immediate action (writing id into a map). 226 * But the request is then transmitted indirectly (i.e. not necessarily being 227 * processed in the same thread). Hence, we first take the request via a direction 228 * connection in the thread where the actual World::createMolecule() was called. 229 * However, the creation of the visual representation must occur in the thread 230 * who also contains GLWorldScene and GLWorldView and all further parents. 231 * 232 * That's the reason why we split here into moleculePrepareInserted and 233 * moleculeInserted. 221 /** Inserts a molecule into the scene. 234 222 * 235 223 * @param _mol molecule to insert 236 224 */ 237 void GLWorldScene::molecule PrepareInserted(const moleculeId_t _id)238 { 239 LOG(3, "INFO: GLWorldScene: Received signal molecule PrepareInserted for molecule "+toString(_id)+".");225 void GLWorldScene::moleculeInserted(const moleculeId_t _id) 226 { 227 LOG(3, "INFO: GLWorldScene: Received signal moleculeInserted for molecule "+toString(_id)+"."); 240 228 241 229 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex); … … 244 232 ASSERT( iter == MoleculesinSceneMap.end(), 245 233 "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" already present."); 246 247 emit moleculePreparedInserted(_id);248 }249 250 /** Inserts a molecule into the scene.251 *252 * \sa moleculePrepareInserted()253 *254 * @param _mol molecule to insert255 */256 void GLWorldScene::moleculeInserted(const moleculeId_t _id)257 {258 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);259 234 260 235 // check whether molecule is still present … … 271 246 LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << _id); 272 247 GLMoleculeObject_molecule *molObject = 273 new GLMoleculeObject_molecule(GLMoleculeObject::meshEmpty, this, _id); 248 new GLMoleculeObject_molecule( 249 GLMoleculeObject::meshEmpty, this, _id); 274 250 ASSERT( molObject != NULL, 275 251 "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id)); … … 347 323 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int))); 348 324 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int))); 349 connect (molObject, SIGNAL(InstanceRemoved(const moleculeId_t)), this, SLOT(moleculeRemoved(const moleculeId_t)));350 325 351 326 emit changed(); … … 355 330 /** Removes a molecule from the scene. 356 331 * 357 * * \sa moleculePrepareRemoved()358 *359 332 * @param _id id of molecule to remove 360 333 */ 361 334 void GLWorldScene::moleculeRemoved(const moleculeId_t _id) 362 335 { 363 LOG(3, "INFO: GLWorldScene: Received signal molecule PrepareRemoved for molecule "+toString(_id)+".");336 LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_id)+"."); 364 337 365 338 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex); -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
r099f67 r026bef 82 82 void hoverChanged(const atomId_t); 83 83 void hoverChanged(const moleculeId_t, int); 84 void moleculePreparedInserted(const moleculeId_t _id);85 84 86 85 private slots: 87 86 void atomClicked(atomId_t no); 88 87 void moleculeClicked(moleculeId_t no); 89 void moleculePrepareInserted(const moleculeId_t _id);90 88 void moleculeRemoved(const moleculeId_t _id); 91 89 void moleculeInserted(const moleculeId_t _id); -
src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp
r099f67 r026bef 90 90 connect(worldscene, SIGNAL(hoverChanged(const atomId_t)), this, SLOT(sceneHoverSignalled(const atomId_t))); 91 91 connect(worldscene, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SLOT(sceneHoverSignalled(const moleculeId_t, int))); 92 connect(this, SIGNAL(atomRemoved(const moleculeId_t, const atomId_t)), worldscene, SLOT(atomRemoved(const moleculeId_t, const atomId_t)), Qt::DirectConnection);93 connect(this, SIGNAL(atomInserted(const moleculeId_t, const atomId_t)), worldscene, SLOT(atomInserted(const moleculeId_t, const atomId_t)), Qt::DirectConnection);94 connect(this, SIGNAL(moleculeInserted(const moleculeId_t)), worldscene, SLOT(moleculePrepareInserted(const moleculeId_t)), Qt::DirectConnection);95 92 //connect(this, SIGNAL(changed()), this, SLOT(updateGL())); 96 93 connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled())); -
src/UIElements/Views/Qt4/Qt3D/ObservedValue_UpdateAtoms.hpp
r099f67 r026bef 34 34 * 35 35 */ 36 class ObservedValue_UpdateAtoms : public ObservedValue_wCallback< std::set<atomId_t> >36 class ObservedValue_UpdateAtoms : public ObservedValue_wCallback< std::set<atomId_t>, moleculeId_t > 37 37 { 38 38 typedef std::set<atomId_t> atoms_t; … … 43 43 const std::string &_name, 44 44 const Observable::channels_t &_channels, 45 const boost::function<void( )> &_callback,45 const boost::function<void(moleculeId_t)> &_callback, 46 46 const boost::function<const moleculeId_t ()> &_getMolIndex 47 47 ) : 48 ObservedValue_wCallback<atoms_t >(48 ObservedValue_wCallback<atoms_t, moleculeId_t>( 49 49 _owner, 50 50 boost::bind(&ObservedValue_UpdateAtoms::updateAtoms, … … 52 52 atoms_t(), 53 53 _channels, 54 _callback), 54 _callback, 55 _getMolIndex), 55 56 getMolIndex(_getMolIndex) 56 57 {} -
src/UIElements/Views/Qt4/Qt3D/ObservedValue_wCallback.hpp
r099f67 r026bef 18 18 #include "CodePatterns/Observer/Observable.hpp" 19 19 20 #include <string> 21 22 #include <boost/bind.hpp> 23 #include <boost/function.hpp> 24 20 25 /** We derive from ObservedValue in order to tell owning instance about 21 26 * subjectKilled() having been called. 22 27 */ 23 template <class T >28 template <class T, class id=T> 24 29 class ObservedValue_wCallback : public ObservedValue<T> 25 30 { … … 31 36 const T &_initialvalue, 32 37 const Observable::channels_t &_channels, 33 const boost::function<void()> &_callback) : 38 const boost::function<void(const id)> &_callback, 39 const boost::function<const id()> &_getId) : 34 40 ObservedValue<T>(_owner, _recalcMethod, _name, _initialvalue, _channels), 35 callback(_callback) 41 callback(_callback), 42 getId(_getId) 36 43 {} 37 44 virtual ~ObservedValue_wCallback() … … 42 49 { 43 50 ObservedValue<T>::subjectKilled(publisher); 44 callback( );51 callback(getId()); 45 52 } 46 53 47 54 private: 48 55 //!> callback function to tell other entity about subjectKilled 49 const boost::function<void()> callback; 56 const boost::function<void(const id)> callback; 57 const boost::function<const id()> getId; 58 }; 59 60 /** Specialization of ObservedValue_wCallback for the index ObservedValue. 61 * 62 * The index serves as the unique identifier for the object instance whose 63 * properties are monitored in ObservedValue. Hence, how to give a subjectKilled() 64 * with an external getId() function? For the index the ObservedValue::get() is 65 * the getId() we need to call! Hence, we may simply connect these internally 66 * in this partial template specialization. 67 * 68 * Because atomicNumber_t, atomId_t and moleculeId_t are not unique types but 69 * -- at the writing of this class -- just typedefs, we have to resort to the 70 * trick with two constructors, one taking an external getId(), the other 71 * routing the getId() internally by binding to ObservedValue<T>::get(). 72 */ 73 template <class T> 74 class ObservedValue_wCallback<T,T> : public ObservedValue<T> 75 { 76 public: 77 ObservedValue_wCallback( 78 const Observable * const _owner, 79 const boost::function<T()> &_recalcMethod, 80 const std::string &_name, 81 const T &_initialvalue, 82 const Observable::channels_t &_channels, 83 const boost::function<void(const T)> &_callback, 84 const boost::function<const T()> &_getId) : 85 ObservedValue<T>(_owner, _recalcMethod, _name, _initialvalue, _channels), 86 callback(_callback), 87 getId(_getId) 88 {} 89 ObservedValue_wCallback( 90 const Observable * const _owner, 91 const boost::function<T()> &_recalcMethod, 92 const std::string &_name, 93 const T &_initialvalue, 94 const Observable::channels_t &_channels, 95 const boost::function<void(const T)> &_callback) : 96 ObservedValue<T>(_owner, _recalcMethod, _name, _initialvalue, _channels), 97 callback(_callback), 98 getId(boost::bind(&ObservedValue<T>::get, this)) 99 {} 100 virtual ~ObservedValue_wCallback() 101 {} 102 103 protected: 104 virtual void subjectKilled(Observable *publisher) 105 { 106 ObservedValue<T>::subjectKilled(publisher); 107 callback(getId()); 108 } 109 110 private: 111 //!> callback function to tell other entity about subjectKilled 112 const boost::function<void(const T)> callback; 113 const boost::function<const T()> getId; 50 114 }; 51 115
Note:
See TracChangeset
for help on using the changeset viewer.