mirror of https://gitlab.com/pamhyr/pamhyr2
geometry: Some change and fix.
parent
cd69d56c74
commit
d4ce6ce83d
|
|
@ -1,7 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
class Profile(object):
|
||||
def __init__(self, kp:float = 0.0, name:str = "",
|
||||
def __init__(self, num: int = 0,
|
||||
kp:float = 0.0, name:str = "",
|
||||
code1: int = 0, code2: int = 0,
|
||||
_type:str = ""):
|
||||
super(Profile, self).__init__()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from Model.Geometry.PointXYZ import PointXYZ
|
|||
class ProfileXYZ(Profile):
|
||||
def __init__(self, num: int = 0,
|
||||
code1: int = 0, code2: int = 0,
|
||||
nb_point: int = 0,
|
||||
kp: float = 0., name: str = ""):
|
||||
"""ProfileXYZ constructor
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ class ProfileXYZ(Profile):
|
|||
|
||||
def __repr__(self):
|
||||
df = pd.DataFrame(columns=["X", "Y", "Z", "Name"],
|
||||
data=[[p.x, p.y, p.z, p.name] for p in self._list_points])
|
||||
data=[[p.x, p.y, p.z, p.name] for p in self._points])
|
||||
return f"\nProfileXYZ : {self.name}\n{df}"
|
||||
|
||||
@property
|
||||
|
|
@ -58,7 +59,7 @@ class ProfileXYZ(Profile):
|
|||
"""
|
||||
for point in list_points:
|
||||
pt = PointXYZ(*point)
|
||||
self._list_points.append(pt)
|
||||
self._points.append(pt)
|
||||
|
||||
def get_point_i(self, index: int) -> PointXYZ:
|
||||
"""Get point at index.
|
||||
|
|
@ -70,7 +71,7 @@ class ProfileXYZ(Profile):
|
|||
The point.
|
||||
"""
|
||||
try:
|
||||
return self._list_points[index]
|
||||
return self._points[index]
|
||||
except IndexError:
|
||||
raise IndexError(f"Invalid point index: {index}")
|
||||
|
||||
|
|
@ -81,7 +82,7 @@ class ProfileXYZ(Profile):
|
|||
Nothing.
|
||||
"""
|
||||
point_xyz = PointXYZ(0., 0., 0.)
|
||||
self._list_points.append(point_xyz)
|
||||
self._points.append(point_xyz)
|
||||
|
||||
def delete(self, index: int):
|
||||
"""Delete the point at index
|
||||
|
|
@ -93,7 +94,7 @@ class ProfileXYZ(Profile):
|
|||
Nothing.
|
||||
"""
|
||||
try:
|
||||
self._list_points.pop(index)
|
||||
self._points.pop(index)
|
||||
except IndexError:
|
||||
raise IndexError(f"Invalid point index: {index}")
|
||||
|
||||
|
|
@ -107,7 +108,7 @@ class ProfileXYZ(Profile):
|
|||
Nothing.
|
||||
"""
|
||||
profile = ProfileXYZ()
|
||||
self._list_points.insert(index, profile)
|
||||
self._points.insert(index, profile)
|
||||
|
||||
def delete1(self, list_index: list):
|
||||
"""Delete a list of points
|
||||
|
|
@ -124,12 +125,12 @@ class ProfileXYZ(Profile):
|
|||
for idx in indices:
|
||||
# if idx < len(self._list_profiles) :
|
||||
try:
|
||||
self._list_points.pop(idx)
|
||||
self._points.pop(idx)
|
||||
except IndexError:
|
||||
print("Empty list, nothing to delete")
|
||||
except TypeError:
|
||||
if isinstance(list_index, int):
|
||||
self._list_points.pop(list_index)
|
||||
self._points.pop(list_index)
|
||||
print(f"\n{list_index} is not a list\n")
|
||||
else:
|
||||
raise TypeError(
|
||||
|
|
@ -148,16 +149,16 @@ class ProfileXYZ(Profile):
|
|||
return [x for x in lst if not np.isnan(x)]
|
||||
|
||||
def x(self):
|
||||
return [point.x for point in self._list_points]
|
||||
return [point.x for point in self._points]
|
||||
|
||||
def y(self):
|
||||
return [point.y for point in self._list_points]
|
||||
return [point.y for point in self._points]
|
||||
|
||||
def z(self):
|
||||
return [point.z for point in self._list_points]
|
||||
return [point.z for point in self._points]
|
||||
|
||||
def names(self):
|
||||
return [point.name for point in self._list_points]
|
||||
return [point.name for point in self._points]
|
||||
|
||||
def x_max(self):
|
||||
return max(self.filter_isnan(self.x))
|
||||
|
|
|
|||
|
|
@ -302,6 +302,9 @@ class Reach:
|
|||
Returns:
|
||||
Nothing.
|
||||
"""
|
||||
list_profile = []
|
||||
list_header = []
|
||||
|
||||
try:
|
||||
list_profile, list_header = self.read_file_st(str(file_path_name))
|
||||
|
||||
|
|
@ -311,6 +314,7 @@ class Reach:
|
|||
prof.import_points(profile)
|
||||
self._profiles.append(prof)
|
||||
self._update_profile_numbers()
|
||||
|
||||
except FileNotFoundError as e:
|
||||
print(e)
|
||||
exception_message_box(e)
|
||||
|
|
@ -367,8 +371,8 @@ class Reach:
|
|||
else:
|
||||
pass
|
||||
|
||||
if list_profile and list_header:
|
||||
raise FileFormatError(filename, f"{list_profile}, {list_header}")
|
||||
# if list_profile and list_header:
|
||||
# raise FileFormatError(filename, f"{list_profile}, {list_header}")
|
||||
|
||||
print("****** Fichier {} lu et traité en {} secondes *******".format(filename, time() - t0))
|
||||
return list_profile, list_header
|
||||
|
|
|
|||
|
|
@ -237,31 +237,28 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
|||
_translate("MainWindow_reach", "Y (m)"), color='green', fontsize=12
|
||||
)
|
||||
|
||||
self.get_x = self._reach.get_x()
|
||||
self.get_y = self._reach.get_y()
|
||||
self.line_xy = [
|
||||
self.ui.canvas_1.axes.plot(x, y, color='r', lw=1., markersize=3, marker='+')
|
||||
for x, y in zip(self.get_x, self.get_y)
|
||||
self.ui.canvas_1.axes.plot(x, y, color='r', lw=1.,
|
||||
markersize=3, marker='+')
|
||||
for x, y in zip(self._reach.get_x(), self._reach.get_y())
|
||||
]
|
||||
|
||||
self.get_x_complete_list_ld = self._reach.get_x_complete_list_ld()
|
||||
self.get_y_complete_list_ld = self._reach.get_y_complete_list_ld()
|
||||
self.line_ld_1 = self.ui.canvas_1.axes.plot(
|
||||
self.get_x_complete_list_ld,
|
||||
self.get_y_complete_list_ld
|
||||
self._reach.get_guidelines_x(),
|
||||
self._reach.get_guidelines_y()
|
||||
)
|
||||
|
||||
self.plot_selected_1, = self.ui.canvas_1.axes.plot(
|
||||
self._reach.get_x_profile_i(0),
|
||||
self._reach.get_y_profile_i(0),
|
||||
self._reach.get_profile_i(0).x(),
|
||||
self._reach.get_profile_i(0).y(),
|
||||
lw=1., markersize=3,
|
||||
marker='+', color="b"
|
||||
)
|
||||
|
||||
self.plot_selected_1.set_visible(False)
|
||||
self.before_plot_selected_1, = self.ui.canvas_1.axes.plot(
|
||||
self._reach.get_x_profile_i(0),
|
||||
self._reach.get_y_profile_i(0),
|
||||
self._reach.get_profile_i(0).x(),
|
||||
self._reach.get_profile_i(0).y(),
|
||||
lw=1., markersize=3,
|
||||
marker='+', color="k", linestyle="--"
|
||||
)
|
||||
|
|
@ -269,8 +266,8 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
|||
self.before_plot_selected_1.set_visible(False)
|
||||
|
||||
self.after_plot_selected_1, = self.ui.canvas_1.axes.plot(
|
||||
self._reach.get_x_profile_i(0),
|
||||
self._reach.get_y_profile_i(0),
|
||||
self._reach.get_profile_i(0).x(),
|
||||
self._reach.get_profile_i(0).y(),
|
||||
lw=1., markersize=3,
|
||||
marker='+', color="m", linestyle='--'
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue