mirror of https://gitlab.com/pamhyr/pamhyr2
geometry: Profile: Base feature of window works.
parent
215b93d6ed
commit
0b06c9be80
|
|
@ -158,15 +158,22 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
||||||
def edit_profile(self):
|
def edit_profile(self):
|
||||||
self.tableView.model().blockSignals(True)
|
self.tableView.model().blockSignals(True)
|
||||||
|
|
||||||
for index in self.tableView.selectedIndexes():
|
rows = list(
|
||||||
profile = self._reach.profile(index.row())
|
set(
|
||||||
|
(i.row() for i in self.tableView.selectedIndexes())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self._profile_window.append(
|
for row in rows:
|
||||||
ProfileWindow(
|
profile = self._reach.profile(row)
|
||||||
|
|
||||||
|
win = ProfileWindow(
|
||||||
profile = profile,
|
profile = profile,
|
||||||
parent = self,
|
parent = self,
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
self._profile_window.append(win)
|
||||||
|
win.show()
|
||||||
|
|
||||||
self.tableView.model().blockSignals(False)
|
self.tableView.model().blockSignals(False)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
from View.Plot.APlot import APlot
|
||||||
|
from View.Plot.mpl_canvas_onpick_event import OnpickEvent
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
QCoreApplication
|
||||||
|
)
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
class Plot(APlot):
|
||||||
|
def __init__(self, canvas=None, data=None, toolbar=None, table=None):
|
||||||
|
super(Plot, self).__init__(
|
||||||
|
canvas=canvas,
|
||||||
|
data=data,
|
||||||
|
toolbar=toolbar
|
||||||
|
)
|
||||||
|
|
||||||
|
self._table = table
|
||||||
|
|
||||||
|
self.line_xy = []
|
||||||
|
self.line_gl = []
|
||||||
|
|
||||||
|
self.before_plot_selected = None
|
||||||
|
self.plot_selected = None
|
||||||
|
self.after_plot_selected = None
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def draw(self):
|
||||||
|
x = self.data.get_station()
|
||||||
|
y = self.data.z()
|
||||||
|
gl = self.data.name
|
||||||
|
x_carto = self.data.x()
|
||||||
|
y_carto = self.data.y()
|
||||||
|
|
||||||
|
self.canvas.axes.cla()
|
||||||
|
self.canvas.axes.grid(
|
||||||
|
color='grey', linestyle='--', linewidth=0.5
|
||||||
|
)
|
||||||
|
|
||||||
|
if (len(x_carto) >= 3 and
|
||||||
|
len(y_carto) >= 3 and
|
||||||
|
len(x) >= 3):
|
||||||
|
self.profile_line2D, = self.canvas.axes.plot(
|
||||||
|
x, y, color='r', lw=1.5,
|
||||||
|
markersize=7, marker='+',
|
||||||
|
picker=30
|
||||||
|
)
|
||||||
|
self.canvas.axes.set_xlabel(
|
||||||
|
_translate("MainWindowProfile",
|
||||||
|
"Abscisse en travers (m)"),
|
||||||
|
color='black', fontsize=10
|
||||||
|
)
|
||||||
|
self.canvas.axes.set_ylabel(
|
||||||
|
_translate("MainWindowProfile", "Cote (m)"),
|
||||||
|
color='black', fontsize=10
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add label on graph
|
||||||
|
self.annotation = []
|
||||||
|
for i, txt in enumerate(list(gl)):
|
||||||
|
annotation = self.canvas.axes.annotate(
|
||||||
|
txt, (x[i], y[i]),
|
||||||
|
horizontalalignment='left',
|
||||||
|
verticalalignment='top',
|
||||||
|
annotation_clip=True,
|
||||||
|
fontsize=10, color='black'
|
||||||
|
)
|
||||||
|
annotation.set_position((x[i], y[i]))
|
||||||
|
annotation.set_color("black")
|
||||||
|
self.annotation.append(annotation)
|
||||||
|
|
||||||
|
al = 8.
|
||||||
|
arrowprops = dict(
|
||||||
|
clip_on=True,
|
||||||
|
headwidth=5.,
|
||||||
|
facecolor='k'
|
||||||
|
)
|
||||||
|
kwargs = dict(
|
||||||
|
xycoords='axes fraction',
|
||||||
|
textcoords='offset points',
|
||||||
|
arrowprops=arrowprops,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.canvas.axes.annotate("", (1, 0), xytext=(-al, 0), **kwargs)
|
||||||
|
self.canvas.axes.annotate("", (0, 1), xytext=(0, -al), **kwargs)
|
||||||
|
|
||||||
|
self.canvas.axes.spines[['top', 'right']].set_color('none')
|
||||||
|
self.canvas.axes.yaxis.tick_left()
|
||||||
|
self.canvas.axes.xaxis.tick_bottom()
|
||||||
|
self.canvas.axes.set_facecolor('#F9F9F9')
|
||||||
|
self.canvas.figure.patch.set_facecolor('white')
|
||||||
|
|
||||||
|
self.onpick_event = OnpickEvent(
|
||||||
|
self.canvas.axes,
|
||||||
|
x, y, x_carto, y_carto,
|
||||||
|
self._table
|
||||||
|
)
|
||||||
|
self.canvas.figure.canvas\
|
||||||
|
.mpl_connect(
|
||||||
|
'pick_event',
|
||||||
|
self.onpick_event.onpick
|
||||||
|
)
|
||||||
|
|
||||||
|
self.onclick_event = OnpickEvent(
|
||||||
|
self.canvas.axes,
|
||||||
|
x, y, x_carto, y_carto,
|
||||||
|
self._table
|
||||||
|
)
|
||||||
|
self.canvas.figure.canvas\
|
||||||
|
.mpl_connect(
|
||||||
|
'button_press_event',
|
||||||
|
self.onclick_event.onclick
|
||||||
|
)
|
||||||
|
|
||||||
|
self.canvas.figure.tight_layout()
|
||||||
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def update(self, ind=None):
|
||||||
|
print("TODO: implemente update")
|
||||||
|
|
@ -13,12 +13,12 @@ from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QCheckBox
|
||||||
|
|
||||||
from View.Geometry.Profile.mainwindow_ui_profile import Ui_MainWindow
|
from View.Geometry.Profile.mainwindow_ui_profile import Ui_MainWindow
|
||||||
|
|
||||||
|
from View.Geometry.Profile.Plot import Plot
|
||||||
|
|
||||||
from Model.Geometry.Reach import Reach
|
from Model.Geometry.Reach import Reach
|
||||||
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
||||||
from View.Geometry.Profile.qtableview_profile import *
|
from View.Geometry.Profile.qtableview_profile import *
|
||||||
|
|
||||||
from View.Plot.mpl_canvas_onpick_event import OnpickEvent
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -36,40 +36,37 @@ class ProfileWindow(QMainWindow):
|
||||||
self.setup_window()
|
self.setup_window()
|
||||||
self.setup_model()
|
self.setup_model()
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
self.graph()
|
self.plot()
|
||||||
|
|
||||||
self._model.dataChanged.connect(self.graph)
|
self._model.dataChanged.connect(self.plot)
|
||||||
self.fileName = None
|
self.fileName = None
|
||||||
|
|
||||||
self.ui.tableView.installEventFilter(self)
|
self.ui.tableView.installEventFilter(self)
|
||||||
self.status_change_tableview = False
|
self.status_change_tableview = False
|
||||||
|
|
||||||
self._model.dataChanged.connect(self.tableview_is_modified)
|
# self._model.dataChanged.connect(self.tableview_is_modified)
|
||||||
|
|
||||||
self.reference_data = None
|
self.reference_data = None
|
||||||
self.ui.btn_go_back.setEnabled(False)
|
# self.ui.btn_go_back.setEnabled(False)
|
||||||
self.ui.btn_check.setEnabled(False)
|
# self.ui.btn_check.setEnabled(False)
|
||||||
self._model.dataChanged.connect(self.set_enable_cancel_btn)
|
# self._model.dataChanged.connect(self.set_enable_cancel_btn)
|
||||||
self._model.dataChanged.connect(self.set_enable_validate_changes_btn)
|
# self._model.dataChanged.connect(self.set_enable_validate_changes_btn)
|
||||||
self.ui.btn_reset.setEnabled(False)
|
# self.ui.btn_reset.setEnabled(False)
|
||||||
self._model.dataChanged.connect(self.set_enable_go_back_initial_state_btn)
|
# self._model.dataChanged.connect(self.set_enable_go_back_initial_state_btn)
|
||||||
|
|
||||||
def setup_window(self):
|
def setup_window(self):
|
||||||
name = self._profile.name
|
|
||||||
if self._profile.name is None or self._profile.name:
|
|
||||||
name = _translate("MainWindowProfile", "(no name)")
|
|
||||||
|
|
||||||
header = _translate("MainWindowProfile", "Profile")
|
header = _translate("MainWindowProfile", "Profile")
|
||||||
|
|
||||||
|
name = self._profile.name
|
||||||
|
if (name is None) or (name == ""):
|
||||||
|
name = _translate("MainWindowProfile", "(no name)")
|
||||||
|
|
||||||
self.setWindowTitle(
|
self.setWindowTitle(
|
||||||
header + " - " +
|
header + " - " +
|
||||||
f"{self._profile.reach.name}" + " - " +
|
f"{self._profile.reach.name}" + " - " +
|
||||||
f"{name} ({self._profile.kp})"
|
f"{name} ({self._profile.kp})"
|
||||||
)
|
)
|
||||||
|
|
||||||
def tableview_is_modified(self):
|
|
||||||
self.status_change_tableview = True
|
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
self.ui.btn_sort_asc_x.clicked.connect(self.sort_X_ascending)
|
self.ui.btn_sort_asc_x.clicked.connect(self.sort_X_ascending)
|
||||||
self.ui.btn_sort_desc_x.clicked.connect(self.sort_X_descending)
|
self.ui.btn_sort_desc_x.clicked.connect(self.sort_X_descending)
|
||||||
|
|
@ -80,114 +77,35 @@ class ProfileWindow(QMainWindow):
|
||||||
self.ui.btn_export.clicked.connect(self.handleSave)
|
self.ui.btn_export.clicked.connect(self.handleSave)
|
||||||
self.ui.btn_add.clicked.connect(self.insert_row)
|
self.ui.btn_add.clicked.connect(self.insert_row)
|
||||||
self.ui.btn_delete.clicked.connect(self.delete_row)
|
self.ui.btn_delete.clicked.connect(self.delete_row)
|
||||||
self.ui.btn_copy.clicked.connect(self.copyTable)
|
# self.ui.btn_copy.clicked.connect(self.copyTable)
|
||||||
self.ui.btn_paste.clicked.connect(self.pasteTable)
|
# self.ui.btn_paste.clicked.connect(self.pasteTable)
|
||||||
self.ui.btn_check.clicked.connect(self.validate_changes)
|
# self.ui.btn_check.clicked.connect(self.validate_changes)
|
||||||
self.ui.btn_go_back.clicked.connect(self.cancel_validate_changes)
|
# self.ui.btn_go_back.clicked.connect(self.cancel_validate_changes)
|
||||||
self.ui.btn_reset.clicked.connect(self.go_back_to_initial_state)
|
# self.ui.btn_reset.clicked.connect(self.go_back_to_initial_state)
|
||||||
|
|
||||||
def setup_model(self):
|
def setup_model(self):
|
||||||
self._model = PandasModelEditable(self._profile)
|
self._model = PandasModelEditable(self._profile)
|
||||||
self._last_saved_model_data = copy.deepcopy(self._model.model_data)
|
|
||||||
self.__initial_model_data = copy.deepcopy(self._model.model_data)
|
|
||||||
|
|
||||||
self.ui.tableView.setModel(self._model)
|
self.ui.tableView.setModel(self._model)
|
||||||
self.ui.tableView.setItemDelegate(Delegate())
|
self.ui.tableView.setItemDelegate(Delegate())
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def graph(self):
|
def plot(self):
|
||||||
"""
|
self.ui.tableView.model().blockSignals(True)
|
||||||
Returns: Le tracé de la cote z en fonction de l'abscisse (calculée).
|
|
||||||
"""
|
|
||||||
x = self._profile.get_station()
|
|
||||||
y = self._profile.z()
|
|
||||||
gl = self._profile.name()
|
|
||||||
x_carto = self._profile.x()
|
|
||||||
y_carto = self._profile.y()
|
|
||||||
|
|
||||||
self.ui.canvas.axes.cla()
|
self._plot = Plot(
|
||||||
self.ui.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
canvas = self.ui.canvas,
|
||||||
|
data = self._profile,
|
||||||
if (len(x_carto) >= 3 and
|
toolbar = None,
|
||||||
len(y_carto) >= 3 and
|
table = self.ui.tableView,
|
||||||
len(x) >= 3):
|
|
||||||
self.profile_line2D, = self.ui.canvas.axes.plot(
|
|
||||||
x, y, color='r', lw=1.5, markersize=7, marker='+',
|
|
||||||
picker=30
|
|
||||||
)
|
|
||||||
self.ui.canvas.axes.set_xlabel(
|
|
||||||
_translate("MainWindowProfile",
|
|
||||||
"Abscisse en travers (m)"),
|
|
||||||
color='black', fontsize=10
|
|
||||||
)
|
|
||||||
self.ui.canvas.axes.set_ylabel(
|
|
||||||
_translate("MainWindowProfile", "Cote (m)"),
|
|
||||||
color='black', fontsize=10
|
|
||||||
)
|
)
|
||||||
|
self._plot.draw()
|
||||||
|
|
||||||
# Add label on graph
|
self.ui.tableView.model().blockSignals(False)
|
||||||
self.annotation = []
|
|
||||||
for i, txt in enumerate(list(gl)):
|
|
||||||
annotation = self.ui.canvas.axes.annotate(
|
|
||||||
txt, (x[i], y[i]),
|
|
||||||
horizontalalignment='left',
|
|
||||||
verticalalignment='top',
|
|
||||||
annotation_clip=True, fontsize=10,
|
|
||||||
color='black'
|
|
||||||
)
|
|
||||||
annotation.set_position((x[i], y[i]))
|
|
||||||
annotation.set_color("black")
|
|
||||||
self.annotation.append(annotation)
|
|
||||||
|
|
||||||
al = 8.
|
|
||||||
arrowprops = dict(
|
|
||||||
clip_on=True,
|
|
||||||
headwidth=5.,
|
|
||||||
facecolor='k'
|
|
||||||
)
|
|
||||||
kwargs = dict(
|
|
||||||
xycoords='axes fraction',
|
|
||||||
textcoords='offset points',
|
|
||||||
arrowprops=arrowprops,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.ui.canvas.axes.annotate("", (1, 0), xytext=(-al, 0), **kwargs)
|
|
||||||
self.ui.canvas.axes.annotate("", (0, 1), xytext=(0, -al), **kwargs)
|
|
||||||
|
|
||||||
self.ui.canvas.axes.spines[['top', 'right']].set_color('none')
|
|
||||||
self.ui.canvas.axes.yaxis.tick_left()
|
|
||||||
self.ui.canvas.axes.xaxis.tick_bottom()
|
|
||||||
self.ui.canvas.axes.set_facecolor('#F9F9F9')
|
|
||||||
self.ui.canvas.figure.patch.set_facecolor('white')
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.onpick_event = OnpickEvent(
|
|
||||||
self.ui.canvas.axes,
|
|
||||||
x, y, x_carto, y_carto,
|
|
||||||
self.ui.tableView
|
|
||||||
)
|
|
||||||
self.ui.canvas\
|
|
||||||
.figure\
|
|
||||||
.canvas\
|
|
||||||
.mpl_connect('pick_event', self.onpick_event.onpick)
|
|
||||||
|
|
||||||
self.onclick_event = OnpickEvent(
|
|
||||||
self.ui.canvas.axes,
|
|
||||||
x, y, x_carto, y_carto,
|
|
||||||
self.ui.tableView
|
|
||||||
)
|
|
||||||
self.ui.canvas\
|
|
||||||
.figure\
|
|
||||||
.canvas\
|
|
||||||
.mpl_connect('button_press_event', self.onclick_event.onclick)
|
|
||||||
except:
|
|
||||||
print("TODO")
|
|
||||||
|
|
||||||
self.ui.canvas.figure.tight_layout()
|
|
||||||
self.ui.canvas.figure.canvas.draw_idle()
|
|
||||||
|
|
||||||
def insert_row(self):
|
def insert_row(self):
|
||||||
if len(self.tableView.selectedIndexes()) == 0:
|
if len(self.ui.tableView.selectedIndexes()) == 0:
|
||||||
self._tablemodel.insert_row(self._tablemodel.rowCount())
|
self._tablemodel.insert_row(self._tablemodel.rowCount())
|
||||||
else:
|
else:
|
||||||
row = self.index_selected_row()
|
row = self.index_selected_row()
|
||||||
|
|
@ -197,7 +115,7 @@ class ProfileWindow(QMainWindow):
|
||||||
rows = sorted(
|
rows = sorted(
|
||||||
list(
|
list(
|
||||||
set(
|
set(
|
||||||
[index.row() for index in self.tableView.selectedIndexes()]
|
[index.row() for index in self.ui.tableView.selectedIndexes()]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -207,19 +125,19 @@ class ProfileWindow(QMainWindow):
|
||||||
|
|
||||||
def sort_X_ascending(self):
|
def sort_X_ascending(self):
|
||||||
self._model.sort('x', order=Qt.AscendingOrder)
|
self._model.sort('x', order=Qt.AscendingOrder)
|
||||||
self.graph()
|
self.plot()
|
||||||
|
|
||||||
def sort_X_descending(self):
|
def sort_X_descending(self):
|
||||||
self._model.sort('x', order=Qt.DescendingOrder)
|
self._model.sort('x', order=Qt.DescendingOrder)
|
||||||
self.graph()
|
self.plot()
|
||||||
|
|
||||||
def sort_Y_ascending(self):
|
def sort_Y_ascending(self):
|
||||||
self._model.sort('y', order=Qt.AscendingOrder)
|
self._model.sort('y', order=Qt.AscendingOrder)
|
||||||
self.graph()
|
self.plot()
|
||||||
|
|
||||||
def sort_Y_descending(self):
|
def sort_Y_descending(self):
|
||||||
self._model.sort('y', order=Qt.DescendingOrder)
|
self._model.sort('y', order=Qt.DescendingOrder)
|
||||||
self.graph()
|
self.plot()
|
||||||
|
|
||||||
def move_row_down(self):
|
def move_row_down(self):
|
||||||
rows = list(
|
rows = list(
|
||||||
|
|
@ -232,7 +150,7 @@ class ProfileWindow(QMainWindow):
|
||||||
if row < self._model.rowCount() - 1:
|
if row < self._model.rowCount() - 1:
|
||||||
self._model.moveRowDown(row)
|
self._model.moveRowDown(row)
|
||||||
|
|
||||||
self.graph()
|
self.plot()
|
||||||
|
|
||||||
def move_row_up(self):
|
def move_row_up(self):
|
||||||
rows = list(
|
rows = list(
|
||||||
|
|
@ -245,103 +163,7 @@ class ProfileWindow(QMainWindow):
|
||||||
if 0 < row:
|
if 0 < row:
|
||||||
self._model.moveRowUp(row)
|
self._model.moveRowUp(row)
|
||||||
|
|
||||||
self.graph()
|
self.plot()
|
||||||
|
|
||||||
def eventFilter(self, source, event):
|
|
||||||
if event.type() == QEvent.KeyPress:
|
|
||||||
if event == QtGui.QKeySequence.Copy:
|
|
||||||
self.copyTable()
|
|
||||||
return True
|
|
||||||
|
|
||||||
elif event == QtGui.QKeySequence.Paste:
|
|
||||||
self.pasteTable()
|
|
||||||
return True
|
|
||||||
|
|
||||||
elif event.type() == QEvent.ContextMenu:
|
|
||||||
menu = QtWidgets.QMenu()
|
|
||||||
copyAction = menu.addAction('Copy')
|
|
||||||
pasteAction = menu.addAction('Paste')
|
|
||||||
|
|
||||||
if not self.ui.tableView.selectedIndexes():
|
|
||||||
pass
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
return super(View, self).eventFilter(source, event)
|
|
||||||
|
|
||||||
def copySelection(self):
|
|
||||||
self.clipboard.clear()
|
|
||||||
selected = self.ui.tableView.selectedIndexes()
|
|
||||||
rows = []
|
|
||||||
columns = []
|
|
||||||
|
|
||||||
for index in selected:
|
|
||||||
rows.append(index.row())
|
|
||||||
columns.append(index.column())
|
|
||||||
|
|
||||||
minRow = min(rows)
|
|
||||||
minCol = min(columns)
|
|
||||||
print(minCol)
|
|
||||||
print(minRow, columns)
|
|
||||||
for index in selected:
|
|
||||||
self.clipboard.append(
|
|
||||||
(index.row() - minRow,
|
|
||||||
index.column() - minCol,
|
|
||||||
index.data_frame())
|
|
||||||
)
|
|
||||||
|
|
||||||
def pasteSelection(self):
|
|
||||||
if not self.clipboard:
|
|
||||||
return
|
|
||||||
|
|
||||||
current = self.ui.tableView.currentIndex()
|
|
||||||
if not current.isValid():
|
|
||||||
# In the rare case that there is no current index, use the
|
|
||||||
# first row and column as target
|
|
||||||
current = self._model.index(0, 0)
|
|
||||||
|
|
||||||
firstRow = current.row()
|
|
||||||
firstColumn = current.column()
|
|
||||||
|
|
||||||
# optional: Get the selection model so that pasted indexes
|
|
||||||
# will be automatically selected at the end
|
|
||||||
selection = self.ui.tableView.selectionModel()
|
|
||||||
|
|
||||||
for row, column, data in self.clipboard:
|
|
||||||
# Get the index, with rows and columns relative to the
|
|
||||||
# current index = self._model.index(firstRow + row,
|
|
||||||
# firstColumn + column)
|
|
||||||
index = self._model.index(firstRow, column)
|
|
||||||
|
|
||||||
# Set the profile for the index
|
|
||||||
self._model.setData(index, data, Qt.EditRole)
|
|
||||||
# Add the index to the selection
|
|
||||||
selection.select(index, selection.Select)
|
|
||||||
|
|
||||||
# Apply the selection model
|
|
||||||
self.ui.tableView.setSelectionModel(selection)
|
|
||||||
|
|
||||||
def copyTable(self):
|
|
||||||
if len(self.ui.tableView.selectedIndexes()) == 0:
|
|
||||||
self._model.copyTable(0, self._model.rowCount())
|
|
||||||
else:
|
|
||||||
rows = list(set([index.row() for index in self.ui.tableView.selectedIndexes()]))
|
|
||||||
rows.sort()
|
|
||||||
df = self._model.model_data.loc[rows, :]
|
|
||||||
df.to_clipboard(header=None, index=False, excel=True, sep='\t')
|
|
||||||
|
|
||||||
def pasteTable(self):
|
|
||||||
if len(self.ui.tableView.selectedIndexes()) == 0:
|
|
||||||
self._model.pasteTable(self._model.rowCount())
|
|
||||||
else:
|
|
||||||
rows = list(set([index.row() for index in self.ui.tableView.selectedIndexes()]))
|
|
||||||
for row in rows:
|
|
||||||
try:
|
|
||||||
self._model.pasteTable(row + 1)
|
|
||||||
except:
|
|
||||||
print("TODO")
|
|
||||||
|
|
||||||
self.graph()
|
|
||||||
|
|
||||||
def handleSave(self):
|
def handleSave(self):
|
||||||
if self.fileName is None or self.fileName == '':
|
if self.fileName is None or self.fileName == '':
|
||||||
|
|
@ -389,27 +211,6 @@ class ProfileWindow(QMainWindow):
|
||||||
self.ui.tableView.setModel(self._model)
|
self.ui.tableView.setModel(self._model)
|
||||||
self.fileName = ''
|
self.fileName = ''
|
||||||
|
|
||||||
def cancel_validate_changes(self):
|
|
||||||
self._model.model_data = copy.deepcopy(self._last_saved_model_data)
|
|
||||||
self.graph()
|
|
||||||
self.ui.btn_go_back.setEnabled(False)
|
|
||||||
|
|
||||||
def validate_changes(self):
|
|
||||||
self.remove_duplicates_point_names()
|
|
||||||
self.delete_empty_rows()
|
|
||||||
self._last_saved_model_data = copy.deepcopy(self._model.model_data)
|
|
||||||
self.ui.btn_check.setEnabled(False)
|
|
||||||
self.ui.btn_go_back.setEnabled(False)
|
|
||||||
self.status_change_tableview = False
|
|
||||||
self.graph()
|
|
||||||
self._model.valide_all_changes()
|
|
||||||
self.parent.update_graphic_2()
|
|
||||||
self.parent.update_graphic_1()
|
|
||||||
self.selected_row = list(set(
|
|
||||||
[index.row() for index in self.parent.tableView.selectedIndexes()]
|
|
||||||
))
|
|
||||||
self.parent.update_graphic_3(self.selected_row[0])
|
|
||||||
|
|
||||||
def set_enable_validate_changes_btn(self):
|
def set_enable_validate_changes_btn(self):
|
||||||
self.ui.btn_check.setEnabled(True)
|
self.ui.btn_check.setEnabled(True)
|
||||||
|
|
||||||
|
|
@ -451,49 +252,26 @@ class ProfileWindow(QMainWindow):
|
||||||
if list_deleted_names:
|
if list_deleted_names:
|
||||||
self.msg_box_check_duplication_names(list_deleted_names)
|
self.msg_box_check_duplication_names(list_deleted_names)
|
||||||
|
|
||||||
def go_back_to_initial_state(self):
|
|
||||||
|
|
||||||
reply = QtWidgets.QMessageBox.question(
|
|
||||||
self,
|
|
||||||
_translate("MainWindowProfile", "Retour à l'état initial "),
|
|
||||||
_translate("MainWindowProfile",
|
|
||||||
"Voulez-vous vraiment annuler toutes "
|
|
||||||
"les modifications?\n\n "
|
|
||||||
"\tOui : Revenir à l'état initial\n"
|
|
||||||
"\tNon : Garder l'état actuel des "
|
|
||||||
"données du profil"),
|
|
||||||
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
|
|
||||||
)
|
|
||||||
|
|
||||||
if reply == QtWidgets.QMessageBox.Yes:
|
|
||||||
self._model.model_data = copy.deepcopy(self.__initial_model_data)
|
|
||||||
self._model.valide_all_changes()
|
|
||||||
self.graph()
|
|
||||||
self.ui.btn_reset.setEnabled(False)
|
|
||||||
self.ui.btn_check.setEnabled(False)
|
|
||||||
self.ui.btn_go_back.setEnabled(False)
|
|
||||||
elif reply == QtWidgets.QMessageBox.No:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
if self.status_change_tableview:
|
print("TODO: Close")
|
||||||
reply = QtWidgets.QMessageBox.question(
|
# if self.status_change_tableview:
|
||||||
self,
|
# reply = QtWidgets.QMessageBox.question(
|
||||||
_translate("MainWindowProfile", "Terminer l'édition du profil "),
|
# self,
|
||||||
_translate("MainWindowProfile", "Voulez-vous vraiment quitter "
|
# _translate("MainWindowProfile", "Terminer l'édition du profil "),
|
||||||
"?\n Oui : Valider et quitter\n"
|
# _translate("MainWindowProfile", "Voulez-vous vraiment quitter "
|
||||||
"Non : Annuler"),
|
# "?\n Oui : Valider et quitter\n"
|
||||||
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
|
# "Non : Annuler"),
|
||||||
)
|
# QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
|
||||||
|
# )
|
||||||
|
|
||||||
if reply == QtWidgets.QMessageBox.Yes:
|
# if reply == QtWidgets.QMessageBox.Yes:
|
||||||
self.validate_changes()
|
# self.validate_changes()
|
||||||
self.graph()
|
# self.plot()
|
||||||
event.accept()
|
# event.accept()
|
||||||
else:
|
# else:
|
||||||
event.ignore()
|
# event.ignore()
|
||||||
self.ui.btn_check.setEnabled(True)
|
# self.ui.btn_check.setEnabled(True)
|
||||||
self.ui.btn_go_back.setEnabled(True)
|
# self.ui.btn_go_back.setEnabled(True)
|
||||||
|
|
||||||
def msg_box_check_duplication_names(self, list_deleted_names): # name_point,list_deleted_names,counter_list):
|
def msg_box_check_duplication_names(self, list_deleted_names): # name_point,list_deleted_names,counter_list):
|
||||||
if len(list_deleted_names) == 1:
|
if len(list_deleted_names) == 1:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ from PyQt5.QtWidgets import (
|
||||||
from View.Plot import MplCanvas, navigation_toolbar_2qt
|
from View.Plot import MplCanvas, navigation_toolbar_2qt
|
||||||
|
|
||||||
file_path = os.path.abspath(os.path.dirname(__file__))
|
file_path = os.path.abspath(os.path.dirname(__file__))
|
||||||
icon_path = f"{os.path.dirname(os.path.dirname(file_path))}/View/ui/ressources/"
|
icon_path = f"{os.path.dirname(os.path.dirname(file_path))}/../View/ui/ressources/"
|
||||||
|
|
||||||
class Ui_MainWindow(object):
|
class Ui_MainWindow(object):
|
||||||
def setupUi(self, MainWindowProfile):
|
def setupUi(self, MainWindowProfile):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue