diff --git a/src/Model/Geometry/Point.py b/src/Model/Geometry/Point.py index af5df57b..3caf6077 100644 --- a/src/Model/Geometry/Point.py +++ b/src/Model/Geometry/Point.py @@ -16,10 +16,11 @@ # -*- coding: utf-8 -*- +from Model.Tools.PamhyrDB import SQLSubModel from Model.Except import NotImplementedMethodeError -class Point(object): +class Point(SQLSubModel): def __init__(self, id: int = -1, name: str = "", profile=None, status=None, owner_scenario=-1): diff --git a/src/Model/Geometry/PointXYZ.py b/src/Model/Geometry/PointXYZ.py index c4026bad..23960107 100644 --- a/src/Model/Geometry/PointXYZ.py +++ b/src/Model/Geometry/PointXYZ.py @@ -28,7 +28,7 @@ from Model.Geometry.Point import Point logger = logging.getLogger() -class PointXYZ(Point, SQLSubModel): +class PointXYZ(Point): _sub_classes = [] def __init__(self, id: int = -1, @@ -302,6 +302,9 @@ class PointXYZ(Point, SQLSubModel): self._z = float(value) self.modified() + def get_coordinate(self): + return (self._x, self._y, self._z) + def is_nan(self): """ Returns: diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index 79cc9303..eed41d82 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -506,7 +506,7 @@ class ProfileXYZ(Profile, SQLSubModel): Returns: Nothing. """ - point_xyz = PointXYZ(0., 0., 0., profile=self, status=self._status) + point_xyz = PointXYZ(x=0., y=0., z=0., profile=self, status=self._status) self.points.append(point_xyz) self.modified() @@ -522,7 +522,12 @@ class ProfileXYZ(Profile, SQLSubModel): Returns: The new point. """ - point = PointXYZ(0., 0., 0., profile=self, status=self._status) + x, y, z = (0., 0., 0.) + + if len(self._points) >= index: + x, y, z = self._points[index - 1].get_coordinate() + + point = PointXYZ(x=x, y=y, z=z, profile=self, status=self._status) self._points.insert(index, point) self.modified()