diff --git a/src/UAV_UI_new/FP.h b/src/UAV_UI_new/FP.h new file mode 100644 index 0000000..4f7bbba --- /dev/null +++ b/src/UAV_UI_new/FP.h @@ -0,0 +1,116 @@ +#include +#include +#include "levelToSpeed.h" + +using namespace std; +#define M_PI acos(-1) + + +class ForestFirePrediction { +public: + // 构造函数 + ForestFirePrediction(int wind_direction, double wind_level, double slope, double altitude, int cover_type, double fire_size, double temperature, double waterlevel) { + this->wind_direction = wind_direction; + this->wind_level = wind_level; + this->slope = slope; + this->altitude = altitude; + this->cover_type = cover_type; + this->fire_size = fire_size; + this->temperature = temperature; + this->waterlevel = waterlevel; + } + + // 计算受阻距离(单位:km) + double get_distance() { + double rad_slope = slope * M_PI / 180.0; // 将坡度转化为弧度 + double distance = sin(rad_slope) * altitude / 1000.0; // 计算受阻距离 + return distance; + } + + // 预测火灾蔓延范围 + void predict_range() { + double impact_factor; // 植被类型影响系数 + double correction_coef; // 风速补正系数 + double distance; // 受阻距离 + double composite_index; // 综合指数 + + // 根据植被类型获取影响系数 + switch (cover_type) { + case 1: // 针叶林 + impact_factor = 0.7; + break; + case 2: // 落叶林 + impact_factor = 0.5; + break; + case 3: // 灌木林 + impact_factor = 0.4; + break; + default: + cout << "植被类型输入错误!" << endl; + return; + } + + // 计算风速补正系数 + int angle = abs(wind_direction - 180); // 计算风向与火灾扩散方向之间的夹角 + if (angle <= 45 || angle >= 315) { // 如果夹角较小,则不需要进行风速补正 + correction_coef = 1; + } + else { + correction_coef = 0.65 + 0.35 * cos((angle - 45) * M_PI / 270.0); // 使用公式计算风速补正系数 + } + + // 计算受阻距离 + distance = get_distance(); + + // 计算综合指数 + composite_index = correction_coef * (1 + distance) * impact_factor; + + // 计算火灾蔓延半径 + double radius = sqrt(fire_size * 1000000 * composite_index) / M_PI; + double range = radius * pow(10, 1.5 * levelToSpeed(wind_level) / 30.0); + + // 输出预测结果 + cout << "火灾蔓延范围预测结果:" << endl; + cout << "火源最可能在" << radius << "米范围内发生。" << endl; + cout << "在风速为 " << wind_level << "级风的情况下,火源最可能的蔓延范围为 " << range << " 米。" << endl; + } + + // 预测火灾蔓延速度 + double predict_speed() { + double slope_factor; // 坡度影响因子 + double speed_factor; // 风速影响因子 + double size_factor; // 火源面积影响因子 + + // 计算坡度影响因子 + if (slope > 0) { + slope_factor = pow(3.33, sqrt(slope)); + } + else { + slope_factor = 1; + } + + // 计算风速影响因子 + double wind_speed = levelToSpeed(wind_level); + speed_factor = 5.15 * pow(wind_speed, 0.39) + 0.299 * temperature + 0.009 * (100 - waterlevel) - 0.304; + + // 计算火源面积影响因子 + size_factor = pow(fire_size, 0.77); + + // 计算火灾蔓延速度 + double speed = 0.348 * sqrt(size_factor * slope_factor * speed_factor); + + + // 输出预测结果 + return speed; + } + +private: + int wind_direction; // 风向(单位:度) + double wind_level; // 风力等级 + double slope; // 坡度(单位:度) + double altitude; // 海拔高度(单位:m) + int cover_type; // 植被类型(1:针叶林;2:落叶林;3:灌木林) + double fire_size; // 火源面积(单位:平方米) + double temperature; // 温度(单位:摄氏度) + double waterlevel; // 湿度(单位:%) +}; diff --git a/src/UAV_UI_new/Fire.png b/src/UAV_UI_new/Fire.png new file mode 100644 index 0000000..1fa4eeb Binary files /dev/null and b/src/UAV_UI_new/Fire.png differ diff --git a/src/UAV_UI_new/Prediction.cpp b/src/UAV_UI_new/Prediction.cpp new file mode 100644 index 0000000..7095053 --- /dev/null +++ b/src/UAV_UI_new/Prediction.cpp @@ -0,0 +1,179 @@ +#include "Prediction.h" +#include +#include +#include "FP.h" +#include +#include +#include +#include + +double Wind_direction, Wind_speed, Humidity, temp; +double fire_size; + +Prediction::Prediction(QPixmap image,double start_pos_x, double start_pos_y,double length,double width, double height, QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); + double dis = distance_of_pix(height, length, width); + qDebug() << start_pos_x << " " << start_pos_y; + QRect rect1(start_pos_x, start_pos_y,length , width); + QPainter painter(&image); + painter.setCompositionMode(QPainter::CompositionMode_Clear); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + painter.fillRect(rect1, QColor(255, 0, 0, 100)); + QString styleSheet = QString("background-image:url(:/background_2.png);\ + background-repeat:no-repeat;background-position:center;").arg(QCoreApplication::applicationDirPath()); + this->setStyleSheet(styleSheet); + this->resize(1080, 640); + getWeatherInfo("beijing"); + fire_size = dis * length * dis * width; + connect(ui.east, &QPushButton::clicked, this, [=] { + int type = 0; + int Tree_Type = ui.Tree_Type->text().toInt(); + QPixmap pixmap = ui.display->pixmap(); + int grow_pix = onclick_wind_button(dis, type, Tree_Type, start_pos_x, start_pos_y, length, width); + qDebug() << grow_pix << "?"; + QPainter painter_1(&pixmap); + QRect rect2(start_pos_x + length, start_pos_y, grow_pix, width); + if (painter_1.isActive()) { + painter_1.fillRect(rect2, QColor(0, 0, 255, 100)); + ui.display->setPixmap(pixmap); + } + else { + qDebug() << "painter is not initialized"; + return; + } + //painter_1.fillRect(rect2, QColor(0, 0, 255, 100)); + //ui.display->setPixmap(pixmap); + }); + connect(ui.west, &QPushButton::clicked, this, [=] { + int type = 1; + int Tree_Type = ui.Tree_Type->text().toInt(); + QPixmap pixmap = ui.display->pixmap(); + int grow_pix = onclick_wind_button(dis, type, Tree_Type, start_pos_x, start_pos_y, length, width); + QPainter painter_1(&pixmap); + QRect rect2(start_pos_x - grow_pix, start_pos_y, grow_pix, width); + if (painter_1.isActive()) { + painter_1.fillRect(rect2, QColor(0, 0, 255, 100)); + ui.display->setPixmap(pixmap); + } + else { + qDebug() << "painter is not initialized"; + return; + } + //painter_1.fillRect(rect2, QColor(0, 0, 255, 100)); + //ui.display->setPixmap(pixmap); + }); + connect(ui.north, &QPushButton::clicked, this, [=] { + int type = 2; + int Tree_Type = ui.Tree_Type->text().toInt(); + QPixmap pixmap = ui.display->pixmap(); + int grow_pix = onclick_wind_button(dis, type, Tree_Type, start_pos_x, start_pos_y, length, width); + QPainter painter_1(&pixmap); + QRect rect2(start_pos_x, start_pos_y - grow_pix, length, grow_pix); + if (painter_1.isActive()) { + painter_1.fillRect(rect2, QColor(0, 0, 255, 100)); + ui.display->setPixmap(pixmap); + } + else { + qDebug() << "painter is not initialized"; + return; + } + //painter_1.fillRect(rect2, QColor(0, 0, 255, 100)); + //ui.display->setPixmap(pixmap); + }); + connect(ui.south, &QPushButton::clicked, this, [=] { + int type = 3; + int Tree_Type = ui.Tree_Type->text().toInt(); + QPixmap pixmap = ui.display->pixmap(); + int grow_pix = onclick_wind_button(dis, type, Tree_Type, start_pos_x, start_pos_y, length, width); + QPainter painter_1(&pixmap); + QRect rect2(start_pos_x, start_pos_y + width, length, grow_pix); + if (painter_1.isActive()) { + painter_1.fillRect(rect2, QColor(0, 0, 255, 100)); + ui.display->setPixmap(pixmap); + } + else { + qDebug() << "painter is not initialized"; + return; + } + //painter_1.fillRect(rect2, QColor(0, 0, 255, 100)); + //ui.display->setPixmap(pixmap); + }); + ui.display->setPixmap(image); +} + +Prediction::~Prediction() +{ + +} +double Prediction::distance_of_pix(int height,int length, int width) { + // ˻߶Ϊ HͼһƬسΪ L + double f = 50.0; // ͷĽ࣬λΪ + double w = 60.0; // ͷˮƽҰλΪ + double A = (2.0 * atan(w / (2.0 * f))) * M_PI / 180.0; // ӽǣλΪ + double r = height / tan(A); // ʵʾͼıֵ + double D = (length * r) / f; // ʵʳȣλΪ + double res = D / length; + // + return res; +} +int Prediction::onclick_wind_button(double dis, int type, int Tree_Type, int start_pos_x, int start_pos_y, int length, int wid) { + //0 for east 1 for west 2 for north 3 for south + double wind_level = std::pow(Wind_speed / 0.836, 0.16); + if (type == 0) { + ForestFirePrediction ffp((int)Wind_direction, wind_level, 12, 200, Tree_Type, fire_size, temp, Humidity); + int speed = ffp.predict_speed(); + int grow_pix = (speed / 12) / dis; + return grow_pix; + if (type == 1) { + ForestFirePrediction ffp((int)Wind_direction, wind_level, 12, 200, Tree_Type, fire_size, temp, Humidity); + int speed = ffp.predict_speed(); + int grow_pix = (speed / 12) / dis; + return grow_pix; + } + if (type == 2) { + ForestFirePrediction ffp((int)Wind_direction, wind_level, 12, 200, Tree_Type, fire_size, temp, Humidity); + int speed = ffp.predict_speed(); + int grow_pix = (speed / 12) / dis; + return grow_pix; + qDebug() << speed << " " << grow_pix << "Grow"; + + } + if (type == 3) { + ForestFirePrediction ffp((int)Wind_direction, wind_level, 12, 200, Tree_Type, fire_size, temp, Humidity); + int speed = ffp.predict_speed(); + int grow_pix = (speed / 12) / dis; + return grow_pix; + } + } +} +void Prediction::getWeatherInfo(QString city) +{ + // Գƽ URL + QString encodedCity = QUrl::toPercentEncoding(city); + + // API URL ַ + QString url = "http://api.openweathermap.org/data/2.5/weather?q=" + encodedCity + "&appid=8a4595940d39d20fbb6f4f94ba813c65"; + + // ʹ + QNetworkAccessManager* nam = new QNetworkAccessManager(); + + // GET + QNetworkReply* reply = nam->get(QNetworkRequest(QUrl(url))); + + // ȴ + while (!reply->isFinished()) { + qApp->processEvents(); + } + + // ȡص JSON + QByteArray jsonData = reply->readAll(); + QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonData); + QJsonObject jsonObject = jsonDocument.object(); + Wind_direction = jsonObject["wind"].toObject()["deg"].toDouble(); + Wind_speed = jsonObject["wind"].toObject()["speed"].toDouble(); + Humidity = jsonObject["main"].toObject()["humidity"].toDouble(); + temp = jsonObject.value("main").toObject().value("temp").toDouble(); + qDebug() << Wind_direction << Wind_speed << Humidity; +} diff --git a/src/UAV_UI_new/Prediction.h b/src/UAV_UI_new/Prediction.h new file mode 100644 index 0000000..3842a39 --- /dev/null +++ b/src/UAV_UI_new/Prediction.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "ui_Prediction.h" +#include +#include +#include +#include + +class Prediction : public QMainWindow +{ + Q_OBJECT + +public: + Prediction(QPixmap image, double start_pos_x, double start_pos_y, double length, double width, double height, QWidget *parent = nullptr); + ~Prediction(); + //QPainter *painter; + +private: + Ui::PredictionClass ui; + double distance_of_pix(int height,int length,int width); + int onclick_wind_button(double dis,int type,int Tree_Type,int start_pos_x,int start_pos_y,int length,int wid); + void getWeatherInfo(QString city); +}; diff --git a/src/UAV_UI_new/Prediction.ui b/src/UAV_UI_new/Prediction.ui new file mode 100644 index 0000000..34dc380 --- /dev/null +++ b/src/UAV_UI_new/Prediction.ui @@ -0,0 +1,159 @@ + + + PredictionClass + + + + 0 + 0 + 1130 + 644 + + + + Prediction + + + + + + 120 + 50 + 642 + 509 + + + + + 640 + 480 + + + + + + + true + + + + 640 + 480 + + + + + 640 + 480 + + + + + + + + + + + + + 130 + 30 + 81 + 31 + + + + 火势状况 + + + + + + 830 + 60 + 93 + 29 + + + + 北风 + + + + + + 830 + 110 + 93 + 29 + + + + 南风 + + + + + + 830 + 160 + 93 + 29 + + + + 东风 + + + + + + 830 + 210 + 93 + 29 + + + + 西风 + + + + + + 830 + 260 + 91 + 31 + + + + 1:针叶林;2:落叶林;3:灌木林 + + + + + + + 0 + 0 + 1130 + 26 + + + + + + TopToolBarArea + + + false + + + + + + + + diff --git a/src/UAV_UI_new/Setting.cpp b/src/UAV_UI_new/Setting.cpp index b5f5f3e..d064b1c 100644 --- a/src/UAV_UI_new/Setting.cpp +++ b/src/UAV_UI_new/Setting.cpp @@ -17,6 +17,11 @@ Setting::Setting(QWidget *parent) tcpsocket = new QTcpSocket(this); tcpsocket->connectToHost("192.168.8.100", 9090); connect(ui.finished, &QPushButton::clicked, this, &Setting::on_finished_button); + QString styleSheet = QString("background-image:url(:/background_1.png);\ + background-repeat:no-repeat;background-position:center;").arg(QCoreApplication::applicationDirPath()); + this->setStyleSheet(styleSheet); + this->resize(806, 453); + ui.finished->setStyleSheet("background-color: white;"); } Setting::~Setting() diff --git a/src/UAV_UI_new/Setting.ui b/src/UAV_UI_new/Setting.ui index a1af477..df56753 100644 --- a/src/UAV_UI_new/Setting.ui +++ b/src/UAV_UI_new/Setting.ui @@ -17,8 +17,8 @@ - 20 - 20 + 200 + 100 451 241 @@ -166,8 +166,8 @@ - 180 - 290 + 360 + 370 93 29 diff --git a/src/UAV_UI_new/Settings.jpg b/src/UAV_UI_new/Settings.jpg new file mode 100644 index 0000000..588aaa7 Binary files /dev/null and b/src/UAV_UI_new/Settings.jpg differ diff --git a/src/UAV_UI_new/Settings_2.jpg b/src/UAV_UI_new/Settings_2.jpg new file mode 100644 index 0000000..e515216 Binary files /dev/null and b/src/UAV_UI_new/Settings_2.jpg differ diff --git a/src/UAV_UI_new/UAV_UI_new.cpp b/src/UAV_UI_new/UAV_UI_new.cpp index 2e865ba..eeac212 100644 --- a/src/UAV_UI_new/UAV_UI_new.cpp +++ b/src/UAV_UI_new/UAV_UI_new.cpp @@ -1,5 +1,6 @@ #include "UAV_UI_new.h" #include "Setting.h" +#include "tips.h" #include #include #include @@ -12,8 +13,10 @@ using namespace cv; using namespace std; VideoCapture cap; -//const string VideoCaptureAdress = "http://admin:admin@192.168.8.126:8081"; -const string VideoCaptureAdress = "rtsp://192.168.144.108:8000/375897"; //ȳ +Prediction* Predict_UI; +int length, wid, start_pos_x, start_pos_y, heig,slope,elevation; +const string VideoCaptureAdress = "http://admin:admin@192.168.8.126:8081"; +//const string VideoCaptureAdress = "rtsp://192.168.144.108:8000/375897"; //ȳ //const string VideoCaptureAdress = "rtsp://192.168.144.108:8000/165506"; //nomal //const string VideoCaptureAdress = "C:\\Users\\87334\\Videos\\Captures\\Fast_sent.mp4"; UAV_UI_new::UAV_UI_new(QWidget* parent) @@ -26,7 +29,7 @@ UAV_UI_new::UAV_UI_new(QWidget* parent) connect(ui.Settings, &QPushButton::clicked, this, &UAV_UI_new::onclick_Setting_button); connect(ui.connection, &QPushButton::clicked, this, &UAV_UI_new::on_connection_button); connect(ui.stop, &QPushButton::clicked, this, &UAV_UI_new::on_stop_button); - connect(ui.action, &QPushButton::clicked, this, &UAV_UI_new::on_action_button); + connect(ui.Prediction, &QPushButton::clicked, this, &UAV_UI_new::on_predict_button); connect(timer, SIGNAL(timeout()), this, SLOT(importImage())); tcpsocket = new QTcpSocket(this); tcpsocket->connectToHost("192.168.8.100", 9090); @@ -42,14 +45,29 @@ UAV_UI_new::UAV_UI_new(QWidget* parent) QByteArray jsonData = tcpsocket->readAll(); // JSON QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonData); QJsonObject jsonObject = jsonDocument.object(); - QString type = jsonObject.value("type").toString(); + QString type = jsonObject.value("type").toString(); if (type == "Alarming") { - QMessageBox msgBox; - msgBox.setWindowTitle("Alarming"); - msgBox.setText("Fire and Fire"); - msgBox.show(); + QPixmap image_Pre(":/Fire.png"); + tips* tip = new tips(image_Pre); + tip->show(); + ui.Prediction->setStyleSheet("color:red"); + length = jsonObject.value("length").toDouble(); + wid = jsonObject.value("width").toDouble(); + qDebug() << jsonObject.value("center_x").toDouble() << jsonObject.value("length").toDouble() / 2; + start_pos_x = jsonObject.value("center_x").toDouble() - jsonObject.value("length").toDouble() / 2; + start_pos_y = jsonObject.value("center_y").toDouble() - jsonObject.value("width").toDouble() / 2; + qDebug() << start_pos_x << " " << start_pos_y << "mAIN"; + slope = jsonObject.value("slope").toDouble(); + elevation = jsonObject.value("slope").toDouble(); + } + if (type == "Set") { + heig = jsonObject.value("z").toInt(); } }); + QString styleSheet = QString("background-image:url(:/background_3.png);\ + background-repeat:no-repeat;background-position:center;").arg(QCoreApplication::applicationDirPath()); + this->setStyleSheet(styleSheet); + this->resize(1440, 720); } UAV_UI_new::~UAV_UI_new() @@ -72,12 +90,15 @@ void UAV_UI_new::importImage() { image.step, QImage::Format_RGB888)); ui.display->setPixmap(showimage); + image_Pre = showimage; } void UAV_UI_new::on_stop_button() { timer->stop(); cap.release(); ui.display->clear(); } -void UAV_UI_new::on_action_button() { - //ž +void UAV_UI_new::on_predict_button() { + QPixmap image_Pre(":/Fire.png"); + Predict_UI = new Prediction(image_Pre, start_pos_x,start_pos_y,length,wid,100); + Predict_UI->show(); } diff --git a/src/UAV_UI_new/UAV_UI_new.h b/src/UAV_UI_new/UAV_UI_new.h index 0a029c1..f33ade1 100644 --- a/src/UAV_UI_new/UAV_UI_new.h +++ b/src/UAV_UI_new/UAV_UI_new.h @@ -3,6 +3,7 @@ #include #include "ui_UAV_UI_new.h" #include "Setting.h" +#include "Prediction.h" #include #include #include @@ -25,11 +26,12 @@ private: QTcpServer* tcpserver; QTcpSocket* tcpsocket; Setting Settings_UI; + QPixmap image_Pre; private slots: void on_connection_button(); void on_stop_button(); void importImage(); void onclick_Setting_button(); - void on_action_button(); + void on_predict_button(); }; diff --git a/src/UAV_UI_new/UAV_UI_new.qrc b/src/UAV_UI_new/UAV_UI_new.qrc index d2572c5..1867e34 100644 --- a/src/UAV_UI_new/UAV_UI_new.qrc +++ b/src/UAV_UI_new/UAV_UI_new.qrc @@ -1,4 +1,9 @@ - + + background_1.png + background_2.png + background_3.png + Fire.png + kill_fire.jpg diff --git a/src/UAV_UI_new/UAV_UI_new.ui b/src/UAV_UI_new/UAV_UI_new.ui index 0559558..3e5a82b 100644 --- a/src/UAV_UI_new/UAV_UI_new.ui +++ b/src/UAV_UI_new/UAV_UI_new.ui @@ -6,10 +6,22 @@ 0 0 - 1159 - 682 + 1440 + 1000 + + + 0 + 0 + + + + + 1440 + 1200 + + UAV_UI_new @@ -64,7 +76,7 @@ - stop + 关闭图像 @@ -77,7 +89,7 @@ - connection + 连接图像 @@ -90,20 +102,20 @@ - 图像播放处 + 实时图像 - 1060 + 1350 0 93 29 - Settings + 设置 @@ -119,13 +131,26 @@ 出警 + + + + 820 + 260 + 93 + 29 + + + + 预测 + + 0 0 - 1159 + 1440 26 diff --git a/src/UAV_UI_new/UAV_UI_new.vcxproj b/src/UAV_UI_new/UAV_UI_new.vcxproj index 3e38d8b..21ea755 100644 --- a/src/UAV_UI_new/UAV_UI_new.vcxproj +++ b/src/UAV_UI_new/UAV_UI_new.vcxproj @@ -92,10 +92,12 @@ + + @@ -105,12 +107,20 @@ + + + + + + + + diff --git a/src/UAV_UI_new/UAV_UI_new.vcxproj.filters b/src/UAV_UI_new/UAV_UI_new.vcxproj.filters index 8d90fdc..804e6e6 100644 --- a/src/UAV_UI_new/UAV_UI_new.vcxproj.filters +++ b/src/UAV_UI_new/UAV_UI_new.vcxproj.filters @@ -46,6 +46,9 @@ Source Files + + Source Files + @@ -54,6 +57,9 @@ Header Files + + Header Files + @@ -62,15 +68,35 @@ Form Files + + Form Files + Header Files + + Header Files + + + Header Files + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/src/UAV_UI_new/UAV_UI_new.vcxproj.user b/src/UAV_UI_new/UAV_UI_new.vcxproj.user index fee5cdc..9b3500c 100644 --- a/src/UAV_UI_new/UAV_UI_new.vcxproj.user +++ b/src/UAV_UI_new/UAV_UI_new.vcxproj.user @@ -2,9 +2,9 @@ - 2023-05-21T16:36:10.6302989Z + 2023-06-14T08:40:27.1306328Z - 2023-05-21T16:36:10.6837787Z + 2023-06-14T08:40:27.2066207Z \ No newline at end of file diff --git a/src/UAV_UI_new/background.jpg b/src/UAV_UI_new/background.jpg new file mode 100644 index 0000000..33817f7 Binary files /dev/null and b/src/UAV_UI_new/background.jpg differ diff --git a/src/UAV_UI_new/background_1.png b/src/UAV_UI_new/background_1.png index 9c2f868..f44c761 100644 Binary files a/src/UAV_UI_new/background_1.png and b/src/UAV_UI_new/background_1.png differ diff --git a/src/UAV_UI_new/background_2.png b/src/UAV_UI_new/background_2.png index 501cee4..80f72e9 100644 Binary files a/src/UAV_UI_new/background_2.png and b/src/UAV_UI_new/background_2.png differ diff --git a/src/UAV_UI_new/background_3.png b/src/UAV_UI_new/background_3.png index 0e15823..1c7742d 100644 Binary files a/src/UAV_UI_new/background_3.png and b/src/UAV_UI_new/background_3.png differ diff --git a/src/UAV_UI_new/kill_fire.jpg b/src/UAV_UI_new/kill_fire.jpg new file mode 100644 index 0000000..41910a7 Binary files /dev/null and b/src/UAV_UI_new/kill_fire.jpg differ diff --git a/src/UAV_UI_new/levelToSpeed.h b/src/UAV_UI_new/levelToSpeed.h new file mode 100644 index 0000000..7098b2f --- /dev/null +++ b/src/UAV_UI_new/levelToSpeed.h @@ -0,0 +1,62 @@ +#include +using namespace std; + +double levelToSpeed(int level) { + double speed = 0; + if (level >= 0 && level <= 12) { + double speed = 0; + switch (level) { + case 1: + speed = 0.3; + break; + case 2: + speed = 1.6; + break; + case 3: + speed = 3.4; + break; + case 4: + speed = 5.5; + break; + case 5: + speed = 8.0; + break; + case 6: + speed = 10.8; + break; + case 7: + speed = 13.9; + break; + case 8: + speed = 17.2; + break; + case 9: + speed = 20.8; + break; + case 10: + speed = 24.5; + break; + case 11: + speed = 28.5; + break; + case 12: + speed = 32.7; + break; + + } + + } + else if (level == 13) { + speed = 35.8; + } + else if (level == 14) { + speed = 41.5; + } + else if (level == 15) { + speed = 48.2; + } + else { + cout << "无效的风力等级!" << endl; + } + return speed; +} \ No newline at end of file diff --git a/src/UAV_UI_new/main.cpp b/src/UAV_UI_new/main.cpp index 285b360..ae8b72b 100644 --- a/src/UAV_UI_new/main.cpp +++ b/src/UAV_UI_new/main.cpp @@ -10,8 +10,5 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); UAV_UI_new w; w.show(); - /*VideoCapture cap; - const string VideoCaptureAdress = "rtsp://192.168.144.108:8000/165506"; - cap.open(VideoCaptureAdress);*/ return a.exec(); } diff --git a/src/UAV_UI_new/tips.cpp b/src/UAV_UI_new/tips.cpp index 0fba930..e878542 100644 --- a/src/UAV_UI_new/tips.cpp +++ b/src/UAV_UI_new/tips.cpp @@ -1,10 +1,20 @@ #include "tips.h" -tips::tips(QWidget *parent) +tips::tips(QPixmap image,QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); + ui.display->setPixmap(image); + connect(ui.action, &QPushButton::clicked, this, &tips::on_action_button); + ui.action->setStyleSheet("background-color:red;"); + QString styleSheet = QString("background-image:url(:/kill_fire.jpg);\ + background-repeat:no-repeat;background-position:center;").arg(QCoreApplication::applicationDirPath()); + this->setStyleSheet(styleSheet); } tips::~tips() -{} +{ +} +void tips::on_action_button() { + //ž +} diff --git a/src/UAV_UI_new/tips.h b/src/UAV_UI_new/tips.h index d9ae8ec..be5b454 100644 --- a/src/UAV_UI_new/tips.h +++ b/src/UAV_UI_new/tips.h @@ -8,9 +8,10 @@ class tips : public QMainWindow Q_OBJECT public: - tips(QWidget *parent = nullptr); + tips(QPixmap image, QWidget *parent = nullptr); ~tips(); private: Ui::tipsClass ui; + void on_action_button(); }; diff --git a/src/UAV_UI_new/tips.ui b/src/UAV_UI_new/tips.ui index cec4907..da25089 100644 --- a/src/UAV_UI_new/tips.ui +++ b/src/UAV_UI_new/tips.ui @@ -1,22 +1,107 @@ - + + tipsClass - - - tipsClass - - + + - 0 - 0 - 600 - 400 + 0 + 0 + 1130 + 644 - + + + 1130 + 644 + + + + + 1130 + 644 + + + tips - + + + + + + 19 + 6 + 81 + 31 + + + + 火势状况 + + + + + true + + + + 20 + 30 + 640 + 480 + + + + + 640 + 480 + + + + + 640 + 480 + + + + + + + + + + 830 + 40 + 93 + 29 + + + + 出警 + + + + + + + 0 + 0 + 1130 + 26 + + + + + + TopToolBarArea + + + false + + + - - + + - +