def restoreFromCache(self, cachedSettings = None): """ Restore settings for the dataunit and source dataunits from a cache entry """ # Load the cached settings if not cachedSettings: if self.cacheKey: cachedSettings, cacheParser = scripting.getSettingsFromCache(self.cacheKey) if not cachedSettings: Logging.info("No settings found in cache", kw = "caching") return Logging.info("Restoring settings with key %s from cache" % (str(self.cacheKey)), kw = "caching") combined = cachedSettings[0] self.dataUnit.setSettings(combined) sources = self.dataUnit.getSourceDataUnits() for i, setting in enumerate(cachedSettings[1:]): #print "Setting settings of source %d"%i #DataUnitSetting.DataUnitSettings.initialize(setting,sources[i],len(sources),sources[i].getNumberOfTimepoints()) sources[i].setSettings(setting) #tf=setting.get("IntensityTransferFunction") #print setting,tf #print "\n\nSetting itf ",i,"= itf with 0=",tf.GetValue(0),"and 255=",tf.GetValue(255) self.settings = sources[self.settingsIndex].getSettings() self.cacheParser = cacheParser self.updateSettings(force = True)
def readAnnotationsFromCache(self): """ a method that will read cached annotations and show them after the panel has bee initialized """ if not self.annotationsEnabled: return if not self.dataUnit.getDataSource(): return print "Reading annotations from dataunit",self.dataUnit cachedSettings, cacheParser = scripting.getSettingsFromCache(self.dataUnit.getFileName() + "_" + self.dataUnit.getName() + "_annotations") if cachedSettings: self.restoreAnnotations(cachedSettings[0])