1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

LP-29 reorganize shared/qml directory

- move java script stuff to js directory
- move PFD implementation to pfd directory
This commit is contained in:
Philippe Renon 2016-03-26 00:16:43 +01:00
parent fd9615b1ab
commit 1f649f4327
22 changed files with 308 additions and 232 deletions

View File

@ -1635,7 +1635,7 @@
<version>0.0.0</version> <version>0.0.0</version>
</configInfo> </configInfo>
<data> <data>
<qmlFile>%%DATAPATH%%qml/Pfd.qml</qmlFile> <qmlFile>%%DATAPATH%%qml/PfdTerrain.qml</qmlFile>
<altitudeFactor>1</altitudeFactor> <altitudeFactor>1</altitudeFactor>
<speedFactor>1</speedFactor> <speedFactor>1</speedFactor>
<terrainEnabled>true</terrainEnabled> <terrainEnabled>true</terrainEnabled>
@ -1659,7 +1659,7 @@
<version>0.0.0</version> <version>0.0.0</version>
</configInfo> </configInfo>
<data> <data>
<qmlFile>%%DATAPATH%%qml/Pfd.qml</qmlFile> <qmlFile>%%DATAPATH%%qml/PfdTerrain.qml</qmlFile>
<altitudeFactor>1</altitudeFactor> <altitudeFactor>1</altitudeFactor>
<speedFactor>1</speedFactor> <speedFactor>1</speedFactor>
<terrainEnabled>true</terrainEnabled> <terrainEnabled>true</terrainEnabled>
@ -1683,7 +1683,7 @@
<version>0.0.0</version> <version>0.0.0</version>
</configInfo> </configInfo>
<data> <data>
<qmlFile>%%DATAPATH%%qml/ModelView.qml</qmlFile> <qmlFile>%%DATAPATH%%qml/Model.qml</qmlFile>
<altitudeFactor>1</altitudeFactor> <altitudeFactor>1</altitudeFactor>
<speedFactor>1</speedFactor> <speedFactor>1</speedFactor>
<terrainEnabled>false</terrainEnabled> <terrainEnabled>false</terrainEnabled>
@ -1707,7 +1707,7 @@
<version>0.0.0</version> <version>0.0.0</version>
</configInfo> </configInfo>
<data> <data>
<qmlFile>%%DATAPATH%%qml/ModelView.qml</qmlFile> <qmlFile>%%DATAPATH%%qml/ModelTerrain.qml</qmlFile>
<altitudeFactor>1</altitudeFactor> <altitudeFactor>1</altitudeFactor>
<speedFactor>1</speedFactor> <speedFactor>1</speedFactor>
<terrainEnabled>true</terrainEnabled> <terrainEnabled>true</terrainEnabled>
@ -1731,7 +1731,7 @@
<version>0.0.0</version> <version>0.0.0</version>
</configInfo> </configInfo>
<data> <data>
<qmlFile>%%DATAPATH%%qml/ModelView.qml</qmlFile> <qmlFile>%%DATAPATH%%qml/ModelTerrain.qml</qmlFile>
<altitudeFactor>1</altitudeFactor> <altitudeFactor>1</altitudeFactor>
<speedFactor>1</speedFactor> <speedFactor>1</speedFactor>
<terrainEnabled>true</terrainEnabled> <terrainEnabled>true</terrainEnabled>
@ -1755,7 +1755,7 @@
<version>0.0.0</version> <version>0.0.0</version>
</configInfo> </configInfo>
<data> <data>
<qmlFile>%%DATAPATH%%qml/EarthView.qml</qmlFile> <qmlFile>%%DATAPATH%%qml/Earth.qml</qmlFile>
<altitudeFactor>1</altitudeFactor> <altitudeFactor>1</altitudeFactor>
<speedFactor>1</speedFactor> <speedFactor>1</speedFactor>
<terrainEnabled>true</terrainEnabled> <terrainEnabled>true</terrainEnabled>

View File

@ -23,7 +23,7 @@ import QtQuick.Controls 1.4
import Pfd 1.0 import Pfd 1.0
import OsgQtQuick 1.0 import OsgQtQuick 1.0
import "common.js" as Utils import "js/common.js" as Utils
Item { Item {
OSGViewport { OSGViewport {

View File

@ -19,10 +19,7 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
Item { import "model"
Loader {
anchors.fill: parent ModelView {
focus: true }
source: pfdContext.terrainEnabled ? "model/ModelTerrainView.qml" : "model/ModelView.qml"
}
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C) 2016 The LibrePilot Project
* Contact: http://www.librepilot.org
*
* This file is part of LibrePilot GCS.
*
* LibrePilot GCS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LibrePilot GCS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LibrePilot GCS. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
import "model"
ModelTerrainView {
}

View File

@ -19,107 +19,8 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "pfd" as Pfd import "pfd"
Rectangle { PfdView {
color: "#515151" worldFile: "PfdSimpleWorld.qml"
Pfd.SvgElementImage {
id: background
elementName: "pfd-window"
fillMode: Image.PreserveAspectFit
anchors.fill: parent
sceneSize: Qt.size(width, height)
Rectangle {
width: Math.floor(parent.paintedHeight * 1.319)
height: Math.floor(parent.paintedHeight - parent.paintedHeight * 0.008)
color: "transparent"
border.color: "white"
border.width: Math.floor(parent.paintedHeight * 0.008)
radius: Math.floor(parent.paintedHeight * 0.01)
anchors.centerIn: parent
}
Item {
id: sceneItem
FontLoader {
id: pt_bold
source: "qrc:/utils/fonts/PTS75F.ttf"
}
width: Math.floor((parent.paintedHeight * 1.32) - (parent.paintedHeight * 0.013))
height: Math.floor(parent.paintedHeight - parent.paintedHeight * 0.02)
property variant viewportSize : Qt.size(width, height)
anchors.centerIn: parent
clip: true
Loader {
id: worldLoader
anchors.fill: parent
focus: true
source: pfdContext.terrainEnabled ? "pfd/PfdTerrainView.qml" : "pfd/PfdWorldView.qml"
}
Pfd.HorizontCenter {
id: horizontCenterItem
sceneSize: sceneItem.viewportSize
anchors.fill: parent
}
Pfd.RollScale {
id: rollscale
sceneSize: sceneItem.viewportSize
horizontCenter: horizontCenterItem.horizontCenter
anchors.fill: parent
}
Pfd.SvgElementImage {
id: side_slip_fixed
elementName: "sideslip-fixed"
sceneSize: sceneItem.viewportSize
x: scaledBounds.x * sceneItem.width
}
Pfd.Compass {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
Pfd.SpeedScale {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
Pfd.AltitudeScale {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
Pfd.VsiScale {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
visible: pfdContext.altitudeUnit != 0
}
Pfd.Info {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
Pfd.Panels {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
Pfd.Warnings {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
}
}
} }

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2016 The LibrePilot Project
* Contact: http://www.librepilot.org
*
* This file is part of LibrePilot GCS.
*
* LibrePilot GCS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LibrePilot GCS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LibrePilot GCS. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
import "pfd"
PfdView {
worldFile: "PfdTerrainWorld.qml"
}

View File

@ -28,7 +28,7 @@
.import UAVTalk.VtolPathFollowerSettings 1.0 as VtolPathFollowerSettings .import UAVTalk.VtolPathFollowerSettings 1.0 as VtolPathFollowerSettings
// Navigation // Navigation
.import UAVTalk.HomeLocation 1.0 as HomeLocation .import UAVTalk.HomeLocation 1.0 as HomeLocation
.import UAVTalk.TakeOffLocation 1.0 as TakeOffLocation .import UAVTalk.TakeOffLocation 1.0 as TakeOffLocation
// Sensors // Sensors
@ -147,7 +147,7 @@ function defaultPosition() {
* *
*/ */
function isCC3D() { function isCC3D() {
// Hack: detect Coptercontrol with mem free // Hack: detect Coptercontrol with mem free
return (freeMemoryBytes() < 3096); return (freeMemoryBytes() < 3096);
} }
@ -251,7 +251,7 @@ function gpsStatus() {
return ["NO GPS", "NO FIX", "2D", "3D"][gpsPositionSensor.status]; return ["NO GPS", "NO FIX", "2D", "3D"][gpsPositionSensor.status];
} }
function fusionAlgorithm() { function fusionAlgorithm() {
return ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPSNav (INS13)"][revoSettings.fusionAlgorithm]; return ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPSNav (INS13)"][revoSettings.fusionAlgorithm];
} }
@ -271,7 +271,7 @@ function batteryModuleEnabled() {
return (hwSettings.optionalModulesBattery == HwSettings.OptionalModules.Enabled); return (hwSettings.optionalModulesBattery == HwSettings.OptionalModules.Enabled);
} }
function batteryNbCells() { function batteryNbCells() {
return flightBatterySettings.nbCells; return flightBatterySettings.nbCells;
} }
@ -287,7 +287,7 @@ function batteryConsumedEnergy() {
return flightBatteryState.consumedEnergy.toFixed(0); return flightBatteryState.consumedEnergy.toFixed(0);
} }
function estimatedFlightTimeValue() { function estimatedFlightTimeValue() {
return Math.round(flightBatteryState.estimatedFlightTime); return Math.round(flightBatteryState.estimatedFlightTime);
} }
@ -351,7 +351,7 @@ function waypointHeading() {
} }
function homeDistance() { function homeDistance() {
return Math.sqrt(Math.pow((takeOffLocation.east - positionState.east), 2) + return Math.sqrt(Math.pow((takeOffLocation.east - positionState.east), 2) +
Math.pow((takeOffLocation.north - positionState.north), 2)); Math.pow((takeOffLocation.north - positionState.north), 2));
} }
@ -377,8 +377,8 @@ function isVtolPathFollowerSettingsThrustAuto() {
} }
function flightModeName() { function flightModeName() {
return ["MANUAL", "STAB 1", "STAB 2", "STAB 3", "STAB 4", "STAB 5", "STAB 6", return ["MANUAL", "STAB 1", "STAB 2", "STAB 3", "STAB 4", "STAB 5", "STAB 6",
"POS HOLD", "COURSELOCK", "VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "POS HOLD", "COURSELOCK", "VEL ROAM", "HOME LEASH", "ABS POS", "RTB",
"LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"][flightStatus.flightMode]; "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"][flightStatus.flightMode];
} }

View File

@ -23,96 +23,98 @@ import QtQuick.Controls 1.4
import Pfd 1.0 import Pfd 1.0
import OsgQtQuick 1.0 import OsgQtQuick 1.0
import "../common.js" as Utils import "../js/common.js" as Utils
import "../uav.js" as UAV import "../js/uav.js" as UAV
OSGViewport { Item {
id: osgViewport OSGViewport {
id: osgViewport
anchors.fill: parent anchors.fill: parent
focus: true focus: true
sceneNode: skyNode sceneNode: skyNode
camera: camera camera: camera
manipulator: nodeTrackerManipulator manipulator: nodeTrackerManipulator
OSGCamera {
id: camera
fieldOfView: 90
logarithmicDepthBuffer: true
}
OSGNodeTrackerManipulator {
id: nodeTrackerManipulator
// use model to compute camera home position
sceneNode: modelTransformNode
// model will be tracked
trackNode: modelTransformNode
}
OSGSkyNode {
id: skyNode
sceneNode: sceneGroup
viewport: osgViewport
dateTime: Utils.getDateTime()
minimumAmbientLight: pfdContext.minimumAmbientLight
}
OSGGroup {
id: sceneGroup
children: [ terrainFileNode, modelNode ]
}
OSGGeoTransformNode {
id: modelNode
childNode: modelTransformNode
sceneNode: terrainFileNode
clampToTerrain: true
position: UAV.position()
}
OSGTransformNode {
id: modelTransformNode
childNode: modelFileNode
// model dimensions are in mm, scale to meters
scale: Qt.vector3d(0.001, 0.001, 0.001)
attitude: UAV.attitude()
}
OSGFileNode {
id: terrainFileNode
source: pfdContext.terrainFile
}
OSGFileNode {
id: modelFileNode
// use ShaderGen pseudoloader to generate the shaders expected by osgEarth
// see http://docs.osgearth.org/en/latest/faq.html#i-added-a-node-but-it-has-no-texture-lighting-etc-in-osgearth-why
source: pfdContext.modelFile + ".osgearth_shadergen"
optimizeMode: OptimizeMode.OptimizeAndCheck
}
Keys.onUpPressed: {
pfdContext.nextModel();
}
Keys.onDownPressed: {
pfdContext.previousModel();
}
BusyIndicator {
width: 24
height: 24
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 4
running: osgViewport.busy
}
OSGCamera {
id: camera
fieldOfView: 90
logarithmicDepthBuffer: true
} }
OSGNodeTrackerManipulator {
id: nodeTrackerManipulator
// use model to compute camera home position
sceneNode: modelTransformNode
// model will be tracked
trackNode: modelTransformNode
}
OSGSkyNode {
id: skyNode
sceneNode: sceneGroup
viewport: osgViewport
dateTime: Utils.getDateTime()
minimumAmbientLight: pfdContext.minimumAmbientLight
}
OSGGroup {
id: sceneGroup
children: [ terrainFileNode, modelNode ]
}
OSGGeoTransformNode {
id: modelNode
childNode: modelTransformNode
sceneNode: terrainFileNode
clampToTerrain: true
position: UAV.position()
}
OSGTransformNode {
id: modelTransformNode
childNode: modelFileNode
// model dimensions are in mm, scale to meters
scale: Qt.vector3d(0.001, 0.001, 0.001)
attitude: UAV.attitude()
}
OSGFileNode {
id: terrainFileNode
source: pfdContext.terrainFile
}
OSGFileNode {
id: modelFileNode
// use ShaderGen pseudoloader to generate the shaders expected by osgEarth
// see http://docs.osgearth.org/en/latest/faq.html#i-added-a-node-but-it-has-no-texture-lighting-etc-in-osgearth-why
source: pfdContext.modelFile + ".osgearth_shadergen"
optimizeMode: OptimizeMode.OptimizeAndCheck
}
Keys.onUpPressed: {
pfdContext.nextModel();
}
Keys.onDownPressed: {
pfdContext.previousModel();
}
BusyIndicator {
width: 24
height: 24
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 4
running: osgViewport.busy
}
} }

View File

@ -21,7 +21,7 @@ import QtQuick 2.4
import OsgQtQuick 1.0 import OsgQtQuick 1.0
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {

View File

@ -19,8 +19,8 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "../common.js" as Utils import "../js/common.js" as Utils
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: sceneItem id: sceneItem

View File

@ -19,7 +19,7 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: sceneItem id: sceneItem

View File

@ -19,8 +19,8 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "../common.js" as Utils import "../js/common.js" as Utils
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: info id: info

View File

@ -19,8 +19,8 @@
*/ */
import QtQuick 2.0 import QtQuick 2.0
import "../common.js" as Utils import "../js/common.js" as Utils
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: panels id: panels

View File

@ -19,7 +19,7 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: worldView id: worldView

View File

@ -22,8 +22,8 @@ import QtQuick 2.4
import Pfd 1.0 import Pfd 1.0
import OsgQtQuick 1.0 import OsgQtQuick 1.0
import "../common.js" as Utils import "../js/common.js" as Utils
import "../uav.js" as UAV import "../js/uav.js" as UAV
OSGViewport { OSGViewport {
id: osgViewport id: osgViewport
@ -31,10 +31,6 @@ OSGViewport {
//anchors.fill: parent //anchors.fill: parent
focus: true focus: true
sceneNode: skyNode
camera: camera
manipulator: geoTransformManipulator
readonly property real horizontCenter : horizontCenterItem.horizontCenter readonly property real horizontCenter : horizontCenterItem.horizontCenter
// Factor for OSGViewer vertical offset // Factor for OSGViewer vertical offset
@ -44,6 +40,10 @@ OSGViewport {
//height: height * (1 + factor) //height: height * (1 + factor)
y: -height * factor y: -height * factor
sceneNode: skyNode
camera: camera
manipulator: geoTransformManipulator
OSGCamera { OSGCamera {
id: camera id: camera
@ -90,7 +90,6 @@ OSGViewport {
property double pitch1DegHeight: sceneItem.height * pitch1DegScaledHeight property double pitch1DegHeight: sceneItem.height * pitch1DegScaledHeight
transform: [ transform: [
Translate { Translate {
id: pitchTranslate id: pitchTranslate

View File

@ -0,0 +1,126 @@
/*
* Copyright (C) 2016 The LibrePilot Project
* Contact: http://www.librepilot.org
*
* This file is part of LibrePilot GCS.
*
* LibrePilot GCS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LibrePilot GCS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LibrePilot GCS. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
Rectangle {
color: "#515151"
property string worldFile: "PfdSimpleWorld.qml"
SvgElementImage {
id: background
elementName: "pfd-window"
fillMode: Image.PreserveAspectFit
anchors.fill: parent
sceneSize: Qt.size(width, height)
Rectangle {
width: Math.floor(parent.paintedHeight * 1.319)
height: Math.floor(parent.paintedHeight - parent.paintedHeight * 0.008)
color: "transparent"
border.color: "white"
border.width: Math.floor(parent.paintedHeight * 0.008)
radius: Math.floor(parent.paintedHeight * 0.01)
anchors.centerIn: parent
}
Item {
id: sceneItem
FontLoader {
id: pt_bold
source: "qrc:/utils/fonts/PTS75F.ttf"
}
width: Math.floor((parent.paintedHeight * 1.32) - (parent.paintedHeight * 0.013))
height: Math.floor(parent.paintedHeight - parent.paintedHeight * 0.02)
property variant viewportSize : Qt.size(width, height)
anchors.centerIn: parent
clip: true
Loader {
id: worldLoader
anchors.fill: parent
focus: true
source: worldFile
}
HorizontCenter {
id: horizontCenterItem
sceneSize: sceneItem.viewportSize
anchors.fill: parent
}
RollScale {
id: rollscale
sceneSize: sceneItem.viewportSize
horizontCenter: horizontCenterItem.horizontCenter
anchors.fill: parent
}
SvgElementImage {
id: side_slip_fixed
elementName: "sideslip-fixed"
sceneSize: sceneItem.viewportSize
x: scaledBounds.x * sceneItem.width
}
Compass {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
SpeedScale {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
AltitudeScale {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
VsiScale {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
visible: pfdContext.altitudeUnit != 0
}
Info {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
Panels {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
Warnings {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
}
}
}

View File

@ -19,7 +19,7 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: sceneItem id: sceneItem

View File

@ -19,7 +19,7 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: sceneItem id: sceneItem

View File

@ -19,7 +19,7 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: sceneItem id: sceneItem

View File

@ -19,8 +19,8 @@
*/ */
import QtQuick 2.4 import QtQuick 2.4
import "../common.js" as Utils import "../js/common.js" as Utils
import "../uav.js" as UAV import "../js/uav.js" as UAV
Item { Item {
id: warnings id: warnings