mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Points: Fix point insertions pamhyr_id creation and default value.
parent
1457db721b
commit
f9a8512477
|
|
@ -16,10 +16,11 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from Model.Tools.PamhyrDB import SQLSubModel
|
||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
|
||||||
|
|
||||||
class Point(object):
|
class Point(SQLSubModel):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
profile=None, status=None,
|
profile=None, status=None,
|
||||||
owner_scenario=-1):
|
owner_scenario=-1):
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ from Model.Geometry.Point import Point
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class PointXYZ(Point, SQLSubModel):
|
class PointXYZ(Point):
|
||||||
_sub_classes = []
|
_sub_classes = []
|
||||||
|
|
||||||
def __init__(self, id: int = -1,
|
def __init__(self, id: int = -1,
|
||||||
|
|
@ -302,6 +302,9 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
self._z = float(value)
|
self._z = float(value)
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
||||||
|
def get_coordinate(self):
|
||||||
|
return (self._x, self._y, self._z)
|
||||||
|
|
||||||
def is_nan(self):
|
def is_nan(self):
|
||||||
"""
|
"""
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
||||||
|
|
@ -506,7 +506,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
Returns:
|
Returns:
|
||||||
Nothing.
|
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.points.append(point_xyz)
|
||||||
|
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
@ -522,7 +522,12 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
Returns:
|
Returns:
|
||||||
The new point.
|
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._points.insert(index, point)
|
||||||
|
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue