SL: Fix save for scenario.

scenarios
Pierre-Antoine 2025-09-15 14:13:24 +02:00
parent 303f6bb35b
commit 40cc188815
1 changed files with 13 additions and 2 deletions

View File

@ -40,6 +40,7 @@ class Layer(SQLSubModel):
owner_scenario=owner_scenario
)
self._sl = sl
self._name = name
self._type = type
@ -58,6 +59,7 @@ class Layer(SQLSubModel):
@name.setter
def name(self, name):
self._name = name
self.modified()
@property
def type(self):
@ -66,6 +68,7 @@ class Layer(SQLSubModel):
@type.setter
def type(self, type):
self._type = type
self.modified()
@property
def height(self):
@ -74,6 +77,7 @@ class Layer(SQLSubModel):
@height.setter
def height(self, height):
self._height = float(height)
self.modified()
@property
def d50(self):
@ -82,6 +86,7 @@ class Layer(SQLSubModel):
@d50.setter
def d50(self, d50):
self._d50 = float(d50)
self.modified()
@property
def sigma(self):
@ -90,6 +95,7 @@ class Layer(SQLSubModel):
@sigma.setter
def sigma(self, sigma):
self._sigma = float(sigma)
self.modified()
@property
def critical_constraint(self):
@ -98,6 +104,7 @@ class Layer(SQLSubModel):
@critical_constraint.setter
def critical_constraint(self, critical_constraint):
self._critical_constraint = float(critical_constraint)
self.modified()
@classmethod
def _db_create(cls, execute, ext=""):
@ -199,7 +206,7 @@ class Layer(SQLSubModel):
"SELECT pamhyr_id, deleted, name, type, height, " +
"d50, sigma, critical_constraint, scenario " +
"FROM sedimentary_layer_layer " +
f"WHERE sl = {sl} " +
f"WHERE sl = {sl.pamhyr_id} " +
f"AND scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
"ORDER BY ind ASC"
@ -263,6 +270,10 @@ class Layer(SQLSubModel):
return True
def modified(self):
super(Layer, self).modified()
self._sl.modified()
class SedimentLayer(SQLSubModel):
_sub_classes = [Layer]
@ -433,7 +444,7 @@ class SedimentLayer(SQLSubModel):
if deleted:
sl.set_as_deleted()
data["sl"] = sl.id
data["sl"] = sl
sl._layers = Layer._db_load(execute, data)
loaded.add(pid)