diff options
author | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2018-12-17 12:28:24 +0100 |
---|---|---|
committer | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2018-12-17 12:28:24 +0100 |
commit | cebdc9244c019224846cb8d2668080fe386a6adc (patch) | |
tree | aedec55da0f9dd4fc4d6c7eb0f58489a956e2e8c /silx/gui/plot3d/SceneWidget.py | |
parent | 159ef14fb9e198bb0066ea14e6b980f065de63dd (diff) |
New upstream version 0.9.0+dfsg
Diffstat (limited to 'silx/gui/plot3d/SceneWidget.py')
-rw-r--r-- | silx/gui/plot3d/SceneWidget.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/silx/gui/plot3d/SceneWidget.py b/silx/gui/plot3d/SceneWidget.py index f005dec..4a824d7 100644 --- a/silx/gui/plot3d/SceneWidget.py +++ b/silx/gui/plot3d/SceneWidget.py @@ -39,6 +39,7 @@ from ..colors import rgba from .Plot3DWidget import Plot3DWidget from . import items +from .items.core import RootGroupWithAxesItem from .scene import interaction from ._model import SceneModel, visitQAbstractItemModel from ._model.items import Item3DRow @@ -363,10 +364,11 @@ class SceneWidget(Plot3DWidget): self._foregroundColor = 1., 1., 1., 1. self._highlightColor = 0.7, 0.7, 0., 1. - self._sceneGroup = items.GroupWithAxesItem(parent=self) + self._sceneGroup = RootGroupWithAxesItem(parent=self) self._sceneGroup.setLabel('Data') - self.viewport.scene.children.append(self._sceneGroup._getScenePrimitive()) + self.viewport.scene.children.append( + self._sceneGroup._getScenePrimitive()) def model(self): """Returns the model corresponding the scene of this widget @@ -395,6 +397,28 @@ class SceneWidget(Plot3DWidget): """ return self._sceneGroup + def pickItems(self, x, y, condition=None): + """Iterator over picked items in the scene at given position. + + Each picked item yield a + :class:`~silx.gui.plot3d.items._pick.PickingResult` object + holding the picking information. + + It traverses the scene tree in a left-to-right top-down way. + + :param int x: X widget coordinate + :param int y: Y widget coordinate + :param callable condition: Optional test called for each item + checking whether to process it or not. + """ + if not self.isValid() or not self.isVisible(): + return # Empty iterator + + devicePixelRatio = self.getDevicePixelRatio() + for result in self.getSceneGroup().pickItems( + x * devicePixelRatio, y * devicePixelRatio, condition): + yield result + # Interactive modes def _handleSelectionChanged(self, current, previous): |