Browse Source

change tool/map_laentoxodr. complete object repeat.

yuchuli 3 năm trước cách đây
mục cha
commit
e70c2d1076

+ 27 - 0
src/tool/map_lanetoxodr/dialogroadobject.cpp

@@ -114,6 +114,7 @@ void DialogRoadObject::CreateView()
     mpPBvalidity = ViewCreate::CreatePB(startpos_x+3*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"validity",this);
 
     connect(mpPBmaterial,SIGNAL(clicked(bool)),this,SLOT(onClickMaterial()));
+    connect(mpPBrepeat,SIGNAL(clicked(bool)),this,SLOT(onClickRepeat()));
 }
 
 
@@ -471,3 +472,29 @@ void DialogRoadObject::onClickMaterial()
     dlgmaterail.exec();
 }
 
+void DialogRoadObject::onClickRepeat()
+{
+    if(mpRoad == 0)return;
+    Road * pRoad = mpRoad;
+    if(pRoad->GetObjectCount() == 0)
+    {
+        QMessageBox::warning(this,"Warning","No Object.",QMessageBox::YesAll);
+        return;
+    }
+
+    int index = ui->comboBox_Object->currentIndex();
+    if(index<0)return;
+    if(index >= mpRoad->GetObjectCount())return;
+
+    Object * pObject = mpRoad->GetObject(index);
+    if(pObject == 0)
+    {
+        QMessageBox::warning(this,"Warning","Can't found Object.",QMessageBox::YesAll);
+        return;
+    }
+
+    DialogRoadObject_repeat dlgrepeat(pObject);
+
+    dlgrepeat.exec();
+}
+

+ 1 - 0
src/tool/map_lanetoxodr/dialogroadobject.h

@@ -36,6 +36,7 @@ private slots:
     void on_pushButton_change_clicked();
 
     void onClickMaterial();
+    void onClickRepeat();
 
 private:
     Ui::DialogRoadObject *ui;

+ 323 - 5
src/tool/map_lanetoxodr/dialogroadobject_repeat.cpp

@@ -1,15 +1,22 @@
 #include "dialogroadobject_repeat.h"
 #include "ui_dialogroadobject_repeat.h"
 
+static std::string stritemname[] = {"s","length","distance","tStart","tEnd","heightStart","heightEnd",
+                                 "zOffsetStart","zOffsetEnd","widthStart","widthEnd","lengthStart",
+                                 "lendthEnd","radiusStart","radiusEnd"};
+
 DialogRoadObject_repeat::DialogRoadObject_repeat(Object * pObject,QWidget *parent) :
     QDialog(parent),
     ui(new Ui::DialogRoadObject_repeat)
 {
     ui->setupUi(this);
+    mpObject = pObject;
 
     CreateView();
 
-    mpObject = pObject;
+    UpdateList();
+
+    setWindowTitle("Edit Road Object Repeat");
 }
 
 DialogRoadObject_repeat::~DialogRoadObject_repeat()
@@ -19,22 +26,333 @@ DialogRoadObject_repeat::~DialogRoadObject_repeat()
 
 void DialogRoadObject_repeat::UpdateList()
 {
+    ui->comboBox_repeat->clear();
+    unsigned int i;
+    for(i=0;i<15;i++)
+    {
+        mpLE[i]->setText("");
+    }
+
+    Object * pObject = mpObject;
+    if(pObject == 0)return;
 
+    if(pObject->GetObjectrepeatCount() == 0)return;
+
+    for(i=0;i<pObject->GetObjectrepeatCount();i++)
+    {
+        Object_repeat * pObject_repeat = pObject->GetObjectrepeat(i);
+        if(pObject_repeat == 0)return;
+        ui->comboBox_repeat->addItem("repeat "+QString::number(i));
+    }
 }
 
 void DialogRoadObject_repeat::CreateView()
 {
     int startpos_x = 30;
     int startpos_y = 150;
-    int nSpace = 300;
-    int nLabelWidth = 100;
+    int nSpace = 260;
+    int nLabelWidth = 80;
     int nLEWidth = 150;
-    int nHeight = 30;
-    int nVSpace = 50;
+    int nHeight = 35;
+    int nVSpace = 60;
     int nVIndex = 0;
 
     mpLEs = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"s",this);
     mpLElength = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"length",this);
     mpLEdistance = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"distance",this);
     nVIndex++;
