From 112ae2bb893c465375e8c7335c3022eab3bc2ec1 Mon Sep 17 00:00:00 2001 From: stojce Date: Fri, 11 Oct 2013 20:25:58 +0200 Subject: [PATCH 1/4] #19437 Adjust bandwith meter to be fixed width, not rescaling --- interface/src/BandwidthMeter.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/interface/src/BandwidthMeter.cpp b/interface/src/BandwidthMeter.cpp index 1c1fa62297..94fb06a496 100644 --- a/interface/src/BandwidthMeter.cpp +++ b/interface/src/BandwidthMeter.cpp @@ -13,7 +13,7 @@ namespace { // .cpp-local - int const AREA_WIDTH = -400; // Width of the area used. Aligned to the right when negative. + int const AREA_WIDTH = -280; // Width of the area used. Aligned to the right when negative. int const AREA_HEIGHT = 40; // Height of the area used. Aligned to the bottom when negative. int const BORDER_DISTANCE_HORIZ = -20; // Distance to edge of screen (use negative value when width is negative). int const BORDER_DISTANCE_VERT = 40; // Distance to edge of screen (use negative value when height is negative). @@ -33,6 +33,8 @@ namespace { // .cpp-local double const UNIT_SCALE = 8000.0 / (1024.0 * 1024.0); // Bytes/ms -> Mbps int const INITIAL_SCALE_MAXIMUM_INDEX = 250; // / 9: exponent, % 9: mantissa - 2, 0 o--o 2 * 10^-10 + int const MIN_METER_SCALE = 10; // 10Mbps + int const NUMBER_OF_MARKERS = 10; } BandwidthMeter::ChannelInfo BandwidthMeter::_CHANNELS[] = { @@ -182,7 +184,7 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { break; } if (totalMax < scaleMax * 0.5) { - _scaleMaxIndex = glm::max(0, _scaleMaxIndex-1); + _scaleMaxIndex = glm::max(0, _scaleMaxIndex - 1); commit = true; } else if (totalMax > scaleMax) { _scaleMaxIndex += 1; @@ -190,10 +192,15 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { } } while (commit); + step = scaleMax / NUMBER_OF_MARKERS; + if (scaleMax < MIN_METER_SCALE) { + scaleMax = MIN_METER_SCALE; + } + // Render scale indicators setColorRGBA(COLOR_INDICATOR); - for (int j = int((scaleMax + step - 0.000001) / step); --j > 0;) { - renderVerticalLine(int(barWidth * j * step / scaleMax), 0, h); + for (int j = NUMBER_OF_MARKERS; --j > 0;) { + renderVerticalLine(int(barWidth * j / NUMBER_OF_MARKERS), 0, h); } // Render bars @@ -220,11 +227,11 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { // Render numbers char fmtBuf[8]; setColorRGBA(COLOR_TEXT); - sprintf(fmtBuf, "%0.2f", totalIn); + sprintf(fmtBuf, "%0.1f", totalIn); _textRenderer.draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, PADDING_HORIZ_VALUE), textYupperLine, fmtBuf); - sprintf(fmtBuf, "%0.2f", totalOut); + sprintf(fmtBuf, "%0.1f", totalOut); _textRenderer.draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, PADDING_HORIZ_VALUE), textYlowerLine, fmtBuf); From e43758a1155e2f68208958b8bd7faae2a3bd0b7c Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 18 Oct 2013 14:36:57 -0700 Subject: [PATCH 2/4] Faceshift fail to connect only notifies log once --- interface/src/devices/Faceshift.cpp | 16 +++++++++++----- interface/src/devices/Faceshift.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index 1798acba46..733b1e639d 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -20,6 +20,7 @@ const quint16 FACESHIFT_PORT = 33433; Faceshift::Faceshift() : _tcpEnabled(false), + _tcpRetryCount(0), _lastTrackingStateReceived(0), _eyeGazeLeftPitch(0.0f), _eyeGazeLeftYaw(0.0f), @@ -88,7 +89,9 @@ void Faceshift::setTCPEnabled(bool enabled) { void Faceshift::connectSocket() { if (_tcpEnabled) { - qDebug("Faceshift: Connecting...\n"); + if (!_tcpRetryCount) { + qDebug("Faceshift: Connecting...\n"); + } _tcpSocket.connectToHost("localhost", FACESHIFT_PORT); _tracking = false; @@ -105,11 +108,14 @@ void Faceshift::noteConnected() { } void Faceshift::noteError(QAbstractSocket::SocketError error) { - qDebug() << "Faceshift: " << _tcpSocket.errorString() << "\n"; - - // reconnect after a delay + if (!_tcpRetryCount) { + // Only spam log with fail to connect the first time, so that we can keep waiting for server + qDebug() << "Faceshift: " << _tcpSocket.errorString() << "\n"; + } + // retry connection after a 2 second delay if (_tcpEnabled) { - QTimer::singleShot(1000, this, SLOT(connectSocket())); + _tcpRetryCount++; + QTimer::singleShot(2000, this, SLOT(connectSocket())); } } diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index 22f474192d..3cda28a3a0 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -85,6 +85,7 @@ private: QUdpSocket _udpSocket; fs::fsBinaryStream _stream; bool _tcpEnabled; + int _tcpRetryCount; bool _tracking; uint64_t _lastTrackingStateReceived; From bdfc7fdb64a8667a87672315484b28e5c25ba49b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 18 Oct 2013 16:07:05 -0700 Subject: [PATCH 3/4] fix for preferences bug on 5.1.1 --- interface/src/Menu.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index f3bae87d4c..b1e65962c0 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -72,12 +72,6 @@ Menu::Menu() : 0, this, SLOT(login()))); - - (addActionToQMenuAndActionHash(fileMenu, - MenuOption::Preferences, - Qt::CTRL | Qt::Key_Comma, - this, - SLOT(editPreferences())))->setMenuRole(QAction::PreferencesRole); addDisabledActionAndSeparator(fileMenu, "Voxels"); addActionToQMenuAndActionHash(fileMenu, MenuOption::ExportVoxels, Qt::CTRL | Qt::Key_E, appInstance, SLOT(exportVoxels())); @@ -121,6 +115,15 @@ Menu::Menu() : SLOT(quit())))->setMenuRole(QAction::QuitRole); QMenu* editMenu = addMenu("Edit"); + + addActionToQMenuAndActionHash(editMenu, + MenuOption::Preferences, + Qt::CTRL | Qt::Key_Comma, + this, + SLOT(editPreferences())); + + addDisabledActionAndSeparator(editMenu, "Voxels"); + addActionToQMenuAndActionHash(editMenu, MenuOption::CutVoxels, Qt::CTRL | Qt::Key_X, appInstance, SLOT(cutVoxels())); addActionToQMenuAndActionHash(editMenu, MenuOption::CopyVoxels, Qt::CTRL | Qt::Key_C, appInstance, SLOT(copyVoxels())); addActionToQMenuAndActionHash(editMenu, MenuOption::PasteVoxels, Qt::CTRL | Qt::Key_V, appInstance, SLOT(pasteVoxels())); From b6c4599a557f0cea91fc994ed796bd742b0ea50d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 18 Oct 2013 16:10:03 -0700 Subject: [PATCH 4/4] cleaup some unecessary defaults in Menu --- interface/src/Menu.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index b1e65962c0..bfafd873ef 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -60,11 +60,11 @@ Menu::Menu() : QMenu* fileMenu = addMenu("File"); #ifdef Q_OS_MAC - (addActionToQMenuAndActionHash(fileMenu, - MenuOption::AboutApp, - 0, - this, - SLOT(aboutApp())))->setMenuRole(QAction::AboutRole); + addActionToQMenuAndActionHash(fileMenu, + MenuOption::AboutApp, + 0, + this, + SLOT(aboutApp())); #endif (addActionToQMenuAndActionHash(fileMenu, @@ -108,11 +108,11 @@ Menu::Menu() : addActionToQMenuAndActionHash(fileMenu, MenuOption::Pair, 0, PairingHandler::getInstance(), SLOT(sendPairRequest())); addCheckableActionToQMenuAndActionHash(fileMenu, MenuOption::TransmitterDrive, 0, true); - (addActionToQMenuAndActionHash(fileMenu, - MenuOption::Quit, - Qt::CTRL | Qt::Key_Q, - appInstance, - SLOT(quit())))->setMenuRole(QAction::QuitRole); + addActionToQMenuAndActionHash(fileMenu, + MenuOption::Quit, + Qt::CTRL | Qt::Key_Q, + appInstance, + SLOT(quit())); QMenu* editMenu = addMenu("Edit");