mirror of https://gitlab.com/pamhyr/pamhyr2
add purge in profile and geometry
parent
5164891928
commit
5790bdfe82
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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]:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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/>
|
||||
|
|
|
|||
|
|
@ -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/>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue