You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
2.7 KiB
C++
113 lines
2.7 KiB
C++
#include "routeanalysisdialog.h"
|
|
#include "ui_routeanalysisdialog.h"
|
|
|
|
RouteAnalysisDialog::RouteAnalysisDialog(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::RouteAnalysisDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
this->resize(900,500);
|
|
this->setWindowTitle("航线分析");
|
|
this->setWindowFlags(Qt::WindowCloseButtonHint); //关闭右上角帮助(?)按钮。
|
|
|
|
ui->FlightDistanceDSpinBox->setSuffix("km");
|
|
ui->FlightSpeedDSpinBox->setSuffix("m/s");
|
|
ui->FlightSpeedDSpinBox->setValue(20);
|
|
|
|
|
|
}
|
|
|
|
RouteAnalysisDialog::~RouteAnalysisDialog()
|
|
{
|
|
delete ui;
|
|
delete chart;
|
|
}
|
|
|
|
void RouteAnalysisDialog::SetRecordset(UGRecordsetPtr res)
|
|
{
|
|
this->res = res;
|
|
}
|
|
|
|
void RouteAnalysisDialog::SetDem(UGDatasetRasterPtr dem)
|
|
{
|
|
this->dem = dem;
|
|
}
|
|
|
|
void RouteAnalysisDialog::InitDialog()
|
|
{
|
|
SetFlightDistance(GetFlightDistance());
|
|
SetFlightTime();
|
|
ShowElevationPlot();
|
|
}
|
|
|
|
double RouteAnalysisDialog::GetFlightDistance()
|
|
{
|
|
UGGeometry* geometry = NULL;
|
|
if(res==NULL) return -1;
|
|
res->MoveFirst();
|
|
res->GetGeometry(geometry);
|
|
return geoComputation.getGeometryLength(geometry);
|
|
}
|
|
|
|
void RouteAnalysisDialog::SetFlightDistance(double dist)
|
|
{
|
|
if(dist<1000)
|
|
{
|
|
ui->FlightDistanceDSpinBox->setSuffix("m");
|
|
ui->FlightDistanceDSpinBox->setValue(dist);
|
|
}
|
|
else
|
|
{
|
|
ui->FlightDistanceDSpinBox->setSuffix("km");
|
|
ui->FlightDistanceDSpinBox->setValue(dist/1000);
|
|
}
|
|
}
|
|
|
|
double RouteAnalysisDialog::GetFlightHeight()
|
|
{
|
|
UGVariant var;
|
|
res->GetFieldValue(Translator::QStr2UGStr(routeGVar.routeFieldsName.RouteHeight),var);
|
|
return var.ToDouble();
|
|
}
|
|
|
|
void RouteAnalysisDialog::SetFlightTime()
|
|
{
|
|
double dist = GetFlightDistance();
|
|
double speed = ui->FlightSpeedDSpinBox->value();
|
|
if(dist<=0 || speed==0) return;
|
|
int time = int(dist/speed);
|
|
int ss = time%60;
|
|
int min = time/60%60;
|
|
int h = time/3600;
|
|
QString strTime = QString::number(h) + "时" + QString::number(min) + "分" + QString::number(ss) + "秒";
|
|
ui->FlightTimeEdit->setText(strTime);
|
|
}
|
|
|
|
void RouteAnalysisDialog::ShowElevationPlot()
|
|
{
|
|
UGGeometry* geometry = NULL;
|
|
res->MoveFirst();
|
|
res->GetGeometry(geometry);
|
|
UGGeoLine* line = (UGGeoLine*)geometry;
|
|
|
|
double alt[128];
|
|
double h = GetFlightHeight();
|
|
for (int i = 0; i < line->GetPointCount(); ++i)
|
|
{
|
|
alt[i] = h;
|
|
}
|
|
UGGeoLine3D line3D = geoFtOpt.transformToLine3D(*line,alt);
|
|
|
|
QVector<double>x_dist,z_diff;
|
|
geoComputation.getAlititudeDiff(line3D,dem,x_dist,z_diff);
|
|
|
|
chart = new Chart(ui->ElevationPlot);
|
|
chart->plotPolyline(x_dist,z_diff);
|
|
}
|
|
|
|
void RouteAnalysisDialog::on_FlightSpeedDSpinBox_textChanged(const QString &arg1)
|
|
{
|
|
SetFlightTime();
|
|
}
|
|
|