Expose `PlotGeometry` in public API (#4193)

Expose `egui_plot::items::values::PlotGeometry` in public API so that
`PlotItem`, which is already public, can actually be implemented by
applications. Fixes #3464.

---------

Co-authored-by: Dominique Würtz <dom@blaukraut.info>
This commit is contained in:
dwuertz 2024-03-21 12:27:18 +01:00 committed by GitHub
parent e4f209ec50
commit 0299663cdd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -9,11 +9,11 @@ use crate::*;
use super::{Cursor, LabelFormatter, PlotBounds, PlotTransform}; use super::{Cursor, LabelFormatter, PlotBounds, PlotTransform};
use rect_elem::*; use rect_elem::*;
use values::{ClosestElem, PlotGeometry}; use values::ClosestElem;
pub use bar::Bar; pub use bar::Bar;
pub use box_elem::{BoxElem, BoxSpread}; pub use box_elem::{BoxElem, BoxSpread};
pub use values::{LineStyle, MarkerShape, Orientation, PlotPoint, PlotPoints}; pub use values::{LineStyle, MarkerShape, Orientation, PlotGeometry, PlotPoint, PlotPoints};
mod bar; mod bar;
mod box_elem; mod box_elem;

View File

@ -23,7 +23,8 @@ pub use crate::{
axis::{Axis, AxisHints, HPlacement, Placement, VPlacement}, axis::{Axis, AxisHints, HPlacement, Placement, VPlacement},
items::{ items::{
Arrows, Bar, BarChart, BoxElem, BoxPlot, BoxSpread, HLine, Line, LineStyle, MarkerShape, Arrows, Bar, BarChart, BoxElem, BoxPlot, BoxSpread, HLine, Line, LineStyle, MarkerShape,
Orientation, PlotImage, PlotItem, PlotPoint, PlotPoints, Points, Polygon, Text, VLine, Orientation, PlotGeometry, PlotImage, PlotItem, PlotPoint, PlotPoints, Points, Polygon,
Text, VLine,
}, },
legend::{Corner, Legend}, legend::{Corner, Legend},
memory::PlotMemory, memory::PlotMemory,

View File

@ -116,6 +116,11 @@ impl PlotUi {
self.last_plot_transform.value_from_position(position) self.last_plot_transform.value_from_position(position)
} }
/// Add an arbitrary item.
pub fn add(&mut self, item: impl PlotItem + 'static) {
self.items.push(Box::new(item));
}
/// Add a data line. /// Add a data line.
pub fn line(&mut self, mut line: Line) { pub fn line(&mut self, mut line: Line) {
if line.series.is_empty() { if line.series.is_empty() {