diff --git a/PayloadAPP.pro b/PayloadAPP.pro index 8810257..53933f9 100644 --- a/PayloadAPP.pro +++ b/PayloadAPP.pro @@ -16,12 +16,14 @@ QMAKE_PROJECT_DEPTH = 0 SOURCES += \ global.cpp \ SDFPDlg.cpp \ + imageswitch.cpp \ main.cpp \ mainwindow.cpp \ HEADERS += \ SDFPDlg.h \ global.h \ + imageswitch.h \ mainwindow.h \ FORMS += \ diff --git a/Src/GDDC/gddcCmdDlg.cpp b/Src/GDDC/gddcCmdDlg.cpp index 6e12a86..6e68bcd 100644 --- a/Src/GDDC/gddcCmdDlg.cpp +++ b/Src/GDDC/gddcCmdDlg.cpp @@ -69,8 +69,15 @@ void GDDCCmdDlg::initParam() { ui->comboBox_4_2->addItem("5"); ui->comboBox_4_2->addItem("6"); ui->comboBox_4_2->addItem("7"); - ui->comboBox_4_3->addItem("关闭");//关闭温度报警或者阈值检测功能 - ui->comboBox_4_3->addItem("开启");//开启温度报警或者阈值检测功能 + + m_paramInfraredWarning = 0; + ui->swtichButton_4_1->setChecked(false); + ui->swtichButton_4_1->setFixedSize(100,20); + ui->swtichButton_4_1->setButtonStyle(ImageSwitch::ButtonStyle_1); + //绑定选中切换信号 + connect(ui->swtichButton_4_1, SIGNAL(checkedChanged(bool)), this, SLOT(checkedChangedSlot(bool))); + + /*稳定平台*/ ui->comboBox_5_1->addItem("非常慢"); @@ -659,33 +666,26 @@ void GDDCCmdDlg::on_pushButton_4_18_released() { clearTJDCCmdBuffer(); } // 红外报警设置 void GDDCCmdDlg::on_pushButton_4_19_pressed() { - UINT8 Bit7 = 0; - UINT8 Bit0 = 0; - int sel = ui->lineEdit_4_1->text().toInt(); - int sel2 = ui->lineEdit_4_2->text().toInt()*10; - - if(ui->comboBox_4_3->currentIndex()==0) { // 关闭温度报警或者阈值检测功能; - Bit7 = 0b00000000; - } else { // 开启温度报警或者阈值检测功能; - Bit7 = 0b10000000; - } - - if(ui->radioButton_4_1->isChecked()) { //温度阈值 - Bit0 = 0b00000000; - TJDCCmdBuffer[0] = (std::byte)(Bit7+Bit0); - TJDCCmdBuffer[1] = (std::byte)sel; //观瞄型 - TJDCCmdBuffer[2] = (std::byte)(sel>>8); - } else { //16位 RAW 数据阈值 - Bit0 = 0b00000001; - TJDCCmdBuffer[0] = (std::byte)(Bit7+Bit0); - TJDCCmdBuffer[1] = (std::byte)sel2; //测温型 - TJDCCmdBuffer[2] = (std::byte)(sel2>>8); - } + UINT8 Bit0 = 0b00000001; // 测温型 + int sel = ui->lineEdit_4_2->text().toDouble()*10; + TJDCCmdBuffer[0] = (std::byte)(m_paramInfraredWarning+Bit0); + TJDCCmdBuffer[1] = (std::byte)sel; + TJDCCmdBuffer[2] = (std::byte)(sel>>8); } void GDDCCmdDlg::on_pushButton_4_19_released(){ clearTJDCCmdBuffer(); } +// 开启/关闭温度报警或者阈值检测功能 +void GDDCCmdDlg::checkedChangedSlot(bool param) +{ + if(!param) { + m_paramInfraredWarning = 0b00000000;// 关闭 + } else { + m_paramInfraredWarning = 0b10000000;// 开启 + } +} + // 俯仰+ void GDDCCmdDlg::on_pushButton_5_1_pressed() { if (paramIsFrame) { diff --git a/Src/GDDC/gddcCmdDlg.h b/Src/GDDC/gddcCmdDlg.h index a4ea38c..5d12e09 100644 --- a/Src/GDDC/gddcCmdDlg.h +++ b/Src/GDDC/gddcCmdDlg.h @@ -17,6 +17,7 @@ #include #include #include +#include "imageswitch.h" #define cmdLength 44 namespace Ui { @@ -51,6 +52,7 @@ public: bool detectionAreaSetting; // 检测区域设置 void setTabWidgetGeometry(int, int, int, int); // 设置tabwidget的几何位置 void setAIDetcLineEditText(QString, QString); // 设置AI监测lineEdit的内容 + UINT8 m_paramInfraredWarning; // 红外告警参数 private slots: /*系统控制*/ void on_pushButton_1_1_pressed(); @@ -176,6 +178,7 @@ private slots: void on_pushButton_4_18_released(); void on_pushButton_4_19_pressed(); void on_pushButton_4_19_released(); + void checkedChangedSlot(bool); /*云台控制*/ void on_pushButton_5_1_pressed(); void on_pushButton_5_1_released(); diff --git a/Src/GDDC/gddcCmdDlg.ui b/Src/GDDC/gddcCmdDlg.ui index c6cf031..284a6e8 100644 --- a/Src/GDDC/gddcCmdDlg.ui +++ b/Src/GDDC/gddcCmdDlg.ui @@ -80,7 +80,7 @@ QTabWidget::TabShape::Rounded - 3 + 5 Qt::TextElideMode::ElideNone @@ -1171,7 +1171,7 @@ - 600 + 590 50 100 30 @@ -1347,7 +1347,7 @@ - 490 + 480 10 101 31 @@ -1357,7 +1357,7 @@ - 600 + 590 10 101 30 @@ -1373,7 +1373,7 @@ - 490 + 480 50 101 31 @@ -1383,34 +1383,30 @@ - 720 + 710 10 - 201 - 161 + 181 + 151 红外报警设置 - - - - 10 - 120 - 71 - 31 - - - - 100 - 120 + 80 + 110 71 - 31 + 25 + + + 0 + 0 + + @@ -1418,22 +1414,12 @@ 设置 - - - - 80 - 40 - 91 - 23 - - - - 80 - 80 - 91 + 75 + 70 + 81 23 @@ -1441,9 +1427,9 @@ - 180 - 80 - 16 + 160 + 70 + 14 21 @@ -1451,30 +1437,40 @@ - + - 10 - 40 + 5 + 70 61 21 - 观瞄型 + 温度阈值 - + - 10 - 80 + 60 + 30 + 71 + 21 + + + + + + + 5 + 30 61 21 - 测温型 + 检测开关 @@ -2208,6 +2204,14 @@ font: 12pt "Microsoft YaHei UI"; + + + ImageSwitch + QWidget +
imageswitch.h
+ 1 +
+
diff --git a/imageswitch.cpp b/imageswitch.cpp new file mode 100644 index 0000000..f387ee3 --- /dev/null +++ b/imageswitch.cpp @@ -0,0 +1,89 @@ +#include "imageswitch.h" +#include + +ImageSwitch::ImageSwitch(QWidget *parent) : QWidget(parent) +{ + isChecked = false; + buttonStyle = ButtonStyle_1; + + imgOffFile = ":/res/switch/switch_close.png"; + imgOnFile = ":/res/switch/switch_open.png"; + imgFile = imgOffFile; +} + +void ImageSwitch::mousePressEvent(QMouseEvent *) +{ + imgFile = isChecked ? imgOffFile : imgOnFile; + isChecked = !isChecked; + emit checkedChanged(isChecked); + this->update(); +} + +void ImageSwitch::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.setRenderHints(QPainter::SmoothPixmapTransform); + QImage img(imgFile); + img = img.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + + //按照比例自动居中绘制 + int pixX = rect().center().x() - img.width() / 2; + int pixY = rect().center().y() - img.height() / 2; + QPoint point(pixX, pixY); + painter.drawImage(point, img); +} + +QSize ImageSwitch::sizeHint() const +{ + return QSize(87, 28); +} + +QSize ImageSwitch::minimumSizeHint() const +{ + return QSize(87, 28); +} + +bool ImageSwitch::getChecked() const +{ + return isChecked; +} + +void ImageSwitch::setChecked(bool isChecked) +{ + if (this->isChecked != isChecked) { + this->isChecked = isChecked; + imgFile = isChecked ? imgOnFile : imgOffFile; + this->update(); + } +} + +ImageSwitch::ButtonStyle ImageSwitch::getButtonStyle() const +{ + return this->buttonStyle; +} + +void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle &buttonStyle) +{ + if (this->buttonStyle != buttonStyle) { + this->buttonStyle = buttonStyle; + + if (buttonStyle == ButtonStyle_1) { + imgOffFile = ":/res/switch/switch_close.png"; + imgOnFile = ":/res/switch/switch_open.png"; + this->resize(87, 28); + } else if (buttonStyle == ButtonStyle_2) { + imgOffFile = ":/res/switch/switch_close1.png"; + imgOnFile = ":/res/switch/switch_open1.png"; + this->resize(87, 28); + } else if (buttonStyle == ButtonStyle_3) { + imgOffFile = ":/res/switch/switch_close3.png"; + imgOnFile = ":/res/switch/switch_open3.png"; + this->resize(96, 38); + } + + imgFile = isChecked ? imgOnFile : imgOffFile; + setChecked(isChecked); + this->update(); + updateGeometry(); + } +} diff --git a/imageswitch.h b/imageswitch.h new file mode 100644 index 0000000..ec441c3 --- /dev/null +++ b/imageswitch.h @@ -0,0 +1,56 @@ +#ifndef IMAGESWITCH_H +#define IMAGESWITCH_H + +#include + +class ImageSwitch : public QWidget +{ + Q_OBJECT + + Q_ENUMS(ButtonStyle) + + Q_PROPERTY(bool isChecked READ getChecked WRITE setChecked) + Q_PROPERTY(ButtonStyle buttonStyle READ getButtonStyle WRITE setButtonStyle) + +public: + ImageSwitch(); + + + enum ButtonStyle { + ButtonStyle_1 = 0, //开关样式1 + ButtonStyle_2 = 1, //开关样式2 + ButtonStyle_3 = 2 //开关样式3 + }; + explicit ImageSwitch(QWidget *parent = 0); + +protected: + void mousePressEvent(QMouseEvent *); + void paintEvent(QPaintEvent *event); + +private: + bool isChecked; //是否选中 + ButtonStyle buttonStyle; //按钮样式 + + QString imgOffFile; //关闭图片 + QString imgOnFile; //开启图片 + QString imgFile; //当前图片 + +public: + //默认尺寸和最小尺寸 + QSize sizeHint() const; + QSize minimumSizeHint() const; + + //获取和设置是否选中 + bool getChecked() const; + void setChecked(bool isChecked); + + //获取和设置按钮样式 + ButtonStyle getButtonStyle() const; + void setButtonStyle(const ImageSwitch::ButtonStyle &buttonStyle); + +signals: + void checkedChanged(bool checked); + +}; + +#endif // IMAGESWITCH_H diff --git a/mainwindow.qrc b/mainwindow.qrc index e1411a7..5ee3888 100644 --- a/mainwindow.qrc +++ b/mainwindow.qrc @@ -30,5 +30,13 @@ res/lamp/red.png res/lamp/white.png res/lamp/yellow.png + res/switch/switch_close.png + res/switch/switch_open.png + res/switch/switch_close1.png + res/switch/switch_close2.png + res/switch/switch_open1.png + res/switch/switch_open2.png + res/switch/switch_close3.png + res/switch/switch_open3.png diff --git a/res/switch/switch_close.png b/res/switch/switch_close.png new file mode 100644 index 0000000..f234ef5 Binary files /dev/null and b/res/switch/switch_close.png differ diff --git a/res/switch/switch_close1.png b/res/switch/switch_close1.png new file mode 100644 index 0000000..ed75e59 Binary files /dev/null and b/res/switch/switch_close1.png differ diff --git a/res/switch/switch_close2.png b/res/switch/switch_close2.png new file mode 100644 index 0000000..29b57b9 Binary files /dev/null and b/res/switch/switch_close2.png differ diff --git a/res/switch/switch_close3.png b/res/switch/switch_close3.png new file mode 100644 index 0000000..fec2c06 Binary files /dev/null and b/res/switch/switch_close3.png differ diff --git a/res/switch/switch_open.png b/res/switch/switch_open.png new file mode 100644 index 0000000..50ea279 Binary files /dev/null and b/res/switch/switch_open.png differ diff --git a/res/switch/switch_open1.png b/res/switch/switch_open1.png new file mode 100644 index 0000000..0fe3ec7 Binary files /dev/null and b/res/switch/switch_open1.png differ diff --git a/res/switch/switch_open2.png b/res/switch/switch_open2.png new file mode 100644 index 0000000..e3c0e42 Binary files /dev/null and b/res/switch/switch_open2.png differ diff --git a/res/switch/switch_open3.png b/res/switch/switch_open3.png new file mode 100644 index 0000000..e55a16c Binary files /dev/null and b/res/switch/switch_open3.png differ