Skip to content

Commit

Permalink
Static data 3: static-aware C & C++ SDKs (#5537)
Browse files Browse the repository at this point in the history
Just exposing all the new static stuff to the C & C++ SDKs, and trying
to kill the "timeless" terminology in the process.

---

Part of a PR series that removes the concept of timeless data in favor
of the much simpler concept of static data:
- #5534
- #5535
- #5536
- #5537
- #5540
  • Loading branch information
teh-cmc authored Apr 5, 2024
1 parent 800f409 commit a8f7a62
Show file tree
Hide file tree
Showing 26 changed files with 175 additions and 127 deletions.
16 changes: 8 additions & 8 deletions crates/rerun_c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,15 @@ fn rr_log_file_from_path_impl(
stream: CRecordingStream,
filepath: CStringView,
entity_path_prefix: CStringView,
timeless: bool,
static_: bool,
) -> Result<(), CError> {
let stream = recording_stream(stream)?;

let filepath = filepath.as_str("filepath")?;
let entity_path_prefix = entity_path_prefix.as_str("entity_path_prefix").ok();

stream
.log_file_from_path(filepath, entity_path_prefix.map(Into::into), timeless)
.log_file_from_path(filepath, entity_path_prefix.map(Into::into), static_)
.map_err(|err| {
CError::new(
CErrorCode::RecordingStreamRuntimeFailure,
Expand All @@ -757,10 +757,10 @@ pub unsafe extern "C" fn rr_recording_stream_log_file_from_path(
stream: CRecordingStream,
filepath: CStringView,
entity_path_prefix: CStringView,
timeless: bool,
static_: bool,
error: *mut CError,
) {
if let Err(err) = rr_log_file_from_path_impl(stream, filepath, entity_path_prefix, timeless) {
if let Err(err) = rr_log_file_from_path_impl(stream, filepath, entity_path_prefix, static_) {
err.write_error(error);
}
}
Expand All @@ -772,7 +772,7 @@ fn rr_log_file_from_contents_impl(
filepath: CStringView,
contents: CBytesView,
entity_path_prefix: CStringView,
timeless: bool,
static_: bool,
) -> Result<(), CError> {
let stream = recording_stream(stream)?;

Expand All @@ -785,7 +785,7 @@ fn rr_log_file_from_contents_impl(
filepath,
std::borrow::Cow::Borrowed(contents),
entity_path_prefix.map(Into::into),
timeless,
static_,
)
.map_err(|err| {
CError::new(
Expand All @@ -804,11 +804,11 @@ pub unsafe extern "C" fn rr_recording_stream_log_file_from_contents(
filepath: CStringView,
contents: CBytesView,
entity_path_prefix: CStringView,
timeless: bool,
static_: bool,
error: *mut CError,
) {
if let Err(err) =
rr_log_file_from_contents_impl(stream, filepath, contents, entity_path_prefix, timeless)
rr_log_file_from_contents_impl(stream, filepath, contents, entity_path_prefix, static_)
{
err.write_error(error);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/rerun_c/src/rerun.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ typedef struct rr_data_loader_settings {
/// Unspecified by default.
rr_string entity_path_prefix;

/// Should the logged data be timeless?
/// Should the logged data be static?
///
/// Defaults to `false` if not set.
bool timeless;
bool static_;
} rr_data_loader_settings;

typedef struct rr_store_info {
Expand Down Expand Up @@ -456,7 +456,7 @@ extern void rr_recording_stream_log(
///
/// See <https://www.rerun.io/docs/howto/open-any-file> for more information.
extern void rr_recording_stream_log_file_from_path(
rr_recording_stream stream, rr_string path, rr_string entity_path_prefix, bool timeless,
rr_recording_stream stream, rr_string path, rr_string entity_path_prefix, bool static_,
rr_error* error
);

Expand All @@ -470,7 +470,7 @@ extern void rr_recording_stream_log_file_from_path(
/// See <https://www.rerun.io/docs/howto/open-any-file> for more information.
extern void rr_recording_stream_log_file_from_contents(
rr_recording_stream stream, rr_string path, rr_bytes contents, rr_string entity_path_prefix,
bool timeless, rr_error* error
bool static_, rr_error* error
);

// ----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/annotation_context_connections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main() {
// Log an annotation context to assign a label and color to each class
// Create a class description with labels and color for each keypoint ID as well as some
// connections between keypoints.
rec.log_timeless(
rec.log_static(
"/",
rerun::AnnotationContext({rerun::ClassDescription{
0,
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/annotation_context_rects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {
rec.spawn().exit_on_failure();

// Log an annotation context to assign a label and color to each class
rec.log_timeless(
rec.log_static(
"/",
rerun::AnnotationContext({
rerun::AnnotationInfo(1, "red", rerun::Rgba32(255, 0, 0)),
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/annotation_context_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main() {
rec.spawn().exit_on_failure();

// create an annotation context to describe the classes
rec.log_timeless(
rec.log_static(
"segmentation",
rerun::AnnotationContext({
rerun::AnnotationInfo(1, "red", rerun::Rgba32(255, 0, 0)),
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/asset3d_out_of_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main(int argc, char** argv) {
const auto rec = rerun::RecordingStream("rerun_example_asset3d_out_of_tree");
rec.spawn().exit_on_failure();

rec.log_timeless("world", rerun::ViewCoordinates::RIGHT_HAND_Z_UP); // Set an up-axis
rec.log_static("world", rerun::ViewCoordinates::RIGHT_HAND_Z_UP); // Set an up-axis

rec.set_time_sequence("frame", 0);
rec.log("world/asset", rerun::Asset3D::from_file(path).value_or_throw());
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/asset3d_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ int main(int argc, char* argv[]) {
const auto rec = rerun::RecordingStream("rerun_example_asset3d");
rec.spawn().exit_on_failure();

rec.log_timeless("world", rerun::ViewCoordinates::RIGHT_HAND_Z_UP); // Set an up-axis
rec.log_static("world", rerun::ViewCoordinates::RIGHT_HAND_Z_UP); // Set an up-axis
rec.log("world/asset", rerun::Asset3D::from_file(path).value_or_throw());
}
14 changes: 4 additions & 10 deletions docs/snippets/all/scalar_multiple_plots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@ int main() {
int64_t lcg_state = 0;

// Set up plot styling:
// They are logged timeless as they don't change over time and apply to all timelines.
// They are logged static as they don't change over time and apply to all timelines.
// Log two lines series under a shared root so that they show in the same plot by default.
rec.log_timeless(
"trig/sin",
rerun::SeriesLine().with_color({255, 0, 0}).with_name("sin(0.01t)")
);
rec.log_timeless(
"trig/cos",
rerun::SeriesLine().with_color({0, 255, 0}).with_name("cos(0.01t)")
);
rec.log_static("trig/sin", rerun::SeriesLine().with_color({255, 0, 0}).with_name("sin(0.01t)"));
rec.log_static("trig/cos", rerun::SeriesLine().with_color({0, 255, 0}).with_name("cos(0.01t)"));
// Log scattered points under a different root so that they show in a different plot by default.
rec.log_timeless("scatter/lcg", rerun::SeriesPoint());
rec.log_static("scatter/lcg", rerun::SeriesPoint());

// Log the data on a timeline called "step".
for (int t = 0; t < static_cast<int>(TAU * 2.0 * 100.0); ++t) {
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/segmentation_image_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main() {
}

// create an annotation context to describe the classes
rec.log_timeless(
rec.log_static(
"/",
rerun::AnnotationContext({
rerun::AnnotationInfo(1, "red", rerun::Rgba32(255, 0, 0)),
Expand Down
6 changes: 3 additions & 3 deletions docs/snippets/all/series_line_style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ int main() {
rec.spawn().exit_on_failure();

// Set up plot styling:
// They are logged timeless as they don't change over time and apply to all timelines.
// They are logged static as they don't change over time and apply to all timelines.
// Log two lines series under a shared root so that they show in the same plot by default.
rec.log_timeless(
rec.log_static(
"trig/sin",
rerun::SeriesLine().with_color({255, 0, 0}).with_name("sin(0.01t)").with_width(2)
);
rec.log_timeless(
rec.log_static(
"trig/cos",
rerun::SeriesLine().with_color({0, 255, 0}).with_name("cos(0.01t)").with_width(4)
);
Expand Down
6 changes: 3 additions & 3 deletions docs/snippets/all/series_point_style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ int main() {
rec.spawn().exit_on_failure();

// Set up plot styling:
// They are logged timeless as they don't change over time and apply to all timelines.
// They are logged static as they don't change over time and apply to all timelines.
// Log two point series under a shared root so that they show in the same plot by default.
rec.log_timeless(
rec.log_static(
"trig/sin",
rerun::SeriesPoint()
.with_color({255, 0, 0})
.with_name("sin(0.01t)")
.with_marker(rerun::components::MarkerShape::Circle)
.with_marker_size(4)
);
rec.log_timeless(
rec.log_static(
"trig/cos",
rerun::SeriesPoint()
.with_color({0, 255, 0})
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/view_coordinates_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main() {
const auto rec = rerun::RecordingStream("rerun_example_view_coordinates");
rec.spawn().exit_on_failure();

rec.log_timeless("world", rerun::ViewCoordinates::RIGHT_HAND_Z_UP); // Set an up-axis
rec.log_static("world", rerun::ViewCoordinates::RIGHT_HAND_Z_UP); // Set an up-axis
rec.log(
"world/xyz",
rerun::Arrows3D::from_vectors({{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}
Expand Down
4 changes: 2 additions & 2 deletions examples/cpp/clock/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ int main() {
const auto rec = rerun::RecordingStream("rerun_example_clock");
rec.spawn().exit_on_failure();

rec.log_timeless("world", rerun::ViewCoordinates::RIGHT_HAND_Y_UP);
rec.log_timeless("world/frame", rerun::Boxes3D::from_half_sizes({{LENGTH_S, LENGTH_S, 1.0f}}));
rec.log_static("world", rerun::ViewCoordinates::RIGHT_HAND_Y_UP);
rec.log_static("world/frame", rerun::Boxes3D::from_half_sizes({{LENGTH_S, LENGTH_S, 1.0f}}));

for (int step = 0; step < num_steps; step++) {
log_hand(rec, "seconds", seconds(step), (step % 60) / 60.0f, LENGTH_S, WIDTH_S, 0);
Expand Down
7 changes: 4 additions & 3 deletions examples/cpp/external_data_loader/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ file with Rerun (`rerun file.cpp`).
("application-id", "Optional recommended ID for the application", cxxopts::value<std::string>())
("recording-id", "Optional recommended ID for the recording", cxxopts::value<std::string>())
("entity-path-prefix", "Optional prefix for all entity paths", cxxopts::value<std::string>())
("timeless", "Optionally mark data to be logged as timeless", cxxopts::value<bool>()->default_value("false"))
("timeless", "Deprecated: alias for `--static`", cxxopts::value<bool>()->default_value("false"))
("static", "Optionally mark data to be logged as static", cxxopts::value<bool>()->default_value("false"))
("time", "Optional timestamps to log at (e.g. `--time sim_time=1709203426`) (repeatable)", cxxopts::value<std::vector<std::string>>())
("sequence", "Optional sequences to log at (e.g. `--sequence sim_frame=42`) (repeatable)", cxxopts::value<std::vector<std::string>>())
;
Expand Down Expand Up @@ -118,9 +119,9 @@ file with Rerun (`rerun file.cpp`).
if (args.count("entity-path-prefix")) {
entity_path = args["entity-path-prefix"].as<std::string>() + "/" + filepath;
}
rec.log_with_timeless(
rec.log_with_static(
entity_path,
args["timeless"].as<bool>(),
args["static"].as<bool>() || args["timeless"].as<bool>(),
rerun::TextDocument(text).with_media_type(rerun::MediaType::markdown())
);
}
6 changes: 3 additions & 3 deletions examples/cpp/incremental_logging/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main() {
const auto rec = rerun::RecordingStream("rerun_example_incremental_logging");
rec.spawn().exit_on_failure();

rec.log_timeless(
rec.log_static(
"readme",
rerun::TextDocument(README).with_media_type(rerun::components::MediaType::markdown())
);
Expand All @@ -56,8 +56,8 @@ int main() {
// Only log colors and radii once.
rec.set_time_sequence("frame_nr", 0);
rec.log("points", colors, radii);
// Logging timelessly with `RecordingStream::log_timeless` would also work.
// rec.log_timeless("points", colors, radii);
// Logging statically with `RecordingStream::log_static` would also work.
// rec.log_static("points", colors, radii);

std::default_random_engine gen;
std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f);
Expand Down
2 changes: 1 addition & 1 deletion rerun_cpp/src/rerun/archetypes/annotation_context.hpp

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

2 changes: 1 addition & 1 deletion rerun_cpp/src/rerun/archetypes/asset3d.hpp

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

2 changes: 1 addition & 1 deletion rerun_cpp/src/rerun/archetypes/segmentation_image.hpp

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

6 changes: 3 additions & 3 deletions rerun_cpp/src/rerun/archetypes/series_line.hpp

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

6 changes: 3 additions & 3 deletions rerun_cpp/src/rerun/archetypes/series_point.hpp

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

2 changes: 1 addition & 1 deletion rerun_cpp/src/rerun/archetypes/view_coordinates.hpp

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

8 changes: 4 additions & 4 deletions rerun_cpp/src/rerun/c/rerun.h

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

Loading

0 comments on commit a8f7a62

Please sign in to comment.