def setup_widget(self):

        self.plot = ImagePlot(self)
        self.image = make.xyimage(self.x, self.y, self.data, colormap='jet')
        self.plot.add_item(self.image)
        self.plot.set_antialiasing(True)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)
Exemple #2
0
 def setup_image(self, i, j, win):
     p = ImagePlot(win, xlabel=self.xlabel, ylabel=self.ylabel,
                   zlabel=self.zlabel, yreverse=self.yreverse)
     self.main_widget = p
     win.add_plot(i, j, p)
     for item in self.images+self.plots:
         if item in self.images:
             item.set_color_map(self.colormap)
         p.add_item(item)
     if self.legend_position is not None:
         p.add_item(make.legend(self.legend_position))
     return p
    def __init__(self, threadacquisition=None, parent = None,):
        super(SlindingTimeFreq, self).__init__(parent)
        
        self.threadacquisition = threadacquisition
        
        self.mainlayout = QHBoxLayout()
        self.setLayout(self.mainlayout)


        v = QVBoxLayout()
        self.mainlayout.addLayout(v)
        self.combo = QComboBox()
        v.addWidget(self.combo)
        self.plot = ImagePlot(yreverse=False, lock_aspect_ratio=False,)
        v.addWidget(self.plot)

        v = QVBoxLayout()
        self.mainlayout.addLayout(v)
        
        self.spinboxes = { }
        for param, value in {'xsize':2., 'f_start':1., 'f_stop':80., 'deltafreq' : .5, 'f0':2.5}.items():
            spin = QDoubleSpinBox( decimals = 1, singleStep = 0.1, value = value, minimum = 0., maximum = np.inf)
            self.spinboxes[spin] = param
            v.addWidget(QLabel(param))
            v.addWidget(spin)
            v.addSpacing(10)
            spin.valueChanged.connect(self.paramChanged)
        v.addStretch(4)

        self.image = None
        self.xsize = 2.

        self.paramsTimeFreq = dict(
                                                        f_start=1.,
                                                        f_stop = 80.,
                                                        deltafreq = .5,
                                                        sampling_rate = 1./self.threadacquisition.samplingInterval,
                                                        f0 = 2.5,
                                                        normalisation = 0.,
                                                        )
        self.recreateThread = True
        self.isComputing = False
        self.initializeTimeFreq()
        
        
        self.timer = QTimer(singleShot = False, interval = 200)
        self.timer.timeout.connect(self.refresh)
        self.timer.start()
Exemple #4
0
    def setup_widget(self):

        self.plot = ImagePlot(self)
        self.image = make.xyimage(self.x, self.y, self.data, colormap='jet')
        self.plot.add_item(self.image)
        self.plot.set_antialiasing(True)
        #--- levels ?
        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels.append(make.curve(x, y, color="w"))
            self.plot.add_item(self.levels[-1])
        #----------------------
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)
        self.plot.adjustSize()
Exemple #5
0
    def test_adding_to_plot(self):
        s = ScanningParam()
        a = AxisParam()
        a.length = 5
        a.increment = 0.5
        a.start = -1.5
        a.unit = 'nm'
        s.axis1 = a
        s.axis2 = a
        data = np.random.rand(5,5)
        m = Measurement(data,s)
        image = ThothImageItem(m)

        from guiqwt.image import ImagePlot
        plot = ImagePlot(title="Test")
        plot.add_item(image)
        plot.show()
Exemple #6
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)

        layout = QGridLayout()
        self.setLayout(layout)

        self.plot1 = ImagePlot(self)
        layout.addWidget(self.plot1, 0, 0, 1, 1)
        self.plot2 = ImagePlot(self)
        layout.addWidget(self.plot2, 1, 0, 1, 1)

        self.contrast = ContrastAdjustment(self)
        layout.addWidget(self.contrast, 2, 0, 1, 2)
        self.itemlist = PlotItemList(self)
        layout.addWidget(self.itemlist, 0, 1, 2, 1)

        self.manager = PlotManager(self)
        for plot in (self.plot1, self.plot2):
            self.manager.add_plot(plot)
        for panel in (self.itemlist, self.contrast):
            self.manager.add_panel(panel)
Exemple #7
0
 def setup_image(self, i, j, win):
     p = ImagePlot(win,
                   xlabel=self.xlabel,
                   ylabel=self.ylabel,
                   zlabel=self.zlabel,
                   yreverse=self.yreverse)
     self.main_widget = p
     win.add_plot(i, j, p)
     for item in self.images + self.plots:
         if item in self.images:
             item.set_color_map(self.colormap)
         p.add_item(item)
     if self.legend_position is not None:
         p.add_item(make.legend(self.legend_position))
     return p
Exemple #8
0
    def test_adding_to_plot(self):
        s = ScanningParam()
        a = AxisParam()
        a.length = 5
        a.increment = 0.5
        a.start = -1.5
        a.unit = 'nm'
        s.axis1 = a
        s.axis2 = a
        data = np.random.rand(5, 5)
        m = Measurement(data, s)
        image = ThothImageItem(m)

        from guiqwt.image import ImagePlot
        plot = ImagePlot(title="Test")
        plot.add_item(image)
        plot.show()
class ImageScreen(QWidget):
    """
    Hum hum hum
    """
    def __init__(self, parent, x, y, data, sizex, sizey):
        QWidget.__init__(self, parent)

        self.setMinimumSize(sizex, sizey)
        self.x = x
        self.y = y
        self.data = data
        #---guiqwt related attributes:
        self.plot = None
        self.image = None
        self.ROI = None
        self.background = None
        #---
        self.setup_widget()

    def setup_widget(self):

        self.plot = ImagePlot(self)
        self.image = make.xyimage(self.x, self.y, self.data, colormap='jet')
        self.plot.add_item(self.image)
        self.plot.set_antialiasing(True)

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)

        #self.plot.adjustSize()

    def update_image(self):
        self.image.x = self.x
        self.image.y = self.y
        self.image.data = self.data

        self.plot.replot()

        pass
Exemple #10
0
    def __init__(self, parent=None, title="",
                 xlabel=("", ""), ylabel=("", ""), zlabel=None,
                 xunit=("", ""), yunit=("", ""), zunit=None, yreverse=True,
                 colormap="jet", aspect_ratio=1.0, lock_aspect_ratio=True,
                 show_contrast=False, show_itemlist=False, show_xsection=False,
                 show_ysection=False, xsection_pos="top", ysection_pos="right",
                 gridparam=None, curve_antialiasing=None, **kwargs):
        if PYQT5:
            super(BaseImageWidget, self).__init__(parent, **kwargs)
            self.setOrientation(Qt.Vertical)
        else:
            QSplitter.__init__(self, Qt.Vertical, parent)
        
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        
        self.sub_splitter = QSplitter(Qt.Horizontal, self)
        self.plot = ImagePlot(parent=self, title=title,
                              xlabel=xlabel, ylabel=ylabel, zlabel=zlabel,
                              xunit=xunit, yunit=yunit, zunit=zunit,
                              yreverse=yreverse, aspect_ratio=aspect_ratio,
                              lock_aspect_ratio=lock_aspect_ratio,
                              gridparam=gridparam)
        if curve_antialiasing is not None:
            self.plot.set_antialiasing(curve_antialiasing)

        from guiqwt.cross_section import YCrossSection
        self.ycsw = YCrossSection(self, position=ysection_pos,
                                  xsection_pos=xsection_pos)
        self.ycsw.setVisible(show_ysection)
        
        from guiqwt.cross_section import XCrossSection
        self.xcsw = XCrossSection(self)
        self.xcsw.setVisible(show_xsection)
        
        self.xcsw.SIG_VISIBILITY_CHANGED.connect(self.xcsw_is_visible)
        
        self.xcsw_splitter = QSplitter(Qt.Vertical, self)
        if xsection_pos == "top":
            self.xcsw_splitter.addWidget(self.xcsw)
            self.xcsw_splitter.addWidget(self.plot)
        else:
            self.xcsw_splitter.addWidget(self.plot)
            self.xcsw_splitter.addWidget(self.xcsw)
        self.xcsw_splitter.splitterMoved.connect(
                                 lambda pos, index: self.adjust_ycsw_height())
        
        self.ycsw_splitter = QSplitter(Qt.Horizontal, self)
        if ysection_pos == "left":
            self.ycsw_splitter.addWidget(self.ycsw)
            self.ycsw_splitter.addWidget(self.xcsw_splitter)
        else:
            self.ycsw_splitter.addWidget(self.xcsw_splitter)
            self.ycsw_splitter.addWidget(self.ycsw)
            
        configure_plot_splitter(self.xcsw_splitter,
                                decreasing_size=xsection_pos == "bottom")
        configure_plot_splitter(self.ycsw_splitter,
                                decreasing_size=ysection_pos == "right")
        
        self.sub_splitter.addWidget(self.ycsw_splitter)
        
        self.itemlist = PlotItemList(self)
        self.itemlist.setVisible(show_itemlist)
        self.sub_splitter.addWidget(self.itemlist)
        
        # Contrast adjustment (Levels histogram)
        from guiqwt.histogram import ContrastAdjustment
        self.contrast = ContrastAdjustment(self)
        self.contrast.setVisible(show_contrast)
        self.addWidget(self.contrast)
        
        configure_plot_splitter(self)
        configure_plot_splitter(self.sub_splitter)
