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