예제 #1
0
    def __init__(self, core, amsn_group):
        """
        @type core: L{amsn2.core.amsn.aMSNCore}
        @type amsn_group: L{amsn2.core.contactlist_manager.aMSNBaseGroup}
        """
        self.uid = amsn_group.id
        self.contact_ids = set(amsn_group.contacts)
        self.icon = ImageView()  # TODO: expanded/collapsed icon
        self.name = StringView()  # TODO: default color from skin/settings

        self.name.append_text(
            amsn_group.name.decode('utf-8'))  #TODO: parse for smileys
        active = len(amsn_group.contacts_online)

        #self.name.append_text(name) #TODO: parse for smileys
        #active = 0
        #for cid in contact_ids:
        #    contact = core._contactlist_manager.get_contact(cid)
        #    if str(contact.status) != core.p2s['FLN']:
        #        active = active + 1

        total = len(self.contact_ids)
        self.name.append_text("(" + str(active) + "/" + str(total) + ")")

        self.on_click = None  #TODO: collapse, expand
        self.on_double_click = None
        self.on_right_click_popup_menu = GroupPopupMenu(core, amsn_group)
        self.tooltip = None
        self.context_menu = None
예제 #2
0
 def create_widgets(self):
     # Source image frame.
     self.source_frame = tk.LabelFrame(self, text="Source image")
     self.source_frame.grid(column=0, row=0)
     self.source_image = ImageView(self.source_frame)
     self.source_image.pack()
     self.source_button = tk.Button(self.source_frame,
                                    text="Load image",
                                    command=self.load_source)
     self.source_button.pack()
     # Palette frame.
     self.pal_frame = tk.LabelFrame(self, text="Palette")
     self.pal_frame.grid(column=1, row=0)
     self.pal_widget = PaletteView(self.pal_frame)
     self.pal_widget.pack()
     self.pal_button = tk.Button(self.pal_frame,
                                 text="Load palette",
                                 command=self.load_palette)
     self.pal_button.pack()
     # Result frame.
     self.result_frame = tk.LabelFrame(self, text="Result")
     self.result_frame.grid(column=2, row=0)
     self.result_image = ImageView(self.result_frame)
     self.result_image.pack()
     self.result_button = tk.Button(self.result_frame,
                                    text="Generate",
                                    command=self.quantize)
     self.result_button.pack(side=tk.LEFT)
     self.save_button = tk.Button(self.result_frame,
                                  text="Save",
                                  command=self.save)
     self.save_button.pack()
     # Progress bar.
     self.progress = tk.IntVar()
     self.progress_bar = ttk.Progressbar(self, variable=self.progress)
     self.progress_bar.grid(column=0,
                            row=1,
                            columnspan=3,
                            sticky=tk.W + tk.E)
예제 #3
0
파일: gui.py 프로젝트: VanessaNav/3D_Cell
    def __init__(self):
        super().__init__()

        # Proyecto
        self.project = None

        # Título
        self.setWindowTitle("3D Cell Reconstruction")

        # Inicializa el menú
        self.initMenubar()

        # Visor de las imágenes (imagen y control van en el mismo layout)
        # NOTA: Es el objeto central del objeto QMainWindow, que tiene eso, una barra de estado, etc. Podemos volver al QWidget si es fuese mejor.
        self.imageViewer = QWidget(self)
        self.imageViewer.setLayout(QGridLayout())
        # Fija márgenes para centrar la imagen
        self.imageViewer.layout().setColumnStretch(0, 0)
        self.imageViewer.layout().setColumnStretch(2, 0)
        self.imageViewer.layout().setRowStretch(1, 0)
        self.imageViewer.layout().setRowStretch(3, 0)
        # Crea un campo de texto para mostrar el nombre de la imagen
        self.imageName = QLineEdit("No project loaded")
        self.imageName.setReadOnly(True)
        self.imageViewer.layout().addWidget(self.imageName, 0, 1)
        # Crea un objeto de la clase ImageView para mostrar la imagen y dibujar
        self.imageView = ImageView()
        self.imageViewer.layout().addWidget(self.imageView, 2, 1)
        # Inicializa los botones de control
        self.initControlLayout()
        self.imageViewer.layout().addLayout(self.control_layout, 3, 0, 1, 3)
        # Lo situa como objeto pricipal de la aplicación.
        self.setCentralWidget(self.imageViewer)

        # NOTA: Como inicialmente no hay proyecto abierto, deshabilita los botones.
        self.enableControls(False)
예제 #4
0
    def __init__(self, core, email):
        """
        @type core: L{amsn2.core.amsn.aMSNCore}
        @type email: str
        """
        self._core = core
        self.email = email
        self.password = None
        self.nick = StringView()
        self.psm = StringView()
        self.presence = core.Presence.ONLINE
        self.dp = ImageView()

        self.save = False
        self.save_password = False
        self.autologin = False

        self.preferred_ui = None
        self.preferred_backend = 'defaultbackend'
예제 #5
0
    def _block_new(self, block_type=PARAGRAPH):
        #print("_block_new:")
        if block_type == SubdocView.PARAGRAPH:
            buf = EditorTextBuffer()
            widget = EditorTextView(self.elements_toolbar, self.notebook_app)
            widget.set_buffer(buf)
            self.add(widget)
        elif block_type == SubdocView.IMAGE:
            #print("Image insertion asked")
            widget = ImageView()
            self.add(widget)
            model = ImageModel()
            widget.set_model(model)
        else:
            raise NotImplementedError

        widget.connect("focus-in-event", self.on_child_focus_in)
        widget.connect("cursor-move", self.on_child_cursor_move)

        #self.add(widget)

        return widget
예제 #6
0
class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.winfo_toplevel().title("Color Quantizer")
        self.pack()
        self.create_widgets()
        self.update_buttons()

    def create_widgets(self):
        # Source image frame.
        self.source_frame = tk.LabelFrame(self, text="Source image")
        self.source_frame.grid(column=0, row=0)
        self.source_image = ImageView(self.source_frame)
        self.source_image.pack()
        self.source_button = tk.Button(self.source_frame,
                                       text="Load image",
                                       command=self.load_source)
        self.source_button.pack()
        # Palette frame.
        self.pal_frame = tk.LabelFrame(self, text="Palette")
        self.pal_frame.grid(column=1, row=0)
        self.pal_widget = PaletteView(self.pal_frame)
        self.pal_widget.pack()
        self.pal_button = tk.Button(self.pal_frame,
                                    text="Load palette",
                                    command=self.load_palette)
        self.pal_button.pack()
        # Result frame.
        self.result_frame = tk.LabelFrame(self, text="Result")
        self.result_frame.grid(column=2, row=0)
        self.result_image = ImageView(self.result_frame)
        self.result_image.pack()
        self.result_button = tk.Button(self.result_frame,
                                       text="Generate",
                                       command=self.quantize)
        self.result_button.pack(side=tk.LEFT)
        self.save_button = tk.Button(self.result_frame,
                                     text="Save",
                                     command=self.save)
        self.save_button.pack()
        # Progress bar.
        self.progress = tk.IntVar()
        self.progress_bar = ttk.Progressbar(self, variable=self.progress)
        self.progress_bar.grid(column=0,
                               row=1,
                               columnspan=3,
                               sticky=tk.W + tk.E)

    def load_palette(self):
        filename = tk.filedialog.askopenfilename(defaultextension=".pal",
                                                 title="Load a palette",
                                                 filetypes=[
                                                     ("JASC Palette File",
                                                      "*.pal")
                                                 ])
        if not filename:
            return
        if not self.pal_widget.load(filename):
            tk.messagebox.showerror("Error",
                                    filename + " is not a valid palette file.")
        self.update_buttons()

    def load_source(self):
        filename = tk.filedialog.askopenfilename(
            title="Load an image",
            filetypes=[("Portable Network Graphics", "*.png"),
                       ("Graphics Interchange Format", "*.gif"),
                       ("All files", "*.*")])
        if not filename:
            return
        if not self.source_image.load(filename):
            tk.messagebox.showerror("Error",
                                    filename + " is not a valid image file.")
        self.update_buttons()

    def quantize(self):
        self.thread = threading.Thread(
            None,
            quantizer.quantize,
            "QuantizeThread",
            (self.source_image.image_get(), self.pal_widget.palette),
            daemon=True)
        self.thread.start()
        self.result_button["state"] = tk.DISABLED
        self.source_button["state"] = tk.DISABLED
        self.wait_thread()

    def quantize_completed(self):
        result = quantizer.get_result()
        w = self.source_image.image_get().width()
        h = self.source_image.image_get().height()
        self.result_image.image_from_array(w, h, result)
        self.progress.set(0)
        self.update_buttons()
        self.source_button["state"] = tk.ACTIVE

    def quantize_allowed(self):
        """ Returns True if we have an image and palette. """
        return self.source_image.image_get(
        ) != None and self.pal_widget.palette != None

    def save(self):
        filename = tk.filedialog.asksaveasfilename(
            title="Save",
            filetypes=[("Portable Network Graphics", "*.png"),
                       ("Graphics Interchange Format", "*.gif"),
                       ("All files", "*.*")])
        if not filename:
            return
        self.result_image.image_get().write(filename)

    def update_buttons(self):
        """ Enable or disable buttons based on application state. """
        self.result_button["state"] = tk.ACTIVE if self.quantize_allowed(
        ) else tk.DISABLED
        self.save_button["state"] = tk.ACTIVE if self.result_image.image_get(
        ) else tk.DISABLED

    def wait_thread(self):
        if self.thread.is_alive():
            # Update progress.
            self.progress.set(quantizer.get_progress())
            # Wait and check again.
            self.after(250, self.wait_thread)
        else:
            self.quantize_completed()
