- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r3927ef r2ad1ec 25 25 #include "GLMoleculeObject_atom.hpp" 26 26 #include "GLMoleculeObject_bond.hpp" 27 #include "GLMoleculeObject_molecule.hpp"28 27 29 28 #include "CodePatterns/MemDebug.hpp" … … 75 74 Runner != molecules.end(); 76 75 Runner++) { 77 76 // create molecule 78 77 for (molecule::const_iterator atomiter = (*Runner)->begin(); 79 78 atomiter != (*Runner)->end(); … … 110 109 AtomsinSceneMap.insert( make_pair(_atom->getId(), atomObject) ); 111 110 connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(atomClicked(atomId_t))); 112 connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));113 111 connect (atomObject, SIGNAL(hoverChanged()), this, SIGNAL(changed())); 114 connect (atomObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));115 112 connect (atomObject, SIGNAL(BondsInserted(const bond *, const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const bond *, const GLMoleculeObject_bond::SideOfBond))); 116 113 //bondsChanged(_atom); … … 137 134 } 138 135 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 mesh159 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 scene171 moleculeRemoved(*Runner);172 }173 174 }175 }176 }177 178 /** Removes a molecule from the scene.179 *180 * @param _molecule molecule to remove181 */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 scene188 // (= 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 199 136 /** Adds a bond to the scene. 200 137 * … … 206 143 LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+"."); 207 144 //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << "."); 145 const double distance = 146 _bond->leftatom->getPosition().distance(_bond->rightatom->getPosition())/2.; 208 147 209 148 BondIds ids; … … 222 161 #endif 223 162 GLMoleculeObject_bond *bondObject = 224 new GLMoleculeObject_bond(this, _bond, side);163 new GLMoleculeObject_bond(this, _bond, distance, side); 225 164 connect ( 226 165 bondObject, SIGNAL(BondRemoved(const atomId_t, const atomId_t)), 227 166 this, SLOT(bondRemoved(const atomId_t, const atomId_t))); 228 connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed()));229 167 BondsinSceneMap.insert( make_pair(ids, bondObject) ); 230 168 // BondIdsinSceneMap.insert( Leftids );
Note:
See TracChangeset
for help on using the changeset viewer.