def __init__(self, parent): wx.Panel.__init__(self, parent, -1, size=(640, 480)) self.sizer = wx.GridBagSizer(5, 5) conf = Configuration.getConfiguration() vtkpath = conf.getConfigItem("VTKPath", "VTK") datapath = conf.getConfigItem("DataPath", "Paths") removevtk = conf.getConfigItem("RemoveOldVTK", "VTK") remember = conf.getConfigItem("RememberPath", "Paths") self.dataBox = wx.StaticBox(self, -1, "Data Files Directory", size=(600, 150)) self.dataBoxSizer = wx.StaticBoxSizer(self.dataBox, wx.VERTICAL) self.dataBoxSizer.SetMinSize(self.dataBox.GetSize()) self.databrowse = filebrowse.DirBrowseButton( self, -1, labelText="Location of Data Files", toolTip="Set the default directory for data files", startDirectory=datapath, ) self.databrowse.SetValue(datapath) self.dataBoxSizer.Add(self.databrowse, 0, wx.EXPAND) self.useLastCheckbox = wx.CheckBox(self, -1, "Use last opened directory as default directory") if type(remember) in [types.StringType, types.UnicodeType]: remember = eval(remember) self.useLastCheckbox.SetValue(remember) self.dataBoxSizer.Add(self.useLastCheckbox) self.cacheBox = wx.StaticBox(self, -1, "Log and cache files", size=(600, 150)) self.cacheBoxSizer = wx.StaticBoxSizer(self.cacheBox, wx.VERTICAL) self.cacheBoxSizer.SetMinSize(self.cacheBox.GetSize()) logdir = scripting.get_log_dir() self.logbrowse = filebrowse.DirBrowseButton( self, -1, labelText="Select log files directory", startDirectory=logdir ) self.logbrowse.SetValue(logdir) previewdir = scripting.get_preview_dir() self.previewbrowse = filebrowse.DirBrowseButton( self, -1, labelText="Select preview files directory", startDirectory=previewdir ) self.previewbrowse.SetValue(previewdir) self.clearCacheButton = wx.Button(self, -1, "Clear logs and previews") self.clearCacheButton.Bind(wx.EVT_BUTTON, self.onClearCache) self.cacheBoxSizer.Add(self.logbrowse, 0, wx.EXPAND) self.cacheBoxSizer.Add(self.previewbrowse, 0, wx.EXPAND) self.cacheBoxSizer.Add(self.clearCacheButton) self.sizer.Add(self.dataBoxSizer, (0, 0), flag=wx.EXPAND | wx.ALL) self.sizer.Add(self.cacheBoxSizer, (1, 0), flag=wx.EXPAND | wx.ALL) self.SetAutoLayout(1) self.SetSizer(self.sizer) self.Layout() self.sizer.Fit(self)
def onClearCache(self, evt): """ Clear the logs and previews directory """ logdir = scripting.get_log_dir() logfiles = glob.glob(os.path.join(logdir, "*.log")) for file in logfiles: os.unlink(file) previewdir = scripting.get_preview_dir() previewfiles = glob.glob(os.path.join(previewdir, "*.png")) for file in previewfiles: os.unlink(file)
def getFromCache(self, datafilename, chName, purpose): """ Retrieve a MIP image from cache """ key = self.getCacheKey(datafilename, chName, purpose) directory = scripting.get_preview_dir() filename = "%s.png" % key filepath = os.path.join(directory, filename) if not os.path.exists(filepath): return None reader = vtk.vtkPNGReader() reader.SetFileName(filepath) reader.Update() return reader.GetOutput()
def storeToCache(self, imagedata, datafilename, chName, purpose): """ Store an image to a cache """ if imagedata.GetScalarType() not in [3, 5]: return key = self.getCacheKey(datafilename, chName, purpose) writer = vtk.vtkPNGWriter() writer.SetInputConnection(imagedata.GetProducerPort()) directory = scripting.get_preview_dir() filename = "%s.png" % key filepath = os.path.join(directory, filename) #print "Storing to cache", filepath writer.SetFileName(filepath) writer.Write()
def writeSettings(self, conf): """ A method that writes out the settings that have been modified in this window. """ datapath = self.databrowse.GetValue() rememberlast = self.useLastCheckbox.GetValue() logpath = unicode(self.logbrowse.GetValue()) if logpath and logpath != scripting.get_log_dir(): conf.setConfigItem("LogPath", "Paths", logpath) print u"Setting logpath to", logpath previewpath = self.previewbrowse.GetValue() if previewpath and previewpath != scripting.get_preview_dir(): conf.setConfigItem("PreviewPath", "Paths", previewpath) print "Setting preview path to", previewpath conf.setConfigItem("DataPath", "Paths", datapath) conf.setConfigItem("RememberPath", "Paths", rememberlast)
def __init__(self, parent): wx.Panel.__init__(self, parent, -1, size=(640, 480)) self.sizer = wx.GridBagSizer(5, 5) conf = Configuration.getConfiguration() vtkpath = conf.getConfigItem("VTKPath", "VTK") datapath = conf.getConfigItem("DataPath", "Paths") removevtk = conf.getConfigItem("RemoveOldVTK", "VTK") remember = conf.getConfigItem("RememberPath", "Paths") self.dataBox = wx.StaticBox(self, -1, "Data Files Directory", size=(600, 150)) self.dataBoxSizer = wx.StaticBoxSizer(self.dataBox, wx.VERTICAL) self.dataBoxSizer.SetMinSize(self.dataBox.GetSize()) self.databrowse = filebrowse.DirBrowseButton( self, -1, labelText="Location of Data Files", toolTip="Set the default directory for data files", startDirectory=datapath) self.databrowse.SetValue(datapath) self.dataBoxSizer.Add(self.databrowse, 0, wx.EXPAND) self.useLastCheckbox = wx.CheckBox( self, -1, "Use last opened directory as default directory") if type(remember) in [types.StringType, types.UnicodeType]: remember = eval(remember) self.useLastCheckbox.SetValue(remember) self.dataBoxSizer.Add(self.useLastCheckbox) self.cacheBox = wx.StaticBox(self, -1, "Log and cache files", size=(600, 150)) self.cacheBoxSizer = wx.StaticBoxSizer(self.cacheBox, wx.VERTICAL) self.cacheBoxSizer.SetMinSize(self.cacheBox.GetSize()) logdir = scripting.get_log_dir() self.logbrowse = filebrowse.DirBrowseButton( self, -1, labelText="Select log files directory", startDirectory=logdir) self.logbrowse.SetValue(logdir) previewdir = scripting.get_preview_dir() self.previewbrowse = filebrowse.DirBrowseButton( self, -1, labelText="Select preview files directory", startDirectory=previewdir) self.previewbrowse.SetValue(previewdir) self.clearCacheButton = wx.Button(self, -1, "Clear logs and previews") self.clearCacheButton.Bind(wx.EVT_BUTTON, self.onClearCache) self.cacheBoxSizer.Add(self.logbrowse, 0, wx.EXPAND) self.cacheBoxSizer.Add(self.previewbrowse, 0, wx.EXPAND) self.cacheBoxSizer.Add(self.clearCacheButton) self.sizer.Add(self.dataBoxSizer, (0, 0), flag=wx.EXPAND | wx.ALL) self.sizer.Add(self.cacheBoxSizer, (1, 0), flag=wx.EXPAND | wx.ALL) self.SetAutoLayout(1) self.SetSizer(self.sizer) self.Layout() self.sizer.Fit(self)