diff --git a/src/Model/Geometry/Profile.py b/src/Model/Geometry/Profile.py index 1a36164d3535760a79839164f1540d91651336c2..6bf4979d6857805d00de2b029591d87927cb2696 100644 --- a/src/Model/Geometry/Profile.py +++ b/src/Model/Geometry/Profile.py @@ -295,6 +295,11 @@ class Profile(object): ) self._status.modified() + @timer + def reverse(self): + self._points.reverse() + self._status.modified() + # Sediment Layers def get_sl(self): diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index 0df81d3043d1fe0defd6f3c3e2c4e5986f82c5ed..54653a326c06c4dece408af8dbf082cb63e7ff2c 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -544,15 +544,12 @@ class ProfileXYZ(Profile, SQLSubModel): if self.point(i).point_is_named(): area.append(9999999.999) nb_named += 1 - print(self.point(i).name.strip()) else: area.append(PointXYZ.areatriangle3d(self.point(i-1),self.point(i),self.point(i+1))) area.append(0.0) - print(area) while (self.nb_points > max(np_purge, nb_named)): to_rm = np.argmin(area[1:self.nb_points-1])+1 - print('to rm = ', to_rm) self.delete_i([to_rm]) area.pop(to_rm) for i in [to_rm-1, to_rm]: diff --git a/src/View/Geometry/Profile/Table.py b/src/View/Geometry/Profile/Table.py index c23eeb6f803b115b9c95ef8017e3b2316a19a1e4..21e202f8ee9fafffe0d4bec3b275355592118f0c 100644 --- a/src/View/Geometry/Profile/Table.py +++ b/src/View/Geometry/Profile/Table.py @@ -250,6 +250,26 @@ class GeometryProfileTableModel(PamhyrTableModel): self.endMoveRows() self.layoutChanged.emit() + def purge(self): + + self._undo.push( + PurgeCommand( + self._data, 24 + ) + ) + + self.layoutChanged.emit() + + def reverse(self): + + self._undo.push( + ReverseCommand( + self._data + ) + ) + + self.layoutChanged.emit() + def paste(self, row, header, data): if row > self._data.number_points: return diff --git a/src/View/Geometry/Profile/UndoCommand.py b/src/View/Geometry/Profile/UndoCommand.py index 800bd4e0bac1fd346eace58eb0815a2c51c8d3c3..a381feee20bcc1ca8b946c9c1e55d931b83965d5 100644 --- a/src/View/Geometry/Profile/UndoCommand.py +++ b/src/View/Geometry/Profile/UndoCommand.py @@ -169,6 +169,34 @@ class MoveCommand(QUndoCommand): self._profile.move_down_point(self._i) +class ReverseCommand(QUndoCommand): + def __init__(self, profile): + QUndoCommand.__init__(self) + + self._profile = profile + + def undo(self): + self._profile.reverse() + + def redo(self): + self._profile.reverse() + + +class PurgeCommand(QUndoCommand): + def __init__(self, profile, np_purge): + QUndoCommand.__init__(self) + + self._profile = profile + self._old = self._profile.points.copy() + self._np_purge = np_purge + + def undo(self): + self._profile._points = self._old.copy() + + def redo(self): + self._profile.purge(self._np_purge) + + class PasteCommand(QUndoCommand): def __init__(self, profile, row, points): QUndoCommand.__init__(self) diff --git a/src/View/Geometry/Profile/Window.py b/src/View/Geometry/Profile/Window.py index 9a274c9f9f15b69758e4194eeed62131b9c17269..f9cb384d1f11a693d3b414f12ef0f3ed92684b94 100644 --- a/src/View/Geometry/Profile/Window.py +++ b/src/View/Geometry/Profile/Window.py @@ -125,6 +125,8 @@ class ProfileWindow(PamhyrWindow): "action_down": self.move_down, "action_add": self.add, "action_delete": self.delete, + "action_purge": self.purge, + "action_reverse": self.reverse, } for action in actions: @@ -137,6 +139,12 @@ class ProfileWindow(PamhyrWindow): self.update_plot() self._propagate_update(key=Modules.GEOMETRY) + def _update(self, redraw=False, propagate=True): + if redraw: + self.update_plot() + if propagate: + self._propagate_update(key=Modules.GEOMETRY) + def update_plot(self): self._tablemodel.blockSignals(True) @@ -145,6 +153,14 @@ class ProfileWindow(PamhyrWindow): self._tablemodel.blockSignals(False) + def _propagated_update(self, key=Modules(0)): + if Modules.GEOMETRY not in key: + return + + print("=====TOTO=====") + self._tablemodel.layoutChanged.emit() + self._update(redraw=True, propagate=False) + def index_selected_row(self): table = self.find(QTableView, "tableView") rows = table.selectionModel()\ @@ -221,6 +237,14 @@ class ProfileWindow(PamhyrWindow): self.update() + def purge(self): + self._tablemodel.purge() + self.update() + + def reverse(self): + self._tablemodel.reverse() + self.update() + def _copy(self): table = self.find(QTableView, "tableView") rows = table.selectionModel().selectedRows() diff --git a/src/View/Geometry/Table.py b/src/View/Geometry/Table.py index 169771cbd98e6a14148ed1a2bee3f01b58fb0bb2..26baa7fb23d84d33a5b7971e7169f1c19f007ed9 100644 --- a/src/View/Geometry/Table.py +++ b/src/View/Geometry/Table.py @@ -246,3 +246,12 @@ class GeometryReachTableModel(PamhyrTableModel): self.layoutAboutToBeChanged.emit() self.layoutChanged.emit() + + def purge(self): + + self._undo.push( + PurgeCommand( + self._data, 24 + ) + ) + self.layoutChanged.emit() diff --git a/src/View/Geometry/UndoCommand.py b/src/View/Geometry/UndoCommand.py index 5c587c0122f99d52cc9486db4a4ce20b54fdba1f..addd0752794fff33e0b633a49352c546bdac0422 100644 --- a/src/View/Geometry/UndoCommand.py +++ b/src/View/Geometry/UndoCommand.py @@ -249,3 +249,23 @@ class MeshingCommand(QUndoCommand): for profile in self._new_profiles: self._reach.insert_profile(0, profile) + + +class PurgeCommand(QUndoCommand): + def __init__(self, reach, np_purge): + QUndoCommand.__init__(self) + + self._reach = reach + self._np_purge = np_purge + + self._old = [] + for profile in self._reach.profiles: + self._old.append(profile.points.copy()) + + def undo(self): + for i in range(self._reach.number_profiles): + self._reach.profiles[i]._points = self._old[i].copy() + + def redo(self): + for profile in self._reach._profiles: + profile.purge(self._np_purge) diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index d8bcc06b47c8e913659c5b26ccb13637197f40c0..a0efa860c2c362fa74a3656ece1f9708b1f17ef2 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -188,6 +188,8 @@ class GeometryWindow(PamhyrWindow): "action_delete": self.delete, "action_edit": self.edit_profile, "action_meshing": self.edit_meshing, + "action_update_kp": self.update_kp, + "action_purge": self.purge, } for action in actions: @@ -227,7 +229,7 @@ class GeometryWindow(PamhyrWindow): self._propagate_update(key=Modules.GEOMETRY) def _propagated_update(self, key=Modules(0)): - if Modules.NETWORK not in key: + if Modules.NETWORK not in key and Modules.GEOMETRY not in key: return self._update(propagate=False) @@ -505,6 +507,13 @@ class GeometryWindow(PamhyrWindow): self._table.move_down(row) self.select_current_profile() + def update_kp(self): + pass + + def purge(self): + self._table.purge() + self.update_redraw() + def duplicate(self): rows = [ row.row() for row in diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index f4d8bad7fbe785ef4b198f2c13f4ab07f60599f0..ca6371a524815bb6a59baae5abb0f7ae02fdc6d1 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -445,9 +445,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): logger.debug(f"Propagation of {keys}") for _, window in self.sub_win_list: window._propagated_update(key=keys) + self._do_propagate_update_rec(window, keys) self._tab_widget_checker.update(modules=keys) + def _do_propagate_update_rec(self, window, keys): + for _, win in window.sub_win_list: + win._propagated_update(key=keys) + self._do_propagate_update_rec(win, keys) + def update(self): self.set_title() diff --git a/src/View/ui/GeometryCrossSection.ui b/src/View/ui/GeometryCrossSection.ui index 6e6d62a522c2fafdd7918dee64371b54608f890f..f7c9158eb1a2a26836ce9d9361823b0bb163e2b2 100644 --- a/src/View/ui/GeometryCrossSection.ui +++ b/src/View/ui/GeometryCrossSection.ui @@ -58,6 +58,8 @@ <addaction name="action_sort_des"/> <addaction name="action_up"/> <addaction name="action_down"/> + <addaction name="action_purge"/> + <addaction name="action_reverse"/> </widget> <action name="action_add"> <property name="icon"> @@ -131,6 +133,22 @@ <string>Sort reversed points by nearest neighbor</string> </property> </action> + <action name="action_purge"> + <property name="text"> + <string>Purge</string> + </property> + <property name="toolTip"> + <string>Purge the cross-section to keep a given number of points</string> + </property> + </action> + <action name="action_reverse"> + <property name="text"> + <string>Reverse</string> + </property> + <property name="toolTip"> + <string>Reverse the points order</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/src/View/ui/GeometryReach.ui b/src/View/ui/GeometryReach.ui index 95e25be170ed4be477e0892d432fe5bcde4581ac..22e5404324d2a74789346feeac75b12277c68811 100644 --- a/src/View/ui/GeometryReach.ui +++ b/src/View/ui/GeometryReach.ui @@ -127,6 +127,8 @@ <addaction name="action_down"/> <addaction name="action_export"/> <addaction name="action_meshing"/> + <addaction name="action_update_kp"/> + <addaction name="action_purge"/> </widget> <action name="action_import"> <property name="text"> @@ -233,6 +235,22 @@ <string>Meshing</string> </property> </action> + <action name="action_update_kp"> + <property name="text"> + <string>Update KP</string> + </property> + <property name="toolTip"> + <string>Recompute KP</string> + </property> + </action> + <action name="action_purge"> + <property name="text"> + <string>Purge</string> + </property> + <property name="toolTip"> + <string>Purge cross-sections to keep a given number of points</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/src/lang/fr.ts b/src/lang/fr.ts index fb23ef40b71230cd7399f82370f770f2fd2533f1..4b3a4a4d4ba613ce312a551c2dd776f42103ee11 100644 --- a/src/lang/fr.ts +++ b/src/lang/fr.ts @@ -1482,12 +1482,12 @@ <translation>Éditer la géométrie</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="136"/> + <location filename="../View/ui/GeometryReach.ui" line="138"/> <source>Import geometry</source> <translation>Importer une géométrie</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="144"/> + <location filename="../View/ui/GeometryReach.ui" line="146"/> <source>Export geometry</source> <translation>Exporter la géométrie</translation> </message> @@ -1852,7 +1852,7 @@ <translation>Exporter les données brutes</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="80"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="82"/> <source>delete</source> <translation>supprimer</translation> </message> @@ -1947,57 +1947,57 @@ <translation>resultats</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="68"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="70"/> <source>add</source> <translation>Ajouter</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="71"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="73"/> <source>Add a point on cross-section</source> <translation>Ajouter un point à la section en travers</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="83"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="85"/> <source>Delete selected point(s)</source> <translation>Supprimer le(s) point(s) sélectionné(s)</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="92"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="94"/> <source>up</source> <translation>Monter</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="95"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="97"/> <source>Move up selected point(s)</source> <translation>Déplacer le point sélectionné vers le haut</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="104"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="106"/> <source>down</source> <translation>Descendre</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="107"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="109"/> <source>Mode down selected point(s)</source> <translation>Déplacer le point sélectionné vers le bas</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="116"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="118"/> <source>sort_asc</source> <translation>sort_asc</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="119"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="121"/> <source>Sort points by nearest neighbor</source> <translation>Trier les points par leurs plus proches voisins</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="128"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="130"/> <source>sort_des</source> <translation>sort_des</translation> </message> <message> - <location filename="../View/ui/GeometryCrossSection.ui" line="131"/> + <location filename="../View/ui/GeometryCrossSection.ui" line="133"/> <source>Sort reversed points by nearest neighbor</source> <translation>Trie inverser les points par leurs plus proche voisins</translation> </message> @@ -2112,52 +2112,52 @@ <translation>Éditer les couches sédimentaires</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="133"/> + <location filename="../View/ui/GeometryReach.ui" line="135"/> <source>Import</source> <translation>Importer</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="156"/> + <location filename="../View/ui/GeometryReach.ui" line="158"/> <source>Add a cross-section</source> <translation>Ajouter une section en travers</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="168"/> + <location filename="../View/ui/GeometryReach.ui" line="170"/> <source>Delete selected cross-section(s)</source> <translation>Supprimer la(es) section(s) en travers sélectionnée(s)</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="177"/> + <location filename="../View/ui/GeometryReach.ui" line="179"/> <source>edit</source> <translation>éditer</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="180"/> + <location filename="../View/ui/GeometryReach.ui" line="182"/> <source>Edit selected cross section(s)</source> <translation>Éditer la(es) section(s) en travers sélectionnée(s)</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="192"/> + <location filename="../View/ui/GeometryReach.ui" line="194"/> <source>Sort cross-sections by ascending KP</source> <translation>Trier les sections en travers par PK croissant</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="204"/> + <location filename="../View/ui/GeometryReach.ui" line="206"/> <source>Sort cross-sections by descending KP</source> <translation>Trier les sections en travers par PK décroissant</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="216"/> + <location filename="../View/ui/GeometryReach.ui" line="218"/> <source>Move up selected cross-section(s)</source> <translation>Déplacer la(s) section(s) en travers vers le haut</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="228"/> + <location filename="../View/ui/GeometryReach.ui" line="230"/> <source>Move down selected cross-section(s)</source> <translation>Déplacer la(es) section(s) en travers vers le bas</translation> </message> <message> - <location filename="../View/ui/GeometryReach.ui" line="233"/> + <location filename="../View/ui/GeometryReach.ui" line="235"/> <source>Meshing</source> <translation>Maillage</translation> </message> @@ -2261,6 +2261,41 @@ <source>Edit the study information</source> <translation>Éditer les information de l'étude</translation> </message> + <message> + <location filename="../View/ui/GeometryReach.ui" line="240"/> + <source>Update KP</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../View/ui/GeometryReach.ui" line="243"/> + <source>Recompute KP</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../View/ui/GeometryCrossSection.ui" line="138"/> + <source>Purge</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../View/ui/GeometryReach.ui" line="251"/> + <source>Purge cross-sections to keep a given number of points</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../View/ui/GeometryCrossSection.ui" line="141"/> + <source>Purge the cross-section to keep a given number of points</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../View/ui/GeometryCrossSection.ui" line="146"/> + <source>Reverse</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../View/ui/GeometryCrossSection.ui" line="149"/> + <source>Reverse the points order</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>MainWindowProfile</name>