MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / view_with_shape_elements

Method view_with_shape_elements

src/plot_widget.rs:658–712  ·  view source on GitHub ↗
(
        &'a self,
        shapes_bottom: impl Iterator<Item = Element<'a, Message>>,
        shapes_top: impl Iterator<Item = Element<'a, Message>>,
        map_plot: MapPlot,
    )

Source from the content-addressed store, hash-verified

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();

Callers 2

viewMethod · 0.80
view_with_shapesMethod · 0.80

Calls 11

legendFunction · 0.85
stack_with_labelsFunction · 0.85
cached_styleMethod · 0.80
mapMethod · 0.80
view_tooltip_overlayMethod · 0.80
view_plot_areaMethod · 0.80
view_tick_labelsMethod · 0.80
update_styleMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected