From 81bc56f124fb0e507e5852c5d9a7b1584bb6b296 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Sat, 11 Mar 2017 14:44:33 +0100 Subject: [PATCH] Fixed slider groove size calculation. Added LOD Tools to Tablet UI --- .../resources/qml/controls-uit/Slider.qml | 2 +- .../qml/hifi/dialogs/TabletLODTools.qml | 119 ++++++++++++++++++ interface/src/Application.cpp | 12 ++ interface/src/Application.h | 1 + interface/src/Menu.cpp | 3 +- interface/src/ui/overlays/Web3DOverlay.cpp | 2 + 6 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 interface/resources/qml/hifi/dialogs/TabletLODTools.qml diff --git a/interface/resources/qml/controls-uit/Slider.qml b/interface/resources/qml/controls-uit/Slider.qml index cf59e1d989..39831546e1 100644 --- a/interface/resources/qml/controls-uit/Slider.qml +++ b/interface/resources/qml/controls-uit/Slider.qml @@ -36,7 +36,7 @@ Slider { Rectangle { width: parent.height - 2 - height: slider.value * slider.width - 1 + height: slider.value * (slider.width/(slider.maximumValue - slider.minimumValue)) - 1 radius: height / 2 anchors { top: parent.top diff --git a/interface/resources/qml/hifi/dialogs/TabletLODTools.qml b/interface/resources/qml/hifi/dialogs/TabletLODTools.qml new file mode 100644 index 0000000000..26e9759e0d --- /dev/null +++ b/interface/resources/qml/hifi/dialogs/TabletLODTools.qml @@ -0,0 +1,119 @@ +// +// TabletLODTools.qml +// +// Created by Vlad Stelmahovsky on 3/11/17 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import Qt.labs.settings 1.0 + +import "../../styles-uit" +import "../../controls-uit" as HifiControls +import "../../windows" + +Rectangle { + id: root + objectName: "LODTools" + + property var eventBridge; + signal sendToScript(var message); + property bool isHMD: false + + color: hifi.colors.baseGray + + property int colorScheme: hifi.colorSchemes.dark + + HifiConstants { id: hifi } + + readonly property real treeScale: 32768; // ~20 miles.. This is the number of meters of the 0.0 to 1.0 voxel universe + readonly property real halfTreeScale: treeScale / 2; + + // This controls the LOD. Larger number will make smaller voxels visible at greater distance. + readonly property real defaultOctreeSizeScale: treeScale * 400.0 + + Column { + anchors.margins: 10 + anchors.left: parent.left + anchors.right: parent.right + y: hifi.dimensions.tabletMenuHeader //-bgNavBar + spacing: 20 + + HifiControls.Label { + size: 20 + anchors.left: parent.left + anchors.right: parent.right + text: qsTr("You can see...") + colorScheme: root.colorScheme + } + HifiControls.Label { + id: whatYouCanSeeLabel + color: "red" + size: 20 + anchors.left: parent.left + anchors.right: parent.right + colorScheme: root.colorScheme + } + Row { + anchors.left: parent.left + anchors.right: parent.right + spacing: 10 + + HifiControls.Label { + size: 20 + text: qsTr("Manually Adjust Level of Detail:") + anchors.verticalCenter: parent.verticalCenter + colorScheme: root.colorScheme + } + + HifiControls.CheckBox { + id: adjustCheckbox + boxSize: 20 + anchors.verticalCenter: parent.verticalCenter + onCheckedChanged: LODManager.setAutomaticLODAdjust(!checked); + } + } + + HifiControls.Label { + size: 20 + anchors.left: parent.left + anchors.right: parent.right + text: qsTr("Level of Detail:") + colorScheme: root.colorScheme + } + HifiControls.Slider { + id: slider + enabled: adjustCheckbox.checked + anchors.left: parent.left + anchors.right: parent.right + minimumValue: 5 + maximumValue: 2000 + value: LODManager.getOctreeSizeScale() / treeScale + tickmarksEnabled: false + onValueChanged: { + LODManager.setOctreeSizeScale(value * treeScale); + whatYouCanSeeLabel.text = LODManager.getLODFeedbackText() + } + } + + HifiControls.Button { + id: uploadButton + anchors.left: parent.left + anchors.right: parent.right + text: qsTr("Reset") + color: hifi.buttons.blue + colorScheme: root.colorScheme + height: 30 + onClicked: { + slider.value = defaultOctreeSizeScale/treeScale + adjustCheckbox.checked = false + LODManager.setAutomaticLODAdjust(adjustCheckbox.checked); + } + } + } +} + diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 27dd65ab8d..94a71e01b0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6363,6 +6363,18 @@ void Application::loadScriptURLDialog() const { } } +void Application::loadLODToolsDialog() { + auto tabletScriptingInterface = DependencyManager::get(); + auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { + auto dialogsManager = DependencyManager::get(); + dialogsManager->lodTools(); + } else { + tablet->pushOntoStack("../../hifi/dialogs/TabletLODTools.qml"); + } + +} + void Application::toggleLogDialog() { if (! _logDialog) { _logDialog = new LogDialog(nullptr, getLogger()); diff --git a/interface/src/Application.h b/interface/src/Application.h index 9fab4aef81..5c72f0fa90 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -403,6 +403,7 @@ public slots: void addAssetToWorldMessageClose(); Q_INVOKABLE void toggleMuteAudio(); + void loadLODToolsDialog(); private slots: void showDesktop(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 241f908190..dcbcfed6a0 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -408,7 +408,8 @@ Menu::Menu() { // Developer > Render > LOD Tools - addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, dialogsManager.data(), SLOT(lodTools())); + addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, + qApp, SLOT(loadLODToolsDialog())); // HACK enable texture decimation { diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 32fe26a697..de0218843a 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -43,6 +43,7 @@ #include "FileDialogHelper.h" #include "avatar/AvatarManager.h" #include "AudioClient.h" +#include "LODManager.h" static const float DPI = 30.47f; static const float INCHES_TO_METERS = 1.0f / 39.3701f; @@ -182,6 +183,7 @@ void Web3DOverlay::loadSourceURL() { _webSurface->getRootContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("Tablet", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("Assets", DependencyManager::get().data()); + _webSurface->getRootContext()->setContextProperty("LODManager", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("pathToFonts", "../../"); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data());