MCPcopy Create free account
hub / github.com/emilk/egui_plot / render_axis_widgets

Method render_axis_widgets

egui_plot/src/plot.rs:1243–1285  ·  view source on GitHub ↗
(&self, ui: &mut Ui, mem: &mut PlotMemory, mut axis_widgets: AxisWidgets<'_>)

Source from the content-addressed store, hash-verified

1241 }
1242
1243 fn render_axis_widgets(&self, ui: &mut Ui, mem: &mut PlotMemory, mut axis_widgets: AxisWidgets<'_>) {
1244 let bounds = mem.transform.bounds();
1245 let x_axis_range = bounds.range_x();
1246 let x_steps = Arc::new({
1247 let input = GridInput {
1248 bounds: (bounds.min[0], bounds.max[0]),
1249 base_step_size: mem.transform.dvalue_dpos()[0].abs() * self.grid_spacing.min as f64,
1250 };
1251 (self.grid_spacers[0])(input)
1252 });
1253 let y_axis_range = bounds.range_y();
1254 let y_steps = Arc::new({
1255 let input = GridInput {
1256 bounds: (bounds.min[1], bounds.max[1]),
1257 base_step_size: mem.transform.dvalue_dpos()[1].abs() * self.grid_spacing.min as f64,
1258 };
1259 (self.grid_spacers[1])(input)
1260 });
1261
1262 // Process X-axis widgets
1263 for widget in &mut axis_widgets[0] {
1264 widget.range = x_axis_range.clone();
1265 widget.transform = Some(mem.transform);
1266 widget.steps = Arc::clone(&x_steps);
1267 }
1268 let x_axis_widgets = std::mem::take(&mut axis_widgets[0]);
1269 for (i, widget) in x_axis_widgets.into_iter().enumerate() {
1270 let (_response, thickness) = widget.ui(ui, Axis::X);
1271 mem.x_axis_thickness.insert(i, thickness);
1272 }
1273
1274 // Process Y-axis widgets
1275 for widget in &mut axis_widgets[1] {
1276 widget.range = y_axis_range.clone();
1277 widget.transform = Some(mem.transform);
1278 widget.steps = Arc::clone(&y_steps);
1279 }
1280 let y_axis_widgets = std::mem::take(&mut axis_widgets[1]);
1281 for (i, widget) in y_axis_widgets.into_iter().enumerate() {
1282 let (_response, thickness) = widget.ui(ui, Axis::Y);
1283 mem.y_axis_thickness.insert(i, thickness);
1284 }
1285 }
1286
1287 fn collect_cursors(&self, ui: &Ui, plot_id: Id) -> Vec<Cursor> {
1288 if let Some((id, _)) = self.linked_cursors.as_ref() {

Callers 1

show_dynMethod · 0.80

Calls 5

range_xMethod · 0.80
dvalue_dposMethod · 0.80
range_yMethod · 0.80
boundsMethod · 0.45
uiMethod · 0.45

Tested by

no test coverage detected