diff --git a/OpenRoadEd/CMakeLists.txt b/OpenRoadEd/CMakeLists.txt index c9e1be4e53661e2baa04d049be20f9e0d666cef8..3b489e18a4e98bbbda7ca49238fc6baf2a7381d4 100644 --- a/OpenRoadEd/CMakeLists.txt +++ b/OpenRoadEd/CMakeLists.txt @@ -47,6 +47,7 @@ set(TARGET_H "${CMAKE_SOURCE_DIR}/OpenDrive/OpenDriveXmlParser.h" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsLaneSpeedRecord.h" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsJunction.h" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsGeometryLine.h" + "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsGeometryParamPoly3.h" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsLaneRoadMark.h" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsLaneHeightRecord.h" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsJunctionConnection.h" @@ -114,6 +115,7 @@ set(TARGET_CPP "${CMAKE_SOURCE_DIR}/OpenDrive/OpenDriveXmlWriter.cpp" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsLane.cpp" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsLaneSection.cpp" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsGeometryLine.cpp" + "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsGeometryParamPoly3.cpp" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsLaneVisibilityRecord.cpp" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsJunction.cpp" "${CMAKE_SOURCE_DIR}/Qt/SettingsWidgets/SettingsLateralProfileCrossfall.cpp" diff --git a/OpenRoadEd/OpenDrive/RoadGeometry.cpp b/OpenRoadEd/OpenDrive/RoadGeometry.cpp index 21f3f8dd52b76493b9d80a4ff2cf01e723973063..b127dc8eb218bca3deaa651462f666de478919fb 100644 --- a/OpenRoadEd/OpenDrive/RoadGeometry.cpp +++ b/OpenRoadEd/OpenDrive/RoadGeometry.cpp @@ -537,6 +537,38 @@ void GeometryParamPoly3::SetAll(double s, double x, double y, double hdg, double ComputeVars(); } +void GeometryParamPoly3::SetAu(double value) +{ + mAu=value; +} +void GeometryParamPoly3::SetBu(double value) +{ + mBu=value; +} +void GeometryParamPoly3::SetCu(double value) +{ + mCu=value; +} +void GeometryParamPoly3::SetDu(double value) +{ + mDu=value; +} +void GeometryParamPoly3::SetAv(double value) +{ + mAv=value; +} +void GeometryParamPoly3::SetBv(double value) +{ + mBv=value; +} +void GeometryParamPoly3::SetCv(double value) +{ + mCv=value; +} +void GeometryParamPoly3::SetDv(double value) +{ + mDv=value; +} //------------------------------------------------- /** diff --git a/OpenRoadEd/OpenDrive/RoadGeometry.h b/OpenRoadEd/OpenDrive/RoadGeometry.h index df5db79f83e46e2f1276cebe4f794a4fd74502a9..0f800a583b2a51eeff4c2e007acea743128d41ae 100644 --- a/OpenRoadEd/OpenDrive/RoadGeometry.h +++ b/OpenRoadEd/OpenDrive/RoadGeometry.h @@ -305,6 +305,15 @@ public: */ void SetAll(double s, double x, double y, double hdg, double length,double au,double bu,double cu,double du,double av,double bv,double cv,double dv); + void SetAu(double value); + void SetBu(double value); + void SetCu(double value); + void SetDu(double value); + void SetAv(double value); + void SetBv(double value); + void SetCv(double value); + void SetDv(double value); + //------------------------------------------------- /** * Getter for the base properties diff --git a/OpenRoadEd/Qt/MainWindow.cpp b/OpenRoadEd/Qt/MainWindow.cpp index 3b8a71d5fd42ed18ea1c4d8fc682671bc2c02fe9..cae2b501abcf8c6f03f099f640bc05ad2f2ecd47 100644 --- a/OpenRoadEd/Qt/MainWindow.cpp +++ b/OpenRoadEd/Qt/MainWindow.cpp @@ -57,6 +57,7 @@ void MainWindow::initRoadTreeAndSettings() connect(mRoadTree, SIGNAL(RoadTypeSelected(RoadType*,double,double)), mSettingsPage, SLOT(OnRoadTypeSelected(RoadType*,double,double))); connect(mRoadTree, SIGNAL(GeometryLineSelected(GeometryBlock*,bool)), mSettingsPage, SLOT(OnGeometryLineSelected(GeometryBlock*,bool))); connect(mRoadTree, SIGNAL(GeometryTurnSelected(GeometryBlock*,bool)), mSettingsPage, SLOT(OnGeometryTurnSelected(GeometryBlock*,bool))); + connect(mRoadTree, SIGNAL(GeometryParamPoly3Selected(GeometryBlock*,bool)), mSettingsPage, SLOT(OnGeometryParamPoly3Selected(GeometryBlock*,bool))); connect(mRoadTree, SIGNAL(ElevationSelected(Elevation*,double,double)), mSettingsPage, SLOT(OnElevationSelected(Elevation*,double,double))); connect(mRoadTree, SIGNAL(SuperElevationSelected(SuperElevation*,double,double)), mSettingsPage, SLOT(OnSuperElevationSelected(SuperElevation*,double,double))); connect(mRoadTree, SIGNAL(CrossfallSelected(Crossfall*,double,double)), mSettingsPage, SLOT(OnCrossfallSelected(Crossfall*,double,double))); @@ -98,6 +99,7 @@ void MainWindow::initCreation() connect(mRoadTree, SIGNAL(RoadTypeSelected(RoadType*,double,double)), mCreationPage, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(GeometryLineSelected(GeometryBlock*,bool)), mCreationPage, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(GeometryTurnSelected(GeometryBlock*,bool)), mCreationPage, SLOT(SomethingSelected())); + connect(mRoadTree, SIGNAL(GeometryParamPoly3Selected(GeometryBlock*,bool)), mCreationPage, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(ElevationSelected(Elevation*,double,double)), mCreationPage, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(SuperElevationSelected(SuperElevation*,double,double)), mCreationPage, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(CrossfallSelected(Crossfall*,double,double)), mCreationPage, SLOT(SomethingSelected())); @@ -348,6 +350,7 @@ void MainWindow::initOSG(OSGMain *osgMain) connect(mRoadTree, SIGNAL(RoadTypeSelected(RoadType*,double,double)), mOSGViewer, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(GeometryLineSelected(GeometryBlock*,bool)), mOSGViewer, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(GeometryTurnSelected(GeometryBlock*,bool)), mOSGViewer, SLOT(SomethingSelected())); + connect(mRoadTree, SIGNAL(GeometryParamPoly3Selected(GeometryBlock*,bool)), mOSGViewer, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(ElevationSelected(Elevation*,double,double)), mOSGViewer, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(SuperElevationSelected(SuperElevation*,double,double)), mOSGViewer, SLOT(SomethingSelected())); connect(mRoadTree, SIGNAL(CrossfallSelected(Crossfall*,double,double)), mOSGViewer, SLOT(SomethingSelected())); diff --git a/OpenRoadEd/Qt/QOSGWidget.cpp b/OpenRoadEd/Qt/QOSGWidget.cpp index d72ed227ce82608668efc51841d1d7706cb26ce2..7010fbcc47938930eabe828f0cbef9e8664e14eb 100644 --- a/OpenRoadEd/Qt/QOSGWidget.cpp +++ b/OpenRoadEd/Qt/QOSGWidget.cpp @@ -214,6 +214,14 @@ void QOSGWidget::SomethingSelected() mOsgMain->MakeSelection(&osgNode); break; } + case GEOMETRY_PARAMPOLY3: + { + osgNode.SetNodeType(GEOMETRY_BLOCK_NODE); + osgNode.AddNodeInfoIndex(lSelection->GetIndex(0)); + osgNode.AddNodeInfoIndex(lSelection->GetIndex(1)); + mOsgMain->MakeSelection(&osgNode); + break; + } case ELEVATION: { osgNode.SetNodeType(ELEVATION_NODE); diff --git a/OpenRoadEd/Qt/SettingsWidgets/SettingsGeometryParamPoly3.cpp b/OpenRoadEd/Qt/SettingsWidgets/SettingsGeometryParamPoly3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fb60ee69281b3e0b2b245a4a378025a6a8a9586e --- /dev/null +++ b/OpenRoadEd/Qt/SettingsWidgets/SettingsGeometryParamPoly3.cpp @@ -0,0 +1,351 @@ +#include "SettingsGeometryParamPoly3.h" +#include "moc_SettingsGeometryParamPoly3.cpp" + +/** + * Initializes the properties panel and the UI elements + */ +SettingsGeometryParamPoly3::SettingsGeometryParamPoly3(QWidget *parent ) +{ + // Resets the record + mParamPoly3=NULL; + + // Main vertical layout + QVBoxLayout *mainLayout = new QVBoxLayout; + + //------------------------------------------------- + // Group for settings + QGroupBox *settingsGroup = new QGroupBox; + settingsGroup->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum); + settingsGroup->setTitle(tr("Line geometry settings")); + + mS = new QLineEdit; + mS->setDisabled(true); + mX = new QDoubleSpinBox; + mX->setKeyboardTracking(false); + mX->setDecimals(9); + mX->setRange(-1000000,1000000); + mY = new QDoubleSpinBox; + mY->setKeyboardTracking(false); + mY->setDecimals(9); + mY->setRange(-1000000,1000000); + mHeading = new QDoubleSpinBox; + mHeading->setKeyboardTracking(false); + mHeading->setDecimals(9); + mHeading->setSingleStep(0.001); + mLength = new QDoubleSpinBox; + mLength->setKeyboardTracking(false); + mLength->setDecimals(9); + mLength->setRange(-1000000,1000000); + mAU = new QDoubleSpinBox; + mAU->setKeyboardTracking(false); + mAU->setDecimals(9); + mAU->setRange(-1000000,1000000); + mBU = new QDoubleSpinBox; + mBU->setKeyboardTracking(false); + mBU->setDecimals(9); + mBU->setRange(-1000000,1000000); + mCU = new QDoubleSpinBox; + mCU->setKeyboardTracking(false); + mCU->setDecimals(9); + mCU->setRange(-1000000,1000000); + mDU = new QDoubleSpinBox; + mDU->setKeyboardTracking(false); + mDU->setDecimals(9); + mDU->setRange(-1000000,1000000); + mAV = new QDoubleSpinBox; + mAV->setKeyboardTracking(false); + mAV->setDecimals(9); + mAV->setRange(-1000000,1000000); + mBV = new QDoubleSpinBox; + mBV->setKeyboardTracking(false); + mBV->setDecimals(9); + mBV->setRange(-1000000,1000000); + mCV = new QDoubleSpinBox; + mCV->setKeyboardTracking(false); + mCV->setDecimals(9); + mCV->setRange(-1000000,1000000); + mDV = new QDoubleSpinBox; + mDV->setKeyboardTracking(false); + mDV->setDecimals(9); + mDV->setRange(-1000000,1000000); + + // Form Layout inside group + QFormLayout *settingsFormLayout = new QFormLayout; + settingsFormLayout->addRow(tr("S:"),mS); + settingsFormLayout->addRow(tr("X position:"),mX); + settingsFormLayout->addRow(tr("Y position:"),mY); + settingsFormLayout->addRow(tr("Heading:"),mHeading); + settingsFormLayout->addRow(tr("Length:"),mLength); + settingsFormLayout->addRow(tr("aU:"),mAU); + settingsFormLayout->addRow(tr("bU:"),mBU); + settingsFormLayout->addRow(tr("cU:"),mCU); + settingsFormLayout->addRow(tr("dU:"),mDU); + settingsFormLayout->addRow(tr("aV:"),mAV); + settingsFormLayout->addRow(tr("bV:"),mBV); + settingsFormLayout->addRow(tr("cV:"),mCV); + settingsFormLayout->addRow(tr("dV:"),mDV); + + settingsGroup->setLayout(settingsFormLayout); + //------------------------------------------------- + // Group for help + QGroupBox *helpGroup = new QGroupBox; + helpGroup->setTitle(tr("Help")); + + QTextEdit *helpText = new QTextEdit; + helpText->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding); + helpText->setReadOnly(true); + helpText->setHtml("This record describes a straight line as part of the road’s chord line." + "<p><b>S</b> - start position (s-offset) [meters]</p>" + "<p><b>X</b> - start position X [meters]</p>" + "<p><b>Y</b> - start position Y [meters]</p>" + "<p><b>Heading</b> - start orientation [radians]</p>" + "<p><b>Length</b> - length of the chord line for this record [meters]</p>" + "<p><b>aU</b> - a coefficient for the parameteric polynomial in x </p>" + "<p><b>bU</b> - b coefficient for the parameteric polynomial in x </p>" + "<p><b>cU</b> - c coefficient for the parameteric polynomial in x </p>" + "<p><b>dU</b> - d coefficient for the parameteric polynomial in x </p>" + "<p><b>aV</b> - a coefficient for the parameteric polynomial in y </p>" + "<p><b>bV</b> - b coefficient for the parameteric polynomial in y </p>" + "<p><b>cV</b> - c coefficient for the parameteric polynomial in y </p>" + "<p><b>dV</b> - d coefficient for the parameteric polynomial in y </p>"); + + QVBoxLayout *helpLayout = new QVBoxLayout; + helpLayout->addWidget(helpText); + + helpGroup->setLayout(helpLayout); + //------------------------------------------------- + + mainLayout->addWidget(settingsGroup); + mainLayout->addWidget(helpGroup); + setLayout(mainLayout); +} + +/** + * Loads the data for a given record + * + * @param block Geometry block record whose properties are to be loaded + * @param first Set to true if it is the first record for this road + */ +void SettingsGeometryParamPoly3::LoadData(GeometryBlock *block) +{ + if(block!=NULL) + { + // Disconnects the "value changed" signals while the values are loaded + disconnect(mS, SIGNAL(textChanged(const QString &)), this, SLOT(SChanged())); + disconnect(mX, SIGNAL(valueChanged(double)), this, SLOT(XChanged(double))); + disconnect(mY, SIGNAL(valueChanged(double)), this, SLOT(YChanged(double))); + disconnect(mHeading, SIGNAL(valueChanged(double)), this, SLOT(HeadingChanged(double))); + disconnect(mLength, SIGNAL(valueChanged(double)), this, SLOT(LengthChanged(double))); + disconnect(mAU, SIGNAL(valueChanged(double)), this, SLOT(AUChanged(double))); + disconnect(mBU, SIGNAL(valueChanged(double)), this, SLOT(BUChanged(double))); + disconnect(mCU, SIGNAL(valueChanged(double)), this, SLOT(CUChanged(double))); + disconnect(mDU, SIGNAL(valueChanged(double)), this, SLOT(DUChanged(double))); + disconnect(mAV, SIGNAL(valueChanged(double)), this, SLOT(AVChanged(double))); + disconnect(mBV, SIGNAL(valueChanged(double)), this, SLOT(BVChanged(double))); + disconnect(mCV, SIGNAL(valueChanged(double)), this, SLOT(CVChanged(double))); + disconnect(mDV, SIGNAL(valueChanged(double)), this, SLOT(DVChanged(double))); + + // Sets the record properties to the input widgets + mParamPoly3=block; + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + mS->setText(QString("%1").arg(lGeometryParamPoly3->GetS())); + mX->setValue(lGeometryParamPoly3->GetX()); + mY->setValue(lGeometryParamPoly3->GetY()); + mHeading->setValue(lGeometryParamPoly3->GetHdg()); + mLength->setValue(lGeometryParamPoly3->GetLength()); + mAU->setValue(lGeometryParamPoly3->GetAu()); + mBU->setValue(lGeometryParamPoly3->GetBu()); + mCU->setValue(lGeometryParamPoly3->GetCu()); + mDU->setValue(lGeometryParamPoly3->GetDu()); + mAV->setValue(lGeometryParamPoly3->GetAv()); + mBV->setValue(lGeometryParamPoly3->GetBv()); + mCV->setValue(lGeometryParamPoly3->GetCv()); + mDV->setValue(lGeometryParamPoly3->GetDv()); + } + + // Connects the "value changed" signals back + connect(mS, SIGNAL(textChanged(const QString &)), this, SLOT(SChanged())); + connect(mX, SIGNAL(valueChanged(double)), this, SLOT(XChanged(double))); + connect(mY, SIGNAL(valueChanged(double)), this, SLOT(YChanged(double))); + connect(mHeading, SIGNAL(valueChanged(double)), this, SLOT(HeadingChanged(double))); + connect(mLength, SIGNAL(valueChanged(double)), this, SLOT(LengthChanged(double))); + connect(mAU, SIGNAL(valueChanged(double)), this, SLOT(AUChanged(double))); + connect(mBU, SIGNAL(valueChanged(double)), this, SLOT(BUChanged(double))); + connect(mCU, SIGNAL(valueChanged(double)), this, SLOT(CUChanged(double))); + connect(mDU, SIGNAL(valueChanged(double)), this, SLOT(DUChanged(double))); + connect(mAV, SIGNAL(valueChanged(double)), this, SLOT(AVChanged(double))); + connect(mBV, SIGNAL(valueChanged(double)), this, SLOT(BVChanged(double))); + connect(mCV, SIGNAL(valueChanged(double)), this, SLOT(CVChanged(double))); + connect(mDV, SIGNAL(valueChanged(double)), this, SLOT(DVChanged(double))); + } +} + +/** + * Makes this record the first for the road, thus enabling controls that only + * the first record has, such as the X and Y coordinates, which are otherwise + * computed automatically and are disabled + */ +void SettingsGeometryParamPoly3::SetFirst(bool first) +{ + if(first) + { + mX->setEnabled(true); + mY->setEnabled(true); + mHeading->setEnabled(true); + } + else + { + mX->setEnabled(false); + mY->setEnabled(false); + mHeading->setEnabled(false); + } +} + +/** + * Methods called when properties change + */ +void SettingsGeometryParamPoly3::SChanged() +{ + // Shouldn't be called + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetS(mS->text().toDouble()); + } +} +void SettingsGeometryParamPoly3::XChanged(double value) +{ + // Gets the first geometry record from the block + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + // Set the new value to the record's property + lGeometryParamPoly3->SetX(value); + // Emit the road changed signal so the road gets redrawn + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::YChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetY(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::HeadingChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetHdg(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::LengthChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetLength(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::AUChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetAu(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::BUChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetBu(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::CUChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetCu(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::DUChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetDu(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::AVChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetAv(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::BVChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetBv(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::CVChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetCv(value); + emit RoadGeometryChanged(true); + } +} +void SettingsGeometryParamPoly3::DVChanged(double value) +{ + // See the first method in this group for details + + GeometryParamPoly3 *lGeometryParamPoly3 = static_cast<GeometryParamPoly3*>(mParamPoly3->GetGeometryAt(0)); + if(lGeometryParamPoly3!=NULL) + { + lGeometryParamPoly3->SetDv(value); + emit RoadGeometryChanged(true); + } +} diff --git a/OpenRoadEd/Qt/SettingsWidgets/SettingsGeometryParamPoly3.h b/OpenRoadEd/Qt/SettingsWidgets/SettingsGeometryParamPoly3.h new file mode 100644 index 0000000000000000000000000000000000000000..70f9c7eb85c32e9b5f5d27428b004b0f25c0dd6c --- /dev/null +++ b/OpenRoadEd/Qt/SettingsWidgets/SettingsGeometryParamPoly3.h @@ -0,0 +1,87 @@ +#ifndef SETTINGSGEOMETRYPARAMPOLY3_H +#define SETTINGSGEOMETRYPARAMPOLY3_H + + +#include <QtGui/QWidget> +#include <QtGui/QtGui> + +#include "../../OpenDrive/RoadGeometry.h" + +/** + * Class that holds all the properties for the GEOMETRY_LINE record + * + */ +class SettingsGeometryParamPoly3 : public QWidget +{ + Q_OBJECT +public: + /** + * Initializes the properties panel and the UI elements + */ + SettingsGeometryParamPoly3(QWidget *parent = 0); + + /** + * Loads the data for a given record + * + * @param block Geometry block record whose properties are to be loaded + * @param first Set to true if it is the first record for this road + */ + void LoadData(GeometryBlock *block); + + /** + * Makes this record the first for the road, thus enabling controls that only + * the first record has, such as the X and Y coordinates, which are otherwise + * computed automatically and are disabled + */ + void SetFirst(bool first); +private: + /** + * Geometry record whose properties are to be displayed + */ + GeometryBlock *mParamPoly3; + + /** + * Interface widgets + */ + QLineEdit *mS; + QDoubleSpinBox *mX; + QDoubleSpinBox *mY; + QDoubleSpinBox *mHeading; + QDoubleSpinBox *mLength; + QDoubleSpinBox *mAU; + QDoubleSpinBox *mBU; + QDoubleSpinBox *mCU; + QDoubleSpinBox *mDU; + QDoubleSpinBox *mAV; + QDoubleSpinBox *mBV; + QDoubleSpinBox *mCV; + QDoubleSpinBox *mDV; + +public slots: + /** + * Methods called when properties change + */ + void SChanged(); + void XChanged(double value); + void YChanged(double value); + void HeadingChanged(double value); + void LengthChanged(double value); + void AUChanged(double value); + void BUChanged(double value); + void CUChanged(double value); + void DUChanged(double value); + void AVChanged(double value); + void BVChanged(double value); + void CVChanged(double value); + void DVChanged(double value); +signals: + /** + * Signal emitted when critical road items are changed + * that require that the road to be redrawn + * + * @param recalculateRoad Set to true if geometry records have to be recalculated (usualy true for this record) + */ + void RoadGeometryChanged(bool recalculateRoad); +}; + +#endif diff --git a/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.cpp b/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.cpp index a58cae9f859b33786632cdeafd9ed1ef69aef182..1125411bc5b5b96b15326d7e849418206a426d93 100644 --- a/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.cpp +++ b/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.cpp @@ -30,6 +30,8 @@ SettingsPage::SettingsPage(OpenDrive *openDrive,RoadTree *roadTree) mGeometryLine->hide(); mGeometryTurn = new SettingsGeometryTurn; mGeometryTurn->hide(); + mGeometryParamPoly3 = new SettingsGeometryParamPoly3; + mGeometryParamPoly3->hide(); mElevation = new SettingsElevationRecord; mElevation->hide(); mSuperElevation = new SettingsLateralProfileSuper; @@ -75,6 +77,7 @@ SettingsPage::SettingsPage(OpenDrive *openDrive,RoadTree *roadTree) mainLayout->addWidget(mRoadType); mainLayout->addWidget(mGeometryLine); mainLayout->addWidget(mGeometryTurn); + mainLayout->addWidget(mGeometryParamPoly3); mainLayout->addWidget(mElevation); mainLayout->addWidget(mSuperElevation); mainLayout->addWidget(mCrossfall); @@ -107,6 +110,7 @@ SettingsPage::SettingsPage(OpenDrive *openDrive,RoadTree *roadTree) connect(mRoadType, SIGNAL(RoadRoadTypeChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); connect(mGeometryLine, SIGNAL(RoadGeometryChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); connect(mGeometryTurn, SIGNAL(RoadGeometryChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); + connect(mGeometryParamPoly3, SIGNAL(RoadGeometryChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); connect(mElevation, SIGNAL(RoadElevationChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); connect(mSuperElevation, SIGNAL(RoadSuperElevationChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); connect(mCrossfall, SIGNAL(RoadCrossfallChanged(bool)), this, SLOT(OnRoadGeometryChanged(bool))); @@ -135,6 +139,7 @@ void SettingsPage::HideAll() mRoadType->hide(); mGeometryLine->hide(); mGeometryTurn->hide(); + mGeometryParamPoly3->hide(); mElevation->hide(); mSuperElevation->hide(); mCrossfall->hide(); @@ -206,6 +211,15 @@ void SettingsPage::OnGeometryTurnSelected(GeometryBlock *node, bool first) mGeometryTurn->LoadData(node); mGeometryTurn->SetFirst(first); } +void SettingsPage::OnGeometryParamPoly3Selected(GeometryBlock *node, bool first) +{ + // See the first few methods in this group for details + + HideAll(); + mGeometryParamPoly3->show(); + mGeometryParamPoly3->LoadData(node); + mGeometryParamPoly3->SetFirst(first); +} void SettingsPage::OnElevationSelected(Elevation *node, double minS, double maxS) { // See the first few methods in this group for details diff --git a/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.h b/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.h index 243edd3db927cced8ca980e53bc3764d6fa7a0c2..065d5954d31af5b9f8592f4d52b1f6021681c4a9 100644 --- a/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.h +++ b/OpenRoadEd/Qt/SettingsWidgets/SettingsPage.h @@ -14,6 +14,7 @@ #include "SettingsRoadTypeRecord.h" #include "SettingsGeometryLine.h" #include "SettingsGeometryTurn.h" +#include "SettingsGeometryParamPoly3.h" #include "SettingsElevationRecord.h" #include "SettingsLateralProfileSuper.h" #include "SettingsLateralProfileCrossfall.h" @@ -67,6 +68,7 @@ private: SettingsRoadTypeRecord *mRoadType; SettingsGeometryLine *mGeometryLine; SettingsGeometryTurn *mGeometryTurn; + SettingsGeometryParamPoly3 *mGeometryParamPoly3; SettingsElevationRecord *mElevation; SettingsLateralProfileSuper *mSuperElevation; SettingsLateralProfileCrossfall *mCrossfall; @@ -106,6 +108,7 @@ public slots: void OnRoadTypeSelected(RoadType *node, double minS, double maxS); void OnGeometryLineSelected(GeometryBlock *node, bool first); void OnGeometryTurnSelected(GeometryBlock *node, bool first); + void OnGeometryParamPoly3Selected(GeometryBlock *node, bool first); void OnElevationSelected(Elevation *node, double minS, double maxS); void OnSuperElevationSelected(SuperElevation *node, double minS, double maxS); void OnCrossfallSelected(Crossfall *node, double minS, double maxS); diff --git a/OpenRoadEd/Qt/Tree/RoadTree.cpp b/OpenRoadEd/Qt/Tree/RoadTree.cpp index cdb66612d3140a099532ab3ad830e87b591fa91d..37991e437997e75294ba1f504c2685c318dc752b 100644 --- a/OpenRoadEd/Qt/Tree/RoadTree.cpp +++ b/OpenRoadEd/Qt/Tree/RoadTree.cpp @@ -225,6 +225,7 @@ void RoadTree::FillInSelectionObject(RoadTreeItemBase *item) case ROAD_TYPE: case GEOMETRY_LINE: case GEOMETRY_TURN: + case GEOMETRY_PARAMPOLY3: case ELEVATION: case SUPERELEVATION: case CROSSFALL: @@ -375,7 +376,13 @@ void RoadTree::AddGeometry(int indexRoad, int indexGeometry, RoadTreeItem *&geom if(lRoad==NULL) return; disconnect(mTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(OnItemSelected())); if(select) mTreeWidget->clearSelection(); - int lType = GetRealGeometry(indexRoad, indexGeometry)->CheckIfLine(); + int lType; + if(GetRealGeometry(indexRoad, indexGeometry)->CheckIfLine()) + lType=1; + else if(GetRealGeometry(indexRoad, indexGeometry)->CheckIfParamPoly3()) + lType=4; + else + lType=2; lRoad->AddGeometryBlock(indexGeometry,geometry,lType); connect(mTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(OnItemSelected())); if(select) @@ -1949,7 +1956,13 @@ void RoadTree::LoadStructure(OpenDrive *openDrive) //========= GEOMETRY ==========// for(unsigned int iRoadGeometry=0; iRoadGeometry<openDrive->GetRoad(iRoad)->GetGeometryBlockCount(); iRoadGeometry++) { - int lType = GetRealGeometry(iRoad, iRoadGeometry)->CheckIfLine(); + int lType; + if(GetRealGeometry(iRoad, iRoadGeometry)->CheckIfLine()) + lType=1; + else if(GetRealGeometry(iRoad, iRoadGeometry)->CheckIfParamPoly3()) + lType=4; + else + lType=2; lRoad->AddGeometryBlock(iRoadGeometry, lType); } @@ -2163,6 +2176,17 @@ void RoadTree::OnItemActivation( QTreeWidgetItem * item, int column) if(lRoadGeometry!=NULL) emit GeometryTurnSelected(lRoadGeometry, lFirst); break; } + case GEOMETRY_PARAMPOLY3: + { + GeometryBlock *lRoadGeometry = GetRealGeometry(); + + bool lFirst=false; + if(mSelection[1]==0) lFirst=true; + + if(lRoadGeometry!=NULL) emit GeometryTurnSelected(lRoadGeometry, lFirst); + break; + } + case ELEVATION: { Elevation *lElevation=GetRealElevation(); diff --git a/OpenRoadEd/Qt/Tree/RoadTree.h b/OpenRoadEd/Qt/Tree/RoadTree.h index 444e8720e83b53786bd0f9142ed61ceefaa83601..2f6f91d976bfdd8a3dcf0b822f276e04d9cf9c48 100644 --- a/OpenRoadEd/Qt/Tree/RoadTree.h +++ b/OpenRoadEd/Qt/Tree/RoadTree.h @@ -414,6 +414,7 @@ signals: void RoadTypeSelected(RoadType *node, double minS, double maxS); void GeometryLineSelected(GeometryBlock *node, bool first); void GeometryTurnSelected(GeometryBlock *node, bool first); + void GeometryParamPoly3Selected(GeometryBlock *node, bool first); void ElevationSelected(Elevation *node, double minS, double maxS); void SuperElevationSelected(SuperElevation *node, double minS, double maxS); void CrossfallSelected(Crossfall *node, double minS, double maxS); diff --git a/OpenRoadEd/Qt/Tree/RoadTreeItems.cpp b/OpenRoadEd/Qt/Tree/RoadTreeItems.cpp index 1112d0d7df0884ee2e188d5dd349d07070c7e3eb..77ebfcd595364222de33c3a9d2211f4d30e43b95 100644 --- a/OpenRoadEd/Qt/Tree/RoadTreeItems.cpp +++ b/OpenRoadEd/Qt/Tree/RoadTreeItems.cpp @@ -91,6 +91,10 @@ void RoadTreeItemBase::ColorCode(bool enable) setBackground(0,RoadTreeItemConfig::GeometryColor()); setIcon(0,QIcon(":/Icons/Turn.png")); break; + case GEOMETRY_PARAMPOLY3: + setBackground(0,RoadTreeItemConfig::GeometryColor()); + setIcon(0,QIcon(":/Icons/Line.png")); + break; case ELEVATION: setBackground(0,RoadTreeItemConfig::ElevationColor()); setIcon(0,QIcon(":/Icons/Elevation.png")); @@ -377,6 +381,9 @@ void RoadTreeItem::SetTextByType() case GEOMETRY_TURN: setText(0,QString("Geometry %1: Turn").arg(mIndex)); break; + case GEOMETRY_PARAMPOLY3: + setText(0,QString("Geometry %1: ParamPoly3").arg(mIndex)); + break; case ELEVATION: setText(0,QString("Elevation %1").arg(mIndex)); break; @@ -564,7 +571,8 @@ void RTIRoad::AddGeometryBlock(int index, int type) void RTIRoad::AddGeometryBlock(int index, RoadTreeItem *&roadGeometry, int type) { RoadTreeItemType lGType; - if(type) lGType=GEOMETRY_LINE; + if(type==1) lGType=GEOMETRY_LINE; + else if(type==4) lGType=GEOMETRY_PARAMPOLY3; else lGType=GEOMETRY_TURN; if(index>=mGeometryBlockContainer->childCount()) diff --git a/OpenRoadEd/Qt/Tree/RoadTreeItems.h b/OpenRoadEd/Qt/Tree/RoadTreeItems.h index 57909a2e153153b2b051cf8f7a98135bbb709bcf..1008d046892c52665426af7eb1360847d0a3d82f 100644 --- a/OpenRoadEd/Qt/Tree/RoadTreeItems.h +++ b/OpenRoadEd/Qt/Tree/RoadTreeItems.h @@ -52,6 +52,7 @@ enum RoadTreeItemType GEOMETRY_CONTAINER, GEOMETRY_LINE, GEOMETRY_TURN, + GEOMETRY_PARAMPOLY3, ELEVATION_CONTAINER, ELEVATION, SUPERELEVATION_CONTAINER,