Exemple #11
0
def fixed_do_autoscale_image(self, *args, **kwargs):
    ImagePlot.old_do_autoscale(self, *args, **kwargs)
    if old_guiqwt:
        self.emit(SIG_PLOT_AXIS_CHANGED, self)
    else:
        self.SIG_PLOT_AXIS_CHANGED.emit(self)
Exemple #12
0
    def __init__(self,
                 parent=None,
                 title="",
                 xlabel=("", ""),
                 ylabel=("", ""),
                 zlabel=None,
                 xunit=("", ""),
                 yunit=("", ""),
                 zunit=None,
                 yreverse=True,
                 colormap="jet",
                 aspect_ratio=1.0,
                 lock_aspect_ratio=True,
                 show_contrast=False,
                 show_itemlist=False,
                 show_xsection=False,
                 show_ysection=False,
                 xsection_pos="top",
                 ysection_pos="right",
                 gridparam=None,
                 curve_antialiasing=None,
                 **kwargs):
        if PYQT5:
            super(BaseImageWidget, self).__init__(parent, **kwargs)
            self.setOrientation(Qt.Vertical)
        else:
            QSplitter.__init__(self, Qt.Vertical, parent)

        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.sub_splitter = QSplitter(Qt.Horizontal, self)
        self.plot = ImagePlot(parent=self,
                              title=title,
                              xlabel=xlabel,
                              ylabel=ylabel,
                              zlabel=zlabel,
                              xunit=xunit,
                              yunit=yunit,
                              zunit=zunit,
                              yreverse=yreverse,
                              aspect_ratio=aspect_ratio,
                              lock_aspect_ratio=lock_aspect_ratio,
                              gridparam=gridparam)
        if curve_antialiasing is not None:
            self.plot.set_antialiasing(curve_antialiasing)

        from guiqwt.cross_section import YCrossSection
        self.ycsw = YCrossSection(self,
                                  position=ysection_pos,
                                  xsection_pos=xsection_pos)
        self.ycsw.setVisible(show_ysection)

        from guiqwt.cross_section import XCrossSection
        self.xcsw = XCrossSection(self)
        self.xcsw.setVisible(show_xsection)

        self.xcsw.SIG_VISIBILITY_CHANGED.connect(self.xcsw_is_visible)

        self.xcsw_splitter = QSplitter(Qt.Vertical, self)
        if xsection_pos == "top":
            self.xcsw_splitter.addWidget(self.xcsw)
            self.xcsw_splitter.addWidget(self.plot)
        else:
            self.xcsw_splitter.addWidget(self.plot)
            self.xcsw_splitter.addWidget(self.xcsw)
        self.xcsw_splitter.splitterMoved.connect(
            lambda pos, index: self.adjust_ycsw_height())

        self.ycsw_splitter = QSplitter(Qt.Horizontal, self)
        if ysection_pos == "left":
            self.ycsw_splitter.addWidget(self.ycsw)
            self.ycsw_splitter.addWidget(self.xcsw_splitter)
        else:
            self.ycsw_splitter.addWidget(self.xcsw_splitter)
            self.ycsw_splitter.addWidget(self.ycsw)

        configure_plot_splitter(self.xcsw_splitter,
                                decreasing_size=xsection_pos == "bottom")
        configure_plot_splitter(self.ycsw_splitter,
                                decreasing_size=ysection_pos == "right")

        self.sub_splitter.addWidget(self.ycsw_splitter)

        self.itemlist = PlotItemList(self)
        self.itemlist.setVisible(show_itemlist)
        self.sub_splitter.addWidget(self.itemlist)

        # Contrast adjustment (Levels histogram)
        from guiqwt.histogram import ContrastAdjustment
        self.contrast = ContrastAdjustment(self)
        self.contrast.setVisible(show_contrast)
        self.addWidget(self.contrast)

        configure_plot_splitter(self)
        configure_plot_splitter(self.sub_splitter)
Exemple #13
0
class BaseImageWidget(QSplitter):
    """
    Construct a BaseImageWidget object, which includes:
        * A plot (:py:class:`guiqwt.curve.CurvePlot`)
        * An `item list` panel (:py:class:`guiqwt.curve.PlotItemList`)
        * A `contrast adjustment` panel 
          (:py:class:`guiqwt.histogram.ContrastAdjustment`)
        * An `X-axis cross section` panel
          (:py:class:`guiqwt.histogram.XCrossSection`)
        * An `Y-axis cross section` panel
          (:py:class:`guiqwt.histogram.YCrossSection`)
        
    This object does nothing in itself because plot and panels are not 
    connected to each other.
    See children class :py:class:`guiqwt.plot.ImageWidget`
    """
    def __init__(self,
                 parent=None,
                 title="",
                 xlabel=("", ""),
                 ylabel=("", ""),
                 zlabel=None,
                 xunit=("", ""),
                 yunit=("", ""),
                 zunit=None,
                 yreverse=True,
                 colormap="jet",
                 aspect_ratio=1.0,
                 lock_aspect_ratio=True,
                 show_contrast=False,
                 show_itemlist=False,
                 show_xsection=False,
                 show_ysection=False,
                 xsection_pos="top",
                 ysection_pos="right",
                 gridparam=None,
                 curve_antialiasing=None,
                 **kwargs):
        if PYQT5:
            super(BaseImageWidget, self).__init__(parent, **kwargs)
            self.setOrientation(Qt.Vertical)
        else:
            QSplitter.__init__(self, Qt.Vertical, parent)

        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.sub_splitter = QSplitter(Qt.Horizontal, self)
        self.plot = ImagePlot(parent=self,
                              title=title,
                              xlabel=xlabel,
                              ylabel=ylabel,
                              zlabel=zlabel,
                              xunit=xunit,
                              yunit=yunit,
                              zunit=zunit,
                              yreverse=yreverse,
                              aspect_ratio=aspect_ratio,
                              lock_aspect_ratio=lock_aspect_ratio,
                              gridparam=gridparam)
        if curve_antialiasing is not None:
            self.plot.set_antialiasing(curve_antialiasing)

        from guiqwt.cross_section import YCrossSection
        self.ycsw = YCrossSection(self,
                                  position=ysection_pos,
                                  xsection_pos=xsection_pos)
        self.ycsw.setVisible(show_ysection)

        from guiqwt.cross_section import XCrossSection
        self.xcsw = XCrossSection(self)
        self.xcsw.setVisible(show_xsection)

        self.xcsw.SIG_VISIBILITY_CHANGED.connect(self.xcsw_is_visible)

        self.xcsw_splitter = QSplitter(Qt.Vertical, self)
        if xsection_pos == "top":
            self.xcsw_splitter.addWidget(self.xcsw)
            self.xcsw_splitter.addWidget(self.plot)
        else:
            self.xcsw_splitter.addWidget(self.plot)
            self.xcsw_splitter.addWidget(self.xcsw)
        self.xcsw_splitter.splitterMoved.connect(
            lambda pos, index: self.adjust_ycsw_height())

        self.ycsw_splitter = QSplitter(Qt.Horizontal, self)
        if ysection_pos == "left":
            self.ycsw_splitter.addWidget(self.ycsw)
            self.ycsw_splitter.addWidget(self.xcsw_splitter)
        else:
            self.ycsw_splitter.addWidget(self.xcsw_splitter)
            self.ycsw_splitter.addWidget(self.ycsw)

        configure_plot_splitter(self.xcsw_splitter,
                                decreasing_size=xsection_pos == "bottom")
        configure_plot_splitter(self.ycsw_splitter,
                                decreasing_size=ysection_pos == "right")

        self.sub_splitter.addWidget(self.ycsw_splitter)

        self.itemlist = PlotItemList(self)
        self.itemlist.setVisible(show_itemlist)
        self.sub_splitter.addWidget(self.itemlist)

        # Contrast adjustment (Levels histogram)
        from guiqwt.histogram import ContrastAdjustment
        self.contrast = ContrastAdjustment(self)
        self.contrast.setVisible(show_contrast)
        self.addWidget(self.contrast)

        configure_plot_splitter(self)
        configure_plot_splitter(self.sub_splitter)

    def adjust_ycsw_height(self, height=None):
        if height is None:
            height = self.xcsw.height() - self.ycsw.toolbar.height()
        self.ycsw.adjust_height(height)
        if height:
            QApplication.processEvents()

    def xcsw_is_visible(self, state):
        if state:
            QApplication.processEvents()
            self.adjust_ycsw_height()
        else:
            self.adjust_ycsw_height(0)
Exemple #14
0
def fixed_do_autoscale_image(self, *args, **kwargs):
    ImagePlot.old_do_autoscale(self, *args, **kwargs)
    if old_guiqwt:
        self.emit(SIG_PLOT_AXIS_CHANGED, self)
    else:
        self.SIG_PLOT_AXIS_CHANGED.emit(self)
class SlindingTimeFreq(QWidget):
    def __init__(self, threadacquisition=None, parent = None,):
        super(SlindingTimeFreq, self).__init__(parent)
        
        self.threadacquisition = threadacquisition
        
        self.mainlayout = QHBoxLayout()
        self.setLayout(self.mainlayout)


        v = QVBoxLayout()
        self.mainlayout.addLayout(v)
        self.combo = QComboBox()
        v.addWidget(self.combo)
        self.plot = ImagePlot(yreverse=False, lock_aspect_ratio=False,)
        v.addWidget(self.plot)

        v = QVBoxLayout()
        self.mainlayout.addLayout(v)
        
        self.spinboxes = { }
        for param, value in {'xsize':2., 'f_start':1., 'f_stop':80., 'deltafreq' : .5, 'f0':2.5}.items():
            spin = QDoubleSpinBox( decimals = 1, singleStep = 0.1, value = value, minimum = 0., maximum = np.inf)
            self.spinboxes[spin] = param
            v.addWidget(QLabel(param))
            v.addWidget(spin)
            v.addSpacing(10)
            spin.valueChanged.connect(self.paramChanged)
        v.addStretch(4)

        self.image = None
        self.xsize = 2.

        self.paramsTimeFreq = dict(
                                                        f_start=1.,
                                                        f_stop = 80.,
                                                        deltafreq = .5,
                                                        sampling_rate = 1./self.threadacquisition.samplingInterval,
                                                        f0 = 2.5,
                                                        normalisation = 0.,
                                                        )
        self.recreateThread = True
        self.isComputing = False
        self.initializeTimeFreq()
        
        
        self.timer = QTimer(singleShot = False, interval = 200)
        self.timer.timeout.connect(self.refresh)
        self.timer.start()

    def initializeTimeFreq(self):
        self.plot.del_all_items()
        
        self.len_wavelet = int(self.xsize/self.threadacquisition.samplingInterval)
        self.wf = generate_wavelet_fourier(len_wavelet= self.len_wavelet, ** self.paramsTimeFreq).transpose()
        
        self.win = hamming(self.len_wavelet)
        self.map = zeros(self.wf.shape)
        self.image = make.image(self.map, title='TimeFreq',interpolation ='nearest')
        self.plot.add_item(self.image)
        
        p = self.paramsTimeFreq
        self.freqs = arange(p['f_start'],p['f_stop'],p['deltafreq'])
        
        
    def paramChanged(self):
        spin = self.sender()
        name = self.spinboxes[spin]
        if name =='xsize':
            self.xsize = spin.value()
            self.xsize = min(30., self.xsize)
        else:
            self.paramsTimeFreq[name] = spin.value()
        
        self.initializeTimeFreq()
        self.recreateThread = True
        
        self.refresh()

    def refresh(self):
        if self.combo.count()==0:
            self.combo.addItems(self.threadacquisition.channelNames)
        channel = self.combo.currentIndex ()
        
        if self.isComputing:
            return
        
        sig = self.threadacquisition.buffer[-self.len_wavelet:, channel]
        if sig.size != self.len_wavelet:
            print 'xsize too BIG!!', sig.size, self.len_wavelet
            return
        
        self.isComputing = True
        
        if self.recreateThread:
            self.thread = ThreadComputeTF(sig, self.wf, self.win, parent = self)
            self.thread.finished.connect(self.mapComputed)
            self.recreateThread = False
        else:
            self.thread.sig = sig
        self.thread.start()

    def mapComputed(self):
        xaxis, yaxis = self.plot.get_active_axes()
        self.plot.setAxisScale(yaxis, self.freqs[0], self.freqs[-1])
        self.plot.setAxisScale(xaxis,-self.xsize, 0.)

        self.image.set_ydata(self.freqs[0], self.freqs[-1])
        self.image.set_xdata(-self.xsize, 0.)
        
        self.image.set_data(self.map)

        self.plot.replot()

        self.isComputing = False
Exemple #16
0
def fixed_do_autoscale_image(self, *args, **kwargs):
    ImagePlot.old_do_autoscale(self, *args, **kwargs)
    self.emit(SIG_PLOT_AXIS_CHANGED, self)
Exemple #17
0
class BaseImageWidget(QSplitter):
    """
    Construct a BaseImageWidget object, which includes:
        * A plot (:py:class:`guiqwt.curve.CurvePlot`)
        * An `item list` panel (:py:class:`guiqwt.curve.PlotItemList`)
        * A `contrast adjustment` panel 
          (:py:class:`guiqwt.histogram.ContrastAdjustment`)
        * An `X-axis cross section` panel
          (:py:class:`guiqwt.histogram.XCrossSection`)
        * An `Y-axis cross section` panel
          (:py:class:`guiqwt.histogram.YCrossSection`)
        
    This object does nothing in itself because plot and panels are not 
    connected to each other.
    See children class :py:class:`guiqwt.plot.ImageWidget`
    """
    def __init__(self, parent=None, title="",
                 xlabel=("", ""), ylabel=("", ""), zlabel=None,
                 xunit=("", ""), yunit=("", ""), zunit=None, yreverse=True,
                 colormap="jet", aspect_ratio=1.0, lock_aspect_ratio=True,
                 show_contrast=False, show_itemlist=False, show_xsection=False,
                 show_ysection=False, xsection_pos="top", ysection_pos="right",
                 gridparam=None, curve_antialiasing=None, **kwargs):
        if PYQT5:
            super(BaseImageWidget, self).__init__(parent, **kwargs)
            self.setOrientation(Qt.Vertical)
        else:
            QSplitter.__init__(self, Qt.Vertical, parent)
        
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        
        self.sub_splitter = QSplitter(Qt.Horizontal, self)
        self.plot = ImagePlot(parent=self, title=title,
                              xlabel=xlabel, ylabel=ylabel, zlabel=zlabel,
                              xunit=xunit, yunit=yunit, zunit=zunit,
                              yreverse=yreverse, aspect_ratio=aspect_ratio,
                              lock_aspect_ratio=lock_aspect_ratio,
                              gridparam=gridparam)
        if curve_antialiasing is not None:
            self.plot.set_antialiasing(curve_antialiasing)

        from guiqwt.cross_section import YCrossSection
        self.ycsw = YCrossSection(self, position=ysection_pos,
                                  xsection_pos=xsection_pos)
        self.ycsw.setVisible(show_ysection)
        
        from guiqwt.cross_section import XCrossSection
        self.xcsw = XCrossSection(self)
        self.xcsw.setVisible(show_xsection)
        
        self.xcsw.SIG_VISIBILITY_CHANGED.connect(self.xcsw_is_visible)
        
        self.xcsw_splitter = QSplitter(Qt.Vertical, self)
        if xsection_pos == "top":
            self.xcsw_splitter.addWidget(self.xcsw)
            self.xcsw_splitter.addWidget(self.plot)
        else:
            self.xcsw_splitter.addWidget(self.plot)
            self.xcsw_splitter.addWidget(self.xcsw)
        self.xcsw_splitter.splitterMoved.connect(
                                 lambda pos, index: self.adjust_ycsw_height())
        
        self.ycsw_splitter = QSplitter(Qt.Horizontal, self)
        if ysection_pos == "left":
            self.ycsw_splitter.addWidget(self.ycsw)
            self.ycsw_splitter.addWidget(self.xcsw_splitter)
        else:
            self.ycsw_splitter.addWidget(self.xcsw_splitter)
            self.ycsw_splitter.addWidget(self.ycsw)
            
        configure_plot_splitter(self.xcsw_splitter,
                                decreasing_size=xsection_pos == "bottom")
        configure_plot_splitter(self.ycsw_splitter,
                                decreasing_size=ysection_pos == "right")
        
        self.sub_splitter.addWidget(self.ycsw_splitter)
        
        self.itemlist = PlotItemList(self)
        self.itemlist.setVisible(show_itemlist)
        self.sub_splitter.addWidget(self.itemlist)
        
        # Contrast adjustment (Levels histogram)
        from guiqwt.histogram import ContrastAdjustment
        self.contrast = ContrastAdjustment(self)
        self.contrast.setVisible(show_contrast)
        self.addWidget(self.contrast)
        
        configure_plot_splitter(self)
        configure_plot_splitter(self.sub_splitter)
        
    def adjust_ycsw_height(self, height=None):
        if height is None:
            height = self.xcsw.height()-self.ycsw.toolbar.height()
        self.ycsw.adjust_height(height)
        if height:
            QApplication.processEvents()
        
    def xcsw_is_visible(self, state):
        if state:
            QApplication.processEvents()
            self.adjust_ycsw_height()
        else:
            self.adjust_ycsw_height(0)
