From 081df66040b3b2c1ff6e2572338f8e2068c14902 Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 3 Mar 2022 14:29:22 +0800 Subject: [PATCH 01/10] =?UTF-8?q?ST=E5=9B=BE=E5=92=8CCurve=E5=9B=BE?= =?UTF-8?q?=E9=80=8F=E6=98=8E=E5=BA=A6=E9=A3=8E=E6=A0=BC=E6=94=B9=E4=B8=BA?= =?UTF-8?q?0-1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/curve_display.cpp | 28 ++++++------- chart_plugin/src/curve_display.h | 10 ++--- chart_plugin/src/st_space_display.cpp | 59 +++++++++++++-------------- chart_plugin/src/st_space_display.h | 14 +++---- 4 files changed, 55 insertions(+), 56 deletions(-) diff --git a/chart_plugin/src/curve_display.cpp b/chart_plugin/src/curve_display.cpp index eea1c79..96402c8 100755 --- a/chart_plugin/src/curve_display.cpp +++ b/chart_plugin/src/curve_display.cpp @@ -1,6 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd - All rights reserved. +Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -39,6 +38,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 +47,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; @@ -124,7 +124,7 @@ void CurveDisplay::InitFirstCurveProperty(EnumProperty &curveProperty) return; } - firstCurveAlphaProperty = new (std::nothrow) IntProperty("First Curve Alpha", FIRST_CURVE_COLOR_ALPHA, + firstCurveAlphaProperty = new (std::nothrow) 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."); @@ -152,7 +152,7 @@ void CurveDisplay::InitSecondCurveProperty(EnumProperty &curveProperty) return; } - secondCurveAlphaProperty = new (std::nothrow) IntProperty("Second Curve Alpha", SECOND_CURVE_COLOR_ALPHA, + secondCurveAlphaProperty = new (std::nothrow) 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."); @@ -189,10 +189,10 @@ 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); @@ -349,14 +349,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); diff --git a/chart_plugin/src/curve_display.h b/chart_plugin/src/curve_display.h index 9b80063..b04d6c9 100755 --- a/chart_plugin/src/curve_display.h +++ b/chart_plugin/src/curve_display.h @@ -1,6 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd - All rights reserved. +Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -30,6 +29,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include @@ -209,7 +209,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 +235,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/st_space_display.cpp b/chart_plugin/src/st_space_display.cpp index d7589f6..fecbacf 100755 --- a/chart_plugin/src/st_space_display.cpp +++ b/chart_plugin/src/st_space_display.cpp @@ -1,6 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd - All rights reserved. +Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -46,20 +45,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; @@ -140,10 +139,10 @@ void StSpaceDisplay::InitFirstCurveProperty(EnumProperty &curveProperty) return; } - firstCurveAlphaProperty = new (std::nothrow) IntProperty("First Alpha", FIRST_CURVE_COLOR_ALPHA, + firstCurveAlphaProperty = new (std::nothrow) 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."); + ROS_ERROR("Failed to Create the firstCurveAlphaProperty of FloatProperty."); return; } @@ -168,10 +167,10 @@ void StSpaceDisplay::InitSecondCurveProperty(EnumProperty &curveProperty) return; } - optimizedCurveAlphaProperty = new (std::nothrow) IntProperty("Optimized Alpha", OPTIMIZED_CURVE_COLOR_ALPHA, + optimizedCurveAlphaProperty = new (std::nothrow) 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."); + ROS_ERROR("Failed to Create the optimizedCurveAlphaProperty of FloatProperty."); return; } @@ -196,10 +195,10 @@ void StSpaceDisplay::InitSpeedLimitCurveProperty(EnumProperty &curveProperty) return; } - speedLimitCurveAlphaProperty = new (std::nothrow) IntProperty("Speed Alpha", SPEED_LIMIT_CURVE_COLOR_ALPHA, + speedLimitCurveAlphaProperty = new (std::nothrow) 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."); + ROS_ERROR("Failed to Create the speedLimitCurveAlphaProperty of FloatProperty."); return; } @@ -237,13 +236,13 @@ 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); @@ -452,14 +451,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); @@ -530,12 +529,12 @@ 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 (std::nothrow) FloatProperty(propertyKey, alphaValue, "Objects type alpha setting.", objectsTypeProperty, SLOT(UpdateObjectsTypeColorAndAlpha()), this); if (objectsTypeAlphaPropertyPtr == nullptr) { - ROS_ERROR("Failed to Create the objectsTypeAlphaPropertyPtr of IntProperty."); + ROS_ERROR("Failed to Create the objectsTypeAlphaPropertyPtr of FloatProperty."); return; } @@ -662,8 +661,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(); @@ -779,12 +778,12 @@ void StSpaceDisplay::SetObjectProperty(int32_t objectType) return; } - IntProperty *objectsTypeAlphaPropertyPtr = - new (std::nothrow) IntProperty(QString("Type %1 Alpha").arg(objectType), color.alpha(), + FloatProperty *objectsTypeAlphaPropertyPtr = + new (std::nothrow) 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."); + ROS_ERROR("Failed to Create the objectsTypeAlphaPropertyPtr of FloatProperty."); return; } @@ -810,7 +809,7 @@ 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); diff --git a/chart_plugin/src/st_space_display.h b/chart_plugin/src/st_space_display.h index 793ae61..4002578 100755 --- a/chart_plugin/src/st_space_display.h +++ b/chart_plugin/src/st_space_display.h @@ -1,6 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd - All rights reserved. +Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -37,6 +36,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 +269,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 +420,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 {}; }; -- Gitee From f05946224f31c10f3b911904c622e4d78a25d18a Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 3 Mar 2022 14:51:09 +0800 Subject: [PATCH 02/10] =?UTF-8?q?Slt=E5=9B=BE=E6=BB=9A=E8=BD=AE=E6=94=BE?= =?UTF-8?q?=E5=A4=A7=E7=BC=A9=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/slt_space/ui_slt_widget.cpp | 5 +- chart_plugin/src/slt_space/ui_slt_widget.h | 56 ++++++++++++++++++-- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/chart_plugin/src/slt_space/ui_slt_widget.cpp b/chart_plugin/src/slt_space/ui_slt_widget.cpp index d5c4018..d6f05ef 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.cpp +++ b/chart_plugin/src/slt_space/ui_slt_widget.cpp @@ -1,6 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd - All rights reserved. +Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -95,7 +94,7 @@ 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); + qMathGl = new (std::nothrow) MathGL(&widgetMathGl); if (qMathGl == nullptr) { ROS_ERROR("Failed to Create the qMathGl of QMathGL."); return; diff --git a/chart_plugin/src/slt_space/ui_slt_widget.h b/chart_plugin/src/slt_space/ui_slt_widget.h index 6306aff..653c11b 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.h +++ b/chart_plugin/src/slt_space/ui_slt_widget.h @@ -1,6 +1,5 @@ /* -Copyright (c) 2020-2021, Huawei Technologies Co., Ltd - All rights reserved. +Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -32,10 +31,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 +117,7 @@ private: private: QVBoxLayout *verticalLayout { nullptr }; - QMathGL *qMathGl { nullptr }; + MathGL *qMathGl { nullptr }; QWidget *widgetMathGl { nullptr }; QPushButton *restoreButton { nullptr }; @@ -124,6 +125,55 @@ private: QWidget *scrollAreaWidgetContents { nullptr }; QGridLayout *gridLayout { nullptr }; }; + +class MathGL : public QMathGL { +public: + MathGL(QWidget *parent = nullptr, Qt::WindowFlags = 0) : QMathGL(parent, f) {} + ~MathGL() override = default; + void wheelEvent(QWheelEvent *event) override + { + 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(); + } else { + 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->accpet(); + } + + } +}; } #endif // UI_SLT_WIDGET_H -- Gitee From c9b372abc9a1a25973b8f9bf8451b36f4b7103c6 Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 3 Mar 2022 15:04:22 +0800 Subject: [PATCH 03/10] =?UTF-8?q?slt=E5=9B=BE=E9=9A=9C=E7=A2=8D=E7=89=A9?= =?UTF-8?q?=E6=98=BE=E9=9A=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/common/chart_display_base.h | 4 ++-- chart_plugin/src/st_space_display.cpp | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/chart_plugin/src/common/chart_display_base.h b/chart_plugin/src/common/chart_display_base.h index bcd4e3c..6967931 100755 --- a/chart_plugin/src/common/chart_display_base.h +++ b/chart_plugin/src/common/chart_display_base.h @@ -1,6 +1,5 @@ /* -Copyright (c) 2020, Huawei Technologies Co., Ltd - All rights reserved. +Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -135,6 +134,7 @@ protected: void IncomingMessage(const typename MessageType::ConstPtr &msg) { if (!msg) { + ProcessMessage(msg); return; } diff --git a/chart_plugin/src/st_space_display.cpp b/chart_plugin/src/st_space_display.cpp index fecbacf..fd89a1f 100755 --- a/chart_plugin/src/st_space_display.cpp +++ b/chart_plugin/src/st_space_display.cpp @@ -798,6 +798,17 @@ void StSpaceDisplay::SetObjectProperty(int32_t objectType) void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdType, const QMap &stObjectsMap) { + if((!stObjectsCurveMap.empty()) && (stObjectsCurveMap.size() == stObjectsMap.size)) { + for (auto &stObjectsCurve : stObjectsCurveMap) { + stObjectsCurve.second->setSamples(stObjectsMap.value(stObjectsCurve.first)); + } + return; + } + + if (stObjectsCurveMap) { + stObjectsCurveMap.clear(); + } + for (auto iter = stObjectsMap.begin(); iter != stObjectsMap.end(); iter++) { QString objectId = iter.key(); int32_t type = objectsIdType.value(objectId); @@ -823,10 +834,6 @@ void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdTyp void StSpaceDisplay::DrawObjects(const QMap &stObjectsMap) { - if (!stObjectsCurveMap.empty()) { - stObjectsCurveMap.clear(); - } - if (stObjectsMap.isEmpty()) { return; } @@ -893,7 +900,10 @@ void StSpaceDisplay::reset() void StSpaceDisplay::updateTopic() { ReplotEmptyData(); - ChartDisplayClass::updateTopic(); + sub.unsubscribe(); + stObjectsCurveMap.clear(); + reset(); + Subscribe(); } } -- Gitee From a7dd06aa172ec76ef7eb83debd845833d83fcd37 Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 3 Mar 2022 15:21:21 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/slt_space/ui_slt_widget.h | 4 ++-- chart_plugin/src/st_space_display.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/chart_plugin/src/slt_space/ui_slt_widget.h b/chart_plugin/src/slt_space/ui_slt_widget.h index 653c11b..2928d1c 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.h +++ b/chart_plugin/src/slt_space/ui_slt_widget.h @@ -128,7 +128,7 @@ private: class MathGL : public QMathGL { public: - MathGL(QWidget *parent = nullptr, Qt::WindowFlags = 0) : QMathGL(parent, f) {} + MathGL(QWidget *parent = nullptr, Qt::WindowFlags flag = 0) : QMathGL(parent, flag) {} ~MathGL() override = default; void wheelEvent(QWheelEvent *event) override { @@ -169,7 +169,7 @@ public: ax2 = sum + diff; mgl_zoom_axis((HMGL)gr, ax1, ay1, 0, 0, ax2, ay2, 0, 0); update(); - event->accpet(); + event->accept(); } } diff --git a/chart_plugin/src/st_space_display.cpp b/chart_plugin/src/st_space_display.cpp index fd89a1f..ff29d0f 100755 --- a/chart_plugin/src/st_space_display.cpp +++ b/chart_plugin/src/st_space_display.cpp @@ -34,6 +34,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; @@ -798,14 +799,14 @@ void StSpaceDisplay::SetObjectProperty(int32_t objectType) void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdType, const QMap &stObjectsMap) { - if((!stObjectsCurveMap.empty()) && (stObjectsCurveMap.size() == stObjectsMap.size)) { + if((!stObjectsCurveMap.empty()) && (stObjectsCurveMap.size() == stObjectsMap.size())) { for (auto &stObjectsCurve : stObjectsCurveMap) { stObjectsCurve.second->setSamples(stObjectsMap.value(stObjectsCurve.first)); } return; } - if (stObjectsCurveMap) { + if (!stObjectsCurveMap.empty()) { stObjectsCurveMap.clear(); } -- Gitee From bc884afe6b9114f73a0e3e92fe929fe3af5ea9c6 Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 3 Mar 2022 15:46:44 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/slt_space/ui_slt_widget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart_plugin/src/slt_space/ui_slt_widget.h b/chart_plugin/src/slt_space/ui_slt_widget.h index 2928d1c..c6963a9 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.h +++ b/chart_plugin/src/slt_space/ui_slt_widget.h @@ -150,7 +150,7 @@ public: // 2代表取平均值 sum = (x2 + x1) / 2; x1 = sum - diff; - x2 = sum - diff; + x2 = sum + diff; refresh(); event->accept(); } else { -- Gitee From a76fe6e4cdc4dfa2a88b3e6d80e56250eb5716bb Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 10 Mar 2022 16:01:09 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=8B=96=E5=8A=A8=E7=89=A9=E4=BD=93=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/common/chart_display_base.h | 3 +- chart_plugin/src/curve_display.cpp | 87 ++------- chart_plugin/src/curve_display.h | 3 +- chart_plugin/src/slt_space/ui_slt_widget.cpp | 148 +++++++++++---- chart_plugin/src/slt_space/ui_slt_widget.h | 58 ++---- chart_plugin/src/st_space_display.cpp | 183 +++++-------------- chart_plugin/src/st_space_display.h | 3 +- 7 files changed, 189 insertions(+), 296 deletions(-) diff --git a/chart_plugin/src/common/chart_display_base.h b/chart_plugin/src/common/chart_display_base.h index 6967931..e751c13 100755 --- a/chart_plugin/src/common/chart_display_base.h +++ b/chart_plugin/src/common/chart_display_base.h @@ -1,5 +1,6 @@ /* -Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +Copyright (c) 2020, Huawei Technologies Co., Ltd + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/chart_plugin/src/curve_display.cpp b/chart_plugin/src/curve_display.cpp index 96402c8..8874785 100755 --- a/chart_plugin/src/curve_display.cpp +++ b/chart_plugin/src/curve_display.cpp @@ -1,5 +1,6 @@ /* -Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +Copyright (c) 2020, Huawei Technologies Co., Ltd + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -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) FloatProperty("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) FloatProperty("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); @@ -196,20 +157,12 @@ void CurveDisplay::UpdateCurveColorAndAlpha() 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); @@ -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 b04d6c9..1914ac5 100755 --- a/chart_plugin/src/curve_display.h +++ b/chart_plugin/src/curve_display.h @@ -1,5 +1,6 @@ /* -Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +Copyright (c) 2020, Huawei Technologies Co., Ltd + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/chart_plugin/src/slt_space/ui_slt_widget.cpp b/chart_plugin/src/slt_space/ui_slt_widget.cpp index d6f05ef..eee69e1 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.cpp +++ b/chart_plugin/src/slt_space/ui_slt_widget.cpp @@ -1,5 +1,6 @@ /* -Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +Copyright (c) 2020, Huawei Technologies Co., Ltd + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -94,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) MathGL(&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)); @@ -126,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")); @@ -157,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); @@ -185,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_case(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 c6963a9..7e1ee65 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.h +++ b/chart_plugin/src/slt_space/ui_slt_widget.h @@ -1,5 +1,6 @@ /* -Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +Copyright (c) 2020, Huawei Technologies Co., Ltd + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -130,49 +131,18 @@ class MathGL : public QMathGL { public: MathGL(QWidget *parent = nullptr, Qt::WindowFlags flag = 0) : QMathGL(parent, flag) {} ~MathGL() override = default; - void wheelEvent(QWheelEvent *event) override - { - 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(); - } else { - 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(); - } - - } + +protected: + void wheelEvent(QWheelEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + +private: + int32_t poxX {}; + int32_t poxY {}; + int32_t x {}; + int32_t y {}; }; } diff --git a/chart_plugin/src/st_space_display.cpp b/chart_plugin/src/st_space_display.cpp index ff29d0f..da8088c 100755 --- a/chart_plugin/src/st_space_display.cpp +++ b/chart_plugin/src/st_space_display.cpp @@ -1,5 +1,6 @@ /* -Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +Copyright (c) 2020, Huawei Technologies Co., Ltd + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -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) FloatProperty("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 FloatProperty."); - 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) FloatProperty("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 FloatProperty."); - 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) FloatProperty("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 FloatProperty."); - 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); @@ -249,30 +198,18 @@ void StSpaceDisplay::UpdateCurveColorAndAlpha() 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); @@ -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); } @@ -531,14 +456,8 @@ void StSpaceDisplay::CreateObjectsTypeAlphaProperty(int32_t type, const QString const QString &propertyValue) { qreal alphaValue = propertyValue.toFloat(); - FloatProperty *objectsTypeAlphaPropertyPtr = new (std::nothrow) FloatProperty(propertyKey, alphaValue, + 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 FloatProperty."); - 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); } @@ -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; - } - FloatProperty *objectsTypeAlphaPropertyPtr = - new (std::nothrow) FloatProperty(QString("Type %1 Alpha").arg(objectType), color.alpha(), + 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 FloatProperty."); - return; - } - objectsTypeAlphaPropertyPtr->setMin(COLOR_ALPHA_MIN); objectsTypeAlphaPropertyPtr->setMax(COLOR_ALPHA_MAX); @@ -810,8 +700,19 @@ void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdTyp stObjectsCurveMap.clear(); } - for (auto iter = stObjectsMap.begin(); iter != stObjectsMap.end(); iter++) { - QString objectId = iter.key(); + QStringList typeName = stObjectsMap.keys(); + for (int32_t i = 0; i < typeNames.count(); i++) { + for (int32_t j = i + 1; j < typeNames.count() + 1; 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) { @@ -827,7 +728,7 @@ void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdTyp 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))); } diff --git a/chart_plugin/src/st_space_display.h b/chart_plugin/src/st_space_display.h index 4002578..58152b2 100755 --- a/chart_plugin/src/st_space_display.h +++ b/chart_plugin/src/st_space_display.h @@ -1,5 +1,6 @@ /* -Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. +Copyright (c) 2020, Huawei Technologies Co., Ltd + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -- Gitee From 23a4342fecab9575dbebd434e019de3c631d9266 Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 10 Mar 2022 16:15:50 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/slt_space/ui_slt_widget.h | 4 ++-- chart_plugin/src/st_space_display.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chart_plugin/src/slt_space/ui_slt_widget.h b/chart_plugin/src/slt_space/ui_slt_widget.h index 7e1ee65..19c2217 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.h +++ b/chart_plugin/src/slt_space/ui_slt_widget.h @@ -139,8 +139,8 @@ protected: void mouseReleaseEvent(QMouseEvent *event) override; private: - int32_t poxX {}; - int32_t poxY {}; + int32_t posX {}; + int32_t posY {}; int32_t x {}; int32_t y {}; }; diff --git a/chart_plugin/src/st_space_display.cpp b/chart_plugin/src/st_space_display.cpp index da8088c..79ba534 100755 --- a/chart_plugin/src/st_space_display.cpp +++ b/chart_plugin/src/st_space_display.cpp @@ -700,7 +700,7 @@ void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdTyp stObjectsCurveMap.clear(); } - QStringList typeName = stObjectsMap.keys(); + QStringList typeNames = stObjectsMap.keys(); for (int32_t i = 0; i < typeNames.count(); i++) { for (int32_t j = i + 1; j < typeNames.count() + 1; j++) { if (objectsIdType.value(typeNames.at(i)) > objectsIdType.value(typeNames.at(j))) { -- Gitee From cc353cb944ef05623c5ea1635b46cff3ec6b9a29 Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 10 Mar 2022 16:23:24 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/slt_space/ui_slt_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart_plugin/src/slt_space/ui_slt_widget.cpp b/chart_plugin/src/slt_space/ui_slt_widget.cpp index eee69e1..ba358cb 100755 --- a/chart_plugin/src/slt_space/ui_slt_widget.cpp +++ b/chart_plugin/src/slt_space/ui_slt_widget.cpp @@ -224,7 +224,7 @@ void MathGL::mouseMoveEvent(QMouseEvent *event) x = event->x(); y = event->y(); - tet += static_case(halfPi * (posY - y) / sqrt(mreal(width() * height()))); + tet += static_cast(halfPi * (posY - y) / sqrt(mreal(width() * height()))); if (tet > halfPi) { tet -= pi; } else if (tet < -halfPi) { -- Gitee From 861b16ced5313e4e4896e493f4a08ebde4e4dabc Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Thu, 10 Mar 2022 17:57:54 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/st_space_display.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chart_plugin/src/st_space_display.cpp b/chart_plugin/src/st_space_display.cpp index 79ba534..52f3d38 100755 --- a/chart_plugin/src/st_space_display.cpp +++ b/chart_plugin/src/st_space_display.cpp @@ -701,8 +701,8 @@ void StSpaceDisplay::ShowObjectsCurve(const QMap &objectsIdTyp } QStringList typeNames = stObjectsMap.keys(); - for (int32_t i = 0; i < typeNames.count(); i++) { - for (int32_t j = i + 1; j < typeNames.count() + 1; j++) { + 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); -- Gitee From c6dd9543e9734a85c8294a0076bef4c7c5431740 Mon Sep 17 00:00:00 2001 From: "1020785391@qq.com" <1020785391@qq.com> Date: Fri, 11 Mar 2022 11:12:59 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chart_plugin/src/common/chart_display_base.h | 2 +- chart_plugin/src/curve_display.cpp | 2 +- chart_plugin/src/curve_display.h | 2 +- chart_plugin/src/slt_space/ui_slt_widget.cpp | 2 +- chart_plugin/src/slt_space/ui_slt_widget.h | 4 ++-- chart_plugin/src/st_space_display.cpp | 2 +- chart_plugin/src/st_space_display.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/chart_plugin/src/common/chart_display_base.h b/chart_plugin/src/common/chart_display_base.h index e751c13..580939e 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 diff --git a/chart_plugin/src/curve_display.cpp b/chart_plugin/src/curve_display.cpp index 8874785..55597ff 100755 --- a/chart_plugin/src/curve_display.cpp +++ b/chart_plugin/src/curve_display.cpp @@ -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 diff --git a/chart_plugin/src/curve_display.h b/chart_plugin/src/curve_display.h index 1914ac5..800b132 100755 --- a/chart_plugin/src/curve_display.h +++ b/chart_plugin/src/curve_display.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 diff --git a/chart_plugin/src/slt_space/ui_slt_widget.cpp b/chart_plugin/src/slt_space/ui_slt_widget.cpp index ba358cb..e543b61 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, 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 diff --git a/chart_plugin/src/slt_space/ui_slt_widget.h b/chart_plugin/src/slt_space/ui_slt_widget.h index 19c2217..a08263d 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, 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 @@ -129,7 +129,7 @@ private: class MathGL : public QMathGL { public: - MathGL(QWidget *parent = nullptr, Qt::WindowFlags flag = 0) : QMathGL(parent, flag) {} + explicit MathGL(QWidget *parent = nullptr, Qt::WindowFlags flag = 0) : QMathGL(parent, flag) {} ~MathGL() override = default; protected: diff --git a/chart_plugin/src/st_space_display.cpp b/chart_plugin/src/st_space_display.cpp index 52f3d38..a707382 100755 --- a/chart_plugin/src/st_space_display.cpp +++ b/chart_plugin/src/st_space_display.cpp @@ -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 diff --git a/chart_plugin/src/st_space_display.h b/chart_plugin/src/st_space_display.h index 58152b2..3067554 100755 --- a/chart_plugin/src/st_space_display.h +++ b/chart_plugin/src/st_space_display.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 -- Gitee