示例#1
0
def create_window():
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="Cross sections test",
                      options=dict(show_xsection=True, show_ysection=True))
    win.resize(600, 600)
    return win
 def __init__(self,
              parent=None,
              designMode=False,
              toolbar=True,
              stackMode='deltatime',
              buffersize=512,
              options=None,
              **kwargs):
     '''see :class:`guiqwt.plot.ImageDialog` for other valid initialization parameters'''
     defaultOptions = dict(lock_aspect_ratio=False)
     if options is not None:
         defaultOptions.update(options)
     ImageDialog.__init__(self,
                          parent=parent,
                          toolbar=toolbar,
                          options=defaultOptions,
                          **kwargs)
     TaurusBaseWidget.__init__(self, "TaurusTrend2DDialog")
     self.trendItem = None
     self.buffersize = buffersize
     self._useArchiving = False
     self._stackMode = stackMode
     self.setStackMode(stackMode)
     self.setWindowFlags(Qt.Qt.Widget)
     # add some tools
     for toolklass in (TaurusModelChooserTool, AutoScrollTool):
         self.add_tool(toolklass)
     self.get_tool(TaurusModelChooserTool).singleModel = True
     self.setModifiableByUser(self._modifiableByUser)
     self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
示例#3
0
    def roi_setup(self):
        """Show a dialog to setup the region of interest."""
        dialog = ImageDialog("ROI Setup", edit=True, toolbar=False, parent=self)
        default = dialog.add_tool(SelectTool)
        dialog.set_default_tool(default)
        roi_tool = dialog.add_tool(RectangleTool, switch_to_default_tool=True)
        roi = self.cam.roi
        old_roi = roi
        roi_tool.activate()

        # Get image and display
        plot = dialog.get_plot()
        img = make.image(self.cam_thread.img_data)
        plot.add_item(img)
        plot.set_active_item(img)

        # Wait for user input
        dialog.show()
        if dialog.exec_():
            try:
                roi = get_rect(roi_tool)
                self.cam.set_roi(roi)
            except:
                e = sys.exc_info()
                print(e)
                self.cam.set_roi(old_roi)
示例#4
0
def create_window():
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="All image and plot tools test")
    for toolklass in (
            LabelTool,
            HRangeTool,
            VCursorTool,
            HCursorTool,
            XCursorTool,
            SegmentTool,
            RectangleTool,
            ObliqueRectangleTool,
            CircleTool,
            EllipseTool,
            MultiLineTool,
            FreeFormTool,
            PlaceAxesTool,
            AnnotatedRectangleTool,
            AnnotatedObliqueRectangleTool,
            AnnotatedCircleTool,
            AnnotatedEllipseTool,
            AnnotatedSegmentTool,
            AnnotatedPointTool,
    ):
        win.add_tool(toolklass)
    return win
示例#5
0
 def create_plot(self, options, row=0, column=0, rowspan=1, columnspan=1):
     ImageDialog.create_plot(self, options, row, column, rowspan, columnspan)
     ra_panel = ObliqueCrossSection(self)
     splitter = self.plot_widget.xcsw_splitter
     splitter.addWidget(ra_panel)
     splitter.setStretchFactor(splitter.count() - 1, 1)
     splitter.setSizes(list(splitter.sizes()) + [2])
     self.add_panel(ra_panel)
示例#6
0
def create_window():
    gridparam = make.gridparam(background="black", minor_enabled=(False, False), major_style=(".", "gray", 1))
    win = ImageDialog(
        edit=False, toolbar=True, wintitle="Region of interest (ROI) test", options=dict(gridparam=gridparam)
    )
    for toolklass in (RectangleTool, EllipseTool, FreeFormTool, PlaceAxesTool):
        win.add_tool(toolklass)
    return win
示例#7
0
def create_window():
    gridparam = make.gridparam(background="black", minor_enabled=(False, False),
                               major_style=(".", "gray", 1))
    win = ImageDialog(edit=False, toolbar=True,
                      wintitle="Region of interest (ROI) test",
                      options=dict(gridparam=gridparam))
    for toolklass in (RectangleTool, EllipseTool, FreeFormTool, PlaceAxesTool):
        win.add_tool(toolklass)
    return win
 def create_plot(self, options, row=0, column=0, rowspan=1, columnspan=1):
     ImageDialog.create_plot(self, options, row, column, rowspan,
                             columnspan)
     ra_panel = ObliqueCrossSection(self)
     splitter = self.plot_widget.xcsw_splitter
     splitter.addWidget(ra_panel)
     splitter.setStretchFactor(splitter.count() - 1, 1)
     splitter.setSizes(list(splitter.sizes()) + [2])
     self.add_panel(ra_panel)
