Skip to content
Open
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
23 changes: 15 additions & 8 deletions glue_vispy_viewers/volume/layer_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from matplotlib.colors import ColorConverter

from glue.core.data import Subset, Data
from glue.core.link_manager import equivalent_pixel_cids
from glue.core.link_manager import pixel_cid_to_pixel_cid_matrix
from glue.core.exceptions import IncompatibleAttribute
from glue.core.fixed_resolution_buffer import ARRAY_CACHE, PIXEL_CACHE
from .colors import get_mpl_cmap, get_translucent_cmap
Expand All @@ -31,17 +31,29 @@ def layer_artist(self):
def viewer_state(self):
return self._viewer_state()

def _pixel_cid_order(self):
data = self.layer_artist.layer
if isinstance(self.layer_artist.layer, Subset):
data = data.data
mat = pixel_cid_to_pixel_cid_matrix(self.viewer_state.reference_data,
data)
order = []
for i in range(mat.shape[1]):
idx = np.argmax(mat[:, i])
order.append(idx if mat[idx, i] else None)
return order

@property
def shape(self):

order = equivalent_pixel_cids(self.viewer_state.reference_data,
self.layer_artist.layer)
order = self._pixel_cid_order()

try:
x_axis = order.index(self.viewer_state.x_att.axis)
y_axis = order.index(self.viewer_state.y_att.axis)
z_axis = order.index(self.viewer_state.z_att.axis)
except (AttributeError, ValueError):
self.layer_artist.disable('Layer data is not fully linked to reference data')
return 0, 0, 0

if isinstance(self.layer_artist.layer, Subset):
Expand All @@ -58,14 +70,9 @@ def compute_fixed_resolution_buffer(self, bounds=None):
if self.layer_artist is None or self.viewer_state is None:
return np.broadcast_to(0, shape)

order = equivalent_pixel_cids(self.viewer_state.reference_data,
self.layer_artist.layer)
reference_axes = [self.viewer_state.x_att.axis,
self.viewer_state.y_att.axis,
self.viewer_state.z_att.axis]
if order is not None and not set(reference_axes) <= set(order):
self.layer_artist.disable('Layer data is not fully linked to x/y/z attributes')
return np.broadcast_to(0, shape)

# For this method, we make use of Data.compute_fixed_resolution_buffer,
# which requires us to specify bounds in the form (min, max, nsteps).
Expand Down
Loading