Skip to content

Commit

Permalink
Rename initial_value -> value
Browse files Browse the repository at this point in the history
  • Loading branch information
jkulhanek committed Jan 29, 2024
1 parent 2d6802f commit 5a49853
Show file tree
Hide file tree
Showing 27 changed files with 202 additions and 124 deletions.
16 changes: 8 additions & 8 deletions docs/source/examples/02_gui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Examples of basic GUI elements that we can create, read from, and write to.
with server.add_gui_folder("Read-only"):
gui_counter = server.add_gui_number(
"Counter",
initial_value=0,
value=0,
disabled=True,
)
Expand All @@ -36,38 +36,38 @@ Examples of basic GUI elements that we can create, read from, and write to.
min=0,
max=100,
step=1,
initial_value=0,
value=0,
disabled=True,
)
with server.add_gui_folder("Editable"):
gui_vector2 = server.add_gui_vector2(
"Position",
initial_value=(0.0, 0.0),
value=(0.0, 0.0),
step=0.1,
)
gui_vector3 = server.add_gui_vector3(
"Size",
initial_value=(1.0, 1.0, 1.0),
value=(1.0, 1.0, 1.0),
step=0.25,
)
with server.add_gui_folder("Text toggle"):
gui_checkbox_hide = server.add_gui_checkbox(
"Hide",
initial_value=False,
value=False,
)
gui_text = server.add_gui_text(
"Text",
initial_value="Hello world",
value="Hello world",
)
gui_button = server.add_gui_button("Button")
gui_checkbox_disable = server.add_gui_checkbox(
"Disable",
initial_value=False,
value=False,
)
gui_rgb = server.add_gui_rgb(
"Color",
initial_value=(255, 255, 0),
value=(255, 255, 0),
)
# Pre-generate a point cloud to send.
Expand Down
10 changes: 5 additions & 5 deletions docs/source/examples/03_gui_callbacks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ we get updates.
gui_plane.on_update(lambda _: update_plane())
with server.add_gui_folder("Control", expand_by_default=False):
gui_show_frame = server.add_gui_checkbox("Show Frame", initial_value=True)
gui_show_frame = server.add_gui_checkbox("Show Frame", value=True)
gui_show_everything = server.add_gui_checkbox(
"Show Everything", initial_value=True
"Show Everything", value=True
)
gui_axis = server.add_gui_dropdown("Axis", ("x", "y", "z"))
gui_include_z = server.add_gui_checkbox("Z in dropdown", initial_value=True)
gui_include_z = server.add_gui_checkbox("Z in dropdown", value=True)
@gui_include_z.on_update
def _(_) -> None:
gui_axis.options = ("x", "y", "z") if gui_include_z.value else ("x", "y")
with server.add_gui_folder("Sliders"):
gui_location = server.add_gui_slider(
"Location", min=-5.0, max=5.0, step=0.05, initial_value=0.0
"Location", min=-5.0, max=5.0, step=0.05, value=0.0
)
gui_num_points = server.add_gui_slider(
"# Points", min=1000, max=200_000, step=1000, initial_value=10_000
"# Points", min=1000, max=200_000, step=1000, value=10_000
)
def draw_frame() -> None:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/04_camera_poses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Example showing how we can detect new clients and read camera poses from them.
print(f"New camera on client {client.client_id}!")
# Show the client ID in the GUI.
gui_info = client.add_gui_text("Client ID", initial_value=str(client.client_id))
gui_info = client.add_gui_text("Client ID", value=str(client.client_id))
gui_info.disabled = True
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/07_record3d_visualizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ Parse and stream record3d captures. To get the demo data, see ``./assets/downloa
min=0,
max=num_frames - 1,
step=1,
initial_value=0,
value=0,
disabled=True,
)
gui_next_frame = server.add_gui_button("Next Frame", disabled=True)
gui_prev_frame = server.add_gui_button("Prev Frame", disabled=True)
gui_playing = server.add_gui_checkbox("Playing", True)
gui_framerate = server.add_gui_slider(
"FPS", min=1, max=60, step=0.1, initial_value=loader.fps
"FPS", min=1, max=60, step=0.1, value=loader.fps
)
gui_framerate_options = server.add_gui_button_group(
"FPS options", ("10", "20", "30", "60")
Expand Down
10 changes: 5 additions & 5 deletions docs/source/examples/08_smplx_visualizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ parameters to run this script:
# GUI elements: mesh settings + visibility.
with tab_group.add_tab("View", viser.Icon.VIEWFINDER):
gui_rgb = server.add_gui_rgb("Color", initial_value=(90, 200, 255))
gui_wireframe = server.add_gui_checkbox("Wireframe", initial_value=False)
gui_show_controls = server.add_gui_checkbox("Handles", initial_value=False)
gui_rgb = server.add_gui_rgb("Color", value=(90, 200, 255))
gui_wireframe = server.add_gui_checkbox("Wireframe", value=False)
gui_show_controls = server.add_gui_checkbox("Handles", value=False)
@gui_rgb.on_update
def _(_):
Expand Down Expand Up @@ -175,7 +175,7 @@ parameters to run this script:
gui_betas = []
for i in range(num_betas):
beta = server.add_gui_slider(
f"beta{i}", min=-5.0, max=5.0, step=0.01, initial_value=0.0
f"beta{i}", min=-5.0, max=5.0, step=0.01, value=0.0
)
gui_betas.append(beta)
Expand Down Expand Up @@ -210,7 +210,7 @@ parameters to run this script:
for i in range(num_body_joints + 1):
gui_joint = server.add_gui_vector3(
label=smplx.joint_names.JOINT_NAMES[i],
initial_value=(0.0, 0.0, 0.0),
value=(0.0, 0.0, 0.0),
step=0.05,
)
gui_joints.append(gui_joint)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/09_urdf_visualizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Examples:
min=lower,
max=upper,
step=1e-3,
initial_value=initial_angle,
value=initial_angle,
)
slider.on_update( # When sliders move, we update the URDF configuration.
lambda _: urdf.update_cfg(onp.array([gui.value for gui in gui_joints]))
Expand Down
6 changes: 3 additions & 3 deletions docs/source/examples/11_colmap_visualizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ Visualize COLMAP sparse reconstruction outputs. To get demo data, see ``./assets
min=1,
max=len(points3d),
step=1,
initial_value=min(len(points3d), 50_000),
value=min(len(points3d), 50_000),
)
gui_frames = server.add_gui_slider(
"Max frames",
min=1,
max=len(images),
step=1,
initial_value=min(len(images), 100),
value=min(len(images), 100),
)
gui_point_size = server.add_gui_number("Point size", initial_value=0.05)
gui_point_size = server.add_gui_number("Point size", value=0.05)
def visualize_colmap() -> None:
"""Send all COLMAP elements to viser for visualization. This could be optimized
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/12_click_meshes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ Click on meshes to select them. The index of the last clicked mesh is displayed
with server.add_gui_folder("Last clicked"):
x_value = server.add_gui_number(
label="x",
initial_value=0,
value=0,
disabled=True,
hint="x coordinate of the last clicked mesh",
)
y_value = server.add_gui_number(
label="y",
initial_value=0,
value=0,
disabled=True,
hint="y coordinate of the last clicked mesh",
)
Expand Down
10 changes: 5 additions & 5 deletions docs/source/examples/13_theming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ Viser includes support for light theming.
gui_theme_code = server.add_gui_markdown("no theme applied yet")
# GUI elements for controllable values.
titlebar = server.add_gui_checkbox("Titlebar", initial_value=True)
dark_mode = server.add_gui_checkbox("Dark mode", initial_value=True)
show_logo = server.add_gui_checkbox("Show logo", initial_value=True)
show_share_button = server.add_gui_checkbox("Show share button", initial_value=True)
titlebar = server.add_gui_checkbox("Titlebar", value=True)
dark_mode = server.add_gui_checkbox("Dark mode", value=True)
show_logo = server.add_gui_checkbox("Show logo", value=True)
show_share_button = server.add_gui_checkbox("Show share button", value=True)
brand_color = server.add_gui_rgb("Brand color", (230, 180, 30))
control_layout = server.add_gui_dropdown(
"Control layout", ("floating", "fixed", "collapsible")
)
control_width = server.add_gui_dropdown(
"Control width", ("small", "medium", "large"), initial_value="medium"
"Control width", ("small", "medium", "large"), value="medium"
)
synchronize = server.add_gui_button("Apply theme", icon=viser.Icon.CHECK)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/14_markdown.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Viser GUI has MDX 2 support.
here = Path(__file__).absolute().parent
button = server.add_gui_button("Remove blurb")
checkbox = server.add_gui_checkbox("Visibility", initial_value=True)
checkbox = server.add_gui_checkbox("Visibility", value=True)
markdown_source = (here / "./assets/mdx_example.mdx").read_text()
markdown_blurb = server.add_gui_markdown(
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/16_modal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Examples of using modals in Viser.
gui_title = client.add_gui_text(
"Title",
initial_value="My Modal",
value="My Modal",
)
modal_button = client.add_gui_button("Show more modals")
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/21_set_up_direction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Set Up Direction
server.world_axes.visible = True
gui_up = server.add_gui_vector3(
"Up Direction",
initial_value=(0.0, 0.0, 1.0),
value=(0.0, 0.0, 1.0),
step=0.01,
)
Expand Down
16 changes: 8 additions & 8 deletions examples/02_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def main() -> None:
with server.add_gui_folder("Read-only"):
gui_counter = server.add_gui_number(
"Counter",
initial_value=0,
value=0,
disabled=True,
)

Expand All @@ -24,38 +24,38 @@ def main() -> None:
min=0,
max=100,
step=1,
initial_value=0,
value=0,
disabled=True,
)

with server.add_gui_folder("Editable"):
gui_vector2 = server.add_gui_vector2(
"Position",
initial_value=(0.0, 0.0),
value=(0.0, 0.0),
step=0.1,
)
gui_vector3 = server.add_gui_vector3(
"Size",
initial_value=(1.0, 1.0, 1.0),
value=(1.0, 1.0, 1.0),
step=0.25,
)
with server.add_gui_folder("Text toggle"):
gui_checkbox_hide = server.add_gui_checkbox(
"Hide",
initial_value=False,
value=False,
)
gui_text = server.add_gui_text(
"Text",
initial_value="Hello world",
value="Hello world",
)
gui_button = server.add_gui_button("Button")
gui_checkbox_disable = server.add_gui_checkbox(
"Disable",
initial_value=False,
value=False,
)
gui_rgb = server.add_gui_rgb(
"Color",
initial_value=(255, 255, 0),
value=(255, 255, 0),
)

# Pre-generate a point cloud to send.
Expand Down
12 changes: 5 additions & 7 deletions examples/03_gui_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,21 @@ def update_plane() -> None:
gui_plane.on_update(lambda _: update_plane())

with server.add_gui_folder("Control", expand_by_default=False):
gui_show_frame = server.add_gui_checkbox("Show Frame", initial_value=True)
gui_show_everything = server.add_gui_checkbox(
"Show Everything", initial_value=True
)
gui_show_frame = server.add_gui_checkbox("Show Frame", value=True)
gui_show_everything = server.add_gui_checkbox("Show Everything", value=True)
gui_axis = server.add_gui_dropdown("Axis", ("x", "y", "z"))
gui_include_z = server.add_gui_checkbox("Z in dropdown", initial_value=True)
gui_include_z = server.add_gui_checkbox("Z in dropdown", value=True)

@gui_include_z.on_update
def _(_) -> None:
gui_axis.options = ("x", "y", "z") if gui_include_z.value else ("x", "y")

with server.add_gui_folder("Sliders"):
gui_location = server.add_gui_slider(
"Location", min=-5.0, max=5.0, step=0.05, initial_value=0.0
"Location", min=-5.0, max=5.0, step=0.05, value=0.0
)
gui_num_points = server.add_gui_slider(
"# Points", min=1000, max=200_000, step=1000, initial_value=10_000
"# Points", min=1000, max=200_000, step=1000, value=10_000
)

def draw_frame() -> None:
Expand Down
2 changes: 1 addition & 1 deletion examples/04_camera_poses.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _(_: viser.CameraHandle) -> None:
print(f"New camera on client {client.client_id}!")

# Show the client ID in the GUI.
gui_info = client.add_gui_text("Client ID", initial_value=str(client.client_id))
gui_info = client.add_gui_text("Client ID", value=str(client.client_id))
gui_info.disabled = True


Expand Down
4 changes: 2 additions & 2 deletions examples/07_record3d_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def main(
min=0,
max=num_frames - 1,
step=1,
initial_value=0,
value=0,
disabled=True,
)
gui_next_frame = server.add_gui_button("Next Frame", disabled=True)
gui_prev_frame = server.add_gui_button("Prev Frame", disabled=True)
gui_playing = server.add_gui_checkbox("Playing", True)
gui_framerate = server.add_gui_slider(
"FPS", min=1, max=60, step=0.1, initial_value=loader.fps
"FPS", min=1, max=60, step=0.1, value=loader.fps
)
gui_framerate_options = server.add_gui_button_group(
"FPS options", ("10", "20", "30", "60")
Expand Down
10 changes: 5 additions & 5 deletions examples/08_smplx_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def make_gui_elements(

# GUI elements: mesh settings + visibility.
with tab_group.add_tab("View", viser.Icon.VIEWFINDER):
gui_rgb = server.add_gui_rgb("Color", initial_value=(90, 200, 255))
gui_wireframe = server.add_gui_checkbox("Wireframe", initial_value=False)
gui_show_controls = server.add_gui_checkbox("Handles", initial_value=False)
gui_rgb = server.add_gui_rgb("Color", value=(90, 200, 255))
gui_wireframe = server.add_gui_checkbox("Wireframe", value=False)
gui_show_controls = server.add_gui_checkbox("Handles", value=False)

@gui_rgb.on_update
def _(_):
Expand Down Expand Up @@ -167,7 +167,7 @@ def _(_):
gui_betas = []
for i in range(num_betas):
beta = server.add_gui_slider(
f"beta{i}", min=-5.0, max=5.0, step=0.01, initial_value=0.0
f"beta{i}", min=-5.0, max=5.0, step=0.01, value=0.0
)
gui_betas.append(beta)

Expand Down Expand Up @@ -202,7 +202,7 @@ def _(_):
for i in range(num_body_joints + 1):
gui_joint = server.add_gui_vector3(
label=smplx.joint_names.JOINT_NAMES[i],
initial_value=(0.0, 0.0, 0.0),
value=(0.0, 0.0, 0.0),
step=0.05,
)
gui_joints.append(gui_joint)
Expand Down
2 changes: 1 addition & 1 deletion examples/09_urdf_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main(urdf_path: Path) -> None:
min=lower,
max=upper,
step=1e-3,
initial_value=initial_angle,
value=initial_angle,
)
slider.on_update( # When sliders move, we update the URDF configuration.
lambda _: urdf.update_cfg(onp.array([gui.value for gui in gui_joints]))
Expand Down
Loading

0 comments on commit 5a49853

Please sign in to comment.