diff --git a/OpenRoadEd/Qt/MainWindow.cpp b/OpenRoadEd/Qt/MainWindow.cpp index 51110502a32ee380202c5746a34b0f7750afdadc..2fea2dcc644f081eb631995fe3c77cee357be031 100644 --- a/OpenRoadEd/Qt/MainWindow.cpp +++ b/OpenRoadEd/Qt/MainWindow.cpp @@ -48,7 +48,7 @@ void MainWindow::initRoadTreeAndSettings() mRoadTree->Init(mOpenDrive); // Creates a new record settings panel - mSettingsPage = new SettingsPage(mOpenDrive,mRoadTree,mOsgMain); + mSettingsPage = new SettingsPage(mOpenDrive,mRoadTree); // Connects the record selection signals of the road tree to the appropriate selected slots of the record settings panel // This is used to show the appropriate set of properties for the selected record type diff --git a/OpenRoadEd/Qt/SettingsWidgets/SettingsJunction.cpp b/OpenRoadEd/Qt/SettingsWidgets/SettingsJunction.cpp index 76949d38787c51a626895977caea9d5378244fc9..13f6728f860981dd7b9f94480d5c12781a33f97c 100644 --- a/OpenRoadEd/Qt/SettingsWidgets/SettingsJunction.cpp +++ b/OpenRoadEd/Qt/SettingsWidgets/SettingsJunction.cpp @@ -1,15 +1,18 @@ #include "SettingsJunction.h" #include "moc_SettingsJunction.cpp" +#include "create_junction_road.h" /** * Initializes the properties panel and the UI elements */ -SettingsJunction::SettingsJunction(OpenDrive *openDrive) +SettingsJunction::SettingsJunction(OpenDrive *openDrive,RoadTree *roadTree) { // Resets the record mJunction=NULL; mOpenDrive=openDrive; + + mRoadTree=roadTree; // Main vertical layout QVBoxLayout *mainLayout = new QVBoxLayout; @@ -22,11 +25,13 @@ SettingsJunction::SettingsJunction(OpenDrive *openDrive) mName = new QLineEdit; mId = new QLineEdit; + mCreateRoads = new QPushButton("create roads"); // Form Layout inside group QFormLayout *settingsFormLayout = new QFormLayout; settingsFormLayout->addRow(tr("Name:"),mName); settingsFormLayout->addRow(tr("Id:"),mId); + settingsFormLayout->addRow(mCreateRoads); settingsGroup->setLayout(settingsFormLayout); //------------------------------------------------- @@ -64,6 +69,7 @@ void SettingsJunction::LoadData(Junction *junction) // Disconnects the "value changed" signals while the values are loaded disconnect(mName, SIGNAL(editingFinished()), this, SLOT(NameChanged())); disconnect(mId, SIGNAL(editingFinished()), this, SLOT(IdChanged())); + disconnect(mCreateRoads, SIGNAL(pressed(void)), this, SLOT(CreateRoadsPressed(void))); // Sets the record properties to the input widgets mJunction=junction; @@ -74,9 +80,33 @@ void SettingsJunction::LoadData(Junction *junction) // Connects the "value changed" signals back connect(mName, SIGNAL(editingFinished()), this, SLOT(NameChanged())); connect(mId, SIGNAL(editingFinished()), this, SLOT(IdChanged())); + connect(mCreateRoads, SIGNAL(pressed(void)), this, SLOT(CreateRoadsPressed(void))); } } +void SettingsJunction::CreateRoadsPressed(void) +{ + Selection *selection=mRoadTree->GetSelection(); + unsigned int junction_index,road_index; + Junction *junction; + JunctionConnection *connection; + + junction_index=(*selection)[0]; + junction=mOpenDrive->GetJunction(junction_index); + for(unsigned int i=0;i<junction->GetJunctionConnectionCount();i++) + { + connection=junction->GetJunctionConnection(i); + for(unsigned int j=0;j<connection->GetJunctionLaneLinkCount();j++) + { + mRoadTree->SelectJunctionLaneLink(junction_index,i,j); + road_index=create_junction_road(mRoadTree,mOpenDrive,junction_index,i,j); + if(road_index!=-1) + emit RoadChanged(road_index); + } + } + mRoadTree->SelectJunction(junction_index); +} + /** * Methods called when properties change */ diff --git a/OpenRoadEd/Qt/SettingsWidgets/SettingsJunction.h b/OpenRoadEd/Qt/SettingsWidgets/SettingsJunction.h index 5e42762989d56d294a741e500d5f31a8c9c6ec02..338fd5a70d1b804042662a61639e8013a89aa9c2 100644 --- a/OpenRoadEd/Qt/SettingsWidgets/SettingsJunction.h +++ b/OpenRoadEd/Qt/SettingsWidgets/SettingsJunction.h @@ -8,6 +8,7 @@ #include "../../OpenDrive/OpenDrive.h" #include "../../OpenDrive/Road.h" #include "../../OpenDrive/Junction.h" +#include "../Tree/RoadTree.h" /** * Class that holds all the properties for the JUNCTION record @@ -20,7 +21,7 @@ public: /** * Initializes the properties panel and the UI elements */ - SettingsJunction(OpenDrive *openDrive); + SettingsJunction(OpenDrive *openDrive,RoadTree *roadTree); /** * Loads the data for a given record @@ -29,6 +30,7 @@ public: */ void LoadData(Junction *junction); private: + RoadTree *mRoadTree; /** * OpenDrive reference for "Select Road" dialog */ @@ -43,6 +45,7 @@ private: */ QLineEdit *mName; QLineEdit *mId; + QPushButton *mCreateRoads; public slots: /** @@ -50,6 +53,14 @@ public slots: */ void NameChanged(); void IdChanged(); + void CreateRoadsPressed(); +signals: + /** + * Signal emitted when critical road items are deleted + * that require that the road to be redrawn + */ + void RoadChanged(unsigned int road_index); + }; #endif diff --git a/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.cpp b/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.cpp index 89a939be7df1757039828b43e5a44ce2bb82d202..450147994e79d4590beb3c99bec158df804d89b4 100644 --- a/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.cpp +++ b/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.cpp @@ -7,12 +7,11 @@ /** * Initializes the settings panel and all the interface elements */ -SettingsPage::SettingsPage(OpenDrive *openDrive,RoadTree *roadTree,OSGMain *osgMain) +SettingsPage::SettingsPage(OpenDrive *openDrive,RoadTree *roadTree) { // Saves a reference to OpenDrive structure mOpenDrive = openDrive; mRoadTree = roadTree; - mOsgMain = osgMain; //setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum); @@ -52,11 +51,11 @@ SettingsPage::SettingsPage(OpenDrive *openDrive,RoadTree *roadTree,OSGMain *osgM mLaneHeight = new SettingsLaneHeightRecord; mLaneHeight->hide(); - mJunction = new SettingsJunction(openDrive); + mJunction = new SettingsJunction(openDrive,roadTree); mJunction->hide(); mJunctionConnection = new SettingsJunctionConnection(openDrive,roadTree); mJunctionConnection->hide(); - mJunctionLaneLink = new SettingsJunctionLaneLink(openDrive,roadTree,osgMain); + mJunctionLaneLink = new SettingsJunctionLaneLink(openDrive,roadTree); mJunctionLaneLink->hide(); mJunctionPriority = new SettingsJunctionPriority; mJunctionPriority->hide(); @@ -116,6 +115,7 @@ SettingsPage::SettingsPage(OpenDrive *openDrive,RoadTree *roadTree,OSGMain *osgM connect(mLaneHeight, SIGNAL(RoadLaneHeightChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); connect(mJunctionLaneLink, SIGNAL(RoadGeometryChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); connect(mJunctionLaneLink, SIGNAL(RoadChanged(unsigned int)), this, SLOT(OnRoadChanged(unsigned int))); + connect(mJunction, SIGNAL(RoadChanged(unsigned int)), this, SLOT(OnRoadChanged(unsigned int))); } /** diff --git a/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.h b/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.h index 06ddd9f6106a3ad261de3c62a667952d117cd22b..98183c2e9d7cf17f1b2ad7a7a9c67e409aa3a492 100644 --- a/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.h +++ b/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.h @@ -48,13 +48,12 @@ public: /** * Initializes the settings panel and all the interface elements */ - SettingsPage(OpenDrive *openDrive,RoadTree *roadTree,OSGMain *osgMain); + SettingsPage(OpenDrive *openDrive,RoadTree *roadTree); private: /** * Pointer to the OpenDrive structure */ OpenDrive *mOpenDrive; - OSGMain *mOsgMain; RoadTree *mRoadTree; /**