예제 #1
0
    def __init__(self):
        PortSupplier.__init__(self)

        self._refid = str(uuid4())
        self._port = None
        self._started = False
예제 #2
0
    def __init__(self):
        _deferred_imports()
        helperBase.__init__(self)
        PortSupplier.__init__(self)

        # Create provides port dictionary.
        self._providesPortDict = {}
        for interface in ('Char', 'Short', 'Long', 'Float', 'Ulong', 'Double',
                          'LongLong', 'Octet', 'UlongLong', 'Ushort'):
            name = '%sIn' % interface.lower()
            self._providesPortDict[name] = {
                'Port Interface': 'IDL:BULKIO/data%s:1.0' % interface,
                'Port Name': name
            }

        self.breakBlock = False
        self._thread = None

        # Create a new figure and axes.
        self._figure = pyplot.figure()
        self._plot = self._figure.add_subplot(1, 1, 1)
        self._canvas = self._figure.canvas
        self._figure.show(False)

        # Let subclasses set up the axes.
        self._configureAxes()

        # Matplotlib 0.99 does not give an easy way to listen for window close
        # events; as a result, we have to get the underlying backend-specific
        # window. This is course, somewhat fragile. Furthermore, QMainWindow
        # does not provide a signal on close that would allow us to stop the
        # rendering loop before the objects are destroyed, so we dynamically
        # override the closeEvent method on this particular instance.
        window = self._getWindow()
        oldClose = window.closeEvent

        def closeEvent(event):
            self.stop()
            oldClose(event)

        window.closeEvent = closeEvent

        # Add thread synchronization to the draw and paintEvent methods on
        # FigureCanvasQTAgg, so that we can do drawing updates in the reader
        # thread at the same time that the main thread might traw to redraw.
        # Without synchronization, this leads to exceptions and flickering.
        lock = threading.Lock()
        oldDraw = self._canvas.draw

        def draw():
            lock.acquire()
            try:
                oldDraw()
            finally:
                lock.release()

        self._canvas.draw = draw
        oldPaint = self._canvas.paintEvent

        def paintEvent(e):
            lock.acquire()
            try:
                oldPaint(e)
            finally:
                lock.release()

        self._canvas.paintEvent = paintEvent
        self._renderLock = lock
예제 #3
0
    def __init__(self):
        _deferred_imports()
        helperBase.__init__(self)
        PortSupplier.__init__(self)

        # Create provides port dictionary.
        self._providesPortDict = {}
        for interface in ('Char', 'Short', 'Long', 'Float', 'Ulong',
                          'Double', 'LongLong', 'Octet', 'UlongLong',
                          'Ushort'):
            name = '%sIn' % interface.lower()
            self._providesPortDict[name] = {
                'Port Interface': 'IDL:BULKIO/data%s:1.0' % interface,
                'Port Name': name
                }

        self.breakBlock = False
        self._thread = None

        # Create a new figure and axes.
        self._figure = pyplot.figure()
        self._plot = self._figure.add_subplot(1, 1, 1)
        self._canvas = self._figure.canvas
        self._figure.show(False)

        # Let subclasses set up the axes.
        self._configureAxes()

        # Matplotlib 0.99 does not give an easy way to listen for window close
        # events; as a result, we have to get the underlying backend-specific
        # window. This is course, somewhat fragile. Furthermore, QMainWindow
        # does not provide a signal on close that would allow us to stop the
        # rendering loop before the objects are destroyed, so we dynamically
        # override the closeEvent method on this particular instance.
        window = self._getWindow()
        oldClose = window.closeEvent
        def closeEvent(event):
            self.stop()
            oldClose(event)
        window.closeEvent = closeEvent

        # Add thread synchronization to the draw and paintEvent methods on
        # FigureCanvasQTAgg, so that we can do drawing updates in the reader
        # thread at the same time that the main thread might traw to redraw.
        # Without synchronization, this leads to exceptions and flickering.
        lock = threading.Lock()
        oldDraw = self._canvas.draw
        def draw():
            lock.acquire()
            try:
                oldDraw()
            finally:
                lock.release()
        self._canvas.draw = draw
        oldPaint = self._canvas.paintEvent
        def paintEvent(e):
            lock.acquire()
            try:
                oldPaint(e)
            finally:
                lock.release()
        self._canvas.paintEvent = paintEvent
        self._renderLock = lock