Ignore:
File:
1 edited

Legend:

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

    rb6d92e r5a9f4c  
    7171  setOption(QGLView::ObjectPicking, true);
    7272  setOption(QGLView::CameraNavigation, false);
    73   setFocusPolicy(Qt::StrongFocus);
    7473  setCameraControlMode(Rotate);
    7574  defaultEyeSeparation = 4.0;
     
    7978  //changeMaterials(false);
    8079
    81   qRegisterMetaType<atomId_t>("atomId_t");
    82   qRegisterMetaType<moleculeId_t>("moleculeId_t");
     80  qRegisterMetaType<atomicNumber_t>("atomicNumber_t");
    8381
    8482  connect(this, SIGNAL(ShapeAdded()), worldscene, SLOT(addShape()));
    8583  connect(this, SIGNAL(ShapeRemoved()), worldscene, SLOT(removeShape()));
    86   connect(this, SIGNAL(TimeChanged()), worldscene, SIGNAL(updated()));
    8784  connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled()));
    8885  connect(worldscene, SIGNAL(changed()), this, SIGNAL(changed()));
    89   connect(worldscene, SIGNAL(hoverChanged(const atom &)), this, SLOT(sceneHoverSignalled(const atom &)));
    90   connect(worldscene, SIGNAL(hoverChanged(const molecule &, int)), this, SLOT(sceneHoverSignalled(const molecule &, int)));
     86  connect(worldscene, SIGNAL(hoverChanged(const atom *)), this, SLOT(sceneHoverSignalled(const atom *)));
     87  connect(this, SIGNAL(atomInserted(const atomicNumber_t)), worldscene, SLOT(atomInserted(const atomicNumber_t)));
     88  connect(this, SIGNAL(atomRemoved(const atomicNumber_t)), worldscene, SLOT(atomRemoved(const atomicNumber_t)));
    9189  connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged()));
    92   connect(this, SIGNAL(moleculeRemoved(const moleculeId_t)), worldscene, SLOT(moleculeRemoved(const moleculeId_t)));
    93   connect(this, SIGNAL(moleculeInserted(const molecule *)), worldscene, SLOT(moleculeInserted(const molecule *)));
     90  connect(this, SIGNAL(moleculeRemoved(const molecule *)), worldscene, SLOT(moleculeRemoved(const molecule *)));
     91  //connect(this, SIGNAL(moleculeInserted(const molecule *)), worldscene, SLOT(moleculeInserted(const molecule *)));
    9492  //connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
    9593  connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
    96   connect(this, SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool)), worldscene, SLOT(moleculesVisibilityChanged(const moleculeId_t,bool)));
    9794
    9895  // sign on to changes in the world
    9996  World::getInstance().signOn(this);
     97  World::getInstance().signOn(this, World::AtomInserted);
     98  World::getInstance().signOn(this, World::AtomRemoved);
    10099  World::getInstance().signOn(this, World::MoleculeInserted);
    101100  World::getInstance().signOn(this, World::MoleculeRemoved);
     
    338337  if (static_cast<World *>(publisher) == World::getPointer()) {
    339338    switch (notification->getChannelNo()) {
     339      case World::AtomInserted:
     340      {
     341        const atomicNumber_t _id = World::getInstance().lastChanged<atom>()->getId();
     342  #ifdef LOG_OBSERVER
     343        observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
     344  #endif
     345        emit atomInserted(_id);
     346        break;
     347      }
     348      case World::AtomRemoved:
     349      {
     350        const atomicNumber_t _id = World::getInstance().lastChanged<atom>()->getId();
     351  #ifdef LOG_OBSERVER
     352        observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed.";
     353  #endif
     354        emit atomRemoved(_id);
     355        break;
     356      }
    340357      case World::SelectionChanged:
    341358      {
     
    348365      case World::MoleculeInserted:
    349366      {
    350         const molecule * _mol = World::getInstance().lastChanged<molecule>();
     367        const molecule *_molecule = World::getInstance().lastChanged<molecule>();
    351368  #ifdef LOG_OBSERVER
    352         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_mol->getId())+" has been removed.";
     369        observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
    353370  #endif
    354         emit moleculeInserted(_mol);
     371        emit moleculeInserted(_molecule);
    355372        break;
    356373      }
    357374      case World::MoleculeRemoved:
    358375      {
    359         const moleculeId_t _id = World::getInstance().lastChanged<molecule>()->getId();
     376        const molecule *_molecule = World::getInstance().lastChanged<molecule>();
    360377  #ifdef LOG_OBSERVER
    361         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been removed.";
     378        observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
    362379  #endif
    363         emit moleculeRemoved(_id);
     380        emit moleculeRemoved(_molecule);
    364381        break;
    365382      }
     
    376393#endif
    377394        emit changed();
    378         emit TimeChanged();
    379395        break;
    380396      }
     
    500516void GLWorldView::keyPressEvent(QKeyEvent *e)
    501517{
    502   // Find the distance between the eye and focus point.
    503   QVector3D d = camera()->eye() - camera()->center();
    504 //  LOG(1, "Distance vector eye and center is "
    505 //      << d.x() << "," << d.y() << "," << d.z());
    506   // scale the move unit by the eye <-> domain center distance
    507   const double key_move_unit = 0.04*(d.length()/50.);
    508 
    509518  if (e->key() == Qt::Key_Tab) {
    510519    // The Tab key turns the ShowPicking option on and off,
     
    512521    setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0));
    513522    updateGL();
    514   } else if ((e->key() == Qt::Key_Minus) || (e->key() == Qt::Key_Plus)) {
    515     // Scale the distance.
    516     if (e->key() == Qt::Key_Minus)
    517       d *= 1.2;
    518     else if (e->key() == Qt::Key_Plus)
    519       d /= 1.2;
    520     // Set new eye position.
    521     camera()->setEye(camera()->center() + d);
    522   } else if ((e->key() == Qt::Key_Left) || (e->key() == Qt::Key_Right)) {
    523     // Translate the camera.
    524     const double d = (e->key() == Qt::Key_Left) ? -key_move_unit : key_move_unit;
    525     camera()->translateCenter( d, 0., 0);
    526     camera()->translateEye( d, 0., 0);
    527   } else if ((e->key() == Qt::Key_Up) || (e->key() == Qt::Key_Down)) {
    528     // Translate the camera.
    529     const double d = (e->key() == Qt::Key_Up) ? -key_move_unit : key_move_unit;
    530     camera()->translateCenter( 0., d, 0);
    531     camera()->translateEye( 0., d, 0);
    532   } else if ((e->key() == Qt::Key_PageUp) || (e->key() == Qt::Key_PageDown)) {
    533     // Translate the camera.
    534     const double d = (e->key() == Qt::Key_PageUp) ? -key_move_unit : key_move_unit;
    535     camera()->translateCenter( 0., 0., d);
    536     camera()->translateEye( 0., 0., d);
    537523  }
    538524  QGLView::keyPressEvent(e);
     
    762748}
    763749
    764 void GLWorldView::sceneHoverSignalled(const atom &_atom)
     750void GLWorldView::sceneHoverSignalled(const atom *_atom)
    765751{
    766752  emit hoverChanged(_atom);
    767753}
    768 
    769 void GLWorldView::sceneHoverSignalled(const molecule &_mol, int _i)
    770 {
    771   emit hoverChanged(_mol, _i);
    772 }
Note: See TracChangeset for help on using the changeset viewer.