mirror of https://gitlab.com/pamhyr/pamhyr2
geometry: Profile: Start to adapt profile window.
parent
a055c80dce
commit
a9c57a9512
|
|
@ -6,7 +6,7 @@ class Profile(object):
|
|||
def __init__(self, num: int = 0,
|
||||
kp:float = 0.0, name:str = "",
|
||||
code1: int = 0, code2: int = 0,
|
||||
_type:str = ""):
|
||||
_type:str = "", reach = None):
|
||||
super(Profile, self).__init__()
|
||||
|
||||
self._num = int(num)
|
||||
|
|
@ -14,11 +14,16 @@ class Profile(object):
|
|||
self._code2 = int(code2)
|
||||
self._kp = float(kp)
|
||||
self._name = str(name)
|
||||
self._reach = reach
|
||||
|
||||
self._points: List[Point] = []
|
||||
|
||||
self._profile_type = _type
|
||||
|
||||
@property
|
||||
def reach(self):
|
||||
return self._reach
|
||||
|
||||
@property
|
||||
def num(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ class ProfileXYZ(Profile):
|
|||
def __init__(self, num: int = 0,
|
||||
code1: int = 0, code2: int = 0,
|
||||
nb_point: int = 0,
|
||||
kp: float = 0., name: str = ""):
|
||||
kp: float = 0., name: str = "",
|
||||
reach = None):
|
||||
"""ProfileXYZ constructor
|
||||
|
||||
Args:
|
||||
|
|
@ -31,6 +32,7 @@ class ProfileXYZ(Profile):
|
|||
kp = kp,
|
||||
code1 = code1, code2 = code2,
|
||||
_type = "XYZ",
|
||||
reach = reach,
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class Reach:
|
|||
Returns:
|
||||
Nothing.
|
||||
"""
|
||||
profile = ProfileXYZ()
|
||||
profile = ProfileXYZ(reach=self)
|
||||
|
||||
self._profiles.insert(index, profile)
|
||||
self._update_profile_numbers()
|
||||
|
|
@ -306,7 +306,7 @@ class Reach:
|
|||
|
||||
if list_profile and list_header:
|
||||
for ind, profile in enumerate(list_profile):
|
||||
prof = ProfileXYZ(*list_header[ind])
|
||||
prof = ProfileXYZ(*list_header[ind], reach=self)
|
||||
prof.import_points(profile)
|
||||
self._profiles.append(prof)
|
||||
self._update_profile_numbers()
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ from View.Geometry.PlotXY import PlotXY
|
|||
from View.Geometry.PlotKPC import PlotKPC
|
||||
from View.Geometry.PlotAC import PlotAC
|
||||
|
||||
from View.ASubWindow import WindowToolKit
|
||||
from View.Geometry.mainwindow_ui_reach import Ui_MainWindow
|
||||
from View.Geometry import qtableview_reach
|
||||
from View.Geometry import window_profileXYZ
|
||||
from View.ASubWindow import WindowToolKit
|
||||
from View.Geometry.Profile.ProfileWindow import ProfileWindow
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
|||
self.tableView_header = self.ui.tableView_header
|
||||
|
||||
self._tablemodel = None
|
||||
|
||||
self._profile_window = []
|
||||
self._clipboard = None
|
||||
|
||||
self.setup_window()
|
||||
|
|
@ -156,77 +156,20 @@ class GeometryWindow(QMainWindow, WindowToolKit):
|
|||
print('OK clicked')
|
||||
|
||||
def edit_profile(self):
|
||||
list_selected_row = list(
|
||||
set([index.row() for index in self.tableView.selectedIndexes()])
|
||||
)
|
||||
|
||||
self.tableView.model().blockSignals(True)
|
||||
|
||||
if len(list_selected_row) > 5:
|
||||
self.messagebox_profile_editing()
|
||||
for index in self.tableView.selectedIndexes():
|
||||
profile = self._reach.profile(index.row())
|
||||
|
||||
for selected_row in list_selected_row[:5]:
|
||||
selected_row = int(selected_row)
|
||||
profile_identifier = self._reach.get_profile_selected_identifier(selected_row)
|
||||
kp = self._reach.profile(selected_row).kp
|
||||
profile_name = self._reach.get_profile_name(selected_row)
|
||||
|
||||
if len(self.list_second_window) == 0:
|
||||
self.second_window = window_profileXYZ.View(
|
||||
selected_row + 1,
|
||||
self._reach.get_profile_via_identifier(profile_identifier),
|
||||
kp=kp, profile_name="", parent=self
|
||||
self._profile_window.append(
|
||||
ProfileWindow(
|
||||
profile = profile,
|
||||
parent = self,
|
||||
)
|
||||
self.second_window.window_title(
|
||||
kp=kp,
|
||||
profile_name=profile_name,
|
||||
profile_selected_num=selected_row
|
||||
)
|
||||
self.second_window.setWindowFlags(Qt.Window | Qt.WindowStaysOnTopHint)
|
||||
self.list_second_window.append(self.second_window)
|
||||
self.second_window.show()
|
||||
self.list_row.append(profile_identifier)
|
||||
)
|
||||
|
||||
else:
|
||||
if profile_identifier in self.list_row:
|
||||
self.list_second_window[self.list_row.index(profile_identifier)]\
|
||||
.window_title(
|
||||
kp=kp, profile_name=profile_name,
|
||||
profile_selected_num=selected_row
|
||||
)
|
||||
|
||||
self.list_second_window[
|
||||
self.list_row.index(profile_identifier)
|
||||
].setWindowFlags(Qt.Window | Qt.WindowStaysOnTopHint)
|
||||
|
||||
self.list_second_window[
|
||||
self.list_row.index(profile_identifier)
|
||||
].show()
|
||||
else:
|
||||
second_window1 = window_profileXYZ.View(
|
||||
selected_row + 1,
|
||||
self._reach.get_profile_via_identifier(profile_identifier),
|
||||
kp=kp, profile_name="", parent=self
|
||||
)
|
||||
second_window1.window_title(
|
||||
kp=kp, profile_name=profile_name,
|
||||
profile_selected_num=selected_row
|
||||
)
|
||||
|
||||
second_window1.setWindowFlags(Qt.Window | Qt.WindowStaysOnTopHint)
|
||||
second_window1.show()
|
||||
self.list_row.append(profile_identifier)
|
||||
self.list_second_window.append(second_window1)
|
||||
|
||||
widgetList = QApplication.topLevelWidgets()
|
||||
numWindows = len(widgetList)
|
||||
self.tableView.model().blockSignals(False)
|
||||
|
||||
def wind_profile_changed(self):
|
||||
self.second_window\
|
||||
.datachanged_signal[bool]\
|
||||
.connect(self.changed_profile_slot)
|
||||
|
||||
pyqtSlot(bool)
|
||||
|
||||
def changed_profile_slot(self, status):
|
||||
|
|
|
|||
|
|
@ -7,64 +7,61 @@ from PyQt5 import QtWidgets, QtGui
|
|||
from PyQt5.QtCore import QModelIndex, Qt, QEvent, QCoreApplication
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QCheckBox
|
||||
|
||||
from View.Geometry.mainwindow_ui_profile import Ui_MainWindow
|
||||
from View.Geometry.Profile.mainwindow_ui_profile import Ui_MainWindow
|
||||
|
||||
from Model.Geometry.Reach import Reach
|
||||
from View.Geometry.qtableview_profile import *
|
||||
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
||||
from View.Geometry.Profile.qtableview_profile import *
|
||||
|
||||
from View.Plot.mpl_canvas_onpick_event import OnpickEvent
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class View(QMainWindow):
|
||||
def __init__(self, profile_selected_num: int = 1,
|
||||
profile=None, pk=None, profile_name=None,
|
||||
parent=None):
|
||||
class ProfileWindow(QMainWindow):
|
||||
def __init__(self, profile=None, parent=None):
|
||||
self.parent = parent
|
||||
super(ProfileWindow, self).__init__(self.parent)
|
||||
|
||||
super(View, self).__init__(self.parent)
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
self.tableView = self.ui.tableView
|
||||
self.my_canvas = self.ui.my_canvas
|
||||
self.profile_selected_num = profile_selected_num
|
||||
|
||||
self.pk = pk
|
||||
self.profile_name = profile_name
|
||||
|
||||
self.profile_selected = profile
|
||||
self.window_title(self.pk, self.profile_name, self.profile_selected_num)
|
||||
self._profile = profile
|
||||
self._model = None
|
||||
|
||||
self.setup_window()
|
||||
self.setup_model()
|
||||
self.setup_connections()
|
||||
self.graph()
|
||||
|
||||
self.model.dataChanged.connect(self.graph)
|
||||
self._model.dataChanged.connect(self.graph)
|
||||
self.filters = "CSV files (*.csv)"
|
||||
self.fileName = None
|
||||
|
||||
self.tableView.installEventFilter(self)
|
||||
self.ui.tableView.installEventFilter(self)
|
||||
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.ui.btn_go_back.setEnabled(False)
|
||||
self.ui.btn_check.setEnabled(False)
|
||||
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_cancel_btn)
|
||||
self._model.dataChanged.connect(self.set_enable_validate_changes_btn)
|
||||
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):
|
||||
name = self._profile.name
|
||||
if self._profile.name is None or self._profile.name:
|
||||
name = _translate("MainWindowProfile", "(no name)")
|
||||
|
||||
header = _translate("MainWindowProfile", "Profile")
|
||||
|
||||
def window_title(self, pk, profile_name=None, profile_selected_num=None):
|
||||
if profile_name is None or profile_name == "":
|
||||
profile_name = _translate("MainWindowProfile", "(sans nom)")
|
||||
self.setWindowTitle(
|
||||
_translate("MainWindowProfile",
|
||||
f"Profil Pk = {pk} \t Section {profile_name} "
|
||||
f"N°: {profile_selected_num + 1} (selon "
|
||||
f"l'ordre du tableau)")
|
||||
header + " - " +
|
||||
f"{self._profile.reach.name}" + " - " +
|
||||
f"{name} ({self._profile.kp})"
|
||||
)
|
||||
|
||||
def tableview_is_modified(self):
|
||||
|
|
@ -87,45 +84,38 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.clicked.connect(self.go_back_to_initial_state)
|
||||
|
||||
def setup_model(self):
|
||||
if self.profile_selected is None:
|
||||
bief = reach.Bief("../../resources/Fichier_ST/Saar.ST")
|
||||
profile_num = 0
|
||||
self.profile_default = bief.profile[profile_num]
|
||||
self.window_title(bief.profile[0].pk, bief.profile[0].name, profile_num + 1)
|
||||
self.model = qtableview_profile.PandasModelEditable(self.profile_default)
|
||||
else:
|
||||
self.model = qtableview_profile.PandasModelEditable(self.profile_selected)
|
||||
self._last_saved_model_data = copy.deepcopy(self.model.model_data)
|
||||
self.__initial_model_data = copy.deepcopy(self.model.model_data)
|
||||
self._model = qtableview_profile.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.tableView.setModel(self.model)
|
||||
self.tableView.setItemDelegate(qtableview_profile.Delegate())
|
||||
self.ui.tableView.setModel(self._model)
|
||||
self.ui.tableView.setItemDelegate(qtableview_profile.Delegate())
|
||||
|
||||
def graph(self):
|
||||
"""
|
||||
Returns: Le tracé de la cote z en fonction de l'abscisse (calculée).
|
||||
"""
|
||||
x = self.model.station # abscisse en travers
|
||||
y = self.model.z # cote z
|
||||
ld = self.model.name # nom des points
|
||||
x_carto = self.model.x # x 'cartographique'
|
||||
y_carto = self.model.y # y 'cartographique'
|
||||
x = self._model.station # abscisse en travers
|
||||
y = self._model.z # cote z
|
||||
ld = self._model.name # nom des points
|
||||
x_carto = self._model.x # x 'cartographique'
|
||||
y_carto = self._model.y # y 'cartographique'
|
||||
|
||||
if len(self.model.x) >= 3 and len(self.model.y) >= 3 and len(self.model.station) >= 3:
|
||||
if len(self._model.x) >= 3 and len(self._model.y) >= 3 and len(self._model.station) >= 3:
|
||||
|
||||
self.my_canvas.axes.cla()
|
||||
self.my_canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
self.profile_line2D, = self.my_canvas.axes.plot(
|
||||
self.ui.canvas.axes.cla()
|
||||
self.ui.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
self.profile_line2D, = self.ui.canvas.axes.plot(
|
||||
x, y, color='r', lw=1.5, markersize=7, marker='+',
|
||||
picker=30
|
||||
)
|
||||
self.my_canvas.axes.set_xlabel(
|
||||
self.ui.canvas.axes.set_xlabel(
|
||||
_translate("MainWindowProfile",
|
||||
"Abscisse en travers (m)"),
|
||||
color='black',
|
||||
fontsize=10
|
||||
)
|
||||
self.my_canvas.axes.set_ylabel(
|
||||
self.ui.canvas.axes.set_ylabel(
|
||||
_translate("MainWindowProfile", "Cote (m)"),
|
||||
color='black', fontsize=10
|
||||
)
|
||||
|
|
@ -133,7 +123,7 @@ class View(QMainWindow):
|
|||
# Add label on graph
|
||||
self.annotation = []
|
||||
for i, txt in enumerate(list(ld)):
|
||||
annotation = self.my_canvas.axes.annotate(
|
||||
annotation = self.ui.canvas.axes.annotate(
|
||||
txt, (x[i], y[i]),
|
||||
horizontalalignment='left',
|
||||
verticalalignment='top',
|
||||
|
|
@ -157,40 +147,40 @@ class View(QMainWindow):
|
|||
arrowprops=arrowprops,
|
||||
)
|
||||
|
||||
self.my_canvas.axes.annotate("", (1, 0), xytext=(-al, 0), **kwargs)
|
||||
self.my_canvas.axes.annotate("", (0, 1), xytext=(0, -al), **kwargs) # left spin arrow
|
||||
self.ui.canvas.axes.annotate("", (1, 0), xytext=(-al, 0), **kwargs)
|
||||
self.ui.canvas.axes.annotate("", (0, 1), xytext=(0, -al), **kwargs) # left spin arrow
|
||||
|
||||
self.my_canvas.axes.spines[['top', 'right']].set_color('none')
|
||||
self.my_canvas.axes.yaxis.tick_left()
|
||||
self.my_canvas.axes.xaxis.tick_bottom()
|
||||
self.my_canvas.axes.set_facecolor('#F9F9F9') # '#E0FFFF')
|
||||
self.my_canvas.figure.patch.set_facecolor('white')
|
||||
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') # '#E0FFFF')
|
||||
self.ui.canvas.figure.patch.set_facecolor('white')
|
||||
|
||||
try:
|
||||
self.onpick_event = OnpickEvent(self.my_canvas.axes, x, y, x_carto, y_carto, self.tableView)
|
||||
self.my_canvas.figure.canvas.mpl_connect('pick_event', self.onpick_event.onpick)
|
||||
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.my_canvas.axes, x, y, x_carto, y_carto, self.tableView)
|
||||
self.my_canvas.figure.canvas.mpl_connect('button_press_event', self.onclick_event.onclick)
|
||||
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.my_canvas.figure.tight_layout()
|
||||
self.my_canvas.figure.canvas.draw_idle()
|
||||
self.ui.canvas.figure.tight_layout()
|
||||
self.ui.canvas.figure.canvas.draw_idle()
|
||||
else:
|
||||
self.my_canvas.axes.cla()
|
||||
self.my_canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
self.ui.canvas.axes.cla()
|
||||
self.ui.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
def insert_row(self):
|
||||
if len(self.tableView.selectedIndexes()) == 0:
|
||||
self.model.insertRows(self.model.rowCount(), 1)
|
||||
if len(self.ui.tableView.selectedIndexes()) == 0:
|
||||
self._model.insertRows(self._model.rowCount(), 1)
|
||||
else:
|
||||
rows = list(set([index.row() for index in self.tableView.selectedIndexes()]))
|
||||
rows = list(set([index.row() for index in self.ui.tableView.selectedIndexes()]))
|
||||
for row in rows: # [::-1]:
|
||||
self.model.insertRows(row + 1, 1)
|
||||
self._model.insertRows(row + 1, 1)
|
||||
|
||||
try:
|
||||
self.graph() # mise à jour du graphique
|
||||
self.graph()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
@ -200,10 +190,10 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.setEnabled(True)
|
||||
|
||||
def delete_row(self):
|
||||
rows = list(set([index.row() for index in self.tableView.selectedIndexes()]))
|
||||
rows = list(set([index.row() for index in self.ui.tableView.selectedIndexes()]))
|
||||
|
||||
if len(rows) > 0:
|
||||
self.model.remove_rows(rows)
|
||||
self._model.remove_rows(rows)
|
||||
|
||||
try:
|
||||
self.graph()
|
||||
|
|
@ -216,7 +206,7 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.setEnabled(True)
|
||||
|
||||
def sort_X_ascending(self):
|
||||
self.model.sort(0, order=Qt.AscendingOrder)
|
||||
self._model.sort(0, order=Qt.AscendingOrder)
|
||||
self.graph()
|
||||
self.status_change_tableview = True
|
||||
self.ui.btn_check.setEnabled(True)
|
||||
|
|
@ -224,7 +214,7 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.setEnabled(True)
|
||||
|
||||
def sort_X_descending(self):
|
||||
self.model.sort(0, order=Qt.DescendingOrder)
|
||||
self._model.sort(0, order=Qt.DescendingOrder)
|
||||
self.graph()
|
||||
self.status_change_tableview = True
|
||||
self.ui.btn_check.setEnabled(True)
|
||||
|
|
@ -232,7 +222,7 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.setEnabled(True)
|
||||
|
||||
def sort_Y_ascending(self):
|
||||
self.model.sort(1, order=Qt.AscendingOrder)
|
||||
self._model.sort(1, order=Qt.AscendingOrder)
|
||||
self.graph()
|
||||
self.status_change_tableview = True
|
||||
self.ui.btn_check.setEnabled(True)
|
||||
|
|
@ -240,7 +230,7 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.setEnabled(True)
|
||||
|
||||
def sort_Y_descending(self):
|
||||
self.model.sort(1, order=Qt.DescendingOrder)
|
||||
self._model.sort(1, order=Qt.DescendingOrder)
|
||||
self.graph()
|
||||
self.status_change_tableview = True
|
||||
self.ui.btn_check.setEnabled(True)
|
||||
|
|
@ -248,11 +238,11 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.setEnabled(True)
|
||||
|
||||
def move_row_down(self):
|
||||
rows = list(set([index.row() for index in self.tableView.selectedIndexes()]))
|
||||
rows = list(set([index.row() for index in self.ui.tableView.selectedIndexes()]))
|
||||
|
||||
for row in rows:
|
||||
if row < self.model.rowCount() - 1:
|
||||
self.model.moveRowDown(row)
|
||||
if row < self._model.rowCount() - 1:
|
||||
self._model.moveRowDown(row)
|
||||
|
||||
self.graph()
|
||||
self.status_change_tableview = True
|
||||
|
|
@ -261,11 +251,11 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.setEnabled(True)
|
||||
|
||||
def move_row_up(self):
|
||||
rows = list(set([index.row() for index in self.tableView.selectedIndexes()]))
|
||||
rows = list(set([index.row() for index in self.ui.tableView.selectedIndexes()]))
|
||||
|
||||
for row in rows:
|
||||
if 0 < row:
|
||||
self.model.moveRowUp(row)
|
||||
self._model.moveRowUp(row)
|
||||
|
||||
self.graph()
|
||||
self.status_change_tableview = True
|
||||
|
|
@ -288,7 +278,7 @@ class View(QMainWindow):
|
|||
copyAction = menu.addAction('Copy')
|
||||
pasteAction = menu.addAction('Paste')
|
||||
|
||||
if not self.tableView.selectedIndexes():
|
||||
if not self.ui.tableView.selectedIndexes():
|
||||
pass
|
||||
|
||||
return True
|
||||
|
|
@ -297,7 +287,7 @@ class View(QMainWindow):
|
|||
|
||||
def copySelection(self):
|
||||
self.clipboard.clear()
|
||||
selected = self.tableView.selectedIndexes()
|
||||
selected = self.ui.tableView.selectedIndexes()
|
||||
rows = []
|
||||
columns = []
|
||||
|
||||
|
|
@ -318,50 +308,50 @@ class View(QMainWindow):
|
|||
if not self.clipboard:
|
||||
return
|
||||
|
||||
current = self.tableView.currentIndex()
|
||||
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)
|
||||
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.tableView.selectionModel()
|
||||
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,
|
||||
# current index = self._model.index(firstRow + row,
|
||||
# firstColumn + column)
|
||||
index = self.model.index(firstRow, column)
|
||||
index = self._model.index(firstRow, column)
|
||||
|
||||
# Set the profile for the index
|
||||
self.model.setData(index, data, Qt.EditRole)
|
||||
self._model.setData(index, data, Qt.EditRole)
|
||||
# Add the index to the selection
|
||||
selection.select(index, selection.Select)
|
||||
|
||||
# Apply the selection model
|
||||
self.tableView.setSelectionModel(selection)
|
||||
self.ui.tableView.setSelectionModel(selection)
|
||||
|
||||
def copyTable(self):
|
||||
if len(self.tableView.selectedIndexes()) == 0:
|
||||
self.model.copyTable(0, self.model.rowCount())
|
||||
if len(self.ui.tableView.selectedIndexes()) == 0:
|
||||
self._model.copyTable(0, self._model.rowCount())
|
||||
else:
|
||||
rows = list(set([index.row() for index in self.tableView.selectedIndexes()]))
|
||||
rows = list(set([index.row() for index in self.ui.tableView.selectedIndexes()]))
|
||||
rows.sort()
|
||||
df = self.model.model_data.loc[rows, :]
|
||||
df = self._model.model_data.loc[rows, :]
|
||||
df.to_clipboard(header=None, index=False, excel=True, sep='\t')
|
||||
|
||||
def pasteTable(self):
|
||||
if len(self.tableView.selectedIndexes()) == 0:
|
||||
self.model.pasteTable(self.model.rowCount())
|
||||
if len(self.ui.tableView.selectedIndexes()) == 0:
|
||||
self._model.pasteTable(self._model.rowCount())
|
||||
else:
|
||||
rows = list(set([index.row() for index in self.tableView.selectedIndexes()]))
|
||||
rows = list(set([index.row() for index in self.ui.tableView.selectedIndexes()]))
|
||||
for row in rows:
|
||||
try:
|
||||
self.model.pasteTable(row + 1)
|
||||
self._model.pasteTable(row + 1)
|
||||
except:
|
||||
print("TODO")
|
||||
|
||||
|
|
@ -384,10 +374,10 @@ class View(QMainWindow):
|
|||
quoting=csv.QUOTE_NONNUMERIC,
|
||||
lineterminator='\n')
|
||||
|
||||
for row in range(self.model.rowCount(QModelIndex())):
|
||||
for row in range(self._model.rowCount(QModelIndex())):
|
||||
rowdata = []
|
||||
for column in range(self.model.columnCount(QModelIndex())):
|
||||
item = self.model.index(
|
||||
for column in range(self._model.columnCount(QModelIndex())):
|
||||
item = self._model.index(
|
||||
row, column, QModelIndex()
|
||||
).data(Qt.DisplayRole)
|
||||
|
||||
|
|
@ -412,25 +402,25 @@ class View(QMainWindow):
|
|||
row[0] = QCheckBox("-")
|
||||
buf.append(row)
|
||||
|
||||
self.model = None
|
||||
self.model = qtableview_profile.PandasModelEditable(buf)
|
||||
self.tableView.setModel(self.model)
|
||||
self._model = None
|
||||
self._model = qtableview_profile.PandasModelEditable(buf)
|
||||
self.ui.tableView.setModel(self._model)
|
||||
self.fileName = ''
|
||||
|
||||
def cancel_validate_changes(self):
|
||||
self.model.model_data = copy.deepcopy(self._last_saved_model_data)
|
||||
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._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._model.valide_all_changes()
|
||||
self.parent.update_graphic_2()
|
||||
self.parent.update_graphic_1()
|
||||
self.selected_row = list(set(
|
||||
|
|
@ -448,7 +438,7 @@ class View(QMainWindow):
|
|||
self.ui.btn_reset.setEnabled(True)
|
||||
|
||||
def delete_empty_rows(self):
|
||||
if self.model.data_contains_nan():
|
||||
if self._model.data_contains_nan():
|
||||
buttonReply = QtWidgets.QMessageBox.question(
|
||||
self,
|
||||
_translate("MainWindowProfile",
|
||||
|
|
@ -460,7 +450,7 @@ class View(QMainWindow):
|
|||
)
|
||||
|
||||
if buttonReply == QtWidgets.QMessageBox.Yes:
|
||||
self.model.delete_empty_rows()
|
||||
self._model.delete_empty_rows()
|
||||
|
||||
if buttonReply == QtWidgets.QMessageBox.No:
|
||||
pass
|
||||
|
|
@ -469,7 +459,7 @@ class View(QMainWindow):
|
|||
counter_list = []
|
||||
list_deleted_names = []
|
||||
|
||||
for ind, name_point in enumerate(self.model.name):
|
||||
for ind, name_point in enumerate(self._model.name):
|
||||
if name_point not in counter_list:
|
||||
counter_list.append(name_point)
|
||||
elif len(name_point.strip()) > 0 and name_point in counter_list:
|
||||
|
|
@ -494,8 +484,8 @@ class View(QMainWindow):
|
|||
)
|
||||
|
||||
if reply == QtWidgets.QMessageBox.Yes:
|
||||
self.model.model_data = copy.deepcopy(self.__initial_model_data)
|
||||
self.model.valide_all_changes()
|
||||
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)
|
||||
|
|
@ -544,7 +534,7 @@ class View(QMainWindow):
|
|||
)
|
||||
|
||||
if buttonReply == QtWidgets.QMessageBox.Yes:
|
||||
self.model.remove_duplicates_names()
|
||||
self._model.remove_duplicates_names()
|
||||
|
||||
def ask_quit(self):
|
||||
choice = QtWidgets.QMessageBox.question(
|
||||
|
|
@ -199,18 +199,6 @@ class Ui_MainWindow(object):
|
|||
self.verticalLayout_left.addLayout(self.horizontalLayout)
|
||||
|
||||
self.tableView = QTableView(self.widget)
|
||||
self.tableView.setStyleSheet(
|
||||
" QTableView { border: 1px solid black;\n"
|
||||
" gridline-color: blue;\n"
|
||||
" border-radius: 2px;\n"
|
||||
" border-style: solid;\n"
|
||||
" background-color: #EEF6FC; \n"
|
||||
" selection-background-color: #218ede;\n"
|
||||
" font-size: 11.5px;\n"
|
||||
" font-family: Helvetica\n"
|
||||
"\n"
|
||||
" }"
|
||||
)
|
||||
self.tableView.setObjectName("tableView")
|
||||
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
self.tableView.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
|
||||
|
|
@ -230,41 +218,18 @@ class Ui_MainWindow(object):
|
|||
self.label_graphic_help = QtWidgets.QLabel(self.widget1)
|
||||
self.label_graphic_help.setMaximumSize(QtCore.QSize(16777215, 25))
|
||||
self.label_graphic_help.setBaseSize(QtCore.QSize(0, 30))
|
||||
self.label_graphic_help.setStyleSheet(
|
||||
"QLabel { border: 1px solid blue;\n"
|
||||
" gridline-color: blue;\n"
|
||||
" border-radius: 3px;\n"
|
||||
" border-style: solid;\n"
|
||||
" background-color: #EEF6FC; \n"
|
||||
" selection-background-color: black;\n"
|
||||
" font-size: 11px;\n"
|
||||
" font-family: Helvetica\n"
|
||||
"}"
|
||||
)
|
||||
self.label_graphic_help.setObjectName("label_graphic_help")
|
||||
self.verticalLayout_right.addWidget(self.label_graphic_help)
|
||||
|
||||
self.my_canvas = MplCanvas.MplCanvas(width=5, height=4, dpi=100)
|
||||
self.my_canvas.setObjectName("my_canvas")
|
||||
self.canvas = MplCanvas.MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas")
|
||||
|
||||
self.my_toolbar = navigation_toolbar_2qt.PamHyrNavigationToolbar2QT(
|
||||
self.my_canvas, self.widget1
|
||||
)
|
||||
self.my_toolbar.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"
|
||||
" }"
|
||||
self.canvas, self.widget1
|
||||
)
|
||||
|
||||
self.verticalLayout_right.addWidget(self.my_toolbar)
|
||||
self.verticalLayout_right.addWidget(self.my_canvas)
|
||||
self.verticalLayout_right.addWidget(self.canvas)
|
||||
self.horizontalLayout_2.addWidget(self.splitter)
|
||||
|
||||
MainWindowProfile.setCentralWidget(self.centralwidget)
|
||||
|
|
|
|||
Loading…
Reference in New Issue