- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r2ad1ec r3927ef 25 25 #include "GLMoleculeObject_atom.hpp" 26 26 #include "GLMoleculeObject_bond.hpp" 27 #include "GLMoleculeObject_molecule.hpp" 27 28 28 29 #include "CodePatterns/MemDebug.hpp" … … 74 75 Runner != molecules.end(); 75 76 Runner++) { 76 // create molecule 77 77 78 for (molecule::const_iterator atomiter = (*Runner)->begin(); 78 79 atomiter != (*Runner)->end(); … … 109 110 AtomsinSceneMap.insert( make_pair(_atom->getId(), atomObject) ); 110 111 connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(atomClicked(atomId_t))); 112 connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed())); 111 113 connect (atomObject, SIGNAL(hoverChanged()), this, SIGNAL(changed())); 114 connect (atomObject, SIGNAL(selectionChanged()), this, SIGNAL(changed())); 112 115 connect (atomObject, SIGNAL(BondsInserted(const bond *, const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const bond *, const GLMoleculeObject_bond::SideOfBond))); 113 116 //bondsChanged(_atom); … … 134 137 } 135 138 139 /** .... 140 * 141 */ 142 void GLWorldScene::worldSelectionChanged() 143 { 144 LOG(3, "INFO: GLWorldScene: Received signal selectionChanged."); 145 146 const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules(); 147 148 if (molecules.size() > 0) { 149 for (std::vector<molecule*>::const_iterator Runner = molecules.begin(); 150 Runner != molecules.end(); 151 Runner++) { 152 153 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find((*Runner)->getId()); 154 bool isSelected = World::getInstance().isSelected(*Runner); 155 156 // molecule selected but not in scene? 157 if (isSelected && (iter == MoleculesinSceneMap.end())){ 158 // -> create new mesh 159 GLMoleculeObject_molecule *molObject = new GLMoleculeObject_molecule(this, *Runner); 160 MoleculesinSceneMap.insert( make_pair((*Runner)->getId(), molObject) ); 161 connect (molObject, SIGNAL(changed()), this, SIGNAL(changed())); 162 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed())); 163 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed())); 164 emit changed(); 165 emit changeOccured(); 166 } 167 168 // molecule not selected but in scene? 169 if (!isSelected && (iter != MoleculesinSceneMap.end())){ 170 // -> remove from scene 171 moleculeRemoved(*Runner); 172 } 173 174 } 175 } 176 } 177 178 /** Removes a molecule from the scene. 179 * 180 * @param _molecule molecule to remove 181 */ 182 void GLWorldScene::moleculeRemoved(const molecule *_molecule) 183 { 184 LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_molecule->getId())+"."); 185 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molecule->getId()); 186 187 // only remove if the molecule is in the scene 188 // (= is selected) 189 if (iter != MoleculesinSceneMap.end()){ 190 GLMoleculeObject_molecule *molObject = iter->second; 191 molObject->disconnect(); 192 MoleculesinSceneMap.erase(iter); 193 delete molObject; 194 emit changed(); 195 emit changeOccured(); 196 } 197 } 198 136 199 /** Adds a bond to the scene. 137 200 * … … 143 206 LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+"."); 144 207 //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << "."); 145 const double distance =146 _bond->leftatom->getPosition().distance(_bond->rightatom->getPosition())/2.;147 208 148 209 BondIds ids; … … 161 222 #endif 162 223 GLMoleculeObject_bond *bondObject = 163 new GLMoleculeObject_bond(this, _bond, distance,side);224 new GLMoleculeObject_bond(this, _bond, side); 164 225 connect ( 165 226 bondObject, SIGNAL(BondRemoved(const atomId_t, const atomId_t)), 166 227 this, SLOT(bondRemoved(const atomId_t, const atomId_t))); 228 connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed())); 167 229 BondsinSceneMap.insert( make_pair(ids, bondObject) ); 168 230 // BondIdsinSceneMap.insert( Leftids );
Note:
See TracChangeset
for help on using the changeset viewer.