示例#9
0
文件: plot.py 项目: dscran/taurus
 def __init__(self, parent=None, designMode=False, toolbar=True, **kwargs):
     '''see :class:`guiqwt.plot.ImageDialog` for other valid initialization parameters'''
     ImageDialog.__init__(self, parent=parent, toolbar=toolbar, **kwargs)
     TaurusBaseWidget.__init__(self, 'TaurusImageDialog')
     self.setWindowFlags(Qt.Qt.Widget)
     self.imgItem = None
     from taurus.qt.qtgui.extra_guiqwt.tools import TaurusModelChooserTool
     self.add_tool(TaurusModelChooserTool, singleModel=True)
     self.setModifiableByUser(True)
     self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
示例#10
0
文件: base.py 项目: mindw/guiqwt
 def __init__(self, parent, wintitle=None, options=None, resize_to=None):
     if wintitle is None:
         wintitle = _("Rotate & Crop")
     ImageDialog.__init__(self, wintitle=wintitle, edit=True,
                          toolbar=False, options=options, parent=parent)
     if resize_to is not None:
         width, height = resize_to
         self.resize(width, height)
     self.accepted.connect(self.accept_changes)
     self.rejected.connect(self.reject_changes)
示例#11
0
    def create_plot(self, options):
        self.filter_gbox = DataSetEditGroupBox(_("Filter parameters"), FilterParam)
        self.filter_gbox.setEnabled(False)
        self.filter_gbox.SIG_APPLY_BUTTON_CLICKED.connect(self.apply_filter)
        self.plot_layout.addWidget(self.filter_gbox, 0, 0)
        self.param_gbox = DataSetShowGroupBox(_("Image parameters"), ImageParam)
        self.plot_layout.addWidget(self.param_gbox, 0, 1)

        options = dict(title=_("Image title"), zlabel=_("z-axis scale label"))
        ImageDialog.create_plot(self, options, 1, 0, 1, 0)
示例#12
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata

    _app = guidata.qapplication()
    # --
    filename = osp.join(osp.dirname(__file__), "brain.png")
    image = make.image(filename=filename, title="Original", colormap="gray")

    win = ImageDialog(
        edit=False,
        toolbar=True,
        wintitle="Contrast test",
        options=dict(show_contrast=True),
    )
    plot = win.get_plot()
    plot.add_item(image)
    win.resize(600, 600)
    win.show()
    try:
        plot.save_widget("contrast.png")
    except IOError:
        # Skipping this part of the test
        # because user has no write permission on current directory
        pass
    win.exec_()
示例#13
0
def create_window():
    gridparam = make.gridparam(background="black",
                               minor_enabled=(False, False),
                               major_style=(".", "gray", 1))
    win = ImageDialog(edit=False, toolbar=True,
                      wintitle="All image and plot tools test",
                      options=dict(gridparam=gridparam))
    for toolklass in (RectangleTool, EllipseTool, SegmentTool,
                      MultiLineTool, FreeFormTool):
        win.add_tool(toolklass, handle_final_shape_cb=customize_shape)
    return win
示例#14
0
 def create_plot(self, options):
     self.filter_gbox = DataSetEditGroupBox(_("Filter parameters"),
                                            FilterParam)
     self.filter_gbox.setEnabled(False)
     self.filter_gbox.SIG_APPLY_BUTTON_CLICKED.connect(self.apply_filter)
     self.plot_layout.addWidget(self.filter_gbox, 0, 0)
     self.param_gbox = DataSetShowGroupBox(_("Image parameters"), ImageParam)
     self.plot_layout.addWidget(self.param_gbox, 0, 1)
     
     options = dict(title=_("Image title"), zlabel=_("z-axis scale label"))
     ImageDialog.create_plot(self, options, 1, 0, 1, 0)
示例#15
0
def test():
    filename = osp.join(osp.dirname(__file__), "mr-brain.dcm")
    image = make.image(filename=filename, title="DICOM img", colormap='gray')
    win = ImageDialog(edit=False, toolbar=True, wintitle="DICOM I/O test",
                      options=dict(show_contrast=True))
    plot = win.get_plot()
    plot.add_item(image)
    plot.select_item(image)
    contrast = win.get_contrast_panel()
    contrast.histogram.eliminate_outliers(54.)
    win.resize(600, 700)
    return win
示例#16
0
def create_window():
    gridparam = make.gridparam(background="black",
                               minor_enabled=(False, False),
                               major_style=(".", "gray", 1))
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="All image and plot tools test",
                      options=dict(gridparam=gridparam))
    for toolklass in (RectangleTool, EllipseTool, SegmentTool, MultiLineTool,
                      FreeFormTool):
        win.add_tool(toolklass, handle_final_shape_cb=customize_shape)
    return win
示例#17
0
def create_window():
    win = ImageDialog(edit=False, toolbar=True,
                      wintitle="All image and plot tools test")
    for toolklass in (LabelTool, HRangeTool,
                      VCursorTool, HCursorTool, XCursorTool,
                      SegmentTool, RectangleTool, ObliqueRectangleTool,
                      CircleTool, EllipseTool,
                      MultiLineTool, FreeFormTool, PlaceAxesTool,
                      AnnotatedRectangleTool, AnnotatedObliqueRectangleTool,
                      AnnotatedCircleTool, AnnotatedEllipseTool,
                      AnnotatedSegmentTool, AnnotatedPointTool):
        win.add_tool(toolklass)
    return win
