Ignore:
File:
1 edited

Legend:

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

    r5a9f4c rb6d92e  
    7171  setOption(QGLView::ObjectPicking, true);
    7272  setOption(QGLView::CameraNavigation, false);
     73  setFocusPolicy(Qt::StrongFocus);
    7374  setCameraControlMode(Rotate);
    7475  defaultEyeSeparation = 4.0;
     
    7879  //changeMaterials(false);
    7980
    80   qRegisterMetaType<atomicNumber_t>("atomicNumber_t");
     81  qRegisterMetaType<atomId_t>("atomId_t");
     82  qRegisterMetaType<moleculeId_t>("moleculeId_t");
    8183
    8284  connect(this, SIGNAL(ShapeAdded()), worldscene, SLOT(addShape()));
    8385  connect(this, SIGNAL(ShapeRemoved()), worldscene, SLOT(removeShape()));
     86  connect(this, SIGNAL(TimeChanged()), worldscene, SIGNAL(updated()));
    8487  connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled()));
    8588  connect(worldscene, SIGNAL(changed()), this, SIGNAL(changed()));
    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)));
     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)));
    8991  connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged()));
    90   connect(this, SIGNAL(moleculeRemoved(const molecule *)), worldscene, SLOT(moleculeRemoved(const molecule *)));
    91   //connect(this, SIGNAL(moleculeInserted(const molecule *)), worldscene, SLOT(moleculeInserted(const molecule *)));
     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 *)));
    9294  //connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
    9395  connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
     96  connect(this, SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool)), worldscene, SLOT(moleculesVisibilityChanged(const moleculeId_t,bool)));
    9497
    9598  // sign on to changes in the world
    9699  World::getInstance().signOn(this);
    97   World::getInstance().signOn(this, World::AtomInserted);
    98   World::getInstance().signOn(this, World::AtomRemoved);
    99100  World::getInstance().signOn(this, World::MoleculeInserted);
    100101  World::getInstance().signOn(this, World::MoleculeRemoved);
     
    337338  if (static_cast<World *>(publisher) == World::getPointer()) {
    338339    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       }
    357340      case World::SelectionChanged:
    358341      {
     
    365348      case World::MoleculeInserted:
    366349      {
    367         const molecule *_molecule = World::getInstance().lastChanged<molecule>();
     350        const molecule * _mol = World::getInstance().lastChanged<molecule>();
    368351  #ifdef LOG_OBSERVER
    369         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
     352        observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_mol->getId())+" has been removed.";
    370353  #endif
    371         emit moleculeInserted(_molecule);
     354        emit moleculeInserted(_mol);
    372355        break;
    373356      }
    374357      case World::MoleculeRemoved:
    375358      {
    376         const molecule *_molecule = World::getInstance().lastChanged<molecule>();
     359        const moleculeId_t _id = World::getInstance().lastChanged<molecule>()->getId();
    377360  #ifdef LOG_OBSERVER
    378         observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
     361        observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_id)+" has been removed.";
    379362  #endif
    380         emit moleculeRemoved(_molecule);
     363        emit moleculeRemoved(_id);
    381364        break;
    382365      }
     
    393376#endif
    394377        emit changed();
     378        emit TimeChanged();
    395379        break;
    396380      }
     
    516500void GLWorldView::keyPressEvent(QKeyEvent *e)
    517501{
     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
    518509  if (e->key() == Qt::Key_Tab) {
    519510    // The Tab key turns the ShowPicking option on and off,
     
    521512    setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0));
    522513    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);
    523537  }
    524538  QGLView::keyPressEvent(e);
     
    748762}
    749763
    750 void GLWorldView::sceneHoverSignalled(const atom *_atom)
     764void GLWorldView::sceneHoverSignalled(const atom &_atom)
    751765{
    752766  emit hoverChanged(_atom);
    753767}
     768
     769void GLWorldView::sceneHoverSignalled(const molecule &_mol, int _i)
     770{
     771  emit hoverChanged(_mol, _i);
     772}
Note: See TracChangeset for help on using the changeset viewer.