mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-21 21:02:09 +08:00
ui: replace line_vertices_data with QPolygonF (#25001)
use QPolygonF use push_front
This commit is contained in:
@@ -430,13 +430,13 @@ void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
// lanelines
|
||||
for (int i = 0; i < std::size(scene.lane_line_vertices); ++i) {
|
||||
painter.setBrush(QColor::fromRgbF(1.0, 1.0, 1.0, std::clamp<float>(scene.lane_line_probs[i], 0.0, 0.7)));
|
||||
painter.drawPolygon(scene.lane_line_vertices[i].v, scene.lane_line_vertices[i].cnt);
|
||||
painter.drawPolygon(scene.lane_line_vertices[i]);
|
||||
}
|
||||
|
||||
// road edges
|
||||
for (int i = 0; i < std::size(scene.road_edge_vertices); ++i) {
|
||||
painter.setBrush(QColor::fromRgbF(1.0, 0, 0, std::clamp<float>(1.0 - scene.road_edge_stds[i], 0.0, 1.0)));
|
||||
painter.drawPolygon(scene.road_edge_vertices[i].v, scene.road_edge_vertices[i].cnt);
|
||||
painter.drawPolygon(scene.road_edge_vertices[i]);
|
||||
}
|
||||
|
||||
// paint path
|
||||
@@ -455,7 +455,7 @@ void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
bg.setColorAt(0.75 / 1.5, QColor::fromHslF(curve_hue / 360., 1.0, 0.68, 0.35));
|
||||
bg.setColorAt(1.0, QColor::fromHslF(curve_hue / 360., 1.0, 0.68, 0.0));
|
||||
painter.setBrush(bg);
|
||||
painter.drawPolygon(scene.track_vertices.v, scene.track_vertices.cnt);
|
||||
painter.drawPolygon(scene.track_vertices);
|
||||
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
+7
-13
@@ -55,10 +55,13 @@ static void update_leads(UIState *s, const cereal::RadarState::Reader &radar_sta
|
||||
}
|
||||
|
||||
static void update_line_data(const UIState *s, const cereal::ModelDataV2::XYZTData::Reader &line,
|
||||
float y_off, float z_off, line_vertices_data *pvd, int max_idx, bool allow_invert=true) {
|
||||
float y_off, float z_off, QPolygonF *pvd, int max_idx, bool allow_invert=true) {
|
||||
const auto line_x = line.getX(), line_y = line.getY(), line_z = line.getZ();
|
||||
|
||||
std::vector<QPointF> left_points, right_points;
|
||||
QPolygonF left_points, right_points;
|
||||
left_points.reserve(max_idx + 1);
|
||||
right_points.reserve(max_idx + 1);
|
||||
|
||||
for (int i = 0; i <= max_idx; i++) {
|
||||
QPointF left, right;
|
||||
bool l = calib_frame_to_full_frame(s, line_x[i], line_y[i] - y_off, line_z[i] + z_off, &left);
|
||||
@@ -69,19 +72,10 @@ static void update_line_data(const UIState *s, const cereal::ModelDataV2::XYZTDa
|
||||
continue;
|
||||
}
|
||||
left_points.push_back(left);
|
||||
right_points.push_back(right);
|
||||
right_points.push_front(right);
|
||||
}
|
||||
}
|
||||
|
||||
pvd->cnt = 2 * left_points.size();
|
||||
assert(left_points.size() == right_points.size());
|
||||
assert(pvd->cnt <= std::size(pvd->v));
|
||||
|
||||
for (int left_idx = 0; left_idx < left_points.size(); left_idx++){
|
||||
int right_idx = 2 * left_points.size() - left_idx - 1;
|
||||
pvd->v[left_idx] = left_points[left_idx];
|
||||
pvd->v[right_idx] = right_points[left_idx];
|
||||
}
|
||||
*pvd = left_points + right_points;
|
||||
}
|
||||
|
||||
static void update_model(UIState *s, const cereal::ModelDataV2::Reader &model) {
|
||||
|
||||
+4
-8
@@ -8,6 +8,7 @@
|
||||
#include <QTimer>
|
||||
#include <QColor>
|
||||
#include <QFuture>
|
||||
#include <QPolygonF>
|
||||
#include <QTransform>
|
||||
|
||||
#include "cereal/messaging/messaging.h"
|
||||
@@ -84,11 +85,6 @@ const QColor bg_colors [] = {
|
||||
[STATUS_ALERT] = QColor(0xC9, 0x22, 0x31, 0xf1),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
QPointF v[TRAJECTORY_SIZE * 2];
|
||||
int cnt;
|
||||
} line_vertices_data;
|
||||
|
||||
typedef struct UIScene {
|
||||
bool calibration_valid = false;
|
||||
mat3 view_from_calib = DEFAULT_CALIBRATION;
|
||||
@@ -97,9 +93,9 @@ typedef struct UIScene {
|
||||
// modelV2
|
||||
float lane_line_probs[4];
|
||||
float road_edge_stds[2];
|
||||
line_vertices_data track_vertices;
|
||||
line_vertices_data lane_line_vertices[4];
|
||||
line_vertices_data road_edge_vertices[2];
|
||||
QPolygonF track_vertices;
|
||||
QPolygonF lane_line_vertices[4];
|
||||
QPolygonF road_edge_vertices[2];
|
||||
|
||||
// lead
|
||||
QPointF lead_vertices[2];
|
||||
|
||||
Reference in New Issue
Block a user