zhangchaoqun_branch
eazzy 1 year ago
parent 87820c7e68
commit 32a97e2d2f

@ -0,0 +1,44 @@
QT += core gui
QT += core gui quickwidgets positioning location
QT += multimedia
QT += multimediawidgets
QT += webenginewidgets webchannel
QT += sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
DogDatabase.cpp \
InjuryAnalysisUI.cpp \
InjuryDatabase.cpp \
UAVDatabase.cpp \
injurydisiplayui.cpp \
main.cpp \
guidingui.cpp
HEADERS += \
DogDatabase.h \
InjuryAnalysisUI.h \
InjuryDatabase.h \
UAVDatabase.h \
guidingui.h \
injurydisiplayui.h
FORMS += \
InjuryAnalysisUI.ui \
guidingui.ui \
injurydisiplayui.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
res.qrc

@ -0,0 +1,268 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 13.0.0, 2024-05-17T08:33:35. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{c17bc554-7aa8-48e6-9607-c4ecd694950b}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">6</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.7.0 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.7.0 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.670.win64_msvc2019_64_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\PROJECT\QT\CasualtySightPlus\build\Desktop_Qt_6_7_0_MSVC2019_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/PROJECT/QT/CasualtySightPlus/build/Desktop_Qt_6_7_0_MSVC2019_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\PROJECT\QT\CasualtySightPlus\build\Desktop_Qt_6_7_0_MSVC2019_64bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/PROJECT/QT/CasualtySightPlus/build/Desktop_Qt_6_7_0_MSVC2019_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="QtQuickCompiler">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\PROJECT\QT\CasualtySightPlus\build\Desktop_Qt_6_7_0_MSVC2019_64bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/PROJECT/QT/CasualtySightPlus/build/Desktop_Qt_6_7_0_MSVC2019_64bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="QtQuickCompiler">0</value>
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/PROJECT/QT/CasualtySightPlus/CasualtySightPlus.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">D:/PROJECT/QT/CasualtySightPlus/CasualtySightPlus.pro</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/PROJECT/QT/CasualtySightPlus/build/Desktop_Qt_6_7_0_MSVC2019_64bit-Release</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

@ -0,0 +1,212 @@
#include "DogDatabase.h"
DogDatabase *DogDatabase::getInstance()
{
static DogDatabase db;
return &db;
}
DogDatabase::~DogDatabase()
{
close();
}
DogDatabase::DogDatabase()
{
m_sqlDb = QSqlDatabase::addDatabase("QMYSQL");
}
//添加记录
bool DogDatabase::add(const Dog &data)
{
<<<<<<< HEAD:src/Client2/fly_land/DogDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/DogDatabase.cpp
{
beginAddFiled("dogdatabase");
addFiled("id");
addFiled("state");
addFiled("ip");
addFiled("port");
addFiled("lon");
addFiled("lat");
endAddFiled();
beginAddRow();
addValue(data.id);
addValue(data.state);
addValue(data.ip);
addValue(data.port);
addValue(data.lon);
addValue(data.lat);
endAddRow();
m_valueSql = m_valueSql.left(m_valueSql.length()-1);
QString sql;
sql = m_headerSql + m_valueSql;
return exec(sql);
}
close();
}
//查询位置信息的记录
Point DogDatabase::ReturnUAVPosition(QString id)
{
<<<<<<< HEAD:src/Client2/fly_land/DogDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/DogDatabase.cpp
{
QSqlQuery query(m_sqlDb);
QString strQuery;
strQuery = "SELECT lon, lat FROM ";
strQuery += "dogdatabase";
strQuery += " WHERE id = ";
strQuery += id;
qDebug()<<strQuery;
query.prepare(strQuery);
Point position;
bool isSuccess = query.exec();
if(isSuccess)
{
while(query.next())
{
double lon = query.value(0).toDouble();
double lat = query.value(1).toDouble();
position.lon = lon;
position.lat = lat;
}
}
return position;
}
close();
}
//返回状态信息
int DogDatabase::giveInfo(QString id)
{
<<<<<<< HEAD:src/Client2/fly_land/DogDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/DogDatabase.cpp
{
QSqlQuery query(m_sqlDb);
QString strQuery;
strQuery = "SELECT state FROM ";
strQuery += "dogdatabase";
strQuery += " WHERE id = ";
strQuery += id;
qDebug()<<strQuery;
query.prepare(strQuery);
int state = -1;
bool isSuccess = query.exec();
if(isSuccess)
{
while(query.next())
{
state = query.value(0).toInt();
}
}
return state;
}
close();
}
//——————————————————私有方法————————————————————
//建立连接
bool DogDatabase::open(const QString &dbName,const QString &userName,const QString &passwd)
{
m_sqlDb.setHostName("localhost"); // 本地数据库 远程DB是ipaddress
m_sqlDb.setPort(3306); // 设置端口号
m_sqlDb.setDatabaseName(dbName);
m_sqlDb.setUserName(userName);
m_sqlDb.setPassword(passwd);
if(!m_sqlDb.open())
{
qDebug()<<"连接失败!";
return false;
}
else
{
qDebug()<<"连接成功!";
return true;
}
}
void DogDatabase::close()
{
m_sqlDb.close();
}
void DogDatabase::beginAddFiled(const QString &tableName)
{
m_tableName = tableName;
m_fieldName.clear();
m_headerSql.clear();
m_valueSql.clear();
m_fieldAdd = 0;
}
void DogDatabase::addFiled(const QString &filedName)
{
m_fieldName.append(filedName);
}
void DogDatabase::endAddFiled()
{
m_headerSql = QString("INSERT INTO %0 (%1) values").arg(m_tableName).arg(m_fieldName.join(","));
}
void DogDatabase::beginAddRow()
{
m_valueSql += "(";
}
void DogDatabase::addValue(const QVariant &value)
{
m_valueSql += QString("\'%0\',").arg(value.toString());
m_fieldAdd++;
}
void DogDatabase::endAddRow()
{
m_valueSql = m_valueSql.left(m_valueSql.length() - 1);
m_valueSql += "),";
}
bool DogDatabase::exec(const QString &sql)
{
bool isSuccess = false;
QSqlQuery query(m_sqlDb);
query.prepare(sql);
qDebug()<<sql;
isSuccess = query.exec();
if(!isSuccess)
<<<<<<< HEAD:src/Client2/fly_land/DogDatabase.cpp
qDebug() << "Error inserting data:" << query.lastError().text();
=======
//qDebug() << "Error inserting data:" << query.lastError().text();
>>>>>>> master:src/Client/DogDatabase.cpp
return isSuccess;
}

@ -0,0 +1,104 @@
#ifndef DOGDATABASE_H
#define DOGDATABASE_H
#include <QtSql>
<<<<<<< HEAD:src/Client2/fly_land/DogDatabase.h
#include <QWidget>
#include <QSqlQuery>
#include <QSqlDatabase>
=======
#include <QSqlDatabase>
#include <QWidget>
#include <QSqlQuery>
>>>>>>> master:src/Client/DogDatabase.h
#include <QString>
#include <QSqlRecord>
#include <QDebug>
#include "UAVDatabase.h"
using namespace std;
struct Dog
{
QString id;
int state;
QString ip;
int port;
double lon;
double lat;
};
class DogDatabase
{
// Q_OBJECT宏用于提供Qt信号槽和元对象系统服务
// 它必须限定为私有访问权限
//Q_OBJECT
public:
static DogDatabase *getInstance();
DogDatabase();
~DogDatabase();
Dog data;
//返回状态信息
int giveInfo(QString id);
//添加数据记录
bool add(const Dog &data);
//查询位置信息数据
Point ReturnUAVPosition( QString id);
private:
//打开
bool open(const QString &dbName,const QString &userName = QString(),const QString &passwd = QString());
//关闭
void close();
//开始添加字段
void beginAddFiled(const QString &tableName);
//添加字段
void addFiled(const QString &filedName);
//结束添加字段
void endAddFiled();
//开始添加行
void beginAddRow();
//添加字段值
void addValue(const QVariant &value);
//结束添加行
void endAddRow();
//执行
bool exec(const QString &sql);
private:
//数据库
QSqlDatabase m_sqlDb;
//表名
QString m_tableName;
//字段名
QStringList m_fieldName;
//头sql
QString m_headerSql;
//值sql
QString m_valueSql;
//已添加row数
int m_fieldAdd = 0;
};
#endif // DOGDATABASE_H

@ -0,0 +1,116 @@
#include "InjuryAnalysisUI.h"
#include "InjuryDatabase.h"
#include "ui_InjuryAnalysisUI.h"
#include <QMessageBox>
#include <QWidget>
InjuryAnalysisUI::InjuryAnalysisUI(QWidget* parent):
QWidget(parent),
ui(new Ui::InjuryAnalysisUI)
{
ui->setupUi(this);
setWindowTitle("伤情态势分析界面");
//resize(600,400);
InjuryDatabase injurydatabase;
QList<Injury> resultNow;
injurydatabase.select_all(resultNow);//获取所有伤员数据
result = resultNow;
//添加一个scrollArea来将信息显示出来
ui->scrollArea->setWidgetResizable(false);//可以拖动滚动条
//竖滚动条和横滚动条都可以一直显示
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//设置主界面的实际界面
ui->scrollArea->setWidget(ui->scrollAreaWidgetContents);
ui->scrollAreaWidgetContents->setGeometry(0, 0, 381, result.length()*20);//实际界面参数
QLabel *label0=new QLabel(ui->scrollAreaWidgetContents);
label0->setText("伤员编号");
label0->move(0,0);
QLabel *label1=new QLabel(ui->scrollAreaWidgetContents);
label1->setText("伤情等级");
label1->move(100,0);
QLabel *label2=new QLabel(ui->scrollAreaWidgetContents);
label2->setText("位置精度");
label2->move(200,0);
QLabel *label3=new QLabel(ui->scrollAreaWidgetContents);
label3->setText("位置维度");
label3->move(300,0);
for(int i = 0; i<result.length(); i++)
{
QLabel *labelID=new QLabel(ui->scrollAreaWidgetContents);
labelID->setText(result[i].id);
labelID->move(0,15*(i+2));
QLabel *labelRank=new QLabel(ui->scrollAreaWidgetContents);
labelRank->setText(QString::number(result[i].rank));
labelRank->move(100,15*(i+2));
QLabel *labelLon=new QLabel(ui->scrollAreaWidgetContents);
labelLon->setText(QString::number(result[i].lon));
labelLon->move(200,15*(i+2));
QLabel *labelLat=new QLabel(ui->scrollAreaWidgetContents);
labelLat->setText(QString::number(result[i].lat));
labelLat->move(300,15*(i+2));
}
//对信息进行分类统计分析
int sum = result.length();
ui->sumLabel->setText(QString::number(sum));
int rank0Sum = 0;
int rank1Sum = 0;
int rank2Sum = 0;
for(int i = 0; i<sum; i++)
{
if(result[i].rank==0)
rank0Sum++;
else if(result[i].rank==1)
rank1Sum++;
else if(result[i].rank==2)
rank2Sum++;
}
ui->rank0Label->setText(QString::number(rank0Sum));
ui->rank1Label->setText(QString::number(rank1Sum));
ui->rank2Label->setText(QString::number(rank2Sum));
}
InjuryAnalysisUI::~InjuryAnalysisUI()
{
delete ui;
}
void InjuryAnalysisUI::on_searchButton_clicked()
{
QString userInput = ui->searchInput->text();
int searchIndex = -1;
if(!userInput.isEmpty())
{
for(int i = 0; i<result.length(); i++)
{
if(QString::compare(userInput,result[i].id)==0)
{
searchIndex = i;
break;
}
}
}
QString rank = QString::number(result[searchIndex].rank);
QString lon = QString::number(result[searchIndex].lon);
QString lat = QString::number(result[searchIndex].lat);
if(searchIndex==-1)
{
QMessageBox::warning(this, tr("查找"), tr("找不到id为 %1 的伤员!").arg(userInput));
}
else
{
QMessageBox::warning(this, tr("查找"), tr("伤员id%1 伤情等级:%2 位置经纬度:%3 %4 ").arg(userInput,rank,lon,lat));
}
}

@ -0,0 +1,36 @@
#ifndef INJURYANALYSISUI_H
#define INJURYANALYSISUI_H
#include "InjuryDatabase.h"
#include <QWidget>
QT_BEGIN_NAMESPACE
namespace Ui {
class InjuryAnalysisUI; //声明ui命名空间下的类
}
QT_END_NAMESPACE
class InjuryAnalysisUI : public QWidget
{
// Q_OBJECT宏用于提供Qt信号槽和元对象系统服务
// 它必须限定为私有访问权限
Q_OBJECT
public:
InjuryAnalysisUI(QWidget *parent = nullptr);
~InjuryAnalysisUI();
QList<Injury> result;
private slots:
void on_searchButton_clicked();
private:
// 创建Ui::InjuryAnalysisUI类型的指针用于操作ui界面及其控件
Ui::InjuryAnalysisUI *ui;
};
#endif // INJURYANALYSISUI_H

@ -0,0 +1,236 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InjuryAnalysisUI</class>
<widget class="QWidget" name="InjuryAnalysisUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>679</width>
<height>410</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(245, 245, 245);
font: 11pt &quot;Microsoft YaHei UI&quot;;</string>
</property>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>215</width>
<height>82</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/logo_backgroundless.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>伤情结果统计:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="AnalysisDialog" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>631</width>
<height>291</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
background-color: rgba(15, 28, 34, 0);
color: rgb(0, 0, 0);
border: none;
padding: 10px 20px; /* 设置内边距 */
border-radius: 5px; /* 设置按钮圆角 */
font-size: 14px; /* 设置文字大小 */
text-align: right; /* 设置字体向右对齐 */
}
QPushButton:hover {
background-color: #0364FF; /* 设置鼠标悬停时按钮背景色 */
}
QPushButton:pressed {
background-color: #398439; /* 设置按钮被按下时背景色 */
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>365</width>
<height>229</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>伤员总数:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="sumLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>伤情轻微的伤员数:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rank0Label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>伤情一般的伤员数:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rank1Label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>伤情严重的伤员数:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rank2Label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>输入伤员编号查询伤员信息</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="searchInput">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="searchButton">
<property name="styleSheet">
<string notr="true">font: 14pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>查询</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,232 @@
#include "InjuryDatabase.h"
InjuryDatabase *InjuryDatabase::getInstance()
{
static InjuryDatabase db;
return &db;
}
InjuryDatabase::~InjuryDatabase()
{
close();
}
InjuryDatabase::InjuryDatabase()
{
m_sqlDb = QSqlDatabase::addDatabase("QMYSQL");
}
//添加记录
bool InjuryDatabase::add(const Injury &data)
{
<<<<<<< HEAD:src/Client2/fly_land/InjuryDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/InjuryDatabase.cpp
{
beginAddFiled("injurydatabase");
addFiled("id");
addFiled("injuryrank");
addFiled("lon");
addFiled("lat");
addFiled("flag");
endAddFiled();
beginAddRow();
addValue(data.id);
addValue(data.rank);
addValue(data.lon);
addValue(data.lat);
addValue(data.flag);
endAddRow();
m_valueSql = m_valueSql.left(m_valueSql.length()-1);
QString sql;
sql = m_headerSql + m_valueSql;
return exec(sql);
}
close();
}
//查询所有记录
bool InjuryDatabase::select_all(QList<Injury> &result)
{
<<<<<<< HEAD:src/Client2/fly_land/InjuryDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/InjuryDatabase.cpp
{
QSqlQuery query(m_sqlDb);
QString strQuery;
strQuery = "SELECT * FROM ";
strQuery += "injurydatabase";
query.prepare(strQuery);
bool isSuccess = query.exec();
if(isSuccess)
{
while(query.next())
{
QString id = query.value(0).toString();
int rank = query.value(1).toInt();
double lon = query.value(2).toDouble();
double lat = query.value(3).toDouble();
int flag = query.value(4).toInt();
Injury data;
data.id = id;
data.rank = rank;
data.lon = lon;
data.lat = lat;
data.flag = flag;
result.append(data);
}
}
return isSuccess;
}
close();
}
//返回有效伤员的信息
void InjuryDatabase::ReturnInfo(QList<Injury> result)
{
<<<<<<< HEAD:src/Client2/fly_land/InjuryDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/InjuryDatabase.cpp
{
select_valid("injurydatabase", result);
for(int i = 0; i<result.length(); i++)
{
qDebug()<<result[i].id<<" "<<result[i].lon<< " "<<result[i].lat<<" "<<result[i].rank;
}
}
close();
}
//——————————————————私有方法————————————
//建立连接
bool InjuryDatabase::open(const QString &dbName,const QString &userName,const QString &passwd)
{
m_sqlDb.setHostName("localhost"); // 本地数据库 远程DB是ipaddress
m_sqlDb.setPort(3306); // 设置端口号
m_sqlDb.setDatabaseName(dbName);
m_sqlDb.setUserName(userName);
m_sqlDb.setPassword(passwd);
if(!m_sqlDb.open())
{
qDebug()<<"连接失败!";
return false;
}
else
{
qDebug()<<"连接成功!";
return true;
}
}
//查询有效记录
bool InjuryDatabase::select_valid(const QString &tableName, QList<Injury> &result)
{
QSqlQuery query(m_sqlDb);
QString strQuery;
strQuery = "SELECT id, injuryrank, lon, lat FROM ";
strQuery += tableName;
strQuery += " WHERE flag = 1";
//qDebug()<<strQuery;//打印SQL语句检查错误
query.prepare(strQuery);
bool isSuccess = query.exec();
if(isSuccess)
{
while(query.next())
{
QString id = query.value(0).toString();
int rank = query.value(1).toInt();
double lon = query.value(2).toDouble();
double lat = query.value(3).toDouble();
Injury data;
data.id = id;
data.rank = rank;
data.lon = lon;
data.lat = lat;
result.append(data);
}
}
return isSuccess;
}
void InjuryDatabase::close()
{
m_sqlDb.close();
}
void InjuryDatabase::beginAddFiled(const QString &tableName)
{
m_tableName = tableName;
m_fieldName.clear();
m_headerSql.clear();
m_valueSql.clear();
m_fieldAdd = 0;
}
void InjuryDatabase::addFiled(const QString &filedName)
{
m_fieldName.append(filedName);
}
void InjuryDatabase::endAddFiled()
{
m_headerSql = QString("INSERT INTO %0 (%1) values").arg(m_tableName).arg(m_fieldName.join(","));
}
void InjuryDatabase::beginAddRow()
{
m_valueSql += "(";
}
void InjuryDatabase::addValue(const QVariant &value)
{
m_valueSql += QString("\'%0\',").arg(value.toString());
m_fieldAdd++;
}
void InjuryDatabase::endAddRow()
{
m_valueSql = m_valueSql.left(m_valueSql.length() - 1);
m_valueSql += "),";
}
bool InjuryDatabase::exec(const QString &sql)
{
bool isSuccess = false;
QSqlQuery query(m_sqlDb);
query.prepare(sql);
qDebug()<<sql;
isSuccess = query.exec();
if(!isSuccess)
//qDebug() << "Error inserting data:" << query.lastError().text();
return isSuccess;
}

@ -0,0 +1,98 @@
#ifndef INJURYDATABASE_H
#define INJURYDATABASE_H
#include <QtSql>
#include <QSqlDatabase>
#include <QWidget>
#include <QSqlQuery>
#include <QString>
#include <QSqlRecord>
#include <QDebug>
using namespace std;
struct Injury
{
QString id;
int rank;
double lon;
double lat;
int flag;
};
class InjuryDatabase
{
// Q_OBJECT宏用于提供Qt信号槽和元对象系统服务
// 它必须限定为私有访问权限
//Q_OBJECT
public:
static InjuryDatabase *getInstance();
InjuryDatabase();
~InjuryDatabase();
//打开
bool open(const QString &dbName,const QString &userName = QString(),const QString &passwd = QString());
//添加数据记录
bool add(const Injury &data);
//查询所有数据
bool select_all(QList<Injury> &result);
Injury data;
//返回有效信息
void ReturnInfo(QList<Injury> data);
private:
//查询有效数据
bool select_valid(const QString &tableName,QList<Injury> &result);
//关闭
void close();
//开始添加字段
void beginAddFiled(const QString &tableName);
//添加字段
void addFiled(const QString &filedName);
//结束添加字段
void endAddFiled();
//开始添加行
void beginAddRow();
//添加字段值
void addValue(const QVariant &value);
//结束添加行
void endAddRow();
//执行
bool exec(const QString &sql);
private:
//数据库
QSqlDatabase m_sqlDb;
//表名
QString m_tableName;
//字段名
QStringList m_fieldName;
//头sql
QString m_headerSql;
//值sql
QString m_valueSql;
//已添加row数
int m_fieldAdd = 0;
};
#endif // INJURYDATABASE_H

@ -0,0 +1,212 @@
#include "UAVDatabase.h"
UAVDatabase *UAVDatabase::getInstance()
{
static UAVDatabase db;
return &db;
}
UAVDatabase::~UAVDatabase()
{
close();
}
UAVDatabase::UAVDatabase()
{
m_sqlDb = QSqlDatabase::addDatabase("QMYSQL");
}
//添加记录
bool UAVDatabase::add(const UAV &data)
{
<<<<<<< HEAD:src/Client2/fly_land/UAVDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/UAVDatabase.cpp
{
beginAddFiled("uavdatabase");
addFiled("id");
addFiled("state");
addFiled("ip");
addFiled("port");
addFiled("lon");
addFiled("lat");
endAddFiled();
beginAddRow();
addValue(data.id);
addValue(data.state);
addValue(data.ip);
addValue(data.port);
addValue(data.lon);
addValue(data.lat);
endAddRow();
m_valueSql = m_valueSql.left(m_valueSql.length()-1);
QString sql;
sql = m_headerSql + m_valueSql;
return exec(sql);
}
close();
}
//查询位置信息的记录
Point UAVDatabase::ReturnUAVPosition(QString id)
{
<<<<<<< HEAD:src/Client2/fly_land/UAVDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/UAVDatabase.cpp
{
QSqlQuery query(m_sqlDb);
QString strQuery;
strQuery = "SELECT lon, lat FROM ";
strQuery += "uavdatabase";
strQuery += " WHERE id = ";
strQuery += id;
qDebug()<<strQuery;
query.prepare(strQuery);
Point position;
bool isSuccess = query.exec();
if(isSuccess)
{
while(query.next())
{
double lon = query.value(0).toDouble();
double lat = query.value(1).toDouble();
position.lon = lon;
position.lat = lat;
}
}
return position;
}
close();
}
//返回状态信息
int UAVDatabase::giveInfo(QString id)
{
<<<<<<< HEAD:src/Client2/fly_land/UAVDatabase.cpp
if(open("fly_land_database","root","684542"))
=======
if(open("fly_land_database","root","MYSQLqwer35257"))
>>>>>>> master:src/Client/UAVDatabase.cpp
{
QSqlQuery query(m_sqlDb);
QString strQuery;
strQuery = "SELECT state FROM ";
strQuery += "uavdatabase";
strQuery += " WHERE id = ";
strQuery += id;
qDebug()<<strQuery;
query.prepare(strQuery);
int state = -1;
bool isSuccess = query.exec();
if(isSuccess)
{
while(query.next())
{
state = query.value(0).toInt();
}
}
return state;
}
close();
}
//——————————————————私有方法————————————————————
//建立连接
bool UAVDatabase::open(const QString &dbName,const QString &userName,const QString &passwd)
{
m_sqlDb.setHostName("localhost"); // 本地数据库 远程DB是ipaddress
m_sqlDb.setPort(3306); // 设置端口号
m_sqlDb.setDatabaseName(dbName);
m_sqlDb.setUserName(userName);
m_sqlDb.setPassword(passwd);
if(!m_sqlDb.open())
{
qDebug()<<"连接失败!";
return false;
}
else
{
qDebug()<<"连接成功!";
return true;
}
}
void UAVDatabase::close()
{
m_sqlDb.close();
}
void UAVDatabase::beginAddFiled(const QString &tableName)
{
m_tableName = tableName;
m_fieldName.clear();
m_headerSql.clear();
m_valueSql.clear();
m_fieldAdd = 0;
}
void UAVDatabase::addFiled(const QString &filedName)
{
m_fieldName.append(filedName);
}
void UAVDatabase::endAddFiled()
{
m_headerSql = QString("INSERT INTO %0 (%1) values").arg(m_tableName).arg(m_fieldName.join(","));
}
void UAVDatabase::beginAddRow()
{
m_valueSql += "(";
}
void UAVDatabase::addValue(const QVariant &value)
{
m_valueSql += QString("\'%0\',").arg(value.toString());
m_fieldAdd++;
}
void UAVDatabase::endAddRow()
{
m_valueSql = m_valueSql.left(m_valueSql.length() - 1);
m_valueSql += "),";
}
bool UAVDatabase::exec(const QString &sql)
{
bool isSuccess = false;
QSqlQuery query(m_sqlDb);
query.prepare(sql);
qDebug()<<sql;
isSuccess = query.exec();
if(!isSuccess)
<<<<<<< HEAD:src/Client2/fly_land/UAVDatabase.cpp
qDebug() << "Error inserting data:" << query.lastError().text();
=======
//qDebug() << "Error inserting data:" << query.lastError().text();
>>>>>>> master:src/Client/UAVDatabase.cpp
return isSuccess;
}

@ -0,0 +1,110 @@
#ifndef UAVDATABASE_H
#define UAVDATABASE_H
<<<<<<< HEAD:src/Client2/fly_land/UAVDatabase.h
#include <QtSql>
#include <QWidget>
#include <QSqlQuery>
=======
#include <QWidget>
#include <QSqlQuery>
#include <QtSql>
>>>>>>> master:src/Client/UAVDatabase.h
#include <QSqlDatabase>
#include <QString>
#include <QSqlRecord>
#include <QDebug>
using namespace std;
struct UAV
{
QString id;
int state;
QString ip;
int port;
double lon;
double lat;
};
//存储经纬度信息
struct Point
{
double lon;
double lat;
};
class UAVDatabase
{
// Q_OBJECT宏用于提供Qt信号槽和元对象系统服务
// 它必须限定为私有访问权限
//Q_OBJECT
public:
static UAVDatabase *getInstance();
UAVDatabase();
~UAVDatabase();
UAV data;
//返回状态信息
int giveInfo(QString id);
//添加数据记录
bool add(const UAV &data);
//查询位置信息数据
Point ReturnUAVPosition( QString id);
private:
//打开
bool open(const QString &dbName,const QString &userName = QString(),const QString &passwd = QString());
//关闭
void close();
//开始添加字段
void beginAddFiled(const QString &tableName);
//添加字段
void addFiled(const QString &filedName);
//结束添加字段
void endAddFiled();
//开始添加行
void beginAddRow();
//添加字段值
void addValue(const QVariant &value);
//结束添加行
void endAddRow();
//执行
bool exec(const QString &sql);
private:
//数据库
QSqlDatabase m_sqlDb;
//表名
QString m_tableName;
//字段名
QStringList m_fieldName;
//头sql
QString m_headerSql;
//值sql
QString m_valueSql;
//已添加row数
int m_fieldAdd = 0;
};
#endif // UAVDATABASE_H

@ -0,0 +1,265 @@
#include "guidingui.h"
#include "ui_guidingui.h"
#include "InjuryAnalysisUI.h"
#include "InjuryDatabase.h"
#include <QWebEngineView>
#include <QString>
#include <QVBoxLayout>
#include <QDir>
#include <QUrl>
#include <QWebEnginePage>
GuidingUI::GuidingUI(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::GuidingUI)
{
ui->setupUi(this);
/* 控制地图显示 */
MapDisplayControl(ui->mapbutton,ui->MapDisplayer,ui->gridLayout_3);
/* 控制添加机器人 */
AddRobotControl(ui->addrobot);
/* 控制机器人列表 */
RobotsInfosControl(ui->robottab);
}
GuidingUI::~GuidingUI()
{
delete ui;
}
void GuidingUI::MapDisplayControl(QPushButton *btnCtr,QWidget*Tar,QGridLayout*layout)
{
// 创建堆栈部件
QStackedWidget* stackedWidget = new QStackedWidget(this);
// 创建背景板部件
QWidget* backgroundWidget = new QWidget(this);
QPixmap backgroundPixmap(":/image/res/image/MapBackGround.png");
QLabel *backgroundLabel = new QLabel(backgroundWidget);
backgroundLabel->setPixmap(backgroundPixmap);
// 设置堆栈部件的组成
backgroundLabel->setMaximumSize(1500,900); // 背景板的最大尺寸
backgroundLabel->setMinimumSize(500,300); // 背景板的最小尺寸
// 设置QLabel的缩放模式为拉伸填充
backgroundLabel->setScaledContents(true);
// 设置地图部件的尺寸
Tar->setMaximumSize(1500,900); // 地图部件的最大尺寸
Tar->setMinimumSize(500,300); // 地图部件的最小尺寸
stackedWidget->addWidget(Tar);
stackedWidget->addWidget(backgroundLabel);
stackedWidget->setCurrentIndex(1);
connect(btnCtr,&QPushButton::clicked,this,[=](){
if(stackedWidget->currentIndex() == 0)
stackedWidget->setCurrentIndex(1);
else
stackedWidget->setCurrentIndex(0);
});
// 将堆栈部件添加到布局当中
layout->addWidget(stackedWidget);
QWebEngineView *view = new QWebEngineView(ui->MapDisplayer);
// 设置HTML文件的路径这里使用资源文件系统
QUrl url = QUrl("qrc:/html/res/html/map.html");
view->load(url);
// 连接loadFinished信号来确认页面是否加载成功并在加载成功后调用addMarker函数
connect(view, &QWebEngineView::loadFinished, [view]() {
// 假设我们要添加的坐标和等级
QList<Injury> result;
InjuryDatabase injuryinfo;
injuryinfo.select_all(result);
for(int i=0;i<result.length();i++)
{
double latitude = result[i].lat;
double longitude = result[i].lon;
int level = result[i].rank;
// 调用JavaScript函数传递参数
view->page()->runJavaScript(QString("addMarker(%1, %2, %3)").arg(latitude).arg(longitude).arg(level), [](const QVariant &result) {
// 这里可以处理JavaScript函数执行后的结果
});
}
});
// 由于 MapDisplayer 已经在 UI 布局中,我们不需要创建新的布局
// 直接将 QWebEngineView 添加到 MapDisplayer 中
QVBoxLayout *layout1 = qobject_cast<QVBoxLayout*>(ui->MapDisplayer->layout());
if (layout1) {
layout1->addWidget(view);
} else {
// 如果 MapDisplayer 没有布局,则创建一个并添加 QWebEngineView
QVBoxLayout *newLayout = new QVBoxLayout(ui->MapDisplayer);
newLayout->addWidget(view);
ui->MapDisplayer->setLayout(newLayout);
}
}
void GuidingUI::on_addrobot_clicked()
{
QDialog *dialog = new QDialog(this);
QVBoxLayout *layout = new QVBoxLayout;
QHBoxLayout *nameLayout = new QHBoxLayout;
QLabel *nameLabel = new QLabel("名称(customized)", dialog);
QLineEdit *nameEdit = new QLineEdit(dialog);
nameLayout->addWidget(nameLabel);
nameLayout->addWidget(nameEdit);
layout->addLayout(nameLayout);
QHBoxLayout *ipLayout = new QHBoxLayout;
QLabel *ipLabel = new QLabel("IP地址", dialog);
QLineEdit *ipEdit = new QLineEdit(dialog);
ipLayout->addWidget(ipLabel);
ipLayout->addWidget(ipEdit);
layout->addLayout(ipLayout);
QPushButton *okButton = new QPushButton("确定", dialog);
layout->addWidget(okButton);
connect(okButton, &QPushButton::clicked, dialog, &QDialog::accept);
connect(dialog, &QDialog::accepted, [=]() {
QString name = nameEdit->text();
QString ip = ipEdit->text();
// listWidget->addItem(name + " - " + ip);
});
dialog->setLayout(layout);
dialog->exec();
}
void GuidingUI::AddRobotControl(QPushButton* btnCtr)
{
connect(btnCtr,&QPushButton::clicked,this,&GuidingUI::on_addrobot_clicked);
}
void on_specifiedrobottab_clicked()
{
}
void GuidingUI::on_robottab_clicked()
{
char robot_one[100] = "alice,192.168.0.1";
char robot_two[100] = "bob,192.168.0.2";
QDialog *dialog = new QDialog(this);
QVBoxLayout *layout = new QVBoxLayout;
QHBoxLayout *titleLayout = new QHBoxLayout;
QLabel *titleLabel = new QLabel("机器人列表", dialog);
// 新布局当中添加标题
/**
* @bug layout
*/
titleLayout->addWidget(titleLabel);
layout->addLayout(titleLayout);
// 新布局当中添加列表
QTableWidget *tableWidget = new QTableWidget(dialog);
QVBoxLayout *robotListLayout = new QVBoxLayout;
robotListLayout->addWidget(tableWidget);
layout->addLayout(robotListLayout);
// 读取机器人的数据格式
/**
* @bug
*/
tableWidget->setRowCount(10);
tableWidget->setColumnCount(2);
tableWidget->setHorizontalHeaderLabels(QStringList() << "名称" << "IP地址");
QTableWidgetItem *nameItem = new QTableWidgetItem("ALice");
QTableWidgetItem *ipAddressItem = new QTableWidgetItem("192.168.0.1");
tableWidget->setItem(0, 0, nameItem);
tableWidget->setItem(0, 1, ipAddressItem);
QTableWidgetItem *nameItem2 = new QTableWidgetItem("Bob");
QTableWidgetItem *ipAddressItem2 = new QTableWidgetItem("192.168.0.2");
tableWidget->setItem(1, 0, nameItem2);
tableWidget->setItem(1, 1, ipAddressItem2);
/* 跳转按钮 */
QPushButton *specified_robot_btn = new QPushButton(dialog); // 新的按钮跟dialog是子属关系
QHBoxLayout *specified_robot_btnLayout = new QHBoxLayout(); // 按钮的布局
specified_robot_btnLayout->addWidget(specified_robot_btn); // 添加按钮到按钮布局当中
layout->addLayout(specified_robot_btnLayout); // 添加按钮布局到对话框布局当中
// connect(specified_robot_btn,&QPushButton::clicked,this,&GuidingUI::on_specifiedrobottab_clicked); // 联系槽函数
dialog->setLayout(layout);
dialog->exec();
}
void GuidingUI::RobotsInfosControl(QPushButton* btnCtr)
{
connect(btnCtr,&QPushButton::clicked,this,&GuidingUI::on_robottab_clicked);
}
void GuidingUI::on_addCasualty_clicked()
{
// QDialog dialog(this);
// dialog.setWindowTitle("添加伤员信息");
// QFormLayout formLayout(&dialog);
// QLineEdit latitudeLineEdit;
// QLineEdit longitudeLineEdit;
// QLineEdit levelLineEdit;
// formLayout.addRow("经度:", &latitudeLineEdit);
// formLayout.addRow("纬度:", &longitudeLineEdit);
// formLayout.addRow("伤情等级:", &levelLineEdit);
// QPushButton addButton("添加", &dialog);
// formLayout.addRow(&addButton);
// // 连接按钮的点击信号到槽函数
// QObject::connect(&addButton, &QPushButton::clicked, [&]() {
// bool ok;
// double latitude = latitudeLineEdit.text().toDouble(&ok);
// if (!ok) {
// qDebug() << "Invalid latitude";
// return;
// }
// double longitude = longitudeLineEdit.text().toDouble(&ok);
// if (!ok) {
// qDebug() << "Invalid longitude";
// return;
// }
// int level = levelLineEdit.text().toInt(&ok);
// if (!ok || level < 1 || level > 3) {
// qDebug() << "Invalid level";
// return;
// }
// // 获取 QML 根对象
// QQuickItem *root = ui->MapDisplayer->rootObject();
// auto labelqml = root->findChild<QObject*>("labelcpp");
// // 调用 QML 中的 addInfo 函数
// QVariant ret;
// QMetaObject::invokeMethod(labelqml, "addInfo", Q_ARG(QVariant, latitude), Q_ARG(QVariant, longitude), Q_ARG(QVariant, level));
// qDebug() << "Added casualty at latitude:" << latitude << " longitude:" << longitude << " level:" << level;
// dialog.accept();
// });
// if (dialog.exec() == QDialog::Accepted) {
// // 如果对话框被接受,则在这里处理添加操作
// }
}
void GuidingUI::on_showInjuryInfo_clicked()
{
InjuryAnalysisUI* InjuryAnalysisDialog = new InjuryAnalysisUI;
InjuryAnalysisDialog->show();
}

@ -0,0 +1,50 @@
#ifndef GUIDINGUI_H
#define GUIDINGUI_H
#include <QMainWindow>
#include <QPushButton>
#include <QLabel>
#include <QDialog>
#include <QLineEdit>
#include <string>
#include <QTableWidget>
#include <cstring>
#include <QQuickItem>
#include <QFormLayout>
#include <QStackedWidget>
QT_BEGIN_NAMESPACE
namespace Ui {
class GuidingUI;
}
QT_END_NAMESPACE
class GuidingUI : public QMainWindow
{
Q_OBJECT
public:
GuidingUI(QWidget *parent = nullptr);
~GuidingUI();
// 功能界面地图显示控制
void MapDisplayControl(QPushButton*,QWidget*,QGridLayout*);
// 添加机器人按钮槽函数
void on_addrobot_clicked();
// 功能界面添加机器人按钮控制
void AddRobotControl(QPushButton*);
// 机器人列表显示按钮槽函数
void on_robottab_clicked();
// 功能界面显示已配置机器人列表按钮控制
void RobotsInfosControl(QPushButton*);
// 机器人列表当中的切换到指定机器人页面槽函数
void on_specifiedrobottab_clicked();
private slots:
void on_addCasualty_clicked();
void on_showInjuryInfo_clicked();
private:
Ui::GuidingUI *ui;
};
#endif // GUIDINGUI_H

@ -0,0 +1,420 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GuidingUI</class>
<widget class="QMainWindow" name="GuidingUI">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1000</width>
<height>663</height>
</rect>
</property>
<property name="windowTitle">
<string>伤情态势感知分析系统</string>
</property>
<property name="toolTipDuration">
<number>0</number>
</property>
<property name="styleSheet">
<string notr="true">#centralwidget{
background-color: rgb(15, 18, 34);
}
</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="styleSheet">
<string notr="true">QLabel {
background-color: rgba(15, 28, 34, 0);
color: white; /* 设置字体颜色为白色 */
border: none;
padding: 10px 20px; /* 设置内边距 */
border-radius: 5px; /* 设置按钮圆角 */
font-size: 30px; /* 设置文字大小 */
font-weight: bold; /*设置字体加粗*/
text-align: right; /* 设置字体居左对齐 */
}
</string>
</property>
<property name="text">
<string>ACM</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>30</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>20</number>
</property>
<property name="spacing">
<number>50</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="MapDisplayer" native="true"/>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/logo_backgroundless.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QWidget" name="widget" native="true">
<property name="styleSheet">
<string notr="true">QPushButton {
background-color: rgba(15, 28, 34, 0);
color: rgb(255, 255, 255);
border: none;
padding: 10px 20px; /* 设置内边距 */
border-radius: 5px; /* 设置按钮圆角 */
font-size: 14px; /* 设置文字大小 */
text-align: right; /* 设置字体向右对齐 */
}
QPushButton:hover {
background-color: #0364FF; /* 设置鼠标悬停时按钮背景色 */
}
QPushButton:pressed {
background-color: #398439; /* 设置按钮被按下时背景色 */
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="robottab">
<property name="text">
<string>机器人列表</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/tab.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="robotlocation">
<property name="text">
<string>机器人位置显示</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/location.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="addrobot">
<property name="styleSheet">
<string notr="true">#QPushButton{
background-color: rgba(255, 255, 255, 0);
color: rgb(255, 255, 255);
border: none;
}</string>
</property>
<property name="text">
<string>添加机器人</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/robotbtn.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="mapbutton">
<property name="text">
<string>显示地图</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/mapbtn.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="addUAV">
<property name="text">
<string>添加无人机</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/UAV.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="UAVtab">
<property name="text">
<string>无人机列表</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/tab.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPushButton" name="casualtycondition">
<property name="text">
<string>显示伤情</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/health.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPushButton" name="UAVlocation">
<property name="text">
<string>无人机位置显示</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/location.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPushButton" name="casualtyList">
<property name="styleSheet">
<string notr="true">#QPushButton{
background-color: rgba(255, 255, 255, 0);
color: rgb(255, 255, 255);
border: none;
}</string>
</property>
<property name="text">
<string>伤员列表</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="styleSheet">
<string notr="true">border-image: url(:/image/res/image/soldier.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QPushButton" name="showInjuryInfo">
<property name="text">
<string>展示信息</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="styleSheet">
<string notr="true">
border-image: url(:/image/res/image/infomation.svg);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1000</width>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menu">
<property name="title">
<string>功能界面</string>
</property>
</widget>
<addaction name="menu"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="action">
<property name="text">
<string>添加机器人</string>
</property>
</action>
<action name="action_3">
<property name="text">
<string>显示机器人</string>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;显示机器人&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</action>
<action name="action_4">
<property name="text">
<string>伤员</string>
</property>
</action>
<action name="action_5">
<property name="text">
<string>加载地图</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,55 @@
#include "injurydisiplayui.h"
#include "ui_injurydisiplayui.h"
#include "InjuryDatabase.h"
#include "guidingui.h"
#include <QWebEngineView>
#include <QString>
#include <QVBoxLayout>
#include <QDir>
#include <QUrl>
#include <QWebEnginePage>
InjuryDisiplayUI::InjuryDisiplayUI(QWidget *parent)
: QDialog(parent)
, ui(new Ui::InjuryDisiplayUI)
{
ui->setupUi(this);
// 创建QWebEngineView实例
QWebEngineView *view = new QWebEngineView(this);
// 设置HTML文件的路径这里使用资源文件系统
QUrl url = QUrl("qrc:/html/res/html/map.html");
view->load(url);
// 连接loadFinished信号来确认页面是否加载成功并在加载成功后调用addMarker函数
connect(view, &QWebEngineView::loadFinished, [view]() {
// 假设我们要添加的坐标和等级
QList<Injury> result;
InjuryDatabase injuryinfo;
injuryinfo.select_all(result);
for(int i=0;i<result.length();i++)
{
double latitude = result[i].lat;
double longitude = result[i].lon;
int level = result[i].rank;
// 调用JavaScript函数传递参数
view->page()->runJavaScript(QString("addMarker(%1, %2, %3)").arg(latitude).arg(longitude).arg(level), [](const QVariant &result) {
// 这里可以处理JavaScript函数执行后的结果
});
}
});
// 创建布局并添加QWebEngineView
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(view);
// 设置布局
setLayout(layout);
}
InjuryDisiplayUI::~InjuryDisiplayUI()
{
delete ui;
}

@ -0,0 +1,24 @@
#ifndef INJURYDISIPLAYUI_H
#define INJURYDISIPLAYUI_H
#include <QDialog>
#include <QWebEngineView>
#include <QtWebChannel>
namespace Ui {
class InjuryDisiplayUI;
}
class InjuryDisiplayUI : public QDialog
{
Q_OBJECT
public:
explicit InjuryDisiplayUI(QWidget *parent = nullptr);
~InjuryDisiplayUI();
private:
Ui::InjuryDisiplayUI *ui;
};
#endif // INJURYDISIPLAYUI_H

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InjuryDisiplayUI</class>
<widget class="QDialog" name="InjuryDisiplayUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1205</width>
<height>710</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,26 @@
#include "guidingui.h"
#include "InjuryDatabase.h"
#include "DogDatabase.h"
#include "UAVDatabase.h"
#include <QApplication>
#include <QtSql>
#include <QSqlDatabase>
#include <QIcon>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//设置窗口图标
QIcon icon(":/image/res/image/logo_backgroundless.png");
a.setWindowIcon(icon);
GuidingUI w;
w.show();
QStringList lis= QSqlDatabase::drivers();
for (int i=0;i<lis.length();i++) {
qDebug() <<"dri:"<<lis[i];
}
return a.exec();
}

@ -0,0 +1,37 @@
<RCC>
<qresource prefix="/image">
<file>res/image/health.png</file>
<file>res/image/health.png.svg</file>
<file>res/image/health.svg</file>
<file>res/image/info.png</file>
<file>res/image/infomation.svg</file>
<file>res/image/location.png</file>
<file>res/image/location.svg</file>
<file>res/image/logo.png</file>
<file>res/image/logo_backgroundless.png</file>
<file>res/image/map.png</file>
<file>res/image/map.svg</file>
<file>res/image/MapBackGround.png</file>
<file>res/image/mapbtn.svg</file>
<file>res/image/robot.png</file>
<file>res/image/robotbtn.svg</file>
<file>res/image/soldier.png</file>
<file>res/image/soldier.svg</file>
<file>res/image/tab.png</file>
<file>res/image/tab.svg</file>
<file>res/image/uav.png</file>
<file>res/image/UAV.svg</file>
</qresource>
<qresource prefix="/qml">
<file>res/qml/MAP.qml</file>
<file>res/qml/MAP2.qml</file>
</qresource>
<qresource prefix="/html">
<file>res/html/map.html</file>
</qresource>
<qresource prefix="/icon">
<file>res/icon/green.png</file>
<file>res/icon/red.png</file>
<file>res/icon/yellow.png</file>
</qresource>
</RCC>

@ -0,0 +1,207 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>伤情态势展示系统</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<style>
html, body, #container {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
h1 {
font-size: 18px;
margin: 0;
color: rgb(180, 180, 190);
}
h3 {
font-size: 12px;
font-weight: normal;
margin-top: 5px;
color: rgb(150,150,150);
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"] {
width: 200px;
margin-bottom: 10px;
}
button {
padding: 5px 10px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
#markerForm {
position: absolute;
top: 10px;
left: 10px;
z-index: 1000; /* 确保表单在地图上层 */
background-color: white;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
#message {
position: absolute;
top: 80px;
left: 10px;
z-index: 1000; /* 确保消息在地图上层 */
color: red;
}
.amap-logo {
display: none !important;
}
.amap-copyright {
display: none !important;
}
</style>
</head>
<body>
<div id="container"></div>
<!-- <form id="markerForm">
<div>
<label for="latitude">Latitude:</label>
<input type="text" id="latitude" placeholder="Enter latitude">
</div>
<div>
<label for="longitude">Longitude:</label>
<input type="text" id="longitude" placeholder="Enter longitude">
</div>
<div>
<label for="level">Level (0-2):</label>
<input type="text" id="level" placeholder="Enter level">
</div>
<button type="submit">Add Marker</button>
</form>
<div id="message"></div>-->
<script src="https://webapi.amap.com/maps?v=2.0&key=b7b2d38034862db152260c9dd73689b2"></script>
<script src="https://webapi.amap.com/loca?v=2.0.0&key=b7b2d38034862db152260c9dd73689b2"></script>
<script>
var map = new AMap.Map('container', {
resizeEnable: true,
zoom: 16,
center: [113.045292, 28.257748],
pitch: 0,
showLabel: true,
mapStyle: 'amap://styles/normal',
viewMode: '3D',
layers: [
new AMap.TileLayer.Satellite()
]
});
// 添加 3D 罗盘
AMap.plugin([
'AMap.ControlBar',
], function(){
// 添加 3D 罗盘控制
map.addControl(new AMap.ControlBar({
position: {
right: '20px',
top: '20px'
},
showControlButton: true, // 是否显示倾斜、旋转按钮。默认为 true
}));
});
//用来添加伤员信息点
function addMarker(latitude, longitude, level) {
var color;
var borderColor = '#333'; // 边框颜色
var radius = 12; // 圆形标记的半径
// 根据等级设置颜色
switch (level) {
case 0:
color = 'rgba(0, 255, 0, 0.7)'; // 绿色70%不透明度
break;
case 1:
color = 'rgba(255, 255, 0, 0.7)'; // 黄色70%不透明度
break;
case 2:
color = 'rgba(255, 0, 0, 0.7)'; // 红色70%不透明度
break;
default:
color = 'rgba(0, 255, 0, 0.7)'; // 默认为绿色70%不透明度
break;
}
// 创建自定义标记内容
var content = '<div style="border-radius: ' + radius + 'px; width: ' + radius * 2 + 'px; height: ' + radius * 2 + 'px; background-color: ' + color + '; border: 2px solid ' + borderColor + ';"></div>';
var marker = new AMap.Marker({
position: [longitude, latitude],
content: content, // 使用自定义内容
offset: new AMap.Pixel(-radius, -radius) // 偏移量,确保标记中心对齐
});
marker.setMap(map);
}
var options = {
'showButton': true,//是否显示定位按钮
'position': 'LB',//定位按钮的位置
/* LT LB RT RB */
'offset': [10, 20],//定位按钮距离对应角落的距离
'showMarker': true,//是否显示定位点
'markerOptions':{//自定义定位点样式同Marker的Options
'offset': new AMap.Pixel(-18, -36),
'content':'<img src="https://a.amap.com/jsapi_demos/static/resource/img/user.png" style="width:36px;height:36px"/>'
},
'showCircle': true,//是否显示定位精度圈
'circleOptions': {//定位精度圈的样式
'strokeColor': '#0093FF',
'noSelect': true,
'strokeOpacity': 0.5,
'strokeWeight': 1,
'fillColor': '#02B0FF',
'fillOpacity': 0.25
}
}
AMap.plugin(["AMap.Geolocation"], function() {
var geolocation = new AMap.Geolocation(options);
map.addControl(geolocation);
geolocation.getCurrentPosition()
});
</script>
<script>
document.getElementById('markerForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent form submission
// Get input values
var latitude = parseFloat(document.getElementById('latitude').value);
var longitude = parseFloat(document.getElementById('longitude').value);
var level = parseInt(document.getElementById('level').value);
// Check if latitude and longitude are valid numbers
if (isNaN(latitude) || isNaN(longitude)) {
document.getElementById('message').innerHTML = 'Latitude and longitude must be valid numbers.';
return;
}
// Check if level is within range
if (level < 0 || level > 2 || isNaN(level)) {
document.getElementById('message').innerHTML = 'Level must be a number between 0 and 2.';
return;
}
// Call addMarker function with input values
addMarker(latitude, longitude, level);
// Clear input fields and message
document.getElementById('latitude').value = '';
document.getElementById('longitude').value = '';
document.getElementById('level').value = '';
document.getElementById('message').innerHTML = '';
});
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-458 -94)"><path d="M548 119 535 119 535 118C535 116.895 534.105 116 533 116 531.895 116 531 116.895 531 118L531 119 518 119C516.895 119 516 119.895 516 121 516 122.105 516.895 123 518 123L531 123 531 126 530 126C529.448 126 529 126.448 529 127L529 129.193 524.631 128.493C512.289 126.506 499.71 126.506 487.368 128.493L483 129.193 483 127C483 126.448 482.552 126 482 126L481 126 481 123 494 123C495.105 123 496 122.105 496 121 496 119.895 495.105 119 494 119L481 119 481 118C481 116.895 480.105 116 479 116 477.895 116 477 116.895 477 118L477 119 464 119C462.895 119 462 119.895 462 121 462 122.105 462.895 123 464 123L477 123 477 126 476 126C475.448 126 475 126.448 475 127L475 130.48 472.812 130.833C471.004 131.107 469.76 132.795 470.034 134.603 470.257 136.071 471.431 137.212 472.905 137.393L478.966 138.193C481.91 138.583 484.809 139.263 487.619 140.224L488.855 140.647C490.007 141.041 491.14 141.481 492.255 141.968L486 157.615 486 168 490 168 490 158.385 495.861 143.732 496.261 143.943C497.563 144.637 499.016 145 500.492 145L503 145 503 150 500 150C498.895 150 498 150.895 498 152L498 160C498 161.105 498.895 162 500 162L512 162C513.105 162 514 161.105 514 160L514 152C514 150.895 513.105 150 512 150L509 150 509 145 511.507 145C512.984 145.001 514.438 144.637 515.742 143.943L516.142 143.731 522 158.385 522 168 526 168 526 157.615 519.742 141.97C520.857 141.485 521.991 141.045 523.142 140.65L524.378 140.227C527.189 139.268 530.089 138.589 533.034 138.2L539.094 137.4C540.909 137.177 542.2 135.526 541.977 133.711 541.797 132.236 540.656 131.063 539.187 130.84L537 130.48 537 127C537 126.448 536.552 126 536 126L535 126 535 123 548 123C549.105 123 550 122.105 550 121 550 119.895 549.105 119 548 119ZM506 158.5C504.619 158.5 503.5 157.381 503.5 156 503.5 154.619 504.619 153.5 506 153.5 507.381 153.5 508.5 154.619 508.5 156 508.5 157.381 507.381 158.5 506 158.5Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-592 -312)"><path d="M640.28 392C644.665 388.538 648.848 384.829 652.81 380.89 658.553 375.419 663.631 369.29 667.94 362.63 671.94 356.19 675.76 347.83 673.13 340.19 671 333.87 665.09 328.5 658.3 327.85 649.72 327 643.51 334.26 640 341.21 636.79 334.85 631.48 328.29 623.81 327.81 617 327.39 610.66 332.18 607.73 338.13 604.06 345.6 607.05 354 610.91 360.71 614.91 367.71 620.23 373.86 625.85 379.55 630.28 384.083 635.007 388.315 640 392.22ZM624 358 627 349 628.78 343.65C629.24 342.26 629.95 340.4 631.87 341.2 633.03 341.69 633.1 342.89 633.3 343.94L634.13 348.37 636.53 361.17 638.12 369.67 643.92 354.33 645.2 350.95C645.57 349.95 645.95 348.95 647.2 348.84 648.79 348.68 649.26 350.04 649.61 351.24L650.84 355.46 653.28 363.85 655.69 361.2C656.461 360.191 657.328 359.26 658.28 358.42 659.28 357.72 661.13 358.04 662.28 358.04L666 358.04C665.26 359.37 664.44 360.71 663.55 362.04L660.3 362.04C658.17 364.39 656.13 366.89 653.87 369.12 653.161 369.967 651.9 370.079 651.053 369.37 650.886 369.231 650.743 369.065 650.63 368.88 650.413 368.45 650.255 367.992 650.16 367.52L648.49 361.81 647.13 357.13C644.58 363.86 642.13 370.6 639.5 377.3 639.353 377.846 639.034 378.33 638.59 378.68 637.68 379.305 636.435 379.074 635.809 378.164 635.649 377.931 635.541 377.668 635.49 377.39 635.26 376.47 635.14 375.51 634.96 374.59L632.43 361.09 630.54 351 627.72 359.47C627.29 360.73 626.95 361.96 625.33 362.04 623.86 362.11 622.38 362.04 620.92 362.04L616.42 362.04C615.54 360.71 614.71 359.37 613.97 358.04Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-592 -312)"><path d="M640.28 392C644.665 388.538 648.848 384.829 652.81 380.89 658.553 375.419 663.631 369.29 667.94 362.63 671.94 356.19 675.76 347.83 673.13 340.19 671 333.87 665.09 328.5 658.3 327.85 649.72 327 643.51 334.26 640 341.21 636.79 334.85 631.48 328.29 623.81 327.81 617 327.39 610.66 332.18 607.73 338.13 604.06 345.6 607.05 354 610.91 360.71 614.91 367.71 620.23 373.86 625.85 379.55 630.28 384.083 635.007 388.315 640 392.22ZM624 358 627 349 628.78 343.65C629.24 342.26 629.95 340.4 631.87 341.2 633.03 341.69 633.1 342.89 633.3 343.94L634.13 348.37 636.53 361.17 638.12 369.67 643.92 354.33 645.2 350.95C645.57 349.95 645.95 348.95 647.2 348.84 648.79 348.68 649.26 350.04 649.61 351.24L650.84 355.46 653.28 363.85 655.69 361.2C656.461 360.191 657.328 359.26 658.28 358.42 659.28 357.72 661.13 358.04 662.28 358.04L666 358.04C665.26 359.37 664.44 360.71 663.55 362.04L660.3 362.04C658.17 364.39 656.13 366.89 653.87 369.12 653.161 369.967 651.9 370.079 651.053 369.37 650.886 369.231 650.743 369.065 650.63 368.88 650.413 368.45 650.255 367.992 650.16 367.52L648.49 361.81 647.13 357.13C644.58 363.86 642.13 370.6 639.5 377.3 639.353 377.846 639.034 378.33 638.59 378.68 637.68 379.305 636.435 379.074 635.809 378.164 635.649 377.931 635.541 377.668 635.49 377.39 635.26 376.47 635.14 375.51 634.96 374.59L632.43 361.09 630.54 351 627.72 359.47C627.29 360.73 626.95 361.96 625.33 362.04 623.86 362.11 622.38 362.04 620.92 362.04L616.42 362.04C615.54 360.71 614.71 359.37 613.97 358.04Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-800 -345)"><path d="M876 419C876 420.1 875.1 421 874 421 872.9 421 872 420.1 872 419L872 371 876 371 876 419ZM822 421C820.9 421 820 420.1 820 419L820 365 866 365 866 419C866 419.7 866.1 420.4 866.3 421L822 421ZM872 365 872 359 814 359 814 419C814 423.4 817.6 427 822 427L874 427C878.4 427 882 423.4 882 419L882 365 872 365Z" fill="#FFFFFF"/><path d="M824 371 862 371 862 375 824 375Z" fill="#FFFFFF"/><path d="M845 379 862 379 862 383 845 383Z" fill="#FFFFFF"/><path d="M845 387 862 387 862 391 845 391Z" fill="#FFFFFF"/><path d="M824 379 841 379 841 391 824 391Z" fill="#FFFFFF"/><path d="M824 395 862 395 862 399 824 399Z" fill="#FFFFFF"/><path d="M845 403 862 403 862 415 845 415Z" fill="#FFFFFF"/><path d="M824 403 841 403 841 407 824 407Z" fill="#FFFFFF"/><path d="M824 411 841 411 841 415 824 415Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 1001 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-1037 -108)"><path d="M1085 152C1080 152 1076 148 1076 143 1076 138 1080 134 1085 134 1090 134 1094 138 1094 143 1094 148 1090 152 1085 152ZM1085 122C1078.1 122 1071.6 125.4 1067.7 131.2 1063.8 136.9 1063 144.2 1065.5 150.7L1075 171.7 1083.2 188.9C1083.5 189.6 1084.2 190 1085 190 1085.8 190 1086.5 189.6 1086.8 188.9L1095 171.7 1104.5 150.7C1107 144.2 1106.2 136.9 1102.3 131.2 1098.4 125.4 1091.9 122 1085 122Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-731 -108)"><path d="M799 138.2C796.6 138.2 794.6 136.2 794.7 133.7 794.7 131.3 796.7 129.3 799.1 129.3 801.5 129.3 803.5 131.3 803.5 133.7 803.5 134.9 803 136 802.2 136.8 801.3 137.7 800.2 138.2 799 138.2ZM794.7 124.3C792.5 125.1 790.8 126.8 789.7 128.8 788.3 131.5 788.1 134.6 789.2 137.4L794 147.8 797.2 154.4C797.5 155.1 798.2 155.5 799 155.5 799.8 155.5 800.5 155.1 800.8 154.4L804 147.8 808.8 137.5C809.3 136.3 809.5 135 809.5 133.7 809.5 126.7 802.3 121.4 794.7 124.3Z" fill="#FFFFFF"/><path d="M777 180.8 761 172.8 761 140.2 777 148.2 777 180.8ZM757 172.8 745 178.8 745 146.2 757 140.2 757 172.8ZM812.4 139.2 812.4 139.2 809.9 144.6 813 146.2 813 178.8 801 172.8 801 159.5 797 159.5 797 172.8 781 180.8 781 148.2 788.1 144.6 785.6 139.2 779 142.5 759 132.5 739 142.5 739 188.5 759 178.5 779 188.5 799 178.5 819 188.5 819 142.5 812.4 139.2Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-731 -108)"><path d="M799 138.2C796.6 138.2 794.6 136.2 794.7 133.7 794.7 131.3 796.7 129.3 799.1 129.3 801.5 129.3 803.5 131.3 803.5 133.7 803.5 134.9 803 136 802.2 136.8 801.3 137.7 800.2 138.2 799 138.2ZM794.7 124.3C792.5 125.1 790.8 126.8 789.7 128.8 788.3 131.5 788.1 134.6 789.2 137.4L794 147.8 797.2 154.4C797.5 155.1 798.2 155.5 799 155.5 799.8 155.5 800.5 155.1 800.8 154.4L804 147.8 808.8 137.5C809.3 136.3 809.5 135 809.5 133.7 809.5 126.7 802.3 121.4 794.7 124.3Z" fill="#FFFFFF"/><path d="M777 180.8 761 172.8 761 140.2 777 148.2 777 180.8ZM757 172.8 745 178.8 745 146.2 757 140.2 757 172.8ZM812.4 139.2 812.4 139.2 809.9 144.6 813 146.2 813 178.8 801 172.8 801 159.5 797 159.5 797 172.8 781 180.8 781 148.2 788.1 144.6 785.6 139.2 779 142.5 759 132.5 739 142.5 739 188.5 759 178.5 779 188.5 799 178.5 819 188.5 819 142.5 812.4 139.2Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-592 -108)"><path d="M656.42 180 623.42 180C619.278 180 615.92 183.358 615.92 187.5 615.92 191.642 619.278 195 623.42 195L656.42 195C660.562 195 663.92 191.642 663.92 187.5 663.92 183.358 660.562 180 656.42 180ZM625.42 190.5C623.763 190.5 622.42 189.157 622.42 187.5 622.42 185.843 623.763 184.5 625.42 184.5 627.077 184.5 628.42 185.843 628.42 187.5 628.42 189.157 627.077 190.5 625.42 190.5ZM639.92 190.5C638.263 190.5 636.92 189.157 636.92 187.5 636.92 185.843 638.263 184.5 639.92 184.5 641.577 184.5 642.92 185.843 642.92 187.5 642.92 189.157 641.577 190.5 639.92 190.5ZM654.42 190.5C652.763 190.5 651.42 189.157 651.42 187.5 651.42 185.843 652.763 184.5 654.42 184.5 656.077 184.5 657.42 185.843 657.42 187.5 657.42 189.157 656.077 190.5 654.42 190.5Z" fill="#FFFFFF"/><path d="M646.83 136C646.83 136.828 646.158 137.5 645.33 137.5 644.502 137.5 643.83 136.828 643.83 136 643.83 135.172 644.502 134.5 645.33 134.5 646.158 134.5 646.83 135.172 646.83 136Z" fill="#FFFFFF"/><path d="M648.61 126 642 126 642 121.45C643.913 120.345 644.569 117.899 643.464 115.986 642.359 114.073 639.913 113.417 638 114.522 636.087 115.626 635.431 118.073 636.536 119.986 636.887 120.594 637.392 121.099 638 121.45L638 126 631.39 126C628.968 126.006 627.005 127.968 627 130.39L627 141.61C627.005 144.032 628.968 145.995 631.39 146L648.61 146C651.032 145.995 652.995 144.032 653 141.61L653 130.39C652.995 127.968 651.032 126.006 648.61 126ZM635 139C633.343 139 632 137.657 632 136 632 134.343 633.343 133 635 133 636.657 133 638 134.343 638 136 638 137.657 636.657 139 635 139ZM645 139C643.343 139 642 137.657 642 136 642 134.343 643.343 133 645 133 646.657 133 648 134.343 648 136 648 137.657 646.657 139 645 139Z" fill="#FFFFFF"/><path d="M636.83 136C636.83 136.828 636.158 137.5 635.33 137.5 634.502 137.5 633.83 136.828 633.83 136 633.83 135.172 634.502 134.5 635.33 134.5 636.158 134.5 636.83 135.172 636.83 136Z" fill="#FFFFFF"/><path d="M666 166.82 666 158.49C666 156.01 663.99 154 661.51 154L656 154 656 149 624 149 624 155 616.49 155C616.219 155 616 154.781 616 154.51L616 146.22C619.438 145.205 621.401 141.595 620.386 138.158 620.114 137.236 619.641 136.386 619 135.67L616 138.33C616.42 138.786 616.658 139.38 616.67 140 616.662 141.381 615.537 142.494 614.156 142.486 612.776 142.479 611.663 141.354 611.67 139.973 611.673 139.376 611.89 138.801 612.28 138.35L609.28 135.72C606.923 138.428 607.208 142.534 609.915 144.89 610.528 145.424 611.235 145.837 612 146.11L612 154.51C612 156.99 614.01 159 616.49 159L624 159 624 177 656 177 656 158 661.51 158C661.781 158 662 158.219 662 158.49L662 166.82C658.584 167.925 656.711 171.59 657.816 175.005 658.093 175.86 658.544 176.648 659.14 177.32L662.14 174.66C661.726 174.206 661.498 173.614 661.5 173 661.501 171.619 662.621 170.501 664.002 170.502 665.383 170.503 666.501 171.624 666.5 173.004 666.5 173.61 666.279 174.195 665.88 174.65L668.88 177.28C671.246 174.588 670.982 170.487 668.289 168.121 667.623 167.535 666.844 167.093 666 166.82ZM652 163 649.22 163C649.123 163.017 649.031 163.055 648.95 163.11L645.89 166.24 643.56 160.72 639.21 169.72 636.16 158 633.81 163 629 163 629 161 632.54 161 636.7 152.15 639.78 163.93 643.69 155.93 646.57 162.75 647.57 161.75C648.009 161.306 648.596 161.039 649.22 161L652 161Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-1020 -204)"><path d="M1040.71 261.479C1038.45 263.338 1037.1 266.077 1037 269L1037.01 286.57 1037.9 287.163C1042.63 290.317 1054.73 291.938 1067 292.045L1067 263.306 1050.01 255.962C1046.66 257.341 1043.53 259.199 1040.71 261.479ZM1052.92 263C1049.5 264.464 1046.19 266.168 1043.02 268.1L1040.99 264.65C1044.3 262.637 1047.75 260.86 1051.31 259.333Z" fill="#FFFFFF"/><path d="M1084 233.05C1085.78 234.572 1088.39 234.577 1090.17 233.06 1088.13 229.44 1087.76 228.38 1087.26 223.91L1087.26 221.5C1087.26 215 1079.26 206.25 1068.26 206.25L1067.74 206.25C1056.74 206.25 1048.74 215 1048.74 221.5L1048.74 223.91C1048.46 230 1045.83 233.07 1045.83 233.07 1047.61 234.585 1050.22 234.585 1052 233.07L1052 233.57C1051.95 234.551 1051.46 235.457 1050.67 236.037 1048.75 237.583 1048.45 240.389 1050 242.305 1050.4 242.806 1050.91 243.214 1051.49 243.5 1051.17 244.12 1051.01 244.805 1051 245.5 1051 247.984 1053.02 249.998 1055.5 250 1056.32 249.999 1057.12 249.771 1057.82 249.342 1057.88 249.386 1057.94 249.424 1057.99 249.468L1057.99 251.722 1056.15 251 1052 254.606 1067 261 1067 255.26 1061.85 253.235C1061.95 252.847 1062 252.448 1062 252.048L1062 251.823C1065.85 253.394 1070.16 253.394 1074.01 251.823L1074.01 252.045C1074.01 252.446 1074.05 252.846 1074.15 253.236L1069 255.257 1069 261 1084 254.609 1079.85 251 1078 251.727 1078 249.475C1078.06 249.428 1078.12 249.388 1078.18 249.341 1078.88 249.771 1079.68 249.999 1080.5 250 1082.99 250 1085 247.985 1085 245.5 1085 244.805 1084.83 244.12 1084.51 243.5 1086.72 242.412 1087.63 239.74 1086.54 237.532 1086.25 236.949 1085.84 236.435 1085.33 236.028 1084.53 235.44 1084.04 234.517 1084 233.521ZM1076.94 230C1077.98 230.002 1079.01 230.173 1080 230.508L1080 237C1080 243.627 1074.63 249 1068 249 1061.37 249 1056 243.627 1056 237L1056 230.514C1056.99 230.176 1058.03 230.002 1059.08 230Z" fill="#FFFFFF"/><path d="M1099 268.962C1098.89 266.053 1097.54 263.329 1095.29 261.479 1092.48 259.199 1089.35 257.341 1085.99 255.964L1069 263.307 1069 292.054C1081.56 291.994 1093.88 290.344 1098.2 287.104L1099 286.504ZM1092.85 268.1C1089.67 266.168 1086.37 264.464 1082.95 263L1084.56 259.336C1088.12 260.862 1091.57 262.638 1094.88 264.65Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

@ -0,0 +1 @@
<svg width="96" height="96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-902 -108)"><path d="M984 146 964 146 964 134 984 134 984 146ZM984 162 964 162 964 150 984 150 984 162ZM984 178 964 178 964 166 984 166 984 178ZM940 178 940 166 960 166 960 178 940 178ZM916 178 916 166 936 166 936 178 916 178ZM916 150 936 150 936 162 916 162 916 150ZM916 134 936 134 936 146 916 146 916 134ZM960 150 960 162 940 162 940 150 960 150ZM960 134 960 146 940 146 940 134 960 134ZM910 128 910 184 990 184 990 128 910 128Z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 708 B

@ -0,0 +1,154 @@
import QtQuick
import QtLocation
import QtPositioning
import QtQuick.Controls
import QtLocation 5.15
import QtPositioning 5.15
Rectangle {
width: parent
height: parent
visible: true
PositionSource {
id: positionSource
active: true //
preferredPositioningMethods: PositionSource.AllPositioningMethods
}
Control{
id:labelcpp
objectName: 'labelcpp'
font.pointSize: 40
// property real latitudeSave: 28.2312227
// property real longitudeSave: 112.9334574
//cpp
//getText setCoordinate
function getText()
{
return map.center + " zoom " + map.zoomLevel.toFixed(3)
+ " min " + map.minimumZoomLevel + " max " + map.maximumZoomLevel
}
function setCoordinate(latitude,longitude)
{
// latitudeSave = latitude
// longitudeSave = longitude
map.center.latitude = latitude
map.center.longitude = longitude
map.update()
console.log("latitude="+latitude+" longitude="+longitude);
console.log(QtPositioning.position.coordinate);
}
function addInfo(latitude, longitude, level) {
var color = "#00FF00"; //
if (level === 2) {
color = "#FFFF00";
} else if (level === 3) {
color = "#FF0000";
}
// MapCircle
var newCircle = mapPlugin.createMapItem("MapCircle", {
"id":newCircle,
"center": QtPositioning.coordinate(latitude, longitude),
"radius": 50,
"border.width": 5,
"color": color
});
//
map.addMapItem(newCircle);
}
}
Plugin {
id: mapPlugin
name: "osm"
}
Map {
id: map
anchors.fill: parent
plugin: mapPlugin
center: positionSource.position.coordinate
zoomLevel: 15
activeMapType: map.supportedMapTypes[1]
copyrightsVisible: false
// MapType{
// id: mapType
// style:MapType.SatelliteMapDay
// }
PositionSource {
id: posSource
active: true
onPositionChanged: {
map.center = position.coordinate //
positionSource.active = true //
}
preferredPositioningMethods: PositionSource.AllPositioningMethods
}
PinchHandler {
id: pinch
target: null
onActiveChanged: if (active) {
map.startCentroid = map.toCoordinate(pinch.centroid.position, false)
}
onScaleChanged: (delta) => {
map.zoomLevel += Math.log2(delta)
map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
}
onRotationChanged: (delta) => {
map.bearing -= delta
map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
}
grabPermissions: PointerHandler.TakeOverForbidden
}
WheelHandler {
id: wheel
// workaround for QTBUG-87646 / QTBUG-112394 / QTBUG-112432:
// Magic Mouse pretends to be a trackpad but doesn't work with PinchHandler
// and we don't yet distinguish mice and trackpads on Wayland either
acceptedDevices: Qt.platform.pluginName === "cocoa" || Qt.platform.pluginName === "wayland"
? PointerDevice.Mouse | PointerDevice.TouchPad
: PointerDevice.Mouse
rotationScale: 1/120
property: "zoomLevel"
}
DragHandler {
id: drag
target: null
onTranslationChanged: (delta) => map.pan(-delta.x, -delta.y)
}
//
Shortcut {
enabled: map.zoomLevel < map.maximumZoomLevel
sequence: StandardKey.ZoomIn
onActivated: map.zoomLevel = Math.round(map.zoomLevel + 1)
}
Shortcut {
enabled: map.zoomLevel > map.minimumZoomLevel
sequence: StandardKey.ZoomOut
onActivated: map.zoomLevel = Math.round(map.zoomLevel - 1)
}
Component.onCompleted: {
positionSource.active = true
map.addMapItem(circle)
}
}
MapCircle {
id: circle
center: QtPositioning.coordinate(labelcpp.latitudeSave,labelcpp.longitudeSave)
radius: 10
border.width: 3
color:"black"
//
MouseArea {
anchors.fill: parent
drag.target: parent
}
}
}

@ -0,0 +1,38 @@
import QtQuick
import QtLocation
import QtPositioning
import QtQuick.Controls
import QtLocation 5.15
import QtPositioning 5.15
Window {
id: root
visible: true
width: 640
height: 480
title: qsTr("My Qt Location")
Map {
id: the_map
anchors.fill: parent
minimumZoomLevel: 3
maximumZoomLevel: 16
zoomLevel: 10
center: QtPositioning.coordinate(30.67, 104.06)
plugin: Plugin {
name: "mymap" //"esri" "mapbox" "osm" "here"
// 使parameters
parameters: [
PluginParameter {
name: "mapPath"
value: applicationDirPath+"/dianzi_gaode_ArcgisServerTiles/_alllayers"
},
PluginParameter {
name: "format"
value: "png"
}
]
}
}
}

@ -0,0 +1,375 @@
import QtQuick 2.9
import QtQuick.Window 2.2
import QtLocation 5.6
import QtPositioning 5.6
import QtQuick.Controls 2.4
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0
import QtQuick
import QtLocation
import QtPositioning
import QtQuick.Controls
import QtLocation 5.15
import QtPositioning 5.15
Window {
id: window
visible: true
width: 820
height: 560
color: "#ffffff"
title: qsTr("覆盖规划")
Settings{
id:settings
property var jd : 112.9334574
property var wd : 28.2312227
}
Plugin {
id: mapPlugin
name: "osm" // "mapboxgl", "esri", ...
}
Item {
id: itemMenu
width: 180
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.top: parent.top
anchors.topMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
property var itemList: []
Row {
id: row
y: 10
height: 40
spacing: 10
anchors.right: parent.right
anchors.rightMargin: 10
anchors.left: parent.left
anchors.leftMargin: 10
Label {
id: label
width: 50
height: 40
text: qsTr("经度:")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: 13
}
Rectangle {
id: rectangle
width: 100
height: 40
color: "#ffffff"
border.color: "#b0b8b4"
border.width: 2
TextInput {
id: textInput_JD
height: 20
text: settings.jd
clip: true
anchors.rightMargin: 5
anchors.leftMargin: 5
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.left: parent.left
font.pointSize: 12
}
}
}
Row {
id: row1
x: 7
y: 60
height: 40
anchors.left: parent.left
anchors.leftMargin: 10
Label {
id: label1
width: 50
height: 40
text: qsTr("纬度:")
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pointSize: 13
}
Rectangle {
id: rectangle1
width: 100
height: 40
color: "#ffffff"
border.color: "#b0b8b4"
TextInput {
id: textInput_WD
height: 20
text: settings.wd
cursorVisible: true
clip: true
anchors.left: parent.left
anchors.leftMargin: 5
font.pointSize: 12
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: 5
}
border.width: 2
}
anchors.right: parent.right
spacing: 10
anchors.rightMargin: 10
}
Row {
id: row2
y: 110
height: 40
anchors.left: parent.left
anchors.leftMargin: 10
Label {
id: label2
width: 50
height: 40
text: qsTr("半径:")
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pointSize: 13
}
Rectangle {
id: rectangle2
width: 100
height: 40
color: "#ffffff"
border.color: "#b0b8b4"
TextInput {
id: textInput_Distance
height: 20
text: qsTr("")
anchors.left: parent.left
anchors.leftMargin: 5
font.pointSize: 12
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: 5
}
border.width: 2
}
anchors.right: parent.right
spacing: 10
anchors.rightMargin: 10
}
Row {
id: row3
x: -9
y: 160
height: 40
anchors.left: parent.left
anchors.leftMargin: 8
Label {
id: label3
width: 50
height: 40
text: qsTr("颜色:")
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pointSize: 13
}
Rectangle {
id: rectangle_color
width: 100
height: 40
color: "#cc72f462"
border.color: "#b0b8b4"
border.width: 0
MouseArea{
id: mouseArea
anchors.fill: parent
onClicked: colorDialog.open()
}
}
anchors.right: parent.right
spacing: 10
anchors.rightMargin: 12
}
Button {
id: button1
x: 40
y: 215
width: 100
text: qsTr("添加覆盖圈")
onClicked: {
var component = Qt.createComponent("MyCircle.qml")
if(component.status === Component.Ready){
var circle = component.createObject(myMap)
var jd = textInput_JD.text
var wd = textInput_WD.text
circle.myCoordinate = QtPositioning.coordinate(wd, jd)
circle.myColor = rectangle_color.color
circle.distance = textInput_Distance.text
myMap.addMapItemGroup(circle)
itemMenu.itemList.push(circle)
}
}
}
Button {
id: button2
x: 40
y: 265
width: 100
text: qsTr("删除")
onClicked: {
var obj = itemMenu.itemList[itemMenu.itemList.length-1]
myMap.removeMapItemGroup(obj)
itemMenu.itemList.pop()
delete obj
}
}
Button {
id: button3
x: 40
y: 315
width: 100
text: qsTr("清除测距")
onClicked: {
lineObj.path = []
distanceLabel.text = ''
}
}
Text {
id: text1
x: 18
y: 427
text: qsTr("双击左键获取图上位置坐标")
font.pixelSize: 12
}
Text {
id: text2
x: 18
y: 453
text: qsTr("点击鼠标右键进行地图测距")
font.pixelSize: 12
}
Button {
id: button4
x: 40
y: 369
width: 100
text: qsTr("保存中心")
onClicked: {
settings.jd = textInput_JD.text
settings.wd = textInput_WD.text
text_info.text = "地图中心位置已保存"
}
}
Text {
id: text_info
x: 74
y: 482
width: 32
height: 12
color: "#f66060"
text: qsTr("")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 12
}
}
Map {
id:myMap
anchors.leftMargin: 180
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(settings.wd, settings.jd) // Oslo
zoomLevel: 11
property bool measure: false
MouseArea {
id: mouseArea_measure
anchors.fill: parent
acceptedButtons: Qt.RightButton | Qt.LeftButton
hoverEnabled: true
onClicked: {
if(mouse.button === Qt.RightButton){
if(!lineObj.start){
myMap.measure = true
lineObj.path = []
var c = myMap.toCoordinate(Qt.point(mouse.x, mouse.y))
lineObj.addCoordinate(c)
lineObj.start = true
}else{
myMap.measure = false
var c = myMap.toCoordinate(Qt.point(mouse.x, mouse.y))
lineObj.addCoordinate(c)
lineObj.start = false
}
}
}
onPositionChanged:{
if(myMap.measure){
var c = myMap.toCoordinate(Qt.point(mouse.x, mouse.y))
var path = lineObj.path;
path[1] = c;
lineObj.path = path;
distanceLabel.coordinate = c
var dis = c.distanceTo(path[0])
distanceLabel.text =" 距离:"+Math.round(dis)/1000+"千米"
}
}
onDoubleClicked: {
if(mouse.button === Qt.LeftButton){
var c = myMap.toCoordinate(Qt.point(mouse.x, mouse.y))
textInput_JD.text = c.longitude.toFixed(6)
textInput_WD.text = c.latitude.toFixed(6)
}
}
}
MapPolyline {
id:lineObj
line.width: 3
line.color: 'green'
path: []
property bool start: false
}
MapQuickItem{
id:distanceLabel
property string text: ''
sourceItem:Label{
color: "darkturquoise"
font.bold: true
font.pointSize: 15
font.family: "微软雅黑"
text: distanceLabel.text
}
}
}
ColorDialog {
id: colorDialog
options:ColorDialog.ShowAlphaChannel
onAccepted: {
rectangle_color.color = colorDialog.currentColor
}
}
}

@ -0,0 +1,41 @@
// import QtQuick 2.15
// import QtPositioning 5.15
// import QtLocation 5.15
// Rectangle {
// width: 400
// height: 300
// PositionSource {
// id: positionSource
// updateInterval: 1000
// preferredPositioningMethods: PositionSource.AllPositioningMethods
// }
// Plugin {
// id: mapPlugin
// name: "osm"
// }
// Map {
// id: map
// anchors.fill: parent
// plugin: Plugin {
// name: "osm" // 使OpenStreetMap
// }
// center: positionSource.position.coordinate
// zoomLevel: 13
// Component.onCompleted: {
// map.addMapItem(markerComponent)
// }
// }
// Component {
// id: markerComponent
// Rectangle {
// width: 20
// height: 20
// color: "blue"
// radius: 10
// }
// }
// }
Loading…
Cancel
Save