Compare commits

...

3 Commits

9 changed files with 51 additions and 20 deletions

View File

@ -343,7 +343,9 @@ class MeshingWithMageMailleurTT(AMeshingTool):
)
)
)
logger.info("Waiting ...")
proc.waitForFinished()
logger.info(f"Waiting ... Done (status : {proc.exitCode()})")
if proc.exitCode() != 0:
logger.error(
@ -352,7 +354,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
f"{logger_color_reset()}"
)
outputs = proc.readAllStandardOutput()
logger.debug(outputs)
logger.warning(outputs)
errors = proc.readAllStandardError()
logger.error(
@ -418,7 +420,9 @@ class MeshingWithMageMailleurTT(AMeshingTool):
)
)
)
logger.debug("Waiting ...")
proc.waitForFinished()
logger.debug(f"Waiting ... Done (status : {proc.exitCode()})")
if proc.exitCode() != 0:
logger.error(
@ -427,7 +431,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
f"{logger_color_reset()}"
)
outputs = proc.readAllStandardOutput()
logger.debug(outputs)
logger.warning(outputs)
errors = proc.readAllStandardError()
logger.error(

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

@ -396,6 +396,12 @@ class ProfileXYZ(Profile, SQLSubModel):
return name
def modified(self):
super(ProfileXYZ, self).modified()
self.tab_up_to_date = False
self.station_up_to_date = False
def x(self):
return [point.x for point in self.points]
@ -436,12 +442,17 @@ class ProfileXYZ(Profile, SQLSubModel):
Nothing.
"""
for point in list_points:
pt = PointXYZ(*point, profile=self, status=self._status)
self.points.append(pt)
named_args = {
"x": point[0],
"y": point[1],
"z": point[2],
"name": point[3],
}
pt = PointXYZ(id=-1, **named_args, profile=self, status=self._status)
self._points.append(pt)
self.modified()
self.tab_up_to_date = False
self.station_up_to_date = False
def get_point_i(self, index: int) -> PointXYZ:
"""Get point at index.
@ -500,12 +511,10 @@ 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()
self.tab_up_to_date = False
self.station_up_to_date = False
def insert(self, index: int):
"""Insert a new point at index.
@ -516,12 +525,15 @@ class ProfileXYZ(Profile, SQLSubModel):
Returns:
The new point.
"""
point = PointXYZ(0., 0., 0., profile=self, status=self._status)
self.points.insert(index, point)
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()
self.tab_up_to_date = False
self.station_up_to_date = False
return point

View File

@ -617,6 +617,8 @@ class Reach(SQLSubModel):
"""
imported_profiles = []
logger.info(f"import reach from {file_path_name}")
try:
list_profile, list_header = self.read_file_st(str(file_path_name))
profile_header = ["num", "code1", "code2",
@ -629,7 +631,10 @@ class Reach(SQLSubModel):
d[profile_header[i]] = data
prof = ProfileXYZ(
**d, reach=self, status=self._status
id=-1,
**d,
reach=self,
status=self._status
)
prof.import_points(profile)

View File

@ -216,7 +216,6 @@ class Plot(PamhyrPlot):
return event.ydata
def rect_select_callback(self, eclick, erelease):
hyd = self.highlight
x1, y1 = eclick.xdata, eclick.ydata
x2, y2 = erelease.xdata, erelease.ydata

View File

@ -107,7 +107,7 @@ class GeometryProfileTableModel(PamhyrTableModel):
SetXCommand(
self._data, row,
self._data.point(row).x,
value
value.replace(",", ".")
)
)
elif column == 1:
@ -115,7 +115,7 @@ class GeometryProfileTableModel(PamhyrTableModel):
SetYCommand(
self._data, row,
self._data.point(row).y,
value
value.replace(",", ".")
)
)
elif column == 2:
@ -123,7 +123,7 @@ class GeometryProfileTableModel(PamhyrTableModel):
SetZCommand(
self._data, row,
self._data.point(row).z,
value
value.replace(",", ".")
)
)
elif column == 3:

View File

@ -16,6 +16,8 @@
# -*- coding: utf-8 -*-
import logging
from tools import trace, timer
from PyQt5.QtWidgets import (
@ -24,6 +26,8 @@ from PyQt5.QtWidgets import (
from Model.Geometry.Profile import Profile
logger = logging.getLogger()
class SetDataCommand(QUndoCommand):
def __init__(self, profile, index, old_value, new_value):
@ -107,6 +111,7 @@ class AddCommand(QUndoCommand):
self._point = self._profile.insert(self._index)
else:
self._profile.insert_point(self._index, self._point)
self._profile.modified()

View File

@ -201,11 +201,13 @@ class ProfileWindow(PamhyrWindow):
def add(self):
table = self.find(QTableView, "tableView")
if len(table.selectedIndexes()) == 0:
self._tablemodel.insert_row(self._tablemodel.rowCount())
else:
row = self.index_selected_row()
self._tablemodel.insert_row(row + 1)
self.update()
def delete(self):