Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r3927ef r2ad1ec  
    2525#include "GLMoleculeObject_atom.hpp"
    2626#include "GLMoleculeObject_bond.hpp"
    27 #include "GLMoleculeObject_molecule.hpp"
    2827
    2928#include "CodePatterns/MemDebug.hpp"
     
    7574        Runner != molecules.end();
    7675        Runner++) {
    77 
     76      // create molecule
    7877      for (molecule::const_iterator atomiter = (*Runner)->begin();
    7978          atomiter != (*Runner)->end();
     
    110109  AtomsinSceneMap.insert( make_pair(_atom->getId(), atomObject) );
    111110  connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
    112   connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));
    113111  connect (atomObject, SIGNAL(hoverChanged()), this, SIGNAL(changed()));
    114   connect (atomObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
    115112  connect (atomObject, SIGNAL(BondsInserted(const bond *, const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const bond *, const GLMoleculeObject_bond::SideOfBond)));
    116113  //bondsChanged(_atom);
     
    137134}
    138135
    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 
    199136/** Adds a bond to the scene.
    200137 *
     
    206143  LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+".");
    207144  //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << ".");
     145  const double distance =
     146      _bond->leftatom->getPosition().distance(_bond->rightatom->getPosition())/2.;
    208147
    209148  BondIds ids;
     
    222161#endif
    223162  GLMoleculeObject_bond *bondObject =
    224       new GLMoleculeObject_bond(this, _bond, side);
     163      new GLMoleculeObject_bond(this, _bond, distance, side);
    225164  connect (
    226165      bondObject, SIGNAL(BondRemoved(const atomId_t, const atomId_t)),
    227166      this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
    228   connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed()));
    229167  BondsinSceneMap.insert( make_pair(ids, bondObject) );
    230168//    BondIdsinSceneMap.insert( Leftids );
Note: See TracChangeset for help on using the changeset viewer.