geometry: Deactive some old custom style and minor change.

mesh
Pierre-Antoine Rouby 2023-04-07 10:48:27 +02:00
parent ca48ed08d5
commit fa9d95c7e7
7 changed files with 200 additions and 185 deletions

View File

@ -36,9 +36,18 @@ class GeometryWindow(QMainWindow, WindowToolKit):
self.tableView_header = self.ui.tableView_header self.tableView_header = self.ui.tableView_header
self.model = None self.model = None
self.filename = None self.filename = None
self.setup_model() self.setup_model()
self.setup_connections() self.setup_connections()
def setup_model(self):
self.model = qtableview_reach.PandasModelEditableCreateReach(
headers = self.ui.tableView_header,
rows = self._reach
)
self.tableView.setModel(self.model)
self.tableView.setItemDelegate(qtableview_reach.Delegate())
def setup_connections(self): def setup_connections(self):
self.ui.btn_open.clicked.connect(self.open_file_dialog) self.ui.btn_open.clicked.connect(self.open_file_dialog)
self.ui.btn_sort_asc.clicked.connect(self.sort_ascending) self.ui.btn_sort_asc.clicked.connect(self.sort_ascending)
@ -55,11 +64,6 @@ class GeometryWindow(QMainWindow, WindowToolKit):
self.ui.btn_slider_down.clicked.connect(self.increment_value_slider) self.ui.btn_slider_down.clicked.connect(self.increment_value_slider)
self.ui.btn_move_up.clicked.connect(self.changed_profile_slot) self.ui.btn_move_up.clicked.connect(self.changed_profile_slot)
def setup_model(self):
self.model = qtableview_reach.PandasModelEditableCreateReach([], self.ui.tableView_header)
self.tableView.setModel(self.model)
self.tableView.setItemDelegate(qtableview_reach.Delegate())
def open_file_dialog(self): def open_file_dialog(self):
options = QFileDialog.Options() options = QFileDialog.Options()
DEFAULT_DIRECTORY = os.getenv("HOME") DEFAULT_DIRECTORY = os.getenv("HOME")
@ -681,10 +685,12 @@ class GeometryWindow(QMainWindow, WindowToolKit):
get_pk_i = self.get_pk_i(ind) get_pk_i = self.get_pk_i(ind)
get_z_min_i = self.get_z_min_i(ind) get_z_min_i = self.get_z_min_i(ind)
get_z_max_i = self.get_z_max_i(ind) get_z_max_i = self.get_z_max_i(ind)
self.after_plot_selected_2.set_data( self.after_plot_selected_2.set_data(
(get_pk_i, get_pk_i), (get_pk_i, get_pk_i),
(get_z_min_i, get_z_max_i) (get_z_min_i, get_z_max_i)
) )
self.after_plot_selected_2.set_visible(True) self.after_plot_selected_2.set_visible(True)
self.ui.canvas_2.figure.canvas.draw_idle() self.ui.canvas_2.figure.canvas.draw_idle()
@ -727,10 +733,9 @@ class GeometryWindow(QMainWindow, WindowToolKit):
self.select_before_plot_selected_1(row - 1) self.select_before_plot_selected_1(row - 1)
self.after_plot_selected_2.set_visible(False) self.after_plot_selected_2.set_visible(False)
self.select_before_plot_selected_2(row - 1) self.select_before_plot_selected_2(row - 1)
self.tableView.model().blockSignals(False) self.tableView.model().blockSignals(False)
self.update_graphic_3(row) self.update_graphic_3(row)
self.ui.canvas_1.figure.canvas.draw_idle() self.ui.canvas_1.figure.canvas.draw_idle()
self.ui.canvas_2.figure.canvas.draw_idle() self.ui.canvas_2.figure.canvas.draw_idle()
@ -741,8 +746,8 @@ class GeometryWindow(QMainWindow, WindowToolKit):
self.ui.verticalSlider.setMaximum(self.model.rowCount() - 1) self.ui.verticalSlider.setMaximum(self.model.rowCount() - 1)
slider_value = self.ui.verticalSlider.value() slider_value = self.ui.verticalSlider.value()
pk = self.model.get_pk_profile_i(slider_value) pk = self.model.get_pk_profile_i(slider_value)
self.ui.vertical_slider_label.setText( self.ui.vertical_slider_label.setText(
_translate("MainWindow_reach", "Pk : ") + _translate("MainWindow_reach", "Pk : ") +
f"{pk}" + "\n" + f"{pk}" + "\n" +
@ -754,7 +759,6 @@ class GeometryWindow(QMainWindow, WindowToolKit):
self.select_plot_graphic_1(slider_value) self.select_plot_graphic_1(slider_value)
self.select_plot_graphic_2(slider_value) self.select_plot_graphic_2(slider_value)
self.select_row_profile_slider(slider_value) self.select_row_profile_slider(slider_value)
self.tableView.model().blockSignals(False) self.tableView.model().blockSignals(False)
def increment_value_slider(self): def increment_value_slider(self):

View File

@ -38,18 +38,18 @@ class Ui_MainWindow(object):
self.label_section_order = QtWidgets.QLabel(self.widget) self.label_section_order = QtWidgets.QLabel(self.widget)
self.label_section_order.setLayoutDirection(Qt.LeftToRight) self.label_section_order.setLayoutDirection(Qt.LeftToRight)
self.label_section_order.setObjectName("label_section_order") self.label_section_order.setObjectName("label_section_order")
self.label_section_order.setStyleSheet( # self.label_section_order.setStyleSheet(
"QLabel{ border: 1px solid darkGray;\n" # "QLabel{ border: 1px solid darkGray;\n"
" gridline-color: gray;\n" # " gridline-color: gray;\n"
" border-radius: 1px;\n" # " border-radius: 1px;\n"
" border-style: solid;\n" # " border-style: solid;\n"
" background-color: ; \n" # " background-color: ; \n"
" selection-background-color: #218ede;\n" # " selection-background-color: #218ede;\n"
" font-size: 12px;\n" # " font-size: 12px;\n"
" font-family: Helvetica\n" # " font-family: Helvetica\n"
"\n" # "\n"
" }" # " }"
) # )
self.verticalLayout.addWidget(self.label_section_order) self.verticalLayout.addWidget(self.label_section_order)
btn_size = QSize(30, 30) btn_size = QSize(30, 30)
self.btn_open = QtWidgets.QPushButton(self.widget) self.btn_open = QtWidgets.QPushButton(self.widget)
@ -187,18 +187,18 @@ class Ui_MainWindow(object):
self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # ajuster la largeur du tableau self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) # ajuster la largeur du tableau
self.tableView.setAlternatingRowColors(True) # colorie une ligne sur 2 self.tableView.setAlternatingRowColors(True) # colorie une ligne sur 2
self.tableView.verticalHeader().hide() # hide vertical/row headers self.tableView.verticalHeader().hide() # hide vertical/row headers
self.tableView.setStyleSheet( # self.tableView.setStyleSheet(
" QTableView { border: 1px solid black;\n" # " QTableView { border: 1px solid black;\n"
" gridline-color: blue;\n" # " gridline-color: blue;\n"
" border-radius: 2px;\n" # " border-radius: 2px;\n"
" border-style: solid;\n" # " border-style: solid;\n"
" background-color: #EEF6FC; \n" # " background-color: #EEF6FC; \n"
" selection-background-color: #218ede;\n" # " selection-background-color: #218ede;\n"
" font-size: 12px;\n" # " font-size: 12px;\n"
" font-family: Helvetica\n" # " font-family: Helvetica\n"
"\n" # "\n"
" }" # " }"
) # )
self.tableView.resizeColumnsToContents() self.tableView.resizeColumnsToContents()
self.tableView.resizeRowsToContents() self.tableView.resizeRowsToContents()
@ -225,18 +225,18 @@ class Ui_MainWindow(object):
self.toolbar_1 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT( self.toolbar_1 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(
self.canvas_1, self.centralwidget self.canvas_1, self.centralwidget
) )
self.toolbar_1.setStyleSheet( # self.toolbar_1.setStyleSheet(
"QToolBar{ border: 1px solid darkGray;\n" # "QToolBar{ border: 1px solid darkGray;\n"
" gridline-color: blue;\n" # " gridline-color: blue;\n"
" border-radius: 4px;\n" # " border-radius: 4px;\n"
" border-style: solid;\n" # " border-style: solid;\n"
" background-color: #EEF6FC; \n" # " background-color: #EEF6FC; \n"
" selection-background-color: #218ede;\n" # " selection-background-color: #218ede;\n"
" font-size: 12px;\n" # " font-size: 12px;\n"
" font-family: Helvetica\n" # " font-family: Helvetica\n"
"\n" # "\n"
" }" # " }"
) # )
self.verticalLayout_canvas_1.addWidget(self.toolbar_1) self.verticalLayout_canvas_1.addWidget(self.toolbar_1)
self.verticalLayout_canvas_1.addWidget(self.canvas_1) self.verticalLayout_canvas_1.addWidget(self.canvas_1)
@ -251,18 +251,18 @@ class Ui_MainWindow(object):
self.canvas_2.setObjectName("canvas_2") self.canvas_2.setObjectName("canvas_2")
self.toolbar_2 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(self.canvas_2, self.centralwidget) self.toolbar_2 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(self.canvas_2, self.centralwidget)
self.toolbar_2.setStyleSheet( # self.toolbar_2.setStyleSheet(
"QToolBar{ border: 1px solid darkGray;\n" # "QToolBar{ border: 1px solid darkGray;\n"
" gridline-color: blue;\n" # " gridline-color: blue;\n"
" border-radius: 4px;\n" # " border-radius: 4px;\n"
" border-style: solid;\n" # " border-style: solid;\n"
" background-color: #EEF6FC; \n" # " background-color: #EEF6FC; \n"
" selection-background-color: #218ede;\n" # " selection-background-color: #218ede;\n"
" font-size: 12px;\n" # " font-size: 12px;\n"
" font-family: Helvetica\n" # " font-family: Helvetica\n"
"\n" # "\n"
" }" # " }"
) # )
self.verticalLayout_canvas_2.addWidget(self.toolbar_2) self.verticalLayout_canvas_2.addWidget(self.toolbar_2)
self.verticalLayout_canvas_2.addWidget(self.canvas_2) self.verticalLayout_canvas_2.addWidget(self.canvas_2)
@ -276,18 +276,18 @@ class Ui_MainWindow(object):
self.canvas_3.setObjectName("canvas_3") self.canvas_3.setObjectName("canvas_3")
self.toolbar_3 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(self.canvas_3, self.centralwidget) self.toolbar_3 = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(self.canvas_3, self.centralwidget)
self.toolbar_3.setStyleSheet( # self.toolbar_3.setStyleSheet(
"QToolBar{ border: 1px solid darkGray;\n" # "QToolBar{ border: 1px solid darkGray;\n"
" gridline-color: blue;\n" # " gridline-color: blue;\n"
" border-radius: 4px;\n" # " border-radius: 4px;\n"
" border-style: solid;\n" # " border-style: solid;\n"
" background-color: #EEF6FC; \n" # " background-color: #EEF6FC; \n"
" selection-background-color: #218ede;\n" # " selection-background-color: #218ede;\n"
" font-size: 12px;\n" # " font-size: 12px;\n"
" font-family: Helvetica\n" # " font-family: Helvetica\n"
"\n" # "\n"
" }" # " }"
) # )
self.verticalLayout_canvas_3.addWidget(self.toolbar_3) self.verticalLayout_canvas_3.addWidget(self.toolbar_3)
self.verticalLayout_canvas_3.addWidget(self.canvas_3) self.verticalLayout_canvas_3.addWidget(self.canvas_3)

View File

@ -55,12 +55,12 @@ class PandasModelEditable(QAbstractTableModel):
if role == Qt.TextAlignmentRole: if role == Qt.TextAlignmentRole:
return Qt.AlignHCenter | Qt.AlignVCenter return Qt.AlignHCenter | Qt.AlignVCenter
if index.column() == 2: # if index.column() == 2:
if role == Qt.ForegroundRole: # if role == Qt.ForegroundRole:
if value == min(self._data.iloc[:, index.column()]): # if value == min(self._data.iloc[:, index.column()]):
return QtGui.QColor("red") # return QtGui.QColor("red")
elif value == max(self._data.iloc[:, index.column()]): # elif value == max(self._data.iloc[:, index.column()]):
return QtGui.QColor("Blue") # return QtGui.QColor("Blue")
if role == Qt.ToolTipRole: if role == Qt.ToolTipRole:
if value == min(self._data.iloc[:, index.column()]): if value == min(self._data.iloc[:, index.column()]):
@ -90,8 +90,8 @@ class PandasModelEditable(QAbstractTableModel):
font.setBold(True) font.setBold(True)
return font return font
if role == Qt.BackgroundRole: # if role == Qt.BackgroundRole:
return QtGui.QColor("#ededee") # return QtGui.QColor("#ededee")
return QVariant() return QVariant()

View File

@ -66,21 +66,22 @@ class PandasModelEditable(QAbstractTableModel):
if index.column() == column and role == Qt.TextAlignmentRole: if index.column() == column and role == Qt.TextAlignmentRole:
return Qt.AlignHCenter | Qt.AlignVCenter return Qt.AlignHCenter | Qt.AlignVCenter
if role == Qt.BackgroundRole and index.column() == 1: # if role == Qt.BackgroundRole and index.column() == 1:
return QtGui.QColor(Qt.lightGray) # return QtGui.QColor(Qt.lightGray)
if role == Qt.BackgroundRole and index.column() == 2: # if role == Qt.BackgroundRole and index.column() == 2:
color = QtGui.QColor() # color = QtGui.QColor()
data_i_profile_type = self._data.profile[index.row()].profile_type # data_i_profile_type = self._data.profile[index.row()].profile_type
if data_i_profile_type == self.profiles_type[1]: # if data_i_profile_type == self.profiles_type[1]:
color = QtGui.QColor("magenta") # color = QtGui.QColor("magenta")
elif data_i_profile_type == self.profiles_type[2]: # elif data_i_profile_type == self.profiles_type[2]:
color = QtGui.QColor("red") # color = QtGui.QColor("red")
else: # else:
color = QtGui.QColor("lightgreen") # color = QtGui.QColor("lightgreen")
# return color
return color
if role == Qt.ForegroundRole and index.column() == 0: if role == Qt.ForegroundRole and index.column() == 0:
if self._data.profile[index.row()].name == "Amont": if self._data.profile[index.row()].name == "Amont":
return QtGui.QColor("Green") return QtGui.QColor("Green")
@ -404,7 +405,7 @@ class Delegate11(QtWidgets.QItemDelegate):
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
self.editor = QtWidgets.QComboBox(parent) self.editor = QtWidgets.QComboBox(parent)
self.editor.currentIndexChanged.connect(self.commit_editor) # self.editor.currentIndexChanged.connect(self.commit_editor)
self.editor.addItems(self.items) self.editor.addItems(self.items)
return self.editor return self.editor
@ -417,25 +418,25 @@ class Delegate11(QtWidgets.QItemDelegate):
style.drawComplexControl(QtWidgets.QStyle.CC_ComboBox, opt, painter) style.drawComplexControl(QtWidgets.QStyle.CC_ComboBox, opt, painter)
QtWidgets.QItemDelegate.paint(self, painter, option, index) QtWidgets.QItemDelegate.paint(self, painter, option, index)
def commit_editor(self): # def commit_editor(self):
editor = self.sender() # editor = self.sender()
color = QtGui.QColor() # color = QtGui.QColor()
if editor.currentText() == "ProfilXYZ": # if editor.currentText() == "ProfilXYZ":
color = QtGui.QColor("lightgreen") # color = QtGui.QColor("lightgreen")
elif editor.currentText() == "ProfilAC": # elif editor.currentText() == "ProfilAC":
color = QtGui.QColor("red") # color = QtGui.QColor("red")
qss = """QComboBox{background-color : %s;}""" % (color.name(),) # qss = """QComboBox{background-color : %s;}""" % (color.name(),)
editor.setStyleSheet(qss) # editor.setStyleSheet(qss)
self.commitData.emit(editor) # self.commitData.emit(editor)
def setEditorData(self, editor, index): def setEditorData(self, editor, index):
editor.blockSignals(True) editor.blockSignals(True)
editor.setCurrentIndex(index.row()) # replacement editor.setCurrentIndex(index.row()) # replacement
editor.blockSignals(False) editor.blockSignals(False)
@pyqtSlot() # @pyqtSlot()
def currentIndexChanged(self): # def currentIndexChanged(self):
self.commit_editor.emit(self.sender()) # self.commit_editor.emit(self.sender())
def setModelData(self, editor, model, index): def setModelData(self, editor, model, index):
value = editor.currentText() value = editor.currentText()
@ -457,22 +458,22 @@ class Delegate1(QtWidgets.QStyledItemDelegate):
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
editor = QtWidgets.QComboBox(parent) editor = QtWidgets.QComboBox(parent)
editor.currentIndexChanged.connect(self.commit_editor) # editor.currentIndexChanged.connect(self.commit_editor)
editor.addItems(self.items) editor.addItems(self.items)
return editor return editor
def commit_editor(self): # def commit_editor(self):
editor = self.sender() # editor = self.sender()
color = QtGui.QColor() # color = QtGui.QColor()
if editor.currentText() == "ProfilXYZ": # if editor.currentText() == "ProfilXYZ":
color = QtGui.QColor("lightgreen") # color = QtGui.QColor("lightgreen")
elif editor.currentText() == "ProfilAC": # elif editor.currentText() == "ProfilAC":
color = QtGui.QColor("red") # color = QtGui.QColor("red")
qss = """QComboBox{background-color : %s;}""" % (color.name(),) # qss = """QComboBox{background-color : %s;}""" % (color.name(),)
editor.setStyleSheet(qss) # editor.setStyleSheet(qss)
self.commitData.emit(editor) # self.commitData.emit(editor)
def setEditorData(self, editor, index): def setEditorData(self, editor, index):
editor.blockSignals(True) editor.blockSignals(True)
@ -526,8 +527,8 @@ class PandasModelEditableCreateReach(QAbstractTableModel):
if index.column() == column and role == Qt.TextAlignmentRole: if index.column() == column and role == Qt.TextAlignmentRole:
return Qt.AlignHCenter | Qt.AlignVCenter return Qt.AlignHCenter | Qt.AlignVCenter
if role == Qt.BackgroundRole and index.column() == 1: # if role == Qt.BackgroundRole and index.column() == 1:
return QtGui.QColor(Qt.lightGray) # return QtGui.QColor(Qt.lightGray)
return QVariant() # None return QVariant() # None
@ -948,7 +949,7 @@ class Delegate11(QtWidgets.QItemDelegate):
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
self.editor = QtWidgets.QComboBox(parent) self.editor = QtWidgets.QComboBox(parent)
self.editor.currentIndexChanged.connect(self.commit_editor) # self.editor.currentIndexChanged.connect(self.commit_editor)
self.editor.addItems(self.items) self.editor.addItems(self.items)
return self.editor return self.editor
@ -962,25 +963,25 @@ class Delegate11(QtWidgets.QItemDelegate):
QtWidgets.QItemDelegate.paint(self, painter, option, index) QtWidgets.QItemDelegate.paint(self, painter, option, index)
def commit_editor(self): # def commit_editor(self):
editor = self.sender() # editor = self.sender()
color = QtGui.QColor() # color = QtGui.QColor()
if editor.currentText() == "ProfilXYZ": # if editor.currentText() == "ProfilXYZ":
color = QtGui.QColor("lightgreen") # color = QtGui.QColor("lightgreen")
elif editor.currentText() == "ProfilAC": # elif editor.currentText() == "ProfilAC":
color = QtGui.QColor("red") # color = QtGui.QColor("red")
qss = """QComboBox{background-color : %s;}""" % (color.name(),) # qss = """QComboBox{background-color : %s;}""" % (color.name(),)
editor.setStyleSheet(qss) # editor.setStyleSheet(qss)
self.commitData.emit(editor) # self.commitData.emit(editor)
def setEditorData(self, editor, index): def setEditorData(self, editor, index):
editor.blockSignals(True) editor.blockSignals(True)
editor.setCurrentIndex(index.row()) # replacement editor.setCurrentIndex(index.row()) # replacement
editor.blockSignals(False) editor.blockSignals(False)
@pyqtSlot() # @pyqtSlot()
def currentIndexChanged(self): # def currentIndexChanged(self):
self.commit_editor.emit(self.sender()) # self.commit_editor.emit(self.sender())
def setModelData(self, editor, model, index): def setModelData(self, editor, model, index):
value = editor.currentText() value = editor.currentText()
@ -1002,20 +1003,20 @@ class Delegate1(QtWidgets.QStyledItemDelegate):
def createEditor(self, parent, option, index): def createEditor(self, parent, option, index):
editor = QtWidgets.QComboBox(parent) editor = QtWidgets.QComboBox(parent)
editor.currentIndexChanged.connect(self.commit_editor) # editor.currentIndexChanged.connect(self.commit_editor)
editor.addItems(self.items) editor.addItems(self.items)
return editor return editor
def commit_editor(self): # def commit_editor(self):
editor = self.sender() # editor = self.sender()
color = QtGui.QColor() # color = QtGui.QColor()
if editor.currentText() == "ProfilXYZ": # if editor.currentText() == "ProfilXYZ":
color = QtGui.QColor("lightgreen") # color = QtGui.QColor("lightgreen")
elif editor.currentText() == "ProfilAC": # elif editor.currentText() == "ProfilAC":
color = QtGui.QColor("red") # color = QtGui.QColor("red")
qss = """QComboBox{background-color : %s;}""" % (color.name(),) # qss = """QComboBox{background-color : %s;}""" % (color.name(),)
editor.setStyleSheet(qss) # editor.setStyleSheet(qss)
self.commitData.emit(editor) # self.commitData.emit(editor)
def setEditorData(self, editor, index): def setEditorData(self, editor, index):
editor.blockSignals(True) editor.blockSignals(True)

View File

@ -3,13 +3,15 @@ from matplotlib.figure import Figure
class MplCanvas(FigureCanvasQTAgg): class MplCanvas(FigureCanvasQTAgg):
def __init__(self, width=5, height=4, dpi=100): def __init__(self, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi) fig = Figure(figsize=(width, height), dpi=dpi)
super(MplCanvas, self).__init__(fig) super(MplCanvas, self).__init__(fig)
self.axes = fig.add_subplot(111) self.axes = fig.add_subplot(111)
self.axes.format_coord = lambda x, y: '(x = ' + format(x, '1.4f') + ', \t' + ' y = ' + format(y, '1.4f') + ')' self.axes.format_coord = lambda x, y: (
'(x = ' + format(x, '1.4f') + ', \t' +
' y = ' + format(y, '1.4f') + ')'
)
self.axes.grid(color='green', linestyle='--', linewidth=0.5) self.axes.grid(color='green', linestyle='--', linewidth=0.5)
self.axes.yaxis.tick_left() self.axes.yaxis.tick_left()
self.axes.xaxis.tick_bottom() self.axes.xaxis.tick_bottom()

View File

@ -27,25 +27,30 @@ class OnpickEvent(object):
self.counter_onclick = 0 self.counter_onclick = 0
# self.select_point_plot() # self.select_point_plot()
self.count = 0 self.count = 0
self.annotation_onclick = self.ax.annotate("", xytext=(np.mean(self.x), np.mean(self.y)), self.annotation_onclick = self.ax.annotate(
xy=(np.mean(self.x), np.mean(self.y)), "",
horizontalalignment='center', xytext=(np.mean(self.x), np.mean(self.y)),
fontsize=8, xy=(np.mean(self.x), np.mean(self.y)),
# fontstyle='italic', horizontalalignment='center',
fontweight='bold', fontsize=8,
alpha=0.7 # fontstyle='italic',
fontweight='bold',
) alpha=0.7
)
self.annotation_onclick.set_visible(False) self.annotation_onclick.set_visible(False)
self.pos_x = 0 self.pos_x = 0
self.zomm_xmin_xmax = self.ax.get_xlim() self.zomm_xmin_xmax = self.ax.get_xlim()
self.plot_selec() self.plot_selec()
# self.select_point_plot() # self.select_point_plot()
self._largeur_miroir, = self.ax.plot(self.x[1], self.y[1], self._largeur_miroir, = self.ax.plot(
color='blue', lw=1.2, ls=":") self.x[1], self.y[1],
color='blue', lw=1.2, ls=":"
)
self.pt = [] self.pt = []
self.tableView.selectionModel().selectionChanged.connect(self.update_select_point_point) self.tableView.selectionModel()\
.selectionChanged\
.connect(self.update_select_point_point)
def select_row_pt_clicked(self, ind: int = 0): def select_row_pt_clicked(self, ind: int = 0):
""" """
@ -56,9 +61,12 @@ class OnpickEvent(object):
if self.tableView is not None: if self.tableView is not None:
selectionModel = self.tableView.selectionModel() selectionModel = self.tableView.selectionModel()
index = self.tableView.model().index(ind, 0) index = self.tableView.model().index(ind, 0)
selectionModel.select(index, selectionModel.select(
QItemSelectionModel.Rows | QItemSelectionModel.ClearAndSelect | index,
QItemSelectionModel.Select) QItemSelectionModel.Rows |
QItemSelectionModel.ClearAndSelect |
QItemSelectionModel.Select
)
self.tableView.scrollTo(index) self.tableView.scrollTo(index)
def select_qtableview_row(self, event): def select_qtableview_row(self, event):
@ -73,28 +81,35 @@ class OnpickEvent(object):
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([index.row() for index in self.tableView.selectedIndexes()])) rows = list(set(
[index.row() for index in self.tableView.selectedIndexes()]
))
for row in rows: for row in rows:
pass pass
def update_select_point_point(self): def update_select_point_point(self):
if self.tableView is not None: if self.tableView is not None:
rows = list(set([index.row() for index in self.tableView.selectedIndexes()])) rows = list(set(
[index.row() for index in self.tableView.selectedIndexes()]
))
if len(rows) > 1: if len(rows) > 1:
for row in rows: for row in rows:
self.pt1 = self.ax.plot(self.x[row], self.y[row], '+', c='Blue', markersize=7) self.pt1 = self.ax.plot(self.x[row], self.y[row],
'+', c='Blue', markersize=7)
self.pt.append(self.pt1) self.pt.append(self.pt1)
self.update_select_point_point_bis(self.x[row], self.y[row]) self.update_select_point_point_bis(self.x[row], self.y[row])
elif len(rows) == 1: elif len(rows) == 1:
for row in rows: for row in rows:
try: try:
[pl[0].set_data([], []) for pl in self.pt if len(self.pt) > 1] [pl[0].set_data([], [])
for pl in self.pt if len(self.pt) > 1]
except: except:
print("Probleme de mise à jour ... update_select_point_point()") print("Probleme de mise à jour ... update_select_point_point()")
try: try:
self.update_select_point_point_bis(self.x[row], self.y[row]) self.update_select_point_point_bis(self.x[row],
self.y[row])
except: except:
print("index introuvable pour la mise à jour de l'affichage de la sélection du point." print("index introuvable pour la mise à jour de l'affichage de la sélection du point."
"Editer les cases en 'nan'.") "Editer les cases en 'nan'.")
@ -102,7 +117,8 @@ class OnpickEvent(object):
self.ax.figure.canvas.draw_idle() self.ax.figure.canvas.draw_idle()
def plot_selec(self): def plot_selec(self):
self.point_selec, = self.ax.plot(self.x[0], self.y[0], '+', c='Blue', markersize=7) self.point_selec, = self.ax.plot(self.x[0], self.y[0],
'+', c='Blue', markersize=7)
self.point_selec.set_visible(False) self.point_selec.set_visible(False)
def update_select_point_point_bis(self, x_ind, y_ind): def update_select_point_point_bis(self, x_ind, y_ind):
@ -118,7 +134,8 @@ class OnpickEvent(object):
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, '+', c='Blue', markersize=7) self.select_point, = self.ax.plot(x, y,
'+', c='Blue', markersize=7)
else: else:
self.select_point, = self.ax.plot([], []) self.select_point, = self.ax.plot([], [])
@ -207,7 +224,9 @@ class OnpickEvent(object):
thisline = event.artist thisline = event.artist
xdata = thisline.get_xdata() xdata = thisline.get_xdata()
ydata = thisline.get_ydata() ydata = thisline.get_ydata()
points_onpick = np.array([(xdata[i], ydata[i]) for i in self.indice_points_onpick(event)]) points_onpick = np.array(
[(xdata[i], ydata[i]) for i in self.indice_points_onpick(event)]
)
return points_onpick return points_onpick
def distance_normee(self, event): def distance_normee(self, event):
@ -338,7 +357,8 @@ class OnpickEvent(object):
event.ydata = self.z_berge_basse event.ydata = self.z_berge_basse
A, p, L = self.calcul_ligne_eau(event.ydata) A, p, L = self.calcul_ligne_eau(event.ydata)
etiq = f"Z = {event.ydata:.3f} m, A = {A:.3f} m\u00B2, p = {p:.3f} m, L = {L:.3f} m" etiq = f"Z = {event.ydata:.3f} m, A = {A:.3f} "\
f"m\u00B2, p = {p:.3f} m, L = {L:.3f} m"
self.annotation_onclick.set_text(etiq) self.annotation_onclick.set_text(etiq)
x_min, x_max = self.ax.get_xlim() x_min, x_max = self.ax.get_xlim()
self.pos_x_annotation = x_min + ((x_max - x_min) / 2) self.pos_x_annotation = x_min + ((x_max - x_min) / 2)
@ -366,7 +386,8 @@ 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.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) self.ax.callbacks.connect('ylim_changed', self.on_ylims_change)
@ -442,7 +463,9 @@ class OnpickEvent(object):
if self.z_point_bas < val <= self.z_berge_basse: if self.z_point_bas < val <= self.z_berge_basse:
z_eau = np.array([val] * (len(self.z_sans_rebord))) z_eau = np.array([val] * (len(self.z_sans_rebord)))
self.poly_col_bis = self.remplir_zone_mouillee(self.x_sans_rebord, z_eau, self.z_sans_rebord) self.poly_col_bis = self.remplir_zone_mouillee(self.x_sans_rebord,
z_eau,
self.z_sans_rebord)
liste_chemins = self.poly_col_bis.get_paths() liste_chemins = self.poly_col_bis.get_paths()
couleurs = ['crimson', 'pink'] * len(liste_chemins) couleurs = ['crimson', 'pink'] * len(liste_chemins)
aire_calculee_shapely = None aire_calculee_shapely = None

View File

@ -86,7 +86,6 @@ class PamHyrNavigationToolbar2QT(NavigationToolbar2QT):
self._actions["non_isometric_view"].setIcon(icon_btn_global_view) self._actions["non_isometric_view"].setIcon(icon_btn_global_view)
self.addSeparator() self.addSeparator()
self.set_style_sheet()
def save_figure(self, *args): def save_figure(self, *args):
filetypes = self.canvas.get_supported_filetypes_grouped() filetypes = self.canvas.get_supported_filetypes_grouped()
@ -146,17 +145,3 @@ class PamHyrNavigationToolbar2QT(NavigationToolbar2QT):
self._actions['save_figure'].setToolTip(_translate("Toolbar", "Enregistrer la figure")) self._actions['save_figure'].setToolTip(_translate("Toolbar", "Enregistrer la figure"))
self.action_isometric_view.setToolTip(_translate("Toolbar", "Vue isométrique (Shift+W)")) self.action_isometric_view.setToolTip(_translate("Toolbar", "Vue isométrique (Shift+W)"))
self.action_auto_global_view.setToolTip(_translate("Toolbar", "Vue globale automatique (Shift+X)")) self.action_auto_global_view.setToolTip(_translate("Toolbar", "Vue globale automatique (Shift+X)"))
def set_style_sheet(self):
self.setStyleSheet(
"QToolBar{ border: 1px solid darkGray;\n"
" gridline-color: blue;\n"
" border-radius: 4px;\n"
" border-style: solid;\n"
" background-color: #EEF6FC; \n"
" selection-background-color: #218ede;\n"
" font-size: 12px;\n"
" font-family: Helvetica\n"
"\n"
" }"
)