@@ -7,7 +7,7 @@ use epaint::Mesh;
7
7
8
8
use crate :: * ;
9
9
10
- use super :: { Cursor , LabelFormatter , PlotBounds , ScreenTransform } ;
10
+ use super :: { Cursor , LabelFormatter , PlotBounds , PlotTransform } ;
11
11
use rect_elem:: * ;
12
12
use values:: { ClosestElem , PlotGeometry } ;
13
13
@@ -25,14 +25,14 @@ const DEFAULT_FILL_ALPHA: f32 = 0.05;
25
25
/// Container to pass-through several parameters related to plot visualization
26
26
pub ( super ) struct PlotConfig < ' a > {
27
27
pub ui : & ' a Ui ,
28
- pub transform : & ' a ScreenTransform ,
28
+ pub transform : & ' a PlotTransform ,
29
29
pub show_x : bool ,
30
30
pub show_y : bool ,
31
31
}
32
32
33
33
/// Trait shared by things that can be drawn in the plot.
34
34
pub ( super ) trait PlotItem {
35
- fn shapes ( & self , ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) ;
35
+ fn shapes ( & self , ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) ;
36
36
37
37
/// For plot-items which are generated based on x values (plotting functions).
38
38
fn initialize ( & mut self , x_range : RangeInclusive < f64 > ) ;
@@ -49,7 +49,7 @@ pub(super) trait PlotItem {
49
49
50
50
fn bounds ( & self ) -> PlotBounds ;
51
51
52
- fn find_closest ( & self , point : Pos2 , transform : & ScreenTransform ) -> Option < ClosestElem > {
52
+ fn find_closest ( & self , point : Pos2 , transform : & PlotTransform ) -> Option < ClosestElem > {
53
53
match self . geometry ( ) {
54
54
PlotGeometry :: None => None ,
55
55
@@ -177,7 +177,7 @@ impl HLine {
177
177
}
178
178
179
179
impl PlotItem for HLine {
180
- fn shapes ( & self , ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
180
+ fn shapes ( & self , ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
181
181
let HLine {
182
182
y,
183
183
stroke,
@@ -293,7 +293,7 @@ impl VLine {
293
293
}
294
294
295
295
impl PlotItem for VLine {
296
- fn shapes ( & self , ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
296
+ fn shapes ( & self , ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
297
297
let VLine {
298
298
x,
299
299
stroke,
@@ -423,7 +423,7 @@ fn y_intersection(p1: &Pos2, p2: &Pos2, y: f32) -> Option<f32> {
423
423
}
424
424
425
425
impl PlotItem for Line {
426
- fn shapes ( & self , _ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
426
+ fn shapes ( & self , _ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
427
427
let Self {
428
428
series,
429
429
stroke,
@@ -584,7 +584,7 @@ impl Polygon {
584
584
}
585
585
586
586
impl PlotItem for Polygon {
587
- fn shapes ( & self , _ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
587
+ fn shapes ( & self , _ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
588
588
let Self {
589
589
series,
590
590
stroke,
@@ -696,7 +696,7 @@ impl Text {
696
696
}
697
697
698
698
impl PlotItem for Text {
699
- fn shapes ( & self , ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
699
+ fn shapes ( & self , ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
700
700
let color = if self . color == Color32 :: TRANSPARENT {
701
701
ui. style ( ) . visuals . text_color ( )
702
702
} else {
@@ -836,7 +836,7 @@ impl Points {
836
836
}
837
837
838
838
impl PlotItem for Points {
839
- fn shapes ( & self , _ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
839
+ fn shapes ( & self , _ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
840
840
let sqrt_3 = 3_f32 . sqrt ( ) ;
841
841
let frac_sqrt_3_2 = 3_f32 . sqrt ( ) / 2.0 ;
842
842
let frac_1_sqrt_2 = 1.0 / 2_f32 . sqrt ( ) ;
@@ -1039,7 +1039,7 @@ impl Arrows {
1039
1039
}
1040
1040
1041
1041
impl PlotItem for Arrows {
1042
- fn shapes ( & self , _ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
1042
+ fn shapes ( & self , _ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
1043
1043
use crate :: emath:: * ;
1044
1044
let Self {
1045
1045
origins,
@@ -1178,7 +1178,7 @@ impl PlotImage {
1178
1178
}
1179
1179
1180
1180
impl PlotItem for PlotImage {
1181
- fn shapes ( & self , ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
1181
+ fn shapes ( & self , ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
1182
1182
let Self {
1183
1183
position,
1184
1184
texture_id,
@@ -1369,7 +1369,7 @@ impl BarChart {
1369
1369
}
1370
1370
1371
1371
impl PlotItem for BarChart {
1372
- fn shapes ( & self , _ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
1372
+ fn shapes ( & self , _ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
1373
1373
for b in & self . bars {
1374
1374
b. add_shapes ( transform, self . highlight , shapes) ;
1375
1375
}
@@ -1407,7 +1407,7 @@ impl PlotItem for BarChart {
1407
1407
bounds
1408
1408
}
1409
1409
1410
- fn find_closest ( & self , point : Pos2 , transform : & ScreenTransform ) -> Option < ClosestElem > {
1410
+ fn find_closest ( & self , point : Pos2 , transform : & PlotTransform ) -> Option < ClosestElem > {
1411
1411
find_closest_rect ( & self . bars , point, transform)
1412
1412
}
1413
1413
@@ -1512,7 +1512,7 @@ impl BoxPlot {
1512
1512
}
1513
1513
1514
1514
impl PlotItem for BoxPlot {
1515
- fn shapes ( & self , _ui : & mut Ui , transform : & ScreenTransform , shapes : & mut Vec < Shape > ) {
1515
+ fn shapes ( & self , _ui : & mut Ui , transform : & PlotTransform , shapes : & mut Vec < Shape > ) {
1516
1516
for b in & self . boxes {
1517
1517
b. add_shapes ( transform, self . highlight , shapes) ;
1518
1518
}
@@ -1550,7 +1550,7 @@ impl PlotItem for BoxPlot {
1550
1550
bounds
1551
1551
}
1552
1552
1553
- fn find_closest ( & self , point : Pos2 , transform : & ScreenTransform ) -> Option < ClosestElem > {
1553
+ fn find_closest ( & self , point : Pos2 , transform : & PlotTransform ) -> Option < ClosestElem > {
1554
1554
find_closest_rect ( & self . boxes , point, transform)
1555
1555
}
1556
1556
@@ -1582,7 +1582,7 @@ pub(crate) fn rulers_color(ui: &Ui) -> Color32 {
1582
1582
1583
1583
pub ( crate ) fn vertical_line (
1584
1584
pointer : Pos2 ,
1585
- transform : & ScreenTransform ,
1585
+ transform : & PlotTransform ,
1586
1586
line_color : Color32 ,
1587
1587
) -> Shape {
1588
1588
let frame = transform. frame ( ) ;
@@ -1597,7 +1597,7 @@ pub(crate) fn vertical_line(
1597
1597
1598
1598
pub ( crate ) fn horizontal_line (
1599
1599
pointer : Pos2 ,
1600
- transform : & ScreenTransform ,
1600
+ transform : & PlotTransform ,
1601
1601
line_color : Color32 ,
1602
1602
) -> Shape {
1603
1603
let frame = transform. frame ( ) ;
@@ -1731,7 +1731,7 @@ pub(super) fn rulers_at_value(
1731
1731
fn find_closest_rect < ' a , T > (
1732
1732
rects : impl IntoIterator < Item = & ' a T > ,
1733
1733
point : Pos2 ,
1734
- transform : & ScreenTransform ,
1734
+ transform : & PlotTransform ,
1735
1735
) -> Option < ClosestElem >
1736
1736
where
1737
1737
T : ' a + RectElement ,
0 commit comments