Skip to content
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
2 changes: 0 additions & 2 deletions docs/source/api/graphics/Graphic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ Methods
Graphic.clear_event_handlers
Graphic.remove_event_handler
Graphic.rotate
Graphic.share_property
Graphic.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/graphics/ImageGraphic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ Methods
ImageGraphic.remove_event_handler
ImageGraphic.reset_vmin_vmax
ImageGraphic.rotate
ImageGraphic.share_property
ImageGraphic.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/graphics/LineCollection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,4 @@ Methods
LineCollection.remove_event_handler
LineCollection.remove_graphic
LineCollection.rotate
LineCollection.share_property
LineCollection.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/graphics/LineGraphic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,4 @@ Methods
LineGraphic.clear_event_handlers
LineGraphic.remove_event_handler
LineGraphic.rotate
LineGraphic.share_property
LineGraphic.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/graphics/LineStack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,4 @@ Methods
LineStack.remove_event_handler
LineStack.remove_graphic
LineStack.rotate
LineStack.share_property
LineStack.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/graphics/ScatterGraphic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,4 @@ Methods
ScatterGraphic.clear_event_handlers
ScatterGraphic.remove_event_handler
ScatterGraphic.rotate
ScatterGraphic.share_property
ScatterGraphic.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/graphics/TextGraphic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,4 @@ Methods
TextGraphic.clear_event_handlers
TextGraphic.remove_event_handler
TextGraphic.rotate
TextGraphic.share_property
TextGraphic.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/selectors/LinearRegionSelector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ Methods
LinearRegionSelector.get_selected_indices
LinearRegionSelector.remove_event_handler
LinearRegionSelector.rotate
LinearRegionSelector.share_property
LinearRegionSelector.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/selectors/LinearSelector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ Methods
LinearSelector.get_selected_indices
LinearSelector.remove_event_handler
LinearSelector.rotate
LinearSelector.share_property
LinearSelector.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/selectors/RectangleSelector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ Methods
RectangleSelector.get_selected_indices
RectangleSelector.remove_event_handler
RectangleSelector.rotate
RectangleSelector.share_property
RectangleSelector.unshare_property

2 changes: 0 additions & 2 deletions docs/source/api/tools/HistogramLUTTool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,4 @@ Methods
HistogramLUTTool.remove_event_handler
HistogramLUTTool.rotate
HistogramLUTTool.set_data
HistogramLUTTool.share_property
HistogramLUTTool.unshare_property

6 changes: 0 additions & 6 deletions fastplotlib/graphics/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,6 @@ def _set_world_object(self, wo: pygfx.WorldObject):
if not all(self.world_object.world.rotation == self.rotation):
self.rotation = self.rotation

def unshare_property(self, feature: str):
raise NotImplementedError

def share_property(self, feature: BufferManager):
raise NotImplementedError

@property
def event_handlers(self) -> list[tuple[str, callable, ...]]:
"""
Expand Down
50 changes: 0 additions & 50 deletions fastplotlib/graphics/_positions_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,53 +153,3 @@ def __init__(

self._size_space = SizeSpace(size_space)
super().__init__(*args, **kwargs)

def unshare_property(self, property: str):
"""unshare a shared property. Experimental and untested!"""
if not isinstance(property, str):
raise TypeError

f = getattr(self, property)
if f.shared == 0:
raise BufferError("Cannot detach an independent buffer")

if property == "colors" and isinstance(property, VertexColors):
self._colors._buffer = pygfx.Buffer(self._colors.value.copy())
self.world_object.geometry.colors = self._colors.buffer
self._colors._shared -= 1

elif property == "data":
self._data._buffer = pygfx.Buffer(self._data.value.copy())
self.world_object.geometry.positions = self._data.buffer
self._data._shared -= 1

elif property == "sizes":
self._sizes._buffer = pygfx.Buffer(self._sizes.value.copy())
self.world_object.geometry.positions = self._sizes.buffer
self._sizes._shared -= 1

def share_property(
self, property: VertexPositions | VertexColors | PointsSizesFeature
):
"""share a property from another graphic. Experimental and untested!"""
if isinstance(property, VertexPositions):
# TODO: check if this causes a memory leak
self._data._shared -= 1

self._data = property
self._data._shared += 1
self.world_object.geometry.positions = self._data.buffer

elif isinstance(property, VertexColors):
self._colors._shared -= 1

self._colors = property
self._colors._shared += 1
self.world_object.geometry.colors = self._colors.buffer

elif isinstance(property, PointsSizesFeature):
self._sizes._shared -= 1

self._sizes = property
self._sizes._shared += 1
self.world_object.geometry.sizes = self._sizes.buffer