(
&'a self,
shapes_bottom: impl Iterator<Item = Element<'a, Message>>,
shapes_top: impl Iterator<Item = Element<'a, Message>>,
map_plot: MapPlot,
)
| 656 | self.x_ticks = ticks; |
| 657 | } |
| 658 | if let Some(ticks) = payload.y_ticks { |
| 659 | self.y_ticks = ticks; |
| 660 | } |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | /// View the plot widget. |
| 666 | pub fn view<'a>(&'a self) -> iced::Element<'a, PlotUiMessage> { |
| 667 | self.shape_overlays_enabled.store(false, Ordering::Relaxed); |
| 668 | self.view_with_shape_elements(std::iter::empty(), std::iter::empty(), |message| message) |
| 669 | } |
| 670 | |
| 671 | /// View the plot widget with external Iced elements anchored to plot coordinates. |
| 672 | pub fn view_with_shapes<'a, Message>( |
| 673 | &'a self, |
| 674 | shapes_bottom: impl Iterator<Item = plot_overlay::PlotOverlay<'a, Message>> + 'a, |
| 675 | shapes_top: impl Iterator<Item = plot_overlay::PlotOverlay<'a, Message>> + 'a, |
| 676 | map_plot: impl Fn(PlotUiMessage) -> Message + Copy + 'a, |
| 677 | ) -> iced::Element<'a, Message> |
| 678 | where |
| 679 | Message: 'a, |
| 680 | { |
| 681 | self.shape_overlays_enabled.store(true, Ordering::Relaxed); |
| 682 | |
| 683 | let shapes_bottom = shapes_bottom.filter_map(|shape| self.view_shape_overlay(shape)); |
| 684 | let shapes_top = shapes_top.filter_map(|shape| self.view_shape_overlay(shape)); |
| 685 | self.view_with_shape_elements(shapes_bottom, shapes_top, map_plot) |
| 686 | } |
| 687 | |
| 688 | fn view_with_shape_elements<'a, Message, MapPlot>( |
| 689 | &'a self, |
| 690 | shapes_bottom: impl Iterator<Item = Element<'a, Message>>, |
| 691 | shapes_top: impl Iterator<Item = Element<'a, Message>>, |
| 692 | map_plot: MapPlot, |
| 693 | ) -> iced::Element<'a, Message> |
| 694 | where |
| 695 | Message: 'a, |
| 696 | MapPlot: Fn(PlotUiMessage) -> Message + Copy + 'a, |
| 697 | { |
| 698 | let style = self.cached_style(); |
| 699 | |
| 700 | let tooltip_overlays = self |
| 701 | .visible_highlighted_points() |
| 702 | .filter_map(|(_, tooltip)| self.view_tooltip_overlay(tooltip, &self.camera_bounds)) |
| 703 | .map(|element| element.map(map_plot)); |
| 704 | let shapes_top = shapes_top.chain(tooltip_overlays); |
| 705 | |
| 706 | let inner_container = self.view_plot_area(shapes_bottom, shapes_top, map_plot); |
| 707 | |
| 708 | let legend = if self.legend_enabled { |
| 709 | legend::legend(self, self.legend_collapsed) |
| 710 | } else { |
| 711 | None |
| 712 | }; |
| 713 | let has_legend = legend.is_some(); |
| 714 | |
| 715 | let mut layers = Vec::new(); |
no test coverage detected