History

Merge branch 'master' of https://github.com/highfidelity/hifi into cuckoo

Stephen Birarda committed 11 years ago

Commit 9425ea22 parents adf51bf 1617d7978 files · +580 −577Browse files

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

Unified · Split

interface/src/Application.cpp+73−48
@@ -64,6 +64,7 @@ · 63 unmodified lines
6464 #include <HFBackEvent.h>
6565 #include <LocalVoxelsList.h>
6666 #include <LogHandler.h>
67+#include <MainWindow.h>
6768 #include <NetworkAccessManager.h>
6869 #include <OctalCode.h>
6970 #include <OctreeSceneStats.h>
@@ -73,6 +74,7 @@ · 3 unmodified lines
7374 #include <ProgramObject.h>
7475 #include <ResourceCache.h>
7576 #include <SoundCache.h>
77+#include <TextRenderer.h>
7678 #include <UserActivityLogger.h>
7779 #include <UUID.h>
7880
@@ -109,7 +111,6 @@ · 30 unmodified lines
109111 #include "ui/InfoView.h"
110112 #include "ui/Snapshot.h"
111113 #include "ui/Stats.h"
112−#include "ui/TextRenderer.h"
113114
114115
115116
@@ -142,7 +143,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 26 unmodified lines
142143 Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
143144 QApplication(argc, argv),
144145 _window(new MainWindow(desktop())),
145− _glWidget(new GLCanvas()),
146146 _toolWindow(NULL),
147147 _nodeThread(new QThread(this)),
148148 _datagramProcessor(),
@@ -155,9 +155,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 6 unmodified lines
155155 _voxelImporter(),
156156 _importSucceded(false),
157157 _sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard),
158− _entities(true),
158+ _entities(true, this, this),
159159 _entityCollisionSystem(),
160− _entityClipboardRenderer(false),
160+ _entityClipboardRenderer(false, this, this),
161161 _entityClipboard(),
162162 _wantToKillLocalVoxels(false),
163163 _viewFrustum(),
@@ -191,8 +191,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines
191191 _isVSyncOn(true),
192192 _aboutToQuit(false)
193193 {
194− Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us
195−
194+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
195+ Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
196+
196197 // read the ApplicationInfo.ini file for Name/Version/Domain information
197198 QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
198199
@@ -362,16 +363,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 163 unmodified lines
362363
363364 ResourceCache::setRequestLimit(3);
364365
365− _window->setCentralWidget(_glWidget);
366+ _window->setCentralWidget(glCanvas.data());
366367
367368 restoreSizeAndPosition();
368369
369370 _window->setVisible(true);
370− _glWidget->setFocusPolicy(Qt::StrongFocus);
371− _glWidget->setFocus();
371+ glCanvas->setFocusPolicy(Qt::StrongFocus);
372+ glCanvas->setFocus();
372373
373374 // enable mouse tracking; otherwise, we only get drag events
374− _glWidget->setMouseTracking(true);
375+ glCanvas->setMouseTracking(true);
375376
376377 _toolWindow = new ToolWindow();
377378 _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
@@ -390,7 +391,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 12 unmodified lines
390391
391392 checkVersion();
392393
393− _overlays.init(_glWidget); // do this before scripts load
394+ _overlays.init(glCanvas.data()); // do this before scripts load
394395
395396 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
396397 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
@@ -439,6 +440,7 @@ void Application::aboutToQuit() { · 42 unmodified lines
439440 }
440441
441442 Application::~Application() {
443+
442444 _entities.getTree()->setSimulation(NULL);
443445 qInstallMessageHandler(NULL);
444446
@@ -480,8 +482,6 @@ Application::~Application() { · 35 unmodified lines
480482 Menu::getInstance()->deleteLater();
481483
482484 _myAvatar = NULL;
483−
484− delete _glWidget;
485485 }
486486
487487 void Application::saveSettings() {
@@ -621,7 +621,7 @@ void Application::paintGL() { · 133 unmodified lines
621621 if (OculusManager::isConnected()) {
622622 DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
623623 } else {
624− QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
624+ QSize fbSize = DependencyManager::get<GLCanvas>()->getDeviceSize() * getRenderResolutionScale();
625625 DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
626626 }
627627
@@ -1045,7 +1045,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 417 unmodified lines
10451045 if (isShifted) {
10461046 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
10471047 if (TV3DManager::isConnected()) {
1048− TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1048+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
1049+ TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
10491050 }
10501051 } else {
10511052 _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
@@ -1057,7 +1058,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines
10571058 if (isShifted) {
10581059 _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
10591060 if (TV3DManager::isConnected()) {
1060− TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1061+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
1062+ TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
10611063 }
10621064
10631065 } else {
@@ -1503,7 +1505,7 @@ void Application::idle() { · 439 unmodified lines
15031505 {
15041506 PerformanceTimer perfTimer("updateGL");
15051507 PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
1506− _glWidget->updateGL();
1508+ DependencyManager::get<GLCanvas>()->updateGL();
15071509 }
15081510 {
15091511 PerformanceTimer perfTimer("rest");
@@ -1529,13 +1531,14 @@ void Application::idle() { · 19 unmodified lines
15291531
15301532 void Application::checkBandwidthMeterClick() {
15311533 // ... to be called upon button release
1534+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
15321535 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
15331536 Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
15341537 Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) &&
15351538 glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(),
15361539 getMouseY() - getMouseDragStartedY())))
15371540 <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH
1538− && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), _glWidget->width(), _glWidget->height())) {
1541+ && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), glCanvas->width(), glCanvas->height())) {
15391542
15401543 // The bandwidth meter is visible, the click didn't get dragged too far and
15411544 // we actually hit the bandwidth meter
@@ -1564,7 +1567,8 @@ void Application::setFullscreen(bool fullscreen) { · 22 unmodified lines
15641567 }
15651568
15661569 void Application::setEnable3DTVMode(bool enable3DTVMode) {
1567− resizeGL(_glWidget->getDeviceWidth(),_glWidget->getDeviceHeight());
1570+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
1571+ resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
15681572 }
15691573
15701574 void Application::setEnableVRMode(bool enableVRMode) {
@@ -1589,7 +1593,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines
15891593 _myCamera.setHmdRotation(glm::quat());
15901594 }
15911595
1592− resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1596+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
1597+ resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
15931598 }
15941599
15951600 void Application::setRenderVoxels(bool voxelRender) {
@@ -1651,8 +1656,9 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox · 55 unmodified lines
16511656
16521657 bool Application::mouseOnScreen() const {
16531658 if (OculusManager::isConnected()) {
1654− return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() &&
1655− getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight();
1659+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
1660+ return getMouseX() >= 0 && getMouseX() <= glCanvas->getDeviceWidth() &&
1661+ getMouseY() >= 0 && getMouseY() <= glCanvas->getDeviceHeight();
16561662 }
16571663 return true;
16581664 }
@@ -1692,13 +1698,13 @@ int Application::getMouseDragStartedY() const { · 33 unmodified lines
16921698 }
16931699
16941700 FaceTracker* Application::getActiveFaceTracker() {
1695− Faceshift* faceshift = DependencyManager::get<Faceshift>();
1696− Visage* visage = DependencyManager::get<Visage>();
1697− DdeFaceTracker* dde = DependencyManager::get<DdeFaceTracker>();
1701+ Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>();
1702+ Visage::SharedPointer visage = DependencyManager::get<Visage>();
1703+ DdeFaceTracker::SharedPointer dde = DependencyManager::get<DdeFaceTracker>();
16981704
1699− return (dde->isActive() ? static_cast<FaceTracker*>(dde) :
1700− (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift) :
1701− (visage->isActive() ? static_cast<FaceTracker*>(visage) : NULL)));
1705+ return (dde->isActive() ? static_cast<FaceTracker*>(dde.data()) :
1706+ (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift.data()) :
1707+ (visage->isActive() ? static_cast<FaceTracker*>(visage.data()) : NULL)));
17021708 }
17031709
17041710 struct SendVoxelsOperationArgs {
@@ -1771,7 +1777,8 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 66 unmodified lines
17711777 QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
17721778 QString suggestedName = desktopLocation.append("/voxels.svo");
17731779
1774− QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName,
1780+ QString fileNameString = QFileDialog::getSaveFileName(DependencyManager::get<GLCanvas>().data(),
1781+ tr("Export Voxels"), suggestedName,
17751782 tr("Sparse Voxel Octree Files (*.svo)"));
17761783 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
17771784 const char* fileName = fileNameAscii.data();
@@ -2025,9 +2032,9 @@ void Application::init() { · 247 unmodified lines
20252032
20262033 _metavoxels.init();
20272034
2028− _audio.init(_glWidget);
2029−
2030− _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings);
2035+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
2036+ _audio.init(glCanvas.data());
2037+ _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings);
20312038
20322039 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
20332040 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
@@ -2040,11 +2047,12 @@ void Application::init() { · 6 unmodified lines
20402047 // save settings when avatar changes
20412048 connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
20422049
2043− // make sure our texture cache knows about window size changes
2044− DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget());
2050+ // make sure our texture cache knows about window size changes
2051+ DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data());
20452052
20462053 // initialize the GlowEffect with our widget
2047− DependencyManager::get<GlowEffect>()->init(getGLWidget(), Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
2054+ DependencyManager::get<GlowEffect>()->init(glCanvas.data(),
2055+ Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
20482056 }
20492057
20502058 void Application::closeMirrorView() {
@@ -2112,7 +2120,7 @@ void Application::updateMouseRay() { · 61 unmodified lines
21122120 void Application::updateFaceshift() {
21132121 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
21142122 PerformanceWarning warn(showWarnings, "Application::updateFaceshift()");
2115− Faceshift* faceshift = DependencyManager::get<Faceshift>();
2123+ Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>();
21162124 // Update faceshift
21172125 faceshift->update();
21182126
@@ -2916,8 +2924,9 @@ void Application::updateShadowMap() { · 797 unmodified lines
29162924 }
29172925
29182926 fbo->release();
2919−
2920− glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
2927+
2928+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
2929+ glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
29212930 }
29222931
29232932 const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
@@ -2944,6 +2953,18 @@ bool Application::shouldRenderMesh(float largestDimension, float distanceToCamer · 20 unmodified lines
29442953 return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
29452954 }
29462955
2956+float Application::getSizeScale() const {
2957+ return Menu::getInstance()->getVoxelSizeScale();
2958+}
2959+
2960+int Application::getBoundaryLevelAdjust() const {
2961+ return Menu::getInstance()->getBoundaryLevelAdjust();
2962+}
2963+
2964+PickRay Application::computePickRay(float x, float y) {
2965+ return getCamera()->computePickRay(x, y);
2966+}
2967+
29472968 QImage Application::renderAvatarBillboard() {
29482969 DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
29492970
@@ -2951,7 +2972,9 @@ QImage Application::renderAvatarBillboard() { · 1 unmodified line
29512972 Glower glower;
29522973
29532974 const int BILLBOARD_SIZE = 64;
2954− renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true);
2975+ renderRearViewMirror(QRect(0, DependencyManager::get<GLCanvas>()->getDeviceHeight() - BILLBOARD_SIZE,
2976+ BILLBOARD_SIZE, BILLBOARD_SIZE),
2977+ true);
29552978
29562979 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
29572980 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
@@ -3254,8 +3277,9 @@ bool Application::getCascadeShadowsEnabled() { · 296 unmodified lines
32543277 }
32553278
32563279 glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
3257− float horizontalScale = _glWidget->getDeviceWidth() / 2.0f;
3258− float verticalScale = _glWidget->getDeviceHeight() / 2.0f;
3280+ GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
3281+ float horizontalScale = glCanvas->getDeviceWidth() / 2.0f;
3282+ float verticalScale = glCanvas->getDeviceHeight() / 2.0f;
32593283
32603284 // -1,-1 is 0,windowHeight
32613285 // 1,1 is windowWidth,0
@@ -3274,7 +3298,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 12 unmodified lines
32743298 // -1,-1 1,-1
32753299
32763300 glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale,
3277− ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight());
3301+ ((projectedPoint.y + 1.0) * -verticalScale) + glCanvas->getDeviceHeight());
32783302
32793303 return screenPoint;
32803304 }
@@ -3585,7 +3609,7 @@ void Application::resetSensors() { · 304 unmodified lines
35853609 QScreen* currentScreen = _window->windowHandle()->screen();
35863610 QWindow* mainWindow = _window->windowHandle();
35873611 QPoint windowCenter = mainWindow->geometry().center();
3588− _glWidget->cursor().setPos(currentScreen, windowCenter);
3612+ DependencyManager::get<GLCanvas>()->cursor().setPos(currentScreen, windowCenter);
35893613
35903614 _myAvatar->reset();
35913615
@@ -4021,7 +4045,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 429 unmodified lines
40214045 scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
40224046 scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
40234047 scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
4024− scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
4048+ scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
40254049 scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
40264050 scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
40274051 scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
@@ -4266,7 +4290,8 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio · 238 unmodified lines
42664290
42674291 void Application::loadDialog() {
42684292
4269− QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"),
4293+ QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get<GLCanvas>().data(),
4294+ tr("Open Script"),
42704295 getPreviousScriptLocation(),
42714296 tr("JavaScript Files (*.js)"));
42724297 if (!fileNameString.isEmpty()) {
@@ -4302,7 +4327,7 @@ void Application::loadScriptURLDialog() { · 29 unmodified lines
43024327
43034328 void Application::toggleLogDialog() {
43044329 if (! _logDialog) {
4305− _logDialog = new LogDialog(_glWidget, getLogger());
4330+ _logDialog = new LogDialog(DependencyManager::get<GLCanvas>().data(), getLogger());
43064331 }
43074332
43084333 if (_logDialog->isVisible()) {
@@ -4362,7 +4387,7 @@ void Application::parseVersionXml() { · 53 unmodified lines
43624387 }
43634388
43644389 if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
4365− new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl);
4390+ new UpdateDialog(DependencyManager::get<GLCanvas>().data(), releaseNotes, latestVersion, downloadUrl);
43664391 }
43674392 sender->deleteLater();
43684393 }
@@ -4395,7 +4420,7 @@ void Application::takeSnapshot() { · 26 unmodified lines
43954420 }
43964421
43974422 if (!_snapshotShareDialog) {
4398− _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);
4423+ _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>().data());
43994424 }
44004425 _snapshotShareDialog->show();
44014426 }

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