Geometry: Points: Fix point insertions pamhyr_id creation and default value.

scenarios
Pierre-Antoine 2025-08-26 10:03:15 +02:00
parent 1457db721b
commit f9a8512477
3 changed files with 13 additions and 4 deletions

View File

@ -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):

View File

@ -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:

View File

@ -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()