Beispiel #1
0
    def __init__(self, parent=None, backend="mpl"):
        qt.QMainWindow.__init__(self, parent)
        self._scatterView = ScatterView(parent=self, backend=backend)

        self._axesSelector = AxesPositionersSelector(parent=self._scatterView)
        self._axesSelector.sigSelectionChanged.connect(self._setAxesData)

        self.setCentralWidget(self._scatterView)
        _axesSelectorDock = BoxLayoutDockWidget()
        _axesSelectorDock.setWindowTitle('Axes selection')
        _axesSelectorDock.setWidget(self._axesSelector)
        self.addDockWidget(qt.Qt.BottomDockWidgetArea, _axesSelectorDock)

        self._positioners = {}
        self._xdata = None
        self._ydata = None
        self._stackImage = None
Beispiel #2
0
    def __init__(self, parent=None, backend=None, title='Plot1D'):
        """Constructor"""
        super(Plot1D, self).__init__(parent=parent,
                                     backend=backend,
                                     resetzoom=True,
                                     autoScale=True,
                                     logScale=True,
                                     grid=False,
                                     curveStyle=True,
                                     colormap=False,
                                     aspectRatio=False,
                                     yInverted=False,
                                     copy=True,
                                     save=True,
                                     print_=True,
                                     control=False,
                                     position=True,
                                     roi=False,
                                     mask=False,
                                     fit=True)
        self._index = None
        self._title = title
        self.setWindowTitle(self._title)

        # Active curve behaviour
        # TODO: https://github.com/silx-kit/silx/blob/5035be343dc37ef60eab114c139016ebd9832d96/silx/gui/plot/test/testPlotWidget.py#L636
        self.setActiveCurveHandling(True)

        self.setDataMargins(0, 0, 0.05, 0.05)

        # Create a MyCurveLegendWidget associated to the plot
        self.legendsWidget = CustomCurveLegendsWidget()
        self.legendsWidget.setPlotWidget(self)

        # Add the CurveLegendsWidget as a dock widget to the plot
        self.dock = BoxLayoutDockWidget()
        self.dock.setWindowTitle('Legend (right click for menu)')
        self.dock.setWidget(self.legendsWidget)
        self.addDockWidget(qt.Qt.RightDockWidgetArea, self.dock)

        # Show the plot and run the QApplication
        self.setAttribute(qt.Qt.WA_DeleteOnClose)
    def test(self):
        """Test update of layout direction according to dock area"""
        # Create a widget with a QBoxLayout
        layout = qt.QBoxLayout(qt.QBoxLayout.LeftToRight)
        layout.addWidget(qt.QLabel('First'))
        layout.addWidget(qt.QLabel('Second'))
        widget = qt.QWidget()
        widget.setLayout(layout)

        # Add it to a BoxLayoutDockWidget
        dock = BoxLayoutDockWidget()
        dock.setWidget(widget)

        self.window.addDockWidget(qt.Qt.BottomDockWidgetArea, dock)
        self.qapp.processEvents()
        self.assertEqual(layout.direction(), qt.QBoxLayout.LeftToRight)

        self.window.addDockWidget(qt.Qt.LeftDockWidgetArea, dock)
        self.qapp.processEvents()
        self.assertEqual(layout.direction(), qt.QBoxLayout.TopToBottom)
Beispiel #4
0
    def test(self):
        """Test update of layout direction according to dock area"""
        # Create a widget with a QBoxLayout
        layout = qt.QBoxLayout(qt.QBoxLayout.LeftToRight)
        layout.addWidget(qt.QLabel('First'))
        layout.addWidget(qt.QLabel('Second'))
        widget = qt.QWidget()
        widget.setLayout(layout)

        # Add it to a BoxLayoutDockWidget
        dock = BoxLayoutDockWidget()
        dock.setWidget(widget)

        self.window.addDockWidget(qt.Qt.BottomDockWidgetArea, dock)
        self.qapp.processEvents()
        self.assertEqual(layout.direction(), qt.QBoxLayout.LeftToRight)

        self.window.addDockWidget(qt.Qt.LeftDockWidgetArea, dock)
        self.qapp.processEvents()
        self.assertEqual(layout.direction(), qt.QBoxLayout.TopToBottom)
Beispiel #5
0
    def __init__(self, parent=None, backend="mpl"):
        qt.QMainWindow.__init__(self, parent)
        self._scatterView = ScatterView(parent=self, backend=backend)

        self._axesSelector = AxesPositionersSelector(parent=self._scatterView)
        self._axesSelector.sigSelectionChanged.connect(self._setAxesData)

        self.setCentralWidget(self._scatterView)
        _axesSelectorDock = BoxLayoutDockWidget()
        _axesSelectorDock.setWindowTitle('Axes selection')
        _axesSelectorDock.setWidget(self._axesSelector)
        self.addDockWidget(qt.Qt.BottomDockWidgetArea, _axesSelectorDock)

        self._positioners = {}
        self._xdata = None
        self._ydata = None
        self._stackImage = None
# Create QApplication
qapp = qt.QApplication([])

# Create a SceneWindow widget
window = SceneWindow()

# Get the SceneWidget contained in the window and set its colors
sceneWidget = window.getSceneWidget()
sceneWidget.setBackgroundColor((0.8, 0.8, 0.8, 1.))
sceneWidget.setForegroundColor((1., 1., 1., 1.))
sceneWidget.setTextColor((0.1, 0.1, 0.1, 1.))

# Add PositionInfoWidget to display picking info
positionInfo = PositionInfoWidget()
positionInfo.setSceneWidget(sceneWidget)
dock = BoxLayoutDockWidget()
dock.setWindowTitle("Selection Info")
dock.setWidget(positionInfo)
window.addDockWidget(qt.Qt.BottomDockWidgetArea, dock)

# 2D Image ###

# Add a dummy RGBA image
img = numpy.random.random(3 * SIZE**2).reshape(SIZE, SIZE, 3)  # Dummy image

imageRgba = sceneWidget.addImage(img)  # Add ImageRgba item to the scene

# Set imageRgba transform
imageRgba.setTranslation(SIZE * .15, SIZE * .15, 0.)  # Translate the image
# Rotate the image by 45 degrees around its center
imageRgba.setRotationCenter('center', 'center', 0.)
Beispiel #7
0
x = numpy.linspace(-numpy.pi, numpy.pi, 100)
window.addCurve(x, 2. * numpy.random.random(100) - 1.,
                legend='random',
                symbol='s', linestyle='--',
                color='red')
window.addCurve(x, numpy.sin(x),
                legend='sin',
                symbol='o', linestyle=':',
                color='blue')
window.addCurve(x, numpy.cos(x),
                legend='cos',
                symbol='', linestyle='-',
                color='blue')


# Create a MyCurveLegendWidget associated to the plot
curveLegendsWidget = MyCurveLegendsWidget()
curveLegendsWidget.setPlotWidget(window)

# Add the CurveLegendsWidget as a dock widget to the plot
dock = BoxLayoutDockWidget()
dock.setWindowTitle('Curve legends')
dock.setWidget(curveLegendsWidget)
window.addDockWidget(qt.Qt.RightDockWidgetArea, dock)

# Show the plot and run the QApplication
window.setAttribute(qt.Qt.WA_DeleteOnClose)
window.show()

app.exec()
Beispiel #8
0
x = numpy.linspace(-numpy.pi, numpy.pi, 100)
window.addCurve(x, 2. * numpy.random.random(100) - 1.,
                legend='random',
                symbol='s', linestyle='--',
                color='red')
window.addCurve(x, numpy.sin(x),
                legend='sin',
                symbol='o', linestyle=':',
                color='blue')
window.addCurve(x, numpy.cos(x),
                legend='cos',
                symbol='', linestyle='-',
                color='blue')


# Create a MyCurveLegendWidget associated to the plot
curveLegendsWidget = MyCurveLegendsWidget()
curveLegendsWidget.setPlotWidget(window)

# Add the CurveLegendsWidget as a dock widget to the plot
dock = BoxLayoutDockWidget()
dock.setWindowTitle('Curve legends')
dock.setWidget(curveLegendsWidget)
window.addDockWidget(qt.Qt.RightDockWidgetArea, dock)

# Show the plot and run the QApplication
window.setAttribute(qt.Qt.WA_DeleteOnClose)
window.show()

app.exec_()
Beispiel #9
0
qapp = qt.QApplication.instance() or qt.QApplication([])

# Create a SceneWindow widget
window = SceneWindow()

# Get the SceneWidget contained in the window and set its colors
sceneWidget = window.getSceneWidget()
sceneWidget.setBackgroundColor((0.8, 0.8, 0.8, 1.))
sceneWidget.setForegroundColor((1., 1., 1., 1.))
sceneWidget.setTextColor((0.1, 0.1, 0.1, 1.))


# Add PositionInfoWidget to display picking info
positionInfo = PositionInfoWidget()
positionInfo.setSceneWidget(sceneWidget)
dock = BoxLayoutDockWidget()
dock.setWindowTitle("Selection Info")
dock.setWidget(positionInfo)
window.addDockWidget(qt.Qt.BottomDockWidgetArea, dock)

# 2D Image ###

# Add a dummy RGBA image
img = numpy.random.random(3 * SIZE ** 2).reshape(SIZE, SIZE, 3)  # Dummy image

imageRgba = sceneWidget.addImage(img)  # Add ImageRgba item to the scene
imageRgba.setLabel('Random RGBA image')  # Set name displayed in parameter tree

# Set imageRgba transform
imageRgba.setTranslation(SIZE*.15, SIZE*.15, 0.)  # Translate the image
# Rotate the image by 45 degrees around its center