pep8: Fix all pep8 format error.

setup.py
Pierre-Antoine Rouby 2023-10-11 15:08:33 +02:00
parent e99037223b
commit e3555b2c51
36 changed files with 229 additions and 115 deletions

View File

@ -128,7 +128,7 @@ class Plot(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -54,7 +54,8 @@ _translate = QCoreApplication.translate
class ComboBoxDelegate(QItemDelegate): class ComboBoxDelegate(QItemDelegate):
def __init__(self, data=None, mode="type", tab="", trad=None, parent=None): def __init__(self, data=None, mode="type", tab="",
trad=None, parent=None):
super(ComboBoxDelegate, self).__init__(parent) super(ComboBoxDelegate, self).__init__(parent)
self._data = data self._data = data
@ -103,7 +104,8 @@ class ComboBoxDelegate(QItemDelegate):
def updateEditorGeometry(self, editor, option, index): def updateEditorGeometry(self, editor, option, index):
r = QRect(option.rect) r = QRect(option.rect)
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: if self.editor.windowFlags() & Qt.Popup:
if editor.parent() is not None:
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
editor.setGeometry(r) editor.setGeometry(r)

View File

@ -97,7 +97,8 @@ class CheckListWindow(PamhyrWindow):
def setup_connections(self): def setup_connections(self):
self.find(QPushButton, "pushButton_ok").clicked.connect(self.accept) self.find(QPushButton, "pushButton_ok").clicked.connect(self.accept)
self.find(QPushButton, "pushButton_retry").clicked.connect(self.retry) self.find(QPushButton, "pushButton_retry").clicked.connect(self.retry)
self.find(QPushButton, "pushButton_cancel").clicked.connect(self.reject) self.find(QPushButton, "pushButton_cancel")\
.clicked.connect(self.reject)
def setup_thread(self): def setup_thread(self):
self._worker = Worker(self._study, self._checker_list) self._worker = Worker(self._study, self._checker_list)

View File

@ -108,6 +108,6 @@ class PlotStricklers(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -51,7 +51,8 @@ _translate = QCoreApplication.translate
class ComboBoxDelegate(QItemDelegate): class ComboBoxDelegate(QItemDelegate):
def __init__(self, data=None, study=None, mode="stricklers", parent=None): def __init__(self, data=None, study=None,
mode="stricklers", parent=None):
super(ComboBoxDelegate, self).__init__(parent) super(ComboBoxDelegate, self).__init__(parent)
self._data = data self._data = data
@ -87,7 +88,8 @@ class ComboBoxDelegate(QItemDelegate):
def updateEditorGeometry(self, editor, option, index): def updateEditorGeometry(self, editor, option, index):
r = QRect(option.rect) r = QRect(option.rect)
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: if self.editor.windowFlags() & Qt.Popup:
if editor.parent() is not None:
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
editor.setGeometry(r) editor.setGeometry(r)
@ -116,12 +118,12 @@ class TableModel(PamhyrTableModel):
return self._lst.get(row).end_kp return self._lst.get(row).end_kp
elif self._headers[column] == "begin_strickler": elif self._headers[column] == "begin_strickler":
value = self._lst.get(row).begin_strickler value = self._lst.get(row).begin_strickler
if value == None: if value is None:
return _translate("Frictions", "Not defined") return _translate("Frictions", "Not defined")
return str(value) return str(value)
elif self._headers[column] == "end_strickler": elif self._headers[column] == "end_strickler":
value = self._lst.get(row).end_strickler value = self._lst.get(row).end_strickler
if value == None: if value is None:
return _translate("Frictions", "Not defined") return _translate("Frictions", "Not defined")
return str(value) return str(value)

View File

@ -323,7 +323,7 @@ class PlotAC(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -170,7 +170,7 @@ class PlotKPZ(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -141,7 +141,7 @@ class PlotXY(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return
@ -191,8 +191,10 @@ class PlotXY(PamhyrPlot):
self.after_plot_selected.set_visible(False) self.after_plot_selected.set_visible(False)
if 0 <= before < self.data.number_profiles: if 0 <= before < self.data.number_profiles:
self.before_plot_selected.set_data(self.data.profile(before).x(), self.before_plot_selected.set_data(
self.data.profile(before).y()) self.data.profile(before).x(),
self.data.profile(before).y()
)
self.before_plot_selected.set_visible(True) self.before_plot_selected.set_visible(True)
if 0 <= ind < self.data.number_profiles: if 0 <= ind < self.data.number_profiles:
@ -201,8 +203,10 @@ class PlotXY(PamhyrPlot):
self.plot_selected.set_visible(True) self.plot_selected.set_visible(True)
if 0 <= after < self.data.number_profiles: if 0 <= after < self.data.number_profiles:
self.after_plot_selected.set_data(self.data.profile(after).x(), self.after_plot_selected.set_data(
self.data.profile(after).y()) self.data.profile(after).x(),
self.data.profile(after).y()
)
self.after_plot_selected.set_visible(True) self.after_plot_selected.set_visible(True)
self.canvas.axes.relim() self.canvas.axes.relim()

View File

@ -106,9 +106,13 @@ class GeometryProfileTableModel(PamhyrTableModel):
if role == Qt.ToolTipRole: if role == Qt.ToolTipRole:
if value.strip().upper() == "RG": if value.strip().upper() == "RG":
return _translate("MainWindowProfile", "Rive gauche") return _translate(
"MainWindowProfile", "Rive gauche"
)
else: else:
return _translate("MainWindowProfile", "Rive droite") return _translate(
"MainWindowProfile", "Rive droite"
)
return QVariant() return QVariant()

View File

@ -139,7 +139,9 @@ class GeometryWindow(PamhyrWindow):
name = profile.name + " " + str(profile.kp) name = profile.name + " " + str(profile.kp)
return ( return (
f"<font color=\"Grey\">{self._trad['reach']}: {self._reach.name}" + " - " "<font color=\"Grey\">" +
f"{self._trad['reach']}: {self._reach.name}" +
" - " +
f"{self._trad['cross_section']}:</font> {name}" f"{self._trad['cross_section']}:</font> {name}"
) )

View File

@ -74,6 +74,6 @@ class PlotDKP(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -62,6 +62,6 @@ class PlotDischarge(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -79,7 +79,8 @@ class ComboBoxDelegate(QItemDelegate):
def updateEditorGeometry(self, editor, option, index): def updateEditorGeometry(self, editor, option, index):
r = QRect(option.rect) r = QRect(option.rect)
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: if self.editor.windowFlags() & Qt.Popup:
if editor.parent() is not None:
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
editor.setGeometry(r) editor.setGeometry(r)

View File

@ -45,7 +45,9 @@ from View.InitialConditions.UndoCommand import (
DuplicateCommand, DuplicateCommand,
) )
from View.InitialConditions.Table import InitialConditionTableModel, ComboBoxDelegate from View.InitialConditions.Table import (
InitialConditionTableModel, ComboBoxDelegate,
)
from View.Tools.Plot.PamhyrCanvas import MplCanvas from View.Tools.Plot.PamhyrCanvas import MplCanvas
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar

View File

@ -124,7 +124,7 @@ class Plot(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -59,12 +59,14 @@ class EditLateralContributionWindow(PamhyrWindow):
name = self._pamhyr_name name = self._pamhyr_name
if self._data is not None: if self._data is not None:
edge_name = (self._data.edge.name if self._data.edge is not None edge_name = (self._data.edge.name if self._data.edge is not None
else _translate("LateralContribution", "Not associate")) else _translate("LateralContribution",
"Not associate"))
name = ( name = (
_translate("Edit lateral contribution", self._pamhyr_name) + _translate("Edit lateral contribution", self._pamhyr_name) +
f" - {study.name} " + f" - {study.name} " +
f" - {self._data.name} ({self._data.id}) " + f" - {self._data.name} ({self._data.id}) " +
f"({trad.get_dict('long_types')[self._data.lctype]} - {edge_name})" f"({trad.get_dict('long_types')[self._data.lctype]} - " +
f"{edge_name})"
) )
super(EditLateralContributionWindow, self).__init__( super(EditLateralContributionWindow, self).__init__(

View File

@ -54,7 +54,8 @@ _translate = QCoreApplication.translate
class ComboBoxDelegate(QItemDelegate): class ComboBoxDelegate(QItemDelegate):
def __init__(self, data=None, mode="type", tab="", trad=None, parent=None): def __init__(self, data=None, mode="type", tab="",
trad=None, parent=None):
super(ComboBoxDelegate, self).__init__(parent) super(ComboBoxDelegate, self).__init__(parent)
self._data = data self._data = data
@ -98,7 +99,8 @@ class ComboBoxDelegate(QItemDelegate):
def updateEditorGeometry(self, editor, option, index): def updateEditorGeometry(self, editor, option, index):
r = QRect(option.rect) r = QRect(option.rect)
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: if self.editor.windowFlags() & Qt.Popup:
if editor.parent() is not None:
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
editor.setGeometry(r) editor.setGeometry(r)

View File

@ -24,7 +24,9 @@ from PyQt5.QtWidgets import (
) )
from Model.LateralContribution.LateralContribution import LateralContribution from Model.LateralContribution.LateralContribution import LateralContribution
from Model.LateralContribution.LateralContributionList import LateralContributionList from Model.LateralContribution.LateralContributionList import (
LateralContributionList
)
class SetNameCommand(QUndoCommand): class SetNameCommand(QUndoCommand):

View File

@ -48,7 +48,7 @@ from View.RunSolver.Log.Window import SolverLogFileWindow
try: try:
from signal import SIGTERM, SIGSTOP, SIGCONT from signal import SIGTERM, SIGSTOP, SIGCONT
_signal = True _signal = True
except: except Exception:
_signal = False _signal = False
_translate = QCoreApplication.translate _translate = QCoreApplication.translate
@ -83,7 +83,8 @@ class SelectSolverWindow(PamhyrDialog):
def setup_connections(self): def setup_connections(self):
self.find(QPushButton, "pushButton_run").clicked.connect(self.accept) self.find(QPushButton, "pushButton_run").clicked.connect(self.accept)
self.find(QPushButton, "pushButton_cancel").clicked.connect(self.reject) self.find(QPushButton, "pushButton_cancel")\
.clicked.connect(self.reject)
@property @property
def solver(self): def solver(self):
@ -181,7 +182,7 @@ class SolverLogWindow(PamhyrWindow):
self._alarm.timeout.connect(self.update) self._alarm.timeout.connect(self.update)
def _log(self, msg, color=None): def _log(self, msg, color=None):
if type(msg) == str: if msg is str:
msg = msg.rsplit('\n')[0] msg = msg.rsplit('\n')[0]
if color is not None: if color is not None:
@ -189,7 +190,7 @@ class SolverLogWindow(PamhyrWindow):
self.find(QTextEdit, "textEdit").append(msg) self.find(QTextEdit, "textEdit").append(msg)
elif type(msg) == int: elif msg is int:
color = "blue" if msg == 0 else "red" color = "blue" if msg == 0 else "red"
self.find(QTextEdit, "textEdit")\ self.find(QTextEdit, "textEdit")\
.append(f"<font color=\"{color}\">" + .append(f"<font color=\"{color}\">" +

View File

@ -11,8 +11,9 @@ logger = logging.getLogger()
class Plot(PamhyrPlot): class Plot(PamhyrPlot):
def __init__(self, canvas=None, trad=None, data=None, toolbar=None, def __init__(self, canvas=None, trad=None, data=None,
display_current=True, parent=None): toolbar=None, display_current=True,
parent=None):
super(Plot, self).__init__( super(Plot, self).__init__(
canvas=canvas, canvas=canvas,
trad=trad, trad=trad,
@ -88,7 +89,7 @@ class Plot(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -19,5 +19,6 @@ class SedimentEditTranslate(SedimentTranslate):
"height": _translate("SedimentLayers", "Height"), "height": _translate("SedimentLayers", "Height"),
"d50": _translate("SedimentLayers", "D50"), "d50": _translate("SedimentLayers", "D50"),
"sigma": _translate("SedimentLayers", "Sigma"), "sigma": _translate("SedimentLayers", "Sigma"),
"critical_constraint": _translate("SedimentLayers", "Critical constraint"), "critical_constraint": _translate("SedimentLayers",
"Critical constraint"),
} }

View File

@ -91,7 +91,7 @@ class Plot(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -90,7 +90,7 @@ class Plot(PamhyrPlot):
@timer @timer
def update(self, ind=None): def update(self, ind=None):
if self._init == False: if not self._init:
self.draw() self.draw()
return return

View File

@ -61,7 +61,8 @@ class ComboBoxDelegate(QItemDelegate):
def updateEditorGeometry(self, editor, option, index): def updateEditorGeometry(self, editor, option, index):
r = QRect(option.rect) r = QRect(option.rect)
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: if self.editor.windowFlags() & Qt.Popup:
if editor.parent() is not None:
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
editor.setGeometry(r) editor.setGeometry(r)
@ -86,7 +87,7 @@ class TableModel(PamhyrTableModel):
return self._data.point(row).name return self._data.point(row).name
elif self._headers[column] == "sl": elif self._headers[column] == "sl":
value = self._data.point(row).sl value = self._data.point(row).sl
if value == None: if value is None:
text = _translate("SedimentLayers", "Not defined") text = _translate("SedimentLayers", "Not defined")
return text return text
return str(value) return str(value)

View File

@ -30,7 +30,9 @@ from View.SedimentLayers.Reach.Profile.Plot import Plot
from View.Tools.Plot.PamhyrCanvas import MplCanvas from View.Tools.Plot.PamhyrCanvas import MplCanvas
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
from View.SedimentLayers.Reach.Profile.translate import SedimentProfileTranslate from View.SedimentLayers.Reach.Profile.translate import (
SedimentProfileTranslate
)
from View.SedimentLayers.Window import SedimentLayersWindow from View.SedimentLayers.Window import SedimentLayersWindow
_translate = QCoreApplication.translate _translate = QCoreApplication.translate

View File

@ -61,7 +61,8 @@ class ComboBoxDelegate(QItemDelegate):
def updateEditorGeometry(self, editor, option, index): def updateEditorGeometry(self, editor, option, index):
r = QRect(option.rect) r = QRect(option.rect)
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: if self.editor.windowFlags() & Qt.Popup:
if editor.parent() is not None:
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
editor.setGeometry(r) editor.setGeometry(r)
@ -88,7 +89,7 @@ class TableModel(PamhyrTableModel):
return self._data.profile(row).kp return self._data.profile(row).kp
if self._headers[column] == "sl": if self._headers[column] == "sl":
value = self._data.profile(row).sl value = self._data.profile(row).sl
if value == None: if value is None:
text = _translate("SedimentLayers", "Not defined") text = _translate("SedimentLayers", "Not defined")
return text return text
return str(value) return str(value)

View File

@ -33,7 +33,9 @@ from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
from View.SedimentLayers.Reach.translate import SedimentReachTranslate from View.SedimentLayers.Reach.translate import SedimentReachTranslate
from View.SedimentLayers.Window import SedimentLayersWindow from View.SedimentLayers.Window import SedimentLayersWindow
from View.SedimentLayers.Reach.Profile.Window import ProfileSedimentLayersWindow from View.SedimentLayers.Reach.Profile.Window import (
ProfileSedimentLayersWindow
)
_translate = QCoreApplication.translate _translate = QCoreApplication.translate

View File

@ -24,7 +24,9 @@ from PyQt5.QtWidgets import (
) )
from Model.LateralContribution.LateralContribution import LateralContribution from Model.LateralContribution.LateralContribution import LateralContribution
from Model.LateralContribution.LateralContributionList import LateralContributionList from Model.LateralContribution.LateralContributionList import (
LateralContributionList
)
class SetNameCommand(QUndoCommand): class SetNameCommand(QUndoCommand):

View File

@ -70,8 +70,8 @@ class WindowToolKit(object):
stream = StringIO(data) stream = StringIO(data)
rows = csv.reader(stream, delimiter='\t') rows = csv.reader(stream, delimiter='\t')
for l, row in enumerate(rows): for ind, row in enumerate(rows):
if has_header and l == 0: if has_header and ind == 0:
header = row.copy() header = row.copy()
continue continue
@ -79,7 +79,9 @@ class WindowToolKit(object):
return header, values return header, values
def file_dialog(self, select_file=True, callback=lambda x: None, directory=None): def file_dialog(self, select_file=True,
callback=lambda x: None,
directory=None):
"""Open a new file dialog and send result to callback function """Open a new file dialog and send result to callback function
Args: Args:

View File

@ -40,7 +40,7 @@ class ListedSubWindow(object):
try: try:
logger.info( logger.info(
f"Open window: {name}: {self.sub_win_cnt}: {win.hash()}") f"Open window: {name}: {self.sub_win_cnt}: {win.hash()}")
except: except Exception:
logger.info(f"Open window: {name}: {self.sub_win_cnt}: X") logger.info(f"Open window: {name}: {self.sub_win_cnt}: X")
def sub_win_del(self, name): def sub_win_del(self, name):
@ -98,5 +98,5 @@ class ListedSubWindow(object):
self.sub_win_list, self.sub_win_list,
) )
)[1] )[1]
except: except Exception:
return None return None

View File

@ -62,7 +62,8 @@ class PamhyrExTimeDelegate(QItemDelegate):
def updateEditorGeometry(self, editor, option, index): def updateEditorGeometry(self, editor, option, index):
r = QRect(option.rect) r = QRect(option.rect)
if self.editor.windowFlags() & Qt.Popup and editor.parent() is not None: if self.editor.windowFlags() & Qt.Popup:
if editor.parent() is not None:
r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft())) r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
editor.setGeometry(r) editor.setGeometry(r)

View File

@ -109,7 +109,8 @@ class PamhyrTableModel(QAbstractTableModel):
def _table_view_configure(self): def _table_view_configure(self):
self._table_view.setModel(self) self._table_view.setModel(self)
self._table_view.setSelectionBehavior(QAbstractItemView.SelectRows) self._table_view.setSelectionBehavior(QAbstractItemView.SelectRows)
self._table_view.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self._table_view.horizontalHeader()\
.setSectionResizeMode(QHeaderView.Stretch)
self._table_view.setAlternatingRowColors(True) self._table_view.setAlternatingRowColors(True)
self._table_view.resizeColumnsToContents() self._table_view.resizeColumnsToContents()
@ -131,7 +132,8 @@ class PamhyrTableModel(QAbstractTableModel):
return len(self._headers) return len(self._headers)
def headerData(self, section, orientation, role): def headerData(self, section, orientation, role):
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal: if role == Qt.ItemDataRole.DisplayRole:
if orientation == Qt.Orientation.Horizontal:
return self._table_headers[self._headers[section]] return self._table_headers[self._headers[section]]
return QVariant() return QVariant()

View File

@ -75,8 +75,11 @@ class OnpickEvent(object):
def select_row_pt_clicked(self, ind: int = 0): def select_row_pt_clicked(self, ind: int = 0):
""" """
Args: Args:
ind: Indice de la ligne se trouve le point le plus proche 'visé'. ind: Indice de la ligne se trouve le point le plus proche
Returns: Sélectionne la ligne (du tableau) correspondant au point le plus proche 'visé' à la suite de l'événement onpick. 'visé'.
Returns: Sélectionne la ligne (du tableau) correspondant au point le
plus proche 'visé' à la suite de l'événement onpick.
""" """
if self.tableView is not None: if self.tableView is not None:
selectionModel = self.tableView.selectionModel() selectionModel = self.tableView.selectionModel()
@ -98,7 +101,8 @@ class OnpickEvent(object):
def select_point_plot(self): def select_point_plot(self):
""" """
Returns: sélectionne le(s) point(s) du graphique correspondant à la/aux ligne(s) sélectionnée(s) dans le tableau. Returns: sélectionne le(s) point(s) du graphique correspondant à
la/aux ligne(s) sélectionnée(s) dans le tableau.
""" """
if self.tableView is not None: if self.tableView is not None:
rows = list(set( rows = list(set(
@ -125,15 +129,17 @@ class OnpickEvent(object):
try: try:
[pl[0].set_data([], []) [pl[0].set_data([], [])
for pl in self.pt if len(self.pt) > 1] for pl in self.pt if len(self.pt) > 1]
except: except Exception:
logger.info("update_select_point_point: Update issue") logger.info("update_select_point_point: Update issue")
try: try:
self.update_select_point_point_bis(self.x[row], self.update_select_point_point_bis(self.x[row],
self.y[row]) self.y[row])
except: except Exception:
logger.info( logger.info(
"update_select_point_point_bis: Update issue, possible index missing") "update_select_point_point_bis: Update issue, " +
"possible index missing"
)
self.ax.figure.canvas.draw_idle() self.ax.figure.canvas.draw_idle()
@ -150,13 +156,18 @@ class OnpickEvent(object):
def plot_selection_point(self, x, y): def plot_selection_point(self, x, y):
""" """
Args: Args:
x: abscisse x: abscissa
y: ordonnée y: ordinate
Returns: sélectionne le point du graphique correspond à la ligne sélectionnée dans le tableau.
Returns: sélectionne le point du graphique correspond à la ligne
sélectionnée dans le tableau.
""" """
if self.tableView is not None: if self.tableView is not None:
self.select_point, = self.ax.plot(x, y, self.select_point, = self.ax.plot(
'+', c='Blue', markersize=7) x, y,
'+', c='Blue',
markersize=7
)
else: else:
self.select_point, = self.ax.plot([], []) self.select_point, = self.ax.plot([], [])
@ -210,7 +221,8 @@ class OnpickEvent(object):
@property @property
def delta_x(self): def delta_x(self):
"""" """"
Returns: la longueur entre les limites de la vue sur l'axe des x, c'est-à-dire |x_max_visible - x_min_visible|. Returns: la longueur entre les limites de la vue sur l'axe des x,
c'est-à-dire |x_max_visible - x_min_visible|.
""" """
xgauche, xdroite = self.ax.get_xlim() xgauche, xdroite = self.ax.get_xlim()
delta_x = abs(xdroite - xgauche) delta_x = abs(xdroite - xgauche)
@ -219,7 +231,8 @@ class OnpickEvent(object):
@property @property
def delta_y(self): def delta_y(self):
""" """
Returns: la longueur entre les limites de la vue sur l'axe des y, c'est à dire |y_max_visible - y_min_visible|. Returns: la longueur entre les limites de la vue sur l'axe des y,
c'est à dire |y_max_visible - y_min_visible|.
""" """
ybas, yhaut = self.ax.get_ylim() ybas, yhaut = self.ax.get_ylim()
delta_y = abs(yhaut - ybas) delta_y = abs(yhaut - ybas)
@ -229,8 +242,9 @@ class OnpickEvent(object):
def indice_points_onpick(event): def indice_points_onpick(event):
""" """
Args: event Args: event
Returns: le(s) indexe(s) du/des point(s) (plus précisement les coordonnées de points) capturé(s) Returns: le(s) indexe(s) du/des point(s) (plus précisement les
par l'événement onpick (voir picker) coordonnées de points) capturé(s) par l'événement onpick
(voir picker)
""" """
return event.ind return event.ind
@ -238,9 +252,9 @@ class OnpickEvent(object):
""" """
Args: Args:
event: event:
Returns: une array contenant les coordonées des points qui se trouvent dans la zone définie par l'événement Returns: une array contenant les coordonées des points qui se
onpick (voir picker) trouvent dans la zone définie par l'événement onpick
(voir picker)
""" """
thisline = event.artist thisline = event.artist
xdata = thisline.get_xdata() xdata = thisline.get_xdata()
@ -254,8 +268,9 @@ class OnpickEvent(object):
""" """
Args: Args:
event: event:
Returns: la liste des distances normées (en m) entre les points situés dans la région définie par l'événement Returns: la liste des distances normées (en m) entre les points
onpick (voir picker). situés dans la région définie par l'événement onpick
(voir picker).
""" """
ind = event.ind ind = event.ind
thisline = event.artist thisline = event.artist
@ -282,15 +297,23 @@ class OnpickEvent(object):
""" """
Args: Args:
event: event:
Returns: la liste des distances 'visuelles' entre les points situés dans la région définie par l'événement Returns: la liste des distances 'visuelles' entre les points situés
onpick (voir picker). dans la région définie par l'événement onpick (voir picker).
""" """
bbox = self.ax.get_window_extent()\ bbox = self.ax.get_window_extent()\
.transformed(self.ax.figure.dpi_scale_trans.inverted()) .transformed(self.ax.figure.dpi_scale_trans.inverted())
ratio_w_sur_h = bbox.width / bbox.height ratio_w_sur_h = bbox.width / bbox.height
distances_ecran = [ distances_ecran = [
(((x - event.mouseevent.xdata) / (self.delta_x * ratio_w_sur_h)) ** 2 + (
((y - event.mouseevent.ydata) / self.delta_y) ** 2) ** (1 / 2) (
(x - event.mouseevent.xdata) /
(self.delta_x * ratio_w_sur_h)
) ** 2 +
(
(y - event.mouseevent.ydata) /
self.delta_y
) ** 2
) ** (1 / 2)
for (x, y) in self.points_onpick(event) for (x, y) in self.points_onpick(event)
] ]
@ -298,9 +321,11 @@ class OnpickEvent(object):
def distances(self, event): def distances(self, event):
""" """
Args: event: Args:
Returns: la liste des distances entre la position de la souris et tous les points se trouvant dans event:
la zone définie par l'événement onpick ( voir picker) Returns: la liste des distances entre la position de la souris et
tous les points se trouvant dans la zone définie par
l'événement onpick (voir picker)
""" """
distances = np.linalg.norm( distances = np.linalg.norm(
self.points_onpick(event) - self.position_souris(event), self.points_onpick(event) - self.position_souris(event),
@ -313,16 +338,21 @@ class OnpickEvent(object):
""" """
Args: Args:
event: event:
Returns: indice du point le plus proche visuellement de la position du click. Returns: indice du point le plus proche visuellement de la position
du click.
""" """
dataidx_ecran = np.argmin(self.distance_ecran(event)) dataidx_ecran = np.argmin(self.distance_ecran(event))
return dataidx_ecran return dataidx_ecran
def point_plus_proche_ecran(self, event): def point_plus_proche_ecran(self, event):
point_onpick = self.points_onpick(event) point_onpick = self.points_onpick(event)
datapos_ecran = point_onpick[self.index_pt_plus_proche_ecran(event)] datapos_ecran = point_onpick[
self.index_pt_plus_proche_ecran(event)
]
return self.points_onpick(event)[self.index_pt_plus_proche_ecran(event)] return self.points_onpick(event)[
self.index_pt_plus_proche_ecran(event)
]
def index_pt_plus_proche(self, event): def index_pt_plus_proche(self, event):
""" """
@ -408,8 +438,10 @@ class OnpickEvent(object):
cte = event.y * 0.1 / 100 cte = event.y * 0.1 / 100
self.y_pos_text_param_hydrau = event.ydata + cte self.y_pos_text_param_hydrau = event.ydata + cte
self.annotation_onclick.set_position((self.pos_x_annotation, self.annotation_onclick.set_position(
self.y_pos_text_param_hydrau)) (self.pos_x_annotation,
self.y_pos_text_param_hydrau)
)
self.ax.callbacks.connect('ylim_changed', self.on_ylims_change) self.ax.callbacks.connect('ylim_changed', self.on_ylims_change)
@ -454,7 +486,7 @@ class OnpickEvent(object):
try: try:
self.poly_col_bis.remove() self.poly_col_bis.remove()
self.largeur_au_miroir(event) self.largeur_au_miroir(event)
except: except Exception:
self.largeur_au_miroir(event) self.largeur_au_miroir(event)
self.annotate_onclick(event) self.annotate_onclick(event)
@ -477,7 +509,8 @@ class OnpickEvent(object):
""" """
Args: Args:
val: Valeur de la cote Z à laquelle on veut caluler A , p et L. val: Valeur de la cote Z à laquelle on veut caluler A , p et L.
Returns: la valeur de la section mouillée A, du périmètre mouillé p et de la largeur au miroir L. Returns: la valeur de la section mouillée A, du périmètre mouillé p
et de la largeur au miroir L.
""" """
largeur_miroir = 0. largeur_miroir = 0.
section_mouillee_totale = 0. section_mouillee_totale = 0.
@ -495,7 +528,10 @@ class OnpickEvent(object):
perimetre_shapely = 0. perimetre_shapely = 0.
perim_calc = 0. perim_calc = 0.
for polyg, coul in zip(liste_chemins, couleurs[0:len(liste_chemins)]): for polyg, coul in zip(
liste_chemins,
couleurs[0:len(liste_chemins)]
):
points_polygone = polyg.vertices points_polygone = polyg.vertices
xs = points_polygone[:, 0] xs = points_polygone[:, 0]
ys = points_polygone[:, 1] ys = points_polygone[:, 1]
@ -510,7 +546,9 @@ class OnpickEvent(object):
polygone_shapely = ShapelyPolygon(points_polygone) polygone_shapely = ShapelyPolygon(points_polygone)
aire_calculee_shapely = polygone_shapely.area aire_calculee_shapely = polygone_shapely.area
perimetre_shapely = polygone_shapely.length perimetre_shapely = polygone_shapely.length
perimetre_mouille_total_shapely = polygone_shapely.length - largeur_miroir perimetre_mouille_total_shapely = (
polygone_shapely.length - largeur_miroir
)
liste_points_fond = [ liste_points_fond = [
(x, y) for (x, y) in zip(xs, ys) if not np.isclose(y, val) (x, y) for (x, y) in zip(xs, ys) if not np.isclose(y, val)
] ]
@ -519,7 +557,9 @@ class OnpickEvent(object):
perimetre = 0 perimetre = 0
aire = 0 aire = 0
for un_point in liste_points_fond + [(min(liste_points_miroir), val)]: for un_point in liste_points_fond + [
(min(liste_points_miroir), val)
]:
x_pt_suivant, y_pt_suivant = un_point x_pt_suivant, y_pt_suivant = un_point
perimetre += ((x_pt_prec - x_pt_suivant) ** 2 + perimetre += ((x_pt_prec - x_pt_suivant) ** 2 +
(y_pt_prec - y_pt_suivant) ** 2) ** (1 / 2) (y_pt_prec - y_pt_suivant) ** 2) ** (1 / 2)

View File

@ -39,7 +39,8 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
""" """
isometric_signal = pyqtSignal(str) isometric_signal = pyqtSignal(str)
def __init__(self, canvas, parent, items=["home", "move", "zoom", "save"]): def __init__(self, canvas, parent,
items=["home", "move", "zoom", "save"]):
"""PamhyrPlotToolbar """PamhyrPlotToolbar
Args: Args:
@ -57,12 +58,22 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
if "home" in items: if "home" in items:
self.toolitems.append( self.toolitems.append(
('Home', _translate("Toolbar", 'Default view'), 'home', 'home')) (
'Home',
_translate("Toolbar", 'Default view'),
'home', 'home'
)
)
self.toolitems.append((None, None, None, None)) self.toolitems.append((None, None, None, None))
if "back/forward" in items: if "back/forward" in items:
self.toolitems.append( self.toolitems.append(
('Back', _translate("Toolbar", 'Back to previous view'), 'back', 'back')) (
'Back',
_translate("Toolbar", 'Back to previous view'),
'back', 'back'
)
)
self.toolitems.append(('Forward', _translate( self.toolitems.append(('Forward', _translate(
"Toolbar", 'Return to next view'), 'forward', 'forward')) "Toolbar", 'Return to next view'), 'forward', 'forward'))
self.toolitems.append((None, None, None, None)) self.toolitems.append((None, None, None, None))
@ -77,7 +88,12 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
if "zoom" in items: if "zoom" in items:
self.toolitems.append( self.toolitems.append(
('Zoom', _translate("Toolbar", 'Zoom'), 'zoom_to_rect', 'zoom')) (
'Zoom',
_translate("Toolbar", 'Zoom'),
'zoom_to_rect', 'zoom'
)
)
self.toolitems.append((None, None, None, None)) self.toolitems.append((None, None, None, None))
icon_zoom = QtGui.QIcon() icon_zoom = QtGui.QIcon()
@ -104,11 +120,21 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
icon_btn_isometric_view = QtGui.QIcon() icon_btn_isometric_view = QtGui.QIcon()
icon_btn_isometric_view.addPixmap( icon_btn_isometric_view.addPixmap(
QtGui.QPixmap(os.path.abspath(f"{file_path}/../ui/ressources/zoom_fit_11.png"))) QtGui.QPixmap(
os.path.abspath(
f"{file_path}/../ui/ressources/zoom_fit_11.png"
)
)
)
icon_btn_global_view = QtGui.QIcon() icon_btn_global_view = QtGui.QIcon()
icon_btn_global_view.addPixmap( icon_btn_global_view.addPixmap(
QtGui.QPixmap(os.path.abspath(f"{file_path}/../ui/ressources/zoom_fit.png"))) QtGui.QPixmap(
os.path.abspath(
f"{file_path}/../ui/ressources/zoom_fit.png"
)
)
)
icons.append(("isometric_view", icon_btn_isometric_view)) icons.append(("isometric_view", icon_btn_isometric_view))
icons.append(("non_isometric_view", icon_btn_global_view)) icons.append(("non_isometric_view", icon_btn_global_view))

View File

@ -63,13 +63,14 @@ def legal_info():
def blue(s): return logger.info( def blue(s): return logger.info(
f"{logger_color_blue()}{s}{logger_color_reset()}") f"{logger_color_blue()}{s}{logger_color_reset()}")
blue("""`7MM\"""Mq. db `7MMM. ,MMF'`7MMF' `7MMF'`YMM' `MM'`7MM\"""Mq.""") with open(os.path.abspath(
blue(""" MM `MM. ;MM: MMMb dPMM MM MM VMA ,V MM `MM.""") os.path.join(
blue(""" MM ,M9 ,V^MM. M YM ,M MM MM MM VMA ,V MM ,M9 pd*"*b.""") os.path.dirname(__file__),
blue(""" MMmmdM9 ,M `MM M Mb M' MM MMmmmmmmMM VMMP MMmmdM9 (O) j8""") "motd.txt"
blue(""" MM AbmmmqMA M YM.P' MM MM MM MM MM YM. ,;j9""") )
blue(""" MM A' VML M `YM' MM MM MM MM MM `Mb. ,-='""") ), "r") as f:
blue(""".JMML. .AMA. .AMMA..JML. `' .JMML..JMML. .JMML. .JMML. .JMML. .JMM. Ammmmmmm""") for line in f:
blue(line.rstrip())
with open(os.path.abspath( with open(os.path.abspath(
os.path.join( os.path.join(

7
src/motd.txt Normal file
View File

@ -0,0 +1,7 @@
`7MM"""Mq. db `7MMM. ,MMF'`7MMF' `7MMF'`YMM' `MM'`7MM"""Mq.
MM `MM. ;MM: MMMb dPMM MM MM VMA ,V MM `MM.
MM ,M9 ,V^MM. M YM ,M MM MM MM VMA ,V MM ,M9 pd*"*b.
MMmmdM9 ,M `MM M Mb M' MM MMmmmmmmMM VMMP MMmmdM9 (O) j8
MM AbmmmqMA M YM.P' MM MM MM MM MM YM. ,;j9
MM A' VML M `YM' MM MM MM MM MM `Mb. ,-='
.JMML. .AMA. .AMMA..JML. `' .JMML..JMML. .JMML. .JMML. .JMML. .JMM. Ammmmmmm