红外检测开关修改为开关样式,删除观瞄型设置

video_old
caoyuhui 6 months ago
parent cc115d2201
commit 7f2334513e

@ -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 += \

@ -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) {

@ -17,6 +17,7 @@
#include <QWidget>
#include <vector>
#include <windows.h>
#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();

@ -80,7 +80,7 @@
<enum>QTabWidget::TabShape::Rounded</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>5</number>
</property>
<property name="elideMode">
<enum>Qt::TextElideMode::ElideNone</enum>
@ -1171,7 +1171,7 @@
<widget class="QPushButton" name="pushButton_4_18">
<property name="geometry">
<rect>
<x>600</x>
<x>590</x>
<y>50</y>
<width>100</width>
<height>30</height>
@ -1347,7 +1347,7 @@
<widget class="QComboBox" name="comboBox_4_1">
<property name="geometry">
<rect>
<x>490</x>
<x>480</x>
<y>10</y>
<width>101</width>
<height>31</height>
@ -1357,7 +1357,7 @@
<widget class="QPushButton" name="pushButton_4_17">
<property name="geometry">
<rect>
<x>600</x>
<x>590</x>
<y>10</y>
<width>101</width>
<height>30</height>
@ -1373,7 +1373,7 @@
<widget class="QComboBox" name="comboBox_4_2">
<property name="geometry">
<rect>
<x>490</x>
<x>480</x>
<y>50</y>
<width>101</width>
<height>31</height>
@ -1383,34 +1383,30 @@
<widget class="QGroupBox" name="groupBox_4_1">
<property name="geometry">
<rect>
<x>720</x>
<x>710</x>
<y>10</y>
<width>201</width>
<height>161</height>
<width>181</width>
<height>151</height>
</rect>
</property>
<property name="title">
<string>红外报警设置</string>
</property>
<widget class="QComboBox" name="comboBox_4_3">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>71</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_4_19">
<property name="geometry">
<rect>
<x>100</x>
<y>120</y>
<x>80</x>
<y>110</y>
<width>71</width>
<height>31</height>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
@ -1418,22 +1414,12 @@
<string>设置</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_4_1">
<property name="geometry">
<rect>
<x>80</x>
<y>40</y>
<width>91</width>
<height>23</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_4_2">
<property name="geometry">
<rect>
<x>80</x>
<y>80</y>
<width>91</width>
<x>75</x>
<y>70</y>
<width>81</width>
<height>23</height>
</rect>
</property>
@ -1441,9 +1427,9 @@
<widget class="QLabel" name="label_4_3">
<property name="geometry">
<rect>
<x>180</x>
<y>80</y>
<width>16</width>
<x>160</x>
<y>70</y>
<width>14</width>
<height>21</height>
</rect>
</property>
@ -1451,30 +1437,40 @@
<string>℃</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_4_1">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<x>5</x>
<y>70</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>观瞄型</string>
<string>温度阈值</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_4_2">
<widget class="ImageSwitch" name="swtichButton_4_1" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<x>60</x>
<y>30</y>
<width>71</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_13">
<property name="geometry">
<rect>
<x>5</x>
<y>30</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>测温型</string>
<string>检测开关</string>
</property>
</widget>
</widget>
@ -2208,6 +2204,14 @@ font: 12pt &quot;Microsoft YaHei UI&quot;;</string>
</widget>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>ImageSwitch</class>
<extends>QWidget</extends>
<header>imageswitch.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

@ -0,0 +1,89 @@
#include "imageswitch.h"
#include <QPainter>
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();
}
}

@ -0,0 +1,56 @@
#ifndef IMAGESWITCH_H
#define IMAGESWITCH_H
#include <QWidget>
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

@ -30,5 +30,13 @@
<file>res/lamp/red.png</file>
<file>res/lamp/white.png</file>
<file>res/lamp/yellow.png</file>
<file>res/switch/switch_close.png</file>
<file>res/switch/switch_open.png</file>
<file>res/switch/switch_close1.png</file>
<file>res/switch/switch_close2.png</file>
<file>res/switch/switch_open1.png</file>
<file>res/switch/switch_open2.png</file>
<file>res/switch/switch_close3.png</file>
<file>res/switch/switch_open3.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Loading…
Cancel
Save