示例#18
0
def imshow(data, title=None, hold=False):
    dlg = ImageDialog(wintitle=title)
    dlg.get_plot().add_item(make.image(data))
    if hold:
        dlg.show()
    else:
        dlg.exec_()
示例#19
0
def taurusImageMain():
    from guiqwt.tools import (RectangleTool, EllipseTool, HRangeTool,
                              PlaceAxesTool, MultiLineTool, FreeFormTool,
                              SegmentTool, CircleTool, AnnotatedRectangleTool,
                              AnnotatedEllipseTool, AnnotatedSegmentTool,
                              AnnotatedCircleTool, LabelTool,
                              AnnotatedPointTool, ObliqueRectangleTool,
                              AnnotatedObliqueRectangleTool)
    try:  # In newer guiqwt versions, Annotated*CursorTool have been replaced by *CursorTool
        from guiqwt.tools import AnnotatedVCursorTool, AnnotatedHCursorTool
        VCursorTool, HCursorTool = AnnotatedVCursorTool, AnnotatedHCursorTool
    except ImportError:
        from guiqwt.tools import VCursorTool, HCursorTool

    from taurus.qt.qtgui.extra_guiqwt.tools import TaurusImageChooserTool
    from guiqwt.plot import ImageDialog
    from taurus.qt.qtgui.extra_guiqwt.builder import make
    from taurus.qt.qtgui.application import TaurusApplication
    import taurus.core.util.argparse
    import sys

    parser = taurus.core.util.argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [<model1> [<model2>] ...]")
    parser.set_description("a taurus application for plotting 2D data sets")
    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurusimage",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()

    # create a dialog with a plot and add the images
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="Taurus Image",
                      options=dict(show_xsection=False, show_ysection=False))

    # add tools
    for toolklass in (TaurusImageChooserTool, LabelTool, HRangeTool,
                      MultiLineTool, FreeFormTool, PlaceAxesTool,
                      AnnotatedObliqueRectangleTool, AnnotatedEllipseTool,
                      AnnotatedSegmentTool, AnnotatedPointTool, VCursorTool,
                      HCursorTool):
        win.add_tool(toolklass)

    # add images from given models
    plot = win.get_plot()
    for m in args:
        img = make.image(taurusmodel=m)
        plot.add_item(img)
        # IMPORTANT: connect the cross section plots to the taurusimage so that
        # they are updated when the taurus data changes
        win.connect(img.getSignaller(), Qt.SIGNAL("dataChanged"),
                    win.update_cross_sections)

    win.exec_()
示例#20
0
def xyimagebug(offset):
    from guiqwt.plot import ImageDialog
    from guiqwt.builder import make
    import numpy
    import guidata
    app = guidata.qapplication()
    data = numpy.random.rand(100, 100)
    x = numpy.arange(100)+offset 
    y = numpy.arange(100)
    image = make.xyimage(x, y, data=data)
    win = ImageDialog()
    plot = win.get_plot()
    plot.add_item(image)
    plot.select_item(image) #this helps in seeing where the image should be
    win.exec_()
示例#21
0
def xyimagebug(offset):
    from guiqwt.plot import ImageDialog
    from guiqwt.builder import make
    import numpy
    import guidata
    app = guidata.qapplication()
    data = numpy.random.rand(100, 100)
    x = numpy.arange(100)+offset 
    y = numpy.arange(100)
    image = make.xyimage(x, y, data=data)
    win = ImageDialog()
    plot = win.get_plot()
    plot.add_item(image)
    plot.select_item(image) #this helps in seeing where the image should be
    win.exec_()
示例#22
0
def get_segment(item):
    """Show image and return selected segment coordinates"""
    win = ImageDialog(_("Select a segment then press OK to accept"), edit=True)
    default = win.add_tool(SelectTool)
    win.set_default_tool(default)
    segtool = win.add_tool(AnnotatedSegmentTool,
                           title="Test",
                           switch_to_default_tool=True)
    segtool.activate()
    plot = win.get_plot()
    plot.add_item(item)
    plot.set_active_item(item)
    win.show()
    if win.exec_():
        shape = segtool.get_last_final_shape()
        return shape.get_rect()
示例#23
0
def mandel():
    win = ImageDialog(edit=True,
                      toolbar=True,
                      wintitle="Mandelbrot",
                      options=dict(yreverse=False))
    mandel = MandelItem(-1.5, .5, -1., 1.)
    win.add_tool(FullScale, mandel)
    plot = win.get_plot()
    plot.set_aspect_ratio(lock=False)
    plot.add_item(mandel)
    plot.set_full_scale(mandel)
    win.show()
    win.exec_()
示例#24
0
 def create_dialog(self):
     self.dlg = dlg = ImageDialog(\
             edit=False, toolbar=True, wintitle="Load/save test",
             options=dict(title="Title", xlabel="xlabel", ylabel="ylabel"))
     dlg.add_separator_tool()
     dlg.add_tool(LoadItemsTool)
     dlg.add_tool(SaveItemsTool)
     dlg.add_tool(ImageMaskTool)
示例#25
0
def imshow(items, title=""):
    gridparam = make.gridparam(background="black",
                               minor_enabled=(False, False),
                               major_style=(".", "gray", 1))
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle=title,
                      options=dict(gridparam=gridparam))
    nc = int(np.sqrt(len(items)) + 1.0)
    maxy = 0
    y = 0
    x = 0
    w = None
    plot = win.get_plot()
    print("-" * 80)
    for i, item in enumerate(items):
        h = item.boundingRect().height()
        if i % nc == 0:
            x = 0
            y += maxy
            maxy = h
        else:
            x += w
            maxy = max(maxy, h)
        w = item.boundingRect().width()

        item.set_transform(x, y, 0.0)
        print("Adding item #%d..." % i, end=' ')
        plot.add_item(item)
        print("Done")
    win.show()
    win.exec_()
示例#26
0
def imshow(filename):
    win = ImageDialog(edit=False, toolbar=True, wintitle="RGB image item test")
    item = make.rgbimage(filename=filename, xdata=[-1, 1], ydata=[-1, 1])
    plot = win.get_plot()
    plot.add_item(item)
    win.show()
    win.exec_()
示例#27
0
def test():
    win = ImageDialog(edit=True, toolbar=True, wintitle="Sample multi-polygon item")
    plot = win.get_plot()
    plot.set_aspect_ratio(lock=True)
    plot.set_antialiasing(False)
    plot.set_axis_direction("left", False)
    plot.set_axis_title("bottom", "Lon")
    plot.set_axis_title("left", "Lat")

    points = []
    offsets = zeros((NCIRC, 2), int32)
    colors = zeros((NCIRC, 2), uint32)
    npts = 0
    for k in range(NCIRC):
        pts = create_circle()
        offsets[k, 0] = k
        offsets[k, 1] = npts
        npts += pts.shape[0]
        points.append(pts)
        colors[k, 0] = COLORS[k % len(COLORS)][0]
        colors[k, 1] = COLORS[(3 * k) % len(COLORS)][1]
    points = concatenate(points)

    print(NCIRC, "Polygons")
    print(points.shape[0], "Points")

    crv = PolygonMapItem()
    crv.set_data(points, offsets, colors)
    plot.add_item(crv, z=0)
    win.show()
    win.exec_()
示例#28
0
文件: mandelbrot.py 项目: HaMF/guiqwt
def mandel():
    win = ImageDialog(edit=True, toolbar=True, wintitle="Mandelbrot",
                      options=dict(yreverse=False))
    mandel = MandelItem(-1.5, .5, -1., 1.)
    win.add_tool(FullScale, mandel)
    plot = win.get_plot()
    plot.set_aspect_ratio(lock=False)
    plot.add_item(mandel)
    plot.set_full_scale(mandel)
    win.show()
    win.exec_()
示例#29
0
def imshow( items ):
    win = ImageDialog(edit=False, toolbar=True, options={"yreverse": False},
                      wintitle="Pcolor test")
    plot = win.get_plot()
    for item in items:
        plot.add_item(item)
    win.show()
    win.exec_()
示例#30
0
def get_segment(item):
    """Show image and return selected segment coordinates"""
    win = ImageDialog(_("Select a segment then press OK to accept"), edit=True)
    default = win.add_tool(SelectTool)
    win.set_default_tool(default)
    segtool = win.add_tool(AnnotatedSegmentTool, title="Test",
                           switch_to_default_tool=True)
    segtool.activate()
    plot = win.get_plot()
    plot.add_item(item)
    plot.set_active_item(item)
    win.show()
    if win.exec_():
        shape = segtool.get_last_final_shape()
        return shape.get_rect()
示例#31
0
文件: image.py 项目: berrosse/guiqwt
def imshow( data ):
    win = ImageDialog(edit=False, toolbar=True, wintitle="ImageDialog test",
                      options=dict(xlabel='Concentration', xunit='ppm'))
    item = make.image(data)
    plot = win.get_plot()
    plot.add_item(item)
    win.show()
    win.exec_()
示例#32
0
def imshow( x, y, data ):
    win = ImageDialog(edit=False, toolbar=True,
                      wintitle="Image with custom X/Y axes scales",
                      options=dict(xlabel="x (a.u.)", ylabel="y (a.u.)",
                                   yreverse=False))
    item = make.xyimage(x, y, data)
    plot = win.get_plot()
    plot.add_item(item)
    win.show()
    win.exec_()
示例#33
0
    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.parent = parent
        self.base_path = os.path.realpath(os.path.curdir)
        self.threadAcq = ThreadAcq(self)
        self.configMTE = QSettings('configMTE.ini', QSettings.IniFormat)

        self.setup()

        self.win = ImageDialog(edit=False,
                               toolbar=True,
                               wintitle="Visu Data",
                               options=dict(show_xsection=True,
                                            show_ysection=True,
                                            show_contrast=True,
                                            show_itemlist=False))
        self.win.resize(800, 1000)
        data = np.ones((1300, 1340))
        self.item_data = make.image(data, colormap='hot')
        self.plot = self.win.get_plot()
        self.plot.add_item(self.item_data)
