mirror of https://gitlab.com/pamhyr/pamhyr2
pep8: Fix all pep8 format error.
parent
e99037223b
commit
e3555b2c51
|
|
@ -128,7 +128,7 @@ class Plot(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ _translate = QCoreApplication.translate
|
|||
|
||||
|
||||
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)
|
||||
|
||||
self._data = data
|
||||
|
|
@ -103,7 +104,8 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
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()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ class CheckListWindow(PamhyrWindow):
|
|||
def setup_connections(self):
|
||||
self.find(QPushButton, "pushButton_ok").clicked.connect(self.accept)
|
||||
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):
|
||||
self._worker = Worker(self._study, self._checker_list)
|
||||
|
|
|
|||
|
|
@ -108,6 +108,6 @@ class PlotStricklers(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ _translate = QCoreApplication.translate
|
|||
|
||||
|
||||
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)
|
||||
|
||||
self._data = data
|
||||
|
|
@ -87,7 +88,8 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
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()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
|
|
@ -116,12 +118,12 @@ class TableModel(PamhyrTableModel):
|
|||
return self._lst.get(row).end_kp
|
||||
elif self._headers[column] == "begin_strickler":
|
||||
value = self._lst.get(row).begin_strickler
|
||||
if value == None:
|
||||
if value is None:
|
||||
return _translate("Frictions", "Not defined")
|
||||
return str(value)
|
||||
elif self._headers[column] == "end_strickler":
|
||||
value = self._lst.get(row).end_strickler
|
||||
if value == None:
|
||||
if value is None:
|
||||
return _translate("Frictions", "Not defined")
|
||||
return str(value)
|
||||
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ class PlotAC(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class PlotKPZ(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class PlotXY(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
|
|
@ -191,8 +191,10 @@ class PlotXY(PamhyrPlot):
|
|||
self.after_plot_selected.set_visible(False)
|
||||
|
||||
if 0 <= before < self.data.number_profiles:
|
||||
self.before_plot_selected.set_data(self.data.profile(before).x(),
|
||||
self.data.profile(before).y())
|
||||
self.before_plot_selected.set_data(
|
||||
self.data.profile(before).x(),
|
||||
self.data.profile(before).y()
|
||||
)
|
||||
self.before_plot_selected.set_visible(True)
|
||||
|
||||
if 0 <= ind < self.data.number_profiles:
|
||||
|
|
@ -201,8 +203,10 @@ class PlotXY(PamhyrPlot):
|
|||
self.plot_selected.set_visible(True)
|
||||
|
||||
if 0 <= after < self.data.number_profiles:
|
||||
self.after_plot_selected.set_data(self.data.profile(after).x(),
|
||||
self.data.profile(after).y())
|
||||
self.after_plot_selected.set_data(
|
||||
self.data.profile(after).x(),
|
||||
self.data.profile(after).y()
|
||||
)
|
||||
self.after_plot_selected.set_visible(True)
|
||||
|
||||
self.canvas.axes.relim()
|
||||
|
|
|
|||
|
|
@ -106,9 +106,13 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
|
||||
if role == Qt.ToolTipRole:
|
||||
if value.strip().upper() == "RG":
|
||||
return _translate("MainWindowProfile", "Rive gauche")
|
||||
return _translate(
|
||||
"MainWindowProfile", "Rive gauche"
|
||||
)
|
||||
else:
|
||||
return _translate("MainWindowProfile", "Rive droite")
|
||||
return _translate(
|
||||
"MainWindowProfile", "Rive droite"
|
||||
)
|
||||
|
||||
return QVariant()
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,9 @@ class GeometryWindow(PamhyrWindow):
|
|||
name = profile.name + " " + str(profile.kp)
|
||||
|
||||
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}"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,6 @@ class PlotDKP(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ class PlotDischarge(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
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()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ from View.InitialConditions.UndoCommand import (
|
|||
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.PamhyrToolbar import PamhyrPlotToolbar
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class Plot(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -59,12 +59,14 @@ class EditLateralContributionWindow(PamhyrWindow):
|
|||
name = self._pamhyr_name
|
||||
if self._data 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 = (
|
||||
_translate("Edit lateral contribution", self._pamhyr_name) +
|
||||
f" - {study.name} " +
|
||||
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__(
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ _translate = QCoreApplication.translate
|
|||
|
||||
|
||||
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)
|
||||
|
||||
self._data = data
|
||||
|
|
@ -98,7 +99,8 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
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()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ from PyQt5.QtWidgets import (
|
|||
)
|
||||
|
||||
from Model.LateralContribution.LateralContribution import LateralContribution
|
||||
from Model.LateralContribution.LateralContributionList import LateralContributionList
|
||||
from Model.LateralContribution.LateralContributionList import (
|
||||
LateralContributionList
|
||||
)
|
||||
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ from View.RunSolver.Log.Window import SolverLogFileWindow
|
|||
try:
|
||||
from signal import SIGTERM, SIGSTOP, SIGCONT
|
||||
_signal = True
|
||||
except:
|
||||
except Exception:
|
||||
_signal = False
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
|
@ -83,7 +83,8 @@ class SelectSolverWindow(PamhyrDialog):
|
|||
|
||||
def setup_connections(self):
|
||||
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
|
||||
def solver(self):
|
||||
|
|
@ -181,7 +182,7 @@ class SolverLogWindow(PamhyrWindow):
|
|||
self._alarm.timeout.connect(self.update)
|
||||
|
||||
def _log(self, msg, color=None):
|
||||
if type(msg) == str:
|
||||
if msg is str:
|
||||
msg = msg.rsplit('\n')[0]
|
||||
|
||||
if color is not None:
|
||||
|
|
@ -189,7 +190,7 @@ class SolverLogWindow(PamhyrWindow):
|
|||
|
||||
self.find(QTextEdit, "textEdit").append(msg)
|
||||
|
||||
elif type(msg) == int:
|
||||
elif msg is int:
|
||||
color = "blue" if msg == 0 else "red"
|
||||
self.find(QTextEdit, "textEdit")\
|
||||
.append(f"<font color=\"{color}\">" +
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ logger = logging.getLogger()
|
|||
|
||||
|
||||
class Plot(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||
display_current=True, parent=None):
|
||||
def __init__(self, canvas=None, trad=None, data=None,
|
||||
toolbar=None, display_current=True,
|
||||
parent=None):
|
||||
super(Plot, self).__init__(
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
|
|
@ -88,7 +89,7 @@ class Plot(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -19,5 +19,6 @@ class SedimentEditTranslate(SedimentTranslate):
|
|||
"height": _translate("SedimentLayers", "Height"),
|
||||
"d50": _translate("SedimentLayers", "D50"),
|
||||
"sigma": _translate("SedimentLayers", "Sigma"),
|
||||
"critical_constraint": _translate("SedimentLayers", "Critical constraint"),
|
||||
"critical_constraint": _translate("SedimentLayers",
|
||||
"Critical constraint"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Plot(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class Plot(PamhyrPlot):
|
|||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
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()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
|
|
@ -86,7 +87,7 @@ class TableModel(PamhyrTableModel):
|
|||
return self._data.point(row).name
|
||||
elif self._headers[column] == "sl":
|
||||
value = self._data.point(row).sl
|
||||
if value == None:
|
||||
if value is None:
|
||||
text = _translate("SedimentLayers", "Not defined")
|
||||
return text
|
||||
return str(value)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ from View.SedimentLayers.Reach.Profile.Plot import Plot
|
|||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||
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
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ class ComboBoxDelegate(QItemDelegate):
|
|||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
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()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ class TableModel(PamhyrTableModel):
|
|||
return self._data.profile(row).kp
|
||||
if self._headers[column] == "sl":
|
||||
value = self._data.profile(row).sl
|
||||
if value == None:
|
||||
if value is None:
|
||||
text = _translate("SedimentLayers", "Not defined")
|
||||
return text
|
||||
return str(value)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
|||
|
||||
from View.SedimentLayers.Reach.translate import SedimentReachTranslate
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ from PyQt5.QtWidgets import (
|
|||
)
|
||||
|
||||
from Model.LateralContribution.LateralContribution import LateralContribution
|
||||
from Model.LateralContribution.LateralContributionList import LateralContributionList
|
||||
from Model.LateralContribution.LateralContributionList import (
|
||||
LateralContributionList
|
||||
)
|
||||
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ class WindowToolKit(object):
|
|||
|
||||
stream = StringIO(data)
|
||||
rows = csv.reader(stream, delimiter='\t')
|
||||
for l, row in enumerate(rows):
|
||||
if has_header and l == 0:
|
||||
for ind, row in enumerate(rows):
|
||||
if has_header and ind == 0:
|
||||
header = row.copy()
|
||||
continue
|
||||
|
||||
|
|
@ -79,7 +79,9 @@ class WindowToolKit(object):
|
|||
|
||||
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
|
||||
|
||||
Args:
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class ListedSubWindow(object):
|
|||
try:
|
||||
logger.info(
|
||||
f"Open window: {name}: {self.sub_win_cnt}: {win.hash()}")
|
||||
except:
|
||||
except Exception:
|
||||
logger.info(f"Open window: {name}: {self.sub_win_cnt}: X")
|
||||
|
||||
def sub_win_del(self, name):
|
||||
|
|
@ -98,5 +98,5 @@ class ListedSubWindow(object):
|
|||
self.sub_win_list,
|
||||
)
|
||||
)[1]
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ class PamhyrExTimeDelegate(QItemDelegate):
|
|||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
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()))
|
||||
editor.setGeometry(r)
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ class PamhyrTableModel(QAbstractTableModel):
|
|||
def _table_view_configure(self):
|
||||
self._table_view.setModel(self)
|
||||
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.resizeColumnsToContents()
|
||||
|
||||
|
|
@ -131,7 +132,8 @@ class PamhyrTableModel(QAbstractTableModel):
|
|||
return len(self._headers)
|
||||
|
||||
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 QVariant()
|
||||
|
|
|
|||
|
|
@ -75,8 +75,11 @@ class OnpickEvent(object):
|
|||
def select_row_pt_clicked(self, ind: int = 0):
|
||||
"""
|
||||
Args:
|
||||
ind: Indice de la ligne où se trouve le point le plus proche 'visé'.
|
||||
Returns: Sélectionne la ligne (du tableau) correspondant au point le plus proche 'visé' à la suite de l'événement onpick.
|
||||
ind: Indice de la ligne où se trouve le point le plus proche
|
||||
'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:
|
||||
selectionModel = self.tableView.selectionModel()
|
||||
|
|
@ -98,7 +101,8 @@ class OnpickEvent(object):
|
|||
|
||||
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:
|
||||
rows = list(set(
|
||||
|
|
@ -125,15 +129,17 @@ class OnpickEvent(object):
|
|||
try:
|
||||
[pl[0].set_data([], [])
|
||||
for pl in self.pt if len(self.pt) > 1]
|
||||
except:
|
||||
except Exception:
|
||||
logger.info("update_select_point_point: Update issue")
|
||||
|
||||
try:
|
||||
self.update_select_point_point_bis(self.x[row],
|
||||
self.y[row])
|
||||
except:
|
||||
except Exception:
|
||||
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()
|
||||
|
||||
|
|
@ -150,13 +156,18 @@ class OnpickEvent(object):
|
|||
def plot_selection_point(self, x, y):
|
||||
"""
|
||||
Args:
|
||||
x: abscisse
|
||||
y: ordonnée
|
||||
Returns: sélectionne le point du graphique correspond à la ligne sélectionnée dans le tableau.
|
||||
x: abscissa
|
||||
y: ordinate
|
||||
|
||||
Returns: sélectionne le point du graphique correspond à la ligne
|
||||
sélectionnée dans le tableau.
|
||||
"""
|
||||
if self.tableView is not None:
|
||||
self.select_point, = self.ax.plot(x, y,
|
||||
'+', c='Blue', markersize=7)
|
||||
self.select_point, = self.ax.plot(
|
||||
x, y,
|
||||
'+', c='Blue',
|
||||
markersize=7
|
||||
)
|
||||
else:
|
||||
self.select_point, = self.ax.plot([], [])
|
||||
|
||||
|
|
@ -210,7 +221,8 @@ class OnpickEvent(object):
|
|||
@property
|
||||
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()
|
||||
delta_x = abs(xdroite - xgauche)
|
||||
|
|
@ -219,7 +231,8 @@ class OnpickEvent(object):
|
|||
@property
|
||||
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()
|
||||
delta_y = abs(yhaut - ybas)
|
||||
|
|
@ -229,8 +242,9 @@ class OnpickEvent(object):
|
|||
def indice_points_onpick(event):
|
||||
"""
|
||||
Args: event
|
||||
Returns: le(s) indexe(s) du/des point(s) (plus précisement les coordonnées de points) capturé(s)
|
||||
par l'événement onpick (voir picker)
|
||||
Returns: le(s) indexe(s) du/des point(s) (plus précisement les
|
||||
coordonnées de points) capturé(s) par l'événement onpick
|
||||
(voir picker)
|
||||
"""
|
||||
return event.ind
|
||||
|
||||
|
|
@ -238,9 +252,9 @@ class OnpickEvent(object):
|
|||
"""
|
||||
Args:
|
||||
event:
|
||||
Returns: une array contenant les coordonées des points qui se trouvent dans la zone définie par l'événement
|
||||
onpick (voir picker)
|
||||
|
||||
Returns: une array contenant les coordonées des points qui se
|
||||
trouvent dans la zone définie par l'événement onpick
|
||||
(voir picker)
|
||||
"""
|
||||
thisline = event.artist
|
||||
xdata = thisline.get_xdata()
|
||||
|
|
@ -254,8 +268,9 @@ class OnpickEvent(object):
|
|||
"""
|
||||
Args:
|
||||
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
|
||||
onpick (voir picker).
|
||||
Returns: la liste des distances normées (en m) entre les points
|
||||
situés dans la région définie par l'événement onpick
|
||||
(voir picker).
|
||||
"""
|
||||
ind = event.ind
|
||||
thisline = event.artist
|
||||
|
|
@ -282,15 +297,23 @@ class OnpickEvent(object):
|
|||
"""
|
||||
Args:
|
||||
event:
|
||||
Returns: la liste des distances 'visuelles' entre les points situés dans la région définie par l'événement
|
||||
onpick (voir picker).
|
||||
Returns: la liste des distances 'visuelles' entre les points situés
|
||||
dans la région définie par l'événement onpick (voir picker).
|
||||
"""
|
||||
bbox = self.ax.get_window_extent()\
|
||||
.transformed(self.ax.figure.dpi_scale_trans.inverted())
|
||||
ratio_w_sur_h = bbox.width / bbox.height
|
||||
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)
|
||||
]
|
||||
|
||||
|
|
@ -298,9 +321,11 @@ class OnpickEvent(object):
|
|||
|
||||
def distances(self, event):
|
||||
"""
|
||||
Args: event:
|
||||
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)
|
||||
Args:
|
||||
event:
|
||||
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(
|
||||
self.points_onpick(event) - self.position_souris(event),
|
||||
|
|
@ -313,16 +338,21 @@ class OnpickEvent(object):
|
|||
"""
|
||||
Args:
|
||||
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))
|
||||
return dataidx_ecran
|
||||
|
||||
def point_plus_proche_ecran(self, 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):
|
||||
"""
|
||||
|
|
@ -408,8 +438,10 @@ class OnpickEvent(object):
|
|||
cte = event.y * 0.1 / 100
|
||||
|
||||
self.y_pos_text_param_hydrau = event.ydata + cte
|
||||
self.annotation_onclick.set_position((self.pos_x_annotation,
|
||||
self.y_pos_text_param_hydrau))
|
||||
self.annotation_onclick.set_position(
|
||||
(self.pos_x_annotation,
|
||||
self.y_pos_text_param_hydrau)
|
||||
)
|
||||
|
||||
self.ax.callbacks.connect('ylim_changed', self.on_ylims_change)
|
||||
|
||||
|
|
@ -454,7 +486,7 @@ class OnpickEvent(object):
|
|||
try:
|
||||
self.poly_col_bis.remove()
|
||||
self.largeur_au_miroir(event)
|
||||
except:
|
||||
except Exception:
|
||||
self.largeur_au_miroir(event)
|
||||
|
||||
self.annotate_onclick(event)
|
||||
|
|
@ -477,7 +509,8 @@ class OnpickEvent(object):
|
|||
"""
|
||||
Args:
|
||||
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.
|
||||
section_mouillee_totale = 0.
|
||||
|
|
@ -495,7 +528,10 @@ class OnpickEvent(object):
|
|||
perimetre_shapely = 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
|
||||
xs = points_polygone[:, 0]
|
||||
ys = points_polygone[:, 1]
|
||||
|
|
@ -510,7 +546,9 @@ class OnpickEvent(object):
|
|||
polygone_shapely = ShapelyPolygon(points_polygone)
|
||||
aire_calculee_shapely = polygone_shapely.area
|
||||
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 = [
|
||||
(x, y) for (x, y) in zip(xs, ys) if not np.isclose(y, val)
|
||||
]
|
||||
|
|
@ -519,7 +557,9 @@ class OnpickEvent(object):
|
|||
perimetre = 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
|
||||
perimetre += ((x_pt_prec - x_pt_suivant) ** 2 +
|
||||
(y_pt_prec - y_pt_suivant) ** 2) ** (1 / 2)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||
"""
|
||||
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
|
||||
|
||||
Args:
|
||||
|
|
@ -57,12 +58,22 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||
|
||||
if "home" in items:
|
||||
self.toolitems.append(
|
||||
('Home', _translate("Toolbar", 'Default view'), 'home', 'home'))
|
||||
(
|
||||
'Home',
|
||||
_translate("Toolbar", 'Default view'),
|
||||
'home', 'home'
|
||||
)
|
||||
)
|
||||
self.toolitems.append((None, None, None, None))
|
||||
|
||||
if "back/forward" in items:
|
||||
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(
|
||||
"Toolbar", 'Return to next view'), 'forward', 'forward'))
|
||||
self.toolitems.append((None, None, None, None))
|
||||
|
|
@ -77,7 +88,12 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||
|
||||
if "zoom" in items:
|
||||
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))
|
||||
|
||||
icon_zoom = QtGui.QIcon()
|
||||
|
|
@ -104,11 +120,21 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||
|
||||
icon_btn_isometric_view = QtGui.QIcon()
|
||||
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.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(("non_isometric_view", icon_btn_global_view))
|
||||
|
|
|
|||
15
src/init.py
15
src/init.py
|
|
@ -63,13 +63,14 @@ def legal_info():
|
|||
def blue(s): return logger.info(
|
||||
f"{logger_color_blue()}{s}{logger_color_reset()}")
|
||||
|
||||
blue("""`7MM\"""Mq. db `7MMM. ,MMF'`7MMF' `7MMF'`YMM' `MM'`7MM\"""Mq.""")
|
||||
blue(""" MM `MM. ;MM: MMMb dPMM MM MM VMA ,V MM `MM.""")
|
||||
blue(""" MM ,M9 ,V^MM. M YM ,M MM MM MM VMA ,V MM ,M9 pd*"*b.""")
|
||||
blue(""" MMmmdM9 ,M `MM M Mb M' MM MMmmmmmmMM VMMP MMmmdM9 (O) j8""")
|
||||
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. ,-='""")
|
||||
blue(""".JMML. .AMA. .AMMA..JML. `' .JMML..JMML. .JMML. .JMML. .JMML. .JMM. Ammmmmmm""")
|
||||
with open(os.path.abspath(
|
||||
os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"motd.txt"
|
||||
)
|
||||
), "r") as f:
|
||||
for line in f:
|
||||
blue(line.rstrip())
|
||||
|
||||
with open(os.path.abspath(
|
||||
os.path.join(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue