initial decoupling of menu from Application

This commit is contained in:
Stephen Birarda 2013-08-15 10:46:51 -07:00
parent 23152abce7
commit 46b064b7d6
15 changed files with 1169 additions and 976 deletions

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,7 @@
#include "BandwidthMeter.h"
#include "Camera.h"
#include "Environment.h"
#include "GLCanvas.h"
#include "PacketHeaders.h"
#include "ParticleSystem.h"
#include "SerialInterface.h"
@ -104,21 +105,22 @@ public:
Camera* getCamera() { return &_myCamera; }
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
VoxelSystem* getVoxels() { return &_voxels; }
QSettings* getSettings() { return _settings; }
Environment* getEnvironment() { return &_environment; }
SerialInterface* getSerialHeadSensor() { return &_serialHeadSensor; }
Webcam* getWebcam() { return &_webcam; }
QGLWidget* getGLWidget() { return _glWidget; }
BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; }
bool shouldEchoAudio() { return _echoAudioMode->isChecked(); }
bool shouldLowPassFilter() { return _shouldLowPassFilter->isChecked(); }
bool shouldDynamicallySetJitterBuffer() { return _audioJitterBufferSamples == 0; }
QSettings* getSettings() { return _settings; }
Swatch* getSwatch() { return &_swatch; }
QMainWindow* getWindow() { return _window; }
QNetworkAccessManager* getNetworkAccessManager() { return _networkAccessManager; }
GeometryCache* getGeometryCache() { return &_geometryCache; }
TextureCache* getTextureCache() { return &_textureCache; }
void resetSongMixMenuItem();
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
const char* nodeTypes, int numNodeTypes);
void setupWorldLight(Camera& whichCamera);
virtual void nodeAdded(Node* node);
@ -133,21 +135,11 @@ private slots:
void idle();
void terminate();
void bandwidthDetails();
void editPreferences();
void bandwidthDetailsClosed();
void voxelStatsDetails();
void voxelStatsDetailsClosed();
void pair();
void setRenderMirrored(bool mirrored);
void setNoise(bool noise);
void setFullscreen(bool fullscreen);
void setRenderFirstPerson(bool firstPerson);
void setRenderThirdPerson(bool thirdPerson);
void increaseAvatarSize();
void decreaseAvatarSize();
void resetAvatarSize();
@ -156,7 +148,6 @@ private slots:
void renderLineToTouchedVoxel();
void setFrustumOffset(bool frustumOffset);
void cycleFrustumRenderMode();
void setRenderWarnings(bool renderWarnings);
void setRenderVoxels(bool renderVoxels);
@ -175,15 +166,9 @@ private slots:
void disableLowResMoving(bool disableLowResMoving);
void disableDeltaSending(bool disableDeltaSending);
void disableOcclusionCulling(bool disableOcclusionCulling);
void updateVoxelModeActions();
void decreaseVoxelSize();
void increaseVoxelSize();
void resetSwatchColors();
void chooseVoxelPaintColor();
void loadSettings(QSettings* set = NULL);
void saveSettings(QSettings* set = NULL);
void importSettings();
void exportSettings();
void exportVoxels();
void importVoxels();
void importVoxelsToClipboard();
@ -194,9 +179,6 @@ private slots:
void setListenModeNormal();
void setListenModePoint();
void setListenModeSingleSource();
void toggleMixedSong();
void toggleWantCollisionsOn();
void renderCoverageMap();
void renderCoverageMapsRecursively(CoverageMap* map);
@ -212,13 +194,9 @@ private slots:
private:
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
const char* nodeTypes, int numNodeTypes);
static void sendVoxelServerAddScene();
static bool sendVoxelsOperation(VoxelNode* node, void* extraData);
static void sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail);
static void sendAvatarVoxelURLMessage(const QUrl& url);
static void processAvatarVoxelURLMessage(unsigned char* packetData, size_t dataBytes);
static void processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes);
static void sendPingPackets();
@ -258,8 +236,6 @@ private:
void updateCursor();
QAction* checkedVoxelModeAction() const;
static void attachNewHeadToNode(Node *newNode);
static void* networkReceive(void* args); // network receive thread
@ -267,69 +243,13 @@ private:
void processVoxelPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength);
void queueVoxelPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength);
// methodes handling menu settings
typedef void(*settingsAction)(QSettings*, QAction*);
static void loadAction(QSettings* set, QAction* action);
static void saveAction(QSettings* set, QAction* action);
void scanMenuBar(settingsAction modifySetting, QSettings* set);
void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set);
QMainWindow* _window;
QGLWidget* _glWidget;
QAction* _lookingInMirror; // Are we currently rendering one's own head as if in mirror?
QAction* _echoAudioMode; // Are we asking the mixer to echo back our audio?
QAction* _shouldLowPassFilter; // Use test lowpass filter
QAction* _gyroLook; // Whether to allow the gyro data from head to move your view
QAction* _renderAvatarBalls; // Switch between voxels and joints/balls for avatar render
QAction* _showHeadMouse; // Whether the have the mouse near edge of screen move your view
QAction* _transmitterDrives; // Whether to have Transmitter data move/steer the Avatar
QAction* _gravityUse; // Whether gravity is on or not
QAction* _testPing; // Whether to display ping or not
QAction* _renderVoxels; // Whether to render voxels
QAction* _renderVoxelTextures; // Whether to render noise textures on voxels
QAction* _renderStarsOn; // Whether to display the stars
QAction* _renderAtmosphereOn; // Whether to display the atmosphere
QAction* _renderGroundPlaneOn; // Whether to display the ground plane
QAction* _renderAvatarsOn; // Whether to render avatars
QAction* _renderStatsOn; // Whether to show onscreen text overlay with stats
QAction* _renderFrameTimerOn; // Whether to show onscreen text overlay with stats
QAction* _renderLookatOn; // Whether to show lookat vectors from avatar eyes if looking at something
QAction* _renderLookatIndicatorOn;
QAction* _renderParticleSystemOn;
QAction* _manualFirstPerson; // Whether to force first-person mode
QAction* _manualThirdPerson; // Whether to force third-person mode
QAction* _logOn; // Whether to show on-screen log
QAction* _oscilloscopeOn; // Whether to show the oscilloscope
QAction* _bandwidthDisplayOn; // Whether to show on-screen bandwidth bars
QActionGroup* _voxelModeActions; // The group of voxel edit mode actions
QAction* _addVoxelMode; // Whether add voxel mode is enabled
QAction* _deleteVoxelMode; // Whether delete voxel mode is enabled
QAction* _colorVoxelMode; // Whether color voxel mode is enabled
QAction* _selectVoxelMode; // Whether select voxel mode is enabled
QAction* _eyedropperMode; // Whether voxel color eyedropper mode is enabled
QAction* _voxelPaintColor; // The color with which to paint voxels
QAction* _destructiveAddVoxel; // when doing voxel editing do we want them to be destructive
QAction* _frustumOn; // Whether or not to display the debug view frustum
QAction* _fullScreenMode; // whether we are in full screen mode
QAction* _frustumRenderModeAction;
QAction* _settingsAutosave; // Whether settings are saved automatically
QAction* _rawAudioMicrophoneMix; // Mixing of a RAW audio file with microphone stream for rave gloves
QAction* _noise;
QAction* _occlusionCulling;
QAction* _wantCollisionsOn;
QAction* _renderPipelineWarnings;
QAction* _renderCoverageMapV2;
QAction* _renderCoverageMap;
QAction* _simulateLeapHand; // When there's no Leap, use this to pretend there is one and feed fake hand data
QAction* _testRaveGlove; // Test fancy sparkle-rave-glove mode
QAction* _followMode;
BandwidthMeter _bandwidthMeter;
BandwidthDialog* _bandwidthDialog;
VoxelStatsDialog* _voxelStatsDialog;
SerialInterface _serialHeadSensor;
@ -358,16 +278,6 @@ private:
bool _wantToKillLocalVoxels;
ViewFrustum _viewFrustum; // current state of view frustum, perspective, orientation, etc.
enum FrustumDrawMode { FRUSTUM_DRAW_MODE_ALL, FRUSTUM_DRAW_MODE_VECTORS, FRUSTUM_DRAW_MODE_PLANES,
FRUSTUM_DRAW_MODE_NEAR_PLANE, FRUSTUM_DRAW_MODE_FAR_PLANE, FRUSTUM_DRAW_MODE_KEYHOLE, FRUSTUM_DRAW_MODE_COUNT };
FrustumDrawMode _frustumDrawingMode;
float _viewFrustumOffsetYaw; // the following variables control yaw, pitch, roll and distance form regular
float _viewFrustumOffsetPitch; // camera to the offset camera
float _viewFrustumOffsetRoll;
float _viewFrustumOffsetDistance;
float _viewFrustumOffsetUp;
Oscilloscope _audioScope;
@ -383,11 +293,6 @@ private:
Environment _environment;
int _headMouseX, _headMouseY;
float _gyroCameraSensitivity;
int _audioJitterBufferSamples; // Number of extra samples to wait before starting audio playback
float _fieldOfView; // In Degrees, doesn't apply to HMD like Oculus
HandControl _handControl;

View file

@ -23,6 +23,7 @@
#include "Application.h"
#include "Audio.h"
#include "Menu.h"
#include "Util.h"
// Uncomment the following definition to test audio device latency by copying output to input
@ -112,7 +113,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte
unsigned char dataPacket[MAX_PACKET_SIZE];
PACKET_TYPE packetType = (Application::getInstance()->shouldEchoAudio())
PACKET_TYPE packetType = Menu::getInstance()->isOptionChecked(MenuOption::EchoAudio)
? PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO
: PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO;
@ -153,38 +154,6 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
memcpy(currentPacketPtr, &headOrientation, sizeof(headOrientation));
currentPacketPtr += sizeof(headOrientation);
// check if we have a song to add to our audio
if (_songFileBytes > 0 && _songFileStream->tellg() != -1) {
// iterate over BUFFER_LENGTH_SAMPLES_PER_CHANNEL from the song file and add that to our audio
for (int i = 0; i < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; i++) {
int16_t songSample = 0;
_songFileStream->read((char*) &songSample, sizeof(songSample));
// attenuate the song samples since they will be loud
const float SONG_SAMPLE_ATTENUATION = 0.25;
songSample *= SONG_SAMPLE_ATTENUATION;
// add the song sample to the output and input buffersg
inputLeft[i] = inputLeft[i] + songSample;
outputLeft[i] = outputLeft[i] + songSample;
outputRight[i] = outputLeft[i] + songSample;
}
} else if (_songFileStream) {
// close the stream
_songFileStream->close();
// delete the _songFileStream
delete _songFileStream;
_songFileStream = NULL;
// reset the _songFileBytes back to zero
_songFileBytes = 0;
// call Application stopMixingSong method to fix menu item
Application::getInstance()->resetSongMixMenuItem();
}
// copy the audio data to the last BUFFER_LENGTH_BYTES bytes of the data packet
memcpy(currentPacketPtr, inputLeft, BUFFER_LENGTH_BYTES_PER_CHANNEL);
@ -415,8 +384,6 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) :
_collisionSoundDuration(0.0f),
_proceduralEffectSample(0),
_heartbeatMagnitude(0.0f),
_songFileStream(NULL),
_songFileBytes(0),
_listenMode(AudioRingBuffer::NORMAL),
_listenRadius(0.0f)
{
@ -489,24 +456,6 @@ Audio::~Audio() {
delete[] _echoSamplesLeft;
}
void Audio::importSongToMixWithMicrophone(const char* filename) {
_songFileStream = new std::ifstream(filename);
long begin = _songFileStream->tellg();
_songFileStream->seekg(0, std::ios::end);
long end = _songFileStream->tellg();
// go back to the beginning
_songFileStream->seekg(0);
_songFileBytes = end - begin;
}
void Audio::stopMixingSongWithMicrophone() {
_songFileBytes = 0;
}
void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBytes) {
const int NUM_INITIAL_PACKETS_DISCARD = 3;
const int STANDARD_DEVIATION_SAMPLE_COUNT = 500;
@ -528,7 +477,7 @@ void Audio::addReceivedAudioToBuffer(unsigned char* receivedData, int receivedBy
// Set jitter buffer to be a multiple of the measured standard deviation
const int MAX_JITTER_BUFFER_SAMPLES = RING_BUFFER_LENGTH_SAMPLES / 2;
const float NUM_STANDARD_DEVIATIONS = 3.f;
if (Application::getInstance()->shouldDynamicallySetJitterBuffer()) {
if (Menu::getInstance()->getAudioJitterBufferSamples() == 0) {
float newJitterBufferSamples = (NUM_STANDARD_DEVIATIONS * _measuredJitter)
/ 1000.f
* SAMPLE_RATE;
@ -646,7 +595,7 @@ void Audio::render(int screenWidth, int screenHeight) {
sprintf(out, "%.0f\n", getJitterBufferSamples() / SAMPLE_RATE * 1000.f);
drawtext(startX + jitterBufferPels - 5, topY - 9, 0.10, 0, 1, 0, out, 1, 0, 0);
sprintf(out, "j %.1f\n", _measuredJitter);
if (Application::getInstance()->shouldDynamicallySetJitterBuffer()) {
if (Menu::getInstance()->getAudioJitterBufferSamples() == 0) {
drawtext(startX + jitterBufferPels - 5, bottomY + 12, 0.10, 0, 1, 0, out, 1, 0, 0);
} else {
drawtext(startX, bottomY + 12, 0.10, 0, 1, 0, out, 1, 0, 0);

View file

@ -54,8 +54,6 @@ public:
float getCollisionSoundMagnitude() { return _collisionSoundMagnitude; };
int getSongFileBytes() { return _songFileBytes; }
void ping();
// Call periodically to eventually perform round trip time analysis,
@ -68,11 +66,6 @@ public:
void addListenSource(int sourceID);
void removeListenSource(int sourceID);
void clearListenSources();
void importSongToMixWithMicrophone(const char* filename);
public slots:
void stopMixingSongWithMicrophone();
private:
PaStream* _stream;
@ -109,9 +102,7 @@ private:
float _collisionSoundDuration;
int _proceduralEffectSample;
float _heartbeatMagnitude;
std::ifstream* _songFileStream;
int _songFileBytes;
AudioRingBuffer::ListenMode _listenMode;
float _listenRadius;
std::vector<int> _listenSources;

View file

@ -0,0 +1,67 @@
//
// GLCanvas.cpp
// hifi
//
// Created by Stephen Birarda on 8/14/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#include "Application.h"
#include "GLCanvas.h"
void GLCanvas::initializeGL() {
Application::getInstance()->initializeGL();
setAttribute(Qt::WA_AcceptTouchEvents);
}
void GLCanvas::paintGL() {
Application::getInstance()->paintGL();
}
void GLCanvas::resizeGL(int width, int height) {
Application::getInstance()->resizeGL(width, height);
}
void GLCanvas::keyPressEvent(QKeyEvent* event) {
Application::getInstance()->keyPressEvent(event);
}
void GLCanvas::keyReleaseEvent(QKeyEvent* event) {
Application::getInstance()->keyReleaseEvent(event);
}
void GLCanvas::mouseMoveEvent(QMouseEvent* event) {
Application::getInstance()->mouseMoveEvent(event);
}
void GLCanvas::mousePressEvent(QMouseEvent* event) {
Application::getInstance()->mousePressEvent(event);
}
void GLCanvas::mouseReleaseEvent(QMouseEvent* event) {
Application::getInstance()->mouseReleaseEvent(event);
}
int updateTime = 0;
bool GLCanvas::event(QEvent* event) {
switch (event->type()) {
case QEvent::TouchBegin:
Application::getInstance()->touchBeginEvent(static_cast<QTouchEvent*>(event));
event->accept();
return true;
case QEvent::TouchEnd:
Application::getInstance()->touchEndEvent(static_cast<QTouchEvent*>(event));
return true;
case QEvent::TouchUpdate:
Application::getInstance()->touchUpdateEvent(static_cast<QTouchEvent*>(event));
return true;
default:
break;
}
return QGLWidget::event(event);
}
void GLCanvas::wheelEvent(QWheelEvent* event) {
Application::getInstance()->wheelEvent(event);
}

34
interface/src/GLCanvas.h Normal file
View file

@ -0,0 +1,34 @@
//
// GLCanvas.h
// hifi
//
// Created by Stephen Birarda on 8/14/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#ifndef __hifi__GLCanvas__
#define __hifi__GLCanvas__
#include <QGLWidget>
/// customized canvas that simply forwards requests/events to the singleton application
class GLCanvas : public QGLWidget {
protected:
virtual void initializeGL();
virtual void paintGL();
virtual void resizeGL(int width, int height);
virtual void keyPressEvent(QKeyEvent* event);
virtual void keyReleaseEvent(QKeyEvent* event);
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual bool event(QEvent* event);
virtual void wheelEvent(QWheelEvent* event);
};
#endif /* defined(__hifi__GLCanvas__) */

View file

@ -8,10 +8,672 @@
#include <cstdlib>
#include <QMenuBar>
#include <QBoxLayout>
#include <QColorDialog>
#include <QDialogButtonBox>
#include <QDoubleSpinBox>
#include <QFileDialog>
#include <QFormLayout>
#include <QLineEdit>
#include <QMainWindow>
#include <QStandardPaths>
#include "Application.h"
#include "PairingHandler.h"
#include "Menu.h"
Menu* Menu::_instance = NULL;
void Menu::init() {
Menu* Menu::getInstance() {
if (!_instance) {
qDebug("First call to Menu::getInstance() - initing menu.\n");
_instance = new Menu();
}
return _instance;
}
const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f};
Menu::Menu() :
_bandwidthDialog(NULL),
_frustumDrawMode(FRUSTUM_DRAW_MODE_ALL),
_viewFrustumOffset(DEFAULT_FRUSTUM_OFFSET)
{
QApplication *appInstance = Application::getInstance();
QMenu* fileMenu = addMenu("File");
(addActionToQMenuAndActionHash(fileMenu,
MenuOption::Quit,
appInstance,
SLOT(quit()),
Qt::CTRL | Qt::Key_Q))->setMenuRole(QAction::QuitRole);
(addActionToQMenuAndActionHash(fileMenu,
MenuOption::Preferences,
this,
SLOT(editPreferences()),
Qt::CTRL | Qt::Key_Comma))->setMenuRole(QAction::PreferencesRole);
QMenu* pairMenu = addMenu("Pair");
addActionToQMenuAndActionHash(pairMenu, MenuOption::Pair, PairingHandler::getInstance(), SLOT(sendPairRequest()));
QMenu* optionsMenu = addMenu("Options");
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::Mirror, NULL, NULL, Qt::Key_H, false);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::Noise, NULL, NULL, Qt::Key_N, false);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::GyroLook, NULL, NULL, 0, true);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::HeadMouse, NULL, NULL, 0);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::TransmitterDrive, NULL, NULL, 0, true);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::Gravity, NULL, NULL, Qt::SHIFT | Qt::Key_G, true);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::TestPing, NULL, NULL, 0, true);
addCheckableActionToQMenuAndActionHash(optionsMenu,
MenuOption::Fullscreen,
appInstance,
SLOT(setFullscreen(bool)),
Qt::Key_F);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::Webcam);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::SkeletonTracking);
// optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true);
// optionsMenu->addAction("Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::Collisions, NULL, NULL, 0, true);
addActionToQMenuAndActionHash(optionsMenu, MenuOption::WebcamMode);
addCheckableActionToQMenuAndActionHash(optionsMenu, MenuOption::WebcamTexture);
// optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode()));
// optionsMenu->addAction("Webcam Texture", _webcam.getGrabber(), SLOT(setDepthOnly(bool)))->setCheckable(true);
addActionToQMenuAndActionHash(optionsMenu, MenuOption::GoHome, appInstance, SLOT(goHome()), Qt::CTRL | Qt::Key_G);
QMenu* audioMenu = addMenu("Audio");
addCheckableActionToQMenuAndActionHash(audioMenu, MenuOption::EchoAudio);
QMenu* renderMenu = addMenu("Render");
addCheckableActionToQMenuAndActionHash(renderMenu,
MenuOption::Voxels,
appInstance,
SLOT(setRenderVoxels(bool)),
Qt::SHIFT | Qt::Key_V,
true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::VoxelTextures);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::Stars, NULL, NULL, 0, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::Atmosphere, NULL, NULL, Qt::SHIFT | Qt::Key_A, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::GroundPlane, NULL, NULL, 0, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::Avatars, NULL, NULL, 0, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::AvatarAsBalls);
addActionToQMenuAndActionHash(renderMenu, MenuOption::VoxelMode);
// renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
addActionToQMenuAndActionHash(renderMenu, MenuOption::FaceMode);
// renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode()));
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::FrameTimer);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::LookAtVectors);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::LookAtIndicator, NULL, NULL, 0, true);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::ParticleSystem);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::FirstPerson, NULL, NULL, Qt::Key_P, true);
addActionToQMenuAndActionHash(renderMenu, MenuOption::IncreaseAvatarSize);
addActionToQMenuAndActionHash(renderMenu, MenuOption::DecreaseAvatarSize);
addActionToQMenuAndActionHash(renderMenu, MenuOption::ResetAvatarSize);
// renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus);
// renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus);
// renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize()));
QMenu* toolsMenu = addMenu("Tools");
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Stats, NULL, NULL, Qt::Key_Slash);
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Log, NULL, NULL, Qt::CTRL | Qt::Key_L);
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Oscilloscope, NULL, NULL, 0, true);
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Bandwidth, NULL, NULL, 0, true);
addActionToQMenuAndActionHash(toolsMenu, MenuOption::BandwidthDetails);
// toolsMenu->addAction("Bandwidth Details", this, SLOT(bandwidthDetails()));
addActionToQMenuAndActionHash(toolsMenu, MenuOption::VoxelStats);
// toolsMenu->addAction("Voxel Stats Details", this, SLOT(voxelStatsDetails()));
QMenu* voxelMenu = addMenu("Voxels");
_voxelModeActionsGroup = new QActionGroup(this);
QAction* addVoxelMode = addCheckableActionToQMenuAndActionHash(voxelMenu, MenuOption::VoxelAddMode, NULL, NULL, Qt::Key_V);
_voxelModeActionsGroup->addAction(addVoxelMode);
QAction* deleteVoxelMode = addCheckableActionToQMenuAndActionHash(voxelMenu,
MenuOption::VoxelDeleteMode,
NULL,
NULL,
Qt::Key_R);
_voxelModeActionsGroup->addAction(deleteVoxelMode);
QAction* colorVoxelMode = addCheckableActionToQMenuAndActionHash(voxelMenu,
MenuOption::VoxelColorMode,
NULL,
NULL,
Qt::Key_B);
_voxelModeActionsGroup->addAction(colorVoxelMode);
QAction* selectVoxelMode = addCheckableActionToQMenuAndActionHash(voxelMenu,
MenuOption::VoxelSelectMode,
NULL,
NULL,
Qt::Key_O);
_voxelModeActionsGroup->addAction(selectVoxelMode);
QAction* getColorMode = addCheckableActionToQMenuAndActionHash(voxelMenu,
MenuOption::VoxelGetColorMode,
NULL,
NULL,
Qt::Key_G);
_voxelModeActionsGroup->addAction(getColorMode);
QAction* voxelPaintColor = addActionToQMenuAndActionHash(voxelMenu,
MenuOption::VoxelPaintColor,
this,
SLOT(chooseVoxelPaintColor()),
Qt::META | Qt::Key_C);
Application::getInstance()->getSwatch()->setAction(voxelPaintColor);
QColor paintColor(128, 128, 128);
voxelPaintColor->setData(paintColor);
voxelPaintColor->setIcon(Swatch::createIcon(paintColor));
addActionToQMenuAndActionHash(voxelMenu,
MenuOption::DecreaseVoxelSize,
appInstance,
SLOT(decreaseVoxelSize()),
QKeySequence::ZoomOut);
addActionToQMenuAndActionHash(voxelMenu,
MenuOption::IncreaseVoxelSize,
appInstance,
SLOT(increaseVoxelSize()),
QKeySequence::ZoomIn);
addActionToQMenuAndActionHash(voxelMenu, MenuOption::ResetSwatchColors, appInstance, SLOT(resetSwatchColors()));
addCheckableActionToQMenuAndActionHash(voxelMenu, MenuOption::DestructiveAddVoxel);
addActionToQMenuAndActionHash(voxelMenu, MenuOption::ExportVoxels, NULL, NULL, Qt::CTRL | Qt::Key_E);
addActionToQMenuAndActionHash(voxelMenu, MenuOption::ImportVoxels, NULL, NULL, Qt::CTRL | Qt::Key_I);
addActionToQMenuAndActionHash(voxelMenu, MenuOption::ImportVoxelsClipboard, NULL, NULL, Qt::SHIFT | Qt::CTRL | Qt::Key_I);
addActionToQMenuAndActionHash(voxelMenu, MenuOption::CutVoxels, NULL, NULL, Qt::CTRL | Qt::Key_X);
addActionToQMenuAndActionHash(voxelMenu, MenuOption::CopyVoxels, NULL, NULL, Qt::CTRL | Qt::Key_C);
addActionToQMenuAndActionHash(voxelMenu, MenuOption::PasteVoxels, NULL, NULL, Qt::CTRL | Qt::Key_V);
QMenu* debugMenu = addMenu("Debug");
QMenu* frustumMenu = debugMenu->addMenu("View Frustum Debugging Tools");
addCheckableActionToQMenuAndActionHash(frustumMenu, MenuOption::DisplayFrustum, NULL, NULL, Qt::SHIFT | Qt::Key_F);
addActionToQMenuAndActionHash(frustumMenu,
MenuOption::FrustumRenderMode,
this,
SLOT(cycleFrustumRenderMode()),
Qt::SHIFT | Qt::Key_R);
updateFrustumRenderModeAction();
addActionToQMenuAndActionHash(debugMenu, MenuOption::RunTimingTests, NULL, NULL);
// debugMenu->addAction("Run Timing Tests", this, SLOT(runTests()));
addActionToQMenuAndActionHash(debugMenu, MenuOption::TreeStats, NULL, NULL, Qt::SHIFT | Qt::Key_S);
// debugMenu->addAction("Calculate Tree Stats", this, SLOT(doTreeStats()), Qt::SHIFT | Qt::Key_S);
QMenu* renderDebugMenu = debugMenu->addMenu("Render Debugging Tools");
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings, NULL, NULL);
// (_renderPipelineWarnings = renderDebugMenu->addAction("Show Render Pipeline Warnings",
// this, SLOT(setRenderWarnings(bool))))->setCheckable(true);
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::KillLocalVoxels, NULL, NULL, Qt::CTRL | Qt::Key_K);
// renderDebugMenu->addAction("Kill Local Voxels", this, SLOT(doKillLocalVoxels()), Qt::CTRL | Qt::Key_K);
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::RandomizeVoxelColors, NULL, NULL, Qt::CTRL | Qt::Key_R);
// renderDebugMenu->addAction("Randomize Voxel TRUE Colors", this, SLOT(doRandomizeVoxelColors()), Qt::CTRL | Qt::Key_R);
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::FalseColorRandomly, NULL, NULL);
// renderDebugMenu->addAction("FALSE Color Voxels Randomly", this, SLOT(doFalseRandomizeVoxelColors()));
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::FalseColorEveryOtherVoxel, NULL, NULL);
// renderDebugMenu->addAction("FALSE Color Voxel Every Other Randomly", this, SLOT(doFalseRandomizeEveryOtherVoxelColors()));
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::FalseColorByDistance, NULL, NULL);
// renderDebugMenu->addAction("FALSE Color Voxels by Distance", this, SLOT(doFalseColorizeByDistance()));
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::FalseColorOutOfView, NULL, NULL);
// renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView()));
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::FalseColorOccluded, NULL, NULL, Qt::CTRL | Qt::Key_O);
// renderDebugMenu->addAction("FALSE Color Occluded Voxels", this, SLOT(doFalseColorizeOccluded()), Qt::CTRL | Qt::Key_O);
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::FalseColorOccludedV2, NULL, NULL, Qt::CTRL | Qt::Key_P);
// renderDebugMenu->addAction("FALSE Color Occluded V2 Voxels", this, SLOT(doFalseColorizeOccludedV2()), Qt::CTRL | Qt::Key_P);
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::FalseColorBySource, NULL, NULL, Qt::CTRL | Qt::SHIFT | Qt::Key_S);
// renderDebugMenu->addAction("FALSE Color By Source", this, SLOT(doFalseColorizeBySource()), Qt::CTRL | Qt::SHIFT | Qt::Key_S);
addActionToQMenuAndActionHash(renderDebugMenu, MenuOption::ShowTrueColors, NULL, NULL, Qt::CTRL | Qt::Key_T);
// renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::LowPassFilter);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::Monochrome, NULL, NULL);
// debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::DisableLowRes, NULL, NULL);
// debugMenu->addAction("Disable Lower Resolution While Moving", this, SLOT(disableLowResMoving(bool)))->setCheckable(true);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::DisableDeltaSending, NULL, NULL);
// debugMenu->addAction("Disable Delta Sending", this, SLOT(disableDeltaSending(bool)))->setCheckable(true);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::DisableOcclusionCulling, NULL, NULL, Qt::SHIFT | Qt::Key_C);
// (_occlusionCulling = debugMenu->addAction("Disable Occlusion Culling", this, SLOT(disableOcclusionCulling(bool)),
// Qt::SHIFT | Qt::Key_C))->setCheckable(true);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::CoverageMap, NULL, NULL, Qt::SHIFT | Qt::CTRL | Qt::Key_O);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::CoverageMapV2, NULL, NULL, Qt::SHIFT | Qt::CTRL | Qt::Key_P);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::SimulateLeapHand);
addCheckableActionToQMenuAndActionHash(debugMenu, MenuOption::TestRaveGlove);
QMenu* audioDebugMenu = debugMenu->addMenu("Audio Debugging Tools");
addActionToQMenuAndActionHash(audioDebugMenu, MenuOption::ListenModeNormal, NULL, NULL, Qt::CTRL | Qt::Key_1);
addActionToQMenuAndActionHash(audioDebugMenu, MenuOption::ListenModePoint, NULL, NULL, Qt::CTRL | Qt::Key_2);
addActionToQMenuAndActionHash(audioDebugMenu, MenuOption::ListenModeSingleSource, NULL, NULL, Qt::CTRL | Qt::Key_3);
// audioDebugMenu->addAction("Listen Mode Single Source", this, SLOT(setListenModeSingleSource()), Qt::CTRL | Qt::Key_3);
QMenu* settingsMenu = addMenu("Settings");
addCheckableActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsAutosave, NULL, NULL, 0, true);
addActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsLoad, NULL, NULL);
addActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsSave, NULL, NULL);
addActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsImport, NULL, NULL);
addActionToQMenuAndActionHash(settingsMenu, MenuOption::SettingsExport, NULL, NULL);
// _networkAccessManager = new QNetworkAccessManager(this);
}
void Menu::loadSettings(QSettings* settings) {
if (!settings) {
settings = Application::getInstance()->getSettings();
}
_gyroCameraSensitivity = loadSetting(settings, "gyroCameraSensitivity", 0.5f);
_audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0);
_fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES);
settings->beginGroup("View Frustum Offset Camera");
// in case settings is corrupt or missing loadSetting() will check for NaN
_viewFrustumOffset.yaw = loadSetting(settings, "viewFrustumOffsetYaw", 0.0f);
_viewFrustumOffset.pitch = loadSetting(settings, "viewFrustumOffsetPitch", 0.0f);
_viewFrustumOffset.roll = loadSetting(settings, "viewFrustumOffsetRoll", 0.0f);
_viewFrustumOffset.distance = loadSetting(settings, "viewFrustumOffsetDistance", 0.0f);
_viewFrustumOffset.up = loadSetting(settings, "viewFrustumOffsetUp", 0.0f);
settings->endGroup();
scanMenuBar(&loadAction, settings);
Application::getInstance()->getAvatar()->loadData(settings);
Application::getInstance()->getSwatch()->loadData(settings);
}
void Menu::saveSettings(QSettings* settings) {
if (!settings) {
settings = Application::getInstance()->getSettings();
}
settings->setValue("gyroCameraSensitivity", _gyroCameraSensitivity);
settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples);
settings->setValue("fieldOfView", _fieldOfView);
settings->beginGroup("View Frustum Offset Camera");
settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffset.yaw);
settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffset.pitch);
settings->setValue("viewFrustumOffsetRoll", _viewFrustumOffset.roll);
settings->setValue("viewFrustumOffsetDistance", _viewFrustumOffset.distance);
settings->setValue("viewFrustumOffsetUp", _viewFrustumOffset.up);
settings->endGroup();
scanMenuBar(&saveAction, settings);
Application::getInstance()->getAvatar()->saveData(settings);
Application::getInstance()->getSwatch()->saveData(settings);
// ask the NodeList to save its data
NodeList::getInstance()->saveData(settings);
}
void Menu::importSettings() {
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
QString fileName = QFileDialog::getOpenFileName(Application::getInstance()->getWindow(),
tr("Open .ini config file"),
locationDir,
tr("Text files (*.ini)"));
if (fileName != "") {
QSettings tmp(fileName, QSettings::IniFormat);
loadSettings(&tmp);
}
}
void Menu::exportSettings() {
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
QString fileName = QFileDialog::getSaveFileName(Application::getInstance()->getWindow(),
tr("Save .ini config file"),
locationDir,
tr("Text files (*.ini)"));
if (fileName != "") {
QSettings tmp(fileName, QSettings::IniFormat);
saveSettings(&tmp);
tmp.sync();
}
}
void Menu::loadAction(QSettings* set, QAction* action) {
if (action->isChecked() != set->value(action->text(), action->isChecked()).toBool()) {
action->trigger();
}
}
void Menu::saveAction(QSettings* set, QAction* action) {
set->setValue(action->text(), action->isChecked());
}
void Menu::scanMenuBar(settingsAction modifySetting, QSettings* set) {
QList<QMenu*> menus = this->findChildren<QMenu *>();
for (QList<QMenu *>::const_iterator it = menus.begin(); menus.end() != it; ++it) {
scanMenu(*it, modifySetting, set);
}
}
void Menu::scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set) {
QList<QAction*> actions = menu->actions();
set->beginGroup(menu->title());
for (QList<QAction *>::const_iterator it = actions.begin(); actions.end() != it; ++it) {
if ((*it)->menu()) {
scanMenu((*it)->menu(), modifySetting, set);
}
if ((*it)->isCheckable()) {
modifySetting(set, *it);
}
}
set->endGroup();
}
void Menu::handleViewFrustumOffsetKeyModifier(int key) {
const float VIEW_FRUSTUM_OFFSET_DELTA = 0.5f;
const float VIEW_FRUSTUM_OFFSET_UP_DELTA = 0.05f;
switch (key) {
case Qt::Key_BracketLeft:
_viewFrustumOffset.yaw -= VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_BracketRight:
_viewFrustumOffset.yaw += VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_BraceLeft:
_viewFrustumOffset.pitch -= VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_BraceRight:
_viewFrustumOffset.pitch += VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_ParenLeft:
_viewFrustumOffset.roll -= VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_ParenRight:
_viewFrustumOffset.roll += VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_Less:
_viewFrustumOffset.distance -= VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_Greater:
_viewFrustumOffset.distance += VIEW_FRUSTUM_OFFSET_DELTA;
break;
case Qt::Key_Comma:
_viewFrustumOffset.up -= VIEW_FRUSTUM_OFFSET_UP_DELTA;
break;
case Qt::Key_Period:
_viewFrustumOffset.up += VIEW_FRUSTUM_OFFSET_UP_DELTA;
break;
default:
break;
}
}
QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString actionName,
const QObject* receiver,
const char* member,
const QKeySequence& shortcut) {
QAction* action;
if (receiver && member) {
action = destinationMenu->addAction(actionName, receiver, member, shortcut);
} else {
action = destinationMenu->addAction(actionName);
action->setShortcut(shortcut);
}
_actionHash.insert(actionName, action);
return action;
}
QAction* Menu::addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString actionName,
const QObject* receiver,
const char* member,
const QKeySequence& shortcut,
const bool checked) {
QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, receiver, member, shortcut);
action->setCheckable(true);
action->setChecked(checked);
return action;
}
bool Menu::isOptionChecked(const QString& menuOption) {
return _actionHash.value(menuOption)->isChecked();
}
void Menu::triggerOption(const QString& menuOption) {
_actionHash.value(menuOption)->trigger();
}
QAction* Menu::getActionForOption(const QString& menuOption) {
return _actionHash.value(menuOption);
}
bool Menu::isVoxelModeActionChecked() {
foreach (QAction* action, _voxelModeActionsGroup->actions()) {
if (action->isChecked()) {
return true;
}
}
return false;
}
void Menu::editPreferences() {
Application *applicationInstance = Application::getInstance();
QDialog dialog(applicationInstance->getGLWidget());
dialog.setWindowTitle("Interface Preferences");
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
dialog.setLayout(layout);
QFormLayout* form = new QFormLayout();
layout->addLayout(form, 1);
const int QLINE_MINIMUM_WIDTH = 400;
QLineEdit* domainServerHostname = new QLineEdit(QString(NodeList::getInstance()->getDomainHostname()));
domainServerHostname->setMinimumWidth(QLINE_MINIMUM_WIDTH);
form->addRow("Domain server:", domainServerHostname);
QLineEdit* avatarURL = new QLineEdit(applicationInstance->getAvatar()->getVoxels()->getVoxelURL().toString());
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
form->addRow("Avatar URL:", avatarURL);
QSpinBox* fieldOfView = new QSpinBox();
fieldOfView->setMaximum(180);
fieldOfView->setMinimum(1);
fieldOfView->setValue(_fieldOfView);
form->addRow("Vertical Field of View (Degrees):", fieldOfView);
QDoubleSpinBox* gyroCameraSensitivity = new QDoubleSpinBox();
gyroCameraSensitivity->setValue(_gyroCameraSensitivity);
form->addRow("Gyro Camera Sensitivity (0 - 1):", gyroCameraSensitivity);
QDoubleSpinBox* leanScale = new QDoubleSpinBox();
leanScale->setValue(applicationInstance->getAvatar()->getLeanScale());
form->addRow("Lean Scale:", leanScale);
QSpinBox* audioJitterBufferSamples = new QSpinBox();
audioJitterBufferSamples->setMaximum(10000);
audioJitterBufferSamples->setMinimum(-10000);
audioJitterBufferSamples->setValue(_audioJitterBufferSamples);
form->addRow("Audio Jitter Buffer Samples (0 for automatic):", audioJitterBufferSamples);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
layout->addWidget(buttons);
if (dialog.exec() != QDialog::Accepted) {
return;
}
QByteArray newHostname;
if (domainServerHostname->text().size() > 0) {
// the user input a new hostname, use that
newHostname = domainServerHostname->text().toLocal8Bit();
} else {
// the user left the field blank, use the default hostname
newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME);
}
// check if the domain server hostname is new
if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) {
NodeList::getInstance()->clear();
// kill the local voxels
applicationInstance->getVoxels()->killLocalVoxels();
// reset the environment to default
applicationInstance->getEnvironment()->resetToDefault();
// set the new hostname
NodeList::getInstance()->setDomainHostname(newHostname.constData());
}
QUrl url(avatarURL->text());
applicationInstance->getAvatar()->getVoxels()->setVoxelURL(url);
Avatar::sendAvatarVoxelURLMessage(url);
_gyroCameraSensitivity = gyroCameraSensitivity->value();
applicationInstance->getAvatar()->setLeanScale(leanScale->value());
_audioJitterBufferSamples = audioJitterBufferSamples->value();
if (_audioJitterBufferSamples != 0) {
applicationInstance->getAudio()->setJitterBufferSamples(_audioJitterBufferSamples);
}
_fieldOfView = fieldOfView->value();
applicationInstance->resizeGL(applicationInstance->getGLWidget()->width(), applicationInstance->getGLWidget()->height());
}
void Menu::bandwidthDetails() {
if (! _bandwidthDialog) {
_bandwidthDialog = new BandwidthDialog(Application::getInstance()->getGLWidget(),
Application::getInstance()->getBandwidthMeter());
connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed()));
_bandwidthDialog->show();
}
_bandwidthDialog->raise();
}
void Menu::bandwidthDetailsClosed() {
delete _bandwidthDialog;
_bandwidthDialog = NULL;
}
void Menu::cycleFrustumRenderMode() {
_frustumDrawMode = (FrustumDrawMode)((_frustumDrawMode + 1) % FRUSTUM_DRAW_MODE_COUNT);
updateFrustumRenderModeAction();
}
void Menu::chooseVoxelPaintColor() {
Application* appInstance = Application::getInstance();
QAction* paintColor = _actionHash.value(MenuOption::VoxelPaintColor);
QColor selected = QColorDialog::getColor(paintColor->data().value<QColor>(),
appInstance->getGLWidget(),
"Voxel Paint Color");
if (selected.isValid()) {
paintColor->setData(selected);
paintColor->setIcon(Swatch::createIcon(selected));
}
// restore the main window's active state
// _window->activateWindow();
}
void Menu::updateFrustumRenderModeAction() {
QAction* frustumRenderModeAction = _actionHash.value(MenuOption::FrustumRenderMode);
switch (_frustumDrawMode) {
default:
case FRUSTUM_DRAW_MODE_ALL:
frustumRenderModeAction->setText("Render Mode - All");
break;
case FRUSTUM_DRAW_MODE_VECTORS:
frustumRenderModeAction->setText("Render Mode - Vectors");
break;
case FRUSTUM_DRAW_MODE_PLANES:
frustumRenderModeAction->setText("Render Mode - Planes");
break;
case FRUSTUM_DRAW_MODE_NEAR_PLANE:
frustumRenderModeAction->setText("Render Mode - Near");
break;
case FRUSTUM_DRAW_MODE_FAR_PLANE:
frustumRenderModeAction->setText("Render Mode - Far");
break;
case FRUSTUM_DRAW_MODE_KEYHOLE:
frustumRenderModeAction->setText("Render Mode - Keyhole");
break;
}
}

View file

@ -9,11 +9,187 @@
#ifndef __hifi__Menu__
#define __hifi__Menu__
class Menu {
public:
static void init();
private:
static Menu* _instance;
#include <QMenuBar>
#include <QHash>
#include <QKeySequence>
enum FrustumDrawMode {
FRUSTUM_DRAW_MODE_ALL,
FRUSTUM_DRAW_MODE_VECTORS,
FRUSTUM_DRAW_MODE_PLANES,
FRUSTUM_DRAW_MODE_NEAR_PLANE,
FRUSTUM_DRAW_MODE_FAR_PLANE,
FRUSTUM_DRAW_MODE_KEYHOLE,
FRUSTUM_DRAW_MODE_COUNT
};
struct ViewFrustumOffset {
float yaw;
float pitch;
float roll;
float distance;
float up;
};
class Menu : public QMenuBar {
Q_OBJECT
public:
static Menu* getInstance();
bool isOptionChecked(const QString& menuOption);
void triggerOption(const QString& menuOption);
QAction* getActionForOption(const QString& menuOption);
bool isVoxelModeActionChecked();
float getAudioJitterBufferSamples() const { return _audioJitterBufferSamples; }
float getFieldOfView() const { return _fieldOfView; }
float getGyroCameraSensitivity() const { return _gyroCameraSensitivity; }
BandwidthDialog* getBandwidthDialog() const { return _bandwidthDialog; }
FrustumDrawMode getFrustumDrawMode() const { return _frustumDrawMode; }
ViewFrustumOffset getViewFrustumOffset() const { return _viewFrustumOffset; }
void loadSettings(QSettings* settings = NULL);
void saveSettings(QSettings* settings = NULL);
void importSettings();
void exportSettings();
void handleViewFrustumOffsetKeyModifier(int key);
public slots:
void bandwidthDetails();
private slots:
void editPreferences();
void bandwidthDetailsClosed();
void cycleFrustumRenderMode();
void chooseVoxelPaintColor();
private:
static Menu* _instance;
Menu();
typedef void(*settingsAction)(QSettings*, QAction*);
static void loadAction(QSettings* set, QAction* action);
static void saveAction(QSettings* set, QAction* action);
void scanMenuBar(settingsAction modifySetting, QSettings* set);
void scanMenu(QMenu* menu, settingsAction modifySetting, QSettings* set);
QAction* addActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString actionName,
const QObject* receiver = NULL,
const char* member = NULL,
const QKeySequence& shortcut = 0);
QAction* addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu,
const QString actionName,
const QObject* receiver = NULL,
const char* member = NULL,
const QKeySequence& shortcut = 0,
const bool checked = false);
void updateFrustumRenderModeAction();
QHash<QString, QAction*> _actionHash;
int _audioJitterBufferSamples; /// number of extra samples to wait before starting audio playback
BandwidthDialog* _bandwidthDialog;
float _fieldOfView; /// in Degrees, doesn't apply to HMD like Oculus
FrustumDrawMode _frustumDrawMode;
float _gyroCameraSensitivity;
ViewFrustumOffset _viewFrustumOffset;
QActionGroup* _voxelModeActionsGroup;
};
namespace MenuOption {
const QString Avatars = "Avatars";
const QString AvatarAsBalls = "Avatar as Balls";
const QString Atmosphere = "Atmosphere";
const QString Bandwidth = "Bandwidth Display";
const QString BandwidthDetails = "Bandwidth Details";
const QString Collisions = "Collisions";
const QString CopyVoxels = "Copy Voxels";
const QString CoverageMap = "Render Coverage Map";
const QString CoverageMapV2 = "Render Coverage Map V2";
const QString CutVoxels = "Cut Voxels";
const QString DecreaseAvatarSize = "Decrease Avatar Size";
const QString DecreaseVoxelSize = "Decrease Voxel Size";
const QString DestructiveAddVoxel = "Create Voxel is Destructive";
const QString DisableDeltaSending = "Disable Delta Sending";
const QString DisableLowRes = "Disable Lower Resolution While Moving";
const QString DisableOcclusionCulling = "Disable Occlusion Culling";
const QString DisplayFrustum = "Display Frustum";
const QString EchoAudio = "Echo Audio";
const QString ExportVoxels = "Export Voxels";
const QString HeadMouse = "Head Mouse";
const QString FaceMode = "Cycle Face Mode";
const QString FalseColorByDistance = "FALSE Color By Distance";
const QString FalseColorBySource = "FALSE Color By Source";
const QString FalseColorEveryOtherVoxel = "FALSE Color Every Other Randomly";
const QString FalseColorOccluded = "FALSE Color Occluded Voxels";
const QString FalseColorOccludedV2 = "FALSE Color Occluded V2 Voxels";
const QString FalseColorOutOfView = "FALSE Color Voxel Out of View";
const QString FalseColorRandomly = "FALSE Color Voxels Randomly";
const QString FirstPerson = "First Person";
const QString FrameTimer = "Show Timer";
const QString FrustumRenderMode = "Render Mode";
const QString Fullscreen = "Fullscreen";
const QString ImportVoxels = "Import Voxels";
const QString ImportVoxelsClipboard = "Import Voxels to Clipboard";
const QString IncreaseAvatarSize = "Increase Avatar Size";
const QString IncreaseVoxelSize = "Increase Voxel Size";
const QString KillLocalVoxels = "Kill Local Voxels";
const QString GoHome = "Go Home";
const QString Gravity = "Use Gravity";
const QString GroundPlane = "Ground Plane";
const QString GyroLook = "Smooth Gyro Look";
const QString ListenModeNormal = "Listen Mode Normal";
const QString ListenModePoint = "Listen Mode Point";
const QString ListenModeSingleSource = "Listen Mode Single Source";
const QString Log = "Log";
const QString LookAtIndicator = "Look-at Indicator";
const QString LookAtVectors = "Look-at Vectors";
const QString LowPassFilter = "Low-pass Filter";
const QString Mirror = "Mirror";
const QString Monochrome = "Monochrome";
const QString Noise = "Noise";
const QString Oscilloscope = "Audio Oscilloscope";
const QString Pair = "Pair";
const QString ParticleSystem = "Particle System";
const QString PasteVoxels = "Paste Voxels";
const QString PipelineWarnings = "Show Render Pipeline Warnings";
const QString Preferences = "Preferences...";
const QString RandomizeVoxelColors = "Randomize Voxel TRUE Colors";
const QString ResetAvatarSize = "Reset Avatar Size";
const QString ResetSwatchColors = "Reset Swatch Colors";
const QString RunTimingTests = "Run Timing Tests";
const QString SettingsAutosave = "Autosave";
const QString SettingsLoad = "Load Settings";
const QString SettingsSave = "Save Settings";
const QString SettingsImport = "Import Settings";
const QString SettingsExport = "Export Settings";
const QString ShowTrueColors = "Show TRUE Colors";
const QString SimulateLeapHand = "Simulate Leap Hand";
const QString SkeletonTracking = "Skeleton Tracking";
const QString Stars = "Stars";
const QString Stats = "Stats";
const QString TestPing = "Test Ping";
const QString TestRaveGlove = "Test Rave Glove";
const QString TreeStats = "Calculate Tree Stats";
const QString TransmitterDrive = "Transmitter Drive";
const QString Quit = "Quit";
const QString Webcam = "Webcam";
const QString WebcamMode = "Cycle Webcam Send Mode";
const QString WebcamTexture = "Webcam Texture";
const QString Voxels = "Voxels";
const QString VoxelAddMode = "Add Voxel Mode";
const QString VoxelColorMode = "Color Voxel Mode";
const QString VoxelDeleteMode = "Delete Voxel Mode";
const QString VoxelGetColorMode = "Get Color Mode";
const QString VoxelMode = "Cycle Voxel Mode";
const QString VoxelPaintColor = "Voxel Paint Color";
const QString VoxelSelectMode = "Select Voxel Mode";
const QString VoxelStats = "Voxel Stats";
const QString VoxelTextures = "Voxel Textures";
}
#endif /* defined(__hifi__Menu__) */

