Skip to content

Commit

Permalink
add draw_order_index_* options for Trailing Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
s-victor committed Mar 28, 2024
1 parent 9691c9f commit eb25caf
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.11.1 (2024-03-28)
-----------------------------
* Trailing Widget
- Add "draw_order_index_*" options,
which sets draw order of plot lines.

2.11.0 (2024-03-28)
-----------------------------
* [New]Fuel calculator
Expand Down
3 changes: 3 additions & 0 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,9 @@ Set reference line style. `0` for solid line, `1` for dashed line.
reference_line_*_width
Set reference line width in pixels. Set value to `0` to hide line.

draw_order_index_*
Set draw order of plot lines.


## Tyre carcass temperature
**This widget displays tyre carcass temperature info.**
Expand Down
2 changes: 1 addition & 1 deletion tinypedal/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


APP_NAME = "TinyPedal"
VERSION = "2.11.0"
VERSION = "2.11.1"
PLATFORM = platform.system()
APP_ICON = "images/icon.png"
COPYRIGHT = "Copyright (C) 2022-2024 TinyPedal developers"
Expand Down
1 change: 1 addition & 0 deletions tinypedal/regex_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"decimal_places|"
"display_margin|"
"display_size|"
"draw_order_index|"
"font_size|"
"icon_size|"
"inner_gap|"
Expand Down
6 changes: 6 additions & 0 deletions tinypedal/template/setting_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,12 @@
"reference_line_5_offset": 0,
"reference_line_5_width": 0,
"reference_line_5_color": "#666666",
"draw_order_index_throttle": 2,
"draw_order_index_brake": 1,
"draw_order_index_clutch": 5,
"draw_order_index_ffb": 6,
"draw_order_index_wheel_lock": 4,
"draw_order_index_wheel_slip": 3,
},
"tyre_carcass": {
"enable": True,
Expand Down
28 changes: 16 additions & 12 deletions tinypedal/widget/trailing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, config):
self.pedal_max_range = self.display_height
self.area_width = self.display_width
self.area_height = self.display_height + self.margin * 2
self.draw_queue = self.config_draw_order()

# Config canvas
self.resize(self.area_width, self.area_height)
Expand Down Expand Up @@ -223,18 +224,9 @@ def draw_plot_section(self):
painter.setBrush(Qt.NoBrush)
self.pen.setStyle(Qt.SolidLine)

if self.wcfg["show_ffb"]:
self.draw_line(painter, "ffb")
if self.wcfg["show_clutch"]:
self.draw_line(painter, "clutch")
if self.wcfg["show_wheel_lock"]:
self.draw_line(painter, "wheel_lock")
if self.wcfg["show_brake"]:
self.draw_line(painter, "brake")
if self.wcfg["show_wheel_slip"]:
self.draw_line(painter, "wheel_slip")
if self.wcfg["show_throttle"]:
self.draw_line(painter, "throttle")
for plot_name in self.draw_queue:
if self.wcfg[f"show_{plot_name}"]:
self.draw_line(painter, plot_name)

def draw_line(self, painter, suffix):
"""Draw plot line"""
Expand Down Expand Up @@ -294,3 +286,15 @@ def set_viewport_orientation(self):
x_pos = 0
width = self.area_width
return QRect(x_pos, y_pos, width, height)

def config_draw_order(self):
"""Config plot draw order"""
plot_list = (
(self.wcfg["draw_order_index_throttle"], "throttle"),
(self.wcfg["draw_order_index_brake"], "brake"),
(self.wcfg["draw_order_index_clutch"], "clutch"),
(self.wcfg["draw_order_index_ffb"], "ffb"),
(self.wcfg["draw_order_index_wheel_lock"], "wheel_lock"),
(self.wcfg["draw_order_index_wheel_slip"], "wheel_slip"),
)
return tuple(zip(*sorted(plot_list, reverse=True)))[1]

0 comments on commit eb25caf

Please sign in to comment.