- Timestamp:
- Apr 20, 2016, 11:07:47 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:
- b2eeaf
- Parents:
- 502614
- git-author:
- Frederik Heber <heber@…> (04/12/16 18:37:31)
- git-committer:
- Frederik Heber <heber@…> (04/20/16 23:07:47)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r502614 ra13f2b 78 78 QObject *parent) : 79 79 QObject(parent), 80 BondNodeParentMaps(std::vector<BondNodeParentMap_t>(2)), 80 81 selectionMode(SelectAtom), 81 82 board(_board) … … 164 165 const ObservedValue_Index_t atomid = _atom->getIndex(); 165 166 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 166 AtomNodeParentMap. insert( std::make_pair(atomid, (ObservedValue_Index_t)NULL) );167 AtomNodeParentMap.left.insert( std::make_pair(atomid, (ObservedValue_Index_t)NULL) ); 167 168 } 168 169 … … 184 185 { 185 186 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 186 AtomNodeParentMap_t:: iterator parentiter = AtomNodeParentMap.find(atomid);187 ASSERT (parentiter != AtomNodeParentMap. end(),187 AtomNodeParentMap_t::left_iterator parentiter = AtomNodeParentMap.left.find(atomid); 188 ASSERT (parentiter != AtomNodeParentMap.left.end(), 188 189 "GLWorldScene::insertAtom() - parent to atom id "+toString(atomid)+" unknown?"); 189 190 const ObservedValue_Index_t parentindex = parentiter->second; … … 235 236 { 236 237 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 237 AtomNodeParentMap. erase(_atomid);238 AtomNodeParentMap.left.erase(_atomid); 238 239 } 239 240 emit changed(); … … 256 257 const ObservedValue_Index_t bondid = _bond->getIndex(); 257 258 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 258 std::vector<ObservedValue_Index_t> parents(2, (ObservedValue_Index_t)NULL);259 259 if ((_bond->getLeftAtom() != NULL) && (_bond->getLeftAtom()->getMoleculeRef() != NULL)) 260 parents[0] = _bond->getLeftAtom()->getMoleculeRef()->getIndex(); 260 BondNodeParentMaps[0].left.insert( 261 std::make_pair(bondid, _bond->getLeftAtom()->getMoleculeRef()->getIndex()) ); 262 else 263 BondNodeParentMaps[0].left.insert( 264 std::make_pair(bondid, (ObservedValue_Index_t)NULL) ); 261 265 if ((_bond->getRightAtom() != NULL) && (_bond->getRightAtom()->getMoleculeRef() != NULL)) 262 parents[1] = _bond->getRightAtom()->getMoleculeRef()->getIndex(); 263 BondNodeParentMap.insert( std::make_pair(bondid, parents) ); 266 BondNodeParentMaps[1].left.insert( 267 std::make_pair(bondid, _bond->getRightAtom()->getMoleculeRef()->getIndex()) ); 268 else 269 BondNodeParentMaps[1].left.insert( 270 std::make_pair(bondid, (ObservedValue_Index_t)NULL) ); 264 271 } 265 272 … … 280 287 281 288 const ObservedValue_Index_t bondid = _bond->getIndex(); 282 std::vector<QObject *> parents(2, static_cast<QObject *>(this)); 289 #ifdef NDEBUG 290 BondNodeMap::iterator iter = BondsinSceneMap.find(bondid); 291 ASSERT( iter == BondsinSceneMap.end(), 292 "GLWorldScene::insertBond() - bond "+toString(bondid)+" is already known."); 293 #endif 283 294 { 284 295 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 285 BondNodeParentMap_t::iterator parentiter = BondNodeParentMap.find(bondid);286 ASSERT (parentiter != BondNodeParentMap.end(),287 "GLWorldScene::insertBond() - parent to bond id "+toString(bondid)+" unknown?");288 const std::vector<ObservedValue_Index_t> &molindices = parentiter->second;289 for (size_t i = 0; i < molindices.size(); ++i) {290 if ( molindices[i]!= (ObservedValue_Index_t)NULL) {291 const MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find( molindices[i]);296 for (size_t i=0;i<2;++i) { 297 BondNodeParentMap_t::left_iterator parentiter = BondNodeParentMaps[i].left.find(bondid); 298 ASSERT (parentiter != BondNodeParentMaps[i].left.end(), 299 "GLWorldScene::insertBond() - parent to bond id "+toString(bondid)+" unknown?"); 300 QObject *parent = this; 301 if (parentiter->second != (ObservedValue_Index_t)NULL) { 302 const MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentiter->second); 292 303 if (moliter != MoleculesinSceneMap.end()) 293 parent s[i]= moliter->second;304 parent = moliter->second; 294 305 } 295 } 296 297 BondNodeMap::iterator iter = BondsinSceneMap.find(bondid); 298 ASSERT( iter == BondsinSceneMap.end(), 299 "GLWorldScene::insertBond() - bond "+toString(bondid)+" is already known."); 300 for (size_t i=0;i<2;++i) { 306 301 307 GLMoleculeObject_bond *bondObject = new GLMoleculeObject_bond( 302 308 GLMoleculeObject::meshCylinder, 303 parent s[i],309 parent, 304 310 _bond, 305 311 bondsides[i]); … … 334 340 { 335 341 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 336 BondNodeParentMap.erase(_bondid); 342 BondNodeParentMaps[0].left.erase(_bondid); 343 BondNodeParentMaps[1].left.erase(_bondid); 337 344 } 338 345 … … 390 397 MoleculeNodeMap::const_iterator iter = MoleculesinSceneMap.find(molid); 391 398 ASSERT( iter == MoleculesinSceneMap.end(), 392 "GLWorldScene::insertMolecule() - molecule's id "+toString( _mol->getMolIndex())399 "GLWorldScene::insertMolecule() - molecule's id "+toString(molid) 393 400 +" already present."); 394 401 395 402 // add new object 396 LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << _mol->getMolIndex());403 LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << molid); 397 404 GLMoleculeObject_molecule *molObject = 398 405 new GLMoleculeObject_molecule( … … 402 409 ASSERT( molObject != NULL, 403 410 "GLWorldScene::insertMolecule - could not create molecule object for " 404 +toString(_mol->getMolIndex())); 411 +toString(molid)); 412 413 // check all atoms for not yet assigned parents 414 { 415 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 416 std::pair<AtomNodeParentMap_t::right_const_iterator, AtomNodeParentMap_t::right_const_iterator> iters = 417 AtomNodeParentMap.right.equal_range(molid); 418 for (AtomNodeParentMap_t::right_const_iterator iter = iters.first; 419 iter != iters.second; ++iter) { 420 AtomNodeMap::const_iterator atomiter = AtomsinSceneMap.find(iter->second); 421 if (atomiter != AtomsinSceneMap.end()) 422 resetParent(atomiter->second, molObject); 423 } 424 } 425 // check all bonds for not yet assigned parents 426 { 427 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 428 for (size_t i=0;i<2;++i) { 429 std::pair<BondNodeParentMap_t::right_const_iterator, BondNodeParentMap_t::right_const_iterator> iters = 430 BondNodeParentMaps[i].right.equal_range(molid); 431 for (BondNodeParentMap_t::right_const_iterator iter = iters.first; 432 iter != iters.second; ++iter) { 433 BondNodeMap::const_iterator bonditer = BondsinSceneMap.find(iter->second); 434 if (bonditer != BondsinSceneMap.end()) 435 resetParent(bonditer->second, molObject); 436 } 437 } 438 } 439 405 440 #ifndef NDEBUG 406 441 std::pair<MoleculeNodeMap::iterator, bool> inserter = … … 453 488 } 454 489 490 /** This converts safely index into a GLMoleculeObject_molecule. 491 * 492 * \param _MoleculesinSceneMap all present molecules 493 * \param _molid index to look for 494 * \return MolObject or NULL when not found 495 */ 496 GLMoleculeObject_molecule *GLWorldScene::getMoleculeObject( 497 const ObservedValue_Index_t _molid) const 498 { 499 const MoleculeNodeMap::const_iterator moliter = MoleculesinSceneMap.find(_molid); 500 if (moliter != MoleculesinSceneMap.end()) 501 return moliter->second; 502 else 503 return NULL; 504 } 505 455 506 /** Changes the parent of an object in the scene. 456 507 * … … 463 514 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 464 515 const ObservedValue_Index_t walkerid = walker->getIndex(); 465 AtomNodeParentMap_t:: iterator parentiter = AtomNodeParentMap.find(walkerid);466 ASSERT( parentiter != AtomNodeParentMap. end(),516 AtomNodeParentMap_t::left_iterator parentiter = AtomNodeParentMap.left.find(walkerid); 517 ASSERT( parentiter != AtomNodeParentMap.left.end(), 467 518 "GLWorldScene::reparentAtom() - could not find object to id "+toString(walkerid)); 468 519 469 520 // change parent entry 521 AtomNodeParentMap.left.erase(parentiter); 470 522 if (walker->getMoleculeRef() != NULL) 471 parentiter->second = walker->getMoleculeRef()->getIndex();523 AtomNodeParentMap.left.insert( std::make_pair(walkerid, walker->getMoleculeRef()->getIndex()) ); 472 524 else 473 parentiter->second = NULL; 474 parentiter = AtomNodeParentMap.find(walkerid); 475 476 // reset parent if atom exists 477 AtomNodeMap::iterator atomiter = AtomsinSceneMap.find(walkerid); 478 if (atomiter != AtomsinSceneMap.end()) { 479 QObject *parent = this; 480 if (parentiter->second != NULL) { 481 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentiter->second); 482 if (moliter != MoleculesinSceneMap.end()) 483 parent = moliter->second; 484 else { 485 // molecule does not yet exist 486 ASSERT(0, "GLWorldScene::reparentAtom() - molecule not existent not implemented."); 487 } 488 } 489 atomiter->second->setParent(parent); 490 } 525 AtomNodeParentMap.left.insert( std::make_pair(walkerid, (ObservedValue_Index_t)NULL) ); 526 parentiter = AtomNodeParentMap.left.find(walkerid); 527 528 const AtomNodeMap::iterator atomiter = AtomsinSceneMap.find(walkerid); 529 if (atomiter != AtomsinSceneMap.end()) 530 resetParent(atomiter->second, getMoleculeObject(parentiter->second)); 531 // else atom does not yet exist 491 532 } 492 533 … … 539 580 { 540 581 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 582 const size_t dim = (_side == GLMoleculeObject_bond::left) ? 0 : 1; 541 583 const ObservedValue_Index_t bondid = _bond->getIndex(); 542 BondNodeParentMap_t:: iterator parentiter = BondNodeParentMap.find(bondid);543 ASSERT( parentiter != BondNodeParentMap .end(),584 BondNodeParentMap_t::left_iterator parentiter = BondNodeParentMaps[dim].left.find(bondid); 585 ASSERT( parentiter != BondNodeParentMaps[dim].left.end(), 544 586 "GLWorldScene::reparentBond() - could not find object to id "+toString(bondid)); 545 587 546 588 // change parent entry 547 const size_t dim = (_side == GLMoleculeObject_bond::left) ? 0 : 1;589 BondNodeParentMaps[dim].left.erase(bondid); 548 590 if ((_atom != NULL) && (_atom->getMoleculeRef() != NULL)) 549 parentiter->second[dim] = _atom->getMoleculeRef()->getIndex();591 BondNodeParentMaps[dim].left.insert( std::make_pair( bondid, _atom->getMoleculeRef()->getIndex())); 550 592 else 551 parentiter->second[dim] = NULL; 593 BondNodeParentMaps[dim].left.insert( std::make_pair( bondid, (ObservedValue_Index_t)NULL) ); 594 parentiter = BondNodeParentMaps[dim].left.find(bondid); 552 595 553 596 // reset parent 554 GLMoleculeObject_bond *bondobj = getBondInScene(bondid, _side); 555 if (bondobj != NULL) { 597 resetParent(getBondInScene(bondid, _side), getMoleculeObject(parentiter->second)); 598 } 599 600 /** Resets the parent of an GLMoleculeObject. 601 * 602 * \param _obj object to reparent 603 * \param _molid index of parent molecule 604 */ 605 void GLWorldScene::resetParent( 606 GLMoleculeObject *_obj, 607 GLMoleculeObject_molecule *_molobj) 608 { 609 if (_obj != NULL) { 556 610 QObject *parent = this; 557 if (parentiter->second[dim] != NULL) { 558 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentiter->second[dim]); 559 if (moliter != MoleculesinSceneMap.end()) 560 parent = moliter->second; 561 else { 562 // molecule does not yet exist 563 ASSERT(0, "GLWorldScene::reparentAtom() - molecule not existent not implemented."); 564 } 565 } 566 bondobj->setParent(parent); 567 } 611 if (_molobj != NULL) 612 parent = _molobj; 613 // else: molecule does not yet exist: is done when molecule is instantiated 614 _obj->setParent(parent); 615 } 616 // else object does not yet exist 568 617 } 569 618 -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
r502614 ra13f2b 20 20 #include <iosfwd> 21 21 22 #include <boost/bimap.hpp> 22 23 #include <boost/thread/recursive_mutex.hpp> 23 24 … … 117 118 118 119 private: 120 121 GLMoleculeObject_molecule *getMoleculeObject( 122 const ObservedValue_Index_t _molid) const; 123 124 void resetParent( 125 GLMoleculeObject *_obj, 126 GLMoleculeObject_molecule *_molobj); 127 119 128 void reparentBond( 120 129 QtObservedBond *_bond, … … 140 149 141 150 //!> typedef for storing the current parent to each atom node in scene, NULL indicates GLWorldScene is parent 142 typedef std::map<ObservedValue_Index_t, ObservedValue_Index_t> AtomNodeParentMap_t; 151 typedef boost::bimap< 152 boost::bimaps::set_of< ObservedValue_Index_t >, 153 boost::bimaps::multiset_of< ObservedValue_Index_t > 154 > AtomNodeParentMap_t; 143 155 //!> typedef for storing the current parent to each bond node in scene, NULL indicates GLWorldScene is parent 144 typedef std::map<ObservedValue_Index_t, std::vector<ObservedValue_Index_t> > BondNodeParentMap_t; 156 typedef boost::bimap< 157 boost::bimaps::set_of< ObservedValue_Index_t >, 158 boost::bimaps::multiset_of< ObservedValue_Index_t > 159 > BondNodeParentMap_t; 145 160 146 161 //!> mutex to ascertain atomic access to NodeParentMaps … … 153 168 ShapeNodeMap ShapesinSceneMap; 154 169 AtomNodeParentMap_t AtomNodeParentMap; 155 BondNodeParentMap_t BondNodeParentMap;170 std::vector<BondNodeParentMap_t> BondNodeParentMaps; 156 171 157 172 SelectionModeType selectionMode;
Note:
See TracChangeset
for help on using the changeset viewer.