Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextDocument archetype #3173

Merged
merged 16 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ re_space_view_bar_chart = { path = "crates/re_space_view_bar_chart", version = "
re_space_view_spatial = { path = "crates/re_space_view_spatial", version = "=0.9.0-alpha.3", default-features = false }
re_space_view_tensor = { path = "crates/re_space_view_tensor", version = "=0.9.0-alpha.3", default-features = false }
re_space_view_text = { path = "crates/re_space_view_text", version = "=0.9.0-alpha.3", default-features = false }
re_space_view_text_box = { path = "crates/re_space_view_text_box", version = "=0.9.0-alpha.3", default-features = false }
re_space_view_text_document = { path = "crates/re_space_view_text_document", version = "=0.9.0-alpha.3", default-features = false }
re_space_view_time_series = { path = "crates/re_space_view_time_series", version = "=0.9.0-alpha.3", default-features = false }
re_string_interner = { path = "crates/re_string_interner", version = "=0.9.0-alpha.3", default-features = false }
re_tensor_ops = { path = "crates/re_tensor_ops", version = "=0.9.0-alpha.3", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions crates/re_components/src/datagen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn build_some_instances_from(instances: impl IntoIterator<Item = u64>) -> Ve
#[cfg(not(target_arch = "wasm32"))]
pub fn data_table_example(timeless: bool) -> re_log_types::DataTable {
use re_log_types::{DataRow, DataTable, RowId, TableId, TimePoint};
use re_types::components::{Color, Label, Point2D};
use re_types::components::{Color, Point2D, Text};

let table_id = TableId::random();

Expand All @@ -110,7 +110,7 @@ pub fn data_table_example(timeless: bool) -> re_log_types::DataTable {
let num_instances = 2;
let points: &[Point2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()];
let colors: &[_] = &[Color::from_rgb(128, 128, 128)];
let labels: &[Label] = &[];
let labels: &[Text] = &[];

DataRow::from_cells3(
RowId::random(),
Expand All @@ -131,7 +131,7 @@ pub fn data_table_example(timeless: bool) -> re_log_types::DataTable {
let row2 = {
let num_instances = 1;
let colors: &[_] = &[Color::from_rgb(255, 255, 255)];
let labels: &[_] = &[Label("hey".into())];
let labels: &[_] = &[Text("hey".into())];

DataRow::from_cells2(
RowId::random(),
Expand Down
10 changes: 4 additions & 6 deletions crates/re_components/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use arrow2_convert::{
serialize::ArrowSerialize,
};
use lazy_static::lazy_static;

use re_types::Loggable;

mod bbox;
Expand All @@ -29,7 +30,6 @@ mod rect;
mod scalar;
mod tensor;
mod tensor_data;
mod text_box;
mod text_entry;
mod vec;

Expand All @@ -56,7 +56,6 @@ pub use self::{
DecodedTensor, Tensor, TensorCastError, TensorData, TensorDataMeaning, TensorDimension,
},
tensor_data::{TensorDataType, TensorDataTypeTrait, TensorElement},
text_box::TextBox,
text_entry::TextEntry,
};

Expand All @@ -83,12 +82,12 @@ pub mod external {

use re_types::components::{
AnnotationContext, ClassId, Color, DisconnectedSpace, DrawOrder, InstanceKey, KeypointId,
Label, LineStrip2D, LineStrip3D, Origin3D, Point2D, Point3D, Radius, Transform3D, Vector3D,
LineStrip2D, LineStrip3D, Origin3D, Point2D, Point3D, Radius, Text, Transform3D, Vector3D,
};

lazy_static! {
//TODO(john): use a run-time type registry
static ref FIELDS: [Field; 28] = [
static ref FIELDS: [Field; 27] = [
<Box3D as LegacyComponent>::field(),
<LegacyVec3D as LegacyComponent>::field(),
<Mesh3D as LegacyComponent>::field(),
Expand All @@ -98,7 +97,6 @@ lazy_static! {
<Scalar as LegacyComponent>::field(),
<ScalarPlotProps as LegacyComponent>::field(),
<Tensor as LegacyComponent>::field(),
<TextBox as LegacyComponent>::field(),
<TextEntry as LegacyComponent>::field(),
<ViewCoordinates as LegacyComponent>::field(),
AnnotationContext::arrow_field(),
Expand All @@ -108,13 +106,13 @@ lazy_static! {
DrawOrder::arrow_field(),
InstanceKey::arrow_field(),
KeypointId::arrow_field(),
Label::arrow_field(),
LineStrip2D::arrow_field(),
LineStrip3D::arrow_field(),
Origin3D::arrow_field(),
Point2D::arrow_field(),
Point3D::arrow_field(),
Radius::arrow_field(),
Text::arrow_field(),
Transform3D::arrow_field(),
Vector3D::arrow_field(),
];
Expand Down
43 changes: 0 additions & 43 deletions crates/re_components/src/text_box.rs

This file was deleted.

4 changes: 2 additions & 2 deletions crates/re_components/tests/data_row.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use re_log_types::{DataRow, DataRowError, EntityPath, RowId, TimePoint};
use re_types::{
components::{Color, Label, Point2D},
components::{Color, Point2D, Text},
Loggable as _,
};

Expand All @@ -12,7 +12,7 @@ fn data_row_error_num_instances() {
let num_instances = 2;
let points: &[Point2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()];
let colors: &[_] = &[Color::from_rgb(128, 128, 128)];
let labels: &[Label] = &[];
let labels: &[Text] = &[];

// 0 = clear: legal
DataRow::try_from_cells1(row_id, "a/b/c", timepoint.clone(), num_instances, labels).unwrap();
Expand Down
8 changes: 4 additions & 4 deletions crates/re_components/tests/data_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ fn data_table_sizes_basics() {
// utf8 (and more generally: dyn_binary)
let mut cell = DataCell::from_native(
[
re_types::components::Label("hey".into()),
re_types::components::Label("hey".into()),
re_types::components::Label("hey".into()),
re_types::components::Text("hey".into()),
re_types::components::Text("hey".into()),
re_types::components::Text("hey".into()),
]
.as_slice(),
);
Expand All @@ -79,7 +79,7 @@ fn data_table_sizes_basics() {
);
expect(
DataCell::from_arrow(
re_types::components::Label::name(),
re_types::components::Text::name(),
cell.to_arrow().sliced(1, 1),
),
10_000, // num_rows
Expand Down
6 changes: 3 additions & 3 deletions crates/re_components/tests/data_table_batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use re_log_types::{
DataRow, DataTableBatcher, DataTableBatcherConfig, RowId, SizeBytes, TimePoint, Timeline,
};
use re_log_types::{DataTable, TableId, Time};
use re_types::components::{Color, Label, Point2D};
use re_types::components::{Color, Point2D, Text};

#[test]
fn manual_trigger() {
Expand Down Expand Up @@ -283,7 +283,7 @@ fn create_table() -> DataTable {
let num_instances = 2;
let points: &[Point2D] = &[[10.0, 10.0].into(), [20.0, 20.0].into()];
let colors: &[_] = &[Color::from_rgb(128, 128, 128)];
let labels: &[Label] = &[];
let labels: &[Text] = &[];

DataRow::from_cells3(
RowId::random(),
Expand All @@ -304,7 +304,7 @@ fn create_table() -> DataTable {
let row2 = {
let num_instances = 1;
let colors: &[_] = &[Color::from_rgb(255, 255, 255)];
let labels: &[_] = &[Label("hey".into())];
let labels: &[_] = &[Text("hey".into())];

DataRow::from_cells2(
RowId::random(),
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_ui/src/annotation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fn class_description_ui(
.and_then(|info| info.label.as_ref())
.map_or_else(
|| format!("id {}", id.0),
|label| label.0.as_str().to_owned(),
|label| label.to_string(),
),
);
});
Expand Down Expand Up @@ -263,7 +263,7 @@ fn annotation_info_table_ui<'a>(
});
row.col(|ui| {
let label = if let Some(label) = &info.label {
label.0.as_str()
label.as_str()
} else {
""
};
Expand Down
4 changes: 2 additions & 2 deletions crates/re_log_types/src/data_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl DataCell {
///
/// Fails if the underlying arrow data cannot be deserialized into `C`.
#[inline]
pub fn try_to_native<'a, C: Component + Default + 'a>(&'a self) -> DataCellResult<Vec<C>> {
pub fn try_to_native<'a, C: Component + 'a>(&'a self) -> DataCellResult<Vec<C>> {
re_tracing::profile_function!(C::name().as_str());
Ok(C::try_from_arrow(self.inner.values.as_ref())?)
}
Expand Down Expand Up @@ -396,7 +396,7 @@ impl DataCell {
/// Panics if the underlying arrow data cannot be deserialized into `C`.
/// See [`Self::try_to_native`] for a fallible alternative.
#[inline]
pub fn to_native<'a, C: Component + Default + 'a>(&'a self) -> Vec<C> {
pub fn to_native<'a, C: Component + 'a>(&'a self) -> Vec<C> {
self.try_to_native().unwrap()
}

Expand Down
10 changes: 5 additions & 5 deletions crates/re_query/benches/query_benchmark2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use re_log_types::{entity_path, DataRow, EntityPath, Index, RowId, TimeInt, Time
use re_query::query_archetype;
use re_types::{
archetypes::Points2D,
components::{Color, InstanceKey, Label, Point2D},
components::{Color, InstanceKey, Point2D, Text},
Loggable as _,
};

Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn build_frame_nr(frame_nr: TimeInt) -> (Timeline, TimeInt) {
(Timeline::new("frame_nr", TimeType::Sequence), frame_nr)
}

pub fn build_some_strings(len: usize) -> Vec<Label> {
pub fn build_some_strings(len: usize) -> Vec<Text> {
use rand::Rng as _;
let mut rng = rand::thread_rng();

Expand All @@ -76,7 +76,7 @@ pub fn build_some_strings(len: usize) -> Vec<Label> {
.take(ilen)
.map(char::from)
.collect();
Label::from(s)
Text::from(s)
})
.collect()
}
Expand Down Expand Up @@ -278,7 +278,7 @@ fn query_and_visit_points(store: &mut DataStore, paths: &[EntityPath]) -> Vec<Sa
}

struct SaveString {
_label: Option<Label>,
_label: Option<Text>,
}

fn query_and_visit_strings(store: &mut DataStore, paths: &[EntityPath]) -> Vec<SaveString> {
Expand All @@ -290,7 +290,7 @@ fn query_and_visit_strings(store: &mut DataStore, paths: &[EntityPath]) -> Vec<S
for path in paths {
let arch_view = query_archetype::<Points2D>(store, &query, path).unwrap();
arch_view
.iter_optional_component::<Label>()
.iter_optional_component::<Text>()
.unwrap()
.for_each(|label| {
strings.push(SaveString { _label: label });
Expand Down
2 changes: 1 addition & 1 deletion crates/re_query/src/archetype_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<A: Archetype> ArchetypeView<A> {

/// Iterate over the values of a required [`Component`].
#[inline]
pub fn iter_required_component<'a, C: Component + Default + 'a>(
pub fn iter_required_component<'a, C: Component + 'a>(
&'a self,
) -> DeserializationResult<impl Iterator<Item = C> + '_> {
re_tracing::profile_function!();
Expand Down
2 changes: 1 addition & 1 deletion crates/re_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub mod components {
};
pub use re_types::components::{
AnnotationContext, ClassId, Color, DisconnectedSpace, DrawOrder, InstanceKey, KeypointId,
Label, LineStrip2D, LineStrip3D, Origin3D, Point2D, Point3D, Radius, Transform3D, Vector3D,
LineStrip2D, LineStrip3D, Origin3D, Point2D, Point3D, Radius, Text, Transform3D, Vector3D,
};
}

Expand Down
6 changes: 1 addition & 5 deletions crates/re_space_view_bar_chart/src/view_part_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ impl ViewPartSystem for BarChartViewPartSystem {

let store = &ctx.store_db.entity_db.data_store;

for (ent_path, props) in query.iter_entities_for_system(Self::name()) {
if !props.visible {
continue;
}

for (ent_path, _props) in query.iter_entities_for_system(Self::name()) {
let query = LatestAtQuery::new(query.timeline, query.latest_at);
let tensor = store.query_latest_component::<Tensor>(ent_path, &query);

Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view_spatial/src/parts/arrows3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use re_query::{ArchetypeView, QueryError};
use re_renderer::renderer::LineStripFlags;
use re_types::{
archetypes::Arrows3D,
components::{Label, Origin3D, Vector3D},
components::{Origin3D, Text, Vector3D},
Archetype as _,
};
use re_viewer_context::{
Expand Down Expand Up @@ -48,7 +48,7 @@ impl Arrows3DPart {
annotation_infos.iter(),
arch_view.iter_required_component::<Vector3D>()?,
arch_view.iter_optional_component::<Origin3D>()?,
arch_view.iter_optional_component::<Label>()?,
arch_view.iter_optional_component::<Text>()?,
colors,
instance_path_hashes,
)
Expand Down
6 changes: 3 additions & 3 deletions crates/re_space_view_spatial/src/parts/boxes2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use re_data_store::EntityPath;
use re_query::{EntityView, QueryError};
use re_renderer::Size;
use re_types::{
components::{ClassId, Color, InstanceKey, Label, Radius},
components::{ClassId, Color, InstanceKey, Radius, Text},
Loggable as _,
};
use re_viewer_context::{
Expand Down Expand Up @@ -50,7 +50,7 @@ impl Boxes2DPart {
rect,
color: Option<Color>,
radius: Option<Radius>,
label: Option<Label>,
label: Option<Text>,
class_id: Option<ClassId>| {
let instance_hash =
re_data_store::InstancePathHash::instance(ent_path, instance_key);
Expand Down Expand Up @@ -121,7 +121,7 @@ impl ViewPartSystem for Boxes2DPart {
InstanceKey::name(),
Color::name(),
Radius::name(),
Label::name(),
Text::name(),
ClassId::name(),
]
}
Expand Down
Loading