Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all
Unified · Split
| @@ -146,7 +146,6 @@ QString& Application::resourcesPath() { · 145 unmodified lines | ||
| 146 | 146 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 147 | 147 | QApplication(argc, argv), |
| 148 | 148 | _window(new MainWindow(desktop())), |
| 149 | − _glWidget(new GLCanvas()), | |
| 150 | 149 | _toolWindow(NULL), |
| 151 | 150 | _nodeThread(new QThread(this)), |
| 152 | 151 | _datagramProcessor(), |
| @@ -195,7 +194,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 42 unmodified lines | ||
| 195 | 194 | _isVSyncOn(true), |
| 196 | 195 | _aboutToQuit(false) |
| 197 | 196 | { |
| 198 | − | |
| 197 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 198 | + | |
| 199 | 199 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 200 | 200 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| 201 | 201 | |
| @@ -365,16 +365,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 163 unmodified lines | ||
| 365 | 365 | |
| 366 | 366 | ResourceCache::setRequestLimit(3); |
| 367 | 367 | |
| 368 | − _window->setCentralWidget(_glWidget); | |
| 368 | + _window->setCentralWidget(glCanvas); | |
| 369 | 369 | |
| 370 | 370 | restoreSizeAndPosition(); |
| 371 | 371 | |
| 372 | 372 | _window->setVisible(true); |
| 373 | − _glWidget->setFocusPolicy(Qt::StrongFocus); | |
| 374 | − _glWidget->setFocus(); | |
| 373 | + glCanvas->setFocusPolicy(Qt::StrongFocus); | |
| 374 | + glCanvas->setFocus(); | |
| 375 | 375 | |
| 376 | 376 | // enable mouse tracking; otherwise, we only get drag events |
| 377 | − _glWidget->setMouseTracking(true); | |
| 377 | + glCanvas->setMouseTracking(true); | |
| 378 | 378 | |
| 379 | 379 | _toolWindow = new ToolWindow(); |
| 380 | 380 | _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint); |
| @@ -393,7 +393,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 12 unmodified lines | ||
| 393 | 393 | |
| 394 | 394 | checkVersion(); |
| 395 | 395 | |
| 396 | − _overlays.init(_glWidget); // do this before scripts load | |
| 396 | + _overlays.init(glCanvas); // do this before scripts load | |
| 397 | 397 | |
| 398 | 398 | LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); |
| 399 | 399 | LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); |
| @@ -483,8 +483,6 @@ Application::~Application() { · 83 unmodified lines | ||
| 483 | 483 | Menu::getInstance()->deleteLater(); |
| 484 | 484 | |
| 485 | 485 | _myAvatar = NULL; |
| 486 | − | |
| 487 | − delete _glWidget; | |
| 488 | 486 | } |
| 489 | 487 | |
| 490 | 488 | void Application::saveSettings() { |
| @@ -624,7 +622,7 @@ void Application::paintGL() { · 133 unmodified lines | ||
| 624 | 622 | if (OculusManager::isConnected()) { |
| 625 | 623 | _textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize()); |
| 626 | 624 | } else { |
| 627 | − QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); | |
| 625 | + QSize fbSize = DependencyManager::get<GLCanvas>()->getDeviceSize() * getRenderResolutionScale(); | |
| 628 | 626 | _textureCache.setFrameBufferSize(fbSize); |
| 629 | 627 | } |
| 630 | 628 | |
| @@ -1048,7 +1046,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 417 unmodified lines | ||
| 1048 | 1046 | if (isShifted) { |
| 1049 | 1047 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f); |
| 1050 | 1048 | if (TV3DManager::isConnected()) { |
| 1051 | − TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1049 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1050 | + TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1052 | 1051 | } |
| 1053 | 1052 | } else { |
| 1054 | 1053 | _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0)); |
| @@ -1060,7 +1059,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | ||
| 1060 | 1059 | if (isShifted) { |
| 1061 | 1060 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f); |
| 1062 | 1061 | if (TV3DManager::isConnected()) { |
| 1063 | − TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1062 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1063 | + TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | } else { |
| @@ -1506,7 +1506,7 @@ void Application::idle() { · 439 unmodified lines | ||
| 1506 | 1506 | { |
| 1507 | 1507 | PerformanceTimer perfTimer("updateGL"); |
| 1508 | 1508 | PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); |
| 1509 | − _glWidget->updateGL(); | |
| 1509 | + DependencyManager::get<GLCanvas>()->updateGL(); | |
| 1510 | 1510 | } |
| 1511 | 1511 | { |
| 1512 | 1512 | PerformanceTimer perfTimer("rest"); |
| @@ -1532,13 +1532,14 @@ void Application::idle() { · 19 unmodified lines | ||
| 1532 | 1532 | |
| 1533 | 1533 | void Application::checkBandwidthMeterClick() { |
| 1534 | 1534 | // ... to be called upon button release |
| 1535 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1535 | 1536 | if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) && |
| 1536 | 1537 | Menu::getInstance()->isOptionChecked(MenuOption::Stats) && |
| 1537 | 1538 | Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) && |
| 1538 | 1539 | glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(), |
| 1539 | 1540 | getMouseY() - getMouseDragStartedY()))) |
| 1540 | 1541 | <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH |
| 1541 | − && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), _glWidget->width(), _glWidget->height())) { | |
| 1542 | + && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), glCanvas->width(), glCanvas->height())) { | |
| 1542 | 1543 | |
| 1543 | 1544 | // The bandwidth meter is visible, the click didn't get dragged too far and |
| 1544 | 1545 | // we actually hit the bandwidth meter |
| @@ -1567,7 +1568,8 @@ void Application::setFullscreen(bool fullscreen) { · 22 unmodified lines | ||
| 1567 | 1568 | } |
| 1568 | 1569 | |
| 1569 | 1570 | void Application::setEnable3DTVMode(bool enable3DTVMode) { |
| 1570 | − resizeGL(_glWidget->getDeviceWidth(),_glWidget->getDeviceHeight()); | |
| 1571 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1572 | + resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1571 | 1573 | } |
| 1572 | 1574 | |
| 1573 | 1575 | void Application::setEnableVRMode(bool enableVRMode) { |
| @@ -1592,7 +1594,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines | ||
| 1592 | 1594 | _myCamera.setHmdRotation(glm::quat()); |
| 1593 | 1595 | } |
| 1594 | 1596 | |
| 1595 | − resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1597 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1598 | + resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1596 | 1599 | } |
| 1597 | 1600 | |
| 1598 | 1601 | void Application::setRenderVoxels(bool voxelRender) { |
| @@ -1654,8 +1657,9 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox · 55 unmodified lines | ||
| 1654 | 1657 | |
| 1655 | 1658 | bool Application::mouseOnScreen() const { |
| 1656 | 1659 | if (OculusManager::isConnected()) { |
| 1657 | − return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() && | |
| 1658 | − getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight(); | |
| 1660 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1661 | + return getMouseX() >= 0 && getMouseX() <= glCanvas->getDeviceWidth() && | |
| 1662 | + getMouseY() >= 0 && getMouseY() <= glCanvas->getDeviceHeight(); | |
| 1659 | 1663 | } |
| 1660 | 1664 | return true; |
| 1661 | 1665 | } |
| @@ -1774,7 +1778,8 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 112 unmodified lines | ||
| 1774 | 1778 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 1775 | 1779 | QString suggestedName = desktopLocation.append("/voxels.svo"); |
| 1776 | 1780 | |
| 1777 | − QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName, | |
| 1781 | + QString fileNameString = QFileDialog::getSaveFileName(DependencyManager::get<GLCanvas>(), | |
| 1782 | + tr("Export Voxels"), suggestedName, | |
| 1778 | 1783 | tr("Sparse Voxel Octree Files (*.svo)")); |
| 1779 | 1784 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1780 | 1785 | const char* fileName = fileNameAscii.data(); |
| @@ -2029,9 +2034,9 @@ void Application::init() { · 248 unmodified lines | ||
| 2029 | 2034 | |
| 2030 | 2035 | _metavoxels.init(); |
| 2031 | 2036 | |
| 2032 | − _audio.init(_glWidget); | |
| 2033 | − | |
| 2034 | − _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); | |
| 2037 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 2038 | + _audio.init(glCanvas); | |
| 2039 | + _rearMirrorTools = new RearMirrorTools(glCanvas, _mirrorViewRect, _settings); | |
| 2035 | 2040 | |
| 2036 | 2041 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); |
| 2037 | 2042 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| @@ -2913,8 +2918,9 @@ void Application::updateShadowMap() { · 875 unmodified lines | ||
| 2913 | 2918 | } |
| 2914 | 2919 | |
| 2915 | 2920 | fbo->release(); |
| 2916 | − | |
| 2917 | − glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 2921 | + | |
| 2922 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 2923 | + glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 2918 | 2924 | } |
| 2919 | 2925 | |
| 2920 | 2926 | const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; |
| @@ -2944,7 +2950,9 @@ QImage Application::renderAvatarBillboard() { · 23 unmodified lines | ||
| 2944 | 2950 | Glower glower; |
| 2945 | 2951 | |
| 2946 | 2952 | const int BILLBOARD_SIZE = 64; |
| 2947 | − renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true); | |
| 2953 | + renderRearViewMirror(QRect(0, DependencyManager::get<GLCanvas>()->getDeviceHeight() - BILLBOARD_SIZE, | |
| 2954 | + BILLBOARD_SIZE, BILLBOARD_SIZE), | |
| 2955 | + true); | |
| 2948 | 2956 | |
| 2949 | 2957 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 2950 | 2958 | glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); |
| @@ -3239,8 +3247,9 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 288 unmodified lines | ||
| 3239 | 3247 | } |
| 3240 | 3248 | |
| 3241 | 3249 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { |
| 3242 | − float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; | |
| 3243 | − float verticalScale = _glWidget->getDeviceHeight() / 2.0f; | |
| 3250 | + GLCanvas* glCanvas = DependencyManager::get<GLCanvas>(); | |
| 3251 | + float horizontalScale = glCanvas->getDeviceWidth() / 2.0f; | |
| 3252 | + float verticalScale = glCanvas->getDeviceHeight() / 2.0f; | |
| 3244 | 3253 | |
| 3245 | 3254 | // -1,-1 is 0,windowHeight |
| 3246 | 3255 | // 1,1 is windowWidth,0 |
| @@ -3259,7 +3268,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 12 unmodified lines | ||
| 3259 | 3268 | // -1,-1 1,-1 |
| 3260 | 3269 | |
| 3261 | 3270 | glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale, |
| 3262 | − ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight()); | |
| 3271 | + ((projectedPoint.y + 1.0) * -verticalScale) + glCanvas->getDeviceHeight()); | |
| 3263 | 3272 | |
| 3264 | 3273 | return screenPoint; |
| 3265 | 3274 | } |
| @@ -3570,7 +3579,7 @@ void Application::resetSensors() { · 304 unmodified lines | ||
| 3570 | 3579 | QScreen* currentScreen = _window->windowHandle()->screen(); |
| 3571 | 3580 | QWindow* mainWindow = _window->windowHandle(); |
| 3572 | 3581 | QPoint windowCenter = mainWindow->geometry().center(); |
| 3573 | − _glWidget->cursor().setPos(currentScreen, windowCenter); | |
| 3582 | + DependencyManager::get<GLCanvas>()->cursor().setPos(currentScreen, windowCenter); | |
| 3574 | 3583 | |
| 3575 | 3584 | _myAvatar->reset(); |
| 3576 | 3585 | |
| @@ -4251,7 +4260,8 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio · 674 unmodified lines | ||
| 4251 | 4260 | |
| 4252 | 4261 | void Application::loadDialog() { |
| 4253 | 4262 | |
| 4254 | − QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), | |
| 4263 | + QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get<GLCanvas>(), | |
| 4264 | + tr("Open Script"), | |
| 4255 | 4265 | getPreviousScriptLocation(), |
| 4256 | 4266 | tr("JavaScript Files (*.js)")); |
| 4257 | 4267 | if (!fileNameString.isEmpty()) { |
| @@ -4287,7 +4297,7 @@ void Application::loadScriptURLDialog() { · 29 unmodified lines | ||
| 4287 | 4297 | |
| 4288 | 4298 | void Application::toggleLogDialog() { |
| 4289 | 4299 | if (! _logDialog) { |
| 4290 | − _logDialog = new LogDialog(_glWidget, getLogger()); | |
| 4300 | + _logDialog = new LogDialog(DependencyManager::get<GLCanvas>(), getLogger()); | |
| 4291 | 4301 | } |
| 4292 | 4302 | |
| 4293 | 4303 | if (_logDialog->isVisible()) { |
| @@ -4347,7 +4357,7 @@ void Application::parseVersionXml() { · 53 unmodified lines | ||
| 4347 | 4357 | } |
| 4348 | 4358 | |
| 4349 | 4359 | if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) { |
| 4350 | − new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl); | |
| 4360 | + new UpdateDialog(DependencyManager::get<GLCanvas>(), releaseNotes, latestVersion, downloadUrl); | |
| 4351 | 4361 | } |
| 4352 | 4362 | sender->deleteLater(); |
| 4353 | 4363 | } |
| @@ -4380,7 +4390,7 @@ void Application::takeSnapshot() { · 26 unmodified lines | ||
| 4380 | 4390 | } |
| 4381 | 4391 | |
| 4382 | 4392 | if (!_snapshotShareDialog) { |
| 4383 | − _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); | |
| 4393 | + _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>()); | |
| 4384 | 4394 | } |
| 4385 | 4395 | _snapshotShareDialog->show(); |
| 4386 | 4396 | } |