11use re_query_cache:: { MaybeCachedComponentData , QueryError } ;
22use re_types:: archetypes;
3+ use re_types:: components:: MarkerShape ;
34use re_types:: {
45 archetypes:: SeriesPoint ,
56 components:: { Color , Radius , Scalar , Text } ,
@@ -14,6 +15,7 @@ use crate::overrides::initial_override_color;
1415use crate :: util:: {
1516 determine_plot_bounds_and_time_per_pixel, determine_time_range, points_to_series,
1617} ;
18+ use crate :: ScatterAttrs ;
1719use crate :: { overrides:: lookup_override, PlotPoint , PlotPointAttrs , PlotSeries , PlotSeriesKind } ;
1820
1921/// The system for rendering [`SeriesPoint`] archetypes.
@@ -29,6 +31,10 @@ impl IdentifiedViewSystem for SeriesPointSystem {
2931 }
3032}
3133
34+ // We use a larger default radius for scatter plots so the marker is
35+ // visible.
36+ const DEFAULT_RADIUS : f32 = 3.0 ;
37+
3238impl VisualizerSystem for SeriesPointSystem {
3339 fn visualizer_query_info ( & self ) -> VisualizerQueryInfo {
3440 let mut query_info = VisualizerQueryInfo :: from_archetype :: < archetypes:: Scalar > ( ) ;
@@ -37,6 +43,8 @@ impl VisualizerSystem for SeriesPointSystem {
3743 . map ( ToOwned :: to_owned)
3844 . collect :: < ComponentNameSet > ( ) ;
3945 query_info. queried . append ( & mut series_point_queried) ;
46+ // TODO(jleibs): Use StrokeWidth instead
47+ query_info. queried . insert ( Radius :: name ( ) ) ;
4048 query_info
4149 }
4250
@@ -76,6 +84,8 @@ impl VisualizerSystem for SeriesPointSystem {
7684 ) -> Option < re_log_types:: DataCell > {
7785 if * component == Color :: name ( ) {
7886 Some ( [ initial_override_color ( entity_path) ] . into ( ) )
87+ } else if * component == Radius :: name ( ) {
88+ Some ( [ Radius ( DEFAULT_RADIUS ) ] . into ( ) )
7989 } else {
8090 None
8191 }
@@ -125,16 +135,18 @@ impl SeriesPointSystem {
125135
126136 let override_radius = lookup_override :: < Radius > ( data_result, ctx) . map ( |r| r. 0 ) ;
127137
138+ let override_marker = lookup_override :: < MarkerShape > ( data_result, ctx) ;
139+
128140 let query = re_data_store:: RangeQuery :: new ( query. timeline , time_range) ;
129141
130142 // TODO(jleibs): need to do a "joined" archetype query
131143 query_caches
132- . query_archetype_pov1_comp2 :: < archetypes:: Scalar , Scalar , Color , Text , _ > (
144+ . query_archetype_pov1_comp3 :: < archetypes:: Scalar , Scalar , Color , MarkerShape , Text , _ > (
133145 ctx. app_options . experimental_primary_caching_range ,
134146 store,
135147 & query. clone ( ) . into ( ) ,
136148 & data_result. entity_path ,
137- |( ( time, _row_id) , _, scalars, colors, labels) | {
149+ |( ( time, _row_id) , _, scalars, colors, markers , labels) | {
138150 let Some ( time) = time else {
139151 return ;
140152 } ; // scalars cannot be timeless
@@ -154,12 +166,16 @@ impl SeriesPointSystem {
154166 return ;
155167 }
156168
157- for ( scalar, color, label) in itertools:: izip!(
169+ for ( scalar, color, marker , label) in itertools:: izip!(
158170 scalars. iter( ) ,
159171 MaybeCachedComponentData :: iter_or_repeat_opt(
160172 & colors,
161173 scalars. len( )
162174 ) ,
175+ MaybeCachedComponentData :: iter_or_repeat_opt(
176+ & markers,
177+ scalars. len( )
178+ ) ,
163179 //MaybeCachedComponentData::iter_or_repeat_opt(&radii, scalars.len()),
164180 MaybeCachedComponentData :: iter_or_repeat_opt(
165181 & labels,
@@ -178,7 +194,9 @@ impl SeriesPointSystem {
178194 let radius = override_radius
179195 . unwrap_or_else ( || radius. map_or ( DEFAULT_RADIUS , |r| r. 0 ) ) ;
180196
181- const DEFAULT_RADIUS : f32 = 0.75 ;
197+ let marker = override_marker. unwrap_or ( marker. unwrap_or_default ( ) ) ;
198+
199+
182200
183201 points. push ( PlotPoint {
184202 time : time. as_i64 ( ) ,
@@ -187,7 +205,7 @@ impl SeriesPointSystem {
187205 label,
188206 color,
189207 radius,
190- kind : PlotSeriesKind :: Scatter ,
208+ kind : PlotSeriesKind :: Scatter ( ScatterAttrs { marker } ) ,
191209 } ,
192210 } ) ;
193211 }
0 commit comments