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

Method update

examples/three_plots.rs:42–136  ·  view source on GitHub ↗
(&mut self, Message { msg, plot_id }: Message)

Source from the content-addressed store, hash-verified

40
41impl App {
42 fn update(&mut self, Message { msg, plot_id }: Message) {
43 match plot_id {
44 1 => {
45 match msg.get_hover_pick_event() {
46 Some(HoverPickEvent::Hover(p1)) => {
47 if let Some([x, _]) = self.w1.point_position(p1) {
48 if let Some(p2) = self.w2.nearest_point_horizontal(self.s2_id, x) {
49 self.w2.add_hover_point(p2);
50 }
51 if let Some(p3) = self.w3.nearest_point_horizontal(self.s3_id, x) {
52 self.w3.add_hover_point(p3);
53 }
54 }
55 }
56 Some(HoverPickEvent::Pick(p1)) => {
57 if let Some([x, _]) = self.w1.point_position(p1) {
58 if let Some(p2) = self.w2.nearest_point_horizontal(self.s2_id, x) {
59 self.w2.add_pick_point(p2);
60 }
61 if let Some(p3) = self.w3.nearest_point_horizontal(self.s3_id, x) {
62 self.w3.add_pick_point(p3);
63 }
64 }
65 }
66 Some(HoverPickEvent::ClearPick) => {
67 self.w2.clear_pick();
68 self.w3.clear_pick();
69 }
70 _ => {}
71 }
72 self.w1.update(msg);
73 }
74 2 => {
75 match msg.get_hover_pick_event() {
76 Some(HoverPickEvent::Hover(p2)) => {
77 if let Some([x, _]) = self.w2.point_position(p2) {
78 if let Some(p1) = self.w1.nearest_point_horizontal(self.s1_id, x) {
79 self.w1.add_hover_point(p1);
80 }
81 if let Some(p3) = self.w3.nearest_point_horizontal(self.s3_id, x) {
82 self.w3.add_hover_point(p3);
83 }
84 }
85 }
86 Some(HoverPickEvent::Pick(p2)) => {
87 if let Some([x, _]) = self.w2.point_position(p2) {
88 if let Some(p1) = self.w1.nearest_point_horizontal(self.s1_id, x) {
89 self.w1.add_pick_point(p1);
90 }
91 if let Some(p3) = self.w3.nearest_point_horizontal(self.s3_id, x) {
92 self.w3.add_pick_point(p3);
93 }
94 }
95 }
96 Some(HoverPickEvent::ClearPick) => {
97 self.w1.clear_pick();
98 self.w3.clear_pick();
99 }

Callers

nothing calls this directly

Calls 6

get_hover_pick_eventMethod · 0.80
point_positionMethod · 0.80
add_hover_pointMethod · 0.80
add_pick_pointMethod · 0.80
clear_pickMethod · 0.80

Tested by

no test coverage detected