ui: remove Q_PROPERTY from `AnnotatedCameraWidget` (#28745)

old-commit-hash: b234cb0223
beeps
Dean Lee 2 years ago committed by GitHub
parent ce1c61d59a
commit a1fe0701e9
  1. 47
      selfdrive/ui/qt/onroad.cc
  2. 13
      selfdrive/ui/qt/onroad.h

@ -283,53 +283,42 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
const bool cs_alive = sm.alive("controlsState"); const bool cs_alive = sm.alive("controlsState");
const bool nav_alive = sm.alive("navInstruction") && sm["navInstruction"].getValid(); const bool nav_alive = sm.alive("navInstruction") && sm["navInstruction"].getValid();
const auto cs = sm["controlsState"].getControlsState(); const auto cs = sm["controlsState"].getControlsState();
const auto car_state = sm["carState"].getCarState(); const auto car_state = sm["carState"].getCarState();
const auto nav_instruction = sm["navInstruction"].getNavInstruction(); const auto nav_instruction = sm["navInstruction"].getNavInstruction();
// Handle older routes where vCruiseCluster is not set // Handle older routes where vCruiseCluster is not set
float v_cruise = cs.getVCruiseCluster() == 0.0 ? cs.getVCruise() : cs.getVCruiseCluster(); float v_cruise = cs.getVCruiseCluster() == 0.0 ? cs.getVCruise() : cs.getVCruiseCluster();
float set_speed = cs_alive ? v_cruise : SET_SPEED_NA; setSpeed = cs_alive ? v_cruise : SET_SPEED_NA;
bool cruise_set = set_speed > 0 && (int)set_speed != SET_SPEED_NA; is_cruise_set = setSpeed > 0 && (int)setSpeed != SET_SPEED_NA;
if (cruise_set && !s.scene.is_metric) { if (is_cruise_set && !s.scene.is_metric) {
set_speed *= KM_TO_MILE; setSpeed *= KM_TO_MILE;
} }
// Handle older routes where vEgoCluster is not set // Handle older routes where vEgoCluster is not set
float v_ego; v_ego_cluster_seen = v_ego_cluster_seen || car_state.getVEgoCluster() != 0.0;
if (car_state.getVEgoCluster() == 0.0 && !v_ego_cluster_seen) { float v_ego = v_ego_cluster_seen ? car_state.getVEgoCluster() : car_state.getVEgo();
v_ego = car_state.getVEgo(); speed = cs_alive ? std::max<float>(0.0, v_ego) : 0.0;
} else { speed *= s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH;
v_ego = car_state.getVEgoCluster();
v_ego_cluster_seen = true;
}
float cur_speed = cs_alive ? std::max<float>(0.0, v_ego) : 0.0;
cur_speed *= s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH;
auto speed_limit_sign = nav_instruction.getSpeedLimitSign(); auto speed_limit_sign = nav_instruction.getSpeedLimitSign();
float speed_limit = nav_alive ? nav_instruction.getSpeedLimit() : 0.0; speedLimit = nav_alive ? nav_instruction.getSpeedLimit() : 0.0;
speed_limit *= (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH); speedLimit *= (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH);
setProperty("speedLimit", speed_limit);
setProperty("has_us_speed_limit", nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::MUTCD);
setProperty("has_eu_speed_limit", nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::VIENNA);
setProperty("is_cruise_set", cruise_set); has_us_speed_limit = (nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::MUTCD);
setProperty("is_metric", s.scene.is_metric); has_eu_speed_limit = (nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::VIENNA);
setProperty("speed", cur_speed); is_metric = s.scene.is_metric;
setProperty("setSpeed", set_speed); speedUnit = s.scene.is_metric ? tr("km/h") : tr("mph");
setProperty("speedUnit", s.scene.is_metric ? tr("km/h") : tr("mph")); hideBottomIcons = (cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE);
setProperty("hideBottomIcons", (cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE)); status = s.status;
setProperty("status", s.status);
// update engageability/experimental mode button // update engageability/experimental mode button
experimental_btn->updateState(s); experimental_btn->updateState(s);
// update DM icon // update DM icon
auto dm_state = sm["driverMonitoringState"].getDriverMonitoringState(); auto dm_state = sm["driverMonitoringState"].getDriverMonitoringState();
setProperty("dmActive", dm_state.getIsActiveMode()); dmActive = dm_state.getIsActiveMode();
setProperty("rightHandDM", dm_state.getIsRHD()); rightHandDM = dm_state.getIsRHD();
// DM icon transition // DM icon transition
dm_fade_state = std::clamp(dm_fade_state+0.2*(0.5-dmActive), 0.0, 1.0); dm_fade_state = std::clamp(dm_fade_state+0.2*(0.5-dmActive), 0.0, 1.0);

@ -65,19 +65,6 @@ private:
// container window for the NVG UI // container window for the NVG UI
class AnnotatedCameraWidget : public CameraWidget { class AnnotatedCameraWidget : public CameraWidget {
Q_OBJECT 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 hideBottomIcons MEMBER hideBottomIcons);
Q_PROPERTY(bool rightHandDM MEMBER rightHandDM);
Q_PROPERTY(int status MEMBER status);
public: public:
explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0); explicit AnnotatedCameraWidget(VisionStreamType type, QWidget* parent = 0);

Loading…
Cancel
Save