View file

@ -17,6 +17,16 @@
const char PAIRING_SERVER_HOSTNAME[] = "pairing.highfidelity.io";
const int PAIRING_SERVER_PORT = 7247;
PairingHandler* PairingHandler::getInstance() {
static PairingHandler* instance = NULL;
if (!instance) {
instance = new PairingHandler();
}
return instance;
}
void PairingHandler::sendPairRequest() {
// grab the node socket from the NodeList singleton
UDPSocket *nodeSocket = NodeList::getInstance()->getNodeSocket();

View file

@ -9,11 +9,14 @@
#ifndef __hifi__PairingHandler__
#define __hifi__PairingHandler__
#include <iostream>
#include <QtCore/QObject>
class PairingHandler {
class PairingHandler : public QObject {
Q_OBJECT
public:
static void sendPairRequest();
static PairingHandler* getInstance();
public slots:
void sendPairRequest();
};
#endif /* defined(__hifi__PairingHandler__) */

View file

@ -1,6 +1,20 @@
//
// Swatch.h
// interface
//
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#include "Swatch.h"
#include <iostream>
QIcon Swatch::createIcon(const QColor& color) {
QPixmap map(16, 16);
map.fill(color);
return QIcon(map);
}
Swatch::Swatch(QAction* action) :
Tool(action, 0, -1, -1),
_textRenderer(MONO_FONT_FAMILY, 10, 100),

View file

@ -23,6 +23,8 @@ static const int colorBase[8][3] = {{237, 175, 0},
class Swatch : public Tool {
public:
static QIcon createIcon(const QColor& color);
Swatch(QAction* action);
QColor getColor();

View file

@ -63,6 +63,28 @@ bool usingBigSphereCollisionTest = true;
float chatMessageScale = 0.0015;
float chatMessageHeight = 0.20;
void Avatar::sendAvatarVoxelURLMessage(const QUrl& url) {
uint16_t ownerID = NodeList::getInstance()->getOwnerID();
if (ownerID == UNKNOWN_NODE_ID) {
return; // we don't yet know who we are
}
QByteArray message;
char packetHeader[MAX_PACKET_HEADER_BYTES];
int numBytesPacketHeader = populateTypeAndVersion((unsigned char*) packetHeader, PACKET_TYPE_AVATAR_VOXEL_URL);
message.append(packetHeader, numBytesPacketHeader);
message.append((const char*)&ownerID, sizeof(ownerID));
message.append(url.toEncoded());
Application::controlledBroadcastToNodes((unsigned char*)message.data(),
message.size(),
&NODE_TYPE_AVATAR_MIXER,
1);
}
Avatar::Avatar(Node* owningNode) :
AvatarData(owningNode),
_initialized(false),

View file

@ -123,6 +123,8 @@ enum ScreenTintLayer
class Avatar : public AvatarData {
public:
static void sendAvatarVoxelURLMessage(const QUrl& url);
Avatar(Node* owningNode = NULL);
~Avatar();

View file

@ -384,6 +384,12 @@ void Head::renderMohawk() {
if (!_mohawkTriangleFan) {
createMohawk();
// if we get here and still don't have a mohawk then we don't know who we are
// so return out since we can't render it yet
if (!_mohawkTriangleFan) {
return;
}
}
if (USING_PHYSICAL_MOHAWK) {