Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnalyzeView: Fix MAVLinkChartInspector #11982

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions custom-example/qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<file alias="MapSettings.qml">../src/UI/preferences/MapSettings.qml</file>
<file alias="MAVLinkConsolePage.qml">../src/AnalyzeView/MAVLinkConsolePage.qml</file>
<file alias="MAVLinkInspectorPage.qml">../src/AnalyzeView/MAVLinkInspectorPage.qml</file>
<file alias="MAVLinkChart.qml">../src/AnalyzeView/MAVLinkChart.qml</file>
<file alias="MAVLinkMessageButton.qml">../src/AnalyzeView/MAVLinkMessageButton.qml</file>
<file alias="PX4LogTransferSettings.qml">../src/UI/preferences/PX4LogTransferSettings.qml</file>
<file alias="MissionSettingsEditor.qml">../src/PlanView/MissionSettingsEditor.qml</file>
<file alias="MotorComponent.qml">../src/AutoPilotPlugins/Common/MotorComponent.qml</file>
Expand Down Expand Up @@ -123,8 +125,6 @@
<file alias="QGroundControl/Controls/FlightModeMenuIndicator.qml">../src/UI/toolbar/FlightModeMenuIndicator.qml</file>
<file alias="QGroundControl/Controls/MainStatusIndicatorOfflinePage.qml">../src/UI/toolbar/MainStatusIndicatorOfflinePage.qml</file>
<file alias="QGroundControl/Controls/MainWindowSavedState.qml">../src/QmlControls/MainWindowSavedState.qml</file>
<file alias="QGroundControl/Controls/MAVLinkChart.qml">../src/QmlControls/MAVLinkChart.qml</file>
<file alias="QGroundControl/Controls/MAVLinkMessageButton.qml">../src/QmlControls/MAVLinkMessageButton.qml</file>
<file alias="QGroundControl/Controls/MissionCommandDialog.qml">../src/QmlControls/MissionCommandDialog.qml</file>
<file alias="QGroundControl/Controls/MissionItemEditor.qml">../src/PlanView/MissionItemEditor.qml</file>
<file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">../src/QmlControls/MissionItemIndexLabel.qml</file>
Expand Down
4 changes: 2 additions & 2 deletions qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<file alias="MapSettings.qml">src/UI/preferences/MapSettings.qml</file>
<file alias="MAVLinkConsolePage.qml">src/AnalyzeView/MAVLinkConsolePage.qml</file>
<file alias="MAVLinkInspectorPage.qml">src/AnalyzeView/MAVLinkInspectorPage.qml</file>
<file alias="MAVLinkChart.qml">src/AnalyzeView/MAVLinkChart.qml</file>
<file alias="MAVLinkMessageButton.qml">src/AnalyzeView/MAVLinkMessageButton.qml</file>
<file alias="PX4LogTransferSettings.qml">src/UI/preferences/PX4LogTransferSettings.qml</file>
<file alias="MissionSettingsEditor.qml">src/PlanView/MissionSettingsEditor.qml</file>
<file alias="MotorComponent.qml">src/AutoPilotPlugins/Common/MotorComponent.qml</file>
Expand Down Expand Up @@ -124,8 +126,6 @@
<file alias="QGroundControl/Controls/FlightModeMenuIndicator.qml">src/UI/toolbar/FlightModeMenuIndicator.qml</file>
<file alias="QGroundControl/Controls/MainStatusIndicatorOfflinePage.qml">src/UI/toolbar/MainStatusIndicatorOfflinePage.qml</file>
<file alias="QGroundControl/Controls/MainWindowSavedState.qml">src/QmlControls/MainWindowSavedState.qml</file>
<file alias="QGroundControl/Controls/MAVLinkChart.qml">src/QmlControls/MAVLinkChart.qml</file>
<file alias="QGroundControl/Controls/MAVLinkMessageButton.qml">src/QmlControls/MAVLinkMessageButton.qml</file>
<file alias="QGroundControl/Controls/MissionCommandDialog.qml">src/QmlControls/MissionCommandDialog.qml</file>
<file alias="QGroundControl/Controls/MissionItemEditor.qml">src/PlanView/MissionItemEditor.qml</file>
<file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">src/QmlControls/MissionItemIndexLabel.qml</file>
Expand Down
140 changes: 140 additions & 0 deletions src/AnalyzeView/MAVLinkChart.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtCharts

import QGroundControl
import QGroundControl.Palette
import QGroundControl.Controls
import QGroundControl.Controllers
import QGroundControl.ScreenTools

ChartView {
id: chartView
theme: ChartView.ChartThemeDark
antialiasing: true
animationOptions: ChartView.NoAnimation
legend.visible: false
backgroundColor: qgcPal.window
backgroundRoundness: 0
margins.bottom: ScreenTools.defaultFontPixelHeight * 1.5
margins.top: chartHeader.height + (ScreenTools.defaultFontPixelHeight * 2)

property var chartController: null
property var seriesColors: ["#00E04B","#DE8500","#F32836","#BFBFBF","#536DFF","#EECC44"]

function addDimension(field) {
if (!chartController) {
chartController = controller.createChart()
}

const color = chartView.seriesColors[chartView.count]
const serie = createSeries(ChartView.SeriesTypeLine, field.label)
serie.axisX = axisX
serie.axisY = axisY
serie.useOpenGL = true
serie.color = color
serie.width = 1
chartController.addSeries(field, serie)
}

function delDimension(field) {
if (chartController) {
chartView.removeSeries(field.series)
chartController.delSeries(field)
if (chartView.count === 0) {
controller.deleteChart(chartController)
chartController = null
}
}
}

QGCPalette { id: qgcPal; colorGroupEnabled: enabled }

DateTimeAxis {
id: axisX
min: chartController ? chartController.rangeXMin : new Date()
max: chartController ? chartController.rangeXMax : new Date()
visible: chartController
format: "<br/>mm:ss.zzz"
tickCount: 5
gridVisible: true
labelsFont.family: ScreenTools.fixedFontFamily
labelsFont.pointSize: ScreenTools.smallFontPointSize
labelsColor: qgcPal.text
}

ValueAxis {
id: axisY
min: chartController ? chartController.rangeYMin : 0
max: chartController ? chartController.rangeYMax : 0
visible: chartController
lineVisible: false
labelsFont.family: ScreenTools.fixedFontFamily
labelsFont.pointSize: ScreenTools.smallFontPointSize
labelsColor: qgcPal.text
}

Row {
id: chartHeader
anchors.left: parent.left
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 4
anchors.right: parent.right
anchors.rightMargin: ScreenTools.defaultFontPixelWidth * 4
anchors.top: parent.top
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 1.5
spacing: ScreenTools.defaultFontPixelWidth * 2
visible: chartController

GridLayout {
columns: 2
columnSpacing: ScreenTools.defaultFontPixelWidth
rowSpacing: ScreenTools.defaultFontPixelHeight * 0.25
anchors.verticalCenter: parent.verticalCenter

QGCLabel {
text: qsTr("Scale:");
Layout.alignment: Qt.AlignVCenter
}

QGCComboBox {
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 10
Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 10
Layout.alignment: Qt.AlignVCenter
height: ScreenTools.defaultFontPixelHeight
model: controller.timeScales
currentIndex: chartController ? chartController.rangeXIndex : 0
onActivated: (index) => { if(chartController) chartController.rangeXIndex = index; }
}

QGCLabel {
text: qsTr("Range:");
Layout.alignment: Qt.AlignVCenter
}

QGCComboBox {
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 10
Layout.maximumWidth: ScreenTools.defaultFontPixelWidth * 10
Layout.alignment: Qt.AlignVCenter
height: ScreenTools.defaultFontPixelHeight
model: controller.rangeList
currentIndex: chartController ? chartController.rangeYIndex : 0
onActivated: (index) => { if(chartController) chartController.rangeYIndex = index; }
}
}

ColumnLayout {
anchors.verticalCenter: parent.verticalCenter

Repeater {
model: chartController ? chartController.chartFields : []

QGCLabel {
text: modelData.label
color: chartView.series(index).color
font.pointSize: ScreenTools.smallFontPointSize
}
}
}
}
}
Loading
Loading