From 270d5ddc31c26b62379e3caa9044dd75ccc71847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Sun, 4 Mar 2018 10:20:27 +0100 Subject: New upstream version 0.7.0+dfsg --- silx/gui/plot3d/actions/Plot3DAction.py | 10 ++- silx/gui/plot3d/actions/io.py | 15 ++-- silx/gui/plot3d/actions/mode.py | 15 ++-- silx/gui/plot3d/actions/viewpoint.py | 141 +++++++++++++++++++++++++++++++- 4 files changed, 162 insertions(+), 19 deletions(-) (limited to 'silx/gui/plot3d/actions') diff --git a/silx/gui/plot3d/actions/Plot3DAction.py b/silx/gui/plot3d/actions/Plot3DAction.py index a1faaea..94b9572 100644 --- a/silx/gui/plot3d/actions/Plot3DAction.py +++ b/silx/gui/plot3d/actions/Plot3DAction.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2017 European Synchrotron Radiation Facility +# Copyright (c) 2016-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -44,7 +44,8 @@ class Plot3DAction(qt.QAction): """QAction associated to a Plot3DWidget :param parent: See :class:`QAction` - :param Plot3DWidget plot3d: Plot3DWidget the action is associated with + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ def __init__(self, parent, plot3d=None): @@ -55,7 +56,8 @@ class Plot3DAction(qt.QAction): def setPlot3DWidget(self, widget): """Set the Plot3DWidget this action is associated with - :param Plot3DWidget widget: The Plot3DWidget to use + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget widget: + The Plot3DWidget to use """ self._plot3d = None if widget is None else weakref.ref(widget) @@ -64,6 +66,6 @@ class Plot3DAction(qt.QAction): If no widget is associated, it returns None. - :rtype: qt.QWidget + :rtype: QWidget """ return None if self._plot3d is None else self._plot3d() diff --git a/silx/gui/plot3d/actions/io.py b/silx/gui/plot3d/actions/io.py index 18f91b4..5126000 100644 --- a/silx/gui/plot3d/actions/io.py +++ b/silx/gui/plot3d/actions/io.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2017 European Synchrotron Radiation Facility +# Copyright (c) 2016-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -54,7 +54,8 @@ class CopyAction(Plot3DAction): """QAction to provide copy of a Plot3DWidget :param parent: See :class:`QAction` - :param Plot3DWidget plot3d: Plot3DWidget the action is associated with + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ def __init__(self, parent, plot3d=None): @@ -81,7 +82,8 @@ class SaveAction(Plot3DAction): """QAction to provide save snapshot of a Plot3DWidget :param parent: See :class:`QAction` - :param Plot3DWidget plot3d: Plot3DWidget the action is associated with + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ def __init__(self, parent, plot3d=None): @@ -135,7 +137,8 @@ class PrintAction(Plot3DAction): """QAction to provide printing of a Plot3DWidget :param parent: See :class:`QAction` - :param Plot3DWidget plot3d: Plot3DWidget the action is associated with + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ def __init__(self, parent, plot3d=None): @@ -152,7 +155,7 @@ class PrintAction(Plot3DAction): def getPrinter(self): """Return the QPrinter instance used for printing. - :rtype: qt.QPrinter + :rtype: QPrinter """ # TODO This is a hack to sync with silx plot PrintAction # This needs to be centralized @@ -201,6 +204,8 @@ class VideoAction(Plot3DAction): The scene is rotated 360 degrees around a vertical axis. :param parent: Action parent see :class:`QAction`. + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ PNG_SERIE_FILTER = 'Serie of PNG files (*.png)' diff --git a/silx/gui/plot3d/actions/mode.py b/silx/gui/plot3d/actions/mode.py index a06b9a8..b591290 100644 --- a/silx/gui/plot3d/actions/mode.py +++ b/silx/gui/plot3d/actions/mode.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2017 European Synchrotron Radiation Facility +# Copyright (c) 2017-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -48,7 +48,8 @@ class InteractiveModeAction(Plot3DAction): :param parent: See :class:`QAction` :param str interaction: The interactive mode this action controls - :param Plot3DWidget plot3d: Plot3DWidget the action is associated with + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ def __init__(self, parent, interaction, plot3d=None): @@ -100,7 +101,8 @@ class RotateArcballAction(InteractiveModeAction): """QAction to set arcball rotation interaction on a Plot3DWidget :param parent: See :class:`QAction` - :param Plot3DWidget plot3d: Plot3DWidget the action is associated with + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ def __init__(self, parent, plot3d=None): @@ -108,14 +110,15 @@ class RotateArcballAction(InteractiveModeAction): self.setIcon(getQIcon('rotate-3d')) self.setText('Rotate') - self.setToolTip('Rotate the view') + self.setToolTip('Rotate the view. Press Ctrl to pan.') class PanAction(InteractiveModeAction): """QAction to set pan interaction on a Plot3DWidget :param parent: See :class:`QAction` - :param Plot3DWidget plot3d: Plot3DWidget the action is associated with + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ def __init__(self, parent, plot3d=None): @@ -123,4 +126,4 @@ class PanAction(InteractiveModeAction): self.setIcon(getQIcon('pan')) self.setText('Pan') - self.setToolTip('Pan the view') + self.setToolTip('Pan the view. Press Ctrl to rotate.') diff --git a/silx/gui/plot3d/actions/viewpoint.py b/silx/gui/plot3d/actions/viewpoint.py index 6aa7400..d764c40 100644 --- a/silx/gui/plot3d/actions/viewpoint.py +++ b/silx/gui/plot3d/actions/viewpoint.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2017 European Synchrotron Radiation Facility +# Copyright (c) 2017-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -45,11 +45,144 @@ from .Plot3DAction import Plot3DAction _logger = logging.getLogger(__name__) -class RotateViewport(Plot3DAction): +class _SetViewpointAction(Plot3DAction): + """Base class for actions setting a Plot3DWidget viewpoint + + :param parent: See :class:`QAction` + :param str face: The name of the predefined viewpoint + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with + """ + def __init__(self, parent, face, plot3d=None): + super(_SetViewpointAction, self).__init__(parent, plot3d) + assert face in ('side', 'front', 'back', 'left', 'right', 'top', 'bottom') + self._face = face + + self.setIconVisibleInMenu(True) + self.setCheckable(False) + self.triggered[bool].connect(self._triggered) + + def _triggered(self, checked=False): + plot3d = self.getPlot3DWidget() + if plot3d is None: + _logger.error( + 'Cannot start/stop rotation, no associated Plot3DWidget') + else: + plot3d.viewport.camera.extrinsic.reset(face=self._face) + plot3d.centerScene() + + +class FrontViewpointAction(_SetViewpointAction): + """QAction to set Plot3DWidget viewpoint to look from the front + + :param parent: See :class:`QAction` + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with + """ + def __init__(self, parent, plot3d=None): + super(FrontViewpointAction, self).__init__(parent, 'front', plot3d) + + self.setIcon(getQIcon('cube-front')) + self.setText('Front') + self.setToolTip('View along the -Z axis') + + +class BackViewpointAction(_SetViewpointAction): + """QAction to set Plot3DWidget viewpoint to look from the back + + :param parent: See :class:`QAction` + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with + """ + def __init__(self, parent, plot3d=None): + super(BackViewpointAction, self).__init__(parent, 'back', plot3d) + + self.setIcon(getQIcon('cube-back')) + self.setText('Back') + self.setToolTip('View along the +Z axis') + + +class LeftViewpointAction(_SetViewpointAction): + """QAction to set Plot3DWidget viewpoint to look from the left + + :param parent: See :class:`QAction` + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with + """ + def __init__(self, parent, plot3d=None): + super(LeftViewpointAction, self).__init__(parent, 'left', plot3d) + + self.setIcon(getQIcon('cube-left')) + self.setText('Left') + self.setToolTip('View along the +X axis') + + +class RightViewpointAction(_SetViewpointAction): + """QAction to set Plot3DWidget viewpoint to look from the right + + :param parent: See :class:`QAction` + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with + """ + def __init__(self, parent, plot3d=None): + super(RightViewpointAction, self).__init__(parent, 'right', plot3d) + + self.setIcon(getQIcon('cube-right')) + self.setText('Right') + self.setToolTip('View along the -X axis') + + +class TopViewpointAction(_SetViewpointAction): + """QAction to set Plot3DWidget viewpoint to look from the top + + :param parent: See :class:`QAction` + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with + """ + def __init__(self, parent, plot3d=None): + super(TopViewpointAction, self).__init__(parent, 'top', plot3d) + + self.setIcon(getQIcon('cube-top')) + self.setText('Top') + self.setToolTip('View along the -Y axis') + + +class BottomViewpointAction(_SetViewpointAction): + """QAction to set Plot3DWidget viewpoint to look from the bottom + + :param parent: See :class:`QAction` + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with + """ + def __init__(self, parent, plot3d=None): + super(BottomViewpointAction, self).__init__(parent, 'bottom', plot3d) + + self.setIcon(getQIcon('cube-bottom')) + self.setText('Bottom') + self.setToolTip('View along the +Y axis') + + +class SideViewpointAction(_SetViewpointAction): + """QAction to set Plot3DWidget viewpoint to look from the side + + :param parent: See :class:`QAction` + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with + """ + def __init__(self, parent, plot3d=None): + super(SideViewpointAction, self).__init__(parent, 'side', plot3d) + + self.setIcon(getQIcon('cube')) + self.setText('Side') + self.setToolTip('Side view') + + +class RotateViewpoint(Plot3DAction): """QAction to rotate the scene of a Plot3DWidget :param parent: See :class:`QAction` - :param Plot3DWidget plot3d: Plot3DWidget the action is associated with + :param ~silx.gui.plot3d.Plot3DWidget.Plot3DWidget plot3d: + Plot3DWidget the action is associated with """ _TIMEOUT_MS = 50 @@ -59,7 +192,7 @@ class RotateViewport(Plot3DAction): """Rotation speed of the animation""" def __init__(self, parent, plot3d=None): - super(RotateViewport, self).__init__(parent, plot3d) + super(RotateViewpoint, self).__init__(parent, plot3d) self._previousTime = None -- cgit v1.2.3