Changeset 9c259e for src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp
- Timestamp:
- Jul 25, 2015, 1:01:20 PM (10 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:
- f759e5
- Parents:
- 8923ad8
- git-author:
- Frederik Heber <heber@…> (06/11/15 07:33:58)
- git-committer:
- Frederik Heber <heber@…> (07/25/15 13:01:20)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp
r8923ad8 r9c259e 59 59 #include "CodePatterns/Observer/Notification.hpp" 60 60 #include "CodePatterns/Observer/ObserverLog.hpp" 61 #include "Descriptors/MoleculeIdDescriptor.hpp" 61 62 #include "molecule.hpp" 62 63 #include "Shapes/ShapeRegistry.hpp" … … 90 91 connect(worldscene, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SLOT(sceneHoverSignalled(const moleculeId_t, int))); 91 92 connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged())); 92 connect(this, SIGNAL(moleculeRemoved(const moleculeId_t)), worldscene, SLOT(moleculeRemoved(const moleculeId_t))); 93 connect(this, SIGNAL(moleculeInserted(const moleculeId_t)), worldscene, SLOT(moleculeInserted(const moleculeId_t))); 93 connect(this, SIGNAL(atomRemoved(const moleculeId_t, const atomId_t)), worldscene, SLOT(atomRemoved(const moleculeId_t, const atomId_t)), Qt::DirectConnection); 94 connect(this, SIGNAL(atomInserted(const moleculeId_t, const atomId_t)), worldscene, SLOT(atomInserted(const moleculeId_t, const atomId_t)), Qt::DirectConnection); 95 connect(this, SIGNAL(moleculeRemoved(const moleculeId_t)), worldscene, SLOT(moleculeRemoved(const moleculeId_t)), Qt::DirectConnection); 96 connect(this, SIGNAL(moleculeInserted(const moleculeId_t)), worldscene, SLOT(moleculeInserted(const moleculeId_t)), Qt::DirectConnection); 94 97 //connect(this, SIGNAL(changed()), this, SLOT(updateGL())); 95 98 connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled())); … … 114 117 GLWorldView::~GLWorldView() 115 118 { 119 // remove me from all observed molecules 120 for (ObservedMolecules_t::iterator iter = ObservedMolecules.begin(); 121 !ObservedMolecules.empty(); 122 iter = ObservedMolecules.begin()) 123 signOffFromMolecule(*iter); 124 116 125 QSettings settings; 117 126 settings.beginGroup("WorldView"); … … 324 333 } 325 334 335 void GLWorldView::signOnToMolecule(const molecule *_mol) 336 { 337 ASSERT( _mol != NULL, 338 "GLWorldView::signOnToMolecule() - molecule ref is NULL."); 339 _mol->signOn(this, molecule::AtomInserted); 340 _mol->signOn(this, molecule::AtomRemoved); 341 342 ObservedMolecules.insert(const_cast<molecule *>(_mol)); 343 } 344 345 void GLWorldView::signOffFromMolecule(const molecule *_mol) 346 { 347 ObservedMolecules_t::const_iterator iter = ObservedMolecules.find( 348 const_cast<molecule *>(_mol)); 349 ASSERT( iter != ObservedMolecules.end(), 350 "GLWorldView::signOffFromMolecule() - molecule "+toString(_mol) 351 +" gave subjectKilled we are not signed on."); 352 // LOG(1, "INFO: Erasing " << mol << " from ObservedMolecules."); 353 ObservedMolecules.erase(iter); 354 355 ASSERT( _mol != NULL, 356 "GLWorldView::signOffFromMolecule() - molecule ref is NULL."); 357 _mol->signOff(this, molecule::AtomInserted); 358 _mol->signOff(this, molecule::AtomRemoved); 359 } 360 326 361 /** 327 362 * The observable can tell when it dies. 328 363 */ 329 void GLWorldView::subjectKilled(Observable *publisher) {} 364 void GLWorldView::subjectKilled(Observable *publisher) 365 { 366 molecule * mol = static_cast<molecule *>(publisher); 367 368 // std::copy(ObservedMolecules.begin(), ObservedMolecules.end(), 369 // std::ostream_iterator<molecule *>(std::cout, "\n")); 370 371 if (mol != NULL) { 372 373 // sign off 374 signOffFromMolecule(mol); 375 376 // emit removed signal 377 const moleculeId_t _id = World::getInstance().lastChanged<molecule>()->getId(); 378 emit moleculeRemoved(_id); 379 } 380 } 330 381 331 382 /** Listen to specific changes to the world. … … 352 403 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been inserted."; 353 404 #endif 354 emit moleculeInserted(_id); 405 const molecule * const _molecule = const_cast<const World &>(World::getInstance()). 406 getMolecule(MoleculeById(_id)); 407 if (_molecule != NULL) { 408 signOnToMolecule(_molecule); 409 410 emit moleculeInserted(_id); 411 } 355 412 break; 356 413 } … … 361 418 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been removed."; 362 419 #endif 420 // removed from ObservedMolecules via subjectKilled 363 421 emit moleculeRemoved(_id); 364 422 break; … … 383 441 break; 384 442 } 385 } else if (dynamic_cast<AtomObservable *>(publisher) != NULL) { 443 } else if (dynamic_cast<molecule *>(publisher) != NULL) { 444 const molecule * mol = const_cast<const molecule * const>(dynamic_cast<molecule *>(publisher)); 445 const atomId_t atomid = mol->lastChanged()->getId(); 446 const moleculeId_t molid = mol->getId(); 447 switch (notification->getChannelNo()) { 448 case molecule::AtomInserted: 449 { 450 #ifdef LOG_OBSERVER 451 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) 452 << " received notification that atom "+toString(atomid)+" has been inserted into molecule "+toString(molid)+"."; 453 #endif 454 emit atomInserted(molid, atomid); 455 break; 456 } 457 case World::AtomRemoved: 458 { 459 #ifdef LOG_OBSERVER 460 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) 461 << " received notification that atom "+toString(atomid)+" has been removed from molecule "+toString(molid)+"."; 462 #endif 463 emit atomRemoved(molid, atomid); 464 break; 465 } 466 default: 467 ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for molecule."); 468 break; 469 } 470 } else if (dynamic_cast<AtomObservable *>(publisher) != NULL) { 386 471 switch (notification->getChannelNo()) { 387 472 case AtomObservable::PositionChanged:
Note:
See TracChangeset
for help on using the changeset viewer.