def __init__(self, iface, inspectionTimes, recoveryTimes, repairTimes, currentDamageStateProbabilities, timeList, assessmentTimes, mobilizationTimes): self.inspectionTimes = inspectionTimes self.recoveryTimes = recoveryTimes self.repairTimes = repairTimes self.currentDamageStateProbabilities = currentDamageStateProbabilities self.timeList = timeList self.assessmentTimes = assessmentTimes self.mobilizationTimes = mobilizationTimes self.iface = iface self.layer = self.iface.activeLayer() # PAOLO: how many of these files whould be read from here? self.leadTimeDispersion = get_layer_setting( self.layer, 'lead_time_dispersion') if self.leadTimeDispersion is None: self.leadTimeDispersion = float(QSettings().value( 'irmt/lead_time_dispersion', RECOVERY_DEFAULTS['lead_time_dispersion'])) self.repairTimeDispersion = get_layer_setting( self.layer, 'repair_time_dispersion') if self.repairTimeDispersion is None: self.repairTimeDispersion = float(QSettings().value( 'irmt/repair_time_dispersion', RECOVERY_DEFAULTS['repair_time_dispersion']))
def get_times(self, times_type): times = get_layer_setting(self.iface.activeLayer(), times_type) if times is None: times_str = QSettings().value('irmt/%s' % times_type, '') if times_str: times = json.loads(times_str) else: times = list(RECOVERY_DEFAULTS[times_type]) return times
def get_transfer_probabilities(layer): transfer_probabilities = get_layer_setting(layer, 'transfer_probabilities') if transfer_probabilities is None: transfer_probabilities_str = QSettings().value( 'irmt/transfer_probabilities', None) if transfer_probabilities_str is None: transfer_probabilities = list( RECOVERY_DEFAULTS['transfer_probabilities']) else: transfer_probabilities = json.loads(transfer_probabilities_str) return transfer_probabilities
def restore_setting_1d_table(self, name, table): elements = get_layer_setting(self.layer, name) if elements is None: array_str = QSettings().value('irmt/%s' % name, None) if array_str: elements = json.loads(array_str) else: elements = list(RECOVERY_DEFAULTS[name]) table.setRowCount(1) table.setColumnCount(len(elements)) for col in range(table.columnCount()): item = QTableWidgetItem() item.setData(Qt.DisplayRole, elements[col]) table.setItem(0, col, item) table.resizeRowsToContents() table.resizeColumnsToContents()
def restore_setting_number(self, name, widget, val_type): value = get_layer_setting(self.layer, name) if value is None: value = val_type(QSettings().value('irmt/%s' % name, RECOVERY_DEFAULTS[name])) widget.setValue(value)