mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-25 03:22:07 +08:00
Compare commits
24 Commits
g80-2022
...
optima-h-new
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ac81d1373 | |||
| e5ee76f88a | |||
| eea5936c68 | |||
| b2594929e4 | |||
| 2584bc9622 | |||
| 909293ab6d | |||
| 13c2b74773 | |||
| 9932519a3b | |||
| e3ae6ea5a3 | |||
| 4111b3c175 | |||
| 56a34030bf | |||
| d306f457a5 | |||
| f8b892b547 | |||
| 4957bb69bc | |||
| be1e38768d | |||
| f88be7a0d1 | |||
| 6f0257fe12 | |||
| f0053d4619 | |||
| 052692b25d | |||
| 7f2898475c | |||
| fa9fb9c742 | |||
| 7dd3972810 | |||
| ab6a93acf8 | |||
| d129fe1878 |
+1
-1
Submodule opendbc_repo updated: ef70686afe...cdf4f6b786
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:eb6992bd60bada6162fea298e1a414b6b3d6a326db4eda46b9de62bcd8554754
|
||||
size 13393859
|
||||
oid sha256:e53f4e0527766082ba7bde38e275def0fe3c14f6c59ae2854439e239884d3ecc
|
||||
size 13393365
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:86680a657bbb34f997034d1930bb2cb65c38b9222cea199732f72bd45791cfad
|
||||
size 13022803
|
||||
oid sha256:ea89c50da3a16e710da292f97c81b083a982cfdee5c28eca0d37ed2fb99af6c5
|
||||
size 13022642
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7af05e03fd170653ff5771baf373a2c57b363da12c4c411cd416dee067b4cf58
|
||||
size 23266366
|
||||
oid sha256:6263aa3fbb44cde6c68a34cdb7cd8c389789dbc02b15c1911afdac4e018281ae
|
||||
size 23267151
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <unordered_set>
|
||||
|
||||
constexpr double PLOT_Y_PAD_FRACTION = 0.4;
|
||||
|
||||
@@ -74,10 +73,6 @@ struct StateBlock {
|
||||
std::string label;
|
||||
};
|
||||
|
||||
struct PaneEnumContext {
|
||||
std::vector<const EnumInfo *> enums;
|
||||
};
|
||||
|
||||
struct PaneValueFormatContext {
|
||||
SeriesFormat format;
|
||||
bool valid = false;
|
||||
@@ -106,38 +101,6 @@ bool curves_are_bool_like(const std::vector<PreparedCurve> &prepared_curves) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool curve_is_state_like(const PreparedCurve &curve) {
|
||||
if (!curve.display_info.integer_like || curve.xs.size() < 2 || curve.xs.size() != curve.ys.size()) {
|
||||
return false;
|
||||
}
|
||||
if (curve.enum_info != nullptr) {
|
||||
return true;
|
||||
}
|
||||
std::unordered_set<int> distinct_values;
|
||||
for (double value : curve.ys) {
|
||||
if (!std::isfinite(value)) {
|
||||
continue;
|
||||
}
|
||||
distinct_values.insert(static_cast<int>(std::llround(value)));
|
||||
if (distinct_values.size() > 12) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !distinct_values.empty();
|
||||
}
|
||||
|
||||
bool curves_use_state_blocks(const std::vector<PreparedCurve> &prepared_curves) {
|
||||
if (prepared_curves.empty()) {
|
||||
return false;
|
||||
}
|
||||
for (const PreparedCurve &curve : prepared_curves) {
|
||||
if (!curve_is_state_like(curve)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ImU32 state_block_color(int value, float alpha = 1.0f) {
|
||||
static constexpr std::array<std::array<uint8_t, 3>, 8> kPalette = {{
|
||||
{{111, 143, 175}},
|
||||
@@ -307,36 +270,6 @@ std::optional<double> app_sample_xy_value_at_time(const std::vector<double> &xs,
|
||||
return y0 + (y1 - y0) * alpha;
|
||||
}
|
||||
|
||||
int format_enum_axis_tick(double value, char *buf, int size, void *user_data) {
|
||||
const auto *ctx = static_cast<const PaneEnumContext *>(user_data);
|
||||
const int idx = static_cast<int>(std::llround(value));
|
||||
if (ctx != nullptr && idx >= 0 && std::abs(value - static_cast<double>(idx)) < 0.01) {
|
||||
std::vector<std::string_view> names;
|
||||
names.reserve(ctx->enums.size());
|
||||
for (const EnumInfo *info : ctx->enums) {
|
||||
if (info == nullptr || static_cast<size_t>(idx) >= info->names.size()) {
|
||||
continue;
|
||||
}
|
||||
const std::string &name = info->names[static_cast<size_t>(idx)];
|
||||
if (name.empty()) continue;
|
||||
if (std::find(names.begin(), names.end(), std::string_view(name)) == names.end()) {
|
||||
names.emplace_back(name);
|
||||
}
|
||||
}
|
||||
if (!names.empty()) {
|
||||
std::string joined;
|
||||
for (size_t i = 0; i < names.size(); ++i) {
|
||||
if (i != 0) {
|
||||
joined += ", ";
|
||||
}
|
||||
joined += names[i];
|
||||
}
|
||||
return std::snprintf(buf, size, "%d (%s)", idx, joined.c_str());
|
||||
}
|
||||
}
|
||||
return std::snprintf(buf, size, "%.6g", value);
|
||||
}
|
||||
|
||||
int format_numeric_axis_tick(double value, char *buf, int size, void *user_data) {
|
||||
const auto *ctx = static_cast<const PaneValueFormatContext *>(user_data);
|
||||
if (ctx == nullptr || !ctx->valid) {
|
||||
@@ -831,23 +764,16 @@ void draw_plot(const AppSession &session, Pane *pane, UiState *state) {
|
||||
}
|
||||
|
||||
const PlotBounds bounds = compute_plot_bounds(*pane, prepared_curves, *state);
|
||||
PaneEnumContext enum_context;
|
||||
PaneValueFormatContext pane_value_format;
|
||||
const bool state_block_mode = curves_use_state_blocks(prepared_curves);
|
||||
bool all_enum_curves = !prepared_curves.empty();
|
||||
bool state_block_mode = !prepared_curves.empty();
|
||||
size_t max_legend_label_width = 0;
|
||||
for (const PreparedCurve &curve : prepared_curves) {
|
||||
max_legend_label_width = std::max(max_legend_label_width, curve.label.size());
|
||||
if (curve.enum_info != nullptr) {
|
||||
enum_context.enums.push_back(curve.enum_info);
|
||||
} else {
|
||||
all_enum_curves = false;
|
||||
if (curve.enum_info == nullptr) {
|
||||
state_block_mode = false;
|
||||
merge_pane_value_format(&pane_value_format, curve.display_info);
|
||||
}
|
||||
}
|
||||
if (prepared_curves.empty()) {
|
||||
all_enum_curves = false;
|
||||
}
|
||||
const int supported_count = static_cast<int>(prepared_curves.size());
|
||||
const ImVec2 plot_size = ImGui::GetContentRegionAvail();
|
||||
const bool has_cursor_time = state->has_tracker_time;
|
||||
@@ -895,8 +821,6 @@ void draw_plot(const AppSession &session, Pane *pane, UiState *state) {
|
||||
ImPlot::SetupAxisFormat(ImAxis_X1, "%.1f");
|
||||
if (state_block_mode) {
|
||||
ImPlot::SetupAxisLimits(ImAxis_Y1, 0.0, 1.0, ImPlotCond_Always);
|
||||
} else if (all_enum_curves && !enum_context.enums.empty()) {
|
||||
ImPlot::SetupAxisFormat(ImAxis_Y1, format_enum_axis_tick, &enum_context);
|
||||
} else if (pane_value_format.valid) {
|
||||
ImPlot::SetupAxisFormat(ImAxis_Y1, format_numeric_axis_tick, &pane_value_format);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user