mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "c58620fdc21cc3818c0cc94c0d585add14eb8651" and "befe1a550ddeeed7546bf87803d6e48964534ddc" have entirely different histories.
c58620fdc2
...
befe1a550d
|
|
@ -239,10 +239,10 @@ class Profile(object):
|
||||||
# Move
|
# Move
|
||||||
|
|
||||||
def move_up_point(self, index: int):
|
def move_up_point(self, index: int):
|
||||||
if index < len(self._points):
|
if index < len(self.points):
|
||||||
next = index - 1
|
next = index - 1
|
||||||
|
|
||||||
p = self._points
|
p = self.points
|
||||||
p[index], p[next] = p[next], p[index]
|
p[index], p[next] = p[next], p[index]
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
||||||
|
|
@ -250,7 +250,7 @@ class Profile(object):
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
prev = index + 1
|
prev = index + 1
|
||||||
|
|
||||||
p = self._points
|
p = self.points
|
||||||
p[index], p[prev] = p[prev], p[index]
|
p[index], p[prev] = p[prev], p[index]
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
||||||
|
|
@ -265,7 +265,7 @@ class Profile(object):
|
||||||
def predicate(p): return p.z
|
def predicate(p): return p.z
|
||||||
|
|
||||||
self._points = sorted(
|
self._points = sorted(
|
||||||
self._points,
|
self.points,
|
||||||
key=predicate,
|
key=predicate,
|
||||||
reverse=is_reversed
|
reverse=is_reversed
|
||||||
)
|
)
|
||||||
|
|
@ -273,14 +273,14 @@ class Profile(object):
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def sort_with_indexes(self, indexes: list):
|
def sort_with_indexes(self, indexes: list):
|
||||||
if len(self._points) != len(indexes):
|
if len(self.points) != len(indexes):
|
||||||
logger.critical("Indexes list do not correspond to point list")
|
logger.critical("Indexes list do not correspond to point list")
|
||||||
|
|
||||||
self._points = list(
|
self._points = list(
|
||||||
map(
|
map(
|
||||||
lambda x: x[1],
|
lambda x: x[1],
|
||||||
sorted(
|
sorted(
|
||||||
enumerate(self._points),
|
enumerate(self.points),
|
||||||
key=lambda x: indexes[x[0]]
|
key=lambda x: indexes[x[0]]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ class Reach(SQLSubModel):
|
||||||
self.modified()
|
self.modified()
|
||||||
|
|
||||||
def move_up_profile(self, index: int):
|
def move_up_profile(self, index: int):
|
||||||
if index < len(self._profiles):
|
if index < len(self.profiles):
|
||||||
next = index - 1
|
next = index - 1
|
||||||
|
|
||||||
p = self._profiles
|
p = self._profiles
|
||||||
|
|
@ -534,7 +534,7 @@ class Reach(SQLSubModel):
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def sort_with_indexes(self, indexes: list):
|
def sort_with_indexes(self, indexes: list):
|
||||||
if len(self._profiles) != len(indexes):
|
if len(self.profiles) != len(indexes):
|
||||||
logger.critical("Indexes list do not correspond to profile list")
|
logger.critical("Indexes list do not correspond to profile list")
|
||||||
|
|
||||||
self._profiles = list(
|
self._profiles = list(
|
||||||
|
|
|
||||||
|
|
@ -319,10 +319,7 @@ class Pollutants(SQLSubModel):
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
if ext != "":
|
return True
|
||||||
return True
|
|
||||||
|
|
||||||
return cls._create_submodel(execute)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update(cls, execute, version, data=None):
|
def _db_update(cls, execute, version, data=None):
|
||||||
|
|
|
||||||
|
|
@ -45,19 +45,6 @@ _translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
class GeometryProfileTableModel(PamhyrTableModel):
|
class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
def get_true_data_row(self, row):
|
|
||||||
profile = self._data.point(row)
|
|
||||||
|
|
||||||
return next(
|
|
||||||
map(
|
|
||||||
lambda e: e[0],
|
|
||||||
filter(
|
|
||||||
lambda e: e[1] == profile,
|
|
||||||
enumerate(self._data._points)
|
|
||||||
)
|
|
||||||
), 0
|
|
||||||
)
|
|
||||||
|
|
||||||
def data(self, index, role=Qt.DisplayRole):
|
def data(self, index, role=Qt.DisplayRole):
|
||||||
if index.isValid():
|
if index.isValid():
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
|
|
@ -175,8 +162,6 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
def insert_row(self, row, parent=QModelIndex()):
|
def insert_row(self, row, parent=QModelIndex()):
|
||||||
self.beginInsertRows(parent, row, row - 1)
|
self.beginInsertRows(parent, row, row - 1)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
AddCommand(
|
AddCommand(
|
||||||
self._data, row
|
self._data, row
|
||||||
|
|
@ -191,12 +176,7 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._data, list(
|
self._data, rows
|
||||||
map(
|
|
||||||
lambda r: self.get_true_data_row(r),
|
|
||||||
rows
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -220,10 +200,10 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row + 1
|
target = row + 2
|
||||||
|
|
||||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._data, "up", row
|
self._data, "up", row
|
||||||
|
|
@ -238,9 +218,9 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row
|
target = row
|
||||||
|
|
||||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._data, "down", row
|
self._data, "down", row
|
||||||
|
|
|
||||||
|
|
@ -144,9 +144,9 @@ class SortCommand(QUndoCommand):
|
||||||
self._column = column
|
self._column = column
|
||||||
self._reverse = _reverse
|
self._reverse = _reverse
|
||||||
|
|
||||||
old = self._profile._points
|
old = self._profile.points
|
||||||
self._profile.sort(self._column, self._reverse)
|
self._profile.sort(self._column, self._reverse)
|
||||||
new = self._profile._points
|
new = self._profile.points
|
||||||
|
|
||||||
self._indexes = list(
|
self._indexes = list(
|
||||||
map(
|
map(
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,8 @@ class ProfileWindow(PamhyrWindow):
|
||||||
actions = {}
|
actions = {}
|
||||||
else:
|
else:
|
||||||
actions = {
|
actions = {
|
||||||
"action_sort_asc": self.sort_Y_ascending,
|
"action_sort_asc": self.sort_X_ascending,
|
||||||
"action_sort_des": self.sort_Y_descending,
|
"action_sort_des": self.sort_X_descending,
|
||||||
"action_up": self.move_up,
|
"action_up": self.move_up,
|
||||||
"action_down": self.move_down,
|
"action_down": self.move_down,
|
||||||
"action_add": self.add,
|
"action_add": self.add,
|
||||||
|
|
|
||||||
|
|
@ -47,19 +47,6 @@ _translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
class GeometryReachTableModel(PamhyrTableModel):
|
class GeometryReachTableModel(PamhyrTableModel):
|
||||||
def get_true_data_row(self, row):
|
|
||||||
profile = self._data.profile(row)
|
|
||||||
|
|
||||||
return next(
|
|
||||||
map(
|
|
||||||
lambda e: e[0],
|
|
||||||
filter(
|
|
||||||
lambda e: e[1] == profile,
|
|
||||||
enumerate(self._data._profiles)
|
|
||||||
)
|
|
||||||
), 0
|
|
||||||
)
|
|
||||||
|
|
||||||
def data(self, index, role=Qt.DisplayRole):
|
def data(self, index, role=Qt.DisplayRole):
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
@ -168,10 +155,10 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row + 1
|
target = row + 2
|
||||||
|
|
||||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._data, "up", row
|
self._data, "up", row
|
||||||
|
|
@ -189,7 +176,6 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._data, "down", row
|
self._data, "down", row
|
||||||
|
|
@ -226,7 +212,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def paste(self, row, header, data):
|
def paste(self, row, header, data):
|
||||||
if row > len(self._data._profiles):
|
if row > self._data.number_profiles:
|
||||||
return
|
return
|
||||||
|
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
|
|
@ -234,10 +220,9 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
|
|
||||||
true_row = self.get_true_data_row(row)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
PasteCommand(
|
PasteCommand(
|
||||||
self._data, true_row,
|
self._data, row,
|
||||||
list(
|
list(
|
||||||
map(
|
map(
|
||||||
lambda d: ProfileXYZ.from_data(header, d),
|
lambda d: ProfileXYZ.from_data(header, d),
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,9 @@ class SortCommand(QUndoCommand):
|
||||||
self._reach = reach
|
self._reach = reach
|
||||||
self._reverse = _reverse
|
self._reverse = _reverse
|
||||||
|
|
||||||
old = self._reach._profiles
|
old = self._reach.profiles
|
||||||
self._reach.sort(self._reverse)
|
self._reach.sort(self._reverse)
|
||||||
new = self._reach._profiles
|
new = self._reach.profiles
|
||||||
|
|
||||||
self._indexes = list(
|
self._indexes = list(
|
||||||
map(
|
map(
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ try:
|
||||||
from View.Doc.Window import DocWindow
|
from View.Doc.Window import DocWindow
|
||||||
_doc = "internal"
|
_doc = "internal"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Handle exception: {e}")
|
print("Handle exception: {e}")
|
||||||
_doc = "external"
|
_doc = "external"
|
||||||
|
|
||||||
from Model.Study import Study
|
from Model.Study import Study
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue