- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp
rb6d92e r5a9f4c 71 71 setOption(QGLView::ObjectPicking, true); 72 72 setOption(QGLView::CameraNavigation, false); 73 setFocusPolicy(Qt::StrongFocus);74 73 setCameraControlMode(Rotate); 75 74 defaultEyeSeparation = 4.0; … … 79 78 //changeMaterials(false); 80 79 81 qRegisterMetaType<atomId_t>("atomId_t"); 82 qRegisterMetaType<moleculeId_t>("moleculeId_t"); 80 qRegisterMetaType<atomicNumber_t>("atomicNumber_t"); 83 81 84 82 connect(this, SIGNAL(ShapeAdded()), worldscene, SLOT(addShape())); 85 83 connect(this, SIGNAL(ShapeRemoved()), worldscene, SLOT(removeShape())); 86 connect(this, SIGNAL(TimeChanged()), worldscene, SIGNAL(updated()));87 84 connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled())); 88 85 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))); 91 89 connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged())); 92 connect(this, SIGNAL(moleculeRemoved(const molecule Id_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 *))); 94 92 //connect(this, SIGNAL(changed()), this, SLOT(updateGL())); 95 93 connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled())); 96 connect(this, SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool)), worldscene, SLOT(moleculesVisibilityChanged(const moleculeId_t,bool)));97 94 98 95 // sign on to changes in the world 99 96 World::getInstance().signOn(this); 97 World::getInstance().signOn(this, World::AtomInserted); 98 World::getInstance().signOn(this, World::AtomRemoved); 100 99 World::getInstance().signOn(this, World::MoleculeInserted); 101 100 World::getInstance().signOn(this, World::MoleculeRemoved); … … 338 337 if (static_cast<World *>(publisher) == World::getPointer()) { 339 338 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 } 340 357 case World::SelectionChanged: 341 358 { … … 348 365 case World::MoleculeInserted: 349 366 { 350 const molecule * _mol= World::getInstance().lastChanged<molecule>();367 const molecule *_molecule = World::getInstance().lastChanged<molecule>(); 351 368 #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."; 353 370 #endif 354 emit moleculeInserted(_mol );371 emit moleculeInserted(_molecule); 355 372 break; 356 373 } 357 374 case World::MoleculeRemoved: 358 375 { 359 const molecule Id_t _id = World::getInstance().lastChanged<molecule>()->getId();376 const molecule *_molecule = World::getInstance().lastChanged<molecule>(); 360 377 #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."; 362 379 #endif 363 emit moleculeRemoved(_ id);380 emit moleculeRemoved(_molecule); 364 381 break; 365 382 } … … 376 393 #endif 377 394 emit changed(); 378 emit TimeChanged();379 395 break; 380 396 } … … 500 516 void GLWorldView::keyPressEvent(QKeyEvent *e) 501 517 { 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 distance507 const double key_move_unit = 0.04*(d.length()/50.);508 509 518 if (e->key() == Qt::Key_Tab) { 510 519 // The Tab key turns the ShowPicking option on and off, … … 512 521 setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0)); 513 522 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);537 523 } 538 524 QGLView::keyPressEvent(e); … … 762 748 } 763 749 764 void GLWorldView::sceneHoverSignalled(const atom &_atom)750 void GLWorldView::sceneHoverSignalled(const atom *_atom) 765 751 { 766 752 emit hoverChanged(_atom); 767 753 } 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.