From f9a85124776530a49d507c157356ce9b47cf73b0 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 26 Aug 2025 10:03:15 +0200 Subject: [PATCH] Geometry: Points: Fix point insertions pamhyr_id creation and default value. --- src/Model/Geometry/Point.py | 3 ++- src/Model/Geometry/PointXYZ.py | 5 ++++- src/Model/Geometry/ProfileXYZ.py | 9 +++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) 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()