Commit d3edf9e5 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Geometry: Propagate profile information into point.

Showing with 15 additions and 13 deletions
+15 -13
......@@ -3,12 +3,13 @@
from Model.Except import NotImplementedMethodeError
class Point(object):
def __init__(self, name:str = "", status = None):
def __init__(self, name:str = "", profile=None, status = None):
super(Point, self).__init__()
self._status = status
self._name = name
self._profile = profile
self._sl = None
......
......@@ -10,8 +10,8 @@ class PointXYZ(Point, SQLSubModel):
_sub_classes = []
def __init__(self, x:float = 0.0, y:float = 0.0, z:float = 0.0,
name:str = "", status = None):
super(PointXYZ, self).__init__(name=name, status=status)
name:str = "", profile = None, status = None):
super(PointXYZ, self).__init__(name=name, profile=profile, status=status)
self._x = float(x)
self._y = float(y)
......@@ -49,7 +49,7 @@ class PointXYZ(Point, SQLSubModel):
table = execute(
"SELECT ind, name, x, y, z " +
"FROM geometry_pointXYZ " +
f"WHERE profile = {profile}"
f"WHERE profile = {profile.id}"
)
# Create points list
......@@ -67,6 +67,7 @@ class PointXYZ(Point, SQLSubModel):
new = cls(
name = name,
x = x, y = y, z = z,
profile = profile,
status = status
)
......@@ -84,7 +85,7 @@ class PointXYZ(Point, SQLSubModel):
"VALUES (" +
f"{ind}, '{self._sql_format(self._name)}', " +
f"{self.x}, {self.y}, {self.z}, " +
f"{profile}" +
f"{profile.id}" +
")"
)
execute(sql)
......@@ -101,7 +102,7 @@ class PointXYZ(Point, SQLSubModel):
*data
)
else:
valid_header = {'name', 'x', 'y', 'z'}
valid_header = {'name', 'x', 'y', 'z', 'profile'}
d = {}
for i, v in enumerate(data):
h = header[i].strip().lower().split(' ')[0]
......
......@@ -102,7 +102,7 @@ class ProfileXYZ(Profile, SQLSubModel):
status = status
)
data["profile"] = id
data["profile"] = new
new._points = PointXYZ._sql_load(execute, data)
profiles[ind] = new
......@@ -124,7 +124,7 @@ class ProfileXYZ(Profile, SQLSubModel):
)
execute(sql)
data["profile"] = self.id
data["profile"] = self
execute(f"DELETE FROM geometry_pointXYZ WHERE profile = {self.id}")
ind = 0
......@@ -162,11 +162,11 @@ class ProfileXYZ(Profile, SQLSubModel):
try:
if len(header) == 0:
point = PointXYZ(
*data, status=self._status
*data, profile=self, status=self._status
)
else:
valid_header = {'name', 'x', 'y', 'z'}
d = {"status": self._status}
d = {"status": self._status, "profile": self}
for i, v in enumerate(data):
h = header[i].strip().lower().split(' ')[0]
if h in valid_header:
......@@ -219,7 +219,7 @@ class ProfileXYZ(Profile, SQLSubModel):
Nothing.
"""
for point in list_points:
pt = PointXYZ(*point, status=self._status)
pt = PointXYZ(*point, profile=self, status=self._status)
self._points.append(pt)
self._status.modified()
......@@ -243,7 +243,7 @@ class ProfileXYZ(Profile, SQLSubModel):
Returns:
Nothing.
"""
point_xyz = PointXYZ(0., 0., 0., status=self._status)
point_xyz = PointXYZ(0., 0., 0., profile=self, status=self._status)
self._points.append(point_xyz)
self._status.modified()
......@@ -256,7 +256,7 @@ class ProfileXYZ(Profile, SQLSubModel):
Returns:
The new point.
"""
point = PointXYZ(0., 0., 0., status=self._status)
point = PointXYZ(0., 0., 0., profile=self, status=self._status)
self._points.insert(index, point)
self._status.modified()
return point
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment