|
|
#include "bindroutedialog.h"
|
|
|
#include "Geometry/UGGeoLine.h"
|
|
|
#include "Geometry3D/UGGeoLine3D.h"
|
|
|
#include "qdebug.h"
|
|
|
#include "ui_bindroutedialog.h"
|
|
|
#include "translator.h"
|
|
|
|
|
|
|
|
|
bindRouteDialog::bindRouteDialog(QWidget *parent) :
|
|
|
QDialog(parent),
|
|
|
ui(new Ui::bindRouteDialog)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
this->setWindowTitle(u8"航线装订");
|
|
|
this->resize(1100,600);
|
|
|
this->setWindowFlags(Qt::WindowCloseButtonHint); //关闭右上角帮助(?)按钮。
|
|
|
// ui->routeNumberCombox->addItem("1");
|
|
|
// addRouteTypeItem();
|
|
|
|
|
|
bindState = u8"未装订";
|
|
|
|
|
|
// RouteType[1] = "飞行航线";
|
|
|
// RouteType[2] = "应急航线";
|
|
|
// RouteType[3] = "回收航线";
|
|
|
// RouteType[4] = "围栏航线";
|
|
|
// RouteType[5] = "通场航线";
|
|
|
// RouteType[6] = "跑道航线";
|
|
|
|
|
|
RouteType = routeGVar.getRouteType();
|
|
|
|
|
|
|
|
|
model = new BindRouteTableModel();
|
|
|
ui->bindRouteTable->setModel(model);
|
|
|
|
|
|
// ui->bindRouteTable->resizeColumnToContents();
|
|
|
ui->bindRouteTable->verticalHeader()->hide();
|
|
|
ui->bindRouteTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
// ui->bindRouteTable->horizontalHeader()->setSectionResizeMode(2,QHeaderView::ResizeToContents);
|
|
|
// ui->bindRouteTable->horizontalHeader()->setSectionResizeMode(3,QHeaderView::ResizeToContents);
|
|
|
|
|
|
ui->bindRouteTable->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
ui->bindRouteTable->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); // 显示垂直滑动条
|
|
|
|
|
|
}
|
|
|
|
|
|
bindRouteDialog::~bindRouteDialog()
|
|
|
{
|
|
|
delete ui;
|
|
|
}
|
|
|
|
|
|
void bindRouteDialog::setDataset(UGC::UGDatasetVector *dv)
|
|
|
{
|
|
|
this->dv = dv;
|
|
|
addRouteTypeItem();
|
|
|
}
|
|
|
|
|
|
void bindRouteDialog::addRouteTypeItem()
|
|
|
{
|
|
|
UGRecordsetPtr res = queryFeature(dv);
|
|
|
if(!res) return;
|
|
|
res->MoveFirst();
|
|
|
UGVariant v;
|
|
|
// QSet<int> typeset;
|
|
|
std::set<int> typeset; //Qset不会排序,因此这里使用std::set
|
|
|
while(!res->IsEOF())
|
|
|
{//获取航线类型唯一值
|
|
|
res->GetFieldValue(Translator::QStr2UGStr(routeGVar.routeFieldsName.RouteType),v);
|
|
|
typeset.insert(v.ToInt());
|
|
|
res->MoveNext();
|
|
|
}
|
|
|
|
|
|
for(auto i = typeset.begin(); i != typeset.end(); i++)
|
|
|
{
|
|
|
ui->routeTypeCombox->addItem(RouteType[*i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void bindRouteDialog::addRouteNumberItem(UGRecordsetPtr res)
|
|
|
{
|
|
|
ui->routeNumberCombox->clear();
|
|
|
QStringList strl;
|
|
|
UGVariant v;
|
|
|
if(res)
|
|
|
{
|
|
|
while (!res->IsEOF()) { //获取航线编号
|
|
|
res->GetFieldValue(Translator::QStr2UGStr(routeGVar.routeFieldsName.RouteNumber),v);
|
|
|
strl << Translator::UGStr2QStr(v.ToString());
|
|
|
res->MoveNext();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ui->routeNumberCombox->addItems(strl);
|
|
|
}
|
|
|
|
|
|
void bindRouteDialog::showTableData(QString routeNumber,QMap<int,QVector3D> points,
|
|
|
QString routeFeatures,QString bindState)
|
|
|
{
|
|
|
//与tableView绑定
|
|
|
model->setBeginResetModel();
|
|
|
model->routeData.routeNumber = routeNumber;
|
|
|
model->routeData.points = points;
|
|
|
// model->routeData.routeHeight = routeHeight;
|
|
|
model->routeData.routeFeatures = routeFeatures;
|
|
|
model->routeData.bindState = bindState;
|
|
|
model->setEndResetModel();
|
|
|
|
|
|
// qDebug()<<"*************************rowCount:"<<model->getRowCount();
|
|
|
// qDebug()<<"*************************rowCount:"<<model->getRowCount();
|
|
|
// qDebug()<<"*************************rowCount:"<<model->getRowCount();
|
|
|
|
|
|
ui->bindRouteTable->viewport()->update();
|
|
|
ui->bindRouteTable->repaint();
|
|
|
|
|
|
}
|
|
|
|
|
|
UGRecordsetPtr bindRouteDialog::queryFeature(UGDatasetVector *dv, UGString filter)
|
|
|
{
|
|
|
UGQueryDef queryDef;
|
|
|
queryDef.m_nOptions = UGQueryDef::Both; //查询选项:几何对象(Geometry)和属性(Attribute)都查询
|
|
|
queryDef.m_nType = UGQueryDef::General; //查询类型:一般的数下条件查询
|
|
|
queryDef.m_nMode = UGQueryDef::GeneralQuery; //查询模式:一般查询(非模糊查询)
|
|
|
queryDef.m_nCursorType = UGQueryDef::OpenStatic; //OpenStatic,用于读取数据;OpenDynamic,用于数据增删改
|
|
|
queryDef.m_strFilter = filter; //查询条件
|
|
|
return dv->Query(queryDef);
|
|
|
}
|
|
|
|
|
|
void bindRouteDialog::getNodePoints(UGRecordsetPtr res, QMap<int,QVector3D>&points)
|
|
|
{
|
|
|
res->MoveFirst();
|
|
|
UGGeometry* pGeometry = NULL;
|
|
|
res->GetGeometry(pGeometry);
|
|
|
|
|
|
QVector3D point;
|
|
|
int type = pGeometry->GetType();
|
|
|
switch (type) {
|
|
|
case UGGeometry::GeoLine:
|
|
|
{
|
|
|
//导航高度
|
|
|
UGVariant v;
|
|
|
res->GetFieldValue(Translator::QStr2UGStr(routeGVar.routeFieldsName.RouteHeight),v);
|
|
|
double height = v.ToDouble();
|
|
|
|
|
|
UGGeoLine* line = (UGGeoLine*)pGeometry;
|
|
|
const UGPoint2D* p = line->GetPoints(); //节点指针
|
|
|
int nodeNum = line->GetPointCount(); //节点数
|
|
|
if (line->GetStartNode() == line->GetEndNode())
|
|
|
{//闭合航线,减去末尾重合航点
|
|
|
nodeNum--;
|
|
|
}
|
|
|
for(int i = 0;i<nodeNum;i++) //遍历一个要素所有节点
|
|
|
{
|
|
|
point.setX(p->x);
|
|
|
point.setY(p->y);
|
|
|
point.setZ(height);
|
|
|
points[i+1] = point;
|
|
|
p++;
|
|
|
}
|
|
|
line = NULL;
|
|
|
p = NULL;
|
|
|
break;
|
|
|
}
|
|
|
case UGGeometry::GeoRegion:
|
|
|
{
|
|
|
UGGeoRegion* polygon = (UGGeoRegion*)pGeometry;
|
|
|
const UGPoint2D* p = polygon->GetPoints(); //节点指针
|
|
|
int nodeNum = polygon->GetPointCount()-1; //节点数
|
|
|
for(int i = 0;i<nodeNum;i++)
|
|
|
{
|
|
|
point.setX(p->x);
|
|
|
point.setY(p->y);
|
|
|
point.setZ(0);
|
|
|
points[i] = point;
|
|
|
p++;
|
|
|
}
|
|
|
polygon = NULL;
|
|
|
p = NULL;
|
|
|
break;
|
|
|
}
|
|
|
case UGGeometry::GeoLine3D:
|
|
|
{
|
|
|
UGGeoLine3D* line3D = (UGGeoLine3D*)pGeometry;
|
|
|
const UGPoint3D* p = line3D->GetPoints(); //节点指针
|
|
|
int nodeNum = line3D->GetPointCount(); //节点数
|
|
|
if (line3D->GetStartNode() == line3D->GetEndNode())
|
|
|
{//闭合航线,减去末尾重合航点
|
|
|
nodeNum--;
|
|
|
}
|
|
|
for(int i = 0;i<nodeNum;i++)
|
|
|
{
|
|
|
point.setX(p->x);
|
|
|
point.setY(p->y);
|
|
|
point.setZ(p->z);
|
|
|
points[i+1] = point;
|
|
|
p++;
|
|
|
}
|
|
|
|
|
|
line3D = NULL;
|
|
|
p = NULL;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void bindRouteDialog::on_routeNumberCombox_currentIndexChanged(int index)
|
|
|
{
|
|
|
routeNumber = ui->routeNumberCombox->currentText();
|
|
|
if(routeNumber.isEmpty())
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
// qDebug()<<"*************************routeNumber:"<<routeNumber;
|
|
|
|
|
|
QString queryFilter = "RouteType=" + routeType + " and " +
|
|
|
("RouteNumber=") + routeNumber;
|
|
|
// qDebug()<<"*************************queryFilter_NUM:"<<queryFilter;
|
|
|
UGRecordsetPtr res1 = queryFeature(dv,Translator::QStr2UGStr(queryFilter));
|
|
|
//导航高度
|
|
|
// UGVariant v1;
|
|
|
// res1->GetFieldValue(Translator::QStr2UGStr(routeGVar.routeFieldsName.RouteHeight),v1);
|
|
|
// routeHeight = v1.ToDouble();
|
|
|
//添加0号起飞点
|
|
|
QVector3D point0(0,0,0); //起飞点
|
|
|
points.clear();
|
|
|
UGGeometry* pGeometry = NULL;
|
|
|
res1->GetGeometry(pGeometry);
|
|
|
getNodePoints(res1,points); //航点
|
|
|
points[0] = point0;
|
|
|
|
|
|
QStringList m_headData;
|
|
|
m_headData<<"航线"<<"航点"<<"经度"<<"纬度"<<"导航高度"<<"航路特征"<<"装订状态";
|
|
|
|
|
|
model->m_headData = m_headData;
|
|
|
showTableData(routeNumber,points,"03",bindState);
|
|
|
|
|
|
pGeometry = NULL;
|
|
|
}
|
|
|
|
|
|
void bindRouteDialog::on_routeTypeCombox_currentIndexChanged(int index)
|
|
|
{
|
|
|
routeType = QString::number(RouteType.key(ui->routeTypeCombox->currentText()));
|
|
|
|
|
|
QString queryFilter = "RouteType=" + routeType;
|
|
|
UGRecordsetPtr res2 = queryFeature(dv,Translator::QStr2UGStr(queryFilter));
|
|
|
//更新航线编号选项
|
|
|
addRouteNumberItem(res2);
|
|
|
|
|
|
routeNumber = ui->routeNumberCombox->currentText();
|
|
|
|
|
|
}
|
|
|
|
|
|
// 当内容改变时自适应列宽
|
|
|
//void bindRouteDialog::resizeContents()
|
|
|
//{
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
void bindRouteDialog::on_bindRouteCancelBtn_clicked()
|
|
|
{
|
|
|
this->close();
|
|
|
}
|
|
|
|
|
|
|
|
|
void bindRouteDialog::on_bindRouteStartBtn_clicked()
|
|
|
{
|
|
|
this->accept();
|
|
|
}
|
|
|
|