From 1457db721bbe36eb451e710aadb938c015e3d329 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 26 Aug 2025 09:31:23 +0200 Subject: [PATCH] Geometry: Fix profile modifications. --- src/Model/Geometry/ProfileXYZ.py | 8 +++++++- src/View/Geometry/Profile/Plot.py | 1 - src/View/Geometry/Profile/Table.py | 6 +++--- src/View/Geometry/Profile/UndoCommand.py | 5 +++++ src/View/Geometry/Profile/Window.py | 2 ++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index ec9348d9..79cc9303 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -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] @@ -517,7 +523,7 @@ class ProfileXYZ(Profile, SQLSubModel): The new point. """ point = PointXYZ(0., 0., 0., profile=self, status=self._status) - self.points.insert(index, point) + self._points.insert(index, point) self.modified() self.tab_up_to_date = False diff --git a/src/View/Geometry/Profile/Plot.py b/src/View/Geometry/Profile/Plot.py index a9c26264..c8a948ba 100644 --- a/src/View/Geometry/Profile/Plot.py +++ b/src/View/Geometry/Profile/Plot.py @@ -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 diff --git a/src/View/Geometry/Profile/Table.py b/src/View/Geometry/Profile/Table.py index 18e589df..98daa77c 100644 --- a/src/View/Geometry/Profile/Table.py +++ b/src/View/Geometry/Profile/Table.py @@ -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: diff --git a/src/View/Geometry/Profile/UndoCommand.py b/src/View/Geometry/Profile/UndoCommand.py index 239bd788..5738fe7d 100644 --- a/src/View/Geometry/Profile/UndoCommand.py +++ b/src/View/Geometry/Profile/UndoCommand.py @@ -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() diff --git a/src/View/Geometry/Profile/Window.py b/src/View/Geometry/Profile/Window.py index 9f2ee123..3f0fc152 100644 --- a/src/View/Geometry/Profile/Window.py +++ b/src/View/Geometry/Profile/Window.py @@ -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):