示例#34
0
文件: image_rgb.py 项目: HaMF/guiqwt
def imshow(filename):
    win = ImageDialog(edit=False, toolbar=True, wintitle="RGB image item test")
    item = make.rgbimage(filename=filename, xdata=[-1, 1], ydata=[-1, 1])
    plot = win.get_plot()
    plot.add_item(item)
    win.show()
    win.exec_()
示例#35
0
文件: polygons.py 项目: HaMF/guiqwt
def test():
    win = ImageDialog(edit=True, toolbar=True,
                      wintitle="Sample multi-polygon item")
    plot = win.get_plot()
    plot.set_aspect_ratio(lock=True)
    plot.set_antialiasing(False)
    plot.set_axis_direction('left', False)
    plot.set_axis_title("bottom", "Lon")
    plot.set_axis_title("left", "Lat")
    
    points = []
    offsets = zeros( (NCIRC, 2), int32)
    colors = zeros( (NCIRC, 2), uint32)
    npts = 0
    for k in range(NCIRC):
        pts = create_circle()
        offsets[k, 0] = k
        offsets[k, 1] = npts
        npts += pts.shape[0]
        points.append(pts)
        colors[k, 0] = COLORS[k%len(COLORS)][0]
        colors[k, 1] = COLORS[(3*k)%len(COLORS)][1]
    points = concatenate(points)
    
    print(NCIRC, "Polygons")
    print(points.shape[0], "Points")
    
    crv = PolygonMapItem()
    crv.set_data(points, offsets, colors)
    plot.add_item(crv, z=0)
    win.show()
    win.exec_()
示例#36
0
文件: QWTWidget.py 项目: Jothy/RTQA
class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(651, 506)
        self.gridLayout = QtGui.QGridLayout(Form)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.imagewidget = ImageDialog()
        self.imagewidget.setOrientation(QtCore.Qt.Vertical)
        self.imagewidget.setObjectName(_fromUtf8("imagewidget"))
        for toolklass in (LabelTool, HRangeTool,
                      VCursorTool, HCursorTool, XCursorTool,
                      SegmentTool, RectangleTool, ObliqueRectangleTool,
                      CircleTool, EllipseTool,
                      MultiLineTool, FreeFormTool, PlaceAxesTool,
                      AnnotatedRectangleTool, AnnotatedObliqueRectangleTool,
                      AnnotatedCircleTool, AnnotatedEllipseTool,
                      AnnotatedSegmentTool, AnnotatedPointTool):
                        self.imagewidget.add_tool(toolklass)
        self.gridLayout.addWidget(self.imagewidget, 0, 0, 1, 1)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(_translate("Form", "Form", None))
示例#37
0
def imshow(items, title=""):
    gridparam = make.gridparam(background="black", minor_enabled=(False, False),
                               major_style=(".", "gray", 1))
    win = ImageDialog(edit=False, toolbar=True, wintitle=title,
                      options=dict(gridparam=gridparam))
    nc = int(np.sqrt(len(items))+1.0)
    maxy = 0
    y = 0
    x = 0
    w = None
    plot = win.get_plot()
    print("-"*80)
    for i, item in enumerate(items):
        h = item.boundingRect().height()
        if i%nc==0:
            x = 0
            y += maxy
            maxy = h
        else:
            x += w
            maxy = max(maxy, h)
        w = item.boundingRect().width()

        item.set_transform(x, y, 0.0)
        print("Adding item #%d..." % i, end=' ')
        plot.add_item(item)
        print("Done")
    win.show()
    win.exec_()
示例#38
0
文件: pcolor.py 项目: HaMF/guiqwt
def imshow( items ):
    win = ImageDialog(edit=False, toolbar=True, options={"yreverse": False},
                      wintitle="Pcolor test")
    plot = win.get_plot()
    for item in items:
        plot.add_item(item)
    win.show()
    win.exec_()
示例#39
0
 def __init__(self, parent=None, designMode=False, toolbar=True,
              stackMode='deltatime', buffersize=512, options=None, **kwargs):
     """see :class:`guiqwt.plot.ImageDialog` for other valid initialization
     parameters"""
     defaultOptions = dict(lock_aspect_ratio=False)
     if options is not None:
         defaultOptions.update(options)
     ImageDialog.__init__(self, parent=parent, toolbar=toolbar,
                          options=defaultOptions, **kwargs)
     TaurusBaseWidget.__init__(self, "TaurusTrend2DDialog")
     self.trendItem = None
     self.buffersize = buffersize
     self._useArchiving = False
     self._stackMode = stackMode
     self.setStackMode(stackMode)
     self.setWindowFlags(Qt.Qt.Widget)
     # add some tools
     for toolklass in (TaurusModelChooserTool, AutoScrollTool):
         self.add_tool(toolklass)
     self.get_tool(TaurusModelChooserTool).singleModel = True
     self.setModifiableByUser(self._modifiableByUser)
     self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
     self.registerConfigDelegate(self.get_tool(AutoScrollTool))