예제 #7
0
class AD_Display(wx.Frame):
    """AreaDetector Display """
    img_attrs = ('ArrayData', 'UniqueId_RBV', 'NDimensions_RBV',
                 'ArraySize0_RBV', 'ArraySize1_RBV', 'ArraySize2_RBV',
                 'ColorMode_RBV')

    cam_attrs = ('Acquire', 'ArrayCounter', 'ArrayCounter_RBV',
                 'DetectorState_RBV', 'NumImages', 'ColorMode', 'DataType_RBV',
                 'Gain', 'AcquireTime', 'AcquirePeriod', 'ImageMode',
                 'MaxSizeX_RBV', 'MaxSizeY_RBV', 'TriggerMode', 'SizeX',
                 'SizeY', 'MinX', 'MinY')

    # plugins to enable
    enabled_plugins = ('image1', 'Over1', 'ROI1', 'JPEG1', 'TIFF1')

    stat_msg = 'Read %.1f%% of images: rate=%.1f frames/sec'

    def __init__(self,
                 prefix=None,
                 app=None,
                 scale=1.0,
                 approx_height=1200,
                 known_cameras=None):
        self.app = app
        self.ad_img = None
        self.ad_cam = None
        self.imgcount = 0
        self.prefix = prefix
        self.fname = 'AD_Image.tiff'
        self.scale = scale
        self.known_cameras = known_cameras
        self.arrsize = [0, 0, 0]
        self.imbuff = None
        self.d_size = None
        self.im_size = None
        self.colormode = 0
        self.last_update = 0.0
        self.n_img = 0
        self.imgcount_start = 0
        self.n_drawn = 0
        self.img_id = 0
        self.starttime = time.time()
        self.drawing = False
        self.lineplotter = None
        self.zoom_lims = []

        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Epics Area Detector Display",
                          style=wx.DEFAULT_FRAME_STYLE)

        if known_cameras is not None:
            self.ConnectToCamera(name=self.prefix)
        else:
            self.ConnectToPV(name=self.prefix)

        self.img_w = 0
        self.img_h = 0
        self.wximage = wx.EmptyImage(
            1024, 1360)  # 1360, 1024) # approx_height, 1.5*approx_height)
        self.buildMenus()
        self.buildFrame()

    def OnLeftUp(self, event):
        if self.image is not None:
            self.image.OnLeftUp(event)

    def ConnectToCamera(self, name=None, event=None):
        if name is None:
            name = ''
        if self.known_cameras is None:
            return
        cam_names = self.known_cameras.keys()
        cam_names.sort()
        dlg = wx.SingleChoiceDialog(self,
                                    'Select Camera',
                                    caption='Select Camera',
                                    choices=cam_names)
        dlg.Raise()
        if dlg.ShowModal() == wx.ID_OK:
            cname = dlg.GetStringSelection()
            if cname in self.known_cameras:
                self.prefix = self.known_cameras[cname]
            wx.CallAfter(self.connect_pvs)
        dlg.Destroy()

    def ConnectToPV(self, event=None, name=None):
        print 'Connect To PV ', name, event
        if name is None:
            name = ''
        dlg = wx.TextEntryDialog(self,
                                 'Enter PV for Area Detector',
                                 caption='Enter PV for Area Detector',
                                 defaultValue=name)
        dlg.Raise()
        if dlg.ShowModal() == wx.ID_OK:
            self.prefix = dlg.GetValue()
            wx.CallAfter(self.connect_pvs)
        dlg.Destroy()

    def onCopyImage(self, event=None):
        "copy bitmap of canvas to system clipboard"
        bmp = wx.BitmapDataObject()
        bmp.SetBitmap(wx.BitmapFromImage(self.wximage))
        wx.TheClipboard.Open()
        wx.TheClipboard.SetData(bmp)
        wx.TheClipboard.Close()
        wx.TheClipboard.Flush()

    @EpicsFunction
    def CameraOff(self):
        try:
            self.ad_cam.Acquire = 0
        except:
            pass

    @EpicsFunction
    def onSaveImage(self, event=None):
        "prompts for and save image to file"
        defdir = os.getcwd()
        self.fname = "Image_%i.tiff" % self.ad_cam.ArrayCounter_RBV
        dlg = wx.FileDialog(None,
                            message='Save Image as',
                            defaultDir=os.getcwd(),
                            defaultFile=self.fname,
                            style=wx.SAVE)
        path = None
        if dlg.ShowModal() == wx.ID_OK:
            path = os.path.abspath(dlg.GetPath())

        dlg.Destroy()
        if path is not None and self.data is not None:
            Image.frombuffer(self.im_mode, self.im_size, self.data.flatten(),
                             'raw', self.im_mode, 0, 1).save(path)

    def onExit(self, event=None):
        try:
            wx.Yield()
        except:
            pass
        self.CameraOff()
        self.Destroy()

    def onAbout(self, event=None):
        msg = """Epics Image Display version 0.2

http://pyepics.github.com/epicsapps/

Matt Newville <*****@*****.**>"""

        dlg = wx.MessageDialog(self, msg, "About Epics Image Display",
                               wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()

    def buildMenus(self):
        fmenu = wx.Menu()
        add_menu(self, fmenu, "&Connect to Pre-defiend Camera",
                 "Connect to PV", self.ConnectToCamera)
        add_menu(self, fmenu, "&Connect to AreaDetector PV\tCtrl+O",
                 "Connect to PV", self.ConnectToPV)
        add_menu(self, fmenu, "&Save\tCtrl+S", "Save Image", self.onSaveImage)
        add_menu(self, fmenu, "&Copy\tCtrl+C", "Copy Image to Clipboard",
                 self.onCopyImage)
        fmenu.AppendSeparator()
        add_menu(self, fmenu, "E&xit\tCtrl+Q", "Exit Program", self.onExit)

        omenu = wx.Menu()
        add_menu(self, omenu, "&Zoom out\tCtrl+Z", "Zoom Out", self.unZoom)
        add_menu(self, omenu, "Reset Image Counter", "Set Image Counter to 0",
                 self.onResetImageCounter)
        omenu.AppendSeparator()
        add_menu(self, omenu, "&Rotate Clockwise\tCtrl+R", "Rotate Clockwise",
                 self.onRotCW)
        add_menu(self, omenu, "Rotate CounterClockwise",
                 "Rotate Counter Clockwise", self.onRotCCW)
        add_menu(self, omenu, "Flip Up/Down\tCtrl+T", "Flip Up/Down",
                 self.onFlipV)
        add_menu(self, omenu, "Flip Left/Right\tCtrl+F", "Flip Left/Right",
                 self.onFlipH)
        omenu.AppendSeparator()

        self.CM_ZOOM = wx.NewId()
        self.CM_SHOW = wx.NewId()
        self.CM_PROF = wx.NewId()
        omenu.Append(self.CM_ZOOM, "Cursor Mode: Zoom to Box\tCtrl+B",
                     "Zoom to box by clicking and dragging", wx.ITEM_RADIO)
        omenu.Append(self.CM_SHOW, "Cursor Mode: Show X,Y\tCtrl+X",
                     "Show X,Y, Intensity Values", wx.ITEM_RADIO)
        omenu.Append(self.CM_PROF, "Cursor Mode: Line Profile\tCtrl+L",
                     "Show Line Profile", wx.ITEM_RADIO)
        self.Bind(wx.EVT_MENU, self.onCursorMode, id=self.CM_ZOOM)
        self.Bind(wx.EVT_MENU, self.onCursorMode, id=self.CM_PROF)
        self.Bind(wx.EVT_MENU, self.onCursorMode, id=self.CM_SHOW)

        hmenu = wx.Menu()
        add_menu(self, hmenu, "About", "About Epics AreadDetector Display",
                 self.onAbout)

        mbar = wx.MenuBar()
        mbar.Append(fmenu, "File")
        mbar.Append(omenu, "Options")
        mbar.Append(hmenu, "&Help")
        self.SetMenuBar(mbar)

    def onCursorMode(self, event=None):
        if event.Id == self.CM_ZOOM:
            self.image.cursor_mode = 'zoom'
        elif event.Id == self.CM_PROF:
            self.image.cursor_mode = 'profile'
        elif event.Id == self.CM_SHOW:
            self.image.cursor_mode = 'show'

    @DelayedEpicsCallback
    def onResetImageCounter(self, event=None):
        self.ad_cam.ArrayCounter = 0

    def onRotCW(self, event):
        self.image.rot90 = (self.image.rot90 + 1) % 4
        self.image.Refresh()

    def onRotCCW(self, event):
        self.image.rot90 = (self.image.rot90 - 1) % 4
        self.image.Refresh()

    def onFlipV(self, event):
        self.image.flipv = not self.image.flipv
        self.image.Refresh()

    def onFlipH(self, event):
        self.image.fliph = not self.image.fliph
        self.image.Refresh()

    def buildFrame(self):
        sbar = self.CreateStatusBar(3, wx.CAPTION | wx.THICK_FRAME)
        sfont = sbar.GetFont()
        sfont.SetWeight(wx.BOLD)
        sfont.SetPointSize(10)
        sbar.SetFont(sfont)

        self.SetStatusWidths([-3, -1, -1])
        self.SetStatusText('', 0)

        sizer = wx.GridBagSizer(10, 4)
        panel = wx.Panel(self)
        self.panel = panel
        labstyle = wx.ALIGN_LEFT | wx.ALIGN_BOTTOM | wx.EXPAND
        ctrlstyle = wx.ALIGN_LEFT | wx.ALIGN_BOTTOM

        rlabstyle = wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP | wx.EXPAND

        txtstyle = wx.ALIGN_LEFT | wx.ST_NO_AUTORESIZE | wx.TE_PROCESS_ENTER
        self.wids = {}
        self.wids['exptime'] = PVFloatCtrl(panel, pv=None, size=(100, -1))
        self.wids['period'] = PVFloatCtrl(panel, pv=None, size=(100, -1))
        self.wids['numimages'] = PVFloatCtrl(panel, pv=None, size=(100, -1))
        self.wids['gain'] = PVFloatCtrl(panel,
                                        pv=None,
                                        size=(100, -1),
                                        minval=0,
                                        maxval=20)

        self.wids['imagemode'] = PVEnumChoice(panel, pv=None, size=(100, -1))
        self.wids['triggermode'] = PVEnumChoice(panel, pv=None, size=(100, -1))
        self.wids['color'] = PVEnumChoice(panel, pv=None, size=(100, -1))
        self.wids['start'] = wx.Button(panel, -1, label='Start', size=(50, -1))
        self.wids['stop'] = wx.Button(panel, -1, label='Stop', size=(50, -1))

        if HAS_OVERLAY_DEVICE:
            self.wids['o1color'] = csel.ColourSelect(panel,
                                                     -1,
                                                     "",
                                                     '#FEFEFE',
                                                     size=(60, 25))
            self.wids['o1color'].Bind(csel.EVT_COLOURSELECT,
                                      Closure(self.onColor, item=1))
            self.wids['o1posx'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o1posy'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o1sizx'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o1sizy'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o1shape'] = PVEnumChoice(panel, pv=None, size=(100, -1))
            self.wids['o1use'] = PVEnumChoice(panel, pv=None, size=(50, -1))
            self.wids['o1name'] = PVTextCtrl(panel, pv=None, size=(100, -1))

            self.wids['o2color'] = csel.ColourSelect(panel,
                                                     -1,
                                                     "",
                                                     '#FEFEFE',
                                                     size=(60, 25))
            self.wids['o2color'].Bind(csel.EVT_COLOURSELECT,
                                      Closure(self.onColor, item=2))
            self.wids['o2posx'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o2posy'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o2sizx'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o2sizy'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o2shape'] = PVEnumChoice(panel, pv=None, size=(100, -1))
            self.wids['o2use'] = PVEnumChoice(panel, pv=None, size=(50, -1))
            self.wids['o2name'] = PVTextCtrl(panel, pv=None, size=(100, -1))

        for key in ('start', 'stop'):
            self.wids[key].Bind(wx.EVT_BUTTON, Closure(self.onEntry, key=key))

        self.wids['zoomsize'] = wx.StaticText(panel,
                                              -1,
                                              size=(250, -1),
                                              style=txtstyle)
        self.wids['fullsize'] = wx.StaticText(panel,
                                              -1,
                                              size=(250, -1),
                                              style=txtstyle)

        def txt(label, size=100):
            return wx.StaticText(panel,
                                 label=label,
                                 size=(size, -1),
                                 style=labstyle)

        def lin(len=30, wid=2, style=wx.LI_HORIZONTAL):
            return wx.StaticLine(panel, size=(len, wid), style=style)

        sizer.Add(txt(' '), (0, 0), (1, 1), labstyle)
        sizer.Add(txt('Image Mode '), (1, 0), (1, 1), labstyle)
        sizer.Add(self.wids['imagemode'], (1, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('# Images '), (2, 0), (1, 1), labstyle)
        sizer.Add(self.wids['numimages'], (2, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Trigger Mode '), (3, 0), (1, 1), labstyle)
        sizer.Add(self.wids['triggermode'], (3, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Period '), (4, 0), (1, 1), labstyle)
        sizer.Add(self.wids['period'], (4, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Exposure Time '), (5, 0), (1, 1), labstyle)
        sizer.Add(self.wids['exptime'], (5, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Gain '), (6, 0), (1, 1), labstyle)
        sizer.Add(self.wids['gain'], (6, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Color Mode'), (7, 0), (1, 1), labstyle)
        sizer.Add(self.wids['color'], (7, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Acquire '), (9, 0), (1, 1), labstyle)

        sizer.Add(self.wids['start'], (9, 1), (1, 1), ctrlstyle)
        sizer.Add(self.wids['stop'], (9, 2), (1, 1), ctrlstyle)

        sizer.Add(self.wids['fullsize'], (12, 0), (1, 3), labstyle)
        sizer.Add(self.wids['zoomsize'], (13, 0), (1, 3), labstyle)

        sizer.Add(lin(75), (15, 0), (1, 3), labstyle)

        if HAS_OVERLAY_DEVICE:
            ir = 16
            sizer.Add(txt('Overlay 1:'), (ir + 0, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1use'], (ir + 0, 1), (1, 2), ctrlstyle)
            sizer.Add(txt('Shape:'), (ir + 1, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1shape'], (ir + 1, 1), (1, 2), ctrlstyle)
            sizer.Add(txt('Name:'), (ir + 2, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1name'], (ir + 2, 1), (1, 2), ctrlstyle)

            sizer.Add(txt('Position '), (ir + 3, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1posx'], (ir + 3, 1), (1, 1), ctrlstyle)
            sizer.Add(self.wids['o1posy'], (ir + 3, 2), (1, 1), ctrlstyle)
            sizer.Add(txt('Size '), (ir + 4, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1sizx'], (ir + 4, 1), (1, 1), ctrlstyle)
            sizer.Add(self.wids['o1sizy'], (ir + 4, 2), (1, 1), ctrlstyle)
            sizer.Add(txt('Color '), (ir + 5, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1color'], (ir + 5, 1), (1, 2), ctrlstyle)
            sizer.Add(lin(75), (ir + 6, 0), (1, 3), labstyle)

            ir = ir + 7
            sizer.Add(txt('Overlay 1:'), (ir + 0, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2use'], (ir + 0, 1), (1, 2), ctrlstyle)
            sizer.Add(txt('Shape:'), (ir + 1, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2shape'], (ir + 1, 1), (1, 2), ctrlstyle)
            sizer.Add(txt('Name:'), (ir + 2, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2name'], (ir + 2, 1), (1, 2), ctrlstyle)

            sizer.Add(txt('Position '), (ir + 3, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2posx'], (ir + 3, 1), (1, 1), ctrlstyle)
            sizer.Add(self.wids['o2posy'], (ir + 3, 2), (1, 1), ctrlstyle)
            sizer.Add(txt('Size '), (ir + 4, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2sizx'], (ir + 4, 1), (1, 1), ctrlstyle)
            sizer.Add(self.wids['o2sizy'], (ir + 4, 2), (1, 1), ctrlstyle)
            sizer.Add(txt('Color '), (ir + 5, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2color'], (ir + 5, 1), (1, 2), ctrlstyle)
            sizer.Add(lin(75), (ir + 6, 0), (1, 3), labstyle)

        self.image = ImageView(self,
                               size=(1360, 1024),
                               onzoom=self.onZoom,
                               onprofile=self.onProfile,
                               onshow=self.onShowXY)

        panel.SetSizer(sizer)
        sizer.Fit(panel)

        mainsizer = wx.BoxSizer(wx.HORIZONTAL)
        mainsizer.Add(panel, 0, wx.LEFT | wx.GROW | wx.ALL, 5)
        mainsizer.Add(self.image, 1, wx.CENTER | wx.GROW | wx.ALL, 5)
        self.SetSizer(mainsizer)
        mainsizer.Fit(self)

        self.SetAutoLayout(True)

        try:
            self.SetIcon(wx.Icon(ICON_FILE, wx.BITMAP_TYPE_ICO))
        except:
            pass

        self.RefreshImage()
        wx.CallAfter(self.connect_pvs)

    def messag(self, s, panel=0):
        """write a message to the Status Bar"""
        wx.CallAfter(Closure(self.SetStatusText, text=s, number=panel))
        # self.SetStatusText(s, panel)

    @EpicsFunction
    def unZoom(self, event=None, full=False):
        if self.zoom_lims is None or full:
            self.zoom_lims = []

        if len(self.zoom_lims) == 0:
            xmin, ymin = 0, 0
            width = self.ad_cam.MaxSizeX_RBV
            height = self.ad_cam.MaxSizeY_RBV
            self.zoom_lims = []
        else:
            xmin, ymin, width, height = self.zoom_lims.pop()
            if (self.ad_cam.MinX == xmin and self.ad_cam.MinY == ymin
                    and self.ad_cam.SizeX == width
                    and self.ad_cam.SizeY == height):
                try:
                    xmin, ymin, width, height = self.zoom_lims.pop()
                except:
                    xmin, ymin = 0, 0
                    width = self.ad_cam.MaxSizeX_RBV
                    height = self.ad_cam.MaxSizeY_RBV

        self.ad_cam.MinX = xmin
        self.ad_cam.MinY = ymin
        self.ad_cam.SizeX = width
        self.ad_cam.SizeY = height
        self.zoom_lims.append((xmin, ymin, width, height))
        time.sleep(0.05)
        self.showZoomsize()
        if self.ad_cam.Acquire == 0 and self.im_size is not None:
            self.img_w = width
            self.img_h = height
            try:
                if self.colormode == 2:
                    self.data.shape = [self.im_size[1], self.im_size[0], 3]
                    zdata = self.data[ymin:ymin + height, xmin:xmin + width, :]
                else:
                    self.data.shape = self.im_size[1], self.im_size[0]
                    zdata = self.data[ymin:ymin + height, xmin:xmin + width]
            except ValueError:
                pass
            self.data = zdata  #self.data.flatten()
            self.im_size = (width, height)
            # print zdata.shape, width, height, self.im_mode
            self.DatatoImage()  # zdata, (width, height), self.im_mode)

        self.RefreshImage()
        self.image.Refresh()

    @EpicsFunction
    def onColor(self, event=None, item=None):
        if HAS_OVERLAY_DEVICE:
            color = event.GetValue()
            over = self.ad_overlays[item - 1]
            over.Red = color[0]
            over.Green = color[1]
            over.Blue = color[2]

    @EpicsFunction
    def showZoomsize(self):
        try:
            msg = 'Showing:  %i x %i pixels' % (self.ad_cam.SizeX,
                                                self.ad_cam.SizeY)
            self.wids['zoomsize'].SetLabel(msg)
        except:
            pass

    @EpicsFunction
    def onZoom(self, x0, y0, x1, y1):
        width = self.ad_cam.SizeX
        height = self.ad_cam.SizeY
        xmin = max(0, int(self.ad_cam.MinX + x0 * width))
        ymin = max(0, int(self.ad_cam.MinY + y0 * height))

        width = int(x1 * width)
        height = int(y1 * height)
        if width < 2 or height < 2:
            return
        self.ad_cam.MinX = xmin
        self.ad_cam.MinY = ymin
        self.ad_cam.SizeX = width
        self.ad_cam.SizeY = height
        if self.zoom_lims is None:
            self.zoom_lims = []
        self.zoom_lims.append((xmin, ymin, width, height))

        time.sleep(0.05)
        self.showZoomsize()

        if self.ad_cam.Acquire == 0:
            self.img_w = width
            self.img_h = height
            if self.colormode == 2:
                self.data.shape = [self.im_size[1], self.im_size[0], 3]
                zdata = self.data[ymin:ymin + height, xmin:xmin + width, :]
            else:
                self.data.shape = self.im_size[1], self.im_size[0]
                zdata = self.data[ymin:ymin + height, xmin:xmin + width]
            self.data = zdata  #. flatten()
            self.im_size = (width, height)
            self.DatatoImage()
        self.image.Refresh()

    def DatatoImage(self):  #,  data, size, mode):
        """convert raw data to image"""
        #x = debugtime()

        width, height = self.im_size
        d_size = (int(width * self.scale), int(height * self.scale))
        data = self.data.flatten()
        #x.add('flatten')
        if self.imbuff is None or d_size != self.d_size or self.im_mode == 'L':
            try:
                self.imbuff = Image.frombuffer(self.im_mode, self.im_size,
                                               data, 'raw', self.im_mode, 0, 1)
                #x.add('made image')
            except:
                return
        self.d_size = d_size = (int(width * self.scale),
                                int(height * self.scale))
        if self.imbuff.size != d_size:
            self.imbuff = self.imbuff.resize(d_size)
            #x.add('resized imbuff')

        if self.wximage.GetSize() != self.imbuff.size:
            self.wximage = wx.EmptyImage(d_size[0], d_size[1])
        #x.add('created wximage %s  ' % (repr(self.wximage.GetSize())))
        if self.im_mode == 'L':
            self.wximage.SetData(self.imbuff.convert('RGB').tostring())
        elif self.im_mode == 'RGB':
            data.shape = (3, width, height)
            self.wximage = wx.ImageFromData(width, height, data)
        #x.add('set wx image wximage : %i, %i ' % d_size)
        self.image.SetValue(self.wximage)
        #x.add('set image value')
        #x.show()

    def onProfile(self, x0, y0, x1, y1):
        width = self.ad_cam.SizeX
        height = self.ad_cam.SizeY

        x0, y0 = int(x0 * width), int(y0 * height)
        x1, y1 = int(x1 * width), int(y1 * height)
        dx, dy = abs(x1 - x0), abs(y1 - y0)

        if dx < 2 and dy < 2:
            return
        outdat = []
        if self.colormode == 2:
            self.data.shape = (self.im_size[1], self.im_size[0], 3)
        else:
            self.data.shape = self.im_size[1], self.im_size[0]

        if dy > dx:
            _y0 = min(int(y0), int(y1 + 0.5))
            _y1 = max(int(y0), int(y1 + 0.5))

            for iy in range(_y0, _y1):
                ix = int(x0 + (iy - int(y0)) * (x1 - x0) / (y1 - y0))
                outdat.append((ix, iy))
        else:
            _x0 = min(int(x0), int(x1 + 0.5))
            _x1 = max(int(x0), int(x1 + 0.5))
            for ix in range(_x0, _x1):
                iy = int(y0 + (ix - int(x0)) * (y1 - y0) / (x1 - x0))
                outdat.append((ix, iy))

        if self.lineplotter is None:
            self.lineplotter = PlotFrame(self, title='Image Profile')
        else:
            try:
                self.lineplotter.Raise()
            except PyDeadObjectError:
                self.lineplotter = PlotFrame(self, title='Image Profile')

        if self.colormode == 2:
            x, y, r, g, b = [], [], [], [], []
            for ix, iy in outdat:
                x.append(ix)
                y.append(iy)
                r.append(self.data[iy, ix, 0])
                g.append(self.data[iy, ix, 1])
                b.append(self.data[iy, ix, 2])
            xlabel = 'Pixel (x)'
            if dy > dx:
                x = y
                xlabel = 'Pixel (y)'
            self.lineplotter.plot(x,
                                  r,
                                  color='red',
                                  label='red',
                                  xlabel=xlabel,
                                  ylabel='Intensity',
                                  title='Image %i' %
                                  self.ad_cam.ArrayCounter_RBV)
            self.lineplotter.oplot(x, g, color='green', label='green')
            self.lineplotter.oplot(x, b, color='blue', label='blue')

        else:
            x, y, z = [], [], []
            for ix, iy in outdat:
                x.append(ix)
                y.append(iy)
                z.append(self.data[iy, ix])
            xlabel = 'Pixel (x)'
            if dy > dx:
                x = y
            xlabel = 'Pixel (y)'
            self.lineplotter.plot(x,
                                  z,
                                  color='k',
                                  xlabel=xlabel,
                                  ylabel='Intensity',
                                  title='Image %i' %
                                  self.ad_cam.ArrayCounter_RBV)
        self.lineplotter.Show()
        self.lineplotter.Raise()

    def onShowXY(self, xval, yval):
        ix = max(0, int(xval * self.ad_cam.SizeX))
        iy = max(0, int(yval * self.ad_cam.SizeY))

        if self.colormode == 2:
            self.data.shape = (self.im_size[1], self.im_size[0], 3)
            ival = tuple(self.data[iy, ix, :])
            smsg = 'Pixel %i, %i, (R, G, B) = %s' % (ix, iy, repr(ival))
        else:
            self.data.shape = self.im_size[1], self.im_size[0]
            ival = self.data[iy, ix]
            smsg = 'Pixel %i, %i, Intensity = %i' % (ix, iy, ival)

        self.messag(smsg, panel=1)

    def onName(self, evt=None, **kws):
        if evt is None:
            return
        s = evt.GetString()
        s = str(s).strip()
        if s.endswith(':image1:'): s = s[:-8]
        if s.endswith(':cam1:'): s = s[:-6]
        if s.endswith(':'): s = s[:-1]
        self.prefix = s
        self.connect_pvs()

    @EpicsFunction
    def onEntry(self, evt=None, key='name', **kw):
        if evt is None:
            return
        if key == 'start':
            self.n_img = 0
            self.n_drawn = 0
            self.starttime = time.time()
            self.imgcount_start = self.ad_cam.ArrayCounter_RBV
            self.ad_cam.Acquire = 1
        elif key == 'stop':
            self.ad_cam.Acquire = 0
        elif key == 'unzoom':
            self.unZoom()
        else:
            print 'unknown Entry ? ', key

    @EpicsFunction
    def connect_pvs(self, verbose=True):
        if self.prefix is None or len(self.prefix) < 2:
            return

        try:
            self.ad_cam.Acquire = 0
        except:
            pass

        if self.prefix.endswith(':'):
            self.prefix = self.prefix[:-1]
        if self.prefix.endswith(':image1'):
            self.prefix = self.prefix[:-7]
        if self.prefix.endswith(':cam1'):
            self.prefix = self.prefix[:-5]

        if verbose:
            self.messag('Connecting to AD %s' % self.prefix)
        self.ad_img = epics.Device(self.prefix + ':image1:',
                                   delim='',
                                   attrs=self.img_attrs)
        self.ad_cam = epics.Device(self.prefix + ':cam1:',
                                   delim='',
                                   attrs=self.cam_attrs)
        self.ad_overlays = []
        if HAS_OVERLAY_DEVICE:
            for ix in (1, 2):
                pvn = '%s:Over1:%i:' % (self.prefix, ix)
                self.ad_overlays.append(AD_OverlayPlugin(pvn))

        time.sleep(0.010)
        if not self.ad_img.PV('UniqueId_RBV').connected:
            epics.poll()
            if not self.ad_img.PV('UniqueId_RBV').connected:
                self.messag('Warning:  Camera seems to not be connected!')
                return
        if verbose:
            self.messag('Connected to AD %s' % self.prefix)

        self.SetTitle("Epics Image Display: %s" % self.prefix)

        self.wids['color'].SetPV(self.ad_cam.PV('ColorMode'))
        self.wids['exptime'].SetPV(self.ad_cam.PV('AcquireTime'))
        self.wids['period'].SetPV(self.ad_cam.PV('AcquirePeriod'))
        self.wids['gain'].SetPV(self.ad_cam.PV('Gain'))
        self.wids['numimages'].SetPV(self.ad_cam.PV('NumImages'))
        self.wids['imagemode'].SetPV(self.ad_cam.PV('ImageMode'))
        self.wids['triggermode'].SetPV(self.ad_cam.PV('TriggerMode'))

        sizex = self.ad_cam.MaxSizeX_RBV
        sizey = self.ad_cam.MaxSizeY_RBV

        if HAS_OVERLAY_DEVICE:
            over = self.ad_overlays[0]
            c1 = (over.Red, over.Green, over.Blue)
            self.wids['o1color'].SetColour(hexcolor(c1))
            self.wids['o1posx'].SetPV(over.PV('PositionX'))
            self.wids['o1posx'].SetMax(sizex)
            self.wids['o1posy'].SetPV(over.PV('PositionY'))
            self.wids['o1posy'].SetMax(sizey)
            self.wids['o1sizx'].SetPV(over.PV('SizeX'))
            self.wids['o1sizx'].SetMax(sizex)
            self.wids['o1sizy'].SetPV(over.PV('SizeY'))
            self.wids['o1sizy'].SetMax(sizey)
            self.wids['o1shape'].SetPV(over.PV('Shape'))
            self.wids['o1name'].SetPV(over.PV('Name'))
            self.wids['o1use'].SetPV(over.PV('Use'))

            over = self.ad_overlays[1]
            c1 = (over.Red, over.Green, over.Blue)
            self.wids['o2color'].SetColour(hexcolor(c1))
            self.wids['o2posx'].SetPV(over.PV('PositionX'))
            self.wids['o2posx'].SetMax(sizex)
            self.wids['o2posy'].SetPV(over.PV('PositionY'))
            self.wids['o2posy'].SetMax(sizey)
            self.wids['o2sizx'].SetPV(over.PV('SizeX'))
            self.wids['o2sizx'].SetMax(sizex)
            self.wids['o2sizy'].SetPV(over.PV('SizeY'))
            self.wids['o2sizy'].SetMax(sizey)
            self.wids['o2shape'].SetPV(over.PV('Shape'))
            self.wids['o2name'].SetPV(over.PV('Name'))
            self.wids['o2use'].SetPV(over.PV('Use'))

        sizelabel = 'Image Size: %i x %i pixels'
        try:
            sizelabel = sizelabel % (sizex, sizey)
        except:
            sizelabel = sizelabel % (0, 0)

        self.wids['fullsize'].SetLabel(sizelabel)
        self.showZoomsize()

        self.ad_img.add_callback('ArrayCounter_RBV', self.onNewImage)
        self.ad_img.add_callback('ArraySize0_RBV', self.onProperty, dim=0)
        self.ad_img.add_callback('ArraySize1_RBV', self.onProperty, dim=1)
        self.ad_img.add_callback('ArraySize2_RBV', self.onProperty, dim=2)
        self.ad_img.add_callback('ColorMode_RBV', self.onProperty, dim='color')
        self.ad_cam.add_callback('DetectorState_RBV', self.onDetState)

        epics.caput("%s:cam1:ArrayCallbacks" % self.prefix, 1)
        for p in self.enabled_plugins:
            epics.caput("%s:%s:EnableCallbacks" % (self.prefix, p), 1)
        epics.caput("%s:JPEG1:NDArrayPort" % self.prefix, "OVER1")
        epics.caput("%s:TIFF1:NDArrayPort" % self.prefix, "OVER1")
        epics.caput("%s:image1:NDArrayPort" % self.prefix, "OVER1")

        self.ad_cam.Acquire = 1
        self.GetImageSize()
        self.unZoom()

        epics.poll()
        self.RefreshImage()

    @EpicsFunction
    def GetImageSize(self):
        self.arrsize = [1, 1, 1]
        self.arrsize[0] = self.ad_img.ArraySize0_RBV
        self.arrsize[1] = self.ad_img.ArraySize1_RBV
        self.arrsize[2] = self.ad_img.ArraySize2_RBV
        self.colormode = self.ad_img.ColorMode_RBV

        self.img_w = self.arrsize[1]
        self.img_h = self.arrsize[0]
        if self.colormode == 2:
            self.img_w = self.arrsize[2]
            self.img_h = self.arrsize[1]

    @DelayedEpicsCallback
    def onDetState(self, pvname=None, value=None, char_value=None, **kw):
        self.messag(char_value, panel=1)

    @DelayedEpicsCallback
    def onProperty(self, pvname=None, value=None, dim=None, **kw):
        if dim == 'color':
            self.colormode = value
        else:
            self.arrsize[dim] = value

    @DelayedEpicsCallback
    def onNewImage(self, pvname=None, value=None, **kw):
        if value != self.img_id:
            self.img_id = value
            if not self.drawing:
                self.drawing = True
                self.RefreshImage()

    @EpicsFunction
    def RefreshImage(self, pvname=None, **kws):
        try:
            wx.Yield()
        except:
            pass
        d = debugtime()

        if self.ad_img is None or self.ad_cam is None:
            return
        imgdim = self.ad_img.NDimensions_RBV
        imgcount = self.ad_cam.ArrayCounter_RBV
        now = time.time()
        if (imgcount == self.imgcount or abs(now - self.last_update) < 0.025):
            self.drawing = False
            return
        d.add('refresh img start')
        self.imgcount = imgcount
        self.drawing = True
        self.n_drawn += 1
        self.n_img = imgcount - self.imgcount_start
        #print 'ImgCount, n_drawn: ', imgcount, self.n_img, self.n_drawn

        self.last_update = time.time()
        self.image.can_resize = False

        xmin = self.ad_cam.MinX
        ymin = self.ad_cam.MinY
        width = self.ad_cam.SizeX
        height = self.ad_cam.SizeY

        arraysize = self.arrsize[0] * self.arrsize[1]
        if imgdim == 3:
            arraysize = arraysize * self.arrsize[2]
        if not self.ad_img.PV('ArrayData').connected:
            self.drawing = False
            return

        d.add('refresh img before raw get %i' % arraysize)
        rawdata = self.ad_img.PV('ArrayData').get(count=arraysize)
        d.add('refresh img after raw get')
        im_mode = 'L'
        im_size = (self.arrsize[0], self.arrsize[1])

        if self.colormode == 2:
            im_mode = 'RGB'
            im_size = [self.arrsize[1], self.arrsize[2]]
        if (self.colormode == 0 and isinstance(rawdata, np.ndarray)
                and rawdata.dtype != np.uint8):
            im_mode = 'I'
            rawdata = rawdata.astype(np.uint32)

        d.add('refresh img before msg')
        self.messag(' Image # %i ' % self.ad_cam.ArrayCounter_RBV, panel=2)
        d.add('refresh img before get image size')
        self.GetImageSize()

        self.im_size = im_size
        self.im_mode = im_mode
        self.data = rawdata
        d.add('refresh img before data to image')
        self.DatatoImage()
        d.add('refresh img after data to image')
        self.image.can_resize = True
        nmissed = max(0, self.n_img - self.n_drawn)

        delt = time.time() - self.starttime
        percent_drawn = self.n_drawn * 100 / (self.n_drawn + nmissed)
        smsg = self.stat_msg % (percent_drawn, self.n_drawn / delt)
        self.messag(smsg, panel=0)

        self.drawing = False
        d.add('refresh img done')
예제 #8
0
    def buildFrame(self):
        sbar = self.CreateStatusBar(3, wx.CAPTION | wx.THICK_FRAME)
        sfont = sbar.GetFont()
        sfont.SetWeight(wx.BOLD)
        sfont.SetPointSize(10)
        sbar.SetFont(sfont)

        self.SetStatusWidths([-3, -1, -1])
        self.SetStatusText('', 0)

        sizer = wx.GridBagSizer(10, 4)
        panel = wx.Panel(self)
        self.panel = panel
        labstyle = wx.ALIGN_LEFT | wx.ALIGN_BOTTOM | wx.EXPAND
        ctrlstyle = wx.ALIGN_LEFT | wx.ALIGN_BOTTOM

        rlabstyle = wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP | wx.EXPAND

        txtstyle = wx.ALIGN_LEFT | wx.ST_NO_AUTORESIZE | wx.TE_PROCESS_ENTER
        self.wids = {}
        self.wids['exptime'] = PVFloatCtrl(panel, pv=None, size=(100, -1))
        self.wids['period'] = PVFloatCtrl(panel, pv=None, size=(100, -1))
        self.wids['numimages'] = PVFloatCtrl(panel, pv=None, size=(100, -1))
        self.wids['gain'] = PVFloatCtrl(panel,
                                        pv=None,
                                        size=(100, -1),
                                        minval=0,
                                        maxval=20)

        self.wids['imagemode'] = PVEnumChoice(panel, pv=None, size=(100, -1))
        self.wids['triggermode'] = PVEnumChoice(panel, pv=None, size=(100, -1))
        self.wids['color'] = PVEnumChoice(panel, pv=None, size=(100, -1))
        self.wids['start'] = wx.Button(panel, -1, label='Start', size=(50, -1))
        self.wids['stop'] = wx.Button(panel, -1, label='Stop', size=(50, -1))

        if HAS_OVERLAY_DEVICE:
            self.wids['o1color'] = csel.ColourSelect(panel,
                                                     -1,
                                                     "",
                                                     '#FEFEFE',
                                                     size=(60, 25))
            self.wids['o1color'].Bind(csel.EVT_COLOURSELECT,
                                      Closure(self.onColor, item=1))
            self.wids['o1posx'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o1posy'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o1sizx'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o1sizy'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o1shape'] = PVEnumChoice(panel, pv=None, size=(100, -1))
            self.wids['o1use'] = PVEnumChoice(panel, pv=None, size=(50, -1))
            self.wids['o1name'] = PVTextCtrl(panel, pv=None, size=(100, -1))

            self.wids['o2color'] = csel.ColourSelect(panel,
                                                     -1,
                                                     "",
                                                     '#FEFEFE',
                                                     size=(60, 25))
            self.wids['o2color'].Bind(csel.EVT_COLOURSELECT,
                                      Closure(self.onColor, item=2))
            self.wids['o2posx'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o2posy'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o2sizx'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o2sizy'] = PVFloatCtrl(panel,
                                              pv=None,
                                              size=(50, -1),
                                              minval=0)
            self.wids['o2shape'] = PVEnumChoice(panel, pv=None, size=(100, -1))
            self.wids['o2use'] = PVEnumChoice(panel, pv=None, size=(50, -1))
            self.wids['o2name'] = PVTextCtrl(panel, pv=None, size=(100, -1))

        for key in ('start', 'stop'):
            self.wids[key].Bind(wx.EVT_BUTTON, Closure(self.onEntry, key=key))

        self.wids['zoomsize'] = wx.StaticText(panel,
                                              -1,
                                              size=(250, -1),
                                              style=txtstyle)
        self.wids['fullsize'] = wx.StaticText(panel,
                                              -1,
                                              size=(250, -1),
                                              style=txtstyle)

        def txt(label, size=100):
            return wx.StaticText(panel,
                                 label=label,
                                 size=(size, -1),
                                 style=labstyle)

        def lin(len=30, wid=2, style=wx.LI_HORIZONTAL):
            return wx.StaticLine(panel, size=(len, wid), style=style)

        sizer.Add(txt(' '), (0, 0), (1, 1), labstyle)
        sizer.Add(txt('Image Mode '), (1, 0), (1, 1), labstyle)
        sizer.Add(self.wids['imagemode'], (1, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('# Images '), (2, 0), (1, 1), labstyle)
        sizer.Add(self.wids['numimages'], (2, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Trigger Mode '), (3, 0), (1, 1), labstyle)
        sizer.Add(self.wids['triggermode'], (3, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Period '), (4, 0), (1, 1), labstyle)
        sizer.Add(self.wids['period'], (4, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Exposure Time '), (5, 0), (1, 1), labstyle)
        sizer.Add(self.wids['exptime'], (5, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Gain '), (6, 0), (1, 1), labstyle)
        sizer.Add(self.wids['gain'], (6, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Color Mode'), (7, 0), (1, 1), labstyle)
        sizer.Add(self.wids['color'], (7, 1), (1, 2), ctrlstyle)

        sizer.Add(txt('Acquire '), (9, 0), (1, 1), labstyle)

        sizer.Add(self.wids['start'], (9, 1), (1, 1), ctrlstyle)
        sizer.Add(self.wids['stop'], (9, 2), (1, 1), ctrlstyle)

        sizer.Add(self.wids['fullsize'], (12, 0), (1, 3), labstyle)
        sizer.Add(self.wids['zoomsize'], (13, 0), (1, 3), labstyle)

        sizer.Add(lin(75), (15, 0), (1, 3), labstyle)

        if HAS_OVERLAY_DEVICE:
            ir = 16
            sizer.Add(txt('Overlay 1:'), (ir + 0, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1use'], (ir + 0, 1), (1, 2), ctrlstyle)
            sizer.Add(txt('Shape:'), (ir + 1, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1shape'], (ir + 1, 1), (1, 2), ctrlstyle)
            sizer.Add(txt('Name:'), (ir + 2, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1name'], (ir + 2, 1), (1, 2), ctrlstyle)

            sizer.Add(txt('Position '), (ir + 3, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1posx'], (ir + 3, 1), (1, 1), ctrlstyle)
            sizer.Add(self.wids['o1posy'], (ir + 3, 2), (1, 1), ctrlstyle)
            sizer.Add(txt('Size '), (ir + 4, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1sizx'], (ir + 4, 1), (1, 1), ctrlstyle)
            sizer.Add(self.wids['o1sizy'], (ir + 4, 2), (1, 1), ctrlstyle)
            sizer.Add(txt('Color '), (ir + 5, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o1color'], (ir + 5, 1), (1, 2), ctrlstyle)
            sizer.Add(lin(75), (ir + 6, 0), (1, 3), labstyle)

            ir = ir + 7
            sizer.Add(txt('Overlay 1:'), (ir + 0, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2use'], (ir + 0, 1), (1, 2), ctrlstyle)
            sizer.Add(txt('Shape:'), (ir + 1, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2shape'], (ir + 1, 1), (1, 2), ctrlstyle)
            sizer.Add(txt('Name:'), (ir + 2, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2name'], (ir + 2, 1), (1, 2), ctrlstyle)

            sizer.Add(txt('Position '), (ir + 3, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2posx'], (ir + 3, 1), (1, 1), ctrlstyle)
            sizer.Add(self.wids['o2posy'], (ir + 3, 2), (1, 1), ctrlstyle)
            sizer.Add(txt('Size '), (ir + 4, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2sizx'], (ir + 4, 1), (1, 1), ctrlstyle)
            sizer.Add(self.wids['o2sizy'], (ir + 4, 2), (1, 1), ctrlstyle)
            sizer.Add(txt('Color '), (ir + 5, 0), (1, 1), labstyle)
            sizer.Add(self.wids['o2color'], (ir + 5, 1), (1, 2), ctrlstyle)
            sizer.Add(lin(75), (ir + 6, 0), (1, 3), labstyle)

        self.image = ImageView(self,
                               size=(1360, 1024),
                               onzoom=self.onZoom,
                               onprofile=self.onProfile,
                               onshow=self.onShowXY)

        panel.SetSizer(sizer)
        sizer.Fit(panel)

        mainsizer = wx.BoxSizer(wx.HORIZONTAL)
        mainsizer.Add(panel, 0, wx.LEFT | wx.GROW | wx.ALL, 5)
        mainsizer.Add(self.image, 1, wx.CENTER | wx.GROW | wx.ALL, 5)
        self.SetSizer(mainsizer)
        mainsizer.Fit(self)

        self.SetAutoLayout(True)

        try:
            self.SetIcon(wx.Icon(ICON_FILE, wx.BITMAP_TYPE_ICO))
        except:
            pass

        self.RefreshImage()
        wx.CallAfter(self.connect_pvs)
예제 #9
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1711, 1320)
        MainWindow.setMinimumSize(QtCore.QSize(1024, 768))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("resources/main.png"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.imageView = ImageView(self.centralwidget)
        self.imageView.setTabletTracking(False)
        self.imageView.setObjectName("imageView")
        self.gridLayout.addWidget(self.imageView, 1, 0, 1, 1)
        self.listWidgetCropImages = QtWidgets.QListWidget(self.centralwidget)
        self.listWidgetCropImages.setObjectName("listWidgetCropImages")
        self.gridLayout.addWidget(self.listWidgetCropImages, 2, 0, 1, 1)
        self.labelHeader = QtWidgets.QLabel(self.centralwidget)
        self.labelHeader.setText("")
        self.labelHeader.setPixmap(QtGui.QPixmap("resources/header.png"))
        self.labelHeader.setScaledContents(True)
        self.labelHeader.setObjectName("labelHeader")
        self.gridLayout.addWidget(self.labelHeader, 0, 0, 1, 1)
        self.gridLayout.setRowStretch(0, 1)
        self.gridLayout.setRowStretch(1, 4)
        self.gridLayout.setRowStretch(2, 2)
        self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
        self.dockWidgetLog = QtWidgets.QDockWidget(self.centralwidget)
        self.dockWidgetLog.setFloating(True)
        self.dockWidgetLog.setFeatures(
            QtWidgets.QDockWidget.AllDockWidgetFeatures)
        self.dockWidgetLog.setObjectName("dockWidgetLog")
        self.dockWidgetContents = QtWidgets.QWidget()
        self.dockWidgetContents.setObjectName("dockWidgetContents")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.dockWidgetContents)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.plainTextEditLog = QtWidgets.QPlainTextEdit(
            self.dockWidgetContents)
        self.plainTextEditLog.setObjectName("plainTextEditLog")
        self.verticalLayout.addWidget(self.plainTextEditLog)
        self.dockWidgetLog.setWidget(self.dockWidgetContents)
        self.gridLayout_2.addWidget(self.dockWidgetLog, 0, 1, 1, 1)
        self.gridLayout_2.setColumnStretch(0, 4)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.toolBar = QtWidgets.QToolBar(MainWindow)
        self.toolBar.setMovable(False)
        self.toolBar.setAllowedAreas(QtCore.Qt.LeftToolBarArea)
        self.toolBar.setIconSize(QtCore.QSize(63, 63))
        self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
        self.toolBar.setObjectName("toolBar")
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
        self.actionSetup = QtWidgets.QAction(MainWindow)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap("resources/setup.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionSetup.setIcon(icon1)
        self.actionSetup.setObjectName("actionSetup")
        self.actionDisplayLog = QtWidgets.QAction(MainWindow)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap("resources/log.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.actionDisplayLog.setIcon(icon2)
        self.actionDisplayLog.setObjectName("actionDisplayLog")
        self.actionExit = QtWidgets.QAction(MainWindow)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap("resources/exit.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionExit.setIcon(icon3)
        self.actionExit.setObjectName("actionExit")
        self.actionImageAdjust = QtWidgets.QAction(MainWindow)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap("resources/imgAdjust.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionImageAdjust.setIcon(icon4)
        self.actionImageAdjust.setObjectName("actionImageAdjust")
        self.actionStart = QtWidgets.QAction(MainWindow)
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap("resources/start.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionStart.setIcon(icon5)
        self.actionStart.setObjectName("actionStart")
        self.actionStop = QtWidgets.QAction(MainWindow)
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap("resources/stop.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionStop.setIcon(icon6)
        self.actionStop.setObjectName("actionStop")
        self.actionPause = QtWidgets.QAction(MainWindow)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap("resources/pause.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionPause.setIcon(icon7)
        self.actionPause.setObjectName("actionPause")
        self.actionNext = QtWidgets.QAction(MainWindow)
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap("resources/next.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionNext.setIcon(icon8)
        self.actionNext.setObjectName("actionNext")
        self.actionPrev = QtWidgets.QAction(MainWindow)
        icon9 = QtGui.QIcon()
        icon9.addPixmap(QtGui.QPixmap("resources/prev.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionPrev.setIcon(icon9)
        self.actionPrev.setObjectName("actionPrev")
        self.actionRedo = QtWidgets.QAction(MainWindow)
        icon10 = QtGui.QIcon()
        icon10.addPixmap(QtGui.QPixmap("resources/redo.png"),
                         QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionRedo.setIcon(icon10)
        self.actionRedo.setObjectName("actionRedo")
        self.toolBar.addAction(self.actionSetup)
        self.toolBar.addAction(self.actionDisplayLog)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.actionStart)
        self.toolBar.addAction(self.actionPause)
        self.toolBar.addAction(self.actionStop)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.actionNext)
        self.toolBar.addAction(self.actionPrev)
        self.toolBar.addAction(self.actionRedo)
        self.toolBar.addAction(self.actionImageAdjust)
        self.toolBar.addAction(self.actionExit)
        self.toolBar.addSeparator()

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
예제 #10
0
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(1213, 744)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
        Form.setSizePolicy(sizePolicy)
        self.verticalLayout_6 = QtGui.QVBoxLayout(Form)
        self.verticalLayout_6.setObjectName(_fromUtf8("verticalLayout_6"))
        self.splitter_side_bar = QtGui.QSplitter(Form)
        self.splitter_side_bar.setOrientation(QtCore.Qt.Horizontal)
        self.splitter_side_bar.setObjectName(_fromUtf8("splitter_side_bar"))
        self.layoutWidget = QtGui.QWidget(self.splitter_side_bar)
        self.layoutWidget.setObjectName(_fromUtf8("layoutWidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget)
        self.verticalLayout.setMargin(0)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.tree_data = QtGui.QTreeWidget(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.tree_data.sizePolicy().hasHeightForWidth())
        self.tree_data.setSizePolicy(sizePolicy)
        self.tree_data.setColumnCount(2)
        self.tree_data.setObjectName(_fromUtf8("tree_data"))
        self.verticalLayout.addWidget(self.tree_data)
        self.horizontalLayout_3 = QtGui.QHBoxLayout()
        self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
        self.label_17 = QtGui.QLabel(self.layoutWidget)
        self.label_17.setMaximumSize(QtCore.QSize(60, 25))
        font = QtGui.QFont()
        font.setPointSize(13)
        font.setItalic(False)
        font.setUnderline(False)
        font.setStrikeOut(False)
        self.label_17.setFont(font)
        self.label_17.setTextFormat(QtCore.Qt.RichText)
        self.label_17.setScaledContents(True)
        self.label_17.setObjectName(_fromUtf8("label_17"))
        self.horizontalLayout_3.addWidget(self.label_17)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem)
        self.verticalLayout.addLayout(self.horizontalLayout_3)
        self.table_images = QtGui.QTableWidget(self.layoutWidget)
        self.table_images.setObjectName(_fromUtf8("table_images"))
        self.table_images.setColumnCount(3)
        self.table_images.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.table_images.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.table_images.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.table_images.setHorizontalHeaderItem(2, item)
        self.verticalLayout.addWidget(self.table_images)
        self.btn_newImage = QtGui.QPushButton(self.layoutWidget)
        self.btn_newImage.setMaximumSize(QtCore.QSize(16777215, 25))
        self.btn_newImage.setObjectName(_fromUtf8("btn_newImage"))
        self.verticalLayout.addWidget(self.btn_newImage)
        self.horizontalLayout_13 = QtGui.QHBoxLayout()
        self.horizontalLayout_13.setObjectName(_fromUtf8("horizontalLayout_13"))
        self.label_18 = QtGui.QLabel(self.layoutWidget)
        self.label_18.setMaximumSize(QtCore.QSize(100, 25))
        font = QtGui.QFont()
        font.setPointSize(13)
        font.setItalic(False)
        font.setUnderline(False)
        font.setStrikeOut(False)
        self.label_18.setFont(font)
        self.label_18.setTextFormat(QtCore.Qt.RichText)
        self.label_18.setScaledContents(True)
        self.label_18.setObjectName(_fromUtf8("label_18"))
        self.horizontalLayout_13.addWidget(self.label_18)
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_13.addItem(spacerItem1)
        self.verticalLayout.addLayout(self.horizontalLayout_13)
        self.horizontalLayout_9 = QtGui.QHBoxLayout()
        self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9"))
        self.label_13 = QtGui.QLabel(self.layoutWidget)
        self.label_13.setMaximumSize(QtCore.QSize(25, 30))
        self.label_13.setObjectName(_fromUtf8("label_13"))
        self.horizontalLayout_9.addWidget(self.label_13)
        self.combo_select_source = QtGui.QComboBox(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.combo_select_source.sizePolicy().hasHeightForWidth())
        self.combo_select_source.setSizePolicy(sizePolicy)
        self.combo_select_source.setMaximumSize(QtCore.QSize(150, 20))
        self.combo_select_source.setObjectName(_fromUtf8("combo_select_source"))
        self.horizontalLayout_9.addWidget(self.combo_select_source)
        self.label_14 = QtGui.QLabel(self.layoutWidget)
        self.label_14.setMaximumSize(QtCore.QSize(20, 30))
        self.label_14.setObjectName(_fromUtf8("label_14"))
        self.horizontalLayout_9.addWidget(self.label_14)
        self.combo_select_val = QtGui.QComboBox(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.combo_select_val.sizePolicy().hasHeightForWidth())
        self.combo_select_val.setSizePolicy(sizePolicy)
        self.combo_select_val.setMaximumSize(QtCore.QSize(150, 20))
        self.combo_select_val.setObjectName(_fromUtf8("combo_select_val"))
        self.horizontalLayout_9.addWidget(self.combo_select_val)
        spacerItem2 = QtGui.QSpacerItem(0, 20, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_9.addItem(spacerItem2)
        self.verticalLayout.addLayout(self.horizontalLayout_9)
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.label_5 = QtGui.QLabel(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth())
        self.label_5.setSizePolicy(sizePolicy)
        self.label_5.setMaximumSize(QtCore.QSize(10, 20))
        self.label_5.setAlignment(QtCore.Qt.AlignCenter)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.gridLayout.addWidget(self.label_5, 0, 0, 1, 1)
        self.label_10 = QtGui.QLabel(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_10.sizePolicy().hasHeightForWidth())
        self.label_10.setSizePolicy(sizePolicy)
        self.label_10.setMaximumSize(QtCore.QSize(10, 20))
        self.label_10.setAlignment(QtCore.Qt.AlignCenter)
        self.label_10.setObjectName(_fromUtf8("label_10"))
        self.gridLayout.addWidget(self.label_10, 1, 0, 1, 1)
        self.label_11 = QtGui.QLabel(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_11.sizePolicy().hasHeightForWidth())
        self.label_11.setSizePolicy(sizePolicy)
        self.label_11.setMaximumSize(QtCore.QSize(10, 20))
        self.label_11.setAlignment(QtCore.Qt.AlignCenter)
        self.label_11.setObjectName(_fromUtf8("label_11"))
        self.gridLayout.addWidget(self.label_11, 0, 2, 1, 1)
        self.label_12 = QtGui.QLabel(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_12.sizePolicy().hasHeightForWidth())
        self.label_12.setSizePolicy(sizePolicy)
        self.label_12.setMaximumSize(QtCore.QSize(10, 20))
        self.label_12.setAlignment(QtCore.Qt.AlignCenter)
        self.label_12.setObjectName(_fromUtf8("label_12"))
        self.gridLayout.addWidget(self.label_12, 1, 2, 1, 1)
        self.combo_x = QtGui.QComboBox(self.layoutWidget)
        self.combo_x.setObjectName(_fromUtf8("combo_x"))
        self.gridLayout.addWidget(self.combo_x, 0, 1, 1, 1)
        self.combo_y = QtGui.QComboBox(self.layoutWidget)
        self.combo_y.setObjectName(_fromUtf8("combo_y"))
        self.gridLayout.addWidget(self.combo_y, 1, 1, 1, 1)
        self.combo_t = QtGui.QComboBox(self.layoutWidget)
        self.combo_t.setObjectName(_fromUtf8("combo_t"))
        self.gridLayout.addWidget(self.combo_t, 0, 3, 1, 1)
        self.combo_c = QtGui.QComboBox(self.layoutWidget)
        self.combo_c.setObjectName(_fromUtf8("combo_c"))
        self.gridLayout.addWidget(self.combo_c, 1, 3, 1, 1)
        self.verticalLayout.addLayout(self.gridLayout)
        self.table_slice = QtGui.QTableWidget(self.layoutWidget)
        self.table_slice.setObjectName(_fromUtf8("table_slice"))
        self.table_slice.setColumnCount(3)
        self.table_slice.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.table_slice.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.table_slice.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.table_slice.setHorizontalHeaderItem(2, item)
        self.verticalLayout.addWidget(self.table_slice)
        self.horizontalLayout_14 = QtGui.QHBoxLayout()
        self.horizontalLayout_14.setObjectName(_fromUtf8("horizontalLayout_14"))
        self.label_19 = QtGui.QLabel(self.layoutWidget)
        self.label_19.setMaximumSize(QtCore.QSize(100, 25))
        font = QtGui.QFont()
        font.setPointSize(13)
        font.setItalic(False)
        font.setUnderline(False)
        font.setStrikeOut(False)
        self.label_19.setFont(font)
        self.label_19.setTextFormat(QtCore.Qt.RichText)
        self.label_19.setScaledContents(True)
        self.label_19.setObjectName(_fromUtf8("label_19"))
        self.horizontalLayout_14.addWidget(self.label_19)
        self.checkBox_isocurve = QtGui.QCheckBox(self.layoutWidget)
        self.checkBox_isocurve.setText(_fromUtf8(""))
        self.checkBox_isocurve.setObjectName(_fromUtf8("checkBox_isocurve"))
        self.horizontalLayout_14.addWidget(self.checkBox_isocurve)
        spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_14.addItem(spacerItem3)
        self.verticalLayout.addLayout(self.horizontalLayout_14)
        self.horizontalLayout_5 = QtGui.QHBoxLayout()
        self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5"))
        self.label_15 = QtGui.QLabel(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_15.sizePolicy().hasHeightForWidth())
        self.label_15.setSizePolicy(sizePolicy)
        self.label_15.setObjectName(_fromUtf8("label_15"))
        self.horizontalLayout_5.addWidget(self.label_15)
        spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_5.addItem(spacerItem4)
        self.label_16 = QtGui.QLabel(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_16.sizePolicy().hasHeightForWidth())
        self.label_16.setSizePolicy(sizePolicy)
        self.label_16.setObjectName(_fromUtf8("label_16"))
        self.horizontalLayout_5.addWidget(self.label_16)
        self.spin_width = SpinBox(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spin_width.sizePolicy().hasHeightForWidth())
        self.spin_width.setSizePolicy(sizePolicy)
        self.spin_width.setMaximumSize(QtCore.QSize(50, 15))
        self.spin_width.setObjectName(_fromUtf8("spin_width"))
        self.horizontalLayout_5.addWidget(self.spin_width)
        self.verticalLayout.addLayout(self.horizontalLayout_5)
        self.gradient_isocurve = GradientWidget(self.layoutWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.gradient_isocurve.sizePolicy().hasHeightForWidth())
        self.gradient_isocurve.setSizePolicy(sizePolicy)
        self.gradient_isocurve.setMaximumSize(QtCore.QSize(16777215, 40))
        self.gradient_isocurve.setObjectName(_fromUtf8("gradient_isocurve"))
        self.verticalLayout.addWidget(self.gradient_isocurve)
        self.table_isocurve = QtGui.QTableWidget(self.layoutWidget)
        self.table_isocurve.setObjectName(_fromUtf8("table_isocurve"))
        self.table_isocurve.setColumnCount(4)
        self.table_isocurve.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.table_isocurve.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.table_isocurve.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.table_isocurve.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.table_isocurve.setHorizontalHeaderItem(3, item)
        self.verticalLayout.addWidget(self.table_isocurve)
        self.btn_new_isocurve = QtGui.QPushButton(self.layoutWidget)
        self.btn_new_isocurve.setMaximumSize(QtCore.QSize(16777215, 25))
        self.btn_new_isocurve.setObjectName(_fromUtf8("btn_new_isocurve"))
        self.verticalLayout.addWidget(self.btn_new_isocurve)
        self.splitter = QtGui.QSplitter(self.splitter_side_bar)
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        self.splitter.setObjectName(_fromUtf8("splitter"))
        self.plot = ImageView(self.splitter)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.plot.sizePolicy().hasHeightForWidth())
        self.plot.setSizePolicy(sizePolicy)
        self.plot.setSizeIncrement(QtCore.QSize(0, 0))
        self.plot.setObjectName(_fromUtf8("plot"))
        self.layoutWidget1 = QtGui.QWidget(self.splitter)
        self.layoutWidget1.setObjectName(_fromUtf8("layoutWidget1"))
        self.horizontalLayout_2 = QtGui.QHBoxLayout(self.layoutWidget1)
        self.horizontalLayout_2.setMargin(0)
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.verticalLayout_5 = QtGui.QVBoxLayout()
        self.verticalLayout_5.setObjectName(_fromUtf8("verticalLayout_5"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.spin_x_min = SpinBox(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spin_x_min.sizePolicy().hasHeightForWidth())
        self.spin_x_min.setSizePolicy(sizePolicy)
        self.spin_x_min.setMinimumSize(QtCore.QSize(0, 0))
        self.spin_x_min.setMaximumSize(QtCore.QSize(80, 15))
        self.spin_x_min.setBaseSize(QtCore.QSize(0, 0))
        self.spin_x_min.setObjectName(_fromUtf8("spin_x_min"))
        self.horizontalLayout.addWidget(self.spin_x_min)
        self.spin_x_max = SpinBox(self.layoutWidget1)
        self.spin_x_max.setEnabled(True)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spin_x_max.sizePolicy().hasHeightForWidth())
        self.spin_x_max.setSizePolicy(sizePolicy)
        self.spin_x_max.setMinimumSize(QtCore.QSize(0, 0))
        self.spin_x_max.setMaximumSize(QtCore.QSize(80, 15))
        self.spin_x_max.setBaseSize(QtCore.QSize(0, 0))
        self.spin_x_max.setObjectName(_fromUtf8("spin_x_max"))
        self.horizontalLayout.addWidget(self.spin_x_max)
        self.spin_y_min = SpinBox(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spin_y_min.sizePolicy().hasHeightForWidth())
        self.spin_y_min.setSizePolicy(sizePolicy)
        self.spin_y_min.setMinimumSize(QtCore.QSize(0, 0))
        self.spin_y_min.setMaximumSize(QtCore.QSize(80, 15))
        self.spin_y_min.setBaseSize(QtCore.QSize(0, 0))
        self.spin_y_min.setObjectName(_fromUtf8("spin_y_min"))
        self.horizontalLayout.addWidget(self.spin_y_min)
        self.spin_y_max = SpinBox(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spin_y_max.sizePolicy().hasHeightForWidth())
        self.spin_y_max.setSizePolicy(sizePolicy)
        self.spin_y_max.setMinimumSize(QtCore.QSize(0, 0))
        self.spin_y_max.setMaximumSize(QtCore.QSize(80, 15))
        self.spin_y_max.setBaseSize(QtCore.QSize(0, 0))
        self.spin_y_max.setObjectName(_fromUtf8("spin_y_max"))
        self.horizontalLayout.addWidget(self.spin_y_max)
        self.spin_t = SpinBox(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spin_t.sizePolicy().hasHeightForWidth())
        self.spin_t.setSizePolicy(sizePolicy)
        self.spin_t.setMaximumSize(QtCore.QSize(80, 15))
        self.spin_t.setObjectName(_fromUtf8("spin_t"))
        self.horizontalLayout.addWidget(self.spin_t)
        self.spin_lvl_min = SpinBox(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spin_lvl_min.sizePolicy().hasHeightForWidth())
        self.spin_lvl_min.setSizePolicy(sizePolicy)
        self.spin_lvl_min.setMaximumSize(QtCore.QSize(80, 15))
        self.spin_lvl_min.setObjectName(_fromUtf8("spin_lvl_min"))
        self.horizontalLayout.addWidget(self.spin_lvl_min)
        self.spin_lvl_max = SpinBox(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.spin_lvl_max.sizePolicy().hasHeightForWidth())
        self.spin_lvl_max.setSizePolicy(sizePolicy)
        self.spin_lvl_max.setMaximumSize(QtCore.QSize(80, 15))
        self.spin_lvl_max.setObjectName(_fromUtf8("spin_lvl_max"))
        self.horizontalLayout.addWidget(self.spin_lvl_max)
        self.verticalLayout_5.addLayout(self.horizontalLayout)
        self.horizontalLayout_4 = QtGui.QHBoxLayout()
        self.horizontalLayout_4.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
        self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
        self.label_3 = QtGui.QLabel(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
        self.label_3.setSizePolicy(sizePolicy)
        self.label_3.setMinimumSize(QtCore.QSize(0, 0))
        self.label_3.setMaximumSize(QtCore.QSize(40, 15))
        self.label_3.setAlignment(QtCore.Qt.AlignCenter)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.horizontalLayout_4.addWidget(self.label_3)
        self.label_4 = QtGui.QLabel(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
        self.label_4.setSizePolicy(sizePolicy)
        self.label_4.setMinimumSize(QtCore.QSize(0, 0))
        self.label_4.setMaximumSize(QtCore.QSize(40, 15))
        self.label_4.setAlignment(QtCore.Qt.AlignCenter)
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.horizontalLayout_4.addWidget(self.label_4)
        self.label = QtGui.QLabel(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
        self.label.setSizePolicy(sizePolicy)
        self.label.setMinimumSize(QtCore.QSize(0, 0))
        self.label.setMaximumSize(QtCore.QSize(40, 15))
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName(_fromUtf8("label"))
        self.horizontalLayout_4.addWidget(self.label)
        self.label_2 = QtGui.QLabel(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
        self.label_2.setSizePolicy(sizePolicy)
        self.label_2.setMinimumSize(QtCore.QSize(0, 0))
        self.label_2.setMaximumSize(QtCore.QSize(40, 15))
        self.label_2.setScaledContents(False)
        self.label_2.setAlignment(QtCore.Qt.AlignCenter)
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.horizontalLayout_4.addWidget(self.label_2)
        self.label_7 = QtGui.QLabel(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_7.sizePolicy().hasHeightForWidth())
        self.label_7.setSizePolicy(sizePolicy)
        self.label_7.setMinimumSize(QtCore.QSize(0, 0))
        self.label_7.setMaximumSize(QtCore.QSize(40, 15))
        self.label_7.setAlignment(QtCore.Qt.AlignCenter)
        self.label_7.setObjectName(_fromUtf8("label_7"))
        self.horizontalLayout_4.addWidget(self.label_7)
        self.label_8 = QtGui.QLabel(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_8.sizePolicy().hasHeightForWidth())
        self.label_8.setSizePolicy(sizePolicy)
        self.label_8.setMinimumSize(QtCore.QSize(0, 0))
        self.label_8.setMaximumSize(QtCore.QSize(40, 15))
        self.label_8.setAlignment(QtCore.Qt.AlignCenter)
        self.label_8.setObjectName(_fromUtf8("label_8"))
        self.horizontalLayout_4.addWidget(self.label_8)
        self.label_9 = QtGui.QLabel(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_9.sizePolicy().hasHeightForWidth())
        self.label_9.setSizePolicy(sizePolicy)
        self.label_9.setMinimumSize(QtCore.QSize(0, 0))
        self.label_9.setMaximumSize(QtCore.QSize(40, 15))
        self.label_9.setAlignment(QtCore.Qt.AlignCenter)
        self.label_9.setObjectName(_fromUtf8("label_9"))
        self.horizontalLayout_4.addWidget(self.label_9)
        self.verticalLayout_5.addLayout(self.horizontalLayout_4)
        self.horizontalLayout_2.addLayout(self.verticalLayout_5)
        self.checkBox_lockRatio = QtGui.QCheckBox(self.layoutWidget1)
        self.checkBox_lockRatio.setMaximumSize(QtCore.QSize(80, 15))
        self.checkBox_lockRatio.setObjectName(_fromUtf8("checkBox_lockRatio"))
        self.horizontalLayout_2.addWidget(self.checkBox_lockRatio)
        self.verticalLayout_3 = QtGui.QVBoxLayout()
        self.verticalLayout_3.setSpacing(0)
        self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
        self.btn_autoRange = QtGui.QPushButton(self.layoutWidget1)
        self.btn_autoRange.setMaximumSize(QtCore.QSize(100, 20))
        self.btn_autoRange.setCheckable(True)
        self.btn_autoRange.setChecked(True)
        self.btn_autoRange.setObjectName(_fromUtf8("btn_autoRange"))
        self.verticalLayout_3.addWidget(self.btn_autoRange)
        self.btn_autoLvl = QtGui.QPushButton(self.layoutWidget1)
        self.btn_autoLvl.setMaximumSize(QtCore.QSize(100, 20))
        self.btn_autoLvl.setCheckable(True)
        self.btn_autoLvl.setChecked(True)
        self.btn_autoLvl.setObjectName(_fromUtf8("btn_autoLvl"))
        self.verticalLayout_3.addWidget(self.btn_autoLvl)
        self.horizontalLayout_2.addLayout(self.verticalLayout_3)
        self.verticalLayout_4 = QtGui.QVBoxLayout()
        self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
        self.btnColor_background = ColorButton(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.btnColor_background.sizePolicy().hasHeightForWidth())
        self.btnColor_background.setSizePolicy(sizePolicy)
        self.btnColor_background.setMaximumSize(QtCore.QSize(75, 25))
        self.btnColor_background.setObjectName(_fromUtf8("btnColor_background"))
        self.verticalLayout_4.addWidget(self.btnColor_background)
        self.label_6 = QtGui.QLabel(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth())
        self.label_6.setSizePolicy(sizePolicy)
        self.label_6.setMaximumSize(QtCore.QSize(100, 15))
        self.label_6.setAlignment(QtCore.Qt.AlignCenter)
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.verticalLayout_4.addWidget(self.label_6)
        self.horizontalLayout_2.addLayout(self.verticalLayout_4)
        self.verticalLayout_2 = QtGui.QVBoxLayout()
        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
        self.btnColor_grid = ColorButton(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.btnColor_grid.sizePolicy().hasHeightForWidth())
        self.btnColor_grid.setSizePolicy(sizePolicy)
        self.btnColor_grid.setMaximumSize(QtCore.QSize(75, 25))
        self.btnColor_grid.setObjectName(_fromUtf8("btnColor_grid"))
        self.verticalLayout_2.addWidget(self.btnColor_grid)
        self.checkBox_showGrid = QtGui.QCheckBox(self.layoutWidget1)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.checkBox_showGrid.sizePolicy().hasHeightForWidth())
        self.checkBox_showGrid.setSizePolicy(sizePolicy)
        self.checkBox_showGrid.setMaximumSize(QtCore.QSize(80, 15))
        self.checkBox_showGrid.setObjectName(_fromUtf8("checkBox_showGrid"))
        self.verticalLayout_2.addWidget(self.checkBox_showGrid)
        self.horizontalLayout_2.addLayout(self.verticalLayout_2)
        self.verticalLayout_8 = QtGui.QVBoxLayout()
        self.verticalLayout_8.setObjectName(_fromUtf8("verticalLayout_8"))
        self.checkBox_x_slice = QtGui.QCheckBox(self.layoutWidget1)
        self.checkBox_x_slice.setMaximumSize(QtCore.QSize(80, 15))
        self.checkBox_x_slice.setObjectName(_fromUtf8("checkBox_x_slice"))
        self.verticalLayout_8.addWidget(self.checkBox_x_slice)
        self.checkBox_y_slice = QtGui.QCheckBox(self.layoutWidget1)
        self.checkBox_y_slice.setMaximumSize(QtCore.QSize(80, 15))
        self.checkBox_y_slice.setObjectName(_fromUtf8("checkBox_y_slice"))
        self.verticalLayout_8.addWidget(self.checkBox_y_slice)
        self.horizontalLayout_2.addLayout(self.verticalLayout_8)
        self.verticalLayout_6.addWidget(self.splitter_side_bar)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
예제 #11
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.mLayout = QVBoxLayout(self)
        self.mLayout.setContentsMargins(0, 0, 0, 0)
        self.mLayout.setSpacing(0)
        self.mHLayout = QHBoxLayout()
        self.mHLayout.setSpacing(20)

        self.mVLayout = QVBoxLayout()
        self.mVLayout.setContentsMargins(5, 5, 5, 5)

        self.mNavigation = NavigationBar(self)
        self.mNavigation.pushNavigation("Apps", 0)
        self.mNavigation.pushNavigation(
            "Neal Analytics SKU Assortment Optimization", 1)
        self.mNavigation.pushNavigation("Neal Analytics", 2)

        self.mSidePanel = SidePanel(self)
        self.mHeaderFrame = QFrame(self)
        self.mAppName = QLabel(self.mHeaderFrame)
        self.mAppName.setFont(QFont("SegeoUI", 20))
        self.mAppName.setText("Neal Analytics SKU Assortment Optimization")
        self.mAppNameBrief = QLabel(self.mHeaderFrame)
        self.mAppNameBrief.setFont(QFont("SegeoUI", 14))
        self.mAppNameBrief.setText("Neal Analytics")
        self.mHeaderLayout = QVBoxLayout(self.mHeaderFrame)
        self.mHeaderLayout.addWidget(self.mAppName, 0, Qt.AlignLeft)
        self.mHeaderLayout.addWidget(self.mAppNameBrief, 0, Qt.AlignLeft)

        self.mTab = TabWidget(self)
        self.mTab.addItemByText("Overview", 0)
        self.mTab.addItemByText("Reviews", 1)
        self.mTab.tabChanged.connect(self.onTabChanged)

        self.mOverviewFrame = QFrame(self)

        self.mIntroFrame = IntroFrame(self.mOverviewFrame)
        self.mIntroFrame.setIntroDescHtmlFile("./html/example.html")

        self.mImageView = ImageView(self.mOverviewFrame)
        self.mImageView.setPresenterSize(640, 480)
        self.mImageView.addThumbnail("./img/phantom.jpg")
        self.mImageView.addThumbnail("./img/spectre.jpg")
        self.mImageView.addThumbnail(
            "./img/deeplearning.png",
            "https://www.youtube.com/embed/b99UVkWzYTQ?rel=0&amp;showinfo=0",
            1)
        self.mImageView.addThumbnail("./img/large.png")
        self.mImageView.addThumbnail("./img/microsoft_preferred.png")
        self.mImageView.addThumbnail("./img/phantom.jpg")
        self.mImageView.addThumbnail("./img/spectre.jpg")

        self.mOverviewLayout = QHBoxLayout(self.mOverviewFrame)
        self.mOverviewLayout.setSpacing(40)
        self.mOverviewLayout.setContentsMargins(0, 0, 0, 0)
        self.mOverviewLayout.addWidget(self.mIntroFrame)
        self.mOverviewLayout.addWidget(self.mImageView)

        self.mReviewFrame = ReviewContainer(self)

        self.mVLayout.addWidget(self.mHeaderFrame, 0)
        self.mVLayout.addWidget(self.mTab, 0)
        self.mVLayout.addWidget(self.mReviewFrame, 10)
        self.mVLayout.addWidget(self.mOverviewFrame, 10)

        self.mHLayout.addWidget(self.mSidePanel)
        self.mHLayout.addLayout(self.mVLayout)

        self.mLayout.addWidget(self.mNavigation, 0, Qt.AlignLeft)
        self.mLayout.addLayout(self.mHLayout)
        self.mSidePanel.adjustFixedWidth(200)

        self.mTab.setActiveItemByIndex(0)

        self.setObjectName("DetailPage")
        self.setStyleSheet("#DetailPage{background-color: white;}")
        self.setAutoFillBackground(True)
        self.onTabChanged(0)
예제 #12
0
파일: gui.py 프로젝트: VanessaNav/3D_Cell
class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        # Proyecto
        self.project = None

        # Título
        self.setWindowTitle("3D Cell Reconstruction")

        # Inicializa el menú
        self.initMenubar()

        # Visor de las imágenes (imagen y control van en el mismo layout)
        # NOTA: Es el objeto central del objeto QMainWindow, que tiene eso, una barra de estado, etc. Podemos volver al QWidget si es fuese mejor.
        self.imageViewer = QWidget(self)
        self.imageViewer.setLayout(QGridLayout())
        # Fija márgenes para centrar la imagen
        self.imageViewer.layout().setColumnStretch(0, 0)
        self.imageViewer.layout().setColumnStretch(2, 0)
        self.imageViewer.layout().setRowStretch(1, 0)
        self.imageViewer.layout().setRowStretch(3, 0)
        # Crea un campo de texto para mostrar el nombre de la imagen
        self.imageName = QLineEdit("No project loaded")
        self.imageName.setReadOnly(True)
        self.imageViewer.layout().addWidget(self.imageName, 0, 1)
        # Crea un objeto de la clase ImageView para mostrar la imagen y dibujar
        self.imageView = ImageView()
        self.imageViewer.layout().addWidget(self.imageView, 2, 1)
        # Inicializa los botones de control
        self.initControlLayout()
        self.imageViewer.layout().addLayout(self.control_layout, 3, 0, 1, 3)
        # Lo situa como objeto pricipal de la aplicación.
        self.setCentralWidget(self.imageViewer)

        # NOTA: Como inicialmente no hay proyecto abierto, deshabilita los botones.
        self.enableControls(False)

    def initMenubar(self):
        '''
        Crea el menú de la aplicación y lo almacena en self.menuBar
        '''
        self.menuBar = QMenuBar()
        self.setMenuBar(self.menuBar)
        self.menuBar.setNativeMenuBar(
            False)  # Necesario para que funcione en MacOS

        # Menu File
        fileMenu = self.menuBar.addMenu("File")
        openAction = QAction('Open image sequence', self)
        fileMenu.addAction(openAction)
        openAction.triggered.connect(self.open)
        exitAction = QAction('Exit', self)
        fileMenu.addAction(exitAction)
        exitAction.triggered.connect(self.close)

        # Menu Display
        displayMenu = self.menuBar.addMenu("Display")
        gen3DAction = QAction('Generate 3D structure', self)
        displayMenu.addAction(gen3DAction)
        gen3DAction.triggered.connect(self.gen3D)

        # Help Display
        helpMenu = self.menuBar.addMenu("Help")
        aboutAction = QAction("About", self)
        helpMenu.addAction(aboutAction)
        # aboutAction.triggered.connect(self.about)  # Una ventana que muestre tu nombre, y eso.

    def initControlLayout(self):
        '''
        Añade los botones para navegar sobre las imágenes en un imgViewerLayout
        denominado self.control_layout.
        '''

        # Alante y atrás
        self.btn_next = QPushButton()
        self.btn_next.setIcon(QIcon('resources/next.png'))
        self.btn_next.setFixedWidth(50)
        self.btn_prev = QPushButton()
        self.btn_prev.setIcon(QIcon('resources/back.png'))
        self.btn_prev.setFixedWidth(50)

        # Borrar y deshacer
        self.btn_clear = QPushButton("Clear")
        self.btn_clear.setFixedWidth(80)
        self.btn_undo = QPushButton("Undo")
        self.btn_undo.setFixedWidth(80)

        # Mostrar o no información de las imágenes anteriores.
        self.check_showC = QCheckBox("Previous Image Curves")
        self.check_showP = QCheckBox("Previous Image Particles")
        self.check_showC.setChecked(False)
        self.check_showP.setChecked(False)

        # Panel para colocar los controles.
        self.control_layout = QHBoxLayout()

        # Coloca los controles en el imgViewerLayout
        self.control_layout.addWidget(self.btn_prev)
        self.control_layout.addWidget(self.btn_next)
        self.control_layout.addStretch()
        self.control_layout.addWidget(self.check_showC)
        self.control_layout.addWidget(self.check_showP)
        self.control_layout.addWidget(self.btn_undo)
        self.control_layout.addWidget(self.btn_clear)

        # Conecta los componentes con las acciones correspondientes.
        self.btn_next.clicked.connect(self.next)
        self.btn_prev.clicked.connect(self.prev)
        self.btn_clear.clicked.connect(self.clear)
        self.btn_undo.clicked.connect(self.undo)
        #self.check_showC.clicked.connect(self.showC)
        #self.check_showP.clicked.connect(self.showP)

    def enableControls(self, state):
        '''
            Habilita o deshabilita los controles y la vista de la imagen.
        '''
        self.imageName.setEnabled(state)
        self.imageView.setEnabled(state)
        self.btn_next.setEnabled(state)
        self.btn_prev.setEnabled(state)
        self.btn_clear.setEnabled(state)
        self.btn_undo.setEnabled(state)
        self.check_showC.setEnabled(state)
        self.check_showP.setEnabled(state)

    def updateWindowSize(self):
        '''
            Aujsta el tamaño de la ventana y la centra
        '''
        # Calcula el tamaño ideal para la vista y la ventana. Para ello determina, el ratio
        # en función la máxima altura o anchura que puede tener la imagen.
        if not self.project is None:
            ratioWidth = (screenSize.getCoords()[2] -
                          100) / (self.project.imgShape[1])
            ratioHeight = (screenSize.getCoords()[3] -
                           150) / (self.project.imgShape[0])
            ratio = ratioWidth if ratioWidth < ratioHeight else ratioHeight
            self.imageView.setFixedWidth(int(self.project.imgShape[1] * ratio))
            self.imageView.setFixedHeight(int(self.project.imgShape[0] *
                                              ratio))
            # Ajusta el tamaño de la ventana.
            self.adjustSize()

        # Centra la ventana
        windowPosition = self.geometry()
        windowPosition.moveCenter(screenSize.center())
        self.move(windowPosition.topLeft())

    def updateImageView(self):
        '''
            Actualiza la imagen
        '''
        # Actualiza el texto y la imagen (recortada).
        self.imageName.setText(
            self.project.imgSequence[self.project.currentImgId])
        utils.cropImageBorders(
            self.project.folder + '/' +
            self.project.imgSequence[self.project.currentImgId])
        self.imageView.loadImage(
            self.project.folder + '/' +
            self.project.imgSequence[self.project.currentImgId])

    def open(self):
        '''
        Abre un proyecto.
        '''
        # Selecciona un directorio de trabajo para cargarlo en un proyecto.
        selectedDirectory = str(
            QFileDialog.getExistingDirectory(self, "Select directory"))

        # Vuelve si se ha cancelado la apertura.
        if len(selectedDirectory) == 0:
            # NOTA: Fíjate que lo que hacemos es dejarlo como estaba. Si había cargado un proyecto, se queda
            #       abierto y los botones y eso habilitados. Si no había nada abierto, sigue sin abrirse.
            return

        # NOTA: Solamente llega aquí si se ha seleccionado un directorio.
        # Se crea el proyecto
        self.project = Project(selectedDirectory)

        # Si en la carpeta seleccionada no hay ninguna imagen, deshabilitamos
        if len(self.project.imgSequence) == 0:
            #self.imageView.scene.clear()
            self.enableControls(False)
            return

        # NOTA: Solamente llega aquí si el proyecto tiene imágenes

        # Actualiza el tamaño de la ventana.
        self.updateWindowSize()

        # Muestra la información actual del proyecto.
        self.updateImageView()

        # Habilita los controles.
        self.enableControls(True)

    def next(self):
        '''
        Pasa a la siguiente imagen.
        '''
        self.project.next()
        self.updateImageView()

    def prev(self):
        '''
        Pasa a la imagen anterior.
        '''
        self.project.prev()
        self.updateImageView()

    def undo(self):
        self.imageView.removeLastCurve()

    def clear(self):
        self.imageView.clear()

    def gen3D(self):
        '''
        Genera la reconstrucción 3D
        '''
        pass
예제 #13
0
 def createCentralWidget(self):
     self.imageView = ImageView(self.mainWindow)
     self.mainWindow.setCentralWidget(self.imageView)