mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-15 03:53:41 +08:00
8fd5f1b50d
* will draw * gradient * bg * add sense of depth * refactor * cleanup * fix endpoint * clean up * use array * 1 matmul * lives in modeldata * standstill only * remove bad pts * do less math * smooth * kind * fix d * lineswidth * fade in and out * hide * quick * gray out * fix joints * offset * rest icon * clean up * circle as state * longlat * new design * gap and g * scaledown, fix jts and unlock not standstill * width * different * intermediate * sand * motion effect * vis * fix bg * clean up * t * btn_size * small speedup * sligh * clean up * facelift * match .2 * .4 is good * size * no ss * rhd compat * less filt * more line * engaged * not white * drop prop * this is fine * independent falg * sg * dont look like hitman * cleanup * little more --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 955c1dff454babe200862f0011e639ec500938b3
131 lines
3.5 KiB
C++
131 lines
3.5 KiB
C++
#pragma once
|
|
|
|
#include <QPushButton>
|
|
#include <QStackedLayout>
|
|
#include <QWidget>
|
|
|
|
#include "common/util.h"
|
|
#include "selfdrive/ui/ui.h"
|
|
#include "selfdrive/ui/qt/widgets/cameraview.h"
|
|
|
|
|
|
const int btn_size = 192;
|
|
const int img_size = (btn_size / 4) * 3;
|
|
|
|
|
|
// ***** onroad widgets *****
|
|
class OnroadAlerts : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
OnroadAlerts(QWidget *parent = 0) : QWidget(parent) {};
|
|
void updateAlert(const Alert &a, const QColor &color);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent*) override;
|
|
|
|
private:
|
|
QColor bg;
|
|
Alert alert = {};
|
|
};
|
|
|
|
class ExperimentalButton : public QPushButton {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ExperimentalButton(QWidget *parent = 0);
|
|
void updateState(const UIState &s);
|
|
|
|
private:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
Params params;
|
|
QPixmap engage_img;
|
|
QPixmap experimental_img;
|
|
};
|
|
|
|
// container window for the NVG UI
|
|
class AnnotatedCameraWidget : public CameraWidget {
|
|
Q_OBJECT
|
|
Q_PROPERTY(float speed MEMBER speed);
|
|
Q_PROPERTY(QString speedUnit MEMBER speedUnit);
|
|
Q_PROPERTY(float setSpeed MEMBER setSpeed);
|
|
Q_PROPERTY(float speedLimit MEMBER speedLimit);
|
|
Q_PROPERTY(bool is_cruise_set MEMBER is_cruise_set);
|
|
Q_PROPERTY(bool has_eu_speed_limit MEMBER has_eu_speed_limit);
|
|
Q_PROPERTY(bool has_us_speed_limit MEMBER has_us_speed_limit);
|
|
Q_PROPERTY(bool is_metric MEMBER is_metric);
|
|
|
|
Q_PROPERTY(bool dmActive MEMBER dmActive);
|
|
Q_PROPERTY(bool hideDM MEMBER hideDM);
|
|
Q_PROPERTY(bool rightHandDM MEMBER rightHandDM);
|
|
Q_PROPERTY(int status MEMBER status);
|
|
|
|
public:
|
|
explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0);
|
|
void updateState(const UIState &s);
|
|
|
|
private:
|
|
void drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity);
|
|
void drawText(QPainter &p, int x, int y, const QString &text, int alpha = 255);
|
|
|
|
ExperimentalButton *experimental_btn;
|
|
QPixmap dm_img;
|
|
float speed;
|
|
QString speedUnit;
|
|
float setSpeed;
|
|
float speedLimit;
|
|
bool is_cruise_set = false;
|
|
bool is_metric = false;
|
|
bool dmActive = false;
|
|
bool hideDM = false;
|
|
bool rightHandDM = false;
|
|
float dm_fade_state = 1.0;
|
|
bool has_us_speed_limit = false;
|
|
bool has_eu_speed_limit = false;
|
|
bool v_ego_cluster_seen = false;
|
|
int status = STATUS_DISENGAGED;
|
|
std::unique_ptr<PubMaster> pm;
|
|
|
|
int skip_frame_count = 0;
|
|
bool wide_cam_requested = false;
|
|
|
|
protected:
|
|
void paintGL() override;
|
|
void initializeGL() override;
|
|
void showEvent(QShowEvent *event) override;
|
|
void updateFrameMat() override;
|
|
void drawLaneLines(QPainter &painter, const UIState *s);
|
|
void drawLead(QPainter &painter, const cereal::RadarState::LeadData::Reader &lead_data, const QPointF &vd);
|
|
void drawHud(QPainter &p);
|
|
void drawDriverState(QPainter &painter, const UIState *s);
|
|
inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
|
|
inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
|
|
inline QColor blackColor(int alpha = 255) { return QColor(0, 0, 0, alpha); }
|
|
|
|
double prev_draw_t = 0;
|
|
FirstOrderFilter fps_filter;
|
|
};
|
|
|
|
// container for all onroad widgets
|
|
class OnroadWindow : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
OnroadWindow(QWidget* parent = 0);
|
|
bool isMapVisible() const { return map && map->isVisible(); }
|
|
|
|
private:
|
|
void paintEvent(QPaintEvent *event);
|
|
void mousePressEvent(QMouseEvent* e) override;
|
|
OnroadAlerts *alerts;
|
|
AnnotatedCameraWidget *nvg;
|
|
QColor bg = bg_colors[STATUS_DISENGAGED];
|
|
QWidget *map = nullptr;
|
|
QHBoxLayout* split;
|
|
|
|
private slots:
|
|
void offroadTransition(bool offroad);
|
|
void updateState(const UIState &s);
|
|
};
|