示例#40
0
def hist2d_func(X, Y, Z):
    win = ImageDialog(edit=True, toolbar=True,
                      wintitle="2-D Histogram X0=(0,1), X1=(-1,-1)")
    hist2d = make.histogram2D(X, Y, 200, 200, Z=Z, computation=2)
    curve = make.curve(X[::50], Y[::50],
                       linestyle='', marker='+', title=_("Markers"))
    plot = win.get_plot()
    plot.set_aspect_ratio(lock=False)
    plot.set_antialiasing(False)
    plot.add_item(hist2d)
    plot.add_item(curve)
    plot.set_item_visible(curve, False)
    win.show()
    win.exec_()
示例#41
0
def hist2d_func(X, Y, Z):
    win = ImageDialog(edit=True, toolbar=True, wintitle="2-D Histogram X0=(0,1), X1=(-1,-1)")
    hist2d = make.histogram2D(X, Y, 200, 200, Z=Z, computation=2)
    curve = make.curve(X[::50], Y[::50], linestyle="", marker="+", title=_("Markers"))
    plot = win.get_plot()
    plot.set_aspect_ratio(lock=False)
    plot.set_antialiasing(False)
    plot.add_item(hist2d)
    plot.add_item(curve)
    plot.set_item_visible(curve, False)
    win.show()
    win.exec_()
示例#42
0
文件: image.py 项目: cmft/taurus
def taurusImageMain():
    from guiqwt.tools import (RectangleTool, EllipseTool, HRangeTool, PlaceAxesTool,
                              MultiLineTool, FreeFormTool, SegmentTool, CircleTool,
                              AnnotatedRectangleTool, AnnotatedEllipseTool,
                              AnnotatedSegmentTool, AnnotatedCircleTool, LabelTool,
                              AnnotatedPointTool, ObliqueRectangleTool,
                              AnnotatedObliqueRectangleTool)
    try:  # In newer guiqwt versions, Annotated*CursorTool have been replaced by *CursorTool
        from guiqwt.tools import AnnotatedVCursorTool, AnnotatedHCursorTool
        VCursorTool, HCursorTool = AnnotatedVCursorTool, AnnotatedHCursorTool
    except ImportError:
        from guiqwt.tools import VCursorTool, HCursorTool

    from taurus.qt.qtgui.extra_guiqwt.tools import TaurusImageChooserTool
    from guiqwt.plot import ImageDialog
    from taurus.qt.qtgui.extra_guiqwt.builder import make
    from taurus.qt.qtgui.application import TaurusApplication
    import taurus.core.util.argparse
    import sys

    parser = taurus.core.util.argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [<model1> [<model2>] ...]")
    parser.set_description("a taurus application for plotting 2D data sets")
    app = TaurusApplication(
        cmd_line_parser=parser, app_name="taurusimage", app_version=taurus.Release.version)
    args = app.get_command_line_args()

    # create a dialog with a plot and add the images
    win = ImageDialog(edit=False, toolbar=True, wintitle="Taurus Image",
                      options=dict(show_xsection=False, show_ysection=False))

    # add tools
    for toolklass in (TaurusImageChooserTool,
                      LabelTool, HRangeTool,
                      MultiLineTool, FreeFormTool, PlaceAxesTool,
                      AnnotatedObliqueRectangleTool,
                      AnnotatedEllipseTool, AnnotatedSegmentTool,
                      AnnotatedPointTool, VCursorTool,
                      HCursorTool):
        win.add_tool(toolklass)

    # add images from given models
    plot = win.get_plot()
    for m in args:
        img = make.image(taurusmodel=m)
        plot.add_item(img)
        # IMPORTANT: connect the cross section plots to the taurusimage so that
        # they are updated when the taurus data changes
        img.dataChanged.connect(win.update_cross_sections)

    win.exec_()
示例#43
0
def test():
    filename = osp.join(osp.dirname(__file__), "mr-brain.dcm")
    image = make.image(filename=filename, title="DICOM img", colormap='gray')
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="DICOM I/O test",
                      options=dict(show_contrast=True))
    plot = win.get_plot()
    plot.add_item(image)
    plot.select_item(image)
    contrast = win.get_contrast_panel()
    contrast.histogram.eliminate_outliers(54.)
    win.resize(600, 700)
    return win
示例#44
0
def imshow(x, y, data, filter_area, yreverse=True):
    win = ImageDialog(edit=False, toolbar=True, wintitle="Image filter demo",
                      options=dict(xlabel="x (cm)", ylabel="y (cm)",
                                   yreverse=yreverse))
    image = make.xyimage(x, y, data)
    plot = win.get_plot()
    plot.add_item(image)
    xmin, xmax, ymin, ymax = filter_area
    flt = make.imagefilter(xmin, xmax, ymin, ymax, image,
                           filter=lambda x, y, data: gaussian_filter(data, 5))
    plot.add_item(flt, z=1)
    plot.replot()
    win.show()
    win.exec_()
