mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
7 Commits
befe1a550d
...
c58620fdc2
| Author | SHA1 | Date |
|---|---|---|
|
|
c58620fdc2 | |
|
|
a6341dedd2 | |
|
|
ba7171326c | |
|
|
78b4269a69 | |
|
|
a30bf8e364 | |
|
|
bd1edbaf30 | |
|
|
bdf9264963 |
|
|
@ -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,8 +319,11 @@ 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):
|
||||||
major, minor, release = version.strip().split(".")
|
major, minor, release = version.strip().split(".")
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,19 @@ _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:
|
||||||
|
|
@ -162,6 +175,8 @@ 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
|
||||||
|
|
@ -176,7 +191,12 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._data, rows
|
self._data, list(
|
||||||
|
map(
|
||||||
|
lambda r: self.get_true_data_row(r),
|
||||||
|
rows
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -200,10 +220,10 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row + 2
|
target = row + 1
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -218,9 +238,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_X_ascending,
|
"action_sort_asc": self.sort_Y_ascending,
|
||||||
"action_sort_des": self.sort_X_descending,
|
"action_sort_des": self.sort_Y_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,6 +47,19 @@ _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()
|
||||||
|
|
@ -155,10 +168,10 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row + 2
|
target = row + 1
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -176,6 +189,7 @@ 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
|
||||||
|
|
@ -212,7 +226,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def paste(self, row, header, data):
|
def paste(self, row, header, data):
|
||||||
if row > self._data.number_profiles:
|
if row > len(self._data._profiles):
|
||||||
return
|
return
|
||||||
|
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
|
|
@ -220,9 +234,10 @@ 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, row,
|
self._data, true_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("Handle exception: {e}")
|
print(f"Handle exception: {e}")
|
||||||
_doc = "external"
|
_doc = "external"
|
||||||
|
|
||||||
from Model.Study import Study
|
from Model.Study import Study
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue