コード例 #1
0
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
コード例 #2
0
ファイル: plot.py プロジェクト: CARIBOuSystem/guiqwt
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)
コード例 #3
0
ファイル: plot.py プロジェクト: alimuldal/guiqwt
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)
コード例 #4
0
ファイル: GuiqwtScreen.py プロジェクト: adareau/pyfit-gui
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