diff --git a/src/Model/Geometry/Point.py b/src/Model/Geometry/Point.py index 041603df38d3cb337c5206e2cd93476766d57158..cdebd17eb6395bc8be1006107d3d0ab0d3d4df37 100644 --- a/src/Model/Geometry/Point.py +++ b/src/Model/Geometry/Point.py @@ -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 diff --git a/src/Model/Geometry/PointXYZ.py b/src/Model/Geometry/PointXYZ.py index 0fecd1ea8dfa96563902729a04e24fb61ccbb4bc..4e55c7b8ab1d982f0f80c3a196343682f12302f1 100644 --- a/src/Model/Geometry/PointXYZ.py +++ b/src/Model/Geometry/PointXYZ.py @@ -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] diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index d368b9812feef667efbd957723b70bbb0cc83258..af3107692d593823284f2061c0412ee5501361b6 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -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