Exemple #18
0
def fixed_do_autoscale_image(self, *args, **kwargs):
    ImagePlot.old_do_autoscale(self, *args, **kwargs)
    self.emit(SIG_PLOT_AXIS_CHANGED, self)
Exemple #19
0
class ImageScreen(QWidget):
    """
    Hum hum hum
    """
    def __init__(self, parent, x, y, data):
        QWidget.__init__(self, parent)

        #self.setMinimumSize(sizex, sizey)
        self.x = x
        self.y = y
        self.data = data
        self.level_xy = [[[0, 0], [0, 0]] for i in range(8)]
        #---guiqwt related attributes:
        self.plot = None
        self.image = None
        self.ROI = None
        self.background = None
        self.levels = []
        #---
        self.setup_widget()

    def setup_widget(self):

        self.plot = ImagePlot(self)
        self.image = make.xyimage(self.x, self.y, self.data, colormap='jet')
        self.plot.add_item(self.image)
        self.plot.set_antialiasing(True)
        #--- levels ?
        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels.append(make.curve(x, y, color="w"))
            self.plot.add_item(self.levels[-1])
        #----------------------
        vlayout = QVBoxLayout()
        vlayout.addWidget(self.plot)
        self.setLayout(vlayout)
        self.plot.adjustSize()

    def update_image(self):
        self.image.x = self.x
        self.image.y = self.y
        self.image.data = self.data

        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels[i].x = x
            self.levels[i].y = y
        self.plot.replot()

        pass

    def update_contour(self):

        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels[i].set_data(x, y)
        self.plot.replot()

        pass

    def reset_contour(self):
        self.level_xy = [[[0, 0], [0, 0]] for i in range(8)]
        for i in range(8):
            x = self.level_xy[i][0]
            y = self.level_xy[i][1]
            self.levels[i].set_data(x, y)

        self.plot.replot()

        pass