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

This commit is contained in:
Stephen Birarda 2013-10-21 09:33:14 -07:00
commit 5fa5e7aa78
4 changed files with 44 additions and 27 deletions

View file

@ -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);

View file

@ -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,
@ -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()));
@ -114,13 +108,22 @@ 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");
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()));

View file

@ -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()));
}
}

View file

@ -85,6 +85,7 @@ private:
QUdpSocket _udpSocket;
fs::fsBinaryStream _stream;
bool _tcpEnabled;
int _tcpRetryCount;
bool _tracking;
uint64_t _lastTrackingStateReceived;