+    mpLEtStart = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"tStart",this);
+    mpLEtEnd = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"tEnd",this);
+    mpLEheightStart = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"heightStart",this);
+    nVIndex++;
+    mpLEheightEnd = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"heightEnd",this);
+    mpLEzOffsetStart = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"zOffsetStart",this);
+    mpLEzOffsetEnd = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"zOffsetEnd",this);
+    nVIndex++;
+    mpLEwidthStart = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"widthStart",this);
+    mpLEwidthEnd = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"widthEnd",this);
+    mpLElengthStart = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"lengthStart",this);
+    nVIndex++;
+    mpLElengthEnd = ViewCreate::CreateLE(startpos_x+0*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"lengthEnd",this);
+    mpLEradiusStart = ViewCreate::CreateLE(startpos_x+1*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"radiusStart",this);
+    mpLEradiusEnd = ViewCreate::CreateLE(startpos_x+2*nSpace,startpos_y+nVIndex*nVSpace,nLabelWidth,nLEWidth,nHeight,"radiusEnd",this);
+    nVIndex++;
+
+    mpLE[0] = mpLEs;
+    mpLE[1] = mpLElength;
+    mpLE[2] = mpLEdistance;
+    mpLE[3] = mpLEtStart;
+    mpLE[4] = mpLEtEnd;
+    mpLE[5] = mpLEheightStart;
+    mpLE[6] = mpLEheightEnd;
+    mpLE[7] = mpLEzOffsetStart;
+    mpLE[8] = mpLEzOffsetEnd;
+    mpLE[9] = mpLEwidthStart;
+    mpLE[10] = mpLEwidthEnd;
+    mpLE[11] = mpLElengthStart;
+    mpLE[12] = mpLElengthEnd;
+    mpLE[13] = mpLEradiusStart;
+    mpLE[14] = mpLEradiusEnd;
+
+    int nPBSpace = 300;
+    int nPBWidth = 150;
+    mpPBAdd = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Add",this);
+    mpPBDel = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Delete",this);
+    mpPBChange = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Change",this);
+
+    connect(mpPBAdd,SIGNAL(clicked(bool)),this,SLOT(onClickAdd()));
+    connect(mpPBDel,SIGNAL(clicked(bool)),this,SLOT(onCLickDel()));
+    connect(mpPBChange,SIGNAL(clicked(bool)),this,SLOT(onClickChange()));
+}
+
+void DialogRoadObject_repeat::on_comboBox_repeat_currentIndexChanged(int index)
+{
+    if(index < 0)return;
+
+    Object * pObject = mpObject;
+    if(pObject == 0)return;
+    if(index > ((int)pObject->GetObjectrepeatCount()))
+    {
+        return;
+    }
+
+    Object_repeat * pObject_repeat = pObject->GetObjectrepeat(index);
+
+    if(pObject_repeat == 0)
+    {
+        return;
+    }
+
+    mpLEs->setText(QString::number(pObject_repeat->Gets()));
+    mpLElength->setText(QString::number(pObject_repeat->Getlength()));
+    mpLEdistance->setText(QString::number(pObject_repeat->Getdistance()));
+    mpLEtStart->setText(QString::number(pObject_repeat->GettStart()));
+    mpLEtEnd->setText(QString::number(pObject_repeat->GettEnd()));
+    mpLEheightStart->setText(QString::number(pObject_repeat->GetheightStart()));
+    mpLEheightEnd->setText(QString::number(pObject_repeat->GetheightEnd()));
+    mpLEzOffsetStart->setText(QString::number(pObject_repeat->GetzOffsetStart()));
+    mpLEzOffsetEnd->setText(QString::number(pObject_repeat->GetzOffsetEnd()));
+
+    double widthStart,widthEnd,lengthStart,lengthEnd,radiusStart,radiusEnd;
+
+    if(pObject_repeat->GetwidthStart(widthStart) == 1)
+    {
+        mpLEwidthStart->setText(QString::number(widthStart));
+    }
+
+    if(pObject_repeat->GetwidthEnd(widthEnd) == 1)
+    {
+        mpLEwidthEnd->setText(QString::number(widthEnd));
+    }
+
+    if(pObject_repeat->GetlengthStart(lengthStart) == 1)
+    {
+        mpLElengthStart->setText(QString::number(lengthStart));
+    }
+
+    if(pObject_repeat->GetlengthEnd(lengthEnd) == 1)
+    {
+        mpLElengthEnd->setText(QString::number(lengthEnd));
+    }
+
+    if(pObject_repeat->GetradiusStart(radiusStart) == 1)
+    {
+        mpLEradiusStart->setText(QString::number(radiusStart));
+    }
+
+    if(pObject_repeat->GetradiusEnd(radiusEnd) == 1)
+    {
+        mpLEradiusEnd->setText(QString::number(radiusEnd));
+    }
+}
+
+void DialogRoadObject_repeat::onClickAdd()
+{
+
+    if(mpObject == 0)
+    {
+        QMessageBox::warning(this,"Warning","Object is NULL.",QMessageBox::YesAll);
+        return;
+    }
+
+    Object * pObject = mpObject;
+
+    unsigned int i;
+    for(i=0;i<9;i++)
+    {
+        if(false == ViewCreate::CheckLE(mpLE[i],stritemname[i].data(),true,this))
+        {
+            return;
+        }
+    }
+
+    double s,length,distance,tStart,tEnd,heightStart,heightEnd,zOffsetStart,zOffsetEnd;
+
+    s = mpLEs->text().toDouble();
+    length = mpLElength->text().toDouble();
+    distance = mpLEdistance->text().toDouble();
+    tStart = mpLEtStart->text().toDouble();
+    tEnd = mpLEtEnd->text().toDouble();
+    heightStart = mpLEheightStart->text().toDouble();
+    heightEnd = mpLEheightEnd->text().toDouble();
+    zOffsetStart = mpLEzOffsetStart->text().toDouble();
+    zOffsetEnd = mpLEzOffsetEnd->text().toDouble();
+
+    pObject->AddObjectrepeat(s,length,distance,tStart,tEnd,heightStart,heightEnd,zOffsetStart,zOffsetEnd);
+
+    Object_repeat * pObject_repeat = pObject->GetLastAddedObjectrepeat();
+
+    if(pObject_repeat == 0)return;
+
+    if(ViewCreate::CheckLE(mpLEwidthStart,"widthStart",false,this) == true)
+    {
+        pObject_repeat->SetwidthStart(mpLEwidthStart->text().toDouble());
+    }
+
+    if(ViewCreate::CheckLE(mpLEwidthEnd,"widthEnd",false,this) == true)
+    {
+        pObject_repeat->SetwidthEnd(mpLEwidthEnd->text().toDouble());
+    }
+
+    if(ViewCreate::CheckLE(mpLElengthStart,"lengthStart",false,this) == true)
+    {
+        pObject_repeat->SetlengthStart(mpLElengthStart->text().toDouble());
+    }
+
+    if(ViewCreate::CheckLE(mpLElengthEnd,"lengthEnd",false,this) == true)
+    {
+        pObject_repeat->SetlengthEnd(mpLElengthEnd->text().toDouble());
+    }
+
+    if(ViewCreate::CheckLE(mpLEradiusStart,"radiusStart",false,this) == true)
+    {
+        pObject_repeat->SetradiusStart(mpLEradiusStart->text().toDouble());
+    }
+
+    if(ViewCreate::CheckLE(mpLEradiusEnd,"radiusEnd",false,this) == true)
+    {
+        pObject_repeat->SetradiusEnd(mpLEradiusEnd->text().toDouble());
+    }
+
+    UpdateList();
+}
+
+void DialogRoadObject_repeat::onCLickDel()
+{
+    if(mpObject == 0)
+    {
+        QMessageBox::warning(this,"Warning","Object is NULL.",QMessageBox::YesAll);
+        return;
+    }
+
+    Object * pObject = mpObject;
+
+    if(pObject->GetObjectrepeatCount() == 0)
+    {
+        QMessageBox::information(this,"Info","No repeat",QMessageBox::YesAll);
+        return;
+    }
+
+    int index = ui->comboBox_repeat->currentIndex();
+
+    pObject->DeleteObjectmaterial(index);
+    UpdateList();
+}
+
+void DialogRoadObject_repeat::onClickChange()
+{
+    if(mpObject == 0)
+    {
+        QMessageBox::warning(this,"Warning","Object is NULL.",QMessageBox::YesAll);
+        return;
+    }
+
+    Object * pObject = mpObject;
+
+    if(pObject->GetObjectrepeatCount() == 0)
+    {
+        QMessageBox::warning(this,"Warning","No repeat",QMessageBox::YesAll);
+        return;
+    }
+
+    int index = ui->comboBox_repeat->currentIndex();
+
+    Object_repeat * pObject_repeat = pObject->GetObjectrepeat(index);
+
+    if(pObject_repeat == 0)return;
+
+    unsigned int i;
+    for(i=0;i<9;i++)
+    {
+        if(false == ViewCreate::CheckLE(mpLE[i],stritemname[i].data(),true,this))
+        {
+            return;
+        }
+    }
+
+    pObject_repeat->Sets(mpLEs->text().toDouble());
+    pObject_repeat->Setlength(mpLElength->text().toDouble());
+    pObject_repeat->Setdistance(mpLEdistance->text().toDouble());
+    pObject_repeat->SettStart(mpLEtStart->text().toDouble());
+    pObject_repeat->SettEnd(mpLEtEnd->text().toDouble());
+    pObject_repeat->SetheightStart(mpLEheightStart->text().toDouble());
+    pObject_repeat->SetheightEnd(mpLEheightEnd->text().toDouble());
+    pObject_repeat->SetzOffsetStart(mpLEzOffsetStart->text().toDouble());
+    pObject_repeat->SetzOffsetEnd(mpLEzOffsetEnd->text().toDouble());
+
+    if(ViewCreate::CheckLE(mpLEwidthStart,"widthStart",false,this) == true)
+    {
+        pObject_repeat->SetwidthStart(mpLEwidthStart->text().toDouble());
+    }
+    else
+    {
+        pObject_repeat->DeletewidthStart();
+    }
+
+    if(ViewCreate::CheckLE(mpLEwidthEnd,"widthEnd",false,this) == true)
+    {
+        pObject_repeat->SetwidthEnd(mpLEwidthEnd->text().toDouble());
+    }
+    else
+    {
+        pObject_repeat->DeletewidthEnd();
+    }
+
+    if(ViewCreate::CheckLE(mpLElengthStart,"lengthStart",false,this) == true)
+    {
+        pObject_repeat->SetlengthStart(mpLElengthStart->text().toDouble());
+    }
+    else
+    {
+        pObject_repeat->DeletelengthStart();
+    }
+
+    if(ViewCreate::CheckLE(mpLElengthEnd,"lengthEnd",false,this) == true)
+    {
+        pObject_repeat->SetlengthEnd(mpLElengthEnd->text().toDouble());
+    }
+    else
+    {
+        pObject_repeat->DeletelengthEnd();
+    }
+
+    if(ViewCreate::CheckLE(mpLEradiusStart,"radiusStart",false,this) == true)
+    {
+        pObject_repeat->SetradiusStart(mpLEradiusStart->text().toDouble());
+    }
+    else
+    {
+        pObject_repeat->DeleteradiusStart();
+    }
+
+    if(ViewCreate::CheckLE(mpLEradiusEnd,"radiusEnd",false,this) == true)
+    {
+        pObject_repeat->SetradiusEnd(mpLEradiusEnd->text().toDouble());
+    }
+    else
+    {
+        pObject_repeat->DeleteradiusEnd();
+    }
+
+    UpdateList();
 }

+ 13 - 0
src/tool/map_lanetoxodr/dialogroadobject_repeat.h

@@ -25,6 +25,13 @@ public:
     explicit DialogRoadObject_repeat(Object * pObject,QWidget *parent = nullptr);
     ~DialogRoadObject_repeat();
 
+private slots:
+    void on_comboBox_repeat_currentIndexChanged(int index);
+
+    void onClickAdd();
+    void onCLickDel();
+    void onClickChange();
+
 private:
     Ui::DialogRoadObject_repeat *ui;
 
@@ -50,6 +57,12 @@ private:
     QLineEdit * mpLElengthEnd;
     QLineEdit * mpLEradiusStart;
     QLineEdit * mpLEradiusEnd;
+
+    QLineEdit * mpLE[15];
+
+    QPushButton * mpPBAdd;
+    QPushButton * mpPBDel;
+    QPushButton * mpPBChange;
 };
 
 #endif // DIALOGROADOBJECT_REPEAT_H