Changeset 9c259e for src/UIElements/Views
- Timestamp:
- Jul 25, 2015, 1:01:20 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:
- 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)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
r8923ad8 r9c259e 329 329 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted."; 330 330 #endif 331 TesselationHullUptodate = false; 332 isBoundingBoxUptodate = false; 333 atomInserted(_id); 331 QMetaObject::invokeMethod(this, // pointer to a QObject 332 "atomInserted", // member name (no parameters here) 333 Qt::QueuedConnection, // connection type 334 Q_ARG(atomId_t, _id)); // parameters 334 335 break; 335 336 } … … 340 341 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed."; 341 342 #endif 342 TesselationHullUptodate = false; 343 isBoundingBoxUptodate = false; 344 atomRemoved(_id); 343 QMetaObject::invokeMethod(this, // pointer to a QObject 344 "atomRemoved", // member name (no parameters here) 345 Qt::QueuedConnection, // connection type 346 Q_ARG(atomId_t, _id)); // parameters 345 347 break; 346 348 } … … 472 474 void GLMoleculeObject_molecule::atomInserted(const atomicNumber_t _id) 473 475 { 474 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_id)+"."); 476 LOG(3, "INFO: GLMoleculeObject_molecule: Received signal atomInserted for atom "+toString(_id)+"."); 477 478 TesselationHullUptodate = false; 479 isBoundingBoxUptodate = false; 480 475 481 GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(GLMoleculeObject::meshSphere, this, _id); 476 482 ASSERT( atomObject != NULL, … … 516 522 void GLMoleculeObject_molecule::atomRemoved(const atomicNumber_t _id) 517 523 { 518 LOG(3, "INFO: GL WorldScene: Received signal atomRemoved for atom "+toString(_id)+".");524 LOG(3, "INFO: GLMoleculeObject_molecule: Received signal atomRemoved for atom "+toString(_id)+"."); 519 525 // bonds are removed by signal coming from ~bond 526 527 TesselationHullUptodate = false; 528 isBoundingBoxUptodate = false; 520 529 521 530 if ((unsigned int)m_objectId == _id) -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r8923ad8 r9c259e 219 219 } 220 220 221 /** Inserts an atom into the scene before molecule is present. 222 * 223 * @param _molid molecule to insert atom for 224 * @param _atomid atom to insert 225 */ 226 void GLWorldScene::atomInserted(const moleculeId_t _molid, const atomId_t _atomid) 227 { 228 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_atomid)+"."); 229 230 // check of molecule is already present 231 if (MoleculesinSceneMap.count(_molid) != 0) { 232 // pass signal through 233 } else { 234 // store signal for when it is instantiated 235 if (MoleculeMissedStateMap.count(_molid) == 0) 236 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) ); 237 MoleculeMissedStateMap[_molid].insert( std::make_pair(_atomid, atomInsertedState) ); 238 } 239 } 240 241 /** Removes an atom into the scene before molecule is present. 242 * 243 * @param _molid molecule to insert atom for 244 * @param _atomid atom to insert 245 */ 246 void GLWorldScene::atomRemoved(const moleculeId_t _molid, const atomId_t _atomid) 247 { 248 LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_atomid)+"."); 249 250 // check of molecule is already present 251 if (MoleculesinSceneMap.count(_molid) != 0) { 252 // pass signal through 253 } else { 254 // store signal for when it is instantiated 255 if (MoleculeMissedStateMap.count(_molid) == 0) 256 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) ); 257 MoleculeMissedStateMap[_molid].insert( std::make_pair(_atomid, atomRemovedState) ); 258 } 259 } 260 221 261 /** Inserts a molecule into the scene. 222 262 * … … 235 275 "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id)); 236 276 MoleculesinSceneMap.insert( make_pair(_id, molObject) ); 277 278 // now handle all state changes that came up before the instantiation 279 if (MoleculeMissedStateMap.count(_id) != 0) { 280 ASSERT( !MoleculeMissedStateMap[_id].empty(), 281 "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id " 282 +toString(_id)); 283 for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin(); 284 !MoleculeMissedStateMap[_id].empty(); 285 iter = MoleculeMissedStateMap[_id].begin()) { 286 std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter = 287 MoleculeMissedStateMap[_id].equal_range(iter->first); 288 const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second); 289 if (StateCounts > 1) { 290 // more than one state change, have to combine 291 typedef std::map<StateChangeType, size_t> StateChangeAmounts_t; 292 StateChangeAmounts_t StateChangeAmounts; 293 for (StateChangeMap_t::const_iterator stateiter = rangeiter.first; 294 stateiter != rangeiter.second; ++stateiter) 295 ++StateChangeAmounts[stateiter->second]; 296 ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState], 297 "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom " 298 +toString(iter->first)); 299 if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) 300 QMetaObject::invokeMethod(molObject, // pointer to a QObject 301 "atomInserted", // member name (no parameters here) 302 Qt::DirectConnection, // connection type 303 Q_ARG(const atomId_t, iter->first)); // parameters 304 } else { 305 // can only be an insertion 306 switch (rangeiter.first->second) { 307 case atomRemovedState: 308 ASSERT( 0, 309 "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom " 310 +toString(iter->first)); 311 break; 312 case atomInsertedState: 313 QMetaObject::invokeMethod(molObject, // pointer to a QObject 314 "atomInserted", // member name (no parameters here) 315 Qt::DirectConnection, // connection type 316 Q_ARG(const atomId_t, iter->first)); // parameters 317 break; 318 default: 319 ASSERT( 0, 320 "GLWorldScene::moleculeInserted() - there are unknown change states."); 321 break; 322 } 323 } 324 // removed state changes for this atom 325 MoleculeMissedStateMap[_id].erase(iter); 326 } 327 // remove state change map for the molecule 328 MoleculeMissedStateMap.erase(_id); 329 } 330 237 331 connect (molObject, SIGNAL(changed()), this, SIGNAL(changed())); 238 332 connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured())); … … 243 337 connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t))); 244 338 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int))); 339 245 340 emit changed(); 246 341 emit changeOccured(); … … 262 357 MoleculesinSceneMap.erase(iter); 263 358 delete molObject; 359 360 // remove any possible state changes left 361 MoleculeMissedStateMap.erase(_id); 362 264 363 emit changed(); 265 364 emit changeOccured(); -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
r8923ad8 r9c259e 83 83 void moleculeRemoved(const moleculeId_t _id); 84 84 void moleculeInserted(const moleculeId_t _id); 85 void atomRemoved(const moleculeId_t _molid, const atomId_t _atomid); 86 void atomInserted(const moleculeId_t _molid, const atomId_t _atomid); 85 87 void worldSelectionChanged(); 86 88 void setSelectionModeAtom(); … … 104 106 ShapeNodeMap ShapesinSceneMap; 105 107 108 //!> enumeration of all possible changes molecule might have missed before instantiation 109 enum StateChangeType { 110 atomInsertedState, 111 atomRemovedState, 112 MAX_StateChangeType 113 }; 114 typedef std::multimap< atomId_t, StateChangeType> StateChangeMap_t; 115 typedef std::map< moleculeId_t, StateChangeMap_t> MoleculeMissedStateMap_t; 116 //!> map of all missed state changes 117 MoleculeMissedStateMap_t MoleculeMissedStateMap; 118 106 119 SelectionModeType selectionMode; 107 120 }; -
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: -
src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp
r8923ad8 r9c259e 59 59 void changed(); 60 60 void TimeChanged(); 61 void atomInserted(const moleculeId_t _molid, const atomId_t _atomid); 62 void atomRemoved(const moleculeId_t _molid, const atomId_t _atomid); 61 63 void moleculeInserted(const moleculeId_t _id); 62 64 void moleculeRemoved(const moleculeId_t _id); … … 107 109 void setDomainStatus(const bool status); 108 110 111 void signOnToMolecule(const molecule *_mol); 112 void signOffFromMolecule(const molecule *_mol); 113 109 114 private: 110 115 … … 126 131 127 132 double defaultEyeSeparation; 133 134 typedef std::multiset<molecule *> ObservedMolecules_t; 135 //!> sorted list of molecules we are sign on to 136 ObservedMolecules_t ObservedMolecules; 128 137 }; 129 138
Note:
See TracChangeset
for help on using the changeset viewer.