- Timestamp:
- Apr 11, 2012, 4:52:37 PM (14 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:
- 3e93332
- Parents:
- c0ed1e (diff), 3927ef (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Frederik Heber <heber@…> (04/06/12 11:59:28)
- git-committer:
- Frederik Heber <heber@…> (04/11/12 16:52:37)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp
rc0ed1e r53059e 39 39 #include "LinearAlgebra/Vector.hpp" 40 40 41 static QGLSceneNode *createBond(QObject *parent , double distance)41 static QGLSceneNode *createBond(QObject *parent) 42 42 { 43 43 QGLBuilder builder; 44 QGLCylinder cylinder(.25,.25,.25); 45 cylinder.setHeight(distance); 44 QGLCylinder cylinder(.25,.25,1.0,16); 46 45 builder << cylinder; 47 46 QGLSceneNode *n = builder.finalizedSceneNode(); … … 50 49 } 51 50 52 GLMoleculeObject_bond::GLMoleculeObject_bond(QObject *parent, const bond *bondref, const double distance, constenum SideOfBond side) :53 GLMoleculeObject(createBond(parent , distance), parent),51 GLMoleculeObject_bond::GLMoleculeObject_bond(QObject *parent, const bond *bondref, const enum SideOfBond side) : 52 GLMoleculeObject(createBond(parent), parent), 54 53 Observer(std::string("GLMoleculeObject_bond") 55 54 +toString(bondref->leftatom->getId()) … … 61 60 // sign on as observer (obtain non-const instance before) 62 61 _bond->signOn(this, BondObservable::BondRemoved); 63 64 Vector Position;65 Vector OtherPosition; 62 _bond->leftatom->signOn(this, AtomObservable::PositionChanged); 63 _bond->rightatom->signOn(this, AtomObservable::PositionChanged); 64 66 65 size_t elementno = 0; 67 66 switch (BondSide) { 68 67 case left: 69 Position = _bond->leftatom->getPosition();70 OtherPosition = _bond->rightatom->getPosition();71 68 if (_bond->leftatom->getType() != NULL) { 72 69 elementno = _bond->leftatom->getType()->getAtomicNumber(); … … 76 73 break; 77 74 case right: 78 Position = _bond->rightatom->getPosition();79 OtherPosition = _bond->leftatom->getPosition();80 75 if (_bond->rightatom->getType() != NULL) { 81 76 elementno = _bond->rightatom->getType()->getAtomicNumber(); … … 93 88 QGLMaterial *elementmaterial = getMaterial(elementno); 94 89 setMaterial(elementmaterial); 90 91 resetPosition(); 92 } 93 94 GLMoleculeObject_bond::~GLMoleculeObject_bond() 95 { 96 // sign on as observer (obtain non-const instance before) 97 _bond->signOff(this, BondObservable::BondRemoved); 98 _bond->leftatom->signOff(this, AtomObservable::PositionChanged); 99 _bond->rightatom->signOff(this, AtomObservable::PositionChanged); 100 101 LOG(2, "INFO: Destroying GLMoleculeObject_bond to bond " << *_bond << " and side " << BondSide << "."); 102 } 103 104 void GLMoleculeObject_bond::update(Observable *publisher) 105 { 106 #ifdef LOG_OBSERVER 107 observerLog().addMessage() << "++ Update of Observer " << observerLog().getName(this) << " from bond " << *_bond << "."; 108 #endif 109 } 110 111 void GLMoleculeObject_bond::subjectKilled(Observable *publisher) 112 { 113 LOG(2, "INFO: Received subjectKilled from " << *_bond << "."); 114 switch (BondSide) { 115 case left: 116 emit BondRemoved(_bond->leftatom->getId(), _bond->rightatom->getId()); 117 break; 118 case right: 119 emit BondRemoved(_bond->rightatom->getId(), _bond->leftatom->getId()); 120 break; 121 default: 122 ASSERT(0, 123 "GLMoleculeObject_bond::subjectKilled() - side is not a valid argument: "+toString(BondSide)+"."); 124 break; 125 } 126 delete this; 127 } 128 129 void GLMoleculeObject_bond::recieveNotification(Observable *publisher, Notification_ptr notification) 130 { 131 #ifdef LOG_OBSERVER 132 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(this) 133 << " received notification from bond " << *_bond << " for channel " 134 << notification->getChannelNo() << "."; 135 #endif 136 if (publisher == dynamic_cast<const Observable*>(_bond)){ 137 // from the bond 138 switch (notification->getChannelNo()) { 139 case BondObservable::BondRemoved: 140 LOG(2, "INFO: Received notification of BondRemoved from " << *_bond << "."); 141 switch (BondSide) { 142 case left: 143 emit BondRemoved(_bond->leftatom->getId(), _bond->rightatom->getId()); 144 break; 145 case right: 146 emit BondRemoved(_bond->rightatom->getId(), _bond->leftatom->getId()); 147 break; 148 default: 149 ASSERT(0, 150 "GLMoleculeObject_bond::recieveNotification() - side is not a valid argument: "+toString(BondSide)+"."); 151 break; 152 } 153 delete this; 154 break; 155 default: 156 break; 157 } 158 }else{ 159 // from an atom 160 switch (notification->getChannelNo()) { 161 case AtomObservable::PositionChanged: 162 LOG(2, "INFO: Received notification of PositionChanged."); 163 resetPosition(); 164 emit changed(); 165 } 166 } 167 } 168 169 void GLMoleculeObject_bond::resetPosition() 170 { 171 Vector Position; 172 Vector OtherPosition; 173 switch (BondSide) { 174 case left: 175 Position = _bond->leftatom->getPosition(); 176 OtherPosition = _bond->rightatom->getPosition(); 177 break; 178 case right: 179 Position = _bond->rightatom->getPosition(); 180 OtherPosition = _bond->leftatom->getPosition(); 181 break; 182 default: 183 ASSERT(0, 184 "GLMoleculeObject_bond::resetPosition() - side is not a valid argument: "+toString(BondSide)+"."); 185 break; 186 } 187 const double distance = 188 Position.distance(OtherPosition)/2.; 189 setScaleZ(distance); 95 190 96 191 // calculate position … … 123 218 setRotationAngle(alpha/M_PI*180.); 124 219 } 125 126 GLMoleculeObject_bond::~GLMoleculeObject_bond()127 {128 // sign on as observer (obtain non-const instance before)129 _bond->signOff(this, BondObservable::BondRemoved);130 131 LOG(2, "INFO: Destroying GLMoleculeObject_bond to bond " << *_bond << " and side " << BondSide << ".");132 }133 134 void GLMoleculeObject_bond::update(Observable *publisher)135 {136 #ifdef LOG_OBSERVER137 observerLog().addMessage() << "++ Update of Observer " << observerLog().getName(this) << " from bond " << *_bond << ".";138 #endif139 }140 141 void GLMoleculeObject_bond::subjectKilled(Observable *publisher)142 {143 LOG(2, "INFO: Received subjectKilled from " << *_bond << ".");144 switch (BondSide) {145 case left:146 emit BondRemoved(_bond->leftatom->getId(), _bond->rightatom->getId());147 break;148 case right:149 emit BondRemoved(_bond->rightatom->getId(), _bond->leftatom->getId());150 break;151 default:152 ASSERT(0,153 "GLMoleculeObject_bond::subjectKilled() - side is not a valid argument: "+toString(BondSide)+".");154 break;155 }156 delete this;157 }158 159 void GLMoleculeObject_bond::recieveNotification(Observable *publisher, Notification_ptr notification)160 {161 #ifdef LOG_OBSERVER162 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(this)163 << " received notification from bond " << *_bond << " for channel "164 << notification->getChannelNo() << ".";165 #endif166 switch (notification->getChannelNo()) {167 case BondObservable::BondRemoved:168 LOG(2, "INFO: Received notification of BondRemoved from " << *_bond << ".");169 switch (BondSide) {170 case left:171 emit BondRemoved(_bond->leftatom->getId(), _bond->rightatom->getId());172 break;173 case right:174 emit BondRemoved(_bond->rightatom->getId(), _bond->leftatom->getId());175 break;176 default:177 ASSERT(0,178 "GLMoleculeObject_bond::recieveNotification() - side is not a valid argument: "+toString(BondSide)+".");179 break;180 }181 delete this;182 break;183 default:184 break;185 }186 }
Note:
See TracChangeset
for help on using the changeset viewer.
