From 45cc573d95321354998dcfc29b41c15d60923a5a Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Tue, 28 Feb 2017 03:13:00 -0500 Subject: [PATCH] Add grid lines to video view --- src/FlightDisplay/FlightDisplayViewVideo.qml | 32 +++++++++++++++++++- src/Settings/Video.SettingsGroup.json | 9 ++++++ src/Settings/VideoSettings.cc | 11 +++++++ src/Settings/VideoSettings.h | 4 +++ src/ui/preferences/GeneralSettings.qml | 14 +++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/FlightDisplay/FlightDisplayViewVideo.qml b/src/FlightDisplay/FlightDisplayViewVideo.qml index 65d9af211..275bfd6ab 100644 --- a/src/FlightDisplay/FlightDisplayViewVideo.qml +++ b/src/FlightDisplay/FlightDisplayViewVideo.qml @@ -23,7 +23,9 @@ import QGroundControl.Controllers 1.0 Item { id: root - property double _ar: QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue + property double _ar: QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue + property bool _showGrid: QGroundControl.settingsManager.videoSettings.gridLines.rawValue > 0 + Rectangle { id: noVideo anchors.fill: parent @@ -50,4 +52,32 @@ Item { visible: QGroundControl.videoManager.videoRunning } } + Rectangle { + color: Qt.rgba(1,1,1,0.5) + height: parent.height + width: 1 + x: parent.width * 0.33 + visible: _showGrid + } + Rectangle { + color: Qt.rgba(1,1,1,0.5) + height: parent.height + width: 1 + x: parent.width * 0.66 + visible: _showGrid + } + Rectangle { + color: Qt.rgba(1,1,1,0.5) + width: parent.width + height: 1 + y: parent.height * 0.33 + visible: _showGrid + } + Rectangle { + color: Qt.rgba(1,1,1,0.5) + width: parent.width + height: 1 + y: parent.height * 0.66 + visible: _showGrid + } } diff --git a/src/Settings/Video.SettingsGroup.json b/src/Settings/Video.SettingsGroup.json index 17e8254db..457a519c2 100644 --- a/src/Settings/Video.SettingsGroup.json +++ b/src/Settings/Video.SettingsGroup.json @@ -35,5 +35,14 @@ "type": "float", "decimalPlaces": 6, "defaultValue": 1.777777 +}, +{ + "name": "VideoGridLines", + "shortDescription": "Video Grid Lines", + "longDescription": "Displays a grid overlayed over the video view.", + "type": "uint32", + "enumStrings": "Hide,Show", + "enumValues": "1,0", + "defaultValue": 0 } ] diff --git a/src/Settings/VideoSettings.cc b/src/Settings/VideoSettings.cc index f36751d24..52cf59615 100644 --- a/src/Settings/VideoSettings.cc +++ b/src/Settings/VideoSettings.cc @@ -24,6 +24,7 @@ const char* VideoSettings::udpPortName = "VideoUDPPort"; const char* VideoSettings::rtspUrlName = "VideoRTSPUrl"; const char* VideoSettings::videoSavePathName = "VideoSavePath"; const char* VideoSettings::videoAspectRatioName = "VideoAspectRatio"; +const char* VideoSettings::videoGridLinesName = "VideoGridLines"; const char* VideoSettings::videoSourceNoVideo = "No Video Available"; const char* VideoSettings::videoSourceUDP = "UDP Video Stream"; @@ -36,6 +37,7 @@ VideoSettings::VideoSettings(QObject* parent) , _rtspUrlFact(NULL) , _videoSavePathFact(NULL) , _videoAspectRatioFact(NULL) + , _gridLinesFact(NULL) { QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only"); @@ -115,3 +117,12 @@ Fact* VideoSettings::aspectRatio(void) return _videoAspectRatioFact; } + +Fact* VideoSettings::gridLines(void) +{ + if (!_gridLinesFact) { + _gridLinesFact = _createSettingsFact(videoGridLinesName); + } + + return _gridLinesFact; +} diff --git a/src/Settings/VideoSettings.h b/src/Settings/VideoSettings.h index d914fc701..48eb53dfc 100644 --- a/src/Settings/VideoSettings.h +++ b/src/Settings/VideoSettings.h @@ -24,12 +24,14 @@ public: Q_PROPERTY(Fact* rtspUrl READ rtspUrl CONSTANT) Q_PROPERTY(Fact* videoSavePath READ videoSavePath CONSTANT) Q_PROPERTY(Fact* aspectRatio READ aspectRatio CONSTANT) + Q_PROPERTY(Fact* gridLines READ gridLines CONSTANT) Fact* videoSource (void); Fact* udpPort (void); Fact* rtspUrl (void); Fact* videoSavePath (void); Fact* aspectRatio (void); + Fact* gridLines (void); static const char* videoSettingsGroupName; @@ -38,6 +40,7 @@ public: static const char* rtspUrlName; static const char* videoSavePathName; static const char* videoAspectRatioName; + static const char* videoGridLinesName; static const char* videoSourceNoVideo; static const char* videoSourceUDP; @@ -49,6 +52,7 @@ private: SettingsFact* _rtspUrlFact; SettingsFact* _videoSavePathFact; SettingsFact* _videoAspectRatioFact; + SettingsFact* _gridLinesFact; }; #endif diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index 4993e8c7e..4506b9174 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -512,6 +512,20 @@ QGCView { fact: QGroundControl.settingsManager.videoSettings.aspectRatio } } + Row { + spacing: ScreenTools.defaultFontPixelWidth + visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 && QGroundControl.settingsManager.videoSettings.gridLines.visible + QGCLabel { + anchors.baseline: gridField.baseline + text: qsTr("Grid Lines:") + width: _labelWidth + } + FactComboBox { + id: gridField + width: _editFieldWidth + fact: QGroundControl.settingsManager.videoSettings.gridLines + } + } Row { spacing: ScreenTools.defaultFontPixelWidth visible: QGroundControl.settingsManager.videoSettings.videoSavePath.visible && QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled -- 2.22.0