Commit 14b5b5e3 authored by Theophile Terraz's avatar Theophile Terraz
Browse files

add purge dialog

Showing with 182 additions and 7 deletions
+182 -7
......@@ -230,11 +230,11 @@ class GeometryProfileTableModel(PamhyrTableModel):
self.endMoveRows()
self.layoutChanged.emit()
def purge(self):
def purge(self, np_purge):
self._undo.push(
PurgeCommand(
self._data, 24
self._data, np_purge
)
)
......
......@@ -20,8 +20,9 @@ import copy
import sys
import csv
from time import time
import logging
from tools import trace, timer
from tools import trace, timer, logger_exception
from Modules import Modules
from PyQt5.QtGui import (
......@@ -46,9 +47,12 @@ from View.Tools.Plot.PamhyrCanvas import MplCanvas
from View.Geometry.Profile.Plot import Plot
from View.Geometry.Profile.Table import GeometryProfileTableModel
from View.Geometry.Profile.Translate import GeometryProfileTranslate
from View.Geometry.PurgeDialog import PurgeDialog
_translate = QCoreApplication.translate
logger = logging.getLogger()
class ProfileWindow(PamhyrWindow):
_pamhyr_ui = "GeometryCrossSection"
......@@ -165,7 +169,6 @@ class ProfileWindow(PamhyrWindow):
if Modules.GEOMETRY not in key:
return
logger.debug("TOTO")
self._tablemodel.layoutChanged.emit()
self._update(redraw=True, propagate=False)
......@@ -258,6 +261,19 @@ class ProfileWindow(PamhyrWindow):
self._tablemodel.purge()
self.update()
def purge(self):
try:
dlg = PurgeDialog(
trad=self._trad,
parent=self
)
if dlg.exec():
self._tablemodel.purge(dlg.np_purge)
self._plot.draw()
except Exception as e:
logger_exception(e)
return
def reverse(self):
self._tablemodel.reverse()
self.update()
......
# PurgeDialog.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
from View.Tools.PamhyrWindow import PamhyrDialog
from PyQt5.QtGui import (
QKeySequence,
)
from PyQt5.QtCore import (
Qt, QVariant, QAbstractTableModel,
)
from PyQt5.QtWidgets import (
QUndoStack, QShortcut, QSpinBox,
)
class PurgeDialog(PamhyrDialog):
_pamhyr_ui = "PurgeOptions"
_pamhyr_name = "Purge"
def __init__(self, trad=None, parent=None):
super(PurgeDialog, self).__init__(
title=trad[self._pamhyr_name],
trad=trad,
options=[],
parent=parent
)
self._init_default_values()
def _init_default_values(self):
self._np_purge = 24
@property
def np_purge(self):
return self._np_purge
def accept(self):
self._np_purge = self.get_spin_box("spinBox_np_purge")
super().accept()
def reject(self):
self.close()
......@@ -259,11 +259,11 @@ class GeometryReachTableModel(PamhyrTableModel):
self.layoutAboutToBeChanged.emit()
self.layoutChanged.emit()
def purge(self):
def purge(self, np_purge):
self._undo.push(
PurgeCommand(
self._data, 24
self._data, np_purge
)
)
self.layoutChanged.emit()
# MeshingDialog.py -- Pamhyr
# UpdateKPDialog.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE
#
# This program is free software: you can redistribute it and/or modify
......
......@@ -57,6 +57,7 @@ from View.Geometry.PlotAC import PlotAC
from View.Geometry.PlotKPZ import PlotKPZ
from View.Geometry.MeshingDialog import MeshingDialog
from View.Geometry.UpdateKPDialog import UpdateKPDialog
from View.Geometry.PurgeDialog import PurgeDialog
from View.Geometry.Translate import GeometryTranslate
from View.Geometry.Profile.Window import ProfileWindow
......@@ -550,6 +551,18 @@ class GeometryWindow(PamhyrWindow):
self._table.purge()
self.update_redraw()
def purge(self):
try:
dlg = PurgeDialog(
trad=self._trad,
parent=self
)
if dlg.exec():
self._table.purge(dlg.np_purge)
except Exception as e:
logger_exception(e)
return
def duplicate(self):
rows = [
row.row() for row in
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>114</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Number of points to keep</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QSpinBox" name="spinBox_np_purge">
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment