123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- #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();
- UpdateList();
- setWindowTitle("Edit Road Object Repeat");
- }
- DialogRoadObject_repeat::~DialogRoadObject_repeat()
- {
- delete ui;
- }
- 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 = 260;
- int nLabelWidth = 80;
- int nLEWidth = 150;
- 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();
- }
|