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

Method collect_shapes

egui_plot/src/plot.rs:1315–1365  ·  view source on GitHub ↗
(
        &self,
        ui: &mut Ui,
        plot_ui: &PlotUi<'_>,
        plot_id: Id,
        transform: &PlotTransform,
        show_xy: Vec2b,
    )

Source from the content-addressed store, hash-verified

1313 }
1314
1315 fn collect_shapes(
1316 &self,
1317 ui: &mut Ui,
1318 plot_ui: &PlotUi<'_>,
1319 plot_id: Id,
1320 transform: &PlotTransform,
1321 show_xy: Vec2b,
1322 ) -> (Vec<Shape>, Vec<Cursor>, Option<Id>) {
1323 let mut child_ui = ui.new_child(
1324 egui::UiBuilder::new()
1325 .max_rect(*transform.frame())
1326 .layout(Layout::default()),
1327 );
1328 child_ui.set_clip_rect(transform.frame().intersect(ui.clip_rect()));
1329
1330 let mut shapes = Vec::new();
1331 self.paint_grid(ui, &mut shapes, &plot_ui.items, transform);
1332
1333 // Use plot_ui to provide context for items to generate their shapes
1334 for item in &plot_ui.items {
1335 item.shapes(&child_ui, transform, &mut shapes);
1336 }
1337
1338 let hover_pos = plot_ui.response.hover_pos();
1339 // Use ui to access style and context information for hover detection
1340 let (cursors, hovered_item_id) = if let Some(pointer) = hover_pos {
1341 self.handle_hover(ui, pointer, &mut shapes, plot_ui, transform, show_xy)
1342 } else {
1343 (Vec::new(), None)
1344 };
1345
1346 // Draw cursors
1347 // Use ui to get the default ruler color from the UI style if not explicitly set
1348 let line_color = self.cursor_color.unwrap_or_else(|| rulers_color(ui));
1349 let draw_cursor_xy = Vec2b {
1350 x: self.linked_cursors.as_ref().is_some_and(|group| group.1.x),
1351 y: self.linked_cursors.as_ref().is_some_and(|group| group.1.y),
1352 };
1353 let neighbour_cursors = self.collect_cursors(ui, plot_id);
1354 Self::draw_cursor(
1355 &neighbour_cursors,
1356 false,
1357 &mut shapes,
1358 line_color,
1359 draw_cursor_xy,
1360 transform,
1361 );
1362 Self::draw_cursor(&cursors, true, &mut shapes, line_color, draw_cursor_xy, transform);
1363
1364 (shapes, cursors, hovered_item_id)
1365 }
1366
1367 fn paint_grid(
1368 &self,

Callers 1

show_dynMethod · 0.80

Calls 6

rulers_colorFunction · 0.85
frameMethod · 0.80
paint_gridMethod · 0.80
handle_hoverMethod · 0.80
collect_cursorsMethod · 0.80
shapesMethod · 0.45

Tested by

no test coverage detected