diff --git a/.gitignore b/.gitignore index 16a004e..aaf9aab 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,6 @@ CMakeLists.txt.user* .rcc/ .uic/ /build*/ +.vs/ +*.json +/out/ \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef4ecb7..0ac9992 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,7 +13,9 @@ qt_add_executable(VideoClient videoControl.h videoControl.ui videoControl.cpp wprogressbar.h wprogressbar.cpp webmapwidget.h webmapwidget.cpp - + utils/CUdpSocket.cpp utils/CUdpSocket.h + utils/protocolPodTJ.cpp utils/protocolPodTJ.h + utils/switchbutton.h utils/switchbutton.cpp ) qt6_add_resources(VideoClient "resources" @@ -28,7 +30,7 @@ set(FFMPEG_DIR ${3RDPARTY_DIR}/ffmpeg) # add_subdirectory(shared) add_subdirectory(video) add_subdirectory(3rdparty) - +# add_subdirectory(utils) target_link_libraries(VideoClient PRIVATE diff --git a/src/commandwidget.cpp b/src/commandwidget.cpp index 829c58b..1a9ddcf 100644 --- a/src/commandwidget.cpp +++ b/src/commandwidget.cpp @@ -1,6 +1,8 @@ #include "commandwidget.h" #include "ui_commandwidget.h" +#include <QIntValidator> +#include "utils/switchbutton.h" CommandWidget::CommandWidget(QWidget *parent) : QWidget(parent), ui(new Ui::CommandWidget) { @@ -13,6 +15,10 @@ CommandWidget::CommandWidget(QWidget *parent) } else { qDebug() << "绑定 UDP 套接字失败"; } + + //创建自定义套接字 + m_CUdpSocket = new CUdpSocket(this); + initmUdpParam(); } CommandWidget::~CommandWidget() { @@ -78,6 +84,21 @@ void CommandWidget::buttonResponse(quint8 cmd) { } } +void CommandWidget::receiveUavTypeIndex(int index) +{ + switch (index) + { + case FP98: + ui->cmdStackedWidget->setCurrentWidget(ui->stackedWidgetPage1); + break; + case MEDICAL_UNIVERSITY: + ui->cmdStackedWidget->setCurrentWidget(ui->stackedWidgePage2); + break; + default: + break; + } +} + void CommandWidget::on_pushButton_clicked() { buttonResponse(0x75); } @@ -145,3 +166,450 @@ void CommandWidget::on_pushButton_16_clicked() { void CommandWidget::on_pushButton_15_clicked() { buttonResponse(0xC9); } + + +/** 武汉天进吊舱 */ +void CommandWidget::on_pushButton_left_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7000"), + m_protocolPodTJ.cmdLeft(ui->cmdSlider->value()))); +} + + +void CommandWidget::on_pushButton_left_released() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7000"), + QByteArray::fromHex("00000000"))); +} + + +void CommandWidget::on_pushButton_right_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7000"), + m_protocolPodTJ.cmdRight(ui->cmdSlider->value()))); +} + + +void CommandWidget::on_pushButton_right_released() +{ + on_pushButton_left_released(); +} + + +void CommandWidget::on_pushButton_up_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7000"), + m_protocolPodTJ.cmdUp(ui->cmdSlider->value()))); +} + + +void CommandWidget::on_pushButton_up_released() +{ + on_pushButton_left_released(); +} + +void CommandWidget::on_pushButton_down_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7000"), + m_protocolPodTJ.cmdDown(ui->cmdSlider->value()))); +} + +void CommandWidget::on_pushButton_down_released() +{ + on_pushButton_left_released(); +} + + +void CommandWidget::on_pushButton_center_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7100"))); +} + + +void CommandWidget::on_pushButton_guid_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7200"), + m_protocolPodTJ.digitalGuid(ui->guidLineEdit->text().toInt(), ui->poseLineEdit->text().toInt()))); +} + + +void CommandWidget::on_pushButton_pose_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7C00"), + m_protocolPodTJ.digitalGuid(ui->guidLineEdit->text().toInt(), ui->poseLineEdit->text().toInt()))); +} + + +void CommandWidget::on_pushButton_directL_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7A00"))); +} + + +void CommandWidget::on_pushButton_directS_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7B00"))); +} + + +void CommandWidget::on_pushButton_lookDown_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7300"))); +} + + +void CommandWidget::on_pushButton_packUp_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7400"))); +} + +void CommandWidget::on_pushButton_scanning_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7900"))); +} + + +void CommandWidget::on_pushButton_close_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7500"))); +} + +void CommandWidget::on_comboBox1_activated(int index) +{ + if (index >= 0) + { + QByteArray data = ui->comboBox1->currentData().toByteArray(); + //qDebug() << data.toHex(); + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("2300"),data)); + } +} + +void CommandWidget::on_comboBox2_activated(int index) +{ + if (index >= 0) + { + QByteArray data = ui->comboBox2->currentData().toByteArray(); + //qDebug() << data.toHex(); + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("2500"), data)); + + } +} + +void CommandWidget::on_pushButton_videoSwitch_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("3100"))); +} + +void CommandWidget::on_pushButton_video_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("3300"))); +} + +void CommandWidget::on_pushButton_photo_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("3200"))); +} + +void CommandWidget::on_pushButton_zoomp_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4500"), + m_protocolPodTJ.cmdZoom(0x01,ui->comboBox3->currentIndex()))); +} + +void CommandWidget::on_pushButton_zoomp_released() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4500"))); +} + +void CommandWidget::on_pushButton_zoomd_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4500"), + m_protocolPodTJ.cmdZoom(0x02, ui->comboBox3->currentIndex()))); +} + +void CommandWidget::on_pushButton_zoomd_released() +{ + on_pushButton_zoomp_released(); +} + +void CommandWidget::on_pushButton_focusP_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4500"), + m_protocolPodTJ.cmdZoom(0x03, ui->comboBox3->currentIndex()))); +} + +void CommandWidget::on_pushButton_focusP_released() +{ + on_pushButton_zoomp_released(); +} + +void CommandWidget::on_pushButton_focusD_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4500"), + m_protocolPodTJ.cmdZoom(0x04, ui->comboBox3->currentIndex()))); +} + +void CommandWidget::on_pushButton_focusD_released() +{ + on_pushButton_zoomp_released(); +} + +void CommandWidget::on_pushButton_auto_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4500"), + m_protocolPodTJ.cmdZoom(0x05, 0x00))); +} + +void CommandWidget::on_pushButton_auto_released() +{ + on_pushButton_zoomp_released(); +} + +void CommandWidget::on_pushButton_contrastP_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4100"), + QByteArray::fromHex("01010000"))); +} + +void CommandWidget::on_pushButton_contrastD_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4100"), + QByteArray::fromHex("01020000"))); +} + +void CommandWidget::on_pushButton_lightP_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4100"), + QByteArray::fromHex("02010000"))); +} + +void CommandWidget::on_pushButton_lightD_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4100"), + QByteArray::fromHex("02020000"))); +} + +void CommandWidget::on_comboBox4_activated(int index) +{ + if (index >= 0) + { + QByteArray data = ui->comboBox4->currentData().toByteArray(); + //qDebug() << data.toHex(); + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4A00"), data)); + } +} + +void CommandWidget::on_pushButton_zoomp_2_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("5000"), + QByteArray::fromHex("0F000000"))); +} + +void CommandWidget::on_pushButton_zoomp_2_released() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("5000"), + QByteArray::fromHex("00000000"))); +} + +void CommandWidget::on_pushButton_zoomd_2_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("5000"), + QByteArray::fromHex("10000000"))); +} + +void CommandWidget::on_pushButton_zoomd_2_released() +{ + on_pushButton_zoomp_2_released(); +} + +void CommandWidget::on_pushButton_contrastP_2_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("5A00"))); +} + +void CommandWidget::on_pushButton_contrastD_2_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("5A00"), + QByteArray::fromHex("01000000"))); +} + +void CommandWidget::on_pushButton_color_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("5300"))); +} + +void CommandWidget::on_comboBox5_activated(int index) +{ + if (index >= 0) + { + QByteArray data = ui->comboBox5->currentData().toByteArray(); + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("5300"), data)); + } +} + +void CommandWidget::on_pushButton_distance_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("3D00"))); +} + +void CommandWidget::on_pushButton_distanceC_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("3E00"), + m_protocolPodTJ.cmdLaser(ui->comboBox6->currentIndex() + 1))); +} + +void CommandWidget::on_pushButton_distanceS_pressed() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("3F00"))); +} + +void CommandWidget::on_cmdLineEdit_textChanged(const QString text) +{ + qDebug() << text; + if (text.toInt() < 10)//数据小于10不响应 + { + return; + } + ui->cmdSlider->setMaximum(text.toInt()); +} + +void CommandWidget::setPodIPConfig(NetworkIPStruct networkIP, bool isConnect) +{ + qDebug() << "ip设置槽函数调用了"; + + if (!isConnect) + { + m_CUdpSocket->close(); + return; + } + + if (m_CUdpSocket->close()) + { + if (!m_CUdpSocket->bind(networkIP.localIP, networkIP.localPort)) + { + qDebug() << "端口号绑定失败"; + } + + //绑定目标IP Port + m_CUdpSocket->setTargetInfo(networkIP.remoteIP, networkIP.remotePort); + } + +} + +void CommandWidget::setMoveParm(QPointF size) +{ + int x = std::clamp(static_cast<int>(size.x() / 10), -60, 60); + int y = std::clamp(static_cast<int>(-size.y() / 10), -60, 60); + qDebug() << "缩减之后的屏幕滑动参数==>" << "x:" << x << "y:" << y; + + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("7000"), + m_protocolPodTJ.cmdServo(x, y))); +} + + +void CommandWidget::stopServo() +{ + on_pushButton_left_released(); +} + +void CommandWidget::setTargetTracking(double dir, double pitch) +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("3A00"), + m_protocolPodTJ.targetTracking(static_cast<int>(std::round(dir)), static_cast<int>(std::round(pitch))))); +} + +void CommandWidget::setStopTracking() +{ + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("3B00"))); +} + +/***武汉天进吊舱控制***/ +void CommandWidget::initmUdpParam() +{ + if (!m_CUdpSocket->bind("172.10.0.249", 10001)) + { + qDebug() << "端口号绑定失败"; + } + + //绑定目标IP Port + m_CUdpSocket->setTargetInfo("172.10.0.249", 10000); + + QIntValidator* validator = new QIntValidator(0, 100, this); + ui->cmdLineEdit->setValidator(validator); + ui->cmdLineEdit->setText("40"); + ui->cmdSlider->setValue(20); + + //AI开关 + connect(ui->switchButton1, &WBSwitchButton::sigSwitchChanged, this, [=](bool onOroff){ + if (onOroff) //开关打开 + { + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("9100"), + QByteArray::fromHex("01000000"))); + } + else + { + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("9100"))); + } + }); + + ui->comboBox1->addItem("16 * 16", QByteArray::fromHex("01000000")); + ui->comboBox1->addItem("32 * 32", QByteArray::fromHex("02000000")); + ui->comboBox1->addItem("64 * 64", QByteArray::fromHex("03000000")); + ui->comboBox1->addItem("128 * 128", QByteArray::fromHex("04000000")); + + ui->comboBox2->addItem("红外", QByteArray::fromHex("00000000")); + ui->comboBox2->addItem("可见光", QByteArray::fromHex("01000000")); + ui->comboBox2->addItem("上下分屏", QByteArray::fromHex("02000000")); + ui->comboBox2->addItem("画中画1", QByteArray::fromHex("03000000")); + ui->comboBox2->addItem("画中画2", QByteArray::fromHex("04000000")); + ui->comboBox2->addItem("左右分屏", QByteArray::fromHex("05000000")); + + ui->comboBox3->setCurrentIndex(4); + + //低照度 + connect(ui->btn_light, &WBSwitchButton::sigSwitchChanged, this, [=](bool onOroff) { + if (onOroff) //开关打开 + { + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4B00"), + QByteArray::fromHex("01000000"))); + } + else + { + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4B00"))); + } + }); + + //电子稳像 + connect(ui->btn_stable, &WBSwitchButton::sigSwitchChanged, this, [=](bool onOroff) { + if (onOroff) //开关打开 + { + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4100"), + QByteArray::fromHex("04010000"))); + } + else + { + m_CUdpSocket->sendData(ProtocolPodTJ::encode(QByteArray::fromHex("4100"), + QByteArray::fromHex("04020000"))); + } + }); + + //图像去雾 + ui->comboBox4->addItem("关", QByteArray::fromHex("00000000")); + ui->comboBox4->addItem("低", QByteArray::fromHex("01000000")); + ui->comboBox4->addItem("中", QByteArray::fromHex("02000000")); + ui->comboBox4->addItem("强", QByteArray::fromHex("03000000")); + + //伪彩选择 + ui->comboBox5->addItem("白热", QByteArray::fromHex("01000000")); + ui->comboBox5->addItem("黑热", QByteArray::fromHex("01010000")); + ui->comboBox5->addItem("蓝红黄", QByteArray::fromHex("01020000")); + ui->comboBox5->addItem("紫红黄", QByteArray::fromHex("01030000")); + ui->comboBox5->addItem("蓝绿红", QByteArray::fromHex("01040000")); + ui->comboBox5->addItem("彩虹1", QByteArray::fromHex("01050000")); + ui->comboBox5->addItem("彩虹2", QByteArray::fromHex("01060000")); + ui->comboBox5->addItem("黑-红", QByteArray::fromHex("01070000")); + ui->comboBox5->addItem("墨绿-红", QByteArray::fromHex("01080000")); + ui->comboBox5->addItem("蓝绿红-粉", QByteArray::fromHex("01090000")); + ui->comboBox5->addItem("混合色", QByteArray::fromHex("010A0000")); + ui->comboBox5->addItem("红头", QByteArray::fromHex("010B0000")); +} \ No newline at end of file diff --git a/src/commandwidget.h b/src/commandwidget.h index f042863..4b83908 100644 --- a/src/commandwidget.h +++ b/src/commandwidget.h @@ -6,6 +6,8 @@ #include "communicationsettingdlg.h" #include "global.h" +#include "utils/CUdpSocket.h" +#include "utils/protocolPodTJ.h" typedef struct struProtocalKB { quint8 head[2]; // 帧头0x @@ -71,6 +73,12 @@ const quint16 CRC8TAB[256] = { 0x0082, 0x00B3, 0x00E0, 0x00D1, 0x0046, 0x0077, 0x0024, 0x0015, 0x003B, 0x000A, 0x0059, 0x0068, 0x00FF, 0x00CE, 0x009D, 0x00AC}; +enum uav_type +{ + FP98=0, + MEDICAL_UNIVERSITY=5 +}; + namespace Ui { class CommandWidget; } @@ -122,18 +130,123 @@ private slots: void on_pushButton_15_clicked(); + /*武汉天进吊舱控制*/ + void on_pushButton_left_pressed(); + void on_pushButton_left_released(); + + void on_pushButton_right_pressed(); + void on_pushButton_right_released(); + + void on_pushButton_up_pressed(); + void on_pushButton_up_released(); + + void on_pushButton_down_pressed(); + void on_pushButton_down_released(); + + void on_pushButton_center_pressed(); + + //姿态指引 + void on_pushButton_guid_pressed(); + void on_pushButton_pose_pressed(); + + //航向锁定 + void on_pushButton_directL_pressed(); + //航向随动 + void on_pushButton_directS_pressed(); + //垂直下视 + void on_pushButton_lookDown_pressed(); + //镜头收藏 + void on_pushButton_packUp_pressed(); + //扫描 + void on_pushButton_scanning_pressed(); + //关伺服 + void on_pushButton_close_pressed(); + //设置检测模板 + void on_comboBox1_activated(int index); + //显示模式 + void on_comboBox2_activated(int index); + //视频切换 + void on_pushButton_videoSwitch_pressed(); + //开始录像 + void on_pushButton_video_pressed(); + //拍照 + void on_pushButton_photo_pressed(); + //可见光变倍+ + void on_pushButton_zoomp_pressed(); + void on_pushButton_zoomp_released(); + //可见光变倍- + void on_pushButton_zoomd_pressed(); + void on_pushButton_zoomd_released(); + //可见光变焦+ + void on_pushButton_focusP_pressed(); + void on_pushButton_focusP_released(); + //可见光变焦- + void on_pushButton_focusD_pressed(); + void on_pushButton_focusD_released(); + //自动对焦 + void on_pushButton_auto_pressed(); + void on_pushButton_auto_released(); + //对比度 + void on_pushButton_contrastP_pressed(); + void on_pushButton_contrastD_pressed(); + //亮度 + void on_pushButton_lightP_pressed(); + void on_pushButton_lightD_pressed(); + //图像去雾 + void on_comboBox4_activated(int index); + //红外变倍+ + void on_pushButton_zoomp_2_pressed(); + void on_pushButton_zoomp_2_released(); + //红外变倍- + void on_pushButton_zoomd_2_pressed(); + void on_pushButton_zoomd_2_released(); + //对比度 + void on_pushButton_contrastP_2_pressed(); + void on_pushButton_contrastD_2_pressed(); + //伪彩循环切换 + void on_pushButton_color_pressed(); + //伪彩选择 + void on_comboBox5_activated(int index); + //单次测距 + void on_pushButton_distance_pressed(); + //连续测距 + void on_pushButton_distanceC_pressed(); + //停止测距 + void on_pushButton_distanceS_pressed(); + + void on_cmdLineEdit_textChanged(const QString text); + private: Ui::CommandWidget *ui; QUdpSocket *m_commandUdpSocket = nullptr; QString m_remoteIP; int m_remotePort; + CUdpSocket* m_CUdpSocket = nullptr; + ProtocolPodTJ m_protocolPodTJ; unsigned char getCrc(quint8 *data, quint8 length); ProtocalKB EncodeCommandCmd(quint8 cmd); bool writeBufferToClient(const QByteArray &data); void buttonResponse(quint8 cmd); + + void initmUdpParam(); + +public slots: + void receiveUavTypeIndex(int index); + + //设置通信IP及Port 连接udp + void setPodIPConfig(NetworkIPStruct networkIP, bool isConnect); +public: + //设置窗口传递参数 + void setMoveParm(QPointF size); + //伺服停止 + void stopServo(); + //目标跟踪 + void setTargetTracking(double dir, double pitch); + //停止跟踪 + void setStopTracking(); }; #endif // COMMANDWIDGET_H diff --git a/src/commandwidget.ui b/src/commandwidget.ui index daed3d5..2007436 100644 --- a/src/commandwidget.ui +++ b/src/commandwidget.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>295</width> - <height>541</height> + <height>819</height> </rect> </property> <property name="windowTitle"> @@ -30,7 +30,7 @@ <number>0</number> </property> <item> - <widget class="QFrame" name="frame"> + <widget class="QStackedWidget" name="cmdStackedWidget"> <property name="styleSheet"> <string notr="true">#frame{ border: 1px solid white; @@ -43,175 +43,1322 @@ <property name="frameShadow"> <enum>QFrame::Shadow::Raised</enum> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="leftMargin"> - <number>2</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>2</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <layout class="QGridLayout" name="gridLayout"> + <property name="currentIndex"> + <number>1</number> + </property> + <widget class="QWidget" name="stackedWidgetPage1"> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <layout class="QGridLayout" name="gridLayout"> + <property name="leftMargin"> + <number>6</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>6</number> + </property> + <property name="bottomMargin"> + <number>6</number> + </property> + <property name="spacing"> + <number>14</number> + </property> + <item row="4" column="0"> + <widget class="QPushButton" name="pushButton_10"> + <property name="text"> + <string>红外小</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QPushButton" name="pushButton_8"> + <property name="text"> + <string>画中画开</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QPushButton" name="pushButton_7"> + <property name="text"> + <string>画中画关</string> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QPushButton" name="pushButton_15"> + <property name="text"> + <string>4-6图拼接</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QPushButton" name="pushButton_17"> + <property name="text"> + <string>图像切换</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QPushButton" name="pushButton_5"> + <property name="text"> + <string>变焦推远</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QPushButton" name="pushButton_6"> + <property name="text"> + <string>变焦拉近</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPushButton" name="pushButton_13"> + <property name="text"> + <string>吊舱</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QPushButton" name="pushButton_9"> + <property name="text"> + <string>红外大</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="pushButton_12"> + <property name="text"> + <string>复位</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QPushButton" name="pushButton_14"> + <property name="text"> + <string>扫描</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QPushButton" name="pushButton_11"> + <property name="text"> + <string>锁定</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="pushButton_4"> + <property name="text"> + <string>俯仰+</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>方位+</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QPushButton" name="pushButton_2"> + <property name="text"> + <string>方位-</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="pushButton_3"> + <property name="text"> + <string>俯仰-</string> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QPushButton" name="pushButton_16"> + <property name="text"> + <string>0-3图拼接</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>219</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <widget class="QWidget" name="stackedWidgePage2"> + <widget class="QWidget" name="widget" native="true"> + <property name="geometry"> + <rect> + <x>10</x> + <y>70</y> + <width>110</width> + <height>110</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout_3"> <property name="leftMargin"> - <number>6</number> + <number>0</number> </property> <property name="topMargin"> - <number>8</number> + <number>0</number> </property> <property name="rightMargin"> - <number>6</number> + <number>0</number> </property> <property name="bottomMargin"> - <number>6</number> + <number>0</number> </property> <property name="spacing"> - <number>14</number> + <number>0</number> </property> - <item row="4" column="0"> - <widget class="QPushButton" name="pushButton_10"> - <property name="text"> - <string>红外小</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QPushButton" name="pushButton_8"> + <item row="1" column="0"> + <widget class="QPushButton" name="pushButton_left"> <property name="text"> - <string>画中画开</string> + <string/> </property> </widget> </item> <item row="1" column="2"> - <widget class="QPushButton" name="pushButton_7"> + <widget class="QPushButton" name="pushButton_right"> <property name="text"> - <string>画中画关</string> + <string/> </property> </widget> </item> - <item row="5" column="2"> - <widget class="QPushButton" name="pushButton_15"> + <item row="2" column="1"> + <widget class="QPushButton" name="pushButton_down"> <property name="text"> - <string>4-6图拼接</string> + <string/> </property> </widget> </item> - <item row="4" column="1"> - <widget class="QPushButton" name="pushButton_17"> + <item row="1" column="1"> + <widget class="QPushButton" name="pushButton_center"> <property name="text"> - <string>图像切换</string> + <string/> </property> </widget> </item> - <item row="2" column="0"> - <widget class="QPushButton" name="pushButton_5"> + <item row="0" column="1"> + <widget class="QPushButton" name="pushButton_up"> <property name="text"> - <string>变焦推远</string> + <string/> </property> </widget> </item> - <item row="3" column="0"> - <widget class="QPushButton" name="pushButton_6"> - <property name="text"> - <string>变焦拉近</string> + </layout> + </widget> + <widget class="QSlider" name="cmdSlider"> + <property name="geometry"> + <rect> + <x>32</x> + <y>20</y> + <width>191</width> + <height>22</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">/*滑块的样式*/ +QSlider::groove:horizontal { +border: 1px solid #64AA64; +background: #64AA64; +height: 2px; +border-radius: 1px; +padding-left:0px; +padding-right:0px; +} + +/*滑块经过的颜色:前面的颜色*/ +QSlider::sub-page:horizontal { +background: #64AA64; +border: 1px solid #64AA64; +height: 2px; +border-radius: 2px; +} + +QSlider::add-page:horizontal { +background: #EAEAEA; +border: 0px solid #EAEAEA; +height: 2px; +border-radius: 2px; +} +QSlider::handle:horizontal +{ + background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, + stop:0.6 #64AA64,stop:0.98409 rgba(255, 255, 255, 255)); + + width: 15px; + margin-top: -6px; + margin-bottom: -6px; + border-radius: 5px; +} + +QSlider::handle:horizontal:hover { + background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, + stop:0.6 #64AA64,stop:0.98409 rgba(255, 255, 255, 255)); + + width: 15px; + margin-top: -6px; + margin-bottom: -6px; + border-radius: 5px; +}</string> + </property> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + </widget> + <widget class="QLineEdit" name="cmdLineEdit"> + <property name="geometry"> + <rect> + <x>230</x> + <y>20</y> + <width>31</width> + <height>21</height> + </rect> + </property> + </widget> + <widget class="QPushButton" name="pushButton_guid"> + <property name="geometry"> + <rect> + <x>130</x> + <y>50</y> + <width>61</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>数字引导</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_pose"> + <property name="geometry"> + <rect> + <x>200</x> + <y>50</y> + <width>61</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>姿态引导</string> + </property> + </widget> + <widget class="QLineEdit" name="guidLineEdit"> + <property name="geometry"> + <rect> + <x>160</x> + <y>90</y> + <width>31</width> + <height>21</height> + </rect> + </property> + </widget> + <widget class="QLineEdit" name="poseLineEdit"> + <property name="geometry"> + <rect> + <x>230</x> + <y>90</y> + <width>31</width> + <height>21</height> + </rect> + </property> + </widget> + <widget class="QLabel" name="label"> + <property name="geometry"> + <rect> + <x>128</x> + <y>90</y> + <width>31</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>方位:</string> + </property> + </widget> + <widget class="QLabel" name="label_2"> + <property name="geometry"> + <rect> + <x>198</x> + <y>90</y> + <width>31</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>俯仰:</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_diectionL"> + <property name="geometry"> + <rect> + <x>130</x> + <y>120</y> + <width>61</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>航向锁定</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_diectionS"> + <property name="geometry"> + <rect> + <x>200</x> + <y>120</y> + <width>61</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>航向随动</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_lookDown"> + <property name="geometry"> + <rect> + <x>130</x> + <y>150</y> + <width>61</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>垂直下视</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_packUp"> + <property name="geometry"> + <rect> + <x>200</x> + <y>150</y> + <width>61</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>镜头收藏</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_scanning"> + <property name="geometry"> + <rect> + <x>130</x> + <y>180</y> + <width>61</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>扫描</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_close"> + <property name="geometry"> + <rect> + <x>200</x> + <y>180</y> + <width>61</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>关伺服</string> + </property> + </widget> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>0</x> + <y>210</y> + <width>281</width> + <height>51</height> + </rect> + </property> + <property name="title"> + <string>检测跟踪</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>5</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label_3"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>20</height> + </size> </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QPushButton" name="pushButton_13"> <property name="text"> - <string>吊舱</string> + <string>检测框:</string> </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QPushButton" name="pushButton_9"> - <property name="text"> - <string>红外大</string> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignCenter</set> </property> </widget> </item> - <item row="2" column="2"> - <widget class="QPushButton" name="pushButton_12"> - <property name="text"> - <string>复位</string> + <item> + <widget class="WBSwitchButton" name="switchButton1" native="true"> + <property name="maximumSize"> + <size> + <width>40</width> + <height>20</height> + </size> </property> </widget> </item> - <item row="2" column="1"> - <widget class="QPushButton" name="pushButton_14"> - <property name="text"> - <string>扫描</string> + <item> + <widget class="QLabel" name="label_4"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>20</height> + </size> </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QPushButton" name="pushButton_11"> <property name="text"> - <string>锁定</string> + <string>模板大小</string> </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QPushButton" name="pushButton_4"> - <property name="text"> - <string>俯仰+</string> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignCenter</set> </property> </widget> </item> + <item> + <widget class="QComboBox" name="comboBox1"/> + </item> + </layout> + </widget> + <widget class="QGroupBox" name="groupBox_2"> + <property name="geometry"> + <rect> + <x>0</x> + <y>260</y> + <width>281</width> + <height>61</height> + </rect> + </property> + <property name="title"> + <string>视频</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> <item row="0" column="0"> - <widget class="QPushButton" name="pushButton"> - <property name="text"> - <string>方位+</string> - </property> - </widget> + <widget class="QComboBox" name="comboBox2"/> </item> - <item row="1" column="0"> - <widget class="QPushButton" name="pushButton_2"> + <item row="0" column="2"> + <widget class="QPushButton" name="pushButton_video"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> <property name="text"> - <string>方位-</string> + <string>开始录像</string> </property> </widget> </item> - <item row="1" column="1"> - <widget class="QPushButton" name="pushButton_3"> + <item row="0" column="1"> + <widget class="QPushButton" name="pushButton_videoSwitch"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> <property name="text"> - <string>俯仰-</string> + <string>视频切换</string> </property> </widget> </item> - <item row="4" column="2"> - <widget class="QPushButton" name="pushButton_16"> + <item row="0" column="3"> + <widget class="QPushButton" name="pushButton_photo"> <property name="text"> - <string>0-3图拼接</string> + <string>拍照</string> </property> </widget> </item> </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Orientation::Vertical</enum> + </widget> + <widget class="QGroupBox" name="groupBox_5"> + <property name="geometry"> + <rect> + <x>0</x> + <y>320</y> + <width>281</width> + <height>171</height> + </rect> + </property> + <property name="title"> + <string>可见光</string> + </property> + <widget class="QPushButton" name="pushButton_zoomp"> + <property name="geometry"> + <rect> + <x>10</x> + <y>56</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>变倍+</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_focusP"> + <property name="geometry"> + <rect> + <x>73</x> + <y>56</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>变焦+</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_contrastP"> + <property name="geometry"> + <rect> + <x>136</x> + <y>56</y> + <width>60</width> + <height>24</height> + </rect> </property> - <property name="sizeHint" stdset="0"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>对比度+</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_lightP"> + <property name="geometry"> + <rect> + <x>199</x> + <y>56</y> + <width>72</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>亮度+</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_zoomd"> + <property name="geometry"> + <rect> + <x>10</x> + <y>85</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>变倍-</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_focusP_2"> + <property name="geometry"> + <rect> + <x>73</x> + <y>85</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>变焦-</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_contrastD"> + <property name="geometry"> + <rect> + <x>136</x> + <y>85</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>对比度-</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_lightD"> + <property name="geometry"> + <rect> + <x>199</x> + <y>85</y> + <width>72</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>亮度-</string> + </property> + </widget> + <widget class="QLabel" name="label_10"> + <property name="geometry"> + <rect> + <x>10</x> + <y>29</y> + <width>60</width> + <height>16</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>速度:</string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignCenter</set> + </property> + </widget> + <widget class="QComboBox" name="comboBox3"> + <property name="geometry"> + <rect> + <x>73</x> + <y>27</y> + <width>45</width> + <height>24</height> + </rect> + </property> + <property name="currentText"> + <string>0</string> + </property> + <item> + <property name="text"> + <string>0</string> + </property> + </item> + <item> + <property name="text"> + <string>1</string> + </property> + </item> + <item> + <property name="text"> + <string>2</string> + </property> + </item> + <item> + <property name="text"> + <string>3</string> + </property> + </item> + <item> + <property name="text"> + <string>4</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + <item> + <property name="text"> + <string>6</string> + </property> + </item> + <item> + <property name="text"> + <string>7</string> + </property> + </item> + </widget> + <widget class="QLabel" name="label_11"> + <property name="geometry"> + <rect> + <x>136</x> + <y>29</y> + <width>60</width> + <height>16</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>透雾:</string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignCenter</set> + </property> + </widget> + <widget class="QComboBox" name="comboBox4"> + <property name="geometry"> + <rect> + <x>199</x> + <y>27</y> + <width>72</width> + <height>24</height> + </rect> + </property> + </widget> + <widget class="QLabel" name="label_12"> + <property name="geometry"> + <rect> + <x>10</x> + <y>116</y> + <width>71</width> + <height>16</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>夜间模式:</string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignCenter</set> + </property> + </widget> + <widget class="WBSwitchButton" name="btn_light" native="true"> + <property name="geometry"> + <rect> + <x>90</x> + <y>116</y> + <width>40</width> + <height>20</height> + </rect> + </property> + <property name="maximumSize"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </widget> + <widget class="QLabel" name="label_13"> + <property name="geometry"> + <rect> + <x>10</x> + <y>143</y> + <width>71</width> + <height>16</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>电子稳像:</string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignCenter</set> + </property> + </widget> + <widget class="WBSwitchButton" name="btn_stable" native="true"> + <property name="geometry"> + <rect> + <x>90</x> + <y>143</y> + <width>40</width> + <height>20</height> + </rect> + </property> + <property name="maximumSize"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </widget> + <widget class="QPushButton" name="pushButton_auto"> + <property name="geometry"> + <rect> + <x>136</x> + <y>114</y> + <width>75</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>自动对焦</string> + </property> + </widget> + </widget> + <widget class="QLabel" name="label_9"> + <property name="geometry"> + <rect> + <x>0</x> + <y>20</y> + <width>31</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>速度:</string> + </property> + </widget> + <widget class="QGroupBox" name="groupBox_6"> + <property name="geometry"> + <rect> + <x>0</x> + <y>490</y> + <width>281</width> + <height>91</height> + </rect> + </property> + <property name="title"> + <string>红外</string> + </property> + <widget class="QPushButton" name="pushButton_zoomp_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>变倍+</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_zoomd_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>50</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>变倍-</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_contrastP_2"> + <property name="geometry"> + <rect> + <x>73</x> + <y>20</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>对比度+</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_contrastD_2"> + <property name="geometry"> + <rect> + <x>73</x> + <y>50</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>对比度-</string> + </property> + </widget> + <widget class="QLabel" name="label_14"> + <property name="geometry"> + <rect> + <x>140</x> + <y>20</y> + <width>40</width> + <height>20</height> + </rect> + </property> + <property name="minimumSize"> <size> <width>20</width> - <height>219</height> + <height>0</height> </size> </property> - </spacer> - </item> - </layout> + <property name="maximumSize"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>伪彩:</string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignCenter</set> + </property> + </widget> + <widget class="QComboBox" name="comboBox5"> + <property name="geometry"> + <rect> + <x>180</x> + <y>20</y> + <width>91</width> + <height>24</height> + </rect> + </property> + <property name="currentText"> + <string/> + </property> + </widget> + <widget class="QPushButton" name="pushButton_color"> + <property name="geometry"> + <rect> + <x>180</x> + <y>50</y> + <width>91</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>伪彩循环切换</string> + </property> + </widget> + </widget> + <widget class="QGroupBox" name="groupBox_7"> + <property name="geometry"> + <rect> + <x>0</x> + <y>590</y> + <width>281</width> + <height>61</height> + </rect> + </property> + <property name="title"> + <string>激光</string> + </property> + <widget class="QPushButton" name="pushButton_distance"> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>单次测距</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton_distanceC"> + <property name="geometry"> + <rect> + <x>73</x> + <y>20</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>连续测距</string> + </property> + </widget> + <widget class="QComboBox" name="comboBox6"> + <property name="geometry"> + <rect> + <x>135</x> + <y>20</y> + <width>31</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>24</height> + </size> + </property> + <property name="currentText"> + <string>1</string> + </property> + <item> + <property name="text"> + <string>1</string> + </property> + </item> + <item> + <property name="text"> + <string>2</string> + </property> + </item> + <item> + <property name="text"> + <string>3</string> + </property> + </item> + <item> + <property name="text"> + <string>4</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + </widget> + <widget class="QPushButton" name="pushButton_distanceS"> + <property name="geometry"> + <rect> + <x>210</x> + <y>20</y> + <width>60</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>24</height> + </size> + </property> + <property name="text"> + <string>停止测距</string> + </property> + </widget> + <widget class="QLabel" name="label_15"> + <property name="geometry"> + <rect> + <x>170</x> + <y>20</y> + <width>35</width> + <height>24</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>35</width> + <height>24</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>次/秒</string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignCenter</set> + </property> + </widget> + </widget> + </widget> </widget> </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>WBSwitchButton</class> + <extends>QWidget</extends> + <header>utils/switchbutton.h</header> + <container>1</container> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> diff --git a/src/communicationsettingdlg.cpp b/src/communicationsettingdlg.cpp index 3e66ebb..f8deb52 100644 --- a/src/communicationsettingdlg.cpp +++ b/src/communicationsettingdlg.cpp @@ -18,6 +18,90 @@ CommunicationSettingDlg::~CommunicationSettingDlg() { void CommunicationSettingDlg::showEvent(QShowEvent *event) { setSaveSettingParms(); + setPodIniSetting(); +} + + +bool CommunicationSettingDlg::isValidIP() +{ + QHostAddress addrLocal(ui->podLocalIP->currentText()); + QHostAddress addrremote(ui->podRemoteIPEdit->text()); + + if (addrLocal.isNull() || addrLocal.protocol() != QAbstractSocket::IPv4Protocol) + { + emit sendErrorMessage("本地IP格式错误!", 2); + return false; + } + + if (addrremote.isNull() || addrremote.protocol() != QAbstractSocket::IPv4Protocol) + { + emit sendErrorMessage("远端IP格式错误!", 2); + return false; + } + + if (ui->podLocalPort->value() == 0 || ui->podRemotePort->value() == 0) + { + emit sendErrorMessage("请输入正确的端口号!", 2); + return false; + } + return true; +} + +void CommunicationSettingDlg::savePodIniSetting() +{ + g_networkSettingInfo->setValue("PodSetting/localIP", + ui->podLocalIP->currentText()); + g_networkSettingInfo->setValue("PodSetting/remoteIP", + ui->podRemoteIPEdit->text()); + g_networkSettingInfo->setValue("PodSetting/localPort", + ui->podLocalPort->value()); + g_networkSettingInfo->setValue("PodSetting/remotePort", + ui->podRemotePort->value()); +} + +void CommunicationSettingDlg::setPodIniSetting() +{ + ui->podRemoteIPEdit->setText( + g_networkSettingInfo->value("PodSetting/remoteIP", "192.168.1.160").toString()); + ui->podRemotePort->setValue( + g_networkSettingInfo->value("PodSetting/remotePort", 10000).toInt()); + ui->podLocalPort->setValue( + g_networkSettingInfo->value("PodSetting/localPort", 10001).toInt()); + + QString localIP = + g_networkSettingInfo->value("PodSetting/localIP").toString(); + for (int i = 0; i < ui->podLocalIP->count(); ++i) { + if (localIP == ui->podLocalIP->itemText(i)) { + ui->podLocalIP->setCurrentIndex(i); + } + } +} + + +void CommunicationSettingDlg::on_podConnectBtn_clicked() +{ + if (!isValidIP()) { return; } + + savePodIniSetting(); + + NetworkIPStruct networkIP; + if (!_commIsConnect)//断开时点击连接 + { + _commIsConnect = true;//状态为连接 + networkIP.localIP = ui->podLocalIP->currentText(); + networkIP.remoteIP = ui->podRemoteIPEdit->text(); + networkIP.localPort = ui->podLocalPort->value(); + networkIP.remotePort = ui->podRemotePort->value(); + emit sendPodData(networkIP, _commIsConnect); + ui->podConnectBtn->setText("断开"); + } + else + { + _commIsConnect = false;//状态为连接 + emit sendPodData(networkIP, _commIsConnect); + ui->podConnectBtn->setText("连接"); + } + } void CommunicationSettingDlg::initCombobox() { @@ -31,10 +115,14 @@ void CommunicationSettingDlg::initNetworkSetting() { QStringList localIPList; getLocalIP(localIPList); ui->localIP->addItems(localIPList); + ui->podLocalIP->addItems(localIPList); ui->remoteIPEdit->setText(QStringLiteral("223.0.0.1")); ui->remotePort->setValue(8080); ui->localPort->setValue(8082); + + ui->podRemotePort->setValue(10000); + ui->podLocalPort->setValue(10001); } void CommunicationSettingDlg::setSaveSettingParms() { @@ -64,7 +152,7 @@ void CommunicationSettingDlg::setSaveSettingParms() { QString localIP = g_networkSettingInfo->value(groupName + "/localIP").toString(); - for (int i = 0; i < ui->dataSourceCombox->count(); ++i) { + for (int i = 0; i < ui->localIP->count(); ++i) { if (localIP == ui->localIP->itemText(i)) { ui->localIP->setCurrentIndex(i); } diff --git a/src/communicationsettingdlg.h b/src/communicationsettingdlg.h index 2ae4dfd..a3f733c 100644 --- a/src/communicationsettingdlg.h +++ b/src/communicationsettingdlg.h @@ -23,9 +23,11 @@ protected: signals: void sendErrorMessage(QString message, int type); + void sendPodData(NetworkIPStruct networkIP, bool isConnect); private slots: void on_saveSettingBtn_clicked(); + void on_podConnectBtn_clicked(); private: void initCombobox(); @@ -34,8 +36,14 @@ private: void setSaveSettingParms(); + bool isValidIP(); + + void savePodIniSetting(); + + void setPodIniSetting(); private: Ui::CommunicationSettingDlg *ui; + bool _commIsConnect{ false }; }; #endif // COMMUNICATIONSETTINGDLG_H diff --git a/src/communicationsettingdlg.ui b/src/communicationsettingdlg.ui index aa2fb4f..a87f1e7 100644 --- a/src/communicationsettingdlg.ui +++ b/src/communicationsettingdlg.ui @@ -6,192 +6,450 @@ <rect> <x>0</x> <y>0</y> - <width>307</width> - <height>275</height> + <width>600</width> + <height>350</height> </rect> </property> + <property name="minimumSize"> + <size> + <width>600</width> + <height>350</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>600</width> + <height>350</height> + </size> + </property> <property name="windowTitle"> <string>Dialog</string> </property> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0"> - <property name="leftMargin"> - <number>4</number> - </property> - <property name="topMargin"> - <number>4</number> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>20</x> + <y>10</y> + <width>551</width> + <height>171</height> + </rect> </property> - <property name="rightMargin"> - <number>4</number> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> </property> - <property name="bottomMargin"> - <number>4</number> + <property name="title"> + <string>网络设置</string> </property> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="title"> - <string>网络设置</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>4</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="rightMargin"> + <number>4</number> + </property> + <property name="bottomMargin"> + <number>2</number> + </property> + <item> + <layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0,0,0,0"> <property name="leftMargin"> <number>4</number> </property> - <property name="topMargin"> - <number>2</number> - </property> <property name="rightMargin"> <number>4</number> </property> - <property name="bottomMargin"> - <number>2</number> - </property> - <item> - <layout class="QGridLayout" name="gridLayout" columnstretch="1,2"> - <property name="leftMargin"> - <number>4</number> - </property> - <property name="rightMargin"> - <number>4</number> - </property> - <property name="horizontalSpacing"> - <number>7</number> - </property> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string>本地IP:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="localIP"/> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="remoteIPEdit"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_2"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string>网络IP:</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>数据来源:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="dataSourceCombox"/> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_12"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string>网络端口:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QSpinBox" name="remotePort"> - <property name="buttonSymbols"> - <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> - </property> - <property name="maximum"> - <number>65534</number> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_13"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string>本地端口:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QSpinBox" name="localPort"> - <property name="buttonSymbols"> - <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> - </property> - <property name="maximum"> - <number>65534</number> - </property> - </widget> - </item> - </layout> + <property name="horizontalSpacing"> + <number>6</number> + </property> + <item row="1" column="4"> + <widget class="QSpinBox" name="remotePort"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> + </property> + <property name="maximum"> + <number>65534</number> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="QSpinBox" name="localPort"> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> + </property> + <property name="maximum"> + <number>65534</number> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="remoteIPEdit"/> + </item> + <item row="0" column="0"> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_4"> + <property name="maximumSize"> + <size> + <width>150</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>数据来源:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="label_2"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>网络IP:</string> + </property> + </widget> + </item> + <item row="0" column="2" colspan="3"> + <widget class="QComboBox" name="dataSourceCombox"/> + </item> + <item row="1" column="3"> + <widget class="QLabel" name="label_12"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>网络端口:</string> + </property> + </widget> + </item> + <item row="1" column="5" rowspan="2"> + <widget class="QWidget" name="widget" native="true"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="saveSettingBtn"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>保存设置</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="label"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>本地IP:</string> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QLabel" name="label_13"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>本地端口:</string> + </property> + </widget> + </item> + <item row="0" column="5"> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="2"> + <widget class="QComboBox" name="localIP"/> </item> </layout> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Orientation::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="saveSettingBtn"> - <property name="font"> - <font> - <pointsize>10</pointsize> - </font> - </property> - <property name="text"> - <string>保存设置</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Orientation::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> + </item> + </layout> + </widget> + <widget class="QGroupBox" name="groupBox_2"> + <property name="geometry"> + <rect> + <x>20</x> + <y>190</y> + <width>551</width> + <height>131</height> + </rect> + </property> + <property name="title"> + <string>吊舱网络设置</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="4"> + <widget class="QSpinBox" name="podRemotePort"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> + </property> + <property name="maximum"> + <number>65534</number> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QLabel" name="label_14"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>本地端口:</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLineEdit" name="podRemoteIPEdit"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="0" column="5" rowspan="2"> + <widget class="QWidget" name="widget_2" native="true"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QPushButton" name="podConnectBtn"> + <property name="text"> + <string>连接</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="2"> + <widget class="QComboBox" name="podLocalIP"/> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="label_3"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>本地IP:</string> + </property> + </widget> + </item> + <item row="1" column="4"> + <widget class="QSpinBox" name="podLocalPort"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> + </property> + <property name="maximum"> + <number>65534</number> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="label_15"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>远端端口:</string> + </property> + <property name="alignment"> + <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_5"> + <property name="maximumSize"> + <size> + <width>50</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>远端P:</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0"> + <spacer name="horizontalSpacer_6"> + <property name="orientation"> + <enum>Qt::Orientation::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Policy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> </widget> <resources/> <connections/> diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5f2a291..b73dc88 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -59,8 +59,10 @@ MainWindow::MainWindow(QWidget *parent) initChangeVideoLayoutConnection(); initHideButton(); + initWidget(); setSavedVideoDir(); + initPodParam(); // ui->stackedWidget->setCurrentIndex(1); // ui->videoWidget1->play(list.at(0)); // ui->videoWidget2->play(list.at(0)); @@ -123,6 +125,8 @@ void MainWindow::initSignalConnection() { connect(ui->videoControlWidget, &VideoControl::stopVideoSignal, this, &MainWindow::closeVideoSlot); + + connect(&streamAddrSettingsDlg, &StreamAddrSettingsDlg::sendUavTypeIndex, ui->commandWidget, &CommandWidget::receiveUavTypeIndex); } void MainWindow::initNotifyMessageConnection() { @@ -132,6 +136,8 @@ void MainWindow::initNotifyMessageConnection() { &MainWindow::showMessageSlots); connect(ui->commandWidget, &CommandWidget::sendErrorMessage, this, &MainWindow::showMessageSlots); + connect(&settingDlg, &CommunicationSettingDlg::sendErrorMessage, this, + &MainWindow::showMessageSlots); } void MainWindow::initChangeVideoLayoutConnection() { @@ -319,6 +325,11 @@ void MainWindow::initHideButton() { &MainWindow::hideCommandWidgetSlot); } +void MainWindow::initWidget() +{ + ui->commandWidget->receiveUavTypeIndex(g_networkSettingInfo->value("NetworkStreamSettings/uavType").toInt()); +} + void MainWindow::showSettingDlgSlot() { settingDlg.exec(); } @@ -506,3 +517,109 @@ void MainWindow::showMap3DSlot() { m_mapWidget->show(); } } + +void MainWindow::initPodParam() +{ + _wheelStopTime = new QTimer(this); + _wheelStopTime->setInterval(300); + _wheelStopTime->setSingleShot(true); + + firstLocation = new QLabel(this); + firstLocation->setPixmap(QPixmap(":/images/c.png")); + firstLocation->setScaledContents(true); + firstLocation->resize(30, 30); + firstLocation->setStyleSheet("border: none; background: transparent;"); + firstLocation->hide(); + + lastLocation = new QLabel(this); + lastLocation->setPixmap(QPixmap(":/images/circle.png")); + lastLocation->setScaledContents(true); + lastLocation->resize(25, 25); + lastLocation->setStyleSheet("border: none; background: transparent;"); + lastLocation->hide(); + + connect(&settingDlg, &CommunicationSettingDlg::sendPodData, ui->commandWidget, &CommandWidget::setPodIPConfig); +} + +void MainWindow::mousePressEvent(QMouseEvent* event) +{ + if (ui->videoWidget->underMouse()) + { + if (event->button() == Qt::LeftButton) + { + //记录鼠标按下位置 + _dragStartPositon = event->pos(); + //QPointF b = event->globalPosition(); + qDebug() << "局部坐标" << "x" << _dragStartPositon.x() << "y" << _dragStartPositon.y(); + //qDebug() << "全局坐标" << "x" << b.x() << "y" << b.y(); + _dragFlag = true; + } + else if (event->button() == Qt::RightButton) + { + //鼠标右键取消目标跟踪 + ui->commandWidget->setStopTracking(); + qDebug() << "取消跟踪"; + } + } +} + +void MainWindow::mouseMoveEvent(QMouseEvent* event) +{ + if (_dragFlag)//点击并且移动 + { + QPointF diff = event->pos() - _dragStartPositon; + qDebug() << "x:" << diff.x() << "y:" << diff.y(); + ui->commandWidget->setMoveParm(diff); + + if (qAbs(diff.x()) > 5 || qAbs(diff.y()) > 5)//像素点超过5ptx才算移动,否则为跟踪 + { + _moveFlag = true; + firstLocation->move((_dragStartPositon - QPoint(firstLocation->width() / 2, firstLocation->height() / 2)).toPoint()); + lastLocation->move(event->pos() - QPoint(lastLocation->width() / 2, lastLocation->height() / 2)); + firstLocation->show(); + lastLocation->show(); + } + + QPointF widgetPos = mapFromGlobal(event->globalPosition()); + + //如果移动的时候超过了画面显示区域,则自动退出伺服控制 + if (!ui->videoWidget->rect().contains(widgetPos.toPoint())) + { + _moveFlag = false; + _dragFlag = false; + + ui->commandWidget->stopServo(); + firstLocation->hide(); + lastLocation->hide(); + } + } +} + +void MainWindow::mouseReleaseEvent(QMouseEvent* event) +{ + if (ui->videoWidget->underMouse()) + { + if (event->button() == Qt::LeftButton && _moveFlag) + { + _moveFlag = false; + + ui->commandWidget->stopServo(); + + firstLocation->hide(); + lastLocation->hide(); + } + else if (event->button() == Qt::LeftButton && _dragFlag) + { + // 目标跟踪 + QPointF sPoint1 = event->globalPosition(); + QPointF widgetPoint = ui->videoWidget->mapFromGlobal(sPoint1); + double a = ui->videoWidget->width(); + double b = ui->videoWidget->height(); + double dir = 1920 / a * widgetPoint.rx() - 960; + double pitch = -(1080 / b * widgetPoint.ry() - 540); + + ui->commandWidget->setTargetTracking(dir, pitch); + qDebug() << "=========>目标跟踪" << " dir:" << dir << " pitch:" << pitch << " a:" << a << " b:" << b; + } + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 0412624..1022393 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -22,6 +22,7 @@ #include "windowsx.h" #pragma comment(lib, "user32.lib") #endif +#include <QLabel> namespace QWK { class WidgetWindowAgent; @@ -68,6 +69,7 @@ private: void setSavedVideoDir(); void initHideButton(); + void initWidget(); private slots: void showSettingDlgSlot(); @@ -92,5 +94,21 @@ private: QToolButton *hideCommandWidgetBtn = nullptr; WebMapWidget *m_mapWidget = nullptr; + + //�����˻��������� + int _delta{0}; //���ֹ����� + QTimer* _wheelStopTime; + QPointF _dragStartPositon; //��¼����������ǰ����ľֲ����� + bool _dragFlag{false}; //��¼������ʼ��־ + bool _moveFlag{false}; //��¼���ڻ����еı�־ + QLabel* firstLocation; + QLabel* lastLocation; + + void initPodParam(); +public: + void mousePressEvent(QMouseEvent* event) override; // �¼������� + void mouseMoveEvent(QMouseEvent* event) override; // �¼������� + void mouseReleaseEvent(QMouseEvent* event) override; + }; #endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 51eb3aa..9249638 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -105,7 +105,14 @@ </layout> </item> <item> - <widget class="CommandWidget" name="commandWidget" native="true"/> + <widget class="CommandWidget" name="commandWidget" native="true"> + <property name="minimumSize"> + <size> + <width>300</width> + <height>0</height> + </size> + </property> + </widget> </item> </layout> </widget> @@ -115,7 +122,7 @@ <x>0</x> <y>0</y> <width>1388</width> - <height>24</height> + <height>33</height> </rect> </property> </widget> diff --git a/src/resources/images/c.png b/src/resources/images/c.png new file mode 100644 index 0000000..a554398 Binary files /dev/null and b/src/resources/images/c.png differ diff --git a/src/resources/images/circle.png b/src/resources/images/circle.png new file mode 100644 index 0000000..06f5c53 Binary files /dev/null and b/src/resources/images/circle.png differ diff --git a/src/resources/res.qrc b/src/resources/res.qrc index 424cc77..81a54a3 100644 --- a/src/resources/res.qrc +++ b/src/resources/res.qrc @@ -37,5 +37,7 @@ <file>images/play1.75X.png</file> <file>images/play1X.png</file> <file>images/play2X.png</file> + <file>images/c.png</file> + <file>images/circle.png</file> </qresource> </RCC> diff --git a/src/streamaddrsettingsdlg.cpp b/src/streamaddrsettingsdlg.cpp index 564e61f..42b6380 100644 --- a/src/streamaddrsettingsdlg.cpp +++ b/src/streamaddrsettingsdlg.cpp @@ -14,6 +14,7 @@ StreamAddrSettingsDlg::StreamAddrSettingsDlg(QWidget *parent) uavTypeList.append("FP981C"); uavTypeList.append("FP981CS"); uavTypeList.append("FP981A"); + uavTypeList.append("四医大"); ui->uavTypeCombox->insertItems(0, uavTypeList); // ui->pushStreamIPCombox->insertItem(0, QStringLiteral("航天飞鹏服务器")); @@ -157,3 +158,11 @@ void StreamAddrSettingsDlg::on_pushStreamBtn_clicked() { ui->pushStreamBtn->setDisabled(false); } + +void StreamAddrSettingsDlg::on_uavTypeCombox_activated(int index) +{ + qDebug() << index; + g_networkSettingInfo->setValue("NetworkStreamSettings/uavType", + ui->uavTypeCombox->currentIndex()); + emit sendUavTypeIndex(index); +} diff --git a/src/streamaddrsettingsdlg.h b/src/streamaddrsettingsdlg.h index 4cfbc2c..25a1517 100644 --- a/src/streamaddrsettingsdlg.h +++ b/src/streamaddrsettingsdlg.h @@ -22,6 +22,7 @@ protected: signals: void startPullStreamSignal(bool bPull); void startPushStreamSignal(bool bPush); + void sendUavTypeIndex(int index); private slots: void on_pushStreamIPCombox_currentIndexChanged(int index); @@ -32,6 +33,8 @@ private slots: void on_pushStreamBtn_clicked(); + void on_uavTypeCombox_activated(int index); + private: void initSavedParms(); void saveParms(); diff --git a/src/utils/CUdpSocket.cpp b/src/utils/CUdpSocket.cpp new file mode 100644 index 0000000..c256dcb --- /dev/null +++ b/src/utils/CUdpSocket.cpp @@ -0,0 +1,74 @@ +#include "CUdpSocket.h" + +CUdpSocket::CUdpSocket(QObject* parent) : QObject(parent) +{ + //创建UDP套接字内存空间 + m_sock = new QUdpSocket; + // 连接数据读取信号槽 + connect(m_sock, &QUdpSocket::readyRead, this, &CUdpSocket::on_readyReadData); +} + +CUdpSocket::~CUdpSocket() +{ + // 释放UDP套接字内存空间 + m_sock->close(); + delete m_sock; +} + +bool CUdpSocket::bind(QString ip, ushort port) +{ + // 返回绑定函数返回值 + + if (!m_sock->bind(QHostAddress(ip), port)) + { + qDebug() << "Bind failed:" << m_sock->errorString(); + isSocketBind = false; + return false; + } + isSocketBind = true; + return true; +} + +void CUdpSocket::sendData(QByteArray data) +{ + // 发送传入的数据到指定的信息的位置 + if (isSocketBind) + { + m_sock->writeDatagram(data, m_hostAddr, m_port); + } +} + +void CUdpSocket::setTargetInfo(QString ip, quint16 port) +{ + // 存储传入的IP和端口号 + m_hostAddr = QHostAddress(ip); + m_port = port; +} + +bool CUdpSocket::close() +{ + m_sock->close(); + if (m_sock->state() == QUdpSocket::UnconnectedState) { + qDebug() << "Socket 已成功关闭"; + return true; + } + + qDebug() << "Socket 关闭失败,当前状态:" << m_sock->state(); + return false; +} + +void CUdpSocket::on_readyReadData() +{ + // 通过函数判断当前是否有等待读取的数据并循环获取 + while (m_sock->hasPendingDatagrams()) + { + //创建数据存储容器,并设置长度为将接收的数据长度 + QByteArray data; + data.resize(m_sock->pendingDatagramSize()); + //读取数据并保存信息发送者的地址和ip(方便发送时指定发送位置) + m_sock->readDatagram(data.data(), data.size(), &m_hostAddr, &m_port); + //发送接收数据的信号 + emit recvDataSignal(data); + } +} + diff --git a/src/utils/CUdpSocket.h b/src/utils/CUdpSocket.h new file mode 100644 index 0000000..5d4865d --- /dev/null +++ b/src/utils/CUdpSocket.h @@ -0,0 +1,41 @@ +#ifndef CUDPSOCKET_H +#define CUDPSOCKET_H + +#include <QObject> +#include <QUdpSocket> +#include <QHostAddress> +class CUdpSocket : public QObject +{ Q_OBJECT +public: + explicit CUdpSocket(QObject* parent = nullptr); + ~CUdpSocket(); + + //绑定本机的ip和端口号信息 + bool bind(QString ip, ushort port); + + //通过该函数发送数据 + void sendData(QByteArray data); + + //设置目标主机的ip和端口号 + void setTargetInfo(QString ip, quint16 port); + + //关闭socket + bool close(); + +signals: + //通过该信号传递接收到的数据 + void recvDataSignal(QString data); + +public slots: + //读取数据的槽函数 + void on_readyReadData(); + +private: + QUdpSocket* m_sock; //UDP套接字指针 + QHostAddress m_hostAddr; //保存目标的地址对象 + quint16 m_port; //保存目标的端口号(类型一致) + + bool isSocketBind{false}; //数据绑定成功or失败 +}; + +#endif \ No newline at end of file diff --git a/src/utils/protocolPodTJ.cpp b/src/utils/protocolPodTJ.cpp new file mode 100644 index 0000000..30c19f0 --- /dev/null +++ b/src/utils/protocolPodTJ.cpp @@ -0,0 +1,123 @@ +#include "protocolPodTJ.h" + +QByteArray ProtocolPodTJ::encode(const QByteArray& cmd, const QByteArray& loadData) +{ + QByteArray buffer; + + // ֡ͷ + buffer.append(0xFB); + buffer.append(0x2C); + buffer.append(0xAA); + + // ֡����ָ��2�ֽ� + ���ݣ� + quint8 length = 2 + loadData.size(); + buffer.append(length); + + // ָ���λ��ǰ�� + buffer.append(cmd); + + // ������ + buffer.append(loadData); + + // У�飨��֡����ʼ �����һ�������ֽڣ� + quint8 xorSum = calculateXOR(buffer, 3, buffer.size() - 1); + buffer.append(xorSum); + + return buffer; +} + +QByteArray ProtocolPodTJ::cmdLeft(uint16_t sliderValue) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[0] = -sliderValue & 0xFF; + param[1] = ((-sliderValue >> 8) & 0xFF); + return param; +} + +QByteArray ProtocolPodTJ::cmdRight(uint16_t sliderValue) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[0] = sliderValue & 0xFF; + param[1] = ((sliderValue >> 8) & 0xFF); + return param; +} + +QByteArray ProtocolPodTJ::cmdUp(uint16_t sliderValue) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[2] = sliderValue & 0xFF; + param[3]= ((sliderValue >> 8) & 0xFF); + return param; +} + +QByteArray ProtocolPodTJ::cmdDown(uint16_t sliderValue) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[2] = -sliderValue & 0xFF; + param[3] = ((-sliderValue >> 8) & 0xFF); + return param; +} + +QByteArray ProtocolPodTJ::cmdZoom(uint8_t model, uint8_t speed) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[0] = model; + param[1] = speed; + return param; +} + +QByteArray ProtocolPodTJ::cmdLaser(uint8_t fre) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[0] = fre; + return param; +} + +QByteArray ProtocolPodTJ::digitalGuid(uint8_t directionAngle, uint8_t pitchAngle) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[0] = (directionAngle * 100) & 0xFF; + param[1] = (((directionAngle * 100) >> 8) & 0xFF); + param[2] = (pitchAngle * 100) & 0xFF; + param[3] = (((pitchAngle * 100) >> 8) & 0xFF); + return param; +} + +QByteArray ProtocolPodTJ::cmdServo(int pointX, int pointY) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[0] = pointX & 0xFF; + param[1] = ((pointX >> 8) & 0xFF); + param[2] = pointY & 0xFF; + param[3] = ((pointY >> 8) & 0xFF); + return param; +} + +QByteArray ProtocolPodTJ::targetTracking(uint16_t dir, uint16_t pitch) +{ + QByteArray param(4, 0x00); + //С����ǰ + param[0] = dir & 0xFF; + param[1] = ((dir >> 8) & 0xFF); + param[2] = pitch & 0xFF; + param[3] = ((pitch >> 8) & 0xFF); + return param; +} + +//����У�� +quint8 ProtocolPodTJ::calculateXOR(const QByteArray& data, int begin, int end) +{ + quint8 xorVal = 0; + for (int i = begin; i <= end; ++i) { + xorVal ^= static_cast<quint8>(data[i]); + } + return xorVal; +} diff --git a/src/utils/protocolPodTJ.h b/src/utils/protocolPodTJ.h new file mode 100644 index 0000000..0caab4d --- /dev/null +++ b/src/utils/protocolPodTJ.h @@ -0,0 +1,28 @@ +#include <QByteArray> +class ProtocolPodTJ +{ +public: + static QByteArray encode(const QByteArray& cmd, const QByteArray& loadData = QByteArray::fromHex("00000000")); + + +public: + //����ָ�� + QByteArray cmdLeft(uint16_t sliderValue); + QByteArray cmdRight(uint16_t sliderValue); + QByteArray cmdUp(uint16_t sliderValue); + QByteArray cmdDown(uint16_t sliderValue); + QByteArray cmdZoom(uint8_t model, uint8_t speed); + QByteArray cmdLaser(uint8_t fre); + + //�������� + QByteArray digitalGuid(uint8_t directionAngle, uint8_t pitchAngle); + + //�ŷ����� + QByteArray cmdServo(int pointX, int pointY); + + //Ŀ����� + QByteArray targetTracking(uint16_t dir, uint16_t pitch); + +private: + static quint8 calculateXOR(const QByteArray& data, int begin, int end); +}; diff --git a/src/utils/switchbutton.cpp b/src/utils/switchbutton.cpp new file mode 100644 index 0000000..347cd3e --- /dev/null +++ b/src/utils/switchbutton.cpp @@ -0,0 +1,201 @@ +#include "switchbutton.h" +#include <QDebug> + +WBSwitchButton::WBSwitchButton(QWidget* parent) + : QWidget{ parent } +{ + +} + +bool WBSwitchButton::getSwitch() { + return mOnOff; +} + +void WBSwitchButton::setSwitch(bool onoff) { + if (mWaitSigModel) return; + /// ״̬�л� + mOnOff = onoff; + /// �����ź� + sigSwitchChanged(mOnOff); + /// ����-������ɫ + QPropertyAnimation* colorAnimation = new QPropertyAnimation(this, "pBackColor"); + colorAnimation->setDuration(mAnimationPeriod); + colorAnimation->setStartValue(mBackColor); + colorAnimation->setEndValue(mOnOff ? mBackOnColor : mBackOffColor); + colorAnimation->start(QAbstractAnimation::DeletionPolicy::DeleteWhenStopped); //ֹͣ��ɾ�� + /// ����-���ذ�ťλ�� + QVariantAnimation* posAnimation = new QVariantAnimation(this); + posAnimation->setDuration(mAnimationPeriod); + posAnimation->setStartValue(mButtonRect.topLeft()); + posAnimation->setEndValue(mOnOff ? mRightPos : mLeftPos); + connect(posAnimation, &QPropertyAnimation::valueChanged, [=](const QVariant& value) { + mButtonRect.moveTo(value.toPointF()); + update(); + }); + posAnimation->start(QAbstractAnimation::DeletionPolicy::DeleteWhenStopped); //ֹͣ��ɾ�� +} + +void WBSwitchButton::setSwitchForWaitModel(bool onoff) +{ + if (!mWaitSigModel) return; + if (mOnOff == onoff) { + /// ��ʾֵδ�ı������а�ťλ�ö��� + QVariantAnimation* posAnimation = new QVariantAnimation(this); + posAnimation->setDuration(mAnimationPeriod); + posAnimation->setStartValue(mOnOff ? mLeftPos : mRightPos); + posAnimation->setEndValue(mOnOff ? mRightPos : mLeftPos); + connect(posAnimation, &QVariantAnimation::valueChanged, [=](const QVariant& value) { + mButtonRect.moveTo(value.toPointF()); + update(); + }); + posAnimation->start(QAbstractAnimation::DeletionPolicy::DeleteWhenStopped); //ֹͣ��ɾ�� + return; + } + /// ״̬�л� + mOnOff = onoff; + /// �����ź� + sigSwitchChanged(mOnOff); + /// �����б�����ɫ���� + QPropertyAnimation* colorAnimation = new QPropertyAnimation(this, "pBackColor"); + colorAnimation->setDuration(mAnimationPeriod); + colorAnimation->setStartValue(mBackColor); + colorAnimation->setEndValue(mOnOff ? mBackOnColor : mBackOffColor); + colorAnimation->start(QAbstractAnimation::DeletionPolicy::DeleteWhenStopped); //ֹͣ��ɾ�� + connect(colorAnimation, &QPropertyAnimation::valueChanged, [=](const QVariant& value) { + update(); + }); +} + +void WBSwitchButton::setEnabled(bool enable) { + QWidget::setEnabled(enable); + mEnable = enable; + emit sigEnableChanged(mEnable); + update(); +} + +bool WBSwitchButton::getEnabled() +{ + return mEnable; +} + +void WBSwitchButton::setAnimationPeriod(int period) { + mAnimationPeriod = period; +} + +void WBSwitchButton::setPrecisionClick(bool flag) { + mPrecisionClickFlagh = flag; +} + +void WBSwitchButton::setWaitModel(bool flag) +{ + mWaitSigModel = flag; +} + +void WBSwitchButton::setButtonColor(QColor color) { + mButtonColor = color; + update(); +} + +void WBSwitchButton::setBackOnColor(QColor color) { + mBackOnColor = color; + update(); +} + +void WBSwitchButton::setBackOffColor(QColor color) { + mBackOffColor = color; + update(); +} + +void WBSwitchButton::setEdgeColor(QColor color) { + mEdgeColor = color; + update(); +} + +void WBSwitchButton::paintEvent(QPaintEvent* event) { + Q_UNUSED(event) + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(Qt::NoPen); + + /// ���Ʊ�Ե��ɫ + QPainterPath path; + path.addRect(this->rect()); + path.addRoundedRect(this->rect(), mRadius, mRadius); + path.setFillRule(Qt::OddEvenFill); + painter.setBrush(mEdgeColor); + painter.drawPath(path); + + /// ���Ʊ�����ɫ + painter.setBrush(mBackColor); + painter.drawRoundedRect(this->rect(), mRadius, mRadius); + + /// ����Բ�ΰ�ť + painter.setBrush(mButtonColor); + painter.drawEllipse(mButtonRect); + + /// ���ư�ť��Ӱ + painter.setBrush(Qt::NoBrush); + QColor color(Qt::black); + int count = (this->height() - mButtonRect.height()) / 2; + float stepColor = (0.15 - 0.0) / count; + for (int i = mButtonRect.height() / 2 + 1; i < this->height() / 2; i++) { + color.setAlphaF(0.15 - stepColor * (i - mButtonRect.height() / 2)); + painter.setPen(color); + painter.drawEllipse(mButtonRect.center(), i, i); + } + + /// ʧ����ʾ������һ���ɲ� + if (!mEnable) { + QColor disable(Qt::black); + disable.setAlphaF(0.5); + painter.setBrush(disable); + painter.drawRoundedRect(this->rect(), mRadius, mRadius); + } +} + +void WBSwitchButton::resizeEvent(QResizeEvent* event) { + Q_UNUSED(event) + /// ���°�ť��С��Բ�Ǵ�С����������λ�� + int size = qMin(this->width(), this->height()); + mRadius = size / 2; + float width = size * 3 / 4; + float border = (size - width) / 2; + mLeftPos = QPoint(border, border); + mRightPos = QPoint(this->width() - border - width, border); + mButtonRect.setWidth(width); + mButtonRect.setHeight(width); + mButtonRect.moveTo(mOnOff ? mRightPos : mLeftPos); + mBackColor = mOnOff ? mBackOnColor : mBackOffColor; + update(); +} + +void WBSwitchButton::mouseReleaseEvent(QMouseEvent* event) { + if (mWaitSigModel) { + /// �����а�ťλ�ö��� + QVariantAnimation* posAnimation = new QVariantAnimation(this); + posAnimation->setDuration(mAnimationPeriod); + posAnimation->setStartValue(mOnOff ? mRightPos : mLeftPos); + posAnimation->setEndValue(mOnOff ? mLeftPos : mRightPos); + connect(posAnimation, &QVariantAnimation::valueChanged, [=](const QVariant& value) { + mButtonRect.moveTo(value.toPointF()); + update(); + }); + posAnimation->start(QAbstractAnimation::DeletionPolicy::DeleteWhenStopped); //ֹͣ��ɾ�� + return; + } + if (!mEnable) return; + if (mButtonRect.contains(event->pos()) || !mPrecisionClickFlagh) { + setSwitch(!mOnOff); + } +} + +void WBSwitchButton::enterEvent(QEvent* event) { + Q_UNUSED(event) + mHover = true; +} + +void WBSwitchButton::leaveEvent(QEvent* event) { + Q_UNUSED(event) + mHover = false; +} + diff --git a/src/utils/switchbutton.h b/src/utils/switchbutton.h new file mode 100644 index 0000000..df71292 --- /dev/null +++ b/src/utils/switchbutton.h @@ -0,0 +1,70 @@ +#ifndef WBSWITCHBUTTON_H +#define WBSWITCHBUTTON_H + +#include <QWidget> +#include <QPropertyAnimation> +#include <QPainterPath> +#include <QPainter> +#include <QRadialGradient> +#include <QMouseEvent> + +/// +/// \brief 基础控件-Switch开关按钮 +/// +class WBSwitchButton : public QWidget +{ + Q_OBJECT +public: + Q_PROPERTY(QColor pBackColor MEMBER mBackColor) //新增背景颜色属性,用于动画 + + explicit WBSwitchButton(QWidget* parent = nullptr); + bool getSwitch(); /// 获取开关状态 + +public slots: + void setSwitch(bool onoff); /// 设置开关状态,default:0 + void setEnabled(bool enable); /// 设置使能状态,default:1 + bool getEnabled(); /// 获取使能状态 + void setAnimationPeriod(int period); /// 设置切换状态周期 + void setPrecisionClick(bool flag); /// 设置精确点击,即只有点中按钮的时候才开关 + void setWaitModel(bool flag); /// 设置等待模式,点击后不会主动切换开关,需要setSwitch + void setSwitchForWaitModel(bool onoff); /// 设置开关状态,default:0 + + void setButtonColor(QColor color); /// 设置开关(圆形按钮)颜色 + void setBackOnColor(QColor color); /// 设置背景颜色-开 + void setBackOffColor(QColor color); /// 设置背景颜色-关 + void setEdgeColor(QColor color); /// 设置边缘颜色,默认透明 + +signals: + void sigEnableChanged(bool enable); /// 使能状态变化信号 + void sigSwitchChanged(bool onoff); /// 开关状态变化信号 + +protected: + void paintEvent(QPaintEvent* event); + void resizeEvent(QResizeEvent* event); + void mouseReleaseEvent(QMouseEvent* event); + void enterEvent(QEvent* event); + void leaveEvent(QEvent* event); + +private: + bool mOnOff{ 0 }; //开关状态 + bool mEnable{ 1 }; //使能状态 + bool mPrecisionClickFlagh{ 0 }; //精确点击标志位 + bool mWaitSigModel{ 0 }; //等待模式,点击后按钮位置会进行切换,但是颜色需要等待外部信号变动 + bool mAnimationOnOff{ 1 }; //动画开关,default:1 + bool mHover{ 0 }; + + QColor mButtonColor{ Qt::white }; //开关(圆形按钮)颜色 + QColor mBackColor{ Qt::red }; + QColor mEdgeColor{ Qt::transparent }; //边缘颜色 + QRectF mButtonRect; //开关按钮rect + int mRadius{ 8 }; // 开关外观边缘圆角 + + int mAnimationPeriod{ 200 }; //动画周期 + QPointF mRightPos; // 动画位置-开 + QPointF mLeftPos; // 动画位置-关 + QColor mBackOnColor{ Qt::green }; //背景颜色-开 + QColor mBackOffColor{ Qt::darkGray }; //背景颜色-关 +}; + +#endif // WBSWITCHBUTTON_H +