Changeset c60665
- Timestamp:
- Oct 5, 2013, 9:30:38 AM (11 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:
- 07414d7
- Parents:
- 917659
- git-author:
- Frederik Heber <heber@…> (09/05/13 07:27:00)
- git-committer:
- Frederik Heber <heber@…> (10/05/13 09:30:38)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
r917659 rc60665 116 116 size_t elementno = 0; 117 117 const atom *_atom = World::getInstance().getAtom(AtomById(atomicid)); 118 const element *_type = NULL; 118 119 if (_atom != NULL) { 119 const element *_type = _atom->getType(); 120 if (_type != NULL) { 121 elementno = _type->getAtomicNumber(); 122 } else { // if no element yet, set to hydrogen 123 elementno = 1; 124 } 125 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new element number is "+toString(elementno)+"."); 126 127 // set materials 128 QGLMaterial *elementmaterial = getMaterial(elementno); 129 ASSERT(elementmaterial != NULL, 130 "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function is NULL."); 131 setMaterial(elementmaterial); 132 133 // set scale 134 double radius = 0.; 135 if (_type != NULL) { 136 radius = _type->getVanDerWaalsRadius(); 137 } else { 138 radius = 0.5; 139 } 140 setScale( radius / 4. ); 120 _type = _atom->getType(); 141 121 } else { 142 122 ELOG(2, "Atom with id "+toString(atomicid)+" is already gone."); 143 123 } 124 if (_type != NULL) { 125 elementno = _type->getAtomicNumber(); 126 } else { // if no element yet, set to hydrogen 127 elementno = 1; 128 } 129 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new element number is "+toString(elementno)+"."); 130 131 // set materials 132 QGLMaterial *elementmaterial = getMaterial(elementno); 133 ASSERT(elementmaterial != NULL, 134 "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function is NULL."); 135 setMaterial(elementmaterial); 136 137 // set scale 138 double radius = 0.; 139 if (_type != NULL) { 140 radius = _type->getVanDerWaalsRadius(); 141 } else { 142 radius = 0.5; 143 } 144 setScale( radius / 4. ); 144 145 } 145 146 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp
r917659 rc60665 48 48 #include "CodePatterns/Observer/Notification.hpp" 49 49 #include "CodePatterns/Observer/ObserverLog.hpp" 50 #include "Descriptors/AtomIdDescriptor.hpp" 50 51 #include "Atom/atom.hpp" 51 52 #include "Bond/bond.hpp" … … 54 55 #include "LinearAlgebra/Line.hpp" 55 56 #include "LinearAlgebra/Vector.hpp" 57 #include "World.hpp" 56 58 57 59 GLMoleculeObject_bond::GLMoleculeObject_bond(QGLSceneNode *mesh[], QObject *parent, const bond::ptr bondref, const enum SideOfBond side) : … … 62 64 +toString(bondref->rightatom->getId())), 63 65 _bond(*bondref), 64 left atom(bondref->leftatom),65 right atom(bondref->rightatom),66 leftobservable(bondref->leftatom), 67 rightobservable(bondref->rightatom), 66 68 leftatomId(bondref->leftatom->getId()), 67 69 rightatomId(bondref->rightatom->getId()), 68 BondSide(side) 70 BondSide(side), 71 leftobservable_enabled(false), 72 rightobservable_enabled(false), 73 bond_enabled(false) 69 74 { 70 75 // sign on as observer (obtain non-const instance before) 76 _bond.signOn(this); 71 77 _bond.signOn(this, BondObservable::BondRemoved); 72 78 _bond.signOn(this, BondObservable::DegreeChanged); 73 leftatom->signOn(this, AtomObservable::PositionChanged); 74 leftatom->signOn(this, AtomObservable::ElementChanged); 75 rightatom->signOn(this, AtomObservable::PositionChanged); 76 rightatom->signOn(this, AtomObservable::ElementChanged); 79 bond_enabled = true; 80 leftobservable->signOn(this); 81 leftobservable->signOn(this, AtomObservable::PositionChanged); 82 leftobservable->signOn(this, AtomObservable::ElementChanged); 83 leftobservable_enabled = true; 84 rightobservable->signOn(this); 85 rightobservable->signOn(this, AtomObservable::PositionChanged); 86 rightobservable->signOn(this, AtomObservable::ElementChanged); 87 rightobservable_enabled = true; 77 88 78 89 size_t elementno = 0; 79 90 switch (BondSide) { 80 91 case left: 81 if (_bond.rightatom->getType() != NULL) { 82 elementno = _bond.rightatom->getType()->getAtomicNumber(); 92 { 93 const atom *_rightatom = World::getInstance().getAtom(AtomById(rightatomId)); 94 if (_rightatom->getType() != NULL) { 95 elementno = _rightatom->getType()->getAtomicNumber(); 83 96 } else { // if not element yet set, set to hydrogen 84 97 elementno = 1; 85 98 } 86 99 break; 100 } 87 101 case right: 88 if (_bond.leftatom->getType() != NULL) { 89 elementno = _bond.leftatom->getType()->getAtomicNumber(); 102 { 103 const atom *_leftatom = World::getInstance().getAtom(AtomById(leftatomId)); 104 if (_leftatom->getType() != NULL) { 105 elementno = _leftatom->getType()->getAtomicNumber(); 90 106 } else { // if not element yet set, set to hydrogen 91 107 elementno = 1; … … 93 109 94 110 break; 111 } 95 112 default: 96 113 ASSERT(0, … … 107 124 108 125 GLMoleculeObject_bond::~GLMoleculeObject_bond() 126 { 127 LOG(3, "DEBUG: Destroying GLMoleculeObject_bond to bond " << &_bond << " and side " << BondSide << "."); 128 // signOff() if not already done 129 removeLeftAtom(); 130 removeRightAtom(); 131 removeBond(); 132 removeChannels(); 133 } 134 135 void GLMoleculeObject_bond::removeLeftAtom() 136 { 137 // at this point both atoms should still be alive, hence we may safely sign off 138 // from the AtomObservable itself 139 if (leftobservable_enabled) { 140 const atom *_leftatom = World::getInstance().getAtom(AtomById(leftatomId)); 141 if (_leftatom != NULL) { 142 _leftatom->signOff(this); 143 } else { 144 ELOG(2, "Left atom of bond with id "+toString(leftatomId)+" is already gone."); 145 } 146 } 147 } 148 149 void GLMoleculeObject_bond::removeRightAtom() 150 { 151 // at this point both atoms should still be alive, hence we may safely sign off 152 // from the AtomObservable itself 153 if (rightobservable_enabled) { 154 const atom *_rightatom = World::getInstance().getAtom(AtomById(rightatomId)); 155 if (_rightatom != NULL) { 156 _rightatom->signOff(this); 157 } else { 158 ELOG(2, "Right atom of bond with id "+toString(rightatomId)+" is already gone."); 159 } 160 } 161 } 162 163 void GLMoleculeObject_bond::removeBond() 164 { 165 if (bond_enabled) 166 _bond.signOff(this); 167 } 168 169 void GLMoleculeObject_bond::removeChannels() 170 { 171 // at this point both atoms should still be alive, hence we may safely sign off 172 // from the AtomObservable itself 173 if (leftobservable_enabled) { 174 const atom *_leftatom = World::getInstance().getAtom(AtomById(leftatomId)); 175 if (_leftatom != NULL) { 176 _leftatom->signOff(this, AtomObservable::PositionChanged); 177 _leftatom->signOff(this, AtomObservable::ElementChanged); 178 } else { 179 ELOG(2, "Left atom of bond with id "+toString(leftatomId)+" is already gone."); 180 } 181 leftobservable_enabled = false; 182 } 183 if (rightobservable_enabled) { 184 const atom *_rightatom = World::getInstance().getAtom(AtomById(rightatomId)); 185 if (_rightatom != NULL) { 186 _rightatom->signOff(this, AtomObservable::PositionChanged); 187 _rightatom->signOff(this, AtomObservable::ElementChanged); 188 } else { 189 ELOG(2, "Right atom of bond with id "+toString(rightatomId)+" is already gone."); 190 } 191 rightobservable_enabled = false; 192 } 193 if (bond_enabled) { 194 _bond.signOff(this, BondObservable::BondRemoved); 195 _bond.signOff(this, BondObservable::DegreeChanged); 196 bond_enabled = false; 197 } 198 } 199 200 201 void GLMoleculeObject_bond::removeMe() 109 202 { 110 203 // sign off … … 122 215 break; 123 216 } 124 _bond.signOff(this, BondObservable::BondRemoved);125 _bond.signOff(this, BondObservable::DegreeChanged);126 leftatom->signOff(this, AtomObservable::PositionChanged);127 leftatom->signOff(this, AtomObservable::ElementChanged);128 rightatom->signOff(this, AtomObservable::PositionChanged);129 rightatom->signOff(this, AtomObservable::ElementChanged);130 LOG(3, "DEBUG: Destroying GLMoleculeObject_bond to bond " << &_bond << " and side " << BondSide << ".");131 217 } 132 218 … … 138 224 << observerLog().getName(static_cast<Observer*>(this)) 139 225 << " from bond."; 140 } else if (publisher == left atom) {141 observerLog().addMessage() << "++ Update of Observer " 142 << observerLog().getName(static_cast<Observer*>(this)) 143 << " from leftatom " << _bond.leftatom->getId()<< ".";144 } else if (publisher == right atom) {226 } else if (publisher == leftobservable) { 227 observerLog().addMessage() << "++ Update of Observer " 228 << observerLog().getName(static_cast<Observer*>(this)) 229 << " from leftatom " << leftatomId << "."; 230 } else if (publisher == rightobservable) { 145 231 observerLog().addMessage() << "++ Update of Observer " << 146 232 observerLog().getName(static_cast<Observer*>(this)) 147 << " from rightatom " << _bond.rightatom->getId()<< ".";233 << " from rightatom " << rightatomId << "."; 148 234 } else 149 235 observerLog().addMessage() << "++ Update of Observer " << … … 154 240 void GLMoleculeObject_bond::subjectKilled(Observable *publisher) 155 241 { 156 delete this; 242 // assume subjectKilled() is from Observable's own subjectKilled(), not notifications 243 // but we must always signOff from all other sources! 244 if (publisher == static_cast<const Observable *>(&_bond)) { 245 #ifdef LOG_OBSERVER 246 observerLog().addMessage() << "++ subjectKilled of Observer " 247 << observerLog().getName(static_cast<Observer*>(this)) 248 << " from bond."; 249 #endif 250 removeLeftAtom(); 251 removeRightAtom(); 252 } else if (publisher == leftobservable) { 253 #ifdef LOG_OBSERVER 254 observerLog().addMessage() << "++ subjectKilled of Observer " 255 << observerLog().getName(static_cast<Observer*>(this)) 256 << " from leftatom " << leftatomId << "."; 257 #endif 258 removeRightAtom(); 259 removeBond(); 260 } else if (publisher == rightobservable) { 261 #ifdef LOG_OBSERVER 262 observerLog().addMessage() << "++ subjectKilled of Observer " << 263 observerLog().getName(static_cast<Observer*>(this)) 264 << " from rightatom " << rightatomId << "."; 265 #endif 266 removeLeftAtom(); 267 removeBond(); 268 } else { 269 #ifdef LOG_OBSERVER 270 observerLog().addMessage() << "++ subjectKilled of Observer " << 271 observerLog().getName(static_cast<Observer*>(this)) << " from unknown source."; 272 #endif 273 } 274 // then indicate to remove us 275 removeChannels(); 276 removeMe(); 157 277 } 158 278 … … 165 285 << " received notification from bond for channel " 166 286 << notification->getChannelNo() << "."; 167 } else if (publisher == left atom) {168 observerLog().addMessage() << "++ Update of Observer " 169 << observerLog().getName(static_cast<Observer*>(this)) 170 << " received notification from leftatom " << _bond.leftatom->getId()<< " for channel "287 } else if (publisher == leftobservable) { 288 observerLog().addMessage() << "++ Update of Observer " 289 << observerLog().getName(static_cast<Observer*>(this)) 290 << " received notification from leftatom " << leftatomId << " for channel " 171 291 << notification->getChannelNo() << "."; 172 } else if (publisher == right atom) {173 observerLog().addMessage() << "++ Update of Observer " 174 << observerLog().getName(static_cast<Observer*>(this)) 175 << " received notification from rightatom " << _bond.rightatom->getId()<< " for channel "292 } else if (publisher == rightobservable) { 293 observerLog().addMessage() << "++ Update of Observer " 294 << observerLog().getName(static_cast<Observer*>(this)) 295 << " received notification from rightatom " << rightatomId << " for channel " 176 296 << notification->getChannelNo() << "."; 177 297 } else … … 185 305 switch (notification->getChannelNo()) { 186 306 case BondObservable::BondRemoved: 187 delete this;307 // removeMe(); 188 308 break; 189 309 case BondObservable::DegreeChanged: … … 231 351 Vector Position; 232 352 Vector OtherPosition; 353 const atom *_leftatom = World::getInstance().getAtom(AtomById(leftatomId)); 354 Vector LeftPos = _leftatom->getPosition(); 355 const atom *_rightatom = World::getInstance().getAtom(AtomById(rightatomId)); 356 Vector RightPos = _rightatom->getPosition(); 233 357 switch (BondSide) { 234 358 case left: 235 Position = _bond.leftatom->getPosition();236 OtherPosition = _bond.rightatom->getPosition();359 Position = LeftPos; 360 OtherPosition = RightPos; 237 361 break; 238 362 case right: 239 Position = _bond.rightatom->getPosition();240 OtherPosition = _bond.leftatom->getPosition();363 Position = RightPos; 364 OtherPosition = LeftPos; 241 365 break; 242 366 default: -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp
r917659 rc60665 51 51 void resetWidth(); 52 52 53 /** This must be called from subjectKilled() only. 54 * 55 * We remove from all other Observables in a controlled manner. 56 * However, we assume that either bond, leftobservable, or rightobservable 57 * called subjectKilled(). Hence, we may still signOff() from all noifications 58 * but not from the calling Observable. 59 * 60 * removeLeftAtom(), removeRightAtom(), removeBond(), and removeChannels() 61 * must have been called before (or one of the subjects has been killed). 62 * 63 */ 64 void removeMe(); 65 void removeLeftAtom(); 66 void removeRightAtom(); 67 void removeChannels(); 68 void removeBond(); 69 70 private: 53 71 const bond& _bond; 54 72 /** Observable instance inside atom_observable for left bond partner. … … 57 75 * 58 76 */ 59 const Observable *left atom;77 const Observable *leftobservable; 60 78 /** Observable instance inside atom_observable for right bond partner. 61 79 * We require this knowledge as subjectKilled is called by Observable, not … … 63 81 * 64 82 */ 65 const Observable *right atom;83 const Observable *rightobservable; 66 84 //!> id of left bond partner for safely emitting BondRemoved sigbal 67 85 const atomId_t leftatomId; … … 69 87 const atomId_t rightatomId; 70 88 const enum SideOfBond BondSide; 89 90 //!> indicate whether we are signed in to leftobservable 91 bool leftobservable_enabled; 92 //!> indicate whether we are signed in to rightobservable 93 bool rightobservable_enabled; 94 //!> indicate whether we are signed in to _bond 95 bool bond_enabled; 71 96 }; 72 97 -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r917659 rc60665 295 295 "GLWorldScene::bondRemoved() - bond "+toString(leftnr)+"-" 296 296 +toString(rightnr)+" not on display."); 297 //GLMoleculeObject_bond::ptrbondObject = leftiter->second;297 GLMoleculeObject_bond *bondObject = leftiter->second; 298 298 BondsinSceneMap.erase(leftiter); 299 //delete bondObject; // is done by signal from bond itself299 delete bondObject; // is done by signal from bond itself 300 300 //LOG(4, "INFO: Still present bonds " << BondsinSceneMap << "."); 301 301 }
Note:
See TracChangeset
for help on using the changeset viewer.