|
@@ -1,12 +1,55 @@
|
|
|
#include "dialoghideroad.h"
|
|
|
#include "ui_dialoghideroad.h"
|
|
|
|
|
|
-DialogHideRoad::DialogHideRoad(OpenDrive * pxodr,std::string strdefroad,QWidget *parent) :
|
|
|
+#include <QMessageBox>
|
|
|
+#include "mainwindow.h"
|
|
|
+
|
|
|
+#include "math.h"
|
|
|
+
|
|
|
+#define VIEW_WIDTH 900
|
|
|
+#define VIEW_HEIGHT 450
|
|
|
+
|
|
|
+DialogHideRoad::DialogHideRoad(OpenDrive * pxodr,std::string strdefroad,std::vector<int> * pvectorhideroadid,QWidget *parent) :
|
|
|
QDialog(parent),
|
|
|
ui(new Ui::DialogHideRoad)
|
|
|
{
|
|
|
+ mpxodr = pxodr;
|
|
|
+ mpvectorhideroadid = pvectorhideroadid;
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
+
|
|
|
+ myview = new MyView(this);
|
|
|
+ myview->setObjectName(QStringLiteral("graphicsView2"));
|
|
|
+ myview->setGeometry(QRect(30, 150, 960, 500));
|
|
|
+
|
|
|
+ // connect(myview,SIGNAL(dbclickxy(double,double)),this,SLOT(onClickXY(double,double)));
|
|
|
+
|
|
|
+ image = new QImage(VIEW_WIDTH, VIEW_HEIGHT, QImage::Format_RGB32);//画布的初始化大小设为300*300,使用32位颜色
|
|
|
+ myview->setCacheMode(myview->CacheBackground);
|
|
|
+ painter = new QPainter(image);
|
|
|
+ painter->end();
|
|
|
+
|
|
|
+ scene = new QGraphicsScene(-VIEW_WIDTH/2, -VIEW_HEIGHT/2, VIEW_WIDTH, VIEW_HEIGHT);
|
|
|
+
|
|
|
+ myview->setScene(scene);
|
|
|
+ scene->setBackgroundBrush(Qt::darkGreen);
|
|
|
+
|
|
|
+
|
|
|
+ int i;
|
|
|
+ int nroadcount = mpxodr->GetRoadCount();
|
|
|
+ for(i=0;i<nroadcount;i++)
|
|
|
+ {
|
|
|
+ const char * strname = mpxodr->GetRoad(i)->GetRoadId().data();
|
|
|
+ ui->comboBox_Road->addItem(strname);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ MainWindow::ComboToString(strdefroad,ui->comboBox_Road);
|
|
|
+
|
|
|
+ UpdateHidenCombo();
|
|
|
+
|
|
|
setWindowTitle("Hide Road");
|
|
|
}
|
|
|
|
|
@@ -14,3 +57,169 @@ DialogHideRoad::~DialogHideRoad()
|
|
|
{
|
|
|
delete ui;
|
|
|
}
|
|
|
+
|
|
|
+void DialogHideRoad::paintEvent(QPaintEvent * painter)
|
|
|
+{
|
|
|
+ scene->update();
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+void DialogHideRoad::on_comboBox_Road_currentIndexChanged(int index)
|
|
|
+{
|
|
|
+ Road * pRoad = mpxodr->GetRoad(index);
|
|
|
+ if(pRoad == 0)
|
|
|
+ {
|
|
|
+ // QMessageBox::warning(this,"WARN","MainWindow::onClickCBRoadChange road is NULL");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mpCurRoad = pRoad;
|
|
|
+
|
|
|
+ int i;
|
|
|
+ int nsize = mvectorroadview.size();
|
|
|
+ for(i=0;i<nsize;i++)
|
|
|
+ {
|
|
|
+ scene->removeItem(mvectorroadview.at(i));
|
|
|
+ delete mvectorroadview.at(i);
|
|
|
+ }
|
|
|
+ mvectorroadview.clear();
|
|
|
+
|
|
|
+ nsize = mvectorviewitem.size();
|
|
|
+ for(i=0;i<nsize;i++)
|
|
|
+ {
|
|
|
+ scene->removeItem(mvectorviewitem.at(i));
|
|
|
+ delete mvectorviewitem.at(i);
|
|
|
+ }
|
|
|
+ mvectorviewitem.clear();
|
|
|
+
|
|
|
+ double froad_xmin,froad_ymin,froad_xmax,froad_ymax;
|
|
|
+ ServiceXODRTool.GetRoadMaxMin(pRoad,froad_xmin,froad_ymin,froad_xmax,froad_ymax);
|
|
|
+// roadviewitem * prvw = new roadviewitem(pRoad);
|
|
|
+
|
|
|
+ int nfac;
|
|
|
+ int nkeep = 30;
|
|
|
+ double fac_x,fac_y;
|
|
|
+ fac_x = 100000;
|
|
|
+ fac_y = 100000;
|
|
|
+ if(froad_xmax > froad_xmin)
|
|
|
+ {
|
|
|
+ fac_x = (VIEW_WIDTH-nkeep*2)/(froad_xmax - froad_xmin);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(froad_ymax > froad_ymin)
|
|
|
+ {
|
|
|
+ fac_y = (VIEW_HEIGHT - nkeep*2)/(froad_ymax - froad_ymin);
|
|
|
+ }
|
|
|
+
|
|
|
+ nfac = fac_x;
|
|
|
+ if(fac_y < nfac)nfac = fac_y;
|
|
|
+
|
|
|
+
|
|
|
+ mfViewMoveX = VIEW_WIDTH/2.0 ;
|
|
|
+ mfViewMoveY = VIEW_HEIGHT/2.0;
|
|
|
+
|
|
|
+ mfViewMoveX = 0 - froad_xmin - (froad_xmax - froad_xmin)/2.0;
|
|
|
+ mfViewMoveY = 0 + froad_ymin + (froad_ymax-froad_ymin)/2.0;
|
|
|
+
|
|
|
+// prvw->setPos(mfViewMoveX,mfViewMoveY);
|
|
|
+ // prvw->setPos((froad_xmax - froad_xmin)/2.0, (froad_ymax-froad_ymin)/2.0);
|
|
|
+// mvectorroadview.push_back(prvw);
|
|
|
+ // prvw->setratio(1.0);
|
|
|
+// scene->addItem(prvw);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ RoadDigit xrd(mpCurRoad,5.0);
|
|
|
+
|
|
|
+ std::vector<QGraphicsPathItem *> xvectorlanepath = xodrscenfunc::GetRoadLaneItem(&xrd);
|
|
|
+ int j;
|
|
|
+ int ncount = xvectorlanepath.size();
|
|
|
+ for(j=0;j<ncount;j++)
|
|
|
+ {
|
|
|
+ QGraphicsPathItem * pitem = xvectorlanepath[j];
|
|
|
+ pitem->setPos(mfViewMoveX,mfViewMoveY);
|
|
|
+ scene->addItem(pitem);
|
|
|
+ mvectorviewitem.push_back(pitem);
|
|
|
+ }
|
|
|
+
|
|
|
+ std::vector<QGraphicsPathItem *> xvectormarkpath = xodrscenfunc::GetRoadMarkItem(&xrd);
|
|
|
+ ncount = xvectormarkpath.size();
|
|
|
+ for(j=0;j<ncount;j++)
|
|
|
+ {
|
|
|
+ QGraphicsPathItem * pitem = xvectormarkpath[j];
|
|
|
+ pitem->setPos(mfViewMoveX,mfViewMoveY);
|
|
|
+ scene->addItem(pitem);
|
|
|
+ mvectorviewitem.push_back(pitem);
|
|
|
+ }
|
|
|
+
|
|
|
+ update();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void DialogHideRoad::on_pushButton_HideRoad_clicked()
|
|
|
+{
|
|
|
+ if(ui->comboBox_Road->currentIndex()<0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","No Road.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int nroadid = ui->comboBox_Road->currentText().toInt();
|
|
|
+ unsigned int i;
|
|
|
+ bool bExist = false;
|
|
|
+ for(i=0;i<mpvectorhideroadid->size();i++)
|
|
|
+ {
|
|
|
+ if(mpvectorhideroadid->at(i) == nroadid)
|
|
|
+ {
|
|
|
+ bExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(bExist)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","This Road is Hiden.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mpvectorhideroadid->push_back(nroadid);
|
|
|
+ UpdateHidenCombo();
|
|
|
+}
|
|
|
+
|
|
|
+void DialogHideRoad::on_pushButton_UnHIdeRoad_clicked()
|
|
|
+{
|
|
|
+ if(ui->comboBox_RoadHiden->currentIndex()<0)
|
|
|
+ {
|
|
|
+ QMessageBox::warning(this,"Warning","No Hiden road.",QMessageBox::YesAll);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mpvectorhideroadid->erase(mpvectorhideroadid->begin()+ui->comboBox_RoadHiden->currentIndex());
|
|
|
+ UpdateHidenCombo();
|
|
|
+}
|
|
|
+
|
|
|
+void DialogHideRoad::on_pushButton_UnHideAllRoad_clicked()
|
|
|
+{
|
|
|
+ if(mpvectorhideroadid->size()>0)
|
|
|
+ {
|
|
|
+ mpvectorhideroadid->clear();
|
|
|
+ UpdateHidenCombo();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void DialogHideRoad::UpdateHidenCombo()
|
|
|
+{
|
|
|
+ int index = ui->comboBox_RoadHiden->currentIndex();
|
|
|
+ ui->comboBox_RoadHiden->clear();
|
|
|
+ if(mpvectorhideroadid->size() == 0)return;
|
|
|
+ unsigned int i;
|
|
|
+ for(i=0;i<mpvectorhideroadid->size();i++)
|
|
|
+ {
|
|
|
+ ui->comboBox_RoadHiden->addItem(QString::number(mpvectorhideroadid->at(i)));
|
|
|
+ }
|
|
|
+ if((index>=0)&&(index<mpvectorhideroadid->size()))
|
|
|
+ {
|
|
|
+ ui->comboBox_RoadHiden->setCurrentIndex(index);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ui->comboBox_RoadHiden->setCurrentIndex(0);
|
|
|
+ }
|
|
|
+}
|