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

Method rebuild_from_widget

src/plot_state.rs:155–348  ·  view source on GitHub ↗

Rebuild GPU data from widget configuration.

(&mut self, widget: &PlotWidget)

Source from the content-addressed store, hash-verified

153 if self.highlighted_points.as_ref() != highlighted_points.as_slice() {
154 self.highlight_version = self.highlight_version.wrapping_add(1);
155 self.highlighted_points = highlighted_points.into();
156 true
157 } else {
158 false
159 }
160 }
161
162 /// Rebuild GPU data from widget configuration.
163 pub(crate) fn rebuild_from_widget(&mut self, widget: &PlotWidget) {
164 let mut points = Vec::new();
165 let mut point_colors = Vec::new();
166 let mut series_spans = Vec::new();
167 let mut data_min_x: Option<f64> = None;
168 let mut data_max_x: Option<f64> = None;
169 let mut data_min_y: Option<f64> = None;
170 let mut data_max_y: Option<f64> = None;
171 let mut rightmost_x: f64 = f64::NEG_INFINITY;
172 let mut rightmost_y: Option<f64> = None;
173 let axis_ranges = self.camera.axis_ranges();
174
175 // Process each series
176 for (id, series) in &widget.series {
177 // Skip hidden series
178 if widget.hidden_shapes.contains(id) {
179 continue;
180 }
181
182 if series.positions.is_empty() {
183 continue;
184 }
185
186 let start = points.len();
187 let mut point_indices = Vec::new();
188 let x_uses_axes = series
189 .transform
190 .x
191 .as_ref()
192 .is_some_and(|transform| transform.uses_axes_coordinates());
193 let y_uses_axes = series
194 .transform
195 .y
196 .as_ref()
197 .is_some_and(|transform| transform.uses_axes_coordinates());
198
199 // Add points and track bounds
200 for (pos_index, &pos) in series.positions.iter().enumerate() {
201 let Some(transformed) = data_point_to_plot_with_transform(
202 pos,
203 widget.x_axis_scale,
204 widget.y_axis_scale,
205 &series.transform,
206 Some(axis_ranges),
207 ) else {
208 continue;
209 };
210
211 if !x_uses_axes {
212 data_min_x =

Calls 13

plot_x_domainFunction · 0.85
plot_y_domainFunction · 0.85
build_fill_spanFunction · 0.85
axis_rangesMethod · 0.80
is_emptyMethod · 0.80
uses_axes_coordinatesMethod · 0.80
mapMethod · 0.80
to_rawMethod · 0.80
getMethod · 0.80
thenMethod · 0.80