void SceneTree::ShowContextMenu(const QPoint &pos) { QModelIndex index = indexAt(pos); DAVA::Entity *clickedEntity = treeModel->GetEntity(index); if(NULL != clickedEntity) { QMenu contextMenu; contextMenu.addAction(QIcon(":/QtIcons/zoom.png"), "Look at", this, SLOT(LookAtSelection())); contextMenu.addSeparator(); contextMenu.addAction(QIcon(":/QtIcons/remove.png"), "Remove", this, SLOT(RemoveSelection())); contextMenu.addSeparator(); QAction *lockAction = contextMenu.addAction(QIcon(":/QtIcons/lock_add.png"), "Lock", this, SLOT(LockEntities())); QAction *unlockAction = contextMenu.addAction(QIcon(":/QtIcons/lock_delete.png"), "Unlock", this, SLOT(UnlockEntities())); if(clickedEntity->GetLocked()) { lockAction->setDisabled(true); } else { unlockAction->setDisabled(true); } contextMenu.exec(mapToGlobal(pos)); } }
void WASDCameraController::Input(UIEvent * event) { if (currScene == 0) return; Camera * camera = currScene->GetCurrentCamera(); if (!camera)return; if (event->phase == UIEvent::PHASE_KEYCHAR) { if(!IsKeyModificatorsPressed()) { switch (event->tid) { case DVKEY_Z: { LookAtSelection(); break; } case DVKEY_T: { if (!camera)return; viewZAngle = 0; viewYAngle = MAX_ANGLE; Matrix4 mt, mt2; mt.CreateRotation(Vector3(0,0,1), DegToRad(viewZAngle)); mt2.CreateRotation(Vector3(1,0,0), DegToRad(viewYAngle)); mt2 *= mt; Vector3 vect = Vector3(0,0, 200); Vector3 position = vect + Vector3(0, 10, 0) * mt2; camera->SetTarget(position); camera->SetPosition(vect); break; } case DVKEY_1: { EditorSettings::Instance()->SetCameraSpeedIndex(0); SetSpeed(EditorSettings::Instance()->GetCameraSpeed()); break; } case DVKEY_2: { EditorSettings::Instance()->SetCameraSpeedIndex(1); SetSpeed(EditorSettings::Instance()->GetCameraSpeed()); break; } case DVKEY_3: { EditorSettings::Instance()->SetCameraSpeedIndex(2); SetSpeed(EditorSettings::Instance()->GetCameraSpeed()); break; } case DVKEY_4: { EditorSettings::Instance()->SetCameraSpeedIndex(3); SetSpeed(EditorSettings::Instance()->GetCameraSpeed()); break; } case DVKEY_9: { if (speed - 50 >= 0) { speed -= 50; } break; } case DVKEY_0: { if (speed + 50 <= 5000) { speed += 50; } break; } default: break; } } } bool altBut3 = (selection && event->tid == UIEvent::BUTTON_3 && IsKeyModificatorPressed(DVKEY_ALT)); if(UIEvent::PHASE_BEGAN == event->phase) { startPt = stopPt = event->point; if (altBut3) { const Vector3 & pos = camera->GetPosition(); AABBox3 box = selection->GetWTMaximumBoundingBoxSlow(); center = box.GetCenter(); radius = (center - pos).Length(); } } else if(UIEvent::PHASE_DRAG == event->phase || UIEvent::PHASE_ENDED == event->phase) { startPt = stopPt; stopPt = event->point; if (event->tid == UIEvent::BUTTON_2) { UpdateCam2But(camera); } else if (altBut3) { UpdateCamAlt3But(camera); } else if (event->tid == UIEvent::BUTTON_3) { UpdateCam3But(camera); } } }