diff --git a/chart_plugin/src/common/chart_display_base.h b/chart_plugin/src/common/chart_display_base.h index bcd4e3c2147a481bb7d7ff9724b7944244ee3bda..580939ee1824ca6154b0fa6ddbe5dd81a751a88c 100755 --- a/chart_plugin/src/common/chart_display_base.h +++ b/chart_plugin/src/common/chart_display_base.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020, Huawei Technologies Co., Ltd +Copyright (c) 2020-2022, Huawei Technologies Co., Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the @@ -135,6 +135,7 @@ protected: void IncomingMessage(const typename MessageType::ConstPtr &msg) { if (!msg) { + ProcessMessage(msg); return; } diff --git a/chart_plugin/src/curve_display.cpp b/chart_plugin/src/curve_display.cpp index eea1c79cb6edb819066b203353d9efc59e643fc0..55597ff578443a74304ffa044221a5f78cabd3b1 100755 --- a/chart_plugin/src/curve_display.cpp +++ b/chart_plugin/src/curve_display.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd +Copyright (c) 2020-2022, Huawei Technologies Co., Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the @@ -39,6 +39,7 @@ namespace chart_plugin { using rviz::ColorProperty; using rviz::Config; using rviz::EnumProperty; +using rviz::FloatProperty; using rviz::IntProperty; using rviz::Property; using rviz::StatusProperty; @@ -47,15 +48,15 @@ using rviz::StringProperty; const int32_t FIRST_CURVE_COLOR_R = 0xF5; const int32_t FIRST_CURVE_COLOR_G = 0xF2; const int32_t FIRST_CURVE_COLOR_B = 0x2E; -const int32_t FIRST_CURVE_COLOR_ALPHA = 0xFF; +const qreal FIRST_CURVE_COLOR_ALPHA = 0x01; const int32_t SECOND_CURVE_COLOR_R = 0xFF; const int32_t SECOND_CURVE_COLOR_G = 0x3B; const int32_t SECOND_CURVE_COLOR_B = 0x3B; -const int32_t SECOND_CURVE_COLOR_ALPHA = 0xFF; +const qreal SECOND_CURVE_COLOR_ALPHA = 0x01; const int32_t COLOR_ALPHA_MIN = 0x00; -const int32_t COLOR_ALPHA_MAX = 0xFF; +const int32_t COLOR_ALPHA_MAX = 0x01; const qreal CURVE_PEN_WIDTH = 0x02; @@ -85,51 +86,27 @@ enum CurveType { void CurveDisplay::InitTitleProperty() { - qwtPlotTitleProperty = new (std::nothrow) StringProperty("Chart Title", "Curve Chart", "Chart title name property.", + qwtPlotTitleProperty = new StringProperty("Chart Title", "Curve Chart", "Chart title name property.", this, SLOT(UpdateChartTitle()), this); - if (qwtPlotTitleProperty == nullptr) { - ROS_ERROR("Failed to create the qwtPlotTitleProperty."); - return; - } - xAxisTitleProperty = new (std::nothrow) + xAxisTitleProperty = new StringProperty("X Axis Title", "X", "X Axis title name property.", this, SLOT(UpdateXAxisTitle()), this); - if (xAxisTitleProperty == nullptr) { - ROS_ERROR("Failed to create the xAxisTitleProperty."); - return; - } - yAxisTitleProperty = new (std::nothrow) + yAxisTitleProperty = new StringProperty("Y Axis Title", "Y", "Y Axis title name property.", this, SLOT(UpdateYAxisTitle()), this); - if (yAxisTitleProperty == nullptr) { - ROS_ERROR("Failed to create the yAxisTitleProperty."); - return; - } } void CurveDisplay::InitFirstCurveProperty(EnumProperty &curveProperty) { - firstCurveTitleProperty = new (std::nothrow) StringProperty("First Curve Title", "First Curve", + firstCurveTitleProperty = new StringProperty("First Curve Title", "First Curve", "First curve title property setting.", &curveProperty, SLOT(UpdateCurveTitle()), this); - if (firstCurveTitleProperty == nullptr) { - ROS_ERROR("Failed to create the firstCurveTitleProperty."); - return; - } - firstCurveColorProperty = new (std::nothrow) + firstCurveColorProperty = new ColorProperty("First Curve Color", QColor(FIRST_CURVE_COLOR_R, FIRST_CURVE_COLOR_G, FIRST_CURVE_COLOR_B), "Color of the first Curve setting.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (firstCurveColorProperty == nullptr) { - ROS_ERROR("Failed to create the firstCurveColorProperty."); - return; - } - firstCurveAlphaProperty = new (std::nothrow) IntProperty("First Curve Alpha", FIRST_CURVE_COLOR_ALPHA, + firstCurveAlphaProperty = new FloatProperty("First Curve Alpha", FIRST_CURVE_COLOR_ALPHA, "First curve alpha property setting.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (firstCurveAlphaProperty == nullptr) { - ROS_ERROR("Failed to create the firstCurveAlphaProperty."); - return; - } firstCurveAlphaProperty->setMin(COLOR_ALPHA_MIN); firstCurveAlphaProperty->setMax(COLOR_ALPHA_MAX); @@ -137,27 +114,15 @@ void CurveDisplay::InitFirstCurveProperty(EnumProperty &curveProperty) void CurveDisplay::InitSecondCurveProperty(EnumProperty &curveProperty) { - secondCurveTitleProperty = new (std::nothrow) StringProperty("Second Curve Title", "Second Curve", + secondCurveTitleProperty = new StringProperty("Second Curve Title", "Second Curve", "Second curve title property setting.", &curveProperty, SLOT(UpdateCurveTitle()), this); - if (secondCurveTitleProperty == nullptr) { - ROS_ERROR("Failed to create the secondCurveTitleProperty."); - return; - } - secondCurveColorProperty = new (std::nothrow) + secondCurveColorProperty = new ColorProperty("Second Curve Color", QColor(SECOND_CURVE_COLOR_R, SECOND_CURVE_COLOR_G, SECOND_CURVE_COLOR_B), "Color of the Second Curve setting.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (secondCurveColorProperty == nullptr) { - ROS_ERROR("Failed to create the secondCurveColorProperty."); - return; - } - secondCurveAlphaProperty = new (std::nothrow) IntProperty("Second Curve Alpha", SECOND_CURVE_COLOR_ALPHA, + secondCurveAlphaProperty = new FloatProperty("Second Curve Alpha", SECOND_CURVE_COLOR_ALPHA, "Second Curve alpha property setting.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (secondCurveAlphaProperty == nullptr) { - ROS_ERROR("Failed to create the secondCurveAlphaProperty."); - return; - } secondCurveAlphaProperty->setMin(COLOR_ALPHA_MIN); secondCurveAlphaProperty->setMax(COLOR_ALPHA_MAX); @@ -165,12 +130,8 @@ void CurveDisplay::InitSecondCurveProperty(EnumProperty &curveProperty) void CurveDisplay::InitCurveProperty() { - curveProperty = new (std::nothrow) + curveProperty = new EnumProperty("Curve", "First Curve", "Curve type setting selection.", this, SLOT(UpdateCurveChoice())); - if (curveProperty == nullptr) { - ROS_ERROR("Failed to create the curveProperty."); - return; - } curveProperty->addOption("First Curve", FIRST_CURVE); curveProperty->addOption("Second Curve", SECOND_CURVE); @@ -189,27 +150,19 @@ void CurveDisplay::UpdateCurveColorAndAlpha() { QColor colorFirstCurve = firstCurveColorProperty->getColor(); QColor colorSecondCurve = secondCurveColorProperty->getColor(); - int32_t alphaFirstCurve = firstCurveAlphaProperty->getInt(); - int32_t alphaOptimizedCurve = secondCurveAlphaProperty->getInt(); - colorFirstCurve.setAlpha(alphaFirstCurve); - colorSecondCurve.setAlpha(alphaOptimizedCurve); + qreal alphaFirstCurve = firstCurveAlphaProperty->getFloat(); + qreal alphaOptimizedCurve = secondCurveAlphaProperty->getFloat(); + colorFirstCurve.setAlpha(alphaFirstCurve * 0xFF); + colorSecondCurve.setAlpha(alphaOptimizedCurve * 0xFF); firstCurve.setPen(colorFirstCurve, CURVE_PEN_WIDTH); secondCurve.setPen(colorSecondCurve, CURVE_PEN_WIDTH); - QwtSymbol *firstSymbol = new (std::nothrow) QwtSymbol(QwtSymbol::Ellipse, QBrush(colorFirstCurve), + QwtSymbol *firstSymbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(colorFirstCurve), QPen(colorFirstCurve, CURVE_SYMBOL_PEN_WIDTH), QSize(CURVE_SYMBOL_SIZE_WIDTH, CURVE_SYMBOL_SIZE_HRIGHT)); - if (firstSymbol == nullptr) { - ROS_ERROR("Failed to create the firstSymbol of QwtSymbol."); - return; - } firstCurve.setSymbol(firstSymbol); - QwtSymbol *optimizedSymbol = new (std::nothrow) QwtSymbol(QwtSymbol::Ellipse, QBrush(colorSecondCurve), + QwtSymbol *optimizedSymbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(colorSecondCurve), QPen(colorSecondCurve, CURVE_SYMBOL_PEN_WIDTH), QSize(CURVE_SYMBOL_SIZE_WIDTH, CURVE_SYMBOL_SIZE_HRIGHT)); - if (optimizedSymbol == nullptr) { - ROS_ERROR("Failed to create the optimizedSymbol of QwtSymbol."); - return; - } secondCurve.setSymbol(optimizedSymbol); ui.qwtPlot->replot(); @@ -324,11 +277,7 @@ void CurveDisplay::InitQwtPlotStyle() titleText.setFont(textFont); ui.qwtPlot->setTitle(titleText); // 设置图例的位置 - QwtLegend *legend = new (std::nothrow) QwtLegend(); - if (legend == nullptr) { - ROS_ERROR("Failed to create the legend of QwtLegend."); - return; - } + QwtLegend *legend = new QwtLegend(); ui.qwtPlot->insertLegend(legend, QwtPlot::BottomLegend); @@ -349,14 +298,14 @@ void CurveDisplay::InitQwtPlotStyle() } void CurveDisplay::InitCurveStyle(QwtPlotCurve &curvePlot, StringProperty &titleProperty, - const ColorProperty &colorProperty, const IntProperty &alphaProperty) + const ColorProperty &colorProperty, const FloatProperty &alphaProperty) { // 图例名字 curvePlot.setTitle(titleProperty.getString()); QColor colorCurve = colorProperty.getColor(); - int32_t alphaCurve = alphaProperty.getInt(); - colorCurve.setAlpha(alphaCurve); + qreal alphaCurve = alphaProperty.getFloat(); + colorCurve.setAlpha(alphaCurve * 0xFF); // 设置画笔 curvePlot.setPen(colorCurve, CURVE_PEN_WIDTH); @@ -365,12 +314,8 @@ void CurveDisplay::InitCurveStyle(QwtPlotCurve &curvePlot, StringProperty &title // 显示图例的标志,这里显示线的颜色 // 设置样本点的颜色、大小 - QwtSymbol *symbol = new (std::nothrow) QwtSymbol(QwtSymbol::Ellipse, QBrush(colorCurve), + QwtSymbol *symbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(colorCurve), QPen(colorCurve, CURVE_SYMBOL_PEN_WIDTH), QSize(CURVE_SYMBOL_SIZE_WIDTH, CURVE_SYMBOL_SIZE_HRIGHT)); - if (symbol == nullptr) { - ROS_ERROR("Failed to Create the symbol of QwtSymbol."); - return; - } // 添加样本点形状 curvePlot.setSymbol(symbol); diff --git a/chart_plugin/src/curve_display.h b/chart_plugin/src/curve_display.h index 9b800638d795141b334f25cc706952bed659aad2..800b132471e99a5f4828f11c3e2a3030e5d652c5 100755 --- a/chart_plugin/src/curve_display.h +++ b/chart_plugin/src/curve_display.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd +Copyright (c) 2020-2022, Huawei Technologies Co., Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the @@ -30,6 +30,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include @@ -209,7 +210,7 @@ private: * 返回值:无 */ void InitCurveStyle(QwtPlotCurve &curvePlot, rviz::StringProperty &titleProperty, - const rviz::ColorProperty &colorProperty, const rviz::IntProperty &alphaProperty); + const rviz::ColorProperty &colorProperty, const rviz::FloatProperty &alphaProperty); /* * 功能:根据输入参数font、字符串text和显示区域宽度displayAreaWidth值来处理字符串text为省略文本显示风格 @@ -235,10 +236,10 @@ private: rviz::EnumProperty *curveProperty { nullptr }; rviz::StringProperty *firstCurveTitleProperty { nullptr }; rviz::ColorProperty *firstCurveColorProperty { nullptr }; - rviz::IntProperty *firstCurveAlphaProperty { nullptr }; + rviz::FloatProperty *firstCurveAlphaProperty { nullptr }; rviz::StringProperty *secondCurveTitleProperty { nullptr }; rviz::ColorProperty *secondCurveColorProperty { nullptr }; - rviz::IntProperty *secondCurveAlphaProperty { nullptr }; + rviz::FloatProperty *secondCurveAlphaProperty { nullptr }; }; } // namespace chart_plugin diff --git a/chart_plugin/src/slt_space/ui_slt_widget.cpp b/chart_plugin/src/slt_space/ui_slt_widget.cpp index d5c4018bfba5c6a133c32ddbf57226d021e78379..e543b6134f6e35c955f81ed60229f393a961b481 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.cpp +++ b/chart_plugin/src/slt_space/ui_slt_widget.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd +Copyright (c) 2020-2022, Huawei Technologies Co., Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the @@ -95,19 +95,11 @@ void UiSltWidget::SetupWidgetMathGlUi(QWidget &widgetMathGl) { widgetMathGl.setObjectName(QStringLiteral("widgetMathGl")); widgetMathGl.setMinimumSize(QSize(WIDGET_MATHGL_MIN_WIDTH, WIDGET_MATHGL_MIN_HEIGHT)); - qMathGl = new (std::nothrow) QMathGL(&widgetMathGl); - if (qMathGl == nullptr) { - ROS_ERROR("Failed to Create the qMathGl of QMathGL."); - return; - } + qMathGl = new MathGL(&widgetMathGl); qMathGl->setObjectName(QStringLiteral("qMathGl")); qMathGl->setStyleSheet(QStringLiteral("background-color: rgb(20, 21, 24);")); - restoreButton = new (std::nothrow) QPushButton(qMathGl); - if (restoreButton == nullptr) { - ROS_ERROR("Failed to Create the restoreButton of QPushButton."); - return; - } + restoreButton = new QPushButton(qMathGl); restoreButton->setObjectName(QStringLiteral("restoreButton")); restoreButton->setGeometry(QRect(BUTTON_POSITION_X, BUTTON_POSITION_Y, BUTTON_WIDTH, BUTTON_HEIGHT)); @@ -127,20 +119,11 @@ void UiSltWidget::SetupScrollAreaUi(QScrollArea &scrollArea) scrollArea.setFrameShape(QFrame::NoFrame); scrollArea.setLineWidth(1); // 设置边框线宽值为1 scrollArea.setWidgetResizable(true); - scrollAreaWidgetContents = new (std::nothrow) QWidget(&scrollArea); - - if (scrollAreaWidgetContents == nullptr) { - ROS_ERROR("Failed to Create the scrollAreaWidgetContents of QWidget."); - return; - } + scrollAreaWidgetContents = new QWidget(&scrollArea); scrollAreaWidgetContents->setObjectName(QStringLiteral("scrollAreaWidgetContents")); scrollAreaWidgetContents->setStyleSheet(SCROLLAREA_WIDGET_STYLE_SHEET); - gridLayout = new (std::nothrow) QGridLayout(scrollAreaWidgetContents); - if (gridLayout == nullptr) { - ROS_ERROR("Failed to Create the gridLayout of QGridLayout."); - return; - } + gridLayout = new QGridLayout(scrollAreaWidgetContents); gridLayout->setSpacing(GRIDLAYOUT_PACING); gridLayout->setObjectName(QStringLiteral("gridLayout")); @@ -158,26 +141,14 @@ void UiSltWidget::SetupUi(QWidget *widget) } SetupWidgetUi(*widget); - verticalLayout = new (std::nothrow) QVBoxLayout(widget); - if (verticalLayout == nullptr) { - ROS_ERROR("Failed to Create the verticalLayout of QVBoxLayout."); - return; - } + verticalLayout = new QVBoxLayout(widget); SetupVerticalLayoutUi(*verticalLayout); - widgetMathGl = new (std::nothrow) QWidget(widget); - if (widgetMathGl == nullptr) { - ROS_ERROR("Failed to Create the widgetMathGl of QWidget."); - return; - } + widgetMathGl = new QWidget(widget); SetupWidgetMathGlUi(*widgetMathGl); verticalLayout->addWidget(widgetMathGl); - scrollArea = new (std::nothrow) QScrollArea(widget); - if (scrollArea == nullptr) { - ROS_ERROR("Failed to Create the scrollArea of QScrollArea."); - return; - } + scrollArea = new QScrollArea(widget); SetupScrollAreaUi(*scrollArea); verticalLayout->addWidget(scrollArea); @@ -186,4 +157,106 @@ void UiSltWidget::SetupUi(QWidget *widget) // 设置滚动区域窗口拉伸比例系数 verticalLayout->setStretch(1, VERTICALL_LAYOUT_STRETCH_SCROLLAREA); } + +void chart_plugin::MathGL::wheelEvent(QWheelEvent *event) +{ + if(!enableWheel) { + event->ignore(); + return; + } + + if(rotate) { + const float scaleSize = -0.001; + // 2代表取平均值 + mreal exponential = exp(scaleSize * event->delta()) / 2; + mreal diff = (y2 - y1) * exponential; + // 2代表取平均值 + mreal sum = (y2 + y1) / 2; + y1 = sum - diff; + y2 = sum + diff; + diff = (x2 - x1) * exponential; + // 2代表取平均值 + sum = (x2 + x1) / 2; + x1 = sum - diff; + x2 = sum + diff; + refresh(); + event->accept(); + return; + } + const float scaleSize = 0.001; + // 2代表取平均值 + mreal exponential = exp(scaleSize * event->delta()) / 2; + mreal diff = (ay2 - ay1) * exponential; + // 2代表取平均值 + mreal sum = (ay2 + ay1) / 2; + ay1 = sum - diff; + ay2 = sum + diff; + diff = (ax2 - ax1) * exponential; + // 2代表取平均值 + sum = (ax2 + ax1) / 2; + ax1 = sum - diff; + ax2 = sum + diff; + mgl_zoom_axis((HMGL)gr, ax1, ay1, 0, 0, ax2, ay2, 0, 0); + update(); + event->accept(); +} + +void MathGL::mousePressEvent(QMouseEvent *event) +{ + posX = event->x(); + posY = event->y(); + x = event->x(); + y = event->y(); + QMathGL::mousePressEvent(event); +} + +void MathGL::mouseMoveEvent(QMouseEvent *event) +{ + if(!rotate || !(event->buttons() & Qt::LeftButton)) { + QMathGL::mouseMoveEvent(event); + return; + } + + int32_t pi = 360; + int32_t halfPi = 180; + // 2代表取高度的一半 + int32_t halfHeight = height() / 2; + x = event->x(); + y = event->y(); + + tet += static_cast(halfPi * (posY - y) / sqrt(mreal(width() * height()))); + if (tet > halfPi) { + tet -= pi; + } else if (tet < -halfPi) { + tet += pi; + } + + if (event->y() < halfHeight) { + phi -= static_cast(halfPi * (posX - x) / sqrt(mreal(width() * height()))); + } else if (event->y() > halfHeight) { + phi += static_cast(halfPi * (posX - x) / sqrt(mreal(width() * height()))); + } + + if (phi > halfPi) { + phi -= pi; + } else if (phi < -halfPi) { + phi += pi; + } + emit tetChanged(static_cast(tet)); + emit phiChanged(static_cast(phi)); + posX = x; + posY = y; + refresh(); +} + +void MathGL::mouseReleaseEvent(QMouseEvent *event) +{ + if ((event->button() & Qt::LeftButton) && enableMouse) { + if (zoom) { + posX = x; + posY = y; + } + } + QMathGL::mouseReleaseEvent(event); +} } // namespace chart_plugin diff --git a/chart_plugin/src/slt_space/ui_slt_widget.h b/chart_plugin/src/slt_space/ui_slt_widget.h index 6306aff280120a61277ff6cc79ea2d0d7aefc1bd..a08263d657566a51e3fb5ec5dcebc3f370328ba2 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.h +++ b/chart_plugin/src/slt_space/ui_slt_widget.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd +Copyright (c) 2020-2022, Huawei Technologies Co., Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the @@ -32,10 +32,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include namespace chart_plugin { +class MathGL; class UiSltWidget { public: UiSltWidget() = default; @@ -116,7 +118,7 @@ private: private: QVBoxLayout *verticalLayout { nullptr }; - QMathGL *qMathGl { nullptr }; + MathGL *qMathGl { nullptr }; QWidget *widgetMathGl { nullptr }; QPushButton *restoreButton { nullptr }; @@ -124,6 +126,24 @@ private: QWidget *scrollAreaWidgetContents { nullptr }; QGridLayout *gridLayout { nullptr }; }; + +class MathGL : public QMathGL { +public: + explicit MathGL(QWidget *parent = nullptr, Qt::WindowFlags flag = 0) : QMathGL(parent, flag) {} + ~MathGL() override = default; + +protected: + void wheelEvent(QWheelEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + +private: + int32_t posX {}; + int32_t posY {}; + int32_t x {}; + int32_t y {}; +}; } #endif // UI_SLT_WIDGET_H diff --git a/chart_plugin/src/st_space_display.cpp b/chart_plugin/src/st_space_display.cpp index d7589f65acebb4fca94225f30125b289c23cf1db..a70738241e4ee62af2d719fbde5e17c2615dd255 100755 --- a/chart_plugin/src/st_space_display.cpp +++ b/chart_plugin/src/st_space_display.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd +Copyright (c) 2020-2022, Huawei Technologies Co., Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the @@ -35,6 +35,7 @@ using rviz::ColorProperty; using rviz::Config; using rviz::EnumProperty; using rviz::IntProperty; +using rviz::FloatProperty; using rviz::Property; using rviz::StatusProperty; using rviz::StringProperty; @@ -46,20 +47,20 @@ using std::unique_ptr; const int32_t FIRST_CURVE_COLOR_R = 0xF5; const int32_t FIRST_CURVE_COLOR_G = 0xF2; const int32_t FIRST_CURVE_COLOR_B = 0x2E; -const int32_t FIRST_CURVE_COLOR_ALPHA = 0xFF; +const qreal FIRST_CURVE_COLOR_ALPHA = 0x01; const int32_t OPTIMIZED_CURVE_COLOR_R = 0xFF; const int32_t OPTIMIZED_CURVE_COLOR_G = 0x3B; const int32_t OPTIMIZED_CURVE_COLOR_B = 0x3B; -const int32_t OPTIMIZED_CURVE_COLOR_ALPHA = 0xFF; +const qreal OPTIMIZED_CURVE_COLOR_ALPHA = 0x01; const int32_t SPEED_LIMIT_CURVE_COLOR_R = 0x00; const int32_t SPEED_LIMIT_CURVE_COLOR_G = 0xFF; const int32_t SPEED_LIMIT_CURVE_COLOR_B = 0xC1; -const int32_t SPEED_LIMIT_CURVE_COLOR_ALPHA = 0xFF; +const qreal SPEED_LIMIT_CURVE_COLOR_ALPHA = 0x01; const int32_t COLOR_ALPHA_MIN = 0x00; -const int32_t COLOR_ALPHA_MAX = 0xFF; +const int32_t COLOR_ALPHA_MAX = 0x01; const int32_t COLOR_MIN = 0x00; const int32_t COLOR_MAX = 0xFF; @@ -98,54 +99,30 @@ enum CurveType { void StSpaceDisplay::InitTitleProperty() { - qwtPlotTitleProperty = new (std::nothrow) + qwtPlotTitleProperty = new StringProperty("Chart Title", "ST图", "Chart title name property.", this, SLOT(UpdateChartTitle()), this); - if (qwtPlotTitleProperty == nullptr) { - ROS_ERROR("Failed to Create the qwtPlotTitleProperty of StringProperty."); - return; - } qwtPlotTitleProperty->setReadOnly(true); - xAxisTitleProperty = new (std::nothrow) + xAxisTitleProperty = new StringProperty("X Axis Title", "T [s]", "X Axis title name property.", this, SLOT(UpdateXAxisTitle()), this); - if (xAxisTitleProperty == nullptr) { - ROS_ERROR("Failed to Create the xAxisTitleProperty of StringProperty."); - return; - } xAxisTitleProperty->setReadOnly(true); - yAxisTitleProperty = new (std::nothrow) + yAxisTitleProperty = new StringProperty("Y Axis Title", "S [m]", "Y Axis title name property.", this, SLOT(UpdateYAxisTitle()), this); - if (yAxisTitleProperty == nullptr) { - ROS_ERROR("Failed to Create the yAxisTitleProperty of StringProperty."); - return; - } yAxisTitleProperty->setReadOnly(true); } void StSpaceDisplay::InitFirstCurveProperty(EnumProperty &curveProperty) { - firstCurveTitleProperty = new (std::nothrow) StringProperty("First Title", "First Track", + firstCurveTitleProperty = new StringProperty("First Title", "First Track", "First curve title property setting.", &curveProperty, SLOT(UpdateCurveTitle()), this); - if (firstCurveTitleProperty == nullptr) { - ROS_ERROR("Failed to Create the firstCurveTitleProperty of StringProperty."); - return; - } - firstCurveColorProperty = new (std::nothrow) + firstCurveColorProperty = new ColorProperty("First Color", QColor(FIRST_CURVE_COLOR_R, FIRST_CURVE_COLOR_G, FIRST_CURVE_COLOR_B), "Color of the first Curve.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (firstCurveColorProperty == nullptr) { - ROS_ERROR("Failed to Create the firstCurveColorProperty of ColorProperty."); - return; - } - firstCurveAlphaProperty = new (std::nothrow) IntProperty("First Alpha", FIRST_CURVE_COLOR_ALPHA, + firstCurveAlphaProperty = new FloatProperty("First Alpha", FIRST_CURVE_COLOR_ALPHA, "First curve alpha property setting.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (firstCurveAlphaProperty == nullptr) { - ROS_ERROR("Failed to Create the firstCurveAlphaProperty of IntProperty."); - return; - } firstCurveAlphaProperty->setMin(COLOR_ALPHA_MIN); firstCurveAlphaProperty->setMax(COLOR_ALPHA_MAX); @@ -153,27 +130,15 @@ void StSpaceDisplay::InitFirstCurveProperty(EnumProperty &curveProperty) void StSpaceDisplay::InitSecondCurveProperty(EnumProperty &curveProperty) { - optimizedCurveTitleProperty = new (std::nothrow) StringProperty("Optimized Title", "Optimized Track", + optimizedCurveTitleProperty = new StringProperty("Optimized Title", "Optimized Track", "Optimized curve title property setting.", &curveProperty, SLOT(UpdateCurveTitle()), this); - if (optimizedCurveTitleProperty == nullptr) { - ROS_ERROR("Failed to Create the optimizedCurveTitleProperty of StringProperty."); - return; - } - optimizedCurveColorProperty = new (std::nothrow) ColorProperty("Optimized Color", + optimizedCurveColorProperty = new ColorProperty("Optimized Color", QColor(OPTIMIZED_CURVE_COLOR_R, OPTIMIZED_CURVE_COLOR_G, OPTIMIZED_CURVE_COLOR_B), "Color of the Optimized St Track Curve.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (optimizedCurveColorProperty == nullptr) { - ROS_ERROR("Failed to Create the optimizedCurveColorProperty of ColorProperty."); - return; - } - optimizedCurveAlphaProperty = new (std::nothrow) IntProperty("Optimized Alpha", OPTIMIZED_CURVE_COLOR_ALPHA, + optimizedCurveAlphaProperty = new FloatProperty("Optimized Alpha", OPTIMIZED_CURVE_COLOR_ALPHA, "Optimized St Track curve alpha property setting.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (optimizedCurveAlphaProperty == nullptr) { - ROS_ERROR("Failed to Create the optimizedCurveAlphaProperty of IntProperty."); - return; - } optimizedCurveAlphaProperty->setMin(COLOR_ALPHA_MIN); optimizedCurveAlphaProperty->setMax(COLOR_ALPHA_MAX); @@ -181,27 +146,15 @@ void StSpaceDisplay::InitSecondCurveProperty(EnumProperty &curveProperty) void StSpaceDisplay::InitSpeedLimitCurveProperty(EnumProperty &curveProperty) { - speedLimitCurveTitleProperty = new (std::nothrow) StringProperty("Speed Title", "St Speed Limit", + speedLimitCurveTitleProperty = new StringProperty("Speed Title", "St Speed Limit", "St Speed Limit curve title property setting.", &curveProperty, SLOT(UpdateCurveTitle()), this); - if (speedLimitCurveTitleProperty == nullptr) { - ROS_ERROR("Failed to Create the speedLimitCurveTitleProperty of StringProperty."); - return; - } - speedLimitCurveColorProperty = new (std::nothrow) ColorProperty("Speed Color", + speedLimitCurveColorProperty = new ColorProperty("Speed Color", QColor(SPEED_LIMIT_CURVE_COLOR_R, SPEED_LIMIT_CURVE_COLOR_G, SPEED_LIMIT_CURVE_COLOR_B), "Color of the St Speed Limit Curve.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (speedLimitCurveColorProperty == nullptr) { - ROS_ERROR("Failed to Create the speedLimitCurveColorProperty of ColorProperty."); - return; - } - speedLimitCurveAlphaProperty = new (std::nothrow) IntProperty("Speed Alpha", SPEED_LIMIT_CURVE_COLOR_ALPHA, + speedLimitCurveAlphaProperty = new FloatProperty("Speed Alpha", SPEED_LIMIT_CURVE_COLOR_ALPHA, "St Speed Limit curve alpha property setting.", &curveProperty, SLOT(UpdateCurveColorAndAlpha()), this); - if (speedLimitCurveAlphaProperty == nullptr) { - ROS_ERROR("Failed to Create the speedLimitCurveAlphaProperty of IntProperty."); - return; - } speedLimitCurveAlphaProperty->setMin(COLOR_ALPHA_MIN); speedLimitCurveAlphaProperty->setMax(COLOR_ALPHA_MAX); @@ -210,12 +163,8 @@ void StSpaceDisplay::InitSpeedLimitCurveProperty(EnumProperty &curveProperty) void StSpaceDisplay::InitCurveProperty() { - curveProperty = new (std::nothrow) + curveProperty = new EnumProperty("Curve", "First St Track", "Curve type setting selection.", this, SLOT(UpdateCurveChoice())); - if (curveProperty == nullptr) { - ROS_ERROR("Failed to Create the curveProperty of EnumProperty."); - return; - } curveProperty->addOption("First St Track", FIRST_ST_TRACK_CURVE); curveProperty->addOption("Optimized St Track", OPTIMIZED_ST_TRACK_CURVE); curveProperty->addOption("St Speed Limit", ST_SPEED_LIMIT_CURVE); @@ -237,42 +186,30 @@ void StSpaceDisplay::UpdateCurveColorAndAlpha() QColor colorOptimizedCurve = optimizedCurveColorProperty->getColor(); QColor colorSpeedLimitCurve = speedLimitCurveColorProperty->getColor(); - int32_t alphaFirstCurve = firstCurveAlphaProperty->getInt(); - int32_t alphaOptimizedCurve = optimizedCurveAlphaProperty->getInt(); - int32_t alphaSpeedLimitCurve = speedLimitCurveAlphaProperty->getInt(); + qreal alphaFirstCurve = firstCurveAlphaProperty->getFloat(); + qreal alphaOptimizedCurve = optimizedCurveAlphaProperty->getFloat(); + qreal alphaSpeedLimitCurve = speedLimitCurveAlphaProperty->getFloat(); - colorFirstCurve.setAlpha(alphaFirstCurve); - colorOptimizedCurve.setAlpha(alphaOptimizedCurve); - colorSpeedLimitCurve.setAlpha(alphaSpeedLimitCurve); + colorFirstCurve.setAlpha(alphaFirstCurve * 0xFF); + colorOptimizedCurve.setAlpha(alphaOptimizedCurve * 0xFF); + colorSpeedLimitCurve.setAlpha(alphaSpeedLimitCurve * 0xFF); firstStTrackCurve.setPen(colorFirstCurve, CURVE_PEN_WIDTH); optimizedStTrackCurve.setPen(colorOptimizedCurve, CURVE_PEN_WIDTH); stSpeedLimitCurve.setPen(colorSpeedLimitCurve, CURVE_PEN_WIDTH); - QwtSymbol *firstSymbol = new (std::nothrow) QwtSymbol(QwtSymbol::Ellipse, QBrush(colorFirstCurve), + QwtSymbol *firstSymbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(colorFirstCurve), QPen(colorFirstCurve, CURVE_SYMBOL_PEN_WIDTH), QSize(CURVE_SYMBOL_SIZE_WIDTH, CURVE_SYMBOL_SIZE_HRIGHT)); - if (firstSymbol == nullptr) { - ROS_ERROR("Failed to Create the firstSymbol of QwtSymbol."); - return; - } firstStTrackCurve.setSymbol(firstSymbol); - QwtSymbol *optimizedSymbol = new (std::nothrow) QwtSymbol(QwtSymbol::Ellipse, QBrush(colorOptimizedCurve), + QwtSymbol *optimizedSymbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(colorOptimizedCurve), QPen(colorOptimizedCurve, CURVE_SYMBOL_PEN_WIDTH), QSize(CURVE_SYMBOL_SIZE_WIDTH, CURVE_SYMBOL_SIZE_HRIGHT)); - if (optimizedSymbol == nullptr) { - ROS_ERROR("Failed to Create the optimizedSymbol of QwtSymbol."); - return; - } optimizedStTrackCurve.setSymbol(optimizedSymbol); - QwtSymbol *stSpeedSymbol = new (std::nothrow) QwtSymbol(QwtSymbol::Ellipse, QBrush(colorSpeedLimitCurve), + QwtSymbol *stSpeedSymbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(colorSpeedLimitCurve), QPen(colorSpeedLimitCurve, CURVE_SYMBOL_PEN_WIDTH), QSize(CURVE_SYMBOL_SIZE_WIDTH, CURVE_SYMBOL_SIZE_HRIGHT)); - if (stSpeedSymbol == nullptr) { - ROS_ERROR("Failed to Create the stSpeedSymbol of QwtSymbol."); - return; - } stSpeedLimitCurve.setSymbol(stSpeedSymbol); ui.qwtPlot->replot(); @@ -412,11 +349,7 @@ void StSpaceDisplay::InitQwtPlotStyle() title.setFont(font); ui.qwtPlot->setTitle(title); - QwtLegend *legend = new (std::nothrow) QwtLegend(); - if (legend == nullptr) { - ROS_ERROR("Failed to Create the legend of QwtLegend."); - return; - } + QwtLegend *legend = new QwtLegend(); if (legend != nullptr) { legend->setStyleSheet(LEGEND_STYLE_SHEET); @@ -452,14 +385,14 @@ void StSpaceDisplay::InitQwtPlotStyle() } void StSpaceDisplay::InitCurveStyle(QwtPlotCurve &curve, StringProperty &title, const ColorProperty &color, - const IntProperty &alpha) + const FloatProperty &alpha) { // 图例名字 curve.setTitle(title.getString()); QColor colorCurve = color.getColor(); - int32_t alphaCurve = alpha.getInt(); - colorCurve.setAlpha(alphaCurve); + qreal alphaCurve = alpha.getFloat(); + colorCurve.setAlpha(alphaCurve * 0xFF); // 设置画笔 curve.setPen(colorCurve, CURVE_PEN_WIDTH); @@ -468,12 +401,8 @@ void StSpaceDisplay::InitCurveStyle(QwtPlotCurve &curve, StringProperty &title, // 显示图例的标志,这里显示线的颜色 // 设置样本点的颜色、大小 - QwtSymbol *symbol = new (std::nothrow) QwtSymbol(QwtSymbol::Ellipse, QBrush(colorCurve), + QwtSymbol *symbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(colorCurve), QPen(colorCurve, CURVE_SYMBOL_PEN_WIDTH), QSize(CURVE_SYMBOL_SIZE_WIDTH, CURVE_SYMBOL_SIZE_HRIGHT)); - if (symbol == nullptr) { - ROS_ERROR("Failed to Create the symbol of QwtSymbol."); - return; - } // 添加样本点形状 curve.setSymbol(symbol); @@ -517,12 +446,8 @@ void StSpaceDisplay::CreateObjectsTypeProperty(int32_t type) objectsTypeTotalVector.append(type); if (objectsTypeProperty == nullptr) { - objectsTypeProperty = new (std::nothrow) EnumProperty("Objects Type", typeName, + objectsTypeProperty = new EnumProperty("Objects Type", typeName, "St Objects Type setting selection.", this, SLOT(UpdateObjectsTypeChoice())); - if (objectsTypeProperty == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeProperty of EnumProperty."); - return; - } } objectsTypeProperty->addOption(typeName, type); } @@ -530,15 +455,9 @@ void StSpaceDisplay::CreateObjectsTypeProperty(int32_t type) void StSpaceDisplay::CreateObjectsTypeAlphaProperty(int32_t type, const QString &propertyKey, const QString &propertyValue) { - int32_t alphaValue = propertyValue.toInt(); - IntProperty *objectsTypeAlphaPropertyPtr = new (std::nothrow) IntProperty(propertyKey, alphaValue, + qreal alphaValue = propertyValue.toFloat(); + FloatProperty *objectsTypeAlphaPropertyPtr = new FloatProperty(propertyKey, alphaValue, "Objects type alpha setting.", objectsTypeProperty, SLOT(UpdateObjectsTypeColorAndAlpha()), this); - - if (objectsTypeAlphaPropertyPtr == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeAlphaPropertyPtr of IntProperty."); - return; - } - objectsTypeAlphaPropertyPtr->setMin(COLOR_ALPHA_MIN); objectsTypeAlphaPropertyPtr->setMax(COLOR_ALPHA_MAX); SetObjectsTypeColorAlpha(type, alphaValue); @@ -559,14 +478,9 @@ void StSpaceDisplay::CreateObjectsTypeColorProperty(int32_t type, const QString int32_t green = colorChannelValue[0x01].toInt(); int32_t blue = colorChannelValue[0x02].toInt(); QColor color = QColor(red, green, blue); - ColorProperty *objectsTypeColorPropertyPtr = new (std::nothrow) ColorProperty(propertyKey, color, + ColorProperty *objectsTypeColorPropertyPtr = new ColorProperty(propertyKey, color, "Objects type color setting.", objectsTypeProperty, SLOT(UpdateObjectsTypeColorAndAlpha()), this); - if (objectsTypeColorPropertyPtr == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeColorPropertyPtr of ColorProperty."); - return; - } - SetObjectsTypeColor(type, red, green, blue); objectsTypeColorProperty.insert(type, objectsTypeColorPropertyPtr); } @@ -574,14 +488,9 @@ void StSpaceDisplay::CreateObjectsTypeColorProperty(int32_t type, const QString void StSpaceDisplay::CreateObjectsTypeTitleProperty(int32_t type, const QString &propertyKey, const QString &propertyValue) { - StringProperty *objectsTypeTitlePropertyPtr = new (std::nothrow) StringProperty(propertyKey, propertyValue, + StringProperty *objectsTypeTitlePropertyPtr = new StringProperty(propertyKey, propertyValue, "Objects type title setting.", objectsTypeProperty, SLOT(UpdateObjectCurveTitle()), this); - if (objectsTypeTitlePropertyPtr == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeTitlePropertyPtr of StringProperty."); - return; - } - objectsTypeTitleProperty.insert(type, objectsTypeTitlePropertyPtr); } @@ -662,8 +571,8 @@ void StSpaceDisplay::UpdateObjectsTypeColorAndAlpha() } QColor objectColor = (objectsTypeColorProperty[type])->getColor(); - int32_t alpha = (objectsTypeAlphaProperty[type])->getInt(); - objectColor.setAlpha(alpha); + qreal alpha = (objectsTypeAlphaProperty[type])->getFloat(); + objectColor.setAlpha(alpha * 0xFF); SetObjectsTypeColor(type, objectColor); const QMap idTypeMap = stSpaceData.GetObjectsIdTypeMap(); @@ -749,45 +658,26 @@ void StSpaceDisplay::SetObjectProperty(int32_t objectType) objectsTypeTotalVector.append(objectType); if (objectsTypeProperty == nullptr) { - objectsTypeProperty = new (std::nothrow) EnumProperty("Objects Type", QString("Type %1").arg(objectType), + objectsTypeProperty = new EnumProperty("Objects Type", QString("Type %1").arg(objectType), "St Objects Type setting selection.", this, SLOT(UpdateObjectsTypeChoice())); - if (objectsTypeProperty == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeProperty of EnumProperty."); - return; - } } QString typeName = QString("Type %1").arg(objectType); objectsTypeProperty->addOption(typeName, objectType); StringProperty *objectsTypeTitlePropertyPtr = - new (std::nothrow) StringProperty(QString("Type %1 Title").arg(objectType), QString("Type %1").arg(objectType), + new StringProperty(QString("Type %1 Title").arg(objectType), QString("Type %1").arg(objectType), "Objects type title setting.", objectsTypeProperty, SLOT(UpdateObjectCurveTitle()), this); - if (objectsTypeTitlePropertyPtr == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeTitlePropertyPtr of StringProperty."); - return; - } - QColor color = GetObjectsTypeColor(objectType); ColorProperty *objectsTypeColorPropertyPtr = - new (std::nothrow) ColorProperty(QString("Type %1 Color").arg(objectType), color, "Objects type color setting.", + new ColorProperty(QString("Type %1 Color").arg(objectType), color, "Objects type color setting.", objectsTypeProperty, SLOT(UpdateObjectsTypeColorAndAlpha()), this); - if (objectsTypeColorPropertyPtr == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeColorPropertyPtr of ColorProperty."); - return; - } - - IntProperty *objectsTypeAlphaPropertyPtr = - new (std::nothrow) IntProperty(QString("Type %1 Alpha").arg(objectType), color.alpha(), + FloatProperty *objectsTypeAlphaPropertyPtr = + new FloatProperty(QString("Type %1 Alpha").arg(objectType), color.alpha(), "Objects type alpha setting.", objectsTypeProperty, SLOT(UpdateObjectsTypeColorAndAlpha()), this); - if (objectsTypeAlphaPropertyPtr == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeAlphaPropertyPtr of IntProperty."); - return; - } - objectsTypeAlphaPropertyPtr->setMin(COLOR_ALPHA_MIN); objectsTypeAlphaPropertyPtr->setMax(COLOR_ALPHA_MAX); @@ -799,8 +689,30 @@ void StSpaceDisplay::SetObjectProperty(int32_t objectType) void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdType, const QMap &stObjectsMap) { - for (auto iter = stObjectsMap.begin(); iter != stObjectsMap.end(); iter++) { - QString objectId = iter.key(); + if((!stObjectsCurveMap.empty()) && (stObjectsCurveMap.size() == stObjectsMap.size())) { + for (auto &stObjectsCurve : stObjectsCurveMap) { + stObjectsCurve.second->setSamples(stObjectsMap.value(stObjectsCurve.first)); + } + return; + } + + if (!stObjectsCurveMap.empty()) { + stObjectsCurveMap.clear(); + } + + QStringList typeNames = stObjectsMap.keys(); + for (int32_t i = 0; i < typeNames.count() - 1; i++) { + for (int32_t j = i + 1; j < typeNames.count(); j++) { + if (objectsIdType.value(typeNames.at(i)) > objectsIdType.value(typeNames.at(j))) { + QString typeName = typeNames.at(i); + typeNames[i] = typeNames.at(j); + typeNames[j] = typeName; + } + } + } + + for (auto typeName : typeNames) { + QString objectId = typeName; int32_t type = objectsIdType.value(objectId); SetObjectProperty(type); if (!objectsTypeTitleProperty.contains(type) || objectsTypeTitleProperty[type] == nullptr) { @@ -810,13 +722,13 @@ void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdTyp QColor color = GetObjectsTypeColor(type); unique_ptr curve = make_unique(objectName); curve->setTitle(objectName); - color.setAlpha(objectsTypeAlphaProperty[type]->getInt()); + color.setAlpha(objectsTypeAlphaProperty[type]->getFloat() * 0xFF); curve->setPen(color, OBJECT_CURVE_PEN_WIDTH); curve->setBrush(color); curve->setRenderHint(QwtPlotItem::RenderAntialiased, true); curve->setLegendAttribute(curve->LegendShowBrush); curve->attach(ui.qwtPlot); - curve->setSamples(iter.value()); + curve->setSamples(stObjectsMap.value(objectId)); ShowCurve(curve.get(), true); stObjectsCurveMap.insert(std::make_pair(objectId, std::move(curve))); } @@ -824,10 +736,6 @@ void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdTyp void StSpaceDisplay::DrawObjects(const QMap &stObjectsMap) { - if (!stObjectsCurveMap.empty()) { - stObjectsCurveMap.clear(); - } - if (stObjectsMap.isEmpty()) { return; } @@ -894,7 +802,10 @@ void StSpaceDisplay::reset() void StSpaceDisplay::updateTopic() { ReplotEmptyData(); - ChartDisplayClass::updateTopic(); + sub.unsubscribe(); + stObjectsCurveMap.clear(); + reset(); + Subscribe(); } } diff --git a/chart_plugin/src/st_space_display.h b/chart_plugin/src/st_space_display.h index 793ae613725ffda8e7258c372ce4ce2aa827edc1..3067554c5d62a46d91c43d6f561a74fe8bb67d01 100755 --- a/chart_plugin/src/st_space_display.h +++ b/chart_plugin/src/st_space_display.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd +Copyright (c) 2020-2022, Huawei Technologies Co., Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the @@ -37,6 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "st_space/st_space_data.h" #include "st_space/ui_st_widget.h" @@ -269,7 +270,7 @@ private: * 返回值:无 */ void InitCurveStyle(QwtPlotCurve &curve, rviz::StringProperty &title, - const rviz::ColorProperty &color, const rviz::IntProperty &alpha); + const rviz::ColorProperty &color, const rviz::FloatProperty &alpha); /* * 功能:在QwtPlot上绘制障碍物曲线 @@ -420,21 +421,21 @@ private: rviz::StringProperty *firstCurveTitleProperty { nullptr }; rviz::ColorProperty *firstCurveColorProperty { nullptr }; - rviz::IntProperty *firstCurveAlphaProperty { nullptr }; + rviz::FloatProperty *firstCurveAlphaProperty { nullptr }; rviz::StringProperty *optimizedCurveTitleProperty { nullptr }; rviz::ColorProperty *optimizedCurveColorProperty { nullptr }; - rviz::IntProperty *optimizedCurveAlphaProperty { nullptr }; + rviz::FloatProperty *optimizedCurveAlphaProperty { nullptr }; rviz::StringProperty *speedLimitCurveTitleProperty { nullptr }; rviz::ColorProperty *speedLimitCurveColorProperty { nullptr }; - rviz::IntProperty *speedLimitCurveAlphaProperty { nullptr }; + rviz::FloatProperty *speedLimitCurveAlphaProperty { nullptr }; rviz::EnumProperty *objectsTypeProperty { nullptr }; QMap objectsTypeTitleProperty {}; QMap objectsTypeColorProperty {}; - QMap objectsTypeAlphaProperty {}; + QMap objectsTypeAlphaProperty {}; QHash objectsTypeColor {}; };