- Timestamp:
- Oct 6, 2011, 4:06:10 PM (13 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:
- 5e2f80
- Parents:
- db7e6d
- git-author:
- Frederik Heber <heber@…> (09/01/11 16:33:11)
- git-committer:
- Frederik Heber <heber@…> (10/06/11 16:06:10)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
rdb7e6d r37b2575 50 50 atomref->signOn(this, atomref->getChannel(AtomObservable::PositionChanged)); 51 51 atomref->signOn(this, atomref->getChannel(AtomObservable::ElementChanged)); 52 atomref->signOn(this, atomref->getChannel(AtomObservable::BondsChanged)); 52 53 53 54 // set the object's id … … 126 127 void GLMoleculeObject_atom::recieveNotification(Observable *publisher, Notification_ptr notification) 127 128 { 128 LOG(0, "GLMoleculeObject_atom::recieveNotification() - notification type " 129 LOG(0, "GLMoleculeObject_atom::recieveNotification() - atom " 130 +toString(_atom->getId())+" got notification type " 129 131 +toString(notification->getChannelNo())+"."); 130 132 switch (notification->getChannelNo()) { … … 137 139 case AtomObservable::PositionChanged: 138 140 resetPosition(); 141 break; 142 case AtomObservable::BondsChanged: 143 emit BondsChanged(_atom); 139 144 break; 140 145 default: -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
rdb7e6d r37b2575 37 37 signals: 38 38 void clicked(atomId_t); 39 void BondsChanged(const atom *_atom); 39 40 40 41 private: -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
rdb7e6d r37b2575 32 32 #include "atom.hpp" 33 33 #include "Bond/bond.hpp" 34 #include "Helpers/helpers.hpp" 34 35 #include "molecule.hpp" 35 36 #include "World.hpp" … … 91 92 LOG(0, "GLWorldScene: Received signal atomInserted for atom "+toString(_atom->getId())+"."); 92 93 GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(this, _atom); 93 AtomNodeMap::iterator iter = Atomsin MoleculeMap.find(_atom->getId());94 ASSERT(iter == Atomsin MoleculeMap.end(),94 AtomNodeMap::iterator iter = AtomsinSceneMap.find(_atom->getId()); 95 ASSERT(iter == AtomsinSceneMap.end(), 95 96 "GLWorldScene::atomAdded() - same atom "+_atom->getName()+" added again."); 96 Atomsin MoleculeMap.insert( make_pair(_atom->getId(), atomObject) );97 AtomsinSceneMap.insert( make_pair(_atom->getId(), atomObject) ); 97 98 connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(atomClicked(atomId_t))); 98 99 connect (atomObject, SIGNAL(hoverChanged()), this, SIGNAL(hoverChanged())); 100 connect (atomObject, SIGNAL(BondsChanged(const atom *)), this, SLOT(bondsChanged(const atom *))); 101 bondsChanged(_atom); 99 102 emit changed(); 100 103 } … … 110 113 const BondList& bondlist = _atom->getListOfBonds(); 111 114 for (BondList::const_iterator iter = bondlist.begin(); iter != bondlist.end(); ++iter) { 112 bondRemoved(*iter); 115 bondRemoved((*iter)->leftatom->getId(), (*iter)->rightatom->getId()); 116 bondRemoved((*iter)->rightatom->getId(), (*iter)->leftatom->getId()); 113 117 } 114 118 // remove atoms 115 AtomNodeMap::iterator iter = Atomsin MoleculeMap.find(_atom->getId());116 ASSERT(iter != Atomsin MoleculeMap.end(),119 AtomNodeMap::iterator iter = AtomsinSceneMap.find(_atom->getId()); 120 ASSERT(iter != AtomsinSceneMap.end(), 117 121 "GLWorldScene::atomRemoved() - atom "+_atom->getName()+" not on display."); 118 122 GLMoleculeObject_atom *atomObject = iter->second; 119 123 atomObject->disconnect(); 120 Atomsin MoleculeMap.erase(iter);124 AtomsinSceneMap.erase(iter); 121 125 delete atomObject; 122 126 emit changed(); 123 127 } 124 128 125 /** Adds an bond to the scene. 129 /** Updates the bond structure of the signaled \a _atom. 130 * 131 * @param _atom atom whose bonds changed. 132 */ 133 void GLWorldScene::bondsChanged(const atom *_atom) 134 { 135 const atomId_t id = _atom->getId(); 136 137 // create list with all present bonds 138 std::set< atomId_t > presentBonds; 139 std::pair< BondIdsMap::const_iterator, BondIdsMap::const_iterator> range = 140 BondIdsinSceneMap.equal_range( id ); 141 for (BondIdsMap::const_iterator iter = range.first; iter != range.second; ++iter) { 142 const atomId_t otherid = iter->second; 143 #ifndef NDEBUG 144 std::set< atomId_t >::const_iterator iter = presentBonds.find(otherid); 145 ASSERT(iter == presentBonds.end(), 146 "GLWorldScene::BondsChanged() - bond id "+toString(otherid)+" for atom " 147 +toString(id)+" present twice."); 148 #endif 149 presentBonds.insert( otherid ); 150 } 151 LOG(0, "We have the following bonds: "+toString(presentBonds)+"."); 152 153 // search for added bonds 154 const BondList &bondlist = _atom->getListOfBonds(); 155 for (BondList::const_iterator bonditer = bondlist.begin(); 156 bonditer != bondlist.end(); 157 ++bonditer) { 158 const bond *_bond = *bonditer; 159 const atomId_t otherid = _bond->GetOtherAtom(_atom)->getId(); 160 const BondIds ids = std::make_pair( id, otherid ); 161 BondNodeMap::const_iterator iter = BondsinSceneMap.find(ids); 162 if (iter != BondsinSceneMap.end()) { 163 // bond is already present 164 std::set< atomId_t >::const_iterator iter = presentBonds.find(otherid); 165 ASSERT(iter != presentBonds.end(), 166 "GLWorldScene::BondsChanged() - other id "+toString(otherid)+" for atom " 167 +toString(_atom->getId())+" not present in BondIdsinSceneMap."); 168 presentBonds.erase(otherid); 169 LOG(0, "Removing "+toString(otherid)+" from presentBonds."); 170 } else { 171 // insert new bond 172 bondInserted(_bond); 173 } 174 } 175 LOG(0, "The following bonds should not be present: "+toString(presentBonds)+"."); 176 177 // remove all still presentBonds 178 for (std::set< atomId_t >::iterator iter = presentBonds.begin(); 179 !presentBonds.empty(); iter = presentBonds.begin()) { 180 bondRemoved( id, *iter ); 181 } 182 } 183 184 /** Adds a bond to the scene. 126 185 * 127 186 * @param _bond bond to add … … 129 188 void GLWorldScene::bondInserted(const bond *_bond) 130 189 { 190 LOG(0, "GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+"."); 131 191 const double distance = 132 192 _bond->leftatom->getPosition().distance(_bond->rightatom->getPosition())/2.; … … 134 194 // left bond 135 195 const BondIds Leftids( make_pair(_bond->leftatom->getId(), _bond->rightatom->getId()) ); 136 BondNodeMap::iterator iter = Bondsin MoleculeMap.find(Leftids);137 ASSERT(iter == Bondsin MoleculeMap.end(),196 BondNodeMap::iterator iter = BondsinSceneMap.find(Leftids); 197 ASSERT(iter == BondsinSceneMap.end(), 138 198 "GLWorldScene::bondAdded() - same left-sided bond "+toString(*_bond)+" added again."); 139 199 GLMoleculeObject_bond *bondObject = 140 200 new GLMoleculeObject_bond(this, _bond, distance, GLMoleculeObject_bond::left); 141 BondsinMoleculeMap.insert( make_pair(Leftids, bondObject) ); 201 BondsinSceneMap.insert( make_pair(Leftids, bondObject) ); 202 BondIdsinSceneMap.insert( Leftids ); 142 203 } 143 204 { 144 205 // right bond 145 206 const BondIds Rightids( make_pair(_bond->rightatom->getId(), _bond->leftatom->getId()) ); 146 BondNodeMap::iterator iter = Bondsin MoleculeMap.find(Rightids);147 ASSERT(iter == Bondsin MoleculeMap.end(),207 BondNodeMap::iterator iter = BondsinSceneMap.find(Rightids); 208 ASSERT(iter == BondsinSceneMap.end(), 148 209 "GLWorldScene::bondAdded() - same right-sided bond "+toString(*_bond)+" added again."); 149 210 GLMoleculeObject_bond *bondObject = 150 211 new GLMoleculeObject_bond(this, _bond, distance, GLMoleculeObject_bond::right); 151 BondsinMoleculeMap.insert( make_pair(Rightids, bondObject) ); 152 } 153 emit changed(); 154 } 155 156 /** Removes an bond from the scene. 212 BondsinSceneMap.insert( make_pair(Rightids, bondObject) ); 213 BondIdsinSceneMap.insert( Rightids ); 214 } 215 emit changed(); 216 } 217 218 /** Removes a bond from the scene. 157 219 * 158 220 * @param _bond bond to remove 159 221 */ 160 void GLWorldScene::bondRemoved(const bond *_bond) 161 { 222 void GLWorldScene::bondRemoved(const atomId_t leftnr, const atomId_t rightnr) 223 { 224 LOG(0, "GLWorldScene::bondRemoved() - Removing bond between "+toString(leftnr)+" and "+toString(leftnr)+"."); 162 225 { 163 226 // left bond 164 const BondIds Leftids( make_pair(_bond->leftatom->getId(), _bond->rightatom->getId()) ); 165 BondNodeMap::iterator leftiter = BondsinMoleculeMap.find( Leftids ); 166 ASSERT(leftiter != BondsinMoleculeMap.end(), 167 "GLWorldScene::bondRemoved() - bond "+toString(*_bond)+" not on display."); 227 const BondIds Leftids( make_pair(leftnr, rightnr) ); 228 BondNodeMap::iterator leftiter = BondsinSceneMap.find( Leftids ); 229 ASSERT(leftiter != BondsinSceneMap.end(), 230 "GLWorldScene::bondRemoved() - bond "+toString(leftnr)+"-" 231 +toString(rightnr)+" not on display."); 168 232 GLMoleculeObject_bond *bondObject = leftiter->second; 169 Bondsin MoleculeMap.erase(leftiter);233 BondsinSceneMap.erase(leftiter); 170 234 delete bondObject; 171 235 } 172 { 173 // right bond 174 const BondIds Rightids( make_pair(_bond->rightatom->getId(), _bond->leftatom->getId()) ); 175 BondNodeMap::iterator rightiter = BondsinMoleculeMap.find( Rightids ); 176 ASSERT(rightiter != BondsinMoleculeMap.end(), 177 "GLWorldScene::bondRemoved() - bond "+toString(*_bond)+" not on display."); 178 GLMoleculeObject_bond *bondObject = rightiter->second; 179 BondsinMoleculeMap.erase(rightiter); 180 delete bondObject; 181 } 236 // remove from bond ids 237 std::pair<BondIdsMap::iterator, BondIdsMap::iterator> leftrange = 238 BondIdsinSceneMap.equal_range(leftnr); 239 BondIdsMap::iterator iter; 240 for (iter = leftrange.first; iter != leftrange.second; ++iter) { 241 if (iter->second == rightnr) { 242 BondIdsinSceneMap.erase(iter); 243 break; 244 } 245 } 246 ASSERT(iter != leftrange.second, 247 "GLWorldScene::bondRemoved() - could not find (" 248 +toString(leftnr)+"-"+toString(rightnr)+" in BondIdsinSceneMap."); 182 249 emit changed(); 183 250 } -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
rdb7e6d r37b2575 64 64 void atomInserted(const atom *_atom); 65 65 void atomRemoved(const atom *_atom); 66 void bondInserted(const bond *_bond); 67 void bondRemoved(const bond *_bond); 66 void bondsChanged(const atom *_atom); 68 67 69 68 private: 70 69 void init(); 70 void bondInserted(const bond *_bond); 71 void bondRemoved(const atomId_t leftnr, const atomId_t rightnr); 71 72 72 typedef std::pair< size_t, size_t> BondIds;73 typedef std::map< size_t, GLMoleculeObject_atom* > AtomNodeMap;73 typedef std::pair< atomId_t, atomId_t> BondIds; 74 typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap; 74 75 typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap; 75 AtomNodeMap AtomsinMoleculeMap; 76 BondNodeMap BondsinMoleculeMap; 76 typedef std::multimap< atomId_t, atomId_t > BondIdsMap; 77 AtomNodeMap AtomsinSceneMap; 78 BondIdsMap BondIdsinSceneMap; 79 BondNodeMap BondsinSceneMap; 77 80 }; 78 81 -
src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp
rdb7e6d r37b2575 46 46 void atomInserted(const atom *_atom); 47 47 void atomRemoved(const atom *_atom); 48 void moleculeInserted(const molecule *_mol);49 void moleculeRemoved(const molecule *_mol);50 48 51 49 protected:
Note:
See TracChangeset
for help on using the changeset viewer.