示例#1
0
 def save_setting_2d_table(self,
                           name,
                           table,
                           val_type,
                           check_row_sum_to_1=False):
     elements = [[0 for col in range(table.columnCount())]
                 for row in range(table.rowCount())]
     for row in range(table.rowCount()):
         for col in range(table.columnCount()):
             elements[row][col] = val_type(table.item(row, col).text())
         if check_row_sum_to_1:
             if abs(1 - sum(elements[row])) > 1e-15:
                 raise ValueError(
                     'In table %s, the elements of row %s do not sum to 1' %
                     (name, row + 1))
     QSettings().setValue('irmt/%s' % name, json.dumps(elements))
     save_layer_setting(self.layer, name, elements)
示例#2
0
 def save_setting_1d_table(self, name, table, val_type):
     elements = [0 for col in range(table.columnCount())]
     for col in range(table.columnCount()):
         elements[col] = val_type(table.item(0, col).text())
     QSettings().setValue('irmt/%s' % name, json.dumps(elements))
     save_layer_setting(self.layer, name, elements)
示例#3
0
 def save_setting_number(self, name, value, val_type):
     QSettings().setValue('irmt/%s' % name, value)
     save_layer_setting(self.layer, name, value)