示例#45
0
def test():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --
    filename = osp.join(osp.dirname(__file__), "brain.png")
    image = make.image(filename=filename, title="Original", colormap='gray')

    win = ImageDialog(edit=False, toolbar=True, wintitle="Contrast test",
                      options=dict(show_contrast=True))
    plot = win.get_plot()
    plot.add_item(image)
    win.resize(600, 600)
    win.show()
    try:
        plot.save_widget('contrast.png')
    except IOError:
        # Skipping this part of the test
        # because user has no write permission on current directory
        pass
    win.exec_()
示例#46
0
def plotImage(x,y,z,wintitle="Contour Plot",options={"lock_aspect_ratio":False,"yreverse":False}):
    options.update(dict(show_xsection=True, show_ysection=True))
    """Test"""
    # -- Create QApplication    
    _app = guidata.qapplication()
    # --
    win = ImageDialog(edit=True, toolbar=True, wintitle=wintitle,
                      options=options)
    win.resize(1500, 1000)
    item = make.xyimage(x, y, z,interpolation="linear")    
    plot = win.get_plot()
    plot.add_item(item)        
    win.plot_widget.xcsw_splitter.setSizes([400,600])
    win.show()
    return win
示例#47
0
def imshow(x, y, data, filter_area, yreverse=True):
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="Image filter demo",
                      options=dict(xlabel="x (cm)",
                                   ylabel="y (cm)",
                                   yreverse=yreverse))
    image = make.xyimage(x, y, data)
    plot = win.get_plot()
    plot.add_item(image)
    xmin, xmax, ymin, ymax = filter_area
    flt = make.imagefilter(xmin,
                           xmax,
                           ymin,
                           ymax,
                           image,
                           filter=lambda x, y, data: gaussian_filter(data, 5))
    plot.add_item(flt, z=1)
    plot.replot()
    win.show()
    win.exec_()
示例#48
0
def test1():
    """Adapted from guiqwt cross_section.py example"""
    from guiqwt.plot import ImageDialog
    from taurus.qt.qtgui.extra_guiqwt.builder import make
    from taurus.qt.qtgui.application import TaurusApplication
    app = TaurusApplication(cmd_line_parser=None)

    # define a taurus image
    #model1 = 'sys/tg_test/1/short_image_ro'
    #model1 = 'sys/tg_test/1/long64_image_ro'
    model1 = 'sys/tg_test/1/ulong_image_ro'
    taurusimage = make.image(taurusmodel=model1)
    #taurusrgbimage = make.rgbimage(taurusmodel= 'eval:array([[[ 222, 0, 0], [0, 222, 0]], [[0, 0, 222], [222, 222, 222]]])')
    #taurusxyimage= make.xyimage(taurusmodel= model1)
    #taurusxyimage.set_xy(numpy.arange(251)*10,numpy.arange(251)*100 )

    # define normal image (guiqwt standard)
    #data = numpy.random.rand(100,100)
    #image = make.image(data=data)

    # create a dialog with a plot and add the images
    win = ImageDialog(edit=False,
                      toolbar=True,
                      wintitle="Taurus Cross sections test",
                      options=dict(show_xsection=False, show_ysection=False))
    from taurus.qt.qtgui.extra_guiqwt.tools import TaurusImageChooserTool
    win.add_tool(TaurusImageChooserTool)
    plot = win.get_plot()
    plot.add_item(taurusimage)
    #    plot.add_item(taurusxyimage)
    #    plot.add_item(image)
    #    plot.add_item(taurusrgbimage)

    #    win.get_itemlist_panel().show()

    # IMPORTANT: connect the cross section plots to the taurusimage so that they are updated when the taurus data changes
    # taurusimage.dataChanged.connect(win.update_cross_sections)

    win.exec_()
示例#49
0
def data_view(data, ofa, data_title):
    win = ImageDialog(edit=True,
                      toolbar=True,
                      wintitle="DW viewer",
                      options=dict(show_contrast=False,
                                   xlabel='Channel',
                                   xunit='#',
                                   ylabel='time',
                                   show_xsection=True,
                                   show_ysection=True))
    #    win.add_tool(AnnotatedRectangleTool)
    #    win.add_tool(ReverseYAxisTool)

    #    win.add_tool(AnnotatedRectangleTool, title="Flag",
    #                 switch_to_default_tool=False,
    #                 handle_final_shape_cb=customize_shape)
    #  win.add_tool(VCursorTool)
    #   sst=win.add_tool(SignalStatsTool)
    #    SignalStatsTool.activate(sst)

    xcs = win.panels['x_cross_section']
    xcs.cs_plot.curveparam.curvestyle = 'Steps'
    xcs.cs_plot.perimage_mode = False
    ycs = win.panels['y_cross_section']
    ycs.cs_plot.curveparam.curvestyle = 'Steps'
    ycs.cs_plot.perimage_mode = False

    item_data = make.image(data, title=data_title)
    item_data.interpolate = (0, )

    item_ofa = make.image(ofa, title='Overflow')
    item_ofa.interpolate = (0, )
    item_ofa.imageparam.alpha_mask = True

    plot = win.get_plot()
    plot.add_item(item_data)
    plot.add_item(item_ofa)
    #    plot.add_item(itemFlag)
    win.show()
    if win.exec_():
        #        return plot.items
        return win
