- Timestamp:
- Sep 29, 2013, 11:40:49 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:
- c60665
- Parents:
- beadd0
- git-author:
- Frederik Heber <heber@…> (09/05/13 07:07:45)
- git-committer:
- Frederik Heber <heber@…> (09/29/13 11:40:49)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
rbeadd0 r917659 53 53 #include "WorldTime.hpp" 54 54 55 GLMoleculeObject_atom::GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atom *atomref) :55 GLMoleculeObject_atom::GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atomId_t _id) : 56 56 GLMoleculeObject(mesh, parent), 57 Observer(std::string("GLMoleculeObject_atom")+toString( atomref->getId())),58 _atom(atomref)57 Observer(std::string("GLMoleculeObject_atom")+toString(_id)), 58 atomicid(_id) 59 59 { 60 60 // sign on as observer (obtain non-const instance before) 61 atomref->signOn(this, AtomObservable::IndexChanged); 62 atomref->signOn(this, AtomObservable::PositionChanged); 63 atomref->signOn(this, AtomObservable::ElementChanged); 64 atomref->signOn(this, AtomObservable::BondsAdded); 61 const atom *_atom = World::getInstance().getAtom(AtomById(atomicid)); 62 if (_atom != NULL) { 63 _atom->signOn(this, AtomObservable::IndexChanged); 64 _atom->signOn(this, AtomObservable::PositionChanged); 65 _atom->signOn(this, AtomObservable::ElementChanged); 66 _atom->signOn(this, AtomObservable::BondsAdded); 67 } else { 68 ELOG(2, "Atom with id "+toString(atomicid)+" is already gone."); 69 } 65 70 World::getInstance().signOn(this, World::SelectionChanged); 66 71 WorldTime::getInstance().signOn(this, WorldTime::TimeChanged); … … 69 74 resetProperties(); 70 75 71 LOG(2, "INFO: Created sphere for atom " << _atom->getId()<< ".");76 LOG(2, "INFO: Created sphere for atom " << atomicid << "."); 72 77 73 78 connect( this, SIGNAL(clicked()), this, SLOT(wasClicked())); … … 76 81 GLMoleculeObject_atom::~GLMoleculeObject_atom() 77 82 { 78 if (_atom){ 83 const atom *_atom = World::getInstance().getAtom(AtomById(atomicid)); 84 if (_atom != NULL){ 79 85 _atom->signOff(this, AtomObservable::IndexChanged); 80 86 _atom->signOff(this, AtomObservable::PositionChanged); … … 89 95 { 90 96 #ifdef LOG_OBSERVER 91 observerLog().addMessage() << "++ Update of Observer " << observerLog().getName(static_cast<Observer *>(this)) << " from atom "+toString( _atom->getId())+".";97 observerLog().addMessage() << "++ Update of Observer " << observerLog().getName(static_cast<Observer *>(this)) << " from atom "+toString(atomicid)+"."; 92 98 #endif 93 99 resetProperties(); … … 96 102 void GLMoleculeObject_atom::resetPosition() 97 103 { 98 const Vector Position = _atom->getPosition(); 99 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new position is "+toString(Position)+"."); 100 setPosition(QVector3D(Position[0], Position[1], Position[2])); 104 const atom *_atom = World::getInstance().getAtom(AtomById(atomicid)); 105 if (_atom != NULL) { 106 const Vector Position = _atom->getPosition(); 107 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new position is "+toString(Position)+"."); 108 setPosition(QVector3D(Position[0], Position[1], Position[2])); 109 } else { 110 ELOG(2, "Atom with id "+toString(atomicid)+" is already gone."); 111 } 101 112 } 102 113 … … 104 115 { 105 116 size_t elementno = 0; 106 if (_atom->getType() != NULL) { 107 elementno = _atom->getType()->getAtomicNumber(); 108 } else { // if no element yet, set to hydrogen 109 elementno = 1; 110 } 111 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new element number is "+toString(elementno)+"."); 112 113 // set materials 114 QGLMaterial *elementmaterial = getMaterial(elementno); 115 ASSERT(elementmaterial != NULL, 116 "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function is NULL."); 117 setMaterial(elementmaterial); 118 119 // set scale 120 double radius = 0.; 121 if (_atom->getType() != NULL) { 122 radius = _atom->getType()->getVanDerWaalsRadius(); 123 } else { 124 radius = 0.5; 125 } 126 setScale( radius / 4. ); 117 const atom *_atom = World::getInstance().getAtom(AtomById(atomicid)); 118 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. ); 141 } else { 142 ELOG(2, "Atom with id "+toString(atomicid)+" is already gone."); 143 } 127 144 } 128 145 … … 130 147 { 131 148 int oldId = objectId(); 132 const size_t atomno = _atom->getId(); 133 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new index is "+toString(atomno)+"."); 134 setObjectId(atomno); 135 136 emit indexChanged(this, oldId, atomno); 149 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new index is "+toString(atomicid)+"."); 150 setObjectId(atomicid); 151 152 emit indexChanged(this, oldId, atomicid); 137 153 } 138 154 … … 149 165 150 166 // selected? 151 setSelected(World::getInstance().is Selected(_atom));167 setSelected(World::getInstance().isAtomSelected(atomicid)); 152 168 } 153 169 154 170 void GLMoleculeObject_atom::subjectKilled(Observable *publisher) 155 171 { 156 _atom = NULL; 172 // remove id such that we don't sign off accidentally from a different atom 173 const_cast<atomId_t &>(atomicid) = -1; 157 174 } 158 175 159 176 void GLMoleculeObject_atom::recieveNotification(Observable *publisher, Notification_ptr notification) 160 177 { 178 const atom *_atom = World::getInstance().getAtom(AtomById(atomicid)); 161 179 if (publisher == dynamic_cast<const Observable*>(_atom)){ 162 180 // notofication from atom … … 180 198 case AtomObservable::BondsAdded: 181 199 { 200 const atom *_atom = World::getInstance().getAtom(AtomById(atomicid)); 201 if (_atom != NULL) { 182 202 ASSERT(!_atom->getListOfBonds().empty(), 183 203 "GLMoleculeObject_atom::recieveNotification() - received BondsAdded but ListOfBonds is empty."); … … 186 206 GLMoleculeObject_bond::left : GLMoleculeObject_bond::right; 187 207 emit BondsInserted(_bond, side); 188 break; 208 } else { 209 ELOG(2, "Atom with id "+toString(atomicid)+" is already gone."); 189 210 } 211 break; 212 } 190 213 default: 191 214 //setProperties(); … … 226 249 void GLMoleculeObject_atom::wasClicked() 227 250 { 228 LOG(4, "INFO: GLMoleculeObject_atom: atom " << _atom->getId()<< " has been clicked");229 emit clicked( _atom->getId());230 } 251 LOG(4, "INFO: GLMoleculeObject_atom: atom " << atomicid << " has been clicked"); 252 emit clicked(atomicid); 253 } -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
rbeadd0 r917659 19 19 20 20 #include "Bond/bond.hpp" 21 #include "GLMoleculeObject_bond.hpp" 22 23 class atom; 21 #include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp" 22 #include "types.hpp" 24 23 25 24 class GLMoleculeObject_atom : public GLMoleculeObject, public Observer … … 27 26 Q_OBJECT 28 27 public: 29 GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atom *atomref);28 GLMoleculeObject_atom(QGLSceneNode *mesh[], QObject *parent, const atomId_t id); 30 29 virtual ~GLMoleculeObject_atom(); 31 30 … … 51 50 void resetProperties(); 52 51 53 const atom *_atom;52 const atomId_t atomicid; 54 53 }; 55 54 -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
rbeadd0 r917659 145 145 { 146 146 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_id)+"."); 147 const atom *_atom = World::getInstance().getAtom(AtomById(_id)); 148 GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(meshSphere, this, _atom); 147 GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(meshSphere, this, _id); 149 148 AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id); 150 149 ASSERT(iter == AtomsinSceneMap.end(), 151 "GLWorldScene::atomAdded() - same atom "+ _atom->getName()+" added again.");150 "GLWorldScene::atomAdded() - same atom "+toString(_id)+" added again."); 152 151 AtomsinSceneMap.insert( make_pair(_id, atomObject) ); 153 152
Note:
See TracChangeset
for help on using the changeset viewer.