Changeset 502614 for src/UIElements
- 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:
- a13f2b
- Parents:
- 6e1628
- git-author:
- Frederik Heber <heber@…> (04/12/16 18:19:47)
- 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
r6e1628 r502614 164 164 const ObservedValue_Index_t atomid = _atom->getIndex(); 165 165 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 166 AtomNodeParentMap [atomid] = static_cast<QObject *>(this);166 AtomNodeParentMap.insert( std::make_pair(atomid, (ObservedValue_Index_t)NULL) ); 167 167 } 168 168 … … 185 185 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 186 186 AtomNodeParentMap_t::iterator parentiter = AtomNodeParentMap.find(atomid); 187 if (parentiter != AtomNodeParentMap.end()) 188 parent = parentiter->second; 189 else 190 AtomNodeParentMap[atomid] = parent; 187 ASSERT (parentiter != AtomNodeParentMap.end(), 188 "GLWorldScene::insertAtom() - parent to atom id "+toString(atomid)+" unknown?"); 189 const ObservedValue_Index_t parentindex = parentiter->second; 190 if (parentindex != (ObservedValue_Index_t)NULL) { 191 const MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(parentindex); 192 if (moliter != MoleculesinSceneMap.end()) 193 parent = moliter->second; 194 } 191 195 192 196 atomObject = new GLMoleculeObject_atom( … … 252 256 const ObservedValue_Index_t bondid = _bond->getIndex(); 253 257 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 254 std::vector<QObject *> parents(2, static_cast<QObject *>(this)); 255 if ((_bond->getLeftAtom() != NULL) && (_bond->getLeftAtom()->getMoleculeRef() != NULL)) { 256 const ObservedValue_Index_t molid = _bond->getLeftAtom()->getMoleculeRef()->getIndex(); 257 const MoleculeNodeMap::iterator leftiter = MoleculesinSceneMap.find(molid); 258 if (leftiter != MoleculesinSceneMap.end()) 259 parents[0] = leftiter->second; 260 } 261 if ((_bond->getRightAtom() != NULL) && (_bond->getRightAtom()->getMoleculeRef() != NULL)) { 262 const ObservedValue_Index_t molid = _bond->getRightAtom()->getMoleculeRef()->getIndex(); 263 const MoleculeNodeMap::iterator leftiter = MoleculesinSceneMap.find(molid); 264 if (leftiter != MoleculesinSceneMap.end()) 265 parents[1] = leftiter->second; 266 } 258 std::vector<ObservedValue_Index_t> parents(2, (ObservedValue_Index_t)NULL); 259 if ((_bond->getLeftAtom() != NULL) && (_bond->getLeftAtom()->getMoleculeRef() != NULL)) 260 parents[0] = _bond->getLeftAtom()->getMoleculeRef()->getIndex(); 261 if ((_bond->getRightAtom() != NULL) && (_bond->getRightAtom()->getMoleculeRef() != NULL)) 262 parents[1] = _bond->getRightAtom()->getMoleculeRef()->getIndex(); 267 263 BondNodeParentMap.insert( std::make_pair(bondid, parents) ); 268 264 } … … 288 284 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 289 285 BondNodeParentMap_t::iterator parentiter = BondNodeParentMap.find(bondid); 290 if (parentiter != BondNodeParentMap.end()) { 291 parents = parentiter->second; 292 } else 293 BondNodeParentMap.insert( std::make_pair(bondid, parents) ); 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]); 292 if (moliter != MoleculesinSceneMap.end()) 293 parents[i] = moliter->second; 294 } 295 } 294 296 295 297 BondNodeMap::iterator iter = BondsinSceneMap.find(bondid); … … 464 466 ASSERT( parentiter != AtomNodeParentMap.end(), 465 467 "GLWorldScene::reparentAtom() - could not find object to id "+toString(walkerid)); 468 469 // change parent entry 470 if (walker->getMoleculeRef() != NULL) 471 parentiter->second = walker->getMoleculeRef()->getIndex(); 472 else 473 parentiter->second = NULL; 474 parentiter = AtomNodeParentMap.find(walkerid); 475 476 // reset parent if atom exists 466 477 AtomNodeMap::iterator atomiter = AtomsinSceneMap.find(walkerid); 467 ASSERT( atomiter != AtomsinSceneMap.end(), 468 "GLWorldScene::reparentAtom() - could not find GLMoleculeObject to id "+toString(walkerid)); 469 if (walker->getMoleculeRef() != NULL) { 470 const ObservedValue_Index_t molid = walker->getMoleculeRef()->getIndex(); 471 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molid); 472 if (moliter != MoleculesinSceneMap.end()) { 473 parentiter->second = moliter->second; 474 atomiter->second->setParent(moliter->second); 475 } else { 476 // associated molecule has not yet been instantiated, keep in mind 477 ASSERT(0, 478 "GLWorldScene::reparentAtom() - new molecule not present yet?"); 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 } 479 488 } 480 } else { 481 parentiter->second = static_cast<QObject*>(this); 482 atomiter->second->setParent(this); 483 } 489 atomiter->second->setParent(parent); 490 } 491 } 492 493 /** Changes the parent of an left-side bond in the scene. 494 * 495 */ 496 void GLWorldScene::reparentBondLeft() 497 { 498 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 499 QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender()); 500 reparentBond(bond, bond->getLeftAtom(), GLMoleculeObject_bond::left); 501 } 502 503 /** Changes the parent of an right-side bond in the scene. 504 * 505 */ 506 void GLWorldScene::reparentBondRight() 507 { 508 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 509 QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender()); 510 reparentBond(bond, bond->getRightAtom(), GLMoleculeObject_bond::right); 511 } 512 513 GLMoleculeObject_bond *GLWorldScene::getBondInScene( 514 const ObservedValue_Index_t _bondid, 515 GLMoleculeObject_bond::SideOfBond _side) const 516 { 517 std::pair<GLWorldScene::BondNodeMap::const_iterator, GLWorldScene::BondNodeMap::const_iterator> iters = 518 BondsinSceneMap.equal_range(_bondid); 519 ASSERT( std::distance(iters.first, iters.second) == 2, 520 "GLWorldScene::getBondInScene() - not exactly two bonds of same id " 521 +toString(_bondid)+" present in scene."); 522 for (GLWorldScene::BondNodeMap::const_iterator bonditer = iters.first; 523 bonditer != iters.second; ++bonditer) { 524 if (bonditer->second->BondSide == _side) 525 return bonditer->second; 526 } 527 return NULL; 484 528 } 485 529 486 530 /** Changes the parent of an object in the scene. 487 531 * 488 * \param _id index of the object whose parent to change 489 * \param _ob new parent 490 */ 491 void GLWorldScene::reparentBondLeft() 492 { 493 QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender()); 532 * \param _atom atom of bond whose molecule we are associated to 533 * \param _side side of bond 534 */ 535 void GLWorldScene::reparentBond( 536 QtObservedBond *_bond, 537 const QtObservedAtom * const _atom, 538 const GLMoleculeObject_bond::SideOfBond _side) 539 { 494 540 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 495 const ObservedValue_Index_t bondid = bond->getIndex();541 const ObservedValue_Index_t bondid = _bond->getIndex(); 496 542 BondNodeParentMap_t::iterator parentiter = BondNodeParentMap.find(bondid); 497 543 ASSERT( parentiter != BondNodeParentMap.end(), 498 "GLWorldScene::reparentBondLeft() - could not find object to id "+toString(bondid)); 499 BondNodeMap::iterator bonditer = BondsinSceneMap.find(bondid); 500 ASSERT( bonditer != BondsinSceneMap.end(), 501 "GLWorldScene::reparentBondLeft() - could not find GLMoleculeObject to id "+toString(bondid)); 502 if (bonditer->second->BondSide != GLMoleculeObject_bond::left) 503 ++bonditer; 504 ASSERT( (bonditer->first == bondid) 505 && (bonditer->second->BondSide == GLMoleculeObject_bond::left), 506 "GLWorldScene::reparentBondLeft() - could not find left-side bond."); 507 if ((bond->getLeftAtom() != NULL) && (bond->getLeftAtom()->getMoleculeRef() != NULL)) { 508 const ObservedValue_Index_t molid = bond->getLeftAtom()->getMoleculeRef()->getIndex(); 509 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molid); 510 if (moliter != MoleculesinSceneMap.end()) { 511 parentiter->second[0] = moliter->second; 512 bonditer->second->setParent(moliter->second); 513 } else { 514 // associated molecule has not yet been instantiated, keep in mind 515 ASSERT(0, 516 "GLWorldScene::reparentBondLeft() - new molecule not present yet?"); 544 "GLWorldScene::reparentBond() - could not find object to id "+toString(bondid)); 545 546 // change parent entry 547 const size_t dim = (_side == GLMoleculeObject_bond::left) ? 0 : 1; 548 if ((_atom != NULL) && (_atom->getMoleculeRef() != NULL)) 549 parentiter->second[dim] = _atom->getMoleculeRef()->getIndex(); 550 else 551 parentiter->second[dim] = NULL; 552 553 // reset parent 554 GLMoleculeObject_bond *bondobj = getBondInScene(bondid, _side); 555 if (bondobj != NULL) { 556 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 } 517 565 } 518 } else { 519 parentiter->second[0] = static_cast<QObject*>(this); 520 bonditer->second->setParent(this); 521 } 522 } 523 524 /** Changes the parent of an object in the scene. 525 * 526 * \param _id index of the object whose parent to change 527 * \param _ob new parent 528 */ 529 void GLWorldScene::reparentBondRight() 530 { 531 QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender()); 532 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 533 const ObservedValue_Index_t bondid = bond->getIndex(); 534 BondNodeParentMap_t::iterator parentiter = BondNodeParentMap.find(bondid); 535 ASSERT( parentiter != BondNodeParentMap.end(), 536 "GLWorldScene::reparentBondLeft() - could not find object to id "+toString(bondid)); 537 BondNodeMap::iterator bonditer = BondsinSceneMap.find(bondid); 538 ASSERT( bonditer != BondsinSceneMap.end(), 539 "GLWorldScene::reparentBondLeft() - could not find GLMoleculeObject to id "+toString(bondid)); 540 if (bonditer->second->BondSide != GLMoleculeObject_bond::right) 541 ++bonditer; 542 ASSERT( (bonditer->first == bondid) 543 && (bonditer->second->BondSide == GLMoleculeObject_bond::right), 544 "GLWorldScene::reparentBondLeft() - could not find right-side bond."); 545 if ((bond->getRightAtom() != NULL) && (bond->getRightAtom()->getMoleculeRef() != NULL)) { 546 const ObservedValue_Index_t molid = bond->getRightAtom()->getMoleculeRef()->getIndex(); 547 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molid); 548 if (moliter != MoleculesinSceneMap.end()) { 549 parentiter->second[1] = moliter->second; 550 bonditer->second->setParent(moliter->second); 551 } else { 552 // associated molecule has not yet been instantiated, keep in mind 553 ASSERT(0, 554 "GLWorldScene::reparentBondRight() - new molecule not present yet?"); 555 } 556 } else { 557 parentiter->second[1] = static_cast<QObject*>(this); 558 bonditer->second->setParent(this); 566 bondobj->setParent(parent); 559 567 } 560 568 } -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
r6e1628 r502614 116 116 void reparentBondRight(); 117 117 118 private: 119 void reparentBond( 120 QtObservedBond *_bond, 121 const QtObservedAtom * const _atom, 122 const GLMoleculeObject_bond::SideOfBond _side); 123 124 GLMoleculeObject_bond *getBondInScene( 125 const ObservedValue_Index_t _bondid, 126 GLMoleculeObject_bond::SideOfBond _side) const; 127 118 128 public: 119 129 void updateSelectedShapes(); … … 129 139 typedef std::map< std::string , GLMoleculeObject_shape* > ShapeNodeMap; 130 140 131 //!> typedef for storing the current parent to each node in scene 132 typedef std::map<ObservedValue_Index_t, QObject *> AtomNodeParentMap_t; 133 typedef std::map<ObservedValue_Index_t, std::vector<QObject *> > BondNodeParentMap_t; 141 //!> 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; 143 //!> 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; 134 145 135 146 //!> mutex to ascertain atomic access to NodeParentMaps
Note:
See TracChangeset
for help on using the changeset viewer.