History

Merge branch 'master' of https://github.com/worklist/hifi into modelserver

ZappoMan committed 12 years ago

Commit 58c852d2 parents f993f98 19b76e320 files · +602 −309Browse files

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

Unified · Split

interface/src/Application.cpp+49−52
@@ -30,7 +30,6 @@ · 29 unmodified lines
30#include <QImage>30#include <QImage>
31#include <QInputDialog>31#include <QInputDialog>
32#include <QKeyEvent>32#include <QKeyEvent>
33#include <QMainWindow>
34#include <QMenuBar>33#include <QMenuBar>
35#include <QMouseEvent>34#include <QMouseEvent>
36#include <QNetworkAccessManager>35#include <QNetworkAccessManager>
@@ -132,7 +131,7 @@ QString& Application::resourcesPath() { · 95 unmodified lines
132 131
133Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :132Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
134 QApplication(argc, argv),133 QApplication(argc, argv),
135 _window(new QMainWindow(desktop())),134 _window(new MainWindow(desktop())),
136 _glWidget(new GLCanvas()),135 _glWidget(new GLCanvas()),
137 _nodeThread(new QThread(this)),136 _nodeThread(new QThread(this)),
138 _datagramProcessor(),137 _datagramProcessor(),
@@ -164,11 +163,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 25 unmodified lines
164 _packetsPerSecond(0),163 _packetsPerSecond(0),
165 _bytesPerSecond(0),164 _bytesPerSecond(0),
166 _previousScriptLocation(),165 _previousScriptLocation(),
167 _logger(new FileLogger(this))166 _logger(new FileLogger(this)),
167 _runningScriptsWidget(new RunningScriptsWidget(_window)),
168 _runningScriptsWidgetWasVisible(false)
168{169{
169 // init GnuTLS for DTLS with domain-servers170 // init GnuTLS for DTLS with domain-servers
170 DTLSClientSession::globalInit();171 DTLSClientSession::globalInit();
171 172
172 // read the ApplicationInfo.ini file for Name/Version/Domain information173 // read the ApplicationInfo.ini file for Name/Version/Domain information
173 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);174 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
174 175
@@ -334,7 +335,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 159 unmodified lines
334 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());335 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
335 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);336 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
336 337
337 _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget());
338 _runningScriptsWidget->setRunningScripts(getRunningScripts());338 _runningScriptsWidget->setRunningScripts(getRunningScripts());
339 connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);339 connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
340 340
@@ -345,16 +345,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 4 unmodified lines
345 // clear the scripts, and set out script to our default scripts345 // clear the scripts, and set out script to our default scripts
346 clearScriptsBeforeRunning();346 clearScriptsBeforeRunning();
347 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");347 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");
348 348
349 QMutexLocker locker(&_settingsMutex);349 QMutexLocker locker(&_settingsMutex);
350 _settings->setValue("firstRun",QVariant(false));350 _settings->setValue("firstRun",QVariant(false));
351 } else {351 } else {
352 // do this as late as possible so that all required subsystems are inialized352 // do this as late as possible so that all required subsystems are inialized
353 loadScripts();353 loadScripts();
354 354
355 QMutexLocker locker(&_settingsMutex);355 QMutexLocker locker(&_settingsMutex);
356 _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();356 _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
357 }357 }
358
359 connect(_window, &MainWindow::windowGeometryChanged,
360 _runningScriptsWidget, &RunningScriptsWidget::setBoundary);
361
362 //When -url in command line, teleport to location
363 urlGoTo(argc, constArgv);
358}364}
359 365
360Application::~Application() {366Application::~Application() {
@@ -363,11 +369,11 @@ Application::~Application() { · 2 unmodified lines
363 369
364 // make sure we don't call the idle timer any more370 // make sure we don't call the idle timer any more
365 delete idleTimer;371 delete idleTimer;
366 372
367 _sharedVoxelSystem.changeTree(new VoxelTree);373 _sharedVoxelSystem.changeTree(new VoxelTree);
368 374
369 saveSettings();375 saveSettings();
370 376
371 delete _voxelImporter;377 delete _voxelImporter;
372 378
373 // let the avatar mixer know we're out379 // let the avatar mixer know we're out
@@ -400,14 +406,14 @@ Application::~Application() { · 26 unmodified lines
400 delete _glWidget;406 delete _glWidget;
401 407
402 AccountManager::getInstance().destroy();408 AccountManager::getInstance().destroy();
403 409
404 DTLSClientSession::globalDeinit();410 DTLSClientSession::globalDeinit();
405}411}
406 412
407void Application::saveSettings() {413void Application::saveSettings() {
408 Menu::getInstance()->saveSettings();414 Menu::getInstance()->saveSettings();
409 _rearMirrorTools->saveSettings(_settings);415 _rearMirrorTools->saveSettings(_settings);
410 416
411 if (_voxelImporter) {417 if (_voxelImporter) {
412 _voxelImporter->saveSettings(_settings);418 _voxelImporter->saveSettings(_settings);
413 }419 }
@@ -574,7 +580,7 @@ void Application::paintGL() { · 160 unmodified lines
574 pushback = qMin(pushback, MAX_PUSHBACK * _myAvatar->getScale());580 pushback = qMin(pushback, MAX_PUSHBACK * _myAvatar->getScale());
575 const float BASE_PUSHBACK_FOCAL_LENGTH = 0.5f;581 const float BASE_PUSHBACK_FOCAL_LENGTH = 0.5f;
576 pushbackFocalLength = BASE_PUSHBACK_FOCAL_LENGTH * _myAvatar->getScale();582 pushbackFocalLength = BASE_PUSHBACK_FOCAL_LENGTH * _myAvatar->getScale();
577 583
578 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {584 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
579 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing585 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
580 _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition());586 _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition());
@@ -587,7 +593,7 @@ void Application::paintGL() { · 6 unmodified lines
587 _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale());593 _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale());
588 _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0));594 _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0));
589 _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));595 _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
590 596
591 // if the head would intersect the near clip plane, we must push the camera out597 // if the head would intersect the near clip plane, we must push the camera out
592 glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) *598 glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) *
593 (eyePosition - _myCamera.getTargetPosition());599 (eyePosition - _myCamera.getTargetPosition());
@@ -596,7 +602,7 @@ void Application::paintGL() { · 2 unmodified lines
596 pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance();602 pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance();
597 pushbackFocalLength = _myCamera.getDistance();603 pushbackFocalLength = _myCamera.getDistance();
598 }604 }
599 605
600 // handle pushback, if any606 // handle pushback, if any
601 if (pushbackFocalLength > 0.0f) {607 if (pushbackFocalLength > 0.0f) {
602 const float PUSHBACK_DECAY = 0.5f;608 const float PUSHBACK_DECAY = 0.5f;
@@ -1277,7 +1283,7 @@ void Application::timer() { · 674 unmodified lines
1277 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {1283 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
1278 sendPingPackets();1284 sendPingPackets();
1279 }1285 }
1280 1286
1281 float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f;1287 float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f;
1282 1288
1283 _fps = (float)_frameCount / diffTime;1289 _fps = (float)_frameCount / diffTime;
@@ -1678,7 +1684,7 @@ void Application::init() { · 394 unmodified lines
1678 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));1684 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
1679 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));1685 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
1680 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));1686 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
1681 1687
1682 // set up our audio reflector1688 // set up our audio reflector
1683 _audioReflector.setMyAvatar(getAvatar());1689 _audioReflector.setMyAvatar(getAvatar());
1684 _audioReflector.setVoxels(_voxels.getTree());1690 _audioReflector.setVoxels(_voxels.getTree());
@@ -1687,7 +1693,7 @@ void Application::init() { · 2 unmodified lines
1687 1693
1688 connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection);1694 connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection);
1689 connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection);1695 connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection);
1690 connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, 1696 connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
1691 &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);1697 &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
1692 1698
1693 // save settings when avatar changes1699 // save settings when avatar changes
@@ -1821,7 +1827,7 @@ void Application::updateMyAvatarLookAtPosition() { · 127 unmodified lines
1821 if (tracker) {1827 if (tracker) {
1822 float eyePitch = tracker->getEstimatedEyePitch();1828 float eyePitch = tracker->getEstimatedEyePitch();
1823 float eyeYaw = tracker->getEstimatedEyeYaw();1829 float eyeYaw = tracker->getEstimatedEyeYaw();
1824 1830
1825 // deflect using Faceshift gaze data1831 // deflect using Faceshift gaze data
1826 glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition();1832 glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition();
1827 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;1833 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
@@ -1908,7 +1914,7 @@ void Application::updateCamera(float deltaTime) { · 80 unmodified lines
1908 PerformanceWarning warn(showWarnings, "Application::updateCamera()");1914 PerformanceWarning warn(showWarnings, "Application::updateCamera()");
1909 1915
1910 if (!OculusManager::isConnected() && !TV3DManager::isConnected() &&1916 if (!OculusManager::isConnected() && !TV3DManager::isConnected() &&
1911 Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { 1917 Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
1912 FaceTracker* tracker = getActiveFaceTracker();1918 FaceTracker* tracker = getActiveFaceTracker();
1913 if (tracker) {1919 if (tracker) {
1914 const float EYE_OFFSET_SCALE = 0.025f;1920 const float EYE_OFFSET_SCALE = 0.025f;
@@ -2464,7 +2470,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 549 unmodified lines
2464 2470
2465 // disable specular lighting for ground and voxels2471 // disable specular lighting for ground and voxels
2466 glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR);2472 glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR);
2467 2473
2468 // draw the audio reflector overlay2474 // draw the audio reflector overlay
2469 _audioReflector.render();2475 _audioReflector.render();
2470 2476
@@ -2622,7 +2628,7 @@ void Application::displayOverlay() { · 151 unmodified lines
2622 const float LOG2_LOUDNESS_FLOOR = 11.f;2628 const float LOG2_LOUDNESS_FLOOR = 11.f;
2623 float audioLevel = 0.f;2629 float audioLevel = 0.f;
2624 float loudness = _audio.getLastInputLoudness() + 1.f;2630 float loudness = _audio.getLastInputLoudness() + 1.f;
2625 2631
2626 _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness;2632 _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness;
2627 float log2loudness = log(_trailingAudioLoudness) / LOG2;2633 float log2loudness = log(_trailingAudioLoudness) / LOG2;
2628 2634
@@ -2634,9 +2640,8 @@ void Application::displayOverlay() { · 5 unmodified lines
2634 if (audioLevel > AUDIO_METER_SCALE_WIDTH) {2640 if (audioLevel > AUDIO_METER_SCALE_WIDTH) {
2635 audioLevel = AUDIO_METER_SCALE_WIDTH;2641 audioLevel = AUDIO_METER_SCALE_WIDTH;
2636 }2642 }
2637
2638 bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));2643 bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));
2639 2644
2640 if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {2645 if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
2641 const float MAX_MAGNITUDE = 0.7f;2646 const float MAX_MAGNITUDE = 0.7f;
2642 float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);2647 float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
@@ -3307,7 +3312,7 @@ void Application::loadScripts() { · 664 unmodified lines
3307 loadScript(string);3312 loadScript(string);
3308 }3313 }
3309 }3314 }
3310 3315
3311 QMutexLocker locker(&_settingsMutex);3316 QMutexLocker locker(&_settingsMutex);
3312 _settings->endArray();3317 _settings->endArray();
3313}3318}
@@ -3362,31 +3367,23 @@ void Application::reloadAllScripts() { · 48 unmodified lines
3362 }3367 }
3363}3368}
3364 3369
3365void Application::toggleRunningScriptsWidget()3370void Application::manageRunningScriptsWidgetVisibility(bool shown) {
3366{3371 if (_runningScriptsWidgetWasVisible && shown) {
3367 if (!_runningScriptsWidget->toggleViewAction()->isChecked()) {3372 _runningScriptsWidget->show();
3368 _runningScriptsWidget->move(_window->geometry().topLeft().x(), _window->geometry().topLeft().y());3373 } else if (_runningScriptsWidgetWasVisible && !shown) {
3369 _runningScriptsWidget->resize(0, _window->height());3374 _runningScriptsWidget->hide();
3370 _runningScriptsWidget->toggleViewAction()->trigger();3375 }
3371 _runningScriptsWidget->grabKeyboard();3376}
3372
3373 QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget);
3374 slideAnimation->setStartValue(_runningScriptsWidget->geometry());
3375 slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(),
3376 310, _runningScriptsWidget->height()));
3377 slideAnimation->setDuration(250);
3378 slideAnimation->start(QAbstractAnimation::DeleteWhenStopped);
3379 } else {
3380 _runningScriptsWidget->releaseKeyboard();
3381
3382 QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget);
3383 slideAnimation->setStartValue(_runningScriptsWidget->geometry());
3384 slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(),
3385 0, _runningScriptsWidget->height()));
3386 slideAnimation->setDuration(250);
3387 slideAnimation->start(QAbstractAnimation::DeleteWhenStopped);
3388 3377
3389 QTimer::singleShot(260, _runningScriptsWidget->toggleViewAction(), SLOT(trigger()));3378void Application::toggleRunningScriptsWidget() {
3379 if (_runningScriptsWidgetWasVisible) {
3380 _runningScriptsWidget->hide();
3381 _runningScriptsWidgetWasVisible = false;
3382 } else {
3383 _runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(),
3384 _window->size()));
3385 _runningScriptsWidget->show();
3386 _runningScriptsWidgetWasVisible = true;
3390 }3387 }
3391}3388}
3392 3389
@@ -3396,7 +3393,7 @@ void Application::uploadFST(bool isHead) { · 3 unmodified lines
3396 thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit()));3393 thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit()));
3397 thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));3394 thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));
3398 uploader->connect(thread, SIGNAL(started()), SLOT(send()));3395 uploader->connect(thread, SIGNAL(started()), SLOT(send()));
3399 3396
3400 thread->start();3397 thread->start();
3401}3398}
3402 3399
@@ -3494,7 +3491,7 @@ void Application::loadDialog() { · 91 unmodified lines
3494 _previousScriptLocation = fileNameString;3491 _previousScriptLocation = fileNameString;
3495 QMutexLocker locker(&_settingsMutex);3492 QMutexLocker locker(&_settingsMutex);
3496 _settings->setValue("LastScriptLocation", _previousScriptLocation);3493 _settings->setValue("LastScriptLocation", _previousScriptLocation);
3497 3494
3498 loadScript(fileNameString);3495 loadScript(fileNameString);
3499 }3496 }
3500}3497}
@@ -3631,7 +3628,7 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { · 130 unmodified lines
3631 QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();3628 QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
3632 3629
3633 Menu::goToDomain(domain);3630 Menu::goToDomain(domain);
3634 3631
3635 // goto either @user, #place, or x-xx,y-yy,z-zz3632 // goto either @user, #place, or x-xx,y-yy,z-zz
3636 // style co-ordinate.3633 // style co-ordinate.
3637 Menu::goTo(destination);3634 Menu::goTo(destination);

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