- Timestamp:
- Aug 5, 2015, 5:32:13 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:
- b9e47e
- Parents:
- a9161d
- git-author:
- Frederik Heber <heber@…> (07/19/15 20:47:41)
- git-committer:
- Frederik Heber <heber@…> (08/05/15 17:32:13)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp
ra9161d r7e2adc 78 78 leftatomId(bondIds.first), 79 79 rightatomId(bondIds.second), 80 left atomref(getAtom(leftatomId)),81 right atomref(getAtom(rightatomId)),82 bond ref(*leftatomref->getBond(rightatomref)),80 leftowner(getAtom(leftatomId)), 81 rightowner(getAtom(rightatomId)), 82 bondowner(getAtom(leftatomId)->getBond(getAtom(rightatomId)).get()), 83 83 BondSide(side), 84 84 leftPosition( 85 left atomref,85 leftowner, 86 86 boost::bind(&GLMoleculeObject_bond::updateLeftPosition, this), 87 87 "BondleftPosition_"+toString(leftatomId), … … 89 89 BondPositionChannels), 90 90 rightPosition( 91 right atomref,91 rightowner, 92 92 boost::bind(&GLMoleculeObject_bond::updateRightPosition, this), 93 93 "BondrightPosition_"+toString(rightatomId), … … 95 95 BondPositionChannels), 96 96 leftElement( 97 left atomref,97 leftowner, 98 98 boost::bind(&GLMoleculeObject_bond::updateLeftElement, this), 99 99 "BondleftElement"+toString(leftatomId), … … 101 101 BondElementChannels), 102 102 rightElement( 103 right atomref,103 rightowner, 104 104 boost::bind(&GLMoleculeObject_bond::updateRightElement, this), 105 105 "BondrightElement"+toString(rightatomId), … … 107 107 BondElementChannels), 108 108 Degree( 109 &bondref,109 bondowner, 110 110 boost::bind(&GLMoleculeObject_bond::updateDegree, this), 111 111 "BondDegree"+toString(leftatomId)+"_"+toString(rightatomId), … … 116 116 { 117 117 // sign on as observer (obtain non-const instance before) 118 bond ref.signOn(this, BondObservable::BondRemoved);119 bond ref.signOn(this, BondObservable::DegreeChanged);118 bondowner->signOn(this, BondObservable::BondRemoved); 119 bondowner->signOn(this, BondObservable::DegreeChanged); 120 120 bond_enabled = true; 121 left atomref->signOn(this, AtomObservable::PositionChanged);122 left atomref->signOn(this, AtomObservable::ElementChanged);121 leftowner->signOn(this, AtomObservable::PositionChanged); 122 leftowner->signOn(this, AtomObservable::ElementChanged); 123 123 leftobservable_enabled = true; 124 right atomref->signOn(this, AtomObservable::PositionChanged);125 right atomref->signOn(this, AtomObservable::ElementChanged);124 rightowner->signOn(this, AtomObservable::PositionChanged); 125 rightowner->signOn(this, AtomObservable::ElementChanged); 126 126 rightobservable_enabled = true; 127 127 … … 140 140 leftatomId << "," << rightatomId << "] and side " << BondSide << "."); 141 141 // signOff() if not already done 142 removeLeftAtom();143 removeRightAtom();144 142 removeChannels(); 145 143 } 146 144 147 void GLMoleculeObject_bond::remove LeftAtom()145 void GLMoleculeObject_bond::removeChannels() 148 146 { 149 147 // at this point both atoms should still be alive, hence we may safely sign off 150 148 // from the AtomObservable itself 149 if (bond_enabled) { 150 if (bondowner != NULL) { 151 bondowner->signOff(this, BondObservable::BondRemoved); 152 bondowner->signOff(this, BondObservable::DegreeChanged); 153 } 154 bond_enabled = false; 155 } 151 156 if (leftobservable_enabled) { 152 const atom * const _leftatom = const_cast<const World &>(World::getInstance()). 153 getAtom(AtomById(leftatomId)); 154 if (_leftatom != NULL) { 155 _leftatom->signOff(this); 156 } else { 157 ELOG(2, "Left atom of bond with id "+toString(leftatomId)+" is already gone."); 158 } 159 } 160 } 161 162 void GLMoleculeObject_bond::removeRightAtom() 163 { 164 // at this point both atoms should still be alive, hence we may safely sign off 165 // from the AtomObservable itself 157 if (leftowner != NULL) { 158 leftowner->signOff(this, AtomObservable::PositionChanged); 159 leftowner->signOff(this, AtomObservable::ElementChanged); 160 } 161 leftobservable_enabled = false; 162 } 166 163 if (rightobservable_enabled) { 167 const atom * const _rightatom = const_cast<const World &>(World::getInstance()). 168 getAtom(AtomById(rightatomId)); 169 if (_rightatom != NULL) { 170 _rightatom->signOff(this); 171 } else { 172 ELOG(2, "Right atom of bond with id "+toString(rightatomId)+" is already gone."); 173 } 174 } 175 } 176 177 void GLMoleculeObject_bond::removeChannels() 178 { 179 // at this point both atoms should still be alive, hence we may safely sign off 180 // from the AtomObservable itself 181 if (leftobservable_enabled) { 182 const atom * const _leftatom = const_cast<const World &>(World::getInstance()). 183 getAtom(AtomById(leftatomId)); 184 if (_leftatom != NULL) { 185 _leftatom->signOff(this, AtomObservable::PositionChanged); 186 _leftatom->signOff(this, AtomObservable::ElementChanged); 187 } else { 188 ELOG(2, "Left atom of bond with id "+toString(leftatomId)+" is already gone."); 189 } 190 leftobservable_enabled = false; 191 } 192 if (rightobservable_enabled) { 193 const atom * const _rightatom = const_cast<const World &>(World::getInstance()). 194 getAtom(AtomById(rightatomId)); 195 if (_rightatom != NULL) { 196 _rightatom->signOff(this, AtomObservable::PositionChanged); 197 _rightatom->signOff(this, AtomObservable::ElementChanged); 198 } else { 199 ELOG(2, "Right atom of bond with id "+toString(rightatomId)+" is already gone."); 164 if (rightowner != NULL) { 165 rightowner->signOff(this, AtomObservable::PositionChanged); 166 rightowner->signOff(this, AtomObservable::ElementChanged); 200 167 } 201 168 rightobservable_enabled = false; 202 169 } 203 if (bond_enabled) {204 const atom * const _leftatom = const_cast<const World &>(World::getInstance()).205 getAtom(AtomById(leftatomId));206 const atom * const _rightatom = const_cast<const World &>(World::getInstance()).207 getAtom(AtomById(rightatomId));208 if ((_leftatom != NULL) && (_rightatom != NULL)) {209 bond::ptr _bond = _leftatom->getBond(_rightatom);210 if (_bond != NULL) {211 _bond->signOff(this, BondObservable::BondRemoved);212 _bond->signOff(this, BondObservable::DegreeChanged);213 }214 }215 bond_enabled = false;216 }217 170 } 218 171 … … 220 173 { 221 174 // sign off 222 switch (BondSide) { 223 case left: 224 emit BondRemoved(leftatomId, rightatomId); 225 break; 226 case right: 227 emit BondRemoved(rightatomId, leftatomId); 228 break; 229 default: 230 ASSERT(0, 231 "GLMoleculeObject_bond::removeMe() - side is not a valid argument: " 232 +toString(BondSide)+"."); 233 break; 234 } 175 emit BondRemoved(leftatomId, rightatomId); 235 176 } 236 177 … … 242 183 void GLMoleculeObject_bond::subjectKilled(Observable *publisher) 243 184 { 244 // assume subjectKilled() is from Observable's own subjectKilled(), not notifications 245 // but we must always signOff from all other sources! 246 if (publisher == static_cast<const Observable*>(&bondref)) { 185 // we signOff from all other sources 186 removeChannels(); 187 // then indicate to remove us 188 removeMe(); 189 } 190 191 void GLMoleculeObject_bond::recieveNotification(Observable *publisher, Notification_ptr notification) 192 { 247 193 #ifdef LOG_OBSERVER 248 observerLog().addMessage() << "++ subjectKilled of Observer " 249 << observerLog().getName(static_cast<Observer*>(this)) 250 << " from bond."; 251 #endif 252 removeLeftAtom(); 253 removeRightAtom(); 254 } else if (publisher == static_cast<const Observable*>(leftatomref)) { 255 #ifdef LOG_OBSERVER 256 observerLog().addMessage() << "++ subjectKilled of Observer " 257 << observerLog().getName(static_cast<Observer*>(this)) 258 << " from leftatom " << leftatomId << "."; 259 #endif 260 removeRightAtom(); 261 } else if (publisher == static_cast<const Observable*>(rightatomref)) { 262 #ifdef LOG_OBSERVER 263 observerLog().addMessage() << "++ subjectKilled of Observer " << 264 observerLog().getName(static_cast<Observer*>(this)) 265 << " from rightatom " << rightatomId << "."; 266 #endif 267 removeLeftAtom(); 268 } else { 269 #ifdef LOG_OBSERVER 270 observerLog().addMessage() << "++ subjectKilled of Observer " 271 << observerLog().getName(static_cast<Observer*>(this)) 272 << " from unknown source."; 273 #endif 274 ASSERT(0, "GLMoleculeObject_bond::recieveNotification() - notification from unknown source."); 275 } 276 // then indicate to remove us 277 removeChannels(); 278 removeMe(); 279 } 280 281 void GLMoleculeObject_bond::recieveNotification(Observable *publisher, Notification_ptr notification) 282 { 283 #ifdef LOG_OBSERVER 284 if (publisher == static_cast<const Observable *>(&bondref)) { 194 if (publisher == static_cast<const Observable *>(bondowner)) { 285 195 observerLog().addMessage() << "++ Update of Observer " 286 196 << observerLog().getName(static_cast<Observer*>(this)) 287 197 << " received notification from bond for channel " 288 198 << notification->getChannelNo() << "."; 289 } else if (publisher == static_cast<const Observable * const>(left atomref)) {199 } else if (publisher == static_cast<const Observable * const>(leftowner)) { 290 200 observerLog().addMessage() << "++ Update of Observer " 291 201 << observerLog().getName(static_cast<Observer*>(this)) 292 202 << " received notification from leftatom " << leftatomId << " for channel " 293 203 << notification->getChannelNo() << "."; 294 } else if (publisher == static_cast<const Observable * const>(right atomref)) {204 } else if (publisher == static_cast<const Observable * const>(rightowner)) { 295 205 observerLog().addMessage() << "++ Update of Observer " 296 206 << observerLog().getName(static_cast<Observer*>(this)) 297 207 << " received notification from rightatom " << rightatomId << " for channel " 298 208 << notification->getChannelNo() << "."; 299 } else 300 observerLog().addMessage() << "++ Update of Observer " 301 << observerLog().getName(static_cast<Observer*>(this)) 302 << " received notification from unknown source."; 209 } 303 210 #endif 304 if (publisher == static_cast<const Observable *>( &bondref)){211 if (publisher == static_cast<const Observable *>(bondowner)){ 305 212 switch (notification->getChannelNo()) { 306 213 case BondObservable::BondRemoved: -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp
ra9161d r7e2adc 73 73 * 74 74 * We remove from all other Observables in a controlled manner. 75 * However, we assume that either bond, leftobservable, or rightobservable76 * called subjectKilled(). Hence, we may still signOff() from all noifications77 * but not from the calling Observable.78 75 * 79 * remove LeftAtom(), removeRightAtom(), removeBond(), and removeChannels()80 * must have been called before (or one ofthe subjects has been killed).76 * removeBond(), and removeChannels() must have been called before (or one of 77 * the subjects has been killed). 81 78 * 82 79 */ 83 80 void removeMe(); 84 void removeLeftAtom();85 void removeRightAtom();86 81 void removeChannels(); 87 82 … … 101 96 const atomId_t rightatomId; 102 97 98 //!> contains ref to Observable of left atom 99 const Observable * const leftowner; 100 //!> contains ref to Observable of right atom 101 const Observable * const rightowner; 103 102 //!> temporary variable used in cstor 104 const atom * const leftatomref; 105 //!> temporary variable used in cstor 106 const atom * const rightatomref; 107 //!> temporary variable used in cstor 108 const bond &bondref; 103 const Observable * const bondowner; 109 104 110 105 const enum SideOfBond BondSide;
Note:
See TracChangeset
for help on using the changeset viewer.