예제 #1
0
 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']))
예제 #2
0
 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
예제 #3
0
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
예제 #4
0
 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()
예제 #5
0
 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)