From ee936e8984057c3c8d72ccaea8e938c8a6c05aee Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Tue, 19 Oct 2021 14:21:12 -0400 Subject: [PATCH 01/10] TrackingSignalsTab - don't recreate series This is the first iteration of optimizing performance of the TrackingSignalsTab. Series' are created only once in QML, to associate them with the chart. Thereafter, the series' persist. Points are replaced and properties are set with each fill_all_series call - which occurs regularly as called by a timer from QML. The update mechanism remains unchanged. Legend seems broken with the changes I have put in here - despite my having attempted to accomodate it. --- .../TrackingSignalsTab.qml | 109 +++++++++------ swiftnav_console/tracking_signals_tab.py | 131 ++++++++++++------ 2 files changed, 157 insertions(+), 83 deletions(-) diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index e39ca5663..8d37f0412 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -9,10 +9,11 @@ import SwiftConsole 1.0 Item { id: trackingSignalsTab - property variant lines: [] - property variant labels: [] - property variant colors: [] - property variant check_labels: [] + // property variant lines: [] + // property variant labels: [] + // property variant colors: [] + property alias all_series: trackingSignalsPoints.all_series + property alias check_labels: trackingSignalsPoints.check_labels property variant check_visibility: [] width: parent.width @@ -74,7 +75,7 @@ Item { Repeater { id: lineLegendRepeaterRows - model: labels + model: all_series Row { Component.onCompleted: { @@ -88,6 +89,7 @@ Item { Rectangle { id: marker + color: model.color width: Constants.commonLegend.markerWidth height: Constants.commonLegend.markerHeight anchors.verticalCenter: parent.verticalCenter @@ -96,7 +98,7 @@ Item { Label { id: label - text: modelData + text: model.name font.pointSize: Constants.smallPointSize anchors.verticalCenter: parent.verticalCenter anchors.verticalCenterOffset: Constants.commonLegend.verticalCenterOffset @@ -162,41 +164,70 @@ Item { repeat: true onTriggered: { if (!trackingTab.visible) - return ; - - tracking_signals_model.fill_console_points(trackingSignalsPoints); - if (!trackingSignalsPoints.points.length) - return ; - - var points = trackingSignalsPoints.points; - colors = trackingSignalsPoints.colors; - labels = trackingSignalsPoints.labels; - trackingSignalsChart.visible = true; - check_labels = trackingSignalsPoints.check_labels; - for (var idx in labels) { - if (idx < lines.length) { - if (labels[idx] != lines[idx][1]) { - trackingSignalsChart.removeSeries(lines[idx][0]); - var line = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, labels[idx], trackingSignalsXAxis); - line.color = colors[idx]; - line.width = Constants.commonChart.lineWidth; - line.axisYRight = trackingSignalsYAxis; - line.useOpenGL = Globals.useOpenGL; - lines[idx] = [line, labels[idx]]; - } - } else { - var line = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, labels[idx], trackingSignalsXAxis); - line.color = colors[idx]; - line.width = Constants.commonChart.lineWidth; - line.axisYRight = trackingSignalsYAxis; - line.useOpenGL = Globals.useOpenGL; - lines.push([line, labels[idx]]); + return; + + if (trackingSignalsPoints.all_series.length < trackingSignalsPoints.num_labels) { + for (var i = trackingSignalsPoints.all_series.length; + i < trackingSignalsPoints.num_labels; i++) { + var series = trackingSignalsChart.createSeries( + ChartView.SeriesTypeLine, trackingSignalsPoints.getLabel(i), + trackingSignalsXAxis) + series.axisYRight = trackingSignalsYAxis + series.width = Constants.commonChart.lineWidth + // Color and useOpenGL will be set in Python with fill_all_series call. + // series.color = sourceSeries.color + // series.useOpenGL = sourceSeries.useOpenGL + trackingSignalsPoints.addSeries(series) } } - trackingSignalsPoints.fill_series(lines); - var last = points[0][points[0].length - 1]; - trackingSignalsXAxis.min = last.x + trackingSignalsPoints.xmin_offset; - trackingSignalsXAxis.max = last.x; + trackingSignalsPoints.fill_all_series(Constants.commonChart.lineWidth, + Globals.useOpenGL); + // for (var series_idx in missing_series_indices) { + // console.log("Creating new series " + sourceSeries.name) + // var series = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, + // sourceSeries.name, trackingSignalsXAxis) + // series.axisYRight = trackingSignalsYAxis + // series.color = sourceSeries.color + // series.width = Constants.commonChart.lineWidth + // series.useOpenGL = sourceSeries.useOpenGL + // } + // if (series_to_create.length > 0) { + // // Fill again to give all the newly created series' their data.. + // // Could probably just skip this step, since a short time later, another + // trackingSignalsPoints.fill_all_series(Constants.commonChart.lineWidth, + // trackingSignalsXAxis, trackingSignalsYAxis, Globals.useOpenGL); + // } + if (trackingSignalsPoints.all_series.length) { + trackingSignalsChart.visible = true; + trackingSignalsXAxis.min = trackingSignalsPoints.xaxis_min; // last.x + trackingSignalsPoints.xmin_offset; + trackingSignalsXAxis.max = trackingSignalsPoints.xaxis_max; // last.x; + } + + // var all_series = trackingSignalsPoints.all_series; + // colors = trackingSignalsPoints.colors; + // labels = trackingSignalsPoints.labels; + // for (var idx in labels) { + // if (idx < lines.length) { + // if (labels[idx] != lines[idx][1]) { + // series = all_series[idx] + // var line = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, labels[idx], trackingSignalsXAxis); + // line.color = colors[idx]; + // line.width = Constants.commonChart.lineWidth; + // line.axisYRight = trackingSignalsYAxis; + // line.useOpenGL = Globals.useOpenGL; + // // lines[idx] = [line, labels[idx]]; + // } + // } else { + // var line = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, labels[idx], trackingSignalsXAxis); + // line.color = colors[idx]; + // line.width = Constants.commonChart.lineWidth; + // line.axisYRight = trackingSignalsYAxis; + // line.useOpenGL = Globals.useOpenGL; + // // lines.push([line, labels[idx]]); + // } + // } + // trackingSignalsPoints.fill_series(lines); + // var last = points[0][points[0].length - 1]; } } diff --git a/swiftnav_console/tracking_signals_tab.py b/swiftnav_console/tracking_signals_tab.py index d2737980e..c744ad1bf 100644 --- a/swiftnav_console/tracking_signals_tab.py +++ b/swiftnav_console/tracking_signals_tab.py @@ -3,7 +3,8 @@ from typing import Dict, List, Any -from PySide2.QtCore import Property, QObject, QPointF, Slot +from PySide2.QtCore import Property, QObject, Slot +from PySide2.QtCharts import QtCharts from .constants import Keys, QTKeys @@ -19,66 +20,108 @@ class TrackingSignalsPoints(QObject): - _colors: List[str] = [] _check_labels: List[str] = [] - _labels: List[str] = [] - _points: List[List[QPointF]] = [[]] - _xmin_offset: float = 0.0 + _all_series: List[QtCharts.QXYSeries] = [] + _xaxis_min: float = 0.0 + _xaxis_max: float = 0.0 - def get_xmin_offset(self) -> float: - """Getter for _xmin_offset.""" - return self._xmin_offset + # def get_xmin_offset(self) -> float: + # """Getter for _xmin_offset.""" + # return self._xmin_offset - def set_xmin_offset(self, xmin_offset_: float) -> None: - """Setter for _xmin_offset.""" - self._xmin_offset = xmin_offset_ + # def set_xmin_offset(self, xmin_offset_: float) -> None: + # """Setter for _xmin_offset.""" + # self._xmin_offset = xmin_offset_ - xmin_offset = Property(float, get_xmin_offset, set_xmin_offset) + # xmin_offset = Property(float, get_xmin_offset, set_xmin_offset) - def get_check_labels(self) -> List[str]: - return self._check_labels - - def set_check_labels(self, check_labels) -> None: - self._check_labels = check_labels - - check_labels = Property(QTKeys.QVARIANTLIST, get_check_labels, set_check_labels) # type: ignore - - def get_labels(self) -> List[str]: - return self._labels + def get_num_labels(self) -> int: + return len(TRACKING_SIGNALS_TAB[Keys.LABELS]) - def set_labels(self, labels) -> None: - self._labels = labels + num_labels = Property(int, get_num_labels) - labels = Property(QTKeys.QVARIANTLIST, get_labels, set_labels) # type: ignore + def get_xaxis_min(self) -> float: + """Getter for _xaxis_min.""" + return self._xaxis_min - def get_colors(self) -> List[str]: - return self._colors + xaxis_min = Property(float, get_xaxis_min) - def set_colors(self, colors) -> None: - self._colors = colors + def get_xaxis_max(self) -> float: + """Getter for _xaxis_max.""" + return self._xaxis_max - colors = Property(QTKeys.QVARIANTLIST, get_colors, set_colors) # type: ignore + xaxis_max = Property(float, get_xaxis_max) - def get_points(self) -> List[List[QPointF]]: - return self._points - - def set_points(self, points) -> None: - self._points = points - - points = Property(QTKeys.QVARIANTLIST, get_points, set_points) # type: ignore + def get_check_labels(self) -> List[str]: + return self._check_labels - @Slot(list) # type: ignore - def fill_series(self, series_list): - for idx, series_and_key in enumerate(series_list): - series, _ = series_and_key - if idx < len(self._points): - series.replace(self._points[idx]) + check_labels = Property(QTKeys.QVARIANTLIST, get_check_labels) # type: ignore + + def get_all_series(self) -> List[QtCharts.QXYSeries]: + return self._all_series + + all_series = Property(QTKeys.QVARIANTLIST, get_all_series) # type: ignore + + @Slot(int) # type: ignore + def getLabel(self, index) -> str: + """Getter for one of the TRACKING_SIGNALS_TAB[Keys.LABELS].""" + return TRACKING_SIGNALS_TAB[Keys.LABELS][index] + + @Slot(QtCharts.QAbstractSeries) # type: ignore + def addSeries(self, series) -> None: + """Add a QML created series to the all_series list""" + self._all_series.append(series) + + @Slot(float, bool) # type: ignore + def fill_all_series(self, line_width, useOpenGL) -> None: + points_for_all_series = TRACKING_SIGNALS_TAB[Keys.POINTS] + # missing_series_indices: List[int] = [] # need to pass up the name too... + if len(points_for_all_series) == 0: + return # missing_series_indices + + labels = TRACKING_SIGNALS_TAB[Keys.LABELS] + colors = TRACKING_SIGNALS_TAB[Keys.COLORS] + self._check_labels = TRACKING_SIGNALS_TAB[Keys.CHECK_LABELS] + self._xaxis_min = points_for_all_series[0][-1].x() + TRACKING_SIGNALS_TAB[Keys.XMIN_OFFSET] + self._xaxis_max = points_for_all_series[0][-1].x() + for idx, series_points in enumerate(points_for_all_series): + series = None + try: + series = self._all_series[idx] + series.replace(series_points) + series.setName(labels[idx]) + series.setColor(colors[idx]) + pen = series.pen() + pen.setWidthF(line_width) + series.setPen(pen) + series.setUseOpenGL(useOpenGL) + except IndexError: + # The current problem is that the series' that are being updated with the points are not the same series that are attached to the chart.. + # Need to get the QML created charts added into the python _all_series list. + # Probably want to return a sparse array or a dictionary mapping missing series index and series data to create. + # Though it might be enough to just shoot back a list of indices that need series' created - and a generic series can be created for those, + # which will be updated with real properties and data on the next timer fire. + print(f"fill_all_series IndexError for idx {idx}") + # Need to build up a return value that tells QML which series' to create. + # missing_series_indices.append(idx) + # series = QtCharts.QLineSeries() + # return_series.append(series) + # series.append(series_points) + # self._all_series.append(series) + return # missing_series_indices + + # @Slot(list) # type: ignore + # def fill_series(self, series_list): + # for idx, series_and_key in enumerate(series_list): + # series, _ = series_and_key + # if idx < len(self._points): + # series.replace(self._points[idx]) class TrackingSignalsModel(QObject): # pylint: disable=too-few-public-methods @Slot(TrackingSignalsPoints) # type: ignore def fill_console_points(self, cp: TrackingSignalsPoints) -> TrackingSignalsPoints: # pylint:disable=no-self-use - cp.set_points(TRACKING_SIGNALS_TAB[Keys.POINTS]) + cp.fill_all_series(TRACKING_SIGNALS_TAB[Keys.POINTS]) cp.set_labels(TRACKING_SIGNALS_TAB[Keys.LABELS]) cp.set_check_labels(TRACKING_SIGNALS_TAB[Keys.CHECK_LABELS]) cp.set_colors(TRACKING_SIGNALS_TAB[Keys.COLORS]) From 6a04bab976481d80e6428e63a663333a46a9202c Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Mon, 25 Oct 2021 15:13:46 -0400 Subject: [PATCH 02/10] New TrackingSignalsTab legend implementation, show it * This fixes my prior changes so the Tracking Signals tab legend actually shows (make an all_series changed notify signal, and emit it when the series changes, so the legend knows when to update. * This reimplements the legend so it looks nicer, based on guidelines from Jason. Maximum two column and scrolling when things don't fit. * Legend can be moved around the chart (drag title bar) * Legend can be hidden to show chart more clearly (click title bar) Rebase: Chart is not filling properly... --- resources/Constants/Constants.qml | 5 +- .../TrackingSignalsTab.qml | 238 +++++++++++------- swiftnav_console/tracking_signals_tab.py | 7 +- 3 files changed, 154 insertions(+), 96 deletions(-) diff --git a/resources/Constants/Constants.qml b/resources/Constants/Constants.qml index 21afe2632..658fdb471 100644 --- a/resources/Constants/Constants.qml +++ b/resources/Constants/Constants.qml @@ -500,8 +500,9 @@ QtObject { readonly property string title: "Tracking C/N0" readonly property color titleColor: "#00006E" readonly property int titlePointSize: 14 - readonly property int legendBottomMargin: 85 - readonly property int legendLeftMargin: 60 + readonly property int legendTopMargin: 30 + readonly property int legendBottomMargin: 75 + readonly property int legendLeftMargin: 30 readonly property int legendLabelPointSize: 6 readonly property string yAxisTitleText: "dB-Hz" readonly property string xAxisTitleText: "seconds" diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index 8d37f0412..a3893a656 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -1,17 +1,14 @@ import "../BaseComponents" import "../Constants" import QtCharts 2.3 -import QtQuick 2.6 -import QtQuick.Controls 2.15 +import QtQuick 2.15 +import QtQuick.Controls 2.12 import QtQuick.Layouts 1.15 import SwiftConsole 1.0 Item { id: trackingSignalsTab - // property variant lines: [] - // property variant labels: [] - // property variant colors: [] property alias all_series: trackingSignalsPoints.all_series property alias check_labels: trackingSignalsPoints.check_labels property variant check_visibility: [] @@ -41,8 +38,8 @@ Item { visible: false title: Constants.trackingSignals.title titleColor: Constants.trackingSignals.titleColor - width: parent.width - height: parent.height - trackingSignalsCheckboxes.height + //width: parent.width + //height: parent.height - trackingSignalsCheckboxes.height backgroundColor: Constants.commonChart.backgroundColor plotAreaColor: Constants.commonChart.areaColor legend.visible: false @@ -58,55 +55,157 @@ Item { Rectangle { id: lineLegend + property int openedHeight: parent.height - Constants.trackingSignals.legendTopMargin - Constants.trackingSignals.legendBottomMargin + property int openCloseSpeed: 350 + + visible: false + radius: 5 border.color: Constants.commonLegend.borderColor border.width: Constants.commonLegend.borderWidth - anchors.bottom: trackingSignalsChart.bottom - anchors.left: trackingSignalsChart.left - anchors.bottomMargin: Constants.trackingSignals.legendBottomMargin - anchors.leftMargin: Constants.trackingSignals.legendLeftMargin - implicitHeight: lineLegendRepeater.height - width: lineLegendRepeater.width + x: Constants.trackingSignals.legendTopMargin + y: Constants.trackingSignals.legendLeftMargin + height: openedHeight + state: "opened" + states: [ + State { + name: "opened" + + PropertyChanges { + target: lineLegend + height: lineLegend.openedHeight + } - Column { - id: lineLegendRepeater + PropertyChanges { + target: gridView + visible: true + } - anchors.bottom: lineLegend.bottom + }, + State { + name: "closed" - Repeater { - id: lineLegendRepeaterRows + PropertyChanges { + target: lineLegend + height: legendHideBar.height + 2 + } - model: all_series + PropertyChanges { + target: gridView + visible: false + } - Row { - Component.onCompleted: { - for (var idx in colors) { - if (lineLegendRepeaterRows.itemAt(idx)) - lineLegendRepeaterRows.itemAt(idx).children[0].color = colors[idx]; + } + ] + transitions: [ + Transition { + to: "closed" + + // reversible property should be what we want here instead of duplicating this, + // but it doesn't seem to work right in this situation. + SequentialAnimation { + SmoothedAnimation { + property: "height" + duration: lineLegend.openCloseSpeed + } - } + PropertyAction { + property: "visible" } - Rectangle { - id: marker + } - color: model.color - width: Constants.commonLegend.markerWidth - height: Constants.commonLegend.markerHeight - anchors.verticalCenter: parent.verticalCenter - } + }, + Transition { + to: "opened" - Label { - id: label + SequentialAnimation { + PropertyAction { + property: "visible" + } - text: model.name - font.pointSize: Constants.smallPointSize - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: Constants.commonLegend.verticalCenterOffset + SmoothedAnimation { + property: "height" + duration: lineLegend.openCloseSpeed } } } + ] + + Rectangle { + id: legendHideBar + + color: "dark grey" + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.topMargin: 1 + height: 10 + radius: lineLegend.radius + + MouseArea { + anchors.fill: parent + onClicked: { + lineLegend.state = lineLegend.state == "opened" ? "closed" : "opened"; + } + cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor + drag.target: lineLegend + hoverEnabled: true + } + + } + + GridView { + id: gridView + + anchors.top: legendHideBar.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + clip: true + model: all_series + flow: GridView.FlowTopToBottom + cellWidth: 10 + cellHeight: 10 + boundsBehavior: Flickable.StopAtBounds + onCellWidthChanged: { + lineLegend.width = cellWidth * 2; + } + + delegate: Row { + padding: 4 + Component.onCompleted: { + if (gridView.cellWidth < implicitWidth) + gridView.cellWidth = implicitWidth; + + if (gridView.cellHeight < implicitHeight) + gridView.cellHeight = implicitHeight; + + if (lineLegend.visible != true && gridView.cellWidth > 50) + lineLegend.visible = true; + + } + + Rectangle { + id: marker + + color: modelData.color + width: Constants.commonLegend.markerWidth + height: Constants.commonLegend.markerHeight + anchors.verticalCenter: parent.verticalCenter + } + + Label { + id: label + + text: modelData.name + font.pointSize: Constants.smallPointSize + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: Constants.commonLegend.verticalCenterOffset + } + + } } @@ -164,70 +263,25 @@ Item { repeat: true onTriggered: { if (!trackingTab.visible) - return; + return ; if (trackingSignalsPoints.all_series.length < trackingSignalsPoints.num_labels) { - for (var i = trackingSignalsPoints.all_series.length; - i < trackingSignalsPoints.num_labels; i++) { - var series = trackingSignalsChart.createSeries( - ChartView.SeriesTypeLine, trackingSignalsPoints.getLabel(i), - trackingSignalsXAxis) - series.axisYRight = trackingSignalsYAxis - series.width = Constants.commonChart.lineWidth + for (var i = trackingSignalsPoints.all_series.length; i < trackingSignalsPoints.num_labels; i++) { + var series = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, trackingSignalsPoints.getLabel(i), trackingSignalsXAxis); + series.axisYRight = trackingSignalsYAxis; + series.width = Constants.commonChart.lineWidth; // Color and useOpenGL will be set in Python with fill_all_series call. // series.color = sourceSeries.color // series.useOpenGL = sourceSeries.useOpenGL - trackingSignalsPoints.addSeries(series) + trackingSignalsPoints.addSeries(series); } } - trackingSignalsPoints.fill_all_series(Constants.commonChart.lineWidth, - Globals.useOpenGL); - // for (var series_idx in missing_series_indices) { - // console.log("Creating new series " + sourceSeries.name) - // var series = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, - // sourceSeries.name, trackingSignalsXAxis) - // series.axisYRight = trackingSignalsYAxis - // series.color = sourceSeries.color - // series.width = Constants.commonChart.lineWidth - // series.useOpenGL = sourceSeries.useOpenGL - // } - // if (series_to_create.length > 0) { - // // Fill again to give all the newly created series' their data.. - // // Could probably just skip this step, since a short time later, another - // trackingSignalsPoints.fill_all_series(Constants.commonChart.lineWidth, - // trackingSignalsXAxis, trackingSignalsYAxis, Globals.useOpenGL); - // } + trackingSignalsPoints.fill_all_series(Constants.commonChart.lineWidth, Globals.useOpenGL); if (trackingSignalsPoints.all_series.length) { trackingSignalsChart.visible = true; - trackingSignalsXAxis.min = trackingSignalsPoints.xaxis_min; // last.x + trackingSignalsPoints.xmin_offset; - trackingSignalsXAxis.max = trackingSignalsPoints.xaxis_max; // last.x; + trackingSignalsXAxis.min = trackingSignalsPoints.xaxis_min; + trackingSignalsXAxis.max = trackingSignalsPoints.xaxis_max; } - - // var all_series = trackingSignalsPoints.all_series; - // colors = trackingSignalsPoints.colors; - // labels = trackingSignalsPoints.labels; - // for (var idx in labels) { - // if (idx < lines.length) { - // if (labels[idx] != lines[idx][1]) { - // series = all_series[idx] - // var line = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, labels[idx], trackingSignalsXAxis); - // line.color = colors[idx]; - // line.width = Constants.commonChart.lineWidth; - // line.axisYRight = trackingSignalsYAxis; - // line.useOpenGL = Globals.useOpenGL; - // // lines[idx] = [line, labels[idx]]; - // } - // } else { - // var line = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, labels[idx], trackingSignalsXAxis); - // line.color = colors[idx]; - // line.width = Constants.commonChart.lineWidth; - // line.axisYRight = trackingSignalsYAxis; - // line.useOpenGL = Globals.useOpenGL; - // // lines.push([line, labels[idx]]); - // } - // } - // trackingSignalsPoints.fill_series(lines); - // var last = points[0][points[0].length - 1]; } } diff --git a/swiftnav_console/tracking_signals_tab.py b/swiftnav_console/tracking_signals_tab.py index c744ad1bf..0af990a54 100644 --- a/swiftnav_console/tracking_signals_tab.py +++ b/swiftnav_console/tracking_signals_tab.py @@ -3,7 +3,7 @@ from typing import Dict, List, Any -from PySide2.QtCore import Property, QObject, Slot +from PySide2.QtCore import Property, QObject, Signal, Slot from PySide2.QtCharts import QtCharts from .constants import Keys, QTKeys @@ -24,6 +24,7 @@ class TrackingSignalsPoints(QObject): _all_series: List[QtCharts.QXYSeries] = [] _xaxis_min: float = 0.0 _xaxis_max: float = 0.0 + all_series_changed = Signal() # def get_xmin_offset(self) -> float: # """Getter for _xmin_offset.""" @@ -60,7 +61,7 @@ def get_check_labels(self) -> List[str]: def get_all_series(self) -> List[QtCharts.QXYSeries]: return self._all_series - all_series = Property(QTKeys.QVARIANTLIST, get_all_series) # type: ignore + all_series = Property(QTKeys.QVARIANTLIST, get_all_series, notify=all_series_changed) # type: ignore @Slot(int) # type: ignore def getLabel(self, index) -> str: @@ -71,6 +72,7 @@ def getLabel(self, index) -> str: def addSeries(self, series) -> None: """Add a QML created series to the all_series list""" self._all_series.append(series) + self.all_series_changed.emit() @Slot(float, bool) # type: ignore def fill_all_series(self, line_width, useOpenGL) -> None: @@ -95,6 +97,7 @@ def fill_all_series(self, line_width, useOpenGL) -> None: pen.setWidthF(line_width) series.setPen(pen) series.setUseOpenGL(useOpenGL) + self.all_series_changed.emit() except IndexError: # The current problem is that the series' that are being updated with the points are not the same series that are attached to the chart.. # Need to get the QML created charts added into the python _all_series list. From 3da5cc1ae51265dbe13175be7cad503e51ce2ce5 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Mon, 25 Oct 2021 16:07:13 -0400 Subject: [PATCH 03/10] This fixes legend showing in TrackingSignalsTab --- resources/TrackingTabComponents/TrackingSignalsTab.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index a3893a656..8f54ae5e5 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -174,8 +174,10 @@ Item { } delegate: Row { - padding: 4 - Component.onCompleted: { + padding: 1 + leftPadding: 4 + rightPadding: leftPadding + onImplicitWidthChanged: { if (gridView.cellWidth < implicitWidth) gridView.cellWidth = implicitWidth; From 90059fb8bf33f39789381089014732f5dc4f4976 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Mon, 25 Oct 2021 21:12:33 -0400 Subject: [PATCH 04/10] Fix formatting issues, clarify IndexError exception * Fix formatting issues * Clarify that IndexError is expected in fill_all_series --- swiftnav_console/tracking_signals_tab.py | 51 ++++++------------------ 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/swiftnav_console/tracking_signals_tab.py b/swiftnav_console/tracking_signals_tab.py index 0af990a54..45111c0cf 100644 --- a/swiftnav_console/tracking_signals_tab.py +++ b/swiftnav_console/tracking_signals_tab.py @@ -26,32 +26,22 @@ class TrackingSignalsPoints(QObject): _xaxis_max: float = 0.0 all_series_changed = Signal() - # def get_xmin_offset(self) -> float: - # """Getter for _xmin_offset.""" - # return self._xmin_offset - - # def set_xmin_offset(self, xmin_offset_: float) -> None: - # """Setter for _xmin_offset.""" - # self._xmin_offset = xmin_offset_ - - # xmin_offset = Property(float, get_xmin_offset, set_xmin_offset) - - def get_num_labels(self) -> int: + def get_num_labels(self) -> int: # pylint:disable=no-self-use return len(TRACKING_SIGNALS_TAB[Keys.LABELS]) - num_labels = Property(int, get_num_labels) + num_labels = Property(int, get_num_labels) # type: ignore def get_xaxis_min(self) -> float: """Getter for _xaxis_min.""" return self._xaxis_min - xaxis_min = Property(float, get_xaxis_min) + xaxis_min = Property(float, get_xaxis_min) # type: ignore def get_xaxis_max(self) -> float: """Getter for _xaxis_max.""" return self._xaxis_max - xaxis_max = Property(float, get_xaxis_max) + xaxis_max = Property(float, get_xaxis_max) # type: ignore def get_check_labels(self) -> List[str]: return self._check_labels @@ -64,7 +54,7 @@ def get_all_series(self) -> List[QtCharts.QXYSeries]: all_series = Property(QTKeys.QVARIANTLIST, get_all_series, notify=all_series_changed) # type: ignore @Slot(int) # type: ignore - def getLabel(self, index) -> str: + def getLabel(self, index) -> str: # pylint:disable=no-self-use """Getter for one of the TRACKING_SIGNALS_TAB[Keys.LABELS].""" return TRACKING_SIGNALS_TAB[Keys.LABELS][index] @@ -72,14 +62,13 @@ def getLabel(self, index) -> str: def addSeries(self, series) -> None: """Add a QML created series to the all_series list""" self._all_series.append(series) - self.all_series_changed.emit() + self.all_series_changed.emit() # type: ignore @Slot(float, bool) # type: ignore def fill_all_series(self, line_width, useOpenGL) -> None: points_for_all_series = TRACKING_SIGNALS_TAB[Keys.POINTS] - # missing_series_indices: List[int] = [] # need to pass up the name too... if len(points_for_all_series) == 0: - return # missing_series_indices + return labels = TRACKING_SIGNALS_TAB[Keys.LABELS] colors = TRACKING_SIGNALS_TAB[Keys.COLORS] @@ -97,28 +86,12 @@ def fill_all_series(self, line_width, useOpenGL) -> None: pen.setWidthF(line_width) series.setPen(pen) series.setUseOpenGL(useOpenGL) - self.all_series_changed.emit() + self.all_series_changed.emit() # type: ignore except IndexError: - # The current problem is that the series' that are being updated with the points are not the same series that are attached to the chart.. - # Need to get the QML created charts added into the python _all_series list. - # Probably want to return a sparse array or a dictionary mapping missing series index and series data to create. - # Though it might be enough to just shoot back a list of indices that need series' created - and a generic series can be created for those, - # which will be updated with real properties and data on the next timer fire. - print(f"fill_all_series IndexError for idx {idx}") - # Need to build up a return value that tells QML which series' to create. - # missing_series_indices.append(idx) - # series = QtCharts.QLineSeries() - # return_series.append(series) - # series.append(series_points) - # self._all_series.append(series) - return # missing_series_indices - - # @Slot(list) # type: ignore - # def fill_series(self, series_list): - # for idx, series_and_key in enumerate(series_list): - # series, _ = series_and_key - # if idx < len(self._points): - # series.replace(self._points[idx]) + # This is ok - QML will create these series, and call addSeries, and these will be + # updated in the next timer fire/update. + pass + return class TrackingSignalsModel(QObject): # pylint: disable=too-few-public-methods From 232c959ea254464314a6d7ec50517e3f748499f0 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Wed, 27 Oct 2021 09:08:00 -0400 Subject: [PATCH 05/10] Add notify signal to check_labels property and others * This adds a notify property to all of the properties in the TrackingSignalsPoints object that did not have it. The lack of the notify property was preventing QML from seeing the changes in those properties, and thus the checkboxes were not being populated in the UI. * Instead of putting the chart and checkboxes in a Rectangle with anchoring, instead use a ColumnLayout. No need for the container to be visible, and it's better if it manages the height of the children. --- .../TrackingSignalsTab.qml | 6 +---- swiftnav_console/tracking_signals_tab.py | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index 8f54ae5e5..4bdb733eb 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -25,9 +25,7 @@ Item { ColumnLayout { id: trackingSignalsArea - width: parent.width - height: parent.height - spacing: 0 + anchors.fill: parent ChartView { id: trackingSignalsChart @@ -38,8 +36,6 @@ Item { visible: false title: Constants.trackingSignals.title titleColor: Constants.trackingSignals.titleColor - //width: parent.width - //height: parent.height - trackingSignalsCheckboxes.height backgroundColor: Constants.commonChart.backgroundColor plotAreaColor: Constants.commonChart.areaColor legend.visible: false diff --git a/swiftnav_console/tracking_signals_tab.py b/swiftnav_console/tracking_signals_tab.py index 45111c0cf..7b3886350 100644 --- a/swiftnav_console/tracking_signals_tab.py +++ b/swiftnav_console/tracking_signals_tab.py @@ -20,33 +20,38 @@ class TrackingSignalsPoints(QObject): - _check_labels: List[str] = [] - _all_series: List[QtCharts.QXYSeries] = [] + _num_labels: int = 0 _xaxis_min: float = 0.0 _xaxis_max: float = 0.0 + _check_labels: List[str] = [] + _all_series: List[QtCharts.QXYSeries] = [] + num_labels_changed = Signal(int, arguments="num_labels") + xaxis_min_changed = Signal() + xaxis_max_changed = Signal() + check_labels_changed = Signal() all_series_changed = Signal() def get_num_labels(self) -> int: # pylint:disable=no-self-use return len(TRACKING_SIGNALS_TAB[Keys.LABELS]) - num_labels = Property(int, get_num_labels) # type: ignore + num_labels = Property(int, get_num_labels, notify=num_labels_changed) # type: ignore def get_xaxis_min(self) -> float: """Getter for _xaxis_min.""" return self._xaxis_min - xaxis_min = Property(float, get_xaxis_min) # type: ignore + xaxis_min = Property(float, get_xaxis_min, notify=xaxis_min_changed) # type: ignore def get_xaxis_max(self) -> float: """Getter for _xaxis_max.""" return self._xaxis_max - xaxis_max = Property(float, get_xaxis_max) # type: ignore + xaxis_max = Property(float, get_xaxis_max, notify=xaxis_max_changed) # type: ignore def get_check_labels(self) -> List[str]: return self._check_labels - check_labels = Property(QTKeys.QVARIANTLIST, get_check_labels) # type: ignore + check_labels = Property(QTKeys.QVARIANTLIST, get_check_labels, notify=check_labels_changed) # type: ignore def get_all_series(self) -> List[QtCharts.QXYSeries]: return self._all_series @@ -66,6 +71,10 @@ def addSeries(self, series) -> None: @Slot(float, bool) # type: ignore def fill_all_series(self, line_width, useOpenGL) -> None: + cur_num_labels = len(TRACKING_SIGNALS_TAB[Keys.LABELS]) + if self._num_labels != cur_num_labels: + self._num_labels = cur_num_labels + self.num_labels_changed.emit(cur_num_labels) # type: ignore points_for_all_series = TRACKING_SIGNALS_TAB[Keys.POINTS] if len(points_for_all_series) == 0: return @@ -73,8 +82,11 @@ def fill_all_series(self, line_width, useOpenGL) -> None: labels = TRACKING_SIGNALS_TAB[Keys.LABELS] colors = TRACKING_SIGNALS_TAB[Keys.COLORS] self._check_labels = TRACKING_SIGNALS_TAB[Keys.CHECK_LABELS] + self.check_labels_changed.emit() # type: ignore self._xaxis_min = points_for_all_series[0][-1].x() + TRACKING_SIGNALS_TAB[Keys.XMIN_OFFSET] + self.xaxis_min_changed.emit() # type: ignore self._xaxis_max = points_for_all_series[0][-1].x() + self.xaxis_max_changed.emit() # type: ignore for idx, series_points in enumerate(points_for_all_series): series = None try: From 75a9e5518ff870b93982c48464417c513a9882a1 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Wed, 27 Oct 2021 09:12:10 -0400 Subject: [PATCH 06/10] Make the legend borderline nicer --- resources/Constants/Constants.qml | 2 +- .../TrackingTabComponents/TrackingSignalsTab.qml | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/resources/Constants/Constants.qml b/resources/Constants/Constants.qml index 658fdb471..15c731988 100644 --- a/resources/Constants/Constants.qml +++ b/resources/Constants/Constants.qml @@ -450,7 +450,7 @@ QtObject { readonly property int padding: 10 readonly property int spacing: 5 readonly property int verticalCenterOffset: -1 - readonly property color borderColor: "#000000" + readonly property color borderColor: "#7F7F7F" readonly property int borderWidth: 1 } diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index 4bdb733eb..489005ba4 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -56,8 +56,6 @@ Item { visible: false radius: 5 - border.color: Constants.commonLegend.borderColor - border.width: Constants.commonLegend.borderWidth x: Constants.trackingSignals.legendTopMargin y: Constants.trackingSignals.legendLeftMargin height: openedHeight @@ -129,6 +127,15 @@ Item { } ] + Rectangle { + anchors.fill: parent + z: 2 + color: "transparent" + radius: parent.radius + border.color: Constants.commonLegend.borderColor + border.width: Constants.commonLegend.borderWidth + } + Rectangle { id: legendHideBar From 0b9ac1e6520529504e989ea151e347a295fa38b5 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Wed, 27 Oct 2021 20:20:00 -0400 Subject: [PATCH 07/10] Legend sizing improvements and removal fixes * Cell width and height is now not dynamically calculated per cell, but based off reference cell contents, reducing complexity. * Legend now resizes as small as it can to the number of series elements. * Still keeps maximum of 2 columns, scrollable beyond that. --- resources/Constants/Constants.qml | 5 ++- .../TrackingSignalsTab.qml | 40 +++++++++---------- swiftnav_console/tracking_signals_tab.py | 22 +++++++++- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/resources/Constants/Constants.qml b/resources/Constants/Constants.qml index 15c731988..3261fcf98 100644 --- a/resources/Constants/Constants.qml +++ b/resources/Constants/Constants.qml @@ -43,6 +43,7 @@ QtObject { readonly property int staticTableTimerIntervalRate: 10 // 10 Hz readonly property int staticTimerSlowIntervalRate: 2 // 2 Hz readonly property string monoSpaceFont: "Courier New" + readonly property string fontFamily: "Roboto" readonly property real smallPointSize: 7 readonly property real mediumPointSize: 8 readonly property real largePointSize: 9 @@ -501,9 +502,11 @@ QtObject { readonly property color titleColor: "#00006E" readonly property int titlePointSize: 14 readonly property int legendTopMargin: 30 - readonly property int legendBottomMargin: 75 + readonly property int legendBottomMargin: 74 readonly property int legendLeftMargin: 30 readonly property int legendLabelPointSize: 6 + readonly property string legendCellTextSample: "XXX XXXX X+NN XNN" + readonly property int legendShadeSpeed: 350 readonly property string yAxisTitleText: "dB-Hz" readonly property string xAxisTitleText: "seconds" readonly property int xAxisMinOffsetFromMaxSeconds: 100 diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index 489005ba4..a93d0a036 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -2,7 +2,7 @@ import "../BaseComponents" import "../Constants" import QtCharts 2.3 import QtQuick 2.15 -import QtQuick.Controls 2.12 +import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import SwiftConsole 1.0 @@ -10,6 +10,7 @@ Item { id: trackingSignalsTab property alias all_series: trackingSignalsPoints.all_series + property alias enabled_series: trackingSignalsPoints.enabled_series property alias check_labels: trackingSignalsPoints.check_labels property variant check_visibility: [] @@ -51,14 +52,18 @@ Item { Rectangle { id: lineLegend - property int openedHeight: parent.height - Constants.trackingSignals.legendTopMargin - Constants.trackingSignals.legendBottomMargin - property int openCloseSpeed: 350 + property int maximumHeight: parent.height - Constants.trackingSignals.legendTopMargin - Constants.trackingSignals.legendBottomMargin + property int openedHeight: gridView.count < maxCellsPerColumn ? gridView.cellHeight * gridView.count : maximumHeight + property int openCloseSpeed: Constants.trackingSignals.legendShadeSpeed + property int maxCellsPerColumn: maximumHeight / gridView.cellHeight // floor/truncation is desired. - visible: false + visible: gridView.count > 0 radius: 5 x: Constants.trackingSignals.legendTopMargin y: Constants.trackingSignals.legendLeftMargin height: openedHeight + // Size to two cols if there are cells for 2+ cols. + width: gridView.cellWidth * (gridView.count <= maxCellsPerColumn ? 1 : 2) state: "opened" states: [ State { @@ -167,30 +172,23 @@ Item { anchors.right: parent.right anchors.bottom: parent.bottom clip: true - model: all_series + model: enabled_series flow: GridView.FlowTopToBottom - cellWidth: 10 - cellHeight: 10 + cellWidth: Constants.commonLegend.markerWidth + legendTextMetrics.width + 4 + cellHeight: legendTextMetrics.height + 2 boundsBehavior: Flickable.StopAtBounds - onCellWidthChanged: { - lineLegend.width = cellWidth * 2; + + TextMetrics { + id: legendTextMetrics + font.family: Constants.fontFamily + font.pointSize: Constants.smallPointSize + text: Constants.trackingSignals.legendCellTextSample } delegate: Row { padding: 1 leftPadding: 4 rightPadding: leftPadding - onImplicitWidthChanged: { - if (gridView.cellWidth < implicitWidth) - gridView.cellWidth = implicitWidth; - - if (gridView.cellHeight < implicitHeight) - gridView.cellHeight = implicitHeight; - - if (lineLegend.visible != true && gridView.cellWidth > 50) - lineLegend.visible = true; - - } Rectangle { id: marker @@ -205,7 +203,7 @@ Item { id: label text: modelData.name - font.pointSize: Constants.smallPointSize + font: legendTextMetrics.font anchors.verticalCenter: parent.verticalCenter anchors.verticalCenterOffset: Constants.commonLegend.verticalCenterOffset } diff --git a/swiftnav_console/tracking_signals_tab.py b/swiftnav_console/tracking_signals_tab.py index 7b3886350..8b426bbad 100644 --- a/swiftnav_console/tracking_signals_tab.py +++ b/swiftnav_console/tracking_signals_tab.py @@ -25,11 +25,13 @@ class TrackingSignalsPoints(QObject): _xaxis_max: float = 0.0 _check_labels: List[str] = [] _all_series: List[QtCharts.QXYSeries] = [] + _enabled_series: List[QtCharts.QXYSeries] = [] num_labels_changed = Signal(int, arguments="num_labels") xaxis_min_changed = Signal() xaxis_max_changed = Signal() check_labels_changed = Signal() all_series_changed = Signal() + enabled_series_changed = Signal() def get_num_labels(self) -> int: # pylint:disable=no-self-use return len(TRACKING_SIGNALS_TAB[Keys.LABELS]) @@ -58,6 +60,11 @@ def get_all_series(self) -> List[QtCharts.QXYSeries]: all_series = Property(QTKeys.QVARIANTLIST, get_all_series, notify=all_series_changed) # type: ignore + def get_enabled_series(self) -> List[QtCharts.QXYSeries]: + return self._enabled_series + + enabled_series = Property(QTKeys.QVARIANTLIST, get_enabled_series, notify=enabled_series_changed) # type: ignore + @Slot(int) # type: ignore def getLabel(self, index) -> str: # pylint:disable=no-self-use """Getter for one of the TRACKING_SIGNALS_TAB[Keys.LABELS].""" @@ -87,6 +94,8 @@ def fill_all_series(self, line_width, useOpenGL) -> None: self.xaxis_min_changed.emit() # type: ignore self._xaxis_max = points_for_all_series[0][-1].x() self.xaxis_max_changed.emit() # type: ignore + series_changed = False + enabled_series = [] for idx, series_points in enumerate(points_for_all_series): series = None try: @@ -98,11 +107,22 @@ def fill_all_series(self, line_width, useOpenGL) -> None: pen.setWidthF(line_width) series.setPen(pen) series.setUseOpenGL(useOpenGL) - self.all_series_changed.emit() # type: ignore + series_changed = True + + if len(series_points) > 0: + enabled_series.append(series) except IndexError: # This is ok - QML will create these series, and call addSeries, and these will be # updated in the next timer fire/update. pass + + if series_changed: + self.all_series_changed.emit() # type: ignore + + if enabled_series != self._enabled_series: + self._enabled_series = enabled_series + self.enabled_series_changed.emit() # type: ignore + return From ad18e9f4844f074e0a06deb8befa299a2d400247 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Wed, 27 Oct 2021 21:24:25 -0400 Subject: [PATCH 08/10] Improve color, layout formatting * This adds some of the SwiftOrange color styling to the TrackingSignals tab. * Remove redundant anchoring, use ColumnLayout in legend shade bar and legend grid --- resources/Constants/Constants.qml | 6 +- resources/TrackingTab.qml | 2 + .../TrackingSignalsTab.qml | 130 +++++++++--------- 3 files changed, 69 insertions(+), 69 deletions(-) diff --git a/resources/Constants/Constants.qml b/resources/Constants/Constants.qml index 3261fcf98..06491eb7f 100644 --- a/resources/Constants/Constants.qml +++ b/resources/Constants/Constants.qml @@ -464,7 +464,7 @@ QtObject { readonly property real solutionMarkerSize: 5 readonly property real solutionLineWidth: 0.5 readonly property color backgroundColor: "#CDC9C9" - readonly property color areaColor: "#FFFFFF" + readonly property color areaColor: "#F0F0F0" readonly property color minorGridLineColor: "#CDC9C9" readonly property color gridLineColor: "#CDC9C9" readonly property color labelsColor: "#000000" @@ -499,13 +499,15 @@ QtObject { trackingSignals: QtObject { readonly property string title: "Tracking C/N0" - readonly property color titleColor: "#00006E" + readonly property color titleColor: Qt.darker(swiftOrange, 1.1) readonly property int titlePointSize: 14 readonly property int legendTopMargin: 30 readonly property int legendBottomMargin: 74 readonly property int legendLeftMargin: 30 readonly property int legendLabelPointSize: 6 readonly property string legendCellTextSample: "XXX XXXX X+NN XNN" + readonly property int legendShadeHeight: 10 + readonly property color legendShadeColor: Qt.lighter(swiftOrange, 1.5) readonly property int legendShadeSpeed: 350 readonly property string yAxisTitleText: "dB-Hz" readonly property string xAxisTitleText: "seconds" diff --git a/resources/TrackingTab.qml b/resources/TrackingTab.qml index 3266c2de9..c4ebbd38c 100644 --- a/resources/TrackingTab.qml +++ b/resources/TrackingTab.qml @@ -48,9 +48,11 @@ Item { currentIndex: trackingBar.currentIndex TrackingTabComponents.TrackingSignalsTab { + anchors.fill: parent } TrackingTabComponents.TrackingSkyPlotTab { + anchors.fill: parent } } diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index a93d0a036..043ced931 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -1,6 +1,6 @@ import "../BaseComponents" import "../Constants" -import QtCharts 2.3 +import QtCharts 2.15 import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 @@ -12,13 +12,9 @@ Item { property alias all_series: trackingSignalsPoints.all_series property alias enabled_series: trackingSignalsPoints.enabled_series property alias check_labels: trackingSignalsPoints.check_labels + property alias num_labels: trackingSignalsPoints.num_labels property variant check_visibility: [] - width: parent.width - height: parent.height - Component.onCompleted: { - } - TrackingSignalsPoints { id: trackingSignalsPoints } @@ -37,7 +33,7 @@ Item { visible: false title: Constants.trackingSignals.title titleColor: Constants.trackingSignals.titleColor - backgroundColor: Constants.commonChart.backgroundColor + // backgroundColor: Constants.commonChart.backgroundColor plotAreaColor: Constants.commonChart.areaColor legend.visible: false antialiasing: true @@ -133,6 +129,7 @@ Item { ] Rectangle { + // This rectangle ensures that the border of the legend is painted nicely. anchors.fill: parent z: 2 color: "transparent" @@ -141,75 +138,74 @@ Item { border.width: Constants.commonLegend.borderWidth } - Rectangle { - id: legendHideBar - - color: "dark grey" - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.topMargin: 1 - height: 10 - radius: lineLegend.radius - - MouseArea { - anchors.fill: parent - onClicked: { - lineLegend.state = lineLegend.state == "opened" ? "closed" : "opened"; + ColumnLayout { + anchors.fill: parent + spacing: 0 + Rectangle { + id: legendHideBar + + Layout.fillWidth: true + color: Constants.trackingSignals.legendShadeColor + height: Constants.trackingSignals.legendShadeHeight + radius: lineLegend.radius + + MouseArea { + anchors.fill: parent + onClicked: { + lineLegend.state = lineLegend.state == "opened" ? "closed" : "opened"; + } + cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor + //drag.target: lineLegend + hoverEnabled: true } - cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor - drag.target: lineLegend - hoverEnabled: true + } - } + GridView { + id: gridView + + Layout.fillWidth: true + Layout.fillHeight: true + clip: true + model: enabled_series + flow: GridView.FlowTopToBottom + cellWidth: Constants.commonLegend.markerWidth + legendTextMetrics.width + 4 + cellHeight: legendTextMetrics.height + 2 + boundsBehavior: Flickable.StopAtBounds + + TextMetrics { + id: legendTextMetrics + font.family: Constants.fontFamily + font.pointSize: Constants.smallPointSize + text: Constants.trackingSignals.legendCellTextSample + } - GridView { - id: gridView - - anchors.top: legendHideBar.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - clip: true - model: enabled_series - flow: GridView.FlowTopToBottom - cellWidth: Constants.commonLegend.markerWidth + legendTextMetrics.width + 4 - cellHeight: legendTextMetrics.height + 2 - boundsBehavior: Flickable.StopAtBounds - - TextMetrics { - id: legendTextMetrics - font.family: Constants.fontFamily - font.pointSize: Constants.smallPointSize - text: Constants.trackingSignals.legendCellTextSample - } + delegate: Row { + padding: 1 + leftPadding: 4 + rightPadding: leftPadding - delegate: Row { - padding: 1 - leftPadding: 4 - rightPadding: leftPadding + Rectangle { + id: marker - Rectangle { - id: marker + color: modelData.color + width: Constants.commonLegend.markerWidth + height: Constants.commonLegend.markerHeight + anchors.verticalCenter: parent.verticalCenter + } - color: modelData.color - width: Constants.commonLegend.markerWidth - height: Constants.commonLegend.markerHeight - anchors.verticalCenter: parent.verticalCenter - } + Label { + id: label - Label { - id: label + text: modelData.name + font: legendTextMetrics.font + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: Constants.commonLegend.verticalCenterOffset + } - text: modelData.name - font: legendTextMetrics.font - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: Constants.commonLegend.verticalCenterOffset } } - } } @@ -268,8 +264,8 @@ Item { if (!trackingTab.visible) return ; - if (trackingSignalsPoints.all_series.length < trackingSignalsPoints.num_labels) { - for (var i = trackingSignalsPoints.all_series.length; i < trackingSignalsPoints.num_labels; i++) { + if (all_series.length < num_labels) { + for (var i = all_series.length; i < num_labels; i++) { var series = trackingSignalsChart.createSeries(ChartView.SeriesTypeLine, trackingSignalsPoints.getLabel(i), trackingSignalsXAxis); series.axisYRight = trackingSignalsYAxis; series.width = Constants.commonChart.lineWidth; @@ -280,7 +276,7 @@ Item { } } trackingSignalsPoints.fill_all_series(Constants.commonChart.lineWidth, Globals.useOpenGL); - if (trackingSignalsPoints.all_series.length) { + if (all_series.length) { trackingSignalsChart.visible = true; trackingSignalsXAxis.min = trackingSignalsPoints.xaxis_min; trackingSignalsXAxis.max = trackingSignalsPoints.xaxis_max; From 9cdc00a77ab0b3fdc59b9c9002947f70556c5474 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Wed, 27 Oct 2021 21:31:52 -0400 Subject: [PATCH 09/10] Formatting fixes from make check-all --- resources/TrackingTabComponents/TrackingSignalsTab.qml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index 043ced931..9e68ef24e 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -51,7 +51,7 @@ Item { property int maximumHeight: parent.height - Constants.trackingSignals.legendTopMargin - Constants.trackingSignals.legendBottomMargin property int openedHeight: gridView.count < maxCellsPerColumn ? gridView.cellHeight * gridView.count : maximumHeight property int openCloseSpeed: Constants.trackingSignals.legendShadeSpeed - property int maxCellsPerColumn: maximumHeight / gridView.cellHeight // floor/truncation is desired. + property int maxCellsPerColumn: maximumHeight / gridView.cellHeight // floor/truncation is desired. visible: gridView.count > 0 radius: 5 @@ -141,6 +141,7 @@ Item { ColumnLayout { anchors.fill: parent spacing: 0 + Rectangle { id: legendHideBar @@ -175,6 +176,7 @@ Item { TextMetrics { id: legendTextMetrics + font.family: Constants.fontFamily font.pointSize: Constants.smallPointSize text: Constants.trackingSignals.legendCellTextSample @@ -206,6 +208,7 @@ Item { } } + } } From 9d7738a30082cb6ea05bd803a04bc124534aa6c4 Mon Sep 17 00:00:00 2001 From: Keith Kyzivat Date: Wed, 27 Oct 2021 21:38:00 -0400 Subject: [PATCH 10/10] Reduce legend font size Reduce the font size we use for the Tracking Signals legend per Jason Mobarak's request. --- resources/Constants/Constants.qml | 1 + resources/TrackingTabComponents/TrackingSignalsTab.qml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/Constants/Constants.qml b/resources/Constants/Constants.qml index 06491eb7f..87765d89d 100644 --- a/resources/Constants/Constants.qml +++ b/resources/Constants/Constants.qml @@ -44,6 +44,7 @@ QtObject { readonly property int staticTimerSlowIntervalRate: 2 // 2 Hz readonly property string monoSpaceFont: "Courier New" readonly property string fontFamily: "Roboto" + readonly property real xSmallPointSize: 6 readonly property real smallPointSize: 7 readonly property real mediumPointSize: 8 readonly property real largePointSize: 9 diff --git a/resources/TrackingTabComponents/TrackingSignalsTab.qml b/resources/TrackingTabComponents/TrackingSignalsTab.qml index 9e68ef24e..6e579d9dd 100644 --- a/resources/TrackingTabComponents/TrackingSignalsTab.qml +++ b/resources/TrackingTabComponents/TrackingSignalsTab.qml @@ -178,7 +178,7 @@ Item { id: legendTextMetrics font.family: Constants.fontFamily - font.pointSize: Constants.smallPointSize + font.pointSize: Constants.xSmallPointSize text: Constants.trackingSignals.legendCellTextSample }