History

Moved GLCanvas to DependencyManager

Atlante45 committed 11 years ago

Commit 68430e11 parent 25df7843 files · +68 −49Browse files

Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all

Unified · Split

interface/src/Application.cpp+43−33
@@ -146,7 +146,6 @@ QString& Application::resourcesPath() { · 145 unmodified lines
146146 Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
147147 QApplication(argc, argv),
148148 _window(new MainWindow(desktop())),
149− _glWidget(new GLCanvas()),
150149 _toolWindow(NULL),
151150 _nodeThread(new QThread(this)),
152151 _datagramProcessor(),
@@ -195,7 +194,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 42 unmodified lines
195194 _isVSyncOn(true),
196195 _aboutToQuit(false)
197196 {
198−
197+ GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
198+
199199 // read the ApplicationInfo.ini file for Name/Version/Domain information
200200 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
201201
@@ -365,16 +365,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 163 unmodified lines
365365
366366 ResourceCache::setRequestLimit(3);
367367
368− _window->setCentralWidget(_glWidget);
368+ _window->setCentralWidget(glCanvas);
369369
370370 restoreSizeAndPosition();
371371
372372 _window->setVisible(true);
373− _glWidget->setFocusPolicy(Qt::StrongFocus);
374− _glWidget->setFocus();
373+ glCanvas->setFocusPolicy(Qt::StrongFocus);
374+ glCanvas->setFocus();
375375
376376 // enable mouse tracking; otherwise, we only get drag events
377− _glWidget->setMouseTracking(true);
377+ glCanvas->setMouseTracking(true);
378378
379379 _toolWindow = new ToolWindow();
380380 _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
@@ -393,7 +393,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 12 unmodified lines
393393
394394 checkVersion();
395395
396− _overlays.init(_glWidget); // do this before scripts load
396+ _overlays.init(glCanvas); // do this before scripts load
397397
398398 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
399399 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
@@ -483,8 +483,6 @@ Application::~Application() { · 83 unmodified lines
483483 Menu::getInstance()->deleteLater();
484484
485485 _myAvatar = NULL;
486−
487− delete _glWidget;
488486 }
489487
490488 void Application::saveSettings() {
@@ -624,7 +622,7 @@ void Application::paintGL() { · 133 unmodified lines
624622 if (OculusManager::isConnected()) {
625623 _textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());
626624 } else {
627− QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
625+ QSize fbSize = DependencyManager::get<GLCanvas>()->getDeviceSize() * getRenderResolutionScale();
628626 _textureCache.setFrameBufferSize(fbSize);
629627 }
630628
@@ -1048,7 +1046,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 417 unmodified lines
10481046 if (isShifted) {
10491047 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
10501048 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());
10521051 }
10531052 } else {
10541053 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
@@ -1060,7 +1059,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines
10601059 if (isShifted) {
10611060 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
10621061 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());
10641064 }
10651065
10661066 } else {
@@ -1506,7 +1506,7 @@ void Application::idle() { · 439 unmodified lines
15061506 {
15071507 PerformanceTimer perfTimer("updateGL");
15081508 PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
1509− _glWidget->updateGL();
1509+ DependencyManager::get<GLCanvas>()->updateGL();
15101510 }
15111511 {
15121512 PerformanceTimer perfTimer("rest");
@@ -1532,13 +1532,14 @@ void Application::idle() { · 19 unmodified lines
15321532
15331533 void Application::checkBandwidthMeterClick() {
15341534 // ... to be called upon button release
1535+ GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
15351536 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
15361537 Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
15371538 Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) &&
15381539 glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(),
15391540 getMouseY() - getMouseDragStartedY())))
15401541 <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH
1541− && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), _glWidget->width(), _glWidget->height())) {
1542+ && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), glCanvas->width(), glCanvas->height())) {
15421543
15431544 // The bandwidth meter is visible, the click didn't get dragged too far and
15441545 // we actually hit the bandwidth meter
@@ -1567,7 +1568,8 @@ void Application::setFullscreen(bool fullscreen) { · 22 unmodified lines
15671568 }
15681569
15691570 void Application::setEnable3DTVMode(bool enable3DTVMode) {
1570− resizeGL(_glWidget->getDeviceWidth(),_glWidget->getDeviceHeight());
1571+ GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
1572+ resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
15711573 }
15721574
15731575 void Application::setEnableVRMode(bool enableVRMode) {
@@ -1592,7 +1594,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines
15921594 _myCamera.setHmdRotation(glm::quat());
15931595 }
15941596
1595− resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1597+ GLCanvas* glCanvas = DependencyManager::get<GLCanvas>();
1598+ resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
15961599 }
15971600
15981601 void Application::setRenderVoxels(bool voxelRender) {
@@ -1654,8 +1657,9 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox · 55 unmodified lines
16541657
16551658 bool Application::mouseOnScreen() const {
16561659 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();
16591663 }
16601664 return true;
16611665 }
@@ -1774,7 +1778,8 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 112 unmodified lines
17741778 QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
17751779 QString suggestedName = desktopLocation.append("/voxels.svo");
17761780
1777− QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName,
1781+ QString fileNameString = QFileDialog::getSaveFileName(DependencyManager::get<GLCanvas>(),
1782+ tr("Export Voxels"), suggestedName,
17781783 tr("Sparse Voxel Octree Files (*.svo)"));
17791784 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
17801785 const char* fileName = fileNameAscii.data();
@@ -2029,9 +2034,9 @@ void Application::init() { · 248 unmodified lines
20292034
20302035 _metavoxels.init();
20312036
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);
20352040
20362041 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
20372042 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
@@ -2913,8 +2918,9 @@ void Application::updateShadowMap() { · 875 unmodified lines
29132918 }
29142919
29152920 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());
29182924 }
29192925
29202926 const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
@@ -2944,7 +2950,9 @@ QImage Application::renderAvatarBillboard() { · 23 unmodified lines
29442950 Glower glower;
29452951
29462952 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);
29482956
29492957 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
29502958 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
32393247 }
32403248
32413249 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;
32443253
32453254 // -1,-1 is 0,windowHeight
32463255 // 1,1 is windowWidth,0
@@ -3259,7 +3268,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 12 unmodified lines
32593268 // -1,-1 1,-1
32603269
32613270 glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale,
3262− ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight());
3271+ ((projectedPoint.y + 1.0) * -verticalScale) + glCanvas->getDeviceHeight());
32633272
32643273 return screenPoint;
32653274 }
@@ -3570,7 +3579,7 @@ void Application::resetSensors() { · 304 unmodified lines
35703579 QScreen* currentScreen = _window->windowHandle()->screen();
35713580 QWindow* mainWindow = _window->windowHandle();
35723581 QPoint windowCenter = mainWindow->geometry().center();
3573− _glWidget->cursor().setPos(currentScreen, windowCenter);
3582+ DependencyManager::get<GLCanvas>()->cursor().setPos(currentScreen, windowCenter);
35743583
35753584 _myAvatar->reset();
35763585
@@ -4251,7 +4260,8 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio · 674 unmodified lines
42514260
42524261 void Application::loadDialog() {
42534262
4254− QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"),
4263+ QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get<GLCanvas>(),
4264+ tr("Open Script"),
42554265 getPreviousScriptLocation(),
42564266 tr("JavaScript Files (*.js)"));
42574267 if (!fileNameString.isEmpty()) {
@@ -4287,7 +4297,7 @@ void Application::loadScriptURLDialog() { · 29 unmodified lines
42874297
42884298 void Application::toggleLogDialog() {
42894299 if (! _logDialog) {
4290− _logDialog = new LogDialog(_glWidget, getLogger());
4300+ _logDialog = new LogDialog(DependencyManager::get<GLCanvas>(), getLogger());
42914301 }
42924302
42934303 if (_logDialog->isVisible()) {
@@ -4347,7 +4357,7 @@ void Application::parseVersionXml() { · 53 unmodified lines
43474357 }
43484358
43494359 if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
4350− new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl);
4360+ new UpdateDialog(DependencyManager::get<GLCanvas>(), releaseNotes, latestVersion, downloadUrl);
43514361 }
43524362 sender->deleteLater();
43534363 }
@@ -4380,7 +4390,7 @@ void Application::takeSnapshot() { · 26 unmodified lines
43804390 }
43814391
43824392 if (!_snapshotShareDialog) {
4383− _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);
4393+ _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>());
43844394 }
43854395 _snapshotShareDialog->show();
43864396 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t