mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Propagate profile information into point.
parent
3397754abc
commit
d3edf9e5c3
|
|
@ -3,12 +3,13 @@
|
||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
|
||||||
class Point(object):
|
class Point(object):
|
||||||
def __init__(self, name:str = "", status = None):
|
def __init__(self, name:str = "", profile=None, status = None):
|
||||||
super(Point, self).__init__()
|
super(Point, self).__init__()
|
||||||
|
|
||||||
self._status = status
|
self._status = status
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._profile = profile
|
||||||
self._sl = None
|
self._sl = None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
_sub_classes = []
|
_sub_classes = []
|
||||||
|
|
||||||
def __init__(self, x:float = 0.0, y:float = 0.0, z:float = 0.0,
|
def __init__(self, x:float = 0.0, y:float = 0.0, z:float = 0.0,
|
||||||
name:str = "", status = None):
|
name:str = "", profile = None, status = None):
|
||||||
super(PointXYZ, self).__init__(name=name, status=status)
|
super(PointXYZ, self).__init__(name=name, profile=profile, status=status)
|
||||||
|
|
||||||
self._x = float(x)
|
self._x = float(x)
|
||||||
self._y = float(y)
|
self._y = float(y)
|
||||||
|
|
@ -49,7 +49,7 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT ind, name, x, y, z " +
|
"SELECT ind, name, x, y, z " +
|
||||||
"FROM geometry_pointXYZ " +
|
"FROM geometry_pointXYZ " +
|
||||||
f"WHERE profile = {profile}"
|
f"WHERE profile = {profile.id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create points list
|
# Create points list
|
||||||
|
|
@ -67,6 +67,7 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
new = cls(
|
new = cls(
|
||||||
name = name,
|
name = name,
|
||||||
x = x, y = y, z = z,
|
x = x, y = y, z = z,
|
||||||
|
profile = profile,
|
||||||
status = status
|
status = status
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -84,7 +85,7 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{ind}, '{self._sql_format(self._name)}', " +
|
f"{ind}, '{self._sql_format(self._name)}', " +
|
||||||
f"{self.x}, {self.y}, {self.z}, " +
|
f"{self.x}, {self.y}, {self.z}, " +
|
||||||
f"{profile}" +
|
f"{profile.id}" +
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
execute(sql)
|
execute(sql)
|
||||||
|
|
@ -101,7 +102,7 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
*data
|
*data
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
valid_header = {'name', 'x', 'y', 'z'}
|
valid_header = {'name', 'x', 'y', 'z', 'profile'}
|
||||||
d = {}
|
d = {}
|
||||||
for i, v in enumerate(data):
|
for i, v in enumerate(data):
|
||||||
h = header[i].strip().lower().split(' ')[0]
|
h = header[i].strip().lower().split(' ')[0]
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
status = status
|
status = status
|
||||||
)
|
)
|
||||||
|
|
||||||
data["profile"] = id
|
data["profile"] = new
|
||||||
new._points = PointXYZ._sql_load(execute, data)
|
new._points = PointXYZ._sql_load(execute, data)
|
||||||
|
|
||||||
profiles[ind] = new
|
profiles[ind] = new
|
||||||
|
|
@ -124,7 +124,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
)
|
)
|
||||||
execute(sql)
|
execute(sql)
|
||||||
|
|
||||||
data["profile"] = self.id
|
data["profile"] = self
|
||||||
execute(f"DELETE FROM geometry_pointXYZ WHERE profile = {self.id}")
|
execute(f"DELETE FROM geometry_pointXYZ WHERE profile = {self.id}")
|
||||||
|
|
||||||
ind = 0
|
ind = 0
|
||||||
|
|
@ -162,11 +162,11 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
try:
|
try:
|
||||||
if len(header) == 0:
|
if len(header) == 0:
|
||||||
point = PointXYZ(
|
point = PointXYZ(
|
||||||
*data, status=self._status
|
*data, profile=self, status=self._status
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
valid_header = {'name', 'x', 'y', 'z'}
|
valid_header = {'name', 'x', 'y', 'z'}
|
||||||
d = {"status": self._status}
|
d = {"status": self._status, "profile": self}
|
||||||
for i, v in enumerate(data):
|
for i, v in enumerate(data):
|
||||||
h = header[i].strip().lower().split(' ')[0]
|
h = header[i].strip().lower().split(' ')[0]
|
||||||
if h in valid_header:
|
if h in valid_header:
|
||||||
|
|
@ -219,7 +219,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
Nothing.
|
Nothing.
|
||||||
"""
|
"""
|
||||||
for point in list_points:
|
for point in list_points:
|
||||||
pt = PointXYZ(*point, status=self._status)
|
pt = PointXYZ(*point, profile=self, status=self._status)
|
||||||
self._points.append(pt)
|
self._points.append(pt)
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
|
|
||||||
|
|
@ -243,7 +243,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
Returns:
|
Returns:
|
||||||
Nothing.
|
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._points.append(point_xyz)
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
|
|
||||||
|
|
@ -256,7 +256,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
Returns:
|
Returns:
|
||||||
The new point.
|
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._points.insert(index, point)
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
return point
|
return point
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue