Пример #1
0
    def __init__(self, *args, **kwargs):
        from PYME.LMVis import gl_render3D_shaders as glrender
        from PYME.LMVis import layer_panel
        AUIFrame.__init__(self, *args, **kwargs)

        self.canvas = glrender.LMGLShaderCanvas(self)
        self.AddPage(page=self.canvas, caption='View')

        self.panesToMinimise = []
        self.layerpanel = layer_panel.LayerPane(self,
                                                self.canvas,
                                                caption=None,
                                                add_button=False)
        self.layerpanel.SetSize(self.layerpanel.GetBestSize())
        pinfo = aui.AuiPaneInfo().Name("layerPanel").Right().Caption(
            'Layers').CloseButton(False).MinimizeButton(True).MinimizeMode(
                aui.AUI_MINIMIZE_CAPT_SMART
                | aui.AUI_MINIMIZE_POS_RIGHT)  #.CaptionVisible(False)
        self._mgr.AddPane(self.layerpanel, pinfo)

        self.panesToMinimise.append(pinfo)

        # self._mgr.AddPane(self.optionspanel.CreateToolBar(self),
        #                   aui.AuiPaneInfo().Name("ViewTools").Caption("View Tools").CloseButton(False).
        #                   ToolbarPane().Right().GripperTop())

        for pn in self.panesToMinimise:
            self._mgr.MinimizePane(pn)

        self.Layout()
Пример #2
0
    def __init__(self, parent, options=None):
        AUIFrame.__init__(self,
                          id=wx.ID_ANY,
                          name='smiMainFrame',
                          parent=parent,
                          pos=wx.Point(20, 20),
                          size=wx.Size(600, 800),
                          style=wx.DEFAULT_FRAME_STYLE,
                          title=getattr(options, 'window_title',
                                        'PYME Acquire'))

        self._create_menu()
        self.options = options

        self.snapNum = 0

        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        self.MainFrame = self  #reference to this window for use in scripts etc...
        protocol.MainFrame = self

        self.toolPanels = []
        self.camPanels = []
        self.aqPanels = []
        self.anPanels = []
        self.postInit = []

        self.initDone = False

        self.scope = microscope.microscope()

        self.splash = splashScreen.SplashScreen(self, self.scope)
        self.splash.Show()

        self.sh = wx.py.shell.Shell(
            id=-1,
            parent=self,
            size=wx.Size(-1, -1),
            style=0,
            locals=self.__dict__,
            introText=
            'PYMEAcquire - note that help, license, etc. below is for Python, not PYME\n\n'
        )
        self.AddPage(self.sh, caption='Shell')

        self.CreateToolPanel(getattr(options, 'gui_mode', 'default'))

        self.SetSize((1030, 895))

        self.roi_on = False
        self.bin_on = False

        self.time1 = mytimer.mytimer()

        self.time1.Start(50)

        wx.CallAfter(self._initialize_hardware)

        #self.time1.WantNotification.append(self.runInitScript)
        self.time1.WantNotification.append(self.splash.Tick)
Пример #3
0
    def __init__(self, parent, filename=None, id=wx.ID_ANY, 
                 title="PYME Visualise", pos=wx.DefaultPosition,
                 size=(900,750), style=wx.DEFAULT_FRAME_STYLE, use_shaders=True, cmd_args=None, pipeline_vars = {}):

        # populate about box info
        self._component_name = 'PYMEVisualise'
        self._long_desc = "Visualisation of localisation microscopy data."
        
        AUIFrame.__init__(self, parent, id, title, pos, size, style)
        
        
        self.cmd_args = cmd_args
        self._flags = 0
        
        self.pipeline = pipeline.Pipeline(visFr=self)
        self.pipeline.dataSources.update(pipeline_vars)

        visCore.VisGUICore.__init__(self, use_shaders=use_shaders)
        
        #self.Quads = None
               
        #self.SetMenuBar(self.CreateMenuBar())
        self.CreateMenuBar(use_shaders=use_shaders)

        self.statusbar = self.CreateStatusBar(1, wx.STB_SIZEGRIP)

        self.statusbar.SetStatusText("", 0)
       
        #self._leftWindow1 = wx.Panel(self, -1, size = wx.Size(220, 1000))
        #self._pnl = 0
        
        #initialize the common parts
        ###############################
        #NB: this has to come after the shell has been generated, but before the fold panel
        

        ################################   

        self.MainWindow = self #so we can access from shell
        self.sh = wx.py.shell.Shell(id=-1,
                                    parent=self, size=wx.Size(-1, -1), style=0, locals=self.__dict__,
                                    startupScript=config.get('VisGUI-console-startup-file', None),
              introText='PYMEVisualize - note that help, license, etc. below is for Python, not PYME\n\n')

        #self._mgr.AddPane(self.sh, aui.AuiPaneInfo().
        #                  Name("Shell").Caption("Console").Centre().CloseButton(False).CaptionVisible(False))

        self.AddPage(self.sh, caption='Shell')
             
        
        self.elv = None
        self.colp = None
        self.mdp = None
        self.rav = None

        self.generatedImages = []
        
        self.sh.Execute('from pylab import *')
        self.sh.Execute('from PYME.DSView.dsviewer import View3D')
        
        import os
        if os.getenv('PYMEGRAPHICSFIX'): # fix issue with graphics freezing on some machines (apparently matplotlib related)
            self.sh.Execute('plot()')
            self.sh.Execute('close()')

        #self.workspace = workspaceTree.WorkWrap(self.__dict__)
        ##### Make certain things visible in the workspace tree

        #components of the pipeline
        #col = self.workspace.newColour()
        #self.workspace.addKey('pipeline', col)
        
        #Generated stuff
        #col = self.workspace.newColour()
        #self.workspace.addKey('GeneratedMeasures', col)
        #self.workspace.addKey('generatedImages', col)
        #self.workspace.addKey('objects', col)

        #main window, so we can get everything else if needed
        #col = self.workspace.newColour()
        #self.workspace.addKey('MainWindow', col)

        ######

        #self.workspaceView = workspaceTree.WorkspaceTree(self, workspace=self.workspace, shell=self.sh)
        #self.AddPage(page=wx.StaticText(self, -1, 'foo'), select=False, caption='Workspace')

#        self.glCanvas = gl_render.LMGLCanvas(self)
#        self.AddPage(page=self.glCanvas, select=True, caption='View')
#        self.glCanvas.cmap = pylab.cm.gist_rainbow #pylab.cm.hot

        #self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_MOVE, self.OnMove)
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        #self.Bind(wx.EVT_IDLE, self.OnIdle)
        #self.refv = False

        statusLog.SetStatusDispFcn(self.SetStatus)
        
        
        self.paneHooks.append(self.GenPanels)
        self.CreateFoldPanel()

        #from .layer_panel import CreateLayerPane, CreateLayerPanel
        #CreateLayerPane(sidePanel, self)
        #CreateLayerPanel(self)
        
        self._recipe_manager = recipeGui.PipelineRecipeManager(self.pipeline)
        self._recipe_editor = recipeGui.RecipeView(self, self._recipe_manager)
        self.AddPage(page=self._recipe_editor, select=False, caption='Pipeline Recipe')
        
        self.AddMenuItem('Recipe', 'Reconstruct from open image', self.reconstruct_pipeline_from_open_image)
        self.AddMenuItem('Recipe', 'Reconstruct from image file', self.reconstruct_pipeline_from_image_file)

        if not filename is None:
            def _recipe_callback():
                recipe = getattr(self.cmd_args, 'recipe', None)
                print('Using recipe: %s' % recipe)
                if recipe:
                    from PYME.recipes import modules
                    self.pipeline.recipe.update_from_yaml(recipe)
                    #self.recipeView.SetRecipe(self.pipeline.recipe)
                    self.update_datasource_panel()

                self._recipe_editor.update_recipe_text()
            
            wx.CallLater(50,self.OpenFile,filename, recipe_callback=_recipe_callback)
            #self.refv = False
        
        wx.CallAfter(self.RefreshView)

        nb = self._mgr.GetNotebooks()[0]
        nb.SetSelection(0)
        self.add_common_menu_items()
Пример #4
0
    def __init__(self, image,  parent=None, title='', mode='LM', 
                 size = (800,700), glCanvas=None):
        AUIFrame.__init__(self,parent, -1, title,size=size, pos=wx.DefaultPosition)

        self.mode = mode
        self.glCanvas = glCanvas
        
        self.updateHooks = []
        self.statusHooks = []
        self.installedModules = []
        
        # will store weakrefs to things that modules previously injected into our namespace
        #self._module_injections = weakref.WeakValueDictionary()
        
        self.dataChangeHooks = []

        self.updating = False

        if glCanvas:
            self.glCanvas.wantViewChangeNotification.add(self)

        

        self.timer = mytimer()
        self.timer.Start(10000)

        self.image = image
        #self.image = ImageStack(data = dstack, mdh = mdh, filename = filename, queueURI = queueURI, events = None)
        if not self.image.filename is None and title == '':
            self.SetTitle(self.image.filename)

        

        self.do = DisplayOpts(self.image.data)
        if self.image.data.shape[1] == 1:
            self.do.slice = self.do.SLICE_XZ
        self.do.Optimise()

        if self.image.mdh and 'ChannelNames' in self.image.mdh.getEntryNames():
            chan_names = self.image.mdh.getEntry('ChannelNames')
            if len(chan_names) == self.image.data.shape[3]:
                self.do.names = chan_names

        #self.vp = ArraySettingsAndViewPanel(self, self.image.data, wantUpdates=[self.update], mdh=self.image.mdh)
        #self.view = ArrayViewPanel(self, do=self.do)
        #self.AddPage(self.view, True, 'Data')
        #self._mgr.AddPane(self.vp, aui.AuiPaneInfo().
        #                  Name("Data").Caption("Data").Centre().CloseButton(False).CaptionVisible(False))

        

        self.mainFrame = weakref.ref(self)
        #self.do = self.vp.do
        
        
        tmp_menu = wx.Menu()
        tmp_menu.Append(wx.ID_OPEN, '&Open', "", wx.ITEM_NORMAL)
        tmp_menu.Append(wx.ID_SAVE, "&Save As", "", wx.ITEM_NORMAL)
        tmp_menu.Append(wx.ID_SAVEAS, "&Export Cropped", "", wx.ITEM_NORMAL)
        

        #a submenu for modules to hook and install saving functions into
        self.save_menu = wx.Menu()
        self._menus['Save'] = self.save_menu
        tmp_menu.AppendMenu(-1, 'Save &Results', self.save_menu)
        
        #tmp_menu.AppendSeparator()
        #tmp_menu.Append(wx.ID_CLOSE, "Close", "", wx.ITEM_NORMAL)
        self.menubar.Append(tmp_menu, "File")
        self._menus['File'] = tmp_menu

        self.view_menu = wx.Menu()
        self.menubar.Append(self.view_menu, "&View")
        self._menus['View'] = self.view_menu

        #'extras' menu for modules to install stuff into
        self.mProcessing = wx.Menu()
        self.menubar.Append(self.mProcessing, "&Processing")
        self._menus['Processing'] = self.mProcessing

        # Menu Bar end
        self.Bind(wx.EVT_MENU, self.OnOpen, id=wx.ID_OPEN)
        self.Bind(wx.EVT_MENU, self.OnSave, id=wx.ID_SAVE)
        self.Bind(wx.EVT_MENU, self.OnExport, id=wx.ID_SAVEAS)
        #self.Bind(wx.EVT_MENU, lambda e: self.Close(), id=wx.ID_CLOSE)
        
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
		
        self.statusbar = self.CreateStatusBar(1, wx.STB_SIZEGRIP)

        self.panesToMinimise = []

        modules.loadMode(self.mode, self)
        self.CreateModuleMenu()

        self.add_common_menu_items()

        self.optionspanel = OptionsPanel(self, self.do, thresholdControls=True)
        self.optionspanel.SetSize(self.optionspanel.GetBestSize())
        pinfo = aui.AuiPaneInfo().Name("optionsPanel").Right().Caption('Display Settings').CloseButton(False).MinimizeButton(True).MinimizeMode(aui.AUI_MINIMIZE_CAPT_SMART|aui.AUI_MINIMIZE_POS_RIGHT)#.CaptionVisible(False)
        self._mgr.AddPane(self.optionspanel, pinfo)

        self.panesToMinimise.append(pinfo)

        self._mgr.AddPane(self.optionspanel.CreateToolBar(self), aui.AuiPaneInfo().Name("ViewTools").Caption("View Tools").CloseButton(False).
                      ToolbarPane().Right().GripperTop())

        if self.do.ds.shape[2] > 1:
            from PYME.DSView.modules import playback
            self.playbackpanel = playback.PlayPanel(self, self)
            self.playbackpanel.SetSize(self.playbackpanel.GetBestSize())

            pinfo1 = aui.AuiPaneInfo().Name("playbackPanel").Bottom().Caption('Playback').CloseButton(False).MinimizeButton(True).MinimizeMode(aui.AUI_MINIMIZE_CAPT_SMART|aui.AUI_MINIMIZE_POS_RIGHT)#.CaptionVisible(False)
            self._mgr.AddPane(self.playbackpanel, pinfo1)
            self.do.WantChangeNotification.append(self.playbackpanel.update)

        #self.mWindows =  wx.Menu()
        #self.menubar.append(self.mWindows, '&Composite With')
        self.do.WantChangeNotification.append(self.update)

        self.CreateFoldPanel()
       

        for pn in self.panesToMinimise:
            self._mgr.MinimizePane(pn)
        #self._mgr.MinimizePane(pinfo2)
        self.Layout()

        if 'view' in dir(self):
            sc = np.floor(np.log2(1.0*self.view.Size[0]/self.do.ds.shape[0]))
            #print self.view.Size[0], self.do.ds.shape[0], sc
            self.do.SetScale(sc)
            self.view.Refresh()
        self.update()
        
        self.drop = dt()        
        self.SetDropTarget(self.drop)
        
        self.AddMenuItem('Save', 'To Cluster', self.OnSaveToCluster)
        
        
        
        openViewers[self.image.filename] = self
Пример #5
0
 def _cleanup(self):
     self.timer.Stop()
     del(self.image)
     
     AUIFrame._cleanup(self)
Пример #6
0
 def _cleanup(self):
     self.timer.Stop()
     
     AUIFrame._cleanup(self)