From e315486888e1518825909aecf65ac778b02b57af Mon Sep 17 00:00:00 2001 From: Kurt Kiefer Date: Tue, 27 Dec 2016 08:40:07 -0800 Subject: [PATCH] Reorganize qml structure and add boson-specific controls --- inc/bosonvariation.h | 21 +++-- inc/bosonvariation_types.h | 43 +++++++++ qml/PaletteModel.qml | 48 ---------- qml/ViewerForm.ui.qml | 85 +----------------- qml/boson/BosonTabs.qml | 52 +++++++++++ qml/boson/InfoControls.qml | 49 +++++++++++ qml/boson/VidControls.qml | 88 +++++++++++++++++++ qml/controls/CameraControls.qml | 66 ++++++++++++++ qml/{ => controls}/RangeDisplay.qml | 0 qml/{ => controls}/ValueSlider.qml | 0 qml/{ => lepton}/AgcControls.qml | 0 .../InfoControls.qml} | 0 qml/lepton/LeptonTabs.qml | 63 +++++++++++++ qml/{ => lepton}/VidControls.qml | 0 qml/qml.qrc | 20 ++--- src/bosonvariation.cpp | 44 ++++++++-- src/leptonvariation.cpp | 2 + src/main.cpp | 1 + 18 files changed, 430 insertions(+), 152 deletions(-) create mode 100644 inc/bosonvariation_types.h delete mode 100644 qml/PaletteModel.qml create mode 100644 qml/boson/BosonTabs.qml create mode 100644 qml/boson/InfoControls.qml create mode 100644 qml/boson/VidControls.qml create mode 100644 qml/controls/CameraControls.qml rename qml/{ => controls}/RangeDisplay.qml (100%) rename qml/{ => controls}/ValueSlider.qml (100%) rename qml/{ => lepton}/AgcControls.qml (100%) rename qml/{LeptonControls.qml => lepton/InfoControls.qml} (100%) create mode 100644 qml/lepton/LeptonTabs.qml rename qml/{ => lepton}/VidControls.qml (100%) diff --git a/inc/bosonvariation.h b/inc/bosonvariation.h index dfb485e..be3fa3b 100644 --- a/inc/bosonvariation.h +++ b/inc/bosonvariation.h @@ -41,13 +41,22 @@ class BosonVariation : public AbstractCCInterface virtual const AbstractCCInterface& operator =(const AbstractCCInterface&); - BOSON_ENUM_PROPERTY(COLORLUT_ID_E, vidPcolorLut, colorLutGetId, colorLutSetId) + BOSON_ENUM_PROPERTY(COLORLUT_ID_E, colorLutId, colorLutGetId, colorLutSetId) - Q_PROPERTY(const QString sysFlirSerialNumber READ getSysFlirSerialNumber) - const QString getSysFlirSerialNumber(); + Q_PROPERTY(const QString cameraSerialNumber READ getCameraSerialNumber) + const QString getCameraSerialNumber(); - Q_PROPERTY(const QString oemFlirPartNumber READ getOemFlirPartNumber) - const QString getOemFlirPartNumber(); + Q_PROPERTY(const QString cameraPartNumber READ getCameraPartNumber) + const QString getCameraPartNumber(); + + Q_PROPERTY(const QString sensorSerialNumber READ getSensorSerialNumber) + const QString getSensorSerialNumber(); + + Q_PROPERTY(const QString sensorPartNumber READ getSensorPartNumber) + const QString getSensorPartNumber(); + + Q_PROPERTY(const QString softwareRev READ getSoftwareRev) + const QString getSoftwareRev(); Q_PROPERTY(float cameraInternalTempC READ getCameraInternalTempC NOTIFY cameraInternalTempChanged) float getCameraInternalTempC(); @@ -64,7 +73,7 @@ class BosonVariation : public AbstractCCInterface signals: void cameraInternalTempChanged(float temp); - void vidPcolorLutChanged(COLORLUT_ID_E val); + void colorLutIdChanged(COLORLUT_ID_E val); public slots: virtual void performFfc(); diff --git a/inc/bosonvariation_types.h b/inc/bosonvariation_types.h new file mode 100644 index 0000000..86bc549 --- /dev/null +++ b/inc/bosonvariation_types.h @@ -0,0 +1,43 @@ +#ifndef BOSONVARIATION_TYPES_H +#define BOSONVARIATION_TYPES_H + +#include +#include + +extern "C" { +#include "boson_sdk/ReturnCodes.h" +#include "boson_sdk/EnumTypes.h" +} + +#define QML_ENUM(name, storageType, ...)\ + enum class name : storageType {\ + __VA_ARGS__\ + };\ + class QE_##name {\ + Q_GADGET\ + Q_ENUMS(E)\ + public:\ + enum class E : storageType {\ + __VA_ARGS__\ + };\ + }; + +namespace FLR { + + QML_ENUM(COLORLUT_ID_E, int32_t, \ + FLR_COLORLUT_WHITEHOT, \ + FLR_COLORLUT_BLACKHOT, \ + FLR_COLORLUT_REDHOT, \ + FLR_COLORLUT_RAINBOW, \ + FLR_COLORLUT_IRONBOW, \ + FLR_COLORLUT_LAVA, \ + FLR_COLORLUT_ARCTIC, \ + FLR_COLORLUT_GLOBOW, \ + FLR_COLORLUT_GRADEDFIRE, \ + FLR_COLORLUT_INSTALERT, \ + ) + +} +void registerBosonVariationQmlTypes(); + +#endif // BOSONVARIATION_TYPES_H diff --git a/qml/PaletteModel.qml b/qml/PaletteModel.qml deleted file mode 100644 index 425057f..0000000 --- a/qml/PaletteModel.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 2.0 - -ListModel { - ListElement { - index: 0 - text: "Wheel 6" - } - - ListElement { - index: 1 - text: "Fusion" - } - - ListElement { - index: 2 - text: "Rainbow" - } - - ListElement { - index: 3 - text: "Glowbow" - } - - ListElement { - index: 4 - text: "Sepia" - } - - ListElement { - index: 5 - text: "Color" - } - - ListElement { - index: 6 - text: "Ice & Fire" - } - - ListElement { - index: 7 - text: "Rain" - } - - ListElement { - index: 8 - text: "User" - } -} diff --git a/qml/ViewerForm.ui.qml b/qml/ViewerForm.ui.qml index 2d0606f..9995c55 100644 --- a/qml/ViewerForm.ui.qml +++ b/qml/ViewerForm.ui.qml @@ -3,7 +3,6 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 import QtMultimedia 5.5 import GetThermal 1.0 -import "qrc:/lepton" import "qrc:/controls" import "qrc:/images" @@ -14,7 +13,6 @@ Item { property alias acq: acq property alias player: player property alias videoOutput: videoOutput - property alias leptonControls1: leptonControls1 width: 640 UvcAcquisition { @@ -30,87 +28,10 @@ Item { spacing: 0 anchors.fill: parent - Pane { - rightPadding: 12 - topPadding: 12 - bottomPadding: 12 - leftPadding: 12 - Layout.minimumWidth: 220 + CameraControls { + Layout.minimumWidth: 240 Layout.fillHeight: true - padding: 0 - - Image { - id: imageLogo - anchors.left: parent.left - anchors.top: parent.top - anchors.right: parent.right - height: 50 - fillMode: Image.PreserveAspectFit - source: "/images/images/brand-logo.png" - } - - Page { - anchors.top: imageLogo.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - clip: true - - header: TabBar { - id: tabBar - currentIndex: swipeView.currentIndex - TabButton { - text: qsTr("VID") - } - TabButton { - text: qsTr("AGC") - visible: typeof acq === "LeptonVariation" - } - TabButton { - text: qsTr("Info") - visible: typeof acq === "LeptonVariation" - } - } - - SwipeView { - id: swipeView - x: 0 - y: 40 - currentIndex: tabBar.currentIndex - anchors.fill: parent - - - VidControls { - id: vidControls1 - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.top: parent.top - acq: acq - } - - AgcControls { - id: agcControls1 - anchors.bottom: parent.bottom - anchors.left: vidControls1.right - anchors.top: parent.top - acq: acq - visible: typeof acq === "LeptonVariation" - } - - - LeptonControls { - id: leptonControls1 - anchors.bottom: parent.bottom - anchors.left: agcControls1.right - anchors.top: parent.top - acq: acq - visible: typeof acq === "LeptonVariation" - } - } - - - - } + acq: acq } Pane { diff --git a/qml/boson/BosonTabs.qml b/qml/boson/BosonTabs.qml new file mode 100644 index 0000000..0794ac2 --- /dev/null +++ b/qml/boson/BosonTabs.qml @@ -0,0 +1,52 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import GetThermal 1.0 +import "qrc:/boson" + +Page { + id: root + clip: true + + width: 220 + height: 480 + + property UvcAcquisition acq: null + + header: TabBar { + id: tabBar + currentIndex: swipeView.currentIndex + + TabButton { + text: qsTr("Vid") + } + + TabButton { + text: qsTr("Info") + } + } + + SwipeView { + id: swipeView + x: 0 + y: 40 + currentIndex: tabBar.currentIndex + anchors.fill: parent + + VidControls { + id: vidControls1 + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.top: parent.top + acq: root.acq + } + + InfoControls { + id: infoControls1 + anchors.bottom: parent.bottom + anchors.left: vidControls1.right + anchors.top: parent.top + acq: root.acq + } + } + +} diff --git a/qml/boson/InfoControls.qml b/qml/boson/InfoControls.qml new file mode 100644 index 0000000..ffa6fd9 --- /dev/null +++ b/qml/boson/InfoControls.qml @@ -0,0 +1,49 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import GetThermal 1.0 + +Item { + id: root + width: 200 + property UvcAcquisition acq: null + + GroupBox { + id: groupBox1 + clip: true + + anchors.margins: 5 + anchors.fill: parent + title: qsTr("FLIR Boson") + + Grid { + id: grid + + columns: 1 + rows: 8 + anchors.fill: parent + spacing: 10 + flow: Grid.TopToBottom + + Label { + text: qsTr("Sensor PN: ") + acq.cci.sensorPartNumber + } + + Label { + text: qsTr("Sensor SN: ") + acq.cci.sensorSerialNumber + } + + Label { + text: qsTr("Cam PN: ") + acq.cci.cameraPartNumber + } + + Label { + text: qsTr("Cam SN: ") + acq.cci.cameraSerialNumber + } + + Label { + text: qsTr("Software: ") + acq.cci.softwareRev + } + } + } + +} diff --git a/qml/boson/VidControls.qml b/qml/boson/VidControls.qml new file mode 100644 index 0000000..fde052a --- /dev/null +++ b/qml/boson/VidControls.qml @@ -0,0 +1,88 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import GetThermal 1.0 + +Item { + id: root + width: 200 + property UvcAcquisition acq: null + + Flow { + id: flow1 + spacing: 5 + anchors.fill: parent + anchors.margins: 5 + + Label { + id: labelPcolor + width: parent.width + text: qsTr("Pseudo-Color Palette:") + } + + ComboBox { + id: comboColorLutId + width: parent.width + visible: acq.cci.supportsHwPseudoColor + + model: ListModel { + ListElement { text: "White Hot"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_WHITEHOT } + ListElement { text: "Black Hot"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_BLACKHOT } + ListElement { text: "Red Hot"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_REDHOT } + ListElement { text: "Rainbow"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_RAINBOW } + ListElement { text: "Ironbow"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_IRONBOW } + ListElement { text: "Lava"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_LAVA } + ListElement { text: "Arctic"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_ARCTIC } + ListElement { text: "Globow"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_GLOBOW } + ListElement { text: "Graded Fire"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_GRADEDFIRE } + ListElement { text: "Instalert"; data: FLR_COLORLUT_ID_E.FLR_COLORLUT_INSTALERT } + } + textRole: qsTr("text") + + currentIndex: acq.cci.colorLutId + } + + ComboBox { + id: comboSwPcolorLut + width: parent.width + visible: !acq.cci.supportsHwPseudoColor + + model: ListModel { + ListElement { text: "Iron Black"; data: DataFormatter.IronBlack } + ListElement { text: "Rainbow"; data: DataFormatter.Rainbow } + ListElement { text: "Grayscale"; data: DataFormatter.Grayscale } + } + textRole: qsTr("text") + + currentIndex: acq.dataFormatter.pseudocolorPalette + } + + Button { + id: buttonFfc + text: qsTr("Perform FFC") + } + } + + + Connections { + target: comboColorLutId + onCurrentIndexChanged: { + var currentItem = target.model.get(target.currentIndex); + acq.cci.colorLutId = currentItem.data; + } + } + + Connections { + target: comboSwPcolorLut + onCurrentIndexChanged: { + var currentItem = target.model.get(target.currentIndex); + acq.dataFormatter.pseudocolorPalette = currentItem.data; + } + } + + Connections { + target: buttonFfc + onClicked: { + acq.cci.performFfc(); + } + } +} diff --git a/qml/controls/CameraControls.qml b/qml/controls/CameraControls.qml new file mode 100644 index 0000000..19b8efc --- /dev/null +++ b/qml/controls/CameraControls.qml @@ -0,0 +1,66 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import GetThermal 1.0 +import "qrc:/lepton" +import "qrc:/boson" +import "qrc:/images" + +Pane { + id: root + + property UvcAcquisition acq: null + + width: 220 + height: 480 + + rightPadding: 5 + topPadding: 12 + bottomPadding: 12 + leftPadding: 12 + padding: 0 + + Image { + id: imageLogo + anchors.left: parent.left + anchors.top: parent.top + anchors.right: parent.right + height: 50 + fillMode: Image.PreserveAspectFit + source: "/images/images/brand-logo.png" + } + + Component { + id: leptonControls1 + LeptonTabs { + acq: root.acq + } + } + + Component { + id: bosonControls1 + BosonTabs { + acq: root.acq + } + } + + Loader { + id: controls + asynchronous: true + anchors.top: imageLogo.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + } + + onAcqChanged: { + if (acq.cci.objectName === "LeptonVariation") + { + controls.sourceComponent = leptonControls1; + } + else if (acq.cci.objectName === "BosonVariation") + { + controls.sourceComponent = bosonControls1; + } + } + +} diff --git a/qml/RangeDisplay.qml b/qml/controls/RangeDisplay.qml similarity index 100% rename from qml/RangeDisplay.qml rename to qml/controls/RangeDisplay.qml diff --git a/qml/ValueSlider.qml b/qml/controls/ValueSlider.qml similarity index 100% rename from qml/ValueSlider.qml rename to qml/controls/ValueSlider.qml diff --git a/qml/AgcControls.qml b/qml/lepton/AgcControls.qml similarity index 100% rename from qml/AgcControls.qml rename to qml/lepton/AgcControls.qml diff --git a/qml/LeptonControls.qml b/qml/lepton/InfoControls.qml similarity index 100% rename from qml/LeptonControls.qml rename to qml/lepton/InfoControls.qml diff --git a/qml/lepton/LeptonTabs.qml b/qml/lepton/LeptonTabs.qml new file mode 100644 index 0000000..3c7ac6a --- /dev/null +++ b/qml/lepton/LeptonTabs.qml @@ -0,0 +1,63 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.0 +import GetThermal 1.0 +import "qrc:/lepton" + +Page { + id: root + clip: true + + width: 220 + height: 480 + + property UvcAcquisition acq: null + + header: TabBar { + id: tabBar + currentIndex: swipeView.currentIndex + TabButton { + text: qsTr("VID") + } + TabButton { + text: qsTr("AGC") + } + TabButton { + text: qsTr("Info") + } + } + + SwipeView { + id: swipeView + x: 0 + y: 40 + currentIndex: tabBar.currentIndex + anchors.fill: parent + + + VidControls { + id: vidControls1 + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.top: parent.top + acq: root.acq + } + + AgcControls { + id: agcControls1 + anchors.bottom: parent.bottom + anchors.left: vidControls1.right + anchors.top: parent.top + acq: root.acq + } + + + InfoControls { + id: leptonControls1 + anchors.bottom: parent.bottom + anchors.left: agcControls1.right + anchors.top: parent.top + acq: root.acq + } + } + +} diff --git a/qml/VidControls.qml b/qml/lepton/VidControls.qml similarity index 100% rename from qml/VidControls.qml rename to qml/lepton/VidControls.qml diff --git a/qml/qml.qrc b/qml/qml.qrc index f53480b..61dddfa 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -4,16 +4,16 @@ Viewer.qml ViewerForm.ui.qml qtquickcontrols2.conf - - - PaletteModel.qml - LeptonControls.qml - AgcControls.qml - VidControls.qml - - - ValueSlider.qml - RangeDisplay.qml + boson/BosonTabs.qml + boson/InfoControls.qml + controls/CameraControls.qml + controls/RangeDisplay.qml + controls/ValueSlider.qml + lepton/AgcControls.qml + lepton/InfoControls.qml + lepton/LeptonTabs.qml + lepton/VidControls.qml + boson/VidControls.qml images/brand-logo.png diff --git a/src/bosonvariation.cpp b/src/bosonvariation.cpp index b3af435..568d7e6 100644 --- a/src/bosonvariation.cpp +++ b/src/bosonvariation.cpp @@ -7,6 +7,15 @@ extern "C" { int boson_example(); } +#define QML_REGISTER_ENUM(name) \ + qmlRegisterUncreatableType("GetThermal", 1,0, "FLR_" #name, "You can't create enumeration " #name); \ + qRegisterMetaType("FLR_" #name); + +void registerBosonVariationQmlTypes() +{ + QML_REGISTER_ENUM(COLORLUT_ID_E) +} + BosonVariation::BosonVariation(uvc_context_t *ctx, uvc_device_t *dev, uvc_device_handle_t *devh) @@ -29,7 +38,7 @@ BosonVariation::BosonVariation(uvc_context_t *ctx, printf("Failed to initialize CCI interface\n"); } - boson_example(); + this->setObjectName("BosonVariation"); } BosonVariation::~BosonVariation() @@ -45,20 +54,43 @@ const AbstractCCInterface& BosonVariation::operator =(const AbstractCCInterface& return BosonVariation(ctx, dev, devh); } -const QString BosonVariation::getOemFlirPartNumber() +const QString BosonVariation::getCameraPartNumber() { FLR_BOSON_PARTNUMBER_T pn; bosonGetCameraPN(&pn); return QString::fromLatin1((char*)pn.value, sizeof(pn.value)); } -const QString BosonVariation::getSysFlirSerialNumber() +const QString BosonVariation::getCameraSerialNumber() +{ + uint32_t sn; + bosonGetCameraSN(&sn); + return QString::asprintf("%d", sn); +} + +const QString BosonVariation::getSensorPartNumber() +{ + + FLR_BOSON_SENSOR_PARTNUMBER_T pn; + bosonGetSensorPN(&pn); + return QString::fromLatin1((char*)pn.value, sizeof(pn.value)); +} + +const QString BosonVariation::getSensorSerialNumber() { - uint32_t camera_sn; - bosonGetSensorSN(&camera_sn); - return QString::asprintf("%lu", camera_sn); + uint32_t sn; + bosonGetSensorSN(&sn); + return QString::asprintf("%d", sn); } +const QString BosonVariation::getSoftwareRev() +{ + uint32_t maj, min, rev; + bosonGetSoftwareRev(&maj, &min, &rev); + return QString::asprintf("%d.%d.%d", maj, min, rev); +} + + bool BosonVariation::getSupportsHwPseudoColor() const { return true; diff --git a/src/leptonvariation.cpp b/src/leptonvariation.cpp index 62cd1f5..c42d0b2 100644 --- a/src/leptonvariation.cpp +++ b/src/leptonvariation.cpp @@ -64,6 +64,8 @@ LeptonVariation::LeptonVariation(uvc_context_t *ctx, printf("\n"); units = units->next; } + + this->setObjectName("LeptonVariation"); } LeptonVariation::~LeptonVariation() diff --git a/src/main.cpp b/src/main.cpp index 35517a5..ceece15 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,6 +24,7 @@ int main(int argc, char *argv[]) qmlRegisterUncreatableType("GetThermal", 1,0, "DataFormatter", ""); registerLeptonVariationQmlTypes(); + registerBosonVariationQmlTypes(); QQmlApplicationEngine engine; engine.addImageProvider(QLatin1String("palettes"), new RangeProvider);