示例#50
0
def plotImage(x,
              y,
              z,
              wintitle="Contour Plot",
              options={
                  "lock_aspect_ratio": False,
                  "yreverse": False
              }):
    options.update(dict(show_xsection=True, show_ysection=True))
    """Test"""
    # -- Create QApplication
    _app = guidata.qapplication()
    # --
    win = ImageDialog(edit=True,
                      toolbar=True,
                      wintitle=wintitle,
                      options=options)
    win.resize(1500, 1000)
    item = make.xyimage(x, y, z, interpolation="linear")
    plot = win.get_plot()
    plot.add_item(item)
    win.plot_widget.xcsw_splitter.setSizes([400, 600])
    win.show()
    return win
示例#51
0
文件: image.py 项目: cmft/taurus
def test1():
    """Adapted from guiqwt cross_section.py example"""
    from guiqwt.plot import ImageDialog
    from taurus.qt.qtgui.extra_guiqwt.builder import make
    from taurus.qt.qtgui.application import TaurusApplication
    app = TaurusApplication()

    # define a taurus image
    #model1 = 'sys/tg_test/1/short_image_ro'
    #model1 = 'sys/tg_test/1/long64_image_ro'
    model1 = 'sys/tg_test/1/ulong_image_ro'
    taurusimage = make.image(taurusmodel=model1)
    #taurusrgbimage = make.rgbimage(taurusmodel= 'eval:array([[[ 222, 0, 0], [0, 222, 0]], [[0, 0, 222], [222, 222, 222]]])')
    #taurusxyimage= make.xyimage(taurusmodel= model1)
    #taurusxyimage.set_xy(numpy.arange(251)*10,numpy.arange(251)*100 )

    # define normal image (guiqwt standard)
    #data = numpy.random.rand(100,100)
    #image = make.image(data=data)

    # create a dialog with a plot and add the images
    win = ImageDialog(edit=False, toolbar=True, wintitle="Taurus Cross sections test",
                      options=dict(show_xsection=False, show_ysection=False))
    from taurus.qt.qtgui.extra_guiqwt.tools import TaurusImageChooserTool
    win.add_tool(TaurusImageChooserTool)
    plot = win.get_plot()
    plot.add_item(taurusimage)
#    plot.add_item(taurusxyimage)
#    plot.add_item(image)
#    plot.add_item(taurusrgbimage)

#    win.get_itemlist_panel().show()

    # IMPORTANT: connect the cross section plots to the taurusimage so that they are updated when the taurus data changes
    # taurusimage.dataChanged.connect(win.update_cross_sections)

    win.exec_()
示例#52
0
 def register_tools(self):
     ImageDialog.register_tools(self)
     self.add_tool(SegmentTool, handle_final_shape_cb=self.draw_seg)
     self.DrawPoint = PointTool
     self.add_tool(self.DrawPoint, handle_final_shape_cb=self.draw_point)
     self.add_tool(RectangleTool, handle_final_shape_cb=self.draw_rect)
示例#53
0
 def create_plot(self, options):
     ImageDialog.create_plot(self, options)
示例#54
0
def create_window():
    win = ImageDialog(edit=False, toolbar=True, wintitle="Cross sections test",
                      options=dict(show_xsection=True, show_ysection=True,
                                   show_itemlist=True))
    win.resize(800, 600)
    return win
示例#55
0
 def register_image_tools(self):
     ImageDialog.register_image_tools(self)
     for tool in (ObliqueCrossSectionTool, OCSPanelTool, ImageMaskTool):
         self.add_tool(tool)
示例#56
0
import os, os.path as osp, pickle

from guiqwt.plot import ImageDialog
from guiqwt.tools import ImageMaskTool
from guiqwt.builder import make

SHOW = True  # Show test in GUI-based test launcher

FNAME = "image_masked.pickle"

if __name__ == "__main__":
    import guidata

    _app = guidata.qapplication()
    win = ImageDialog(toolbar=True, wintitle="Masked image item test")
    win.add_tool(ImageMaskTool)
    if os.access(FNAME, os.R_OK):
        print("Restoring mask...", end=" ")
        iofile = open(FNAME, "rb")
        image = pickle.load(iofile)
        iofile.close()
        print("OK")
    else:
        fname = osp.join(osp.abspath(osp.dirname(__file__)), "brain.png")
        image = make.maskedimage(filename=fname, colormap="gray", show_mask=True, xdata=[0, 20], ydata=[0, 25])
    win.get_plot().add_item(image)
    win.show()
    win.exec_()
    iofile = open(FNAME, "wb")
    pickle.dump(image, iofile)