Skip to content

Commit

Permalink
Merge branch 'add-slide-data' of https://github.com/TissueImageAnalyt…
Browse files Browse the repository at this point in the history
…ics/tiatoolbox into add-slide-data
  • Loading branch information
measty committed Mar 15, 2024
2 parents cd9e3bd + 96ccd97 commit f52ee5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests/test_app_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ def test_get_level_by_extent() -> None:

def test_roots(doc: Document) -> None:
"""Test that the document has the correct number of roots."""
# should be 4 roots: main window, controls, slide_info, popup table
assert len(doc.roots) == 4
# should be 5 roots: main window, controls, slide_info, popup, extra_layout
assert len(doc.roots) == 5


def test_config_loaded(data_path: pytest.TempPathFactory) -> None:
Expand Down Expand Up @@ -627,7 +627,7 @@ def test_pt_size_spinner(doc: Document) -> None:
pt_size_spinner.value = 10
# check that the point size has been set correctly
assert (
main.UI["p"].renderers[main.UI["vstate"].layer_dict["nodes"]].glyph.size
main.UI["p"].renderers[main.UI["vstate"].layer_dict["nodes"]].glyph.radius
== 2 * 10
)

Expand Down
21 changes: 18 additions & 3 deletions tiatoolbox/visualization/bokeh_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ def overlay_alpha_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001

def pt_size_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
"""Callback to change the size of the points."""
UI["vstate"].graph_node.size = 2 * new
UI["vstate"].graph_node.radius = 2 * new


def edge_size_cb(attr: str, old: float, new: float) -> None: # noqa: ARG001
Expand Down Expand Up @@ -1789,7 +1789,14 @@ def make_window(vstate: ViewerState) -> dict: # noqa: PLR0915
box_source = ColumnDataSource({"x": [], "y": [], "width": [], "height": []})
pt_source = ColumnDataSource({"x": [], "y": []})
r = p.rect("x", "y", "width", "height", source=box_source, fill_alpha=0)
c = p.circle("x", "y", source=pt_source, color="red", size=5)
c = p.circle(
"x",
"y",
source=pt_source,
color="red",
radius=3,
radius_units="screen",
)
p.add_tools(BoxEditTool(renderers=[r], num_objects=1))
p.add_tools(PointDrawTool(renderers=[c]))
p.add_tools(TapTool())
Expand All @@ -1801,7 +1808,13 @@ def make_window(vstate: ViewerState) -> dict: # noqa: PLR0915
# Add graph stuff
node_source = ColumnDataSource({"x_": [], "y_": [], "node_color_": []})
edge_source = ColumnDataSource({"x0_": [], "y0_": [], "x1_": [], "y1_": []})
vstate.graph_node = Circle(x="x_", y="y_", fill_color="node_color_", size=5)
vstate.graph_node = Circle(
x="x_",
y="y_",
fill_color="node_color_",
radius=3,
radius_units="screen",
)
vstate.graph_edge = Segment(x0="x0_", y0="y0_", x1="x1_", y1="y1_")
p.add_glyph(node_source, vstate.graph_node)
node_source.selected.on_change("indices", node_select_cb)
Expand Down Expand Up @@ -1871,6 +1884,8 @@ def make_window(vstate: ViewerState) -> dict: # noqa: PLR0915
"hover": hover,
"user": user,
"color_bar": color_bar,
"ui_layout": ui_layout,
"extra_options": extra_options,
}


Expand Down

0 comments on commit f52ee5e

Please sign in to comment.