Changeset 649f59 for src/UIElements
- Timestamp:
- Apr 25, 2016, 7:05:31 AM (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:
- efeeb7
- Parents:
- 136842
- git-author:
- Frederik Heber <heber@…> (04/15/16 07:38:55)
- git-committer:
- Frederik Heber <heber@…> (04/25/16 07:05:31)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r136842 r649f59 163 163 164 164 // store the object, as we need it on reparenting 165 { 165 166 #ifndef NDEBUG 166 std::pair< ObservedAtoms_t::iterator, bool > inserter =167 std::pair< ObservedAtoms_t::iterator, bool > inserter = 167 168 #endif 168 ObservedAtoms.insert( std::make_pair(_atom->getIndex(), _atom) ); 169 ASSERT( inserter.second, 170 "GLWorldScene::connectAtom() - observed atom "+toString(_atom)+" already stored?"); 171 169 ObservedAtoms.insert( std::make_pair(_atom.get(), _atom) ); 170 ASSERT( inserter.second, 171 "GLWorldScene::connectAtom() - observed atom "+toString(_atom)+" already stored?"); 172 #ifndef NDEBUG 173 std::pair< ObservedValueIndexLookup_t::iterator, bool > indexinserter = 174 #endif 175 ObservedValueIndexLookup.insert( std::make_pair(_atom->getIndex(), _atom.get()) ); 176 ASSERT( indexinserter.second, 177 "GLWorldScene::connectAtom() - observed atom's index " 178 +toString(_atom->getIndex())+" already stored?"); 179 } 172 180 { 173 181 const ObservedValue_Index_t atomid = _atom->getIndex(); … … 226 234 } 227 235 236 template <class T> 237 void removeStoredObservedValue( 238 GLWorldScene::ObservedValueIndexLookup_t &_ObservedValueIndexLookup, 239 T &_ObservedValues, 240 ObservedValue_Index_t _id) 241 { 242 // get QObject* from lookup 243 const GLWorldScene::ObservedValueIndexLookup_t::iterator iter = 244 _ObservedValueIndexLookup.find(_id); 245 ASSERT( iter != _ObservedValueIndexLookup.end(), 246 "GLWorldScene::removeAtom() - could not find index "+toString(_id) 247 +" to stored observed value."); 248 QObject * sender = iter->second; 249 const size_t erased = _ObservedValues.erase(sender); 250 ASSERT( erased == 1, 251 "GLWorldScene::removeStoredObservedValue() - could not erase stored observed value " 252 +toString(_id)); 253 _ObservedValueIndexLookup.erase(iter); 254 } 255 228 256 /** Removes an atom. 229 257 * … … 246 274 { 247 275 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 248 AtomNodeParentMap.left.erase(_atomid); 249 } 250 { 251 const size_t erased = ObservedAtoms.erase(_atomid); 252 ASSERT( erased == 1, 253 "GLWorldScene::removeAtom() - could not erase stored observed value "+toString(_atomid)); 254 } 276 AtomNodeParentMap_t::left_iterator iter = AtomNodeParentMap.left.find(_atomid); 277 ASSERT( iter != AtomNodeParentMap.left.end(), 278 "GLWorldScene::removeAtom() - missing parent entry for "+toString(_atomid)); 279 if (iter->second == (ObservedValue_Index_t)NULL) { 280 LOG(4, "DEBUG: Found parent of atom as GLWorldScene, removing."); 281 removeStoredObservedValue(ObservedValueIndexLookup, ObservedAtoms, _atomid); 282 } 283 AtomNodeParentMap.left.erase(iter); 284 } 285 255 286 emit changed(); 256 287 emit changeOccured(); … … 270 301 271 302 // store the object, as we need it on reparenting 303 { 272 304 #ifndef NDEBUG 273 std::pair< ObservedBonds_t::iterator, bool > inserter =305 std::pair< ObservedBonds_t::iterator, bool > inserter = 274 306 #endif 275 ObservedBonds.insert( std::make_pair(_bond->getIndex(), _bond) ); 276 ASSERT( inserter.second, 277 "GLWorldScene::connectBond() - observed bond "+toString(_bond)+" already stored?"); 278 307 ObservedBonds.insert( std::make_pair(_bond.get(), _bond) ); 308 ASSERT( inserter.second, 309 "GLWorldScene::connectBond() - observed bond "+toString(_bond)+" already stored?"); 310 #ifndef NDEBUG 311 std::pair< ObservedValueIndexLookup_t::iterator, bool > indexinserter = 312 #endif 313 ObservedValueIndexLookup.insert( std::make_pair(_bond->getIndex(), _bond.get()) ); 314 ASSERT( indexinserter.second, 315 "GLWorldScene::connectBond() - observed bond's index " 316 +toString(_bond->getIndex())+" already stored?"); 317 } 279 318 { 280 319 const ObservedValue_Index_t bondid = _bond->getIndex(); … … 365 404 { 366 405 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 367 BondNodeParentMaps[0].left.erase(_bondid); 368 BondNodeParentMaps[1].left.erase(_bondid); 369 } 370 { 371 const size_t erased = ObservedAtoms.erase(_bondid); 372 ASSERT( erased == 1, 373 "GLWorldScene::removeBond() - could not erase stored observed value "+toString(_bondid)); 406 for (size_t i=0;i<2;++i) { 407 BondNodeParentMap_t::left_iterator iter = BondNodeParentMaps[i].left.find(_bondid); 408 ASSERT( iter != BondNodeParentMaps[i].left.end(), 409 "GLWorldScene::removeBond() - missing parent entry for "+toString(_bondid)); 410 if (iter->second == (ObservedValue_Index_t)NULL) { 411 LOG(4, "DEBUG: Found parent of bond as GLWorldScene, removing."); 412 removeStoredObservedValue(ObservedValueIndexLookup, ObservedBonds, _bondid); 413 } 414 BondNodeParentMaps[i].left.erase(iter); 415 } 374 416 } 375 417 … … 556 598 void GLWorldScene::reparentAtom() 557 599 { 558 QtObservedAtom *walker = dynamic_cast<QtObservedAtom *>(sender());559 600 boost::recursive_mutex::scoped_lock lock(AtomNodeParentMap_mutex); 601 QObject * origin = sender(); 602 ObservedAtoms_t::const_iterator iter = ObservedAtoms.find(origin); 603 ASSERT( iter != ObservedAtoms.end(), 604 "GLWorldScene::reparentAtom() - atom's "+toString(origin)+" is no longer stored?"); 605 QtObservedAtom::ptr walker = iter->second; 560 606 const ObservedValue_Index_t walkerid = walker->getIndex(); 561 607 LOG(4, "DEBUG: GLWorldScene: Received signal moleculeChanged for atom "+toString(walkerid)+"."); … … 576 622 resetParent(atomiter->second, getMoleculeObject(parentiter->second)); 577 623 // else atom does not yet exist 624 625 // check whether node is still shown, otherwise remove from lists completely 626 { 627 AtomNodeMap::iterator iter = AtomsinSceneMap.find(walkerid); 628 if (iter == AtomsinSceneMap.end()) { 629 LOG(3, "DEBUG: Reparented atom that is no longer on display, removing."); 630 removeStoredObservedValue(ObservedValueIndexLookup, ObservedAtoms, walkerid); 631 } 632 } 578 633 } 579 634 … … 584 639 { 585 640 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 586 QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender()); 641 QObject * origin = sender(); 642 ObservedBonds_t::const_iterator iter = ObservedBonds.find(origin); 643 ASSERT( iter != ObservedBonds.end(), 644 "GLWorldScene::reparentBondLeft() - bond "+toString(origin)+" is no longer stored?"); 645 QtObservedBond::ptr bond = iter->second; 587 646 reparentBond(bond, bond->getLeftAtom(), GLMoleculeObject_bond::left); 647 648 // check whether node is still shown, otherwise remove from lists completely 649 { 650 const ObservedValue_Index_t bondid = bond->getIndex(); 651 BondNodeMap::iterator iter = BondsinSceneMap.find(bondid); 652 if (iter == BondsinSceneMap.end()) { 653 // check whether both parents are now NULL 654 BondNodeParentMap_t::left_iterator leftiter = BondNodeParentMaps[0].left.find(bondid); 655 BondNodeParentMap_t::left_iterator rightiter = BondNodeParentMaps[1].left.find(bondid); 656 ASSERT( leftiter != BondNodeParentMaps[0].left.end(), 657 "GLWorldScene::reparentBondRight() - left parent to index "+toString(bondid)+" missing?"); 658 ASSERT( rightiter != BondNodeParentMaps[1].left.end(), 659 "GLWorldScene::reparentBondRight() - right parent to index "+toString(bondid)+" missing?"); 660 if ((leftiter->second == (ObservedValue_Index_t)NULL) 661 && (rightiter->second == (ObservedValue_Index_t)NULL)) { 662 LOG(3, "DEBUG: Reparented both left and right bond that is also no longer on display, removing."); 663 removeStoredObservedValue(ObservedValueIndexLookup, ObservedBonds, bondid); 664 } 665 } 666 } 588 667 } 589 668 … … 594 673 { 595 674 boost::recursive_mutex::scoped_lock lock(BondNodeParentMap_mutex); 596 QtObservedBond *bond = dynamic_cast<QtObservedBond *>(sender()); 675 QObject * origin = sender(); 676 ObservedBonds_t::const_iterator iter = ObservedBonds.find(origin); 677 ASSERT( iter != ObservedBonds.end(), 678 "GLWorldScene::reparentBondRight() - bond "+toString(origin)+" is no longer stored?"); 679 QtObservedBond::ptr bond = iter->second; 597 680 reparentBond(bond, bond->getRightAtom(), GLMoleculeObject_bond::right); 681 682 // check whether node is still shown, otherwise remove from lists completely 683 { 684 const ObservedValue_Index_t bondid = bond->getIndex(); 685 BondNodeMap::iterator iter = BondsinSceneMap.find(bondid); 686 if (iter == BondsinSceneMap.end()) { 687 // check whether both parents are now NULL 688 BondNodeParentMap_t::left_iterator leftiter = BondNodeParentMaps[0].left.find(bondid); 689 BondNodeParentMap_t::left_iterator rightiter = BondNodeParentMaps[1].left.find(bondid); 690 ASSERT( leftiter != BondNodeParentMaps[0].left.end(), 691 "GLWorldScene::reparentBondRight() - left parent to index "+toString(bondid)+" missing?"); 692 ASSERT( rightiter != BondNodeParentMaps[1].left.end(), 693 "GLWorldScene::reparentBondRight() - right parent to index "+toString(bondid)+" missing?"); 694 if ((leftiter->second == (ObservedValue_Index_t)NULL) 695 && (rightiter->second == (ObservedValue_Index_t)NULL)) { 696 LOG(3, "DEBUG: Reparented both left and right bond that is also no longer on display, removing."); 697 removeStoredObservedValue(ObservedValueIndexLookup, ObservedBonds, bondid); 698 } 699 } 700 } 598 701 } 599 702 … … 621 724 */ 622 725 void GLWorldScene::reparentBond( 623 QtObservedBond *_bond,726 const QtObservedBond::ptr _bond, 624 727 const QtObservedAtom::ptr _atom, 625 728 const GLMoleculeObject_bond::SideOfBond _side) -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
r136842 r649f59 127 127 128 128 void reparentBond( 129 QtObservedBond *_bond,129 const QtObservedBond::ptr _bond, 130 130 const QtObservedAtom::ptr _atom, 131 131 const GLMoleculeObject_bond::SideOfBond _side); … … 137 137 public: 138 138 void updateSelectedShapes(); 139 140 typedef std::map< QObject*, QtObservedAtom::ptr > ObservedAtoms_t; 141 typedef std::map< QObject*, QtObservedBond::ptr > ObservedBonds_t; 142 143 typedef std::map< ObservedValue_Index_t, QObject* > ObservedValueIndexLookup_t; 139 144 140 145 private: … … 159 164 > BondNodeParentMap_t; 160 165 161 typedef std::map< ObservedValue_Index_t, QtObservedAtom::ptr > ObservedAtoms_t;162 typedef std::map< ObservedValue_Index_t, QtObservedBond::ptr > ObservedBonds_t;163 164 166 //!> mutex to ascertain atomic access to NodeParentMaps 165 167 boost::recursive_mutex AtomNodeParentMap_mutex; … … 177 179 //!> stored observed bond such that its signals may always be safely evaluated 178 180 ObservedBonds_t ObservedBonds; 181 //!> in moleculeChanged() we only have QObject*, in reparent..() we have ObservedValue_Index_t, need lookup 182 ObservedValueIndexLookup_t ObservedValueIndexLookup; 179 183 180 184 SelectionModeType selectionMode;
Note:
See TracChangeset
for help on using the changeset viewer.