mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
38
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17792ec995 | ||
|
|
40b48a2080 | ||
|
|
bddaad0193 | ||
|
|
49eb28056e | ||
|
|
ddb682dff6 | ||
|
|
89c6e8bb29 | ||
|
|
d4c596a6fe | ||
|
|
d15fa684b7 | ||
|
|
9879094661 | ||
|
|
5ce5478bf4 | ||
|
|
5fb36e7fbe | ||
|
|
0dbea26a2e | ||
|
|
b0e0dc75f1 | ||
|
|
318f6a4668 | ||
|
|
fdb5cd23e7 | ||
|
|
e064c1aee5 | ||
|
|
e0bc481ae2 | ||
|
|
081e6e7322 | ||
|
|
a0d8b9ea43 | ||
|
|
d97620ad56 | ||
|
|
6d4dc3a22b | ||
|
|
74d23386a7 | ||
|
|
9f46bcd853 | ||
|
|
bcc9dd1a0d | ||
|
|
fc40552d68 | ||
|
|
f41050fe5c | ||
|
|
97f487c0af | ||
|
|
499e16975f | ||
|
|
75f3c07cd9 | ||
|
|
0a0c00d877 | ||
|
|
8d2c18b6af | ||
|
|
2d2f83436c | ||
|
|
71914fdf57 | ||
|
|
2d7409debb | ||
|
|
beece68498 | ||
|
|
92fb653676 | ||
|
|
d8e9d786d9 | ||
|
|
7ef305e724 |
No files matched your search
+97
-61
@@ -172,8 +172,8 @@ class InternalMeshing(AMeshingTool):
|
||||
|
||||
ltot1 = 0.0
|
||||
ltot2 = 0.0
|
||||
alpha = []
|
||||
beta = []
|
||||
alpha = [0.0]
|
||||
beta = [0.0]
|
||||
# remove names
|
||||
sect2.points[start2].name = ''
|
||||
sect2.points[end2].name = ''
|
||||
@@ -196,67 +196,38 @@ class InternalMeshing(AMeshingTool):
|
||||
else: # regular case
|
||||
alpha = list(map(lambda x: x/ltot1, alpha)) # target ratios
|
||||
beta = list(map(lambda x: x/ltot2, beta)) # current ratios
|
||||
for i in range(len1 - len2):
|
||||
beta.append(1.0)
|
||||
beta.append(0.0) # beta[-1]
|
||||
# loop on the points to insert
|
||||
for k in range(len1-len2):
|
||||
trouve = False
|
||||
for j0 in range(len2):
|
||||
if trouve:
|
||||
break
|
||||
undeplus = True
|
||||
for j1 in range(j0, len2):
|
||||
if undeplus:
|
||||
if beta[j1] <= alpha[j1]:
|
||||
undeplus = False
|
||||
break
|
||||
if undeplus:
|
||||
if j0 == len2:
|
||||
trouve = True
|
||||
else:
|
||||
j1 = j0+1
|
||||
if beta[j0]-alpha[j0] > alpha[j1]-beta[j0]:
|
||||
trouve = True
|
||||
match = self._match_indices(alpha, beta)
|
||||
|
||||
if trouve:
|
||||
len2 += 1
|
||||
for i in reversed(range(j0, len2)):
|
||||
beta[i+1] = beta[i]
|
||||
if (beta[j0] == beta[j0-1]):
|
||||
# rien
|
||||
pass
|
||||
else:
|
||||
ratio = (alpha[j0] - beta[j0-1]) \
|
||||
/ (beta[j0] - beta[j0-1])
|
||||
if ratio < 0.0:
|
||||
logger.warning(f"ratio négatif {ratio}")
|
||||
# on double le point a gauche
|
||||
p = sect2.point(start2+j0-1).copy()
|
||||
sect2.insert_point(start2+j0-1, p)
|
||||
sect2.point(start2+j0-1).name = ''
|
||||
beta[j0] = beta[j0-1]
|
||||
else:
|
||||
p = sect2.point(start2+j0).copy()
|
||||
sect2.insert_point(start2+j0, p)
|
||||
sect2.point(start2+j0+1).name = ''
|
||||
sect2.point(start2+j0+1).x = \
|
||||
(1.0-ratio) * sect2.point(start2+j0).x + \
|
||||
ratio * sect2.point(start2+j0+2).x
|
||||
sect2.point(start2+j0+1).y = \
|
||||
(1.0-ratio) * sect2.point(start2+j0).y + \
|
||||
ratio * sect2.point(start2+j0+2).y
|
||||
sect2.point(start2+j0+1).z = \
|
||||
(1.0-ratio) * sect2.point(start2+j0).z + \
|
||||
ratio * sect2.point(start2+j0+2).z
|
||||
beta[j0] = (1.-ratio)*beta[j0-1] \
|
||||
+ ratio*beta[j0+1]
|
||||
insertions_per_segment = [] # liste de (index, [points])
|
||||
for j in range(len2):
|
||||
i_start = match[j]
|
||||
i_end = match[j + 1]
|
||||
q_start = sect2.point(start2 + j)
|
||||
q_end = sect2.point(start2 + j + 1)
|
||||
|
||||
new_points = []
|
||||
if i_end - i_start > 1:
|
||||
u_start, u_end = alpha[i_start], alpha[i_end]
|
||||
span = u_end - u_start
|
||||
for k in range(i_start + 1, i_end):
|
||||
ratio = (alpha[k] - u_start) / span # dans [0,1]
|
||||
p = q_start.copy()
|
||||
p.name = ''
|
||||
p.x = (1.0-ratio) * q_start.x + ratio * q_end.x
|
||||
p.y = (1.0-ratio) * q_start.y + ratio * q_end.y
|
||||
p.z = (1.0-ratio) * q_start.z + ratio * q_end.z
|
||||
new_points.append(p)
|
||||
|
||||
# à insérer après l'indice j
|
||||
insertions_per_segment.append((j, new_points))
|
||||
|
||||
# Insertion en ordre décroissant de j
|
||||
# pour ne pas perturber les indices
|
||||
for j, new_points in reversed(insertions_per_segment):
|
||||
for offset, p in enumerate(new_points):
|
||||
sect2.insert_point(start2 + j + 1 + offset, p)
|
||||
len2 += 1
|
||||
|
||||
if len1 > len2:
|
||||
for i in range(len1 - len2):
|
||||
p = sect2.point(start2+len2).copy()
|
||||
sect2.insert_point(start2+len2, p)
|
||||
sect2.point(start2+len2).name = ''
|
||||
if tag1 != "un":
|
||||
sect2.point(start2).name = tag1
|
||||
if tag2 != "np":
|
||||
@@ -264,6 +235,71 @@ class InternalMeshing(AMeshingTool):
|
||||
|
||||
sect2.modified()
|
||||
|
||||
def _match_indices(self, u_ref, v_target):
|
||||
# appariement optimal (ordre croissant) par programmation dynamique
|
||||
"""
|
||||
Trouve, pour chaque v_target[j], un indice i_j dans u_ref tel que
|
||||
i_0 < i_1 < ... < i_{m-1} et
|
||||
Sum |u_ref[i_j] - v_target[j]| soit minimal.
|
||||
|
||||
Retourne la liste des indices i_j (longueur m),
|
||||
avec i_0 = 0 et i_{m-1} = n-1 imposés
|
||||
(les extrémités se correspondent forcément).
|
||||
|
||||
"""
|
||||
n = len(u_ref)
|
||||
m = len(v_target)
|
||||
|
||||
# Les extrémités sont fixées.
|
||||
fixed_first, fixed_last = 0, n - 1
|
||||
|
||||
# DP sur les indices disponibles entre fixed_first+1 et fixed_last-1
|
||||
# dp[j][i] = coût minimal pour apparier v_target[1..j] aux indices
|
||||
# se terminant à l'indice i (i croissant strict), j de 1 à m-2.
|
||||
if m == 2:
|
||||
return [fixed_first, fixed_last]
|
||||
|
||||
# indices internes possibles
|
||||
candidates = list(range(fixed_first + 1, fixed_last))
|
||||
inner_targets = v_target[1:-1] # cibles internes (j = 1..m-2)
|
||||
|
||||
INF = float("inf")
|
||||
# dp[j] : dict indice_candidat -> (coût_min, provenance)
|
||||
dp = [{} for _ in range(len(inner_targets))]
|
||||
|
||||
for j, vt in enumerate(inner_targets):
|
||||
for idx_pos, i in enumerate(candidates):
|
||||
cost_here = abs(u_ref[i] - vt)
|
||||
if j == 0:
|
||||
# doit être > fixed_first
|
||||
dp[j][i] = (cost_here, fixed_first)
|
||||
else:
|
||||
best = (INF, None)
|
||||
for i_prev in candidates[:idx_pos]:
|
||||
if i_prev in dp[j - 1]:
|
||||
c = dp[j - 1][i_prev][0] + cost_here
|
||||
if c < best[0]:
|
||||
best = (c, i_prev)
|
||||
if best[1] is not None:
|
||||
dp[j][i] = best
|
||||
|
||||
# Reconstruction : on part du dernier niveau, on choisit le
|
||||
# meilleur indice tel que la suite jusqu'à fixed_last
|
||||
# reste croissante et valide.
|
||||
last_level = dp[-1]
|
||||
valid = {i: c for i, c in last_level.items() if i < fixed_last}
|
||||
if not valid:
|
||||
raise RuntimeError("Alignement impossible avec ces données.")
|
||||
best_i = min(valid, key=lambda i: valid[i][0])
|
||||
|
||||
chain = [best_i]
|
||||
for j in range(len(inner_targets) - 1, 0, -1):
|
||||
prev_i = dp[j][chain[-1]][1]
|
||||
chain.append(prev_i)
|
||||
chain.reverse()
|
||||
|
||||
return [fixed_first] + chain + [fixed_last]
|
||||
|
||||
def update_rk(self, reach, begin_rk, end_rk,
|
||||
step: float = 50,
|
||||
limites=[-1, -1],
|
||||
|
||||
@@ -531,7 +531,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||
new_0 = self._types[0](data[0].replace(",", "."))
|
||||
new_1 = self._types[1](data[1].replace(",", "."))
|
||||
|
||||
return (new_0, new_1)
|
||||
return Data(new_0, new_1, types=self._types, status=self._status)
|
||||
|
||||
def add(self, index: int):
|
||||
value = Data(
|
||||
@@ -543,7 +543,10 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||
return value
|
||||
|
||||
def insert(self, index: int, value):
|
||||
self._data.insert(index, value)
|
||||
if value in self._data:
|
||||
value.set_as_not_deleted()
|
||||
else:
|
||||
self._data.insert(index, value)
|
||||
self.modified()
|
||||
|
||||
def delete_i(self, indexes):
|
||||
|
||||
@@ -419,7 +419,7 @@ class BoundaryConditionTemperature(SQLSubModel):
|
||||
new_0 = self._types[0](data[0].replace(",", "."))
|
||||
new_1 = self._types[1](data[1].replace(",", "."))
|
||||
|
||||
return (new_0, new_1)
|
||||
return Data(new_0, new_1, types=self._types, status=self._status)
|
||||
|
||||
def add(self, index: int):
|
||||
value = Data(
|
||||
@@ -431,7 +431,10 @@ class BoundaryConditionTemperature(SQLSubModel):
|
||||
return value
|
||||
|
||||
def insert(self, index: int, value):
|
||||
self._data.insert(index, value)
|
||||
if value in self._data:
|
||||
value.set_as_not_deleted()
|
||||
else:
|
||||
self._data.insert(index, value)
|
||||
self.modified()
|
||||
|
||||
def delete_i(self, indexes):
|
||||
|
||||
@@ -55,8 +55,11 @@ class Point(SQLSubModel):
|
||||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
changed = self._name != name
|
||||
self._name = name
|
||||
self.modified()
|
||||
if changed and self._profile is not None:
|
||||
self._profile.content_modified()
|
||||
|
||||
def is_named(self):
|
||||
"""
|
||||
|
||||
@@ -95,12 +95,11 @@ class PointXYZ(Point):
|
||||
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
||||
)
|
||||
|
||||
if major == "0" and minor == "2":
|
||||
if int(release) < 5:
|
||||
execute(
|
||||
"CREATE INDEX idx_point " +
|
||||
"ON geometry_pointXYZ(profile, scenario);"
|
||||
)
|
||||
# Try to create index at each update
|
||||
execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_point " +
|
||||
"ON geometry_pointXYZ(profile, scenario);"
|
||||
)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
||||
@@ -329,8 +328,11 @@ class PointXYZ(Point):
|
||||
|
||||
@x.setter
|
||||
def x(self, value):
|
||||
changed = self._x != float(value)
|
||||
self._x = float(value)
|
||||
self.modified()
|
||||
if changed and self._profile is not None:
|
||||
self._profile.content_modified()
|
||||
|
||||
@property
|
||||
def y(self):
|
||||
@@ -338,8 +340,11 @@ class PointXYZ(Point):
|
||||
|
||||
@y.setter
|
||||
def y(self, value):
|
||||
changed = self._y != float(value)
|
||||
self._y = float(value)
|
||||
self.modified()
|
||||
if changed and self._profile is not None:
|
||||
self._profile.content_modified()
|
||||
|
||||
@property
|
||||
def z(self):
|
||||
@@ -347,8 +352,11 @@ class PointXYZ(Point):
|
||||
|
||||
@z.setter
|
||||
def z(self, value):
|
||||
changed = self._z != float(value)
|
||||
self._z = float(value)
|
||||
self.modified()
|
||||
if changed and self._profile is not None:
|
||||
self._profile.content_modified()
|
||||
|
||||
def shift(self, x, y, z):
|
||||
self.x += x
|
||||
|
||||
@@ -47,6 +47,8 @@ class Profile(object):
|
||||
self._sl = None
|
||||
|
||||
self._points: List[Point] = []
|
||||
self._modification_count = 0
|
||||
self._old_interpolated = ""
|
||||
|
||||
self._profile_type = _type
|
||||
|
||||
@@ -160,8 +162,13 @@ class Profile(object):
|
||||
|
||||
@rk.setter
|
||||
def rk(self, value: float):
|
||||
self._rk = float(value)
|
||||
self.modified()
|
||||
value = float(value)
|
||||
changed = value != self._rk
|
||||
self._rk = value
|
||||
if changed:
|
||||
self.content_modified()
|
||||
else:
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -173,8 +180,13 @@ class Profile(object):
|
||||
|
||||
@name.setter
|
||||
def name(self, value: str):
|
||||
self._name = value.strip()
|
||||
self.modified()
|
||||
value = value.strip()
|
||||
changed = value != self._name
|
||||
self._name = value
|
||||
if changed:
|
||||
self.content_modified()
|
||||
else:
|
||||
self.modified()
|
||||
|
||||
@property
|
||||
def sl(self):
|
||||
@@ -217,6 +229,38 @@ class Profile(object):
|
||||
return [point for point in self.points
|
||||
if point.is_named()]
|
||||
|
||||
@property
|
||||
def modification_count(self):
|
||||
"""Content revision for this session; not stored in the database."""
|
||||
return self._modification_count
|
||||
|
||||
def increase_modification_count(self):
|
||||
"""Increase content revision for this session;
|
||||
not stored in the database."""
|
||||
self._modification_count += 1
|
||||
|
||||
def decrease_modification_count(self):
|
||||
"""Decrease content revision for this session;
|
||||
not stored in the database."""
|
||||
self._modification_count -= 1
|
||||
|
||||
@property
|
||||
def old_interpolated(self):
|
||||
"""Old interpolated value for this session;
|
||||
not stored in the database."""
|
||||
return self._old_interpolated
|
||||
|
||||
@old_interpolated.setter
|
||||
def old_interpolated(self, value):
|
||||
self._old_interpolated = value
|
||||
|
||||
def content_modified(self):
|
||||
"""An edited profile is no longer an interpolation result."""
|
||||
# self._modification_count += 1
|
||||
if hasattr(self, "_interpolated"):
|
||||
self._interpolated = False
|
||||
self.modified()
|
||||
|
||||
def insert_point(self, index: int, point: Point):
|
||||
"""Insert point at index.
|
||||
|
||||
@@ -232,7 +276,7 @@ class Profile(object):
|
||||
else:
|
||||
self._points.insert(index, point)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def delete_i(self, indexes: list):
|
||||
list(
|
||||
@@ -245,7 +289,7 @@ class Profile(object):
|
||||
)
|
||||
)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def delete_points(self, points):
|
||||
"""Delete some elements in profile list
|
||||
@@ -262,7 +306,7 @@ class Profile(object):
|
||||
points
|
||||
)
|
||||
)
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
# Move
|
||||
|
||||
@@ -272,7 +316,7 @@ class Profile(object):
|
||||
|
||||
p = self._points
|
||||
p[index], p[next] = p[next], p[index]
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def move_down_point(self, index: int):
|
||||
if index >= 0:
|
||||
@@ -280,7 +324,7 @@ class Profile(object):
|
||||
|
||||
p = self._points
|
||||
p[index], p[prev] = p[prev], p[index]
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
# Sort
|
||||
|
||||
@@ -297,7 +341,7 @@ class Profile(object):
|
||||
key=predicate,
|
||||
reverse=is_reversed
|
||||
)
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
@timer
|
||||
def sort_with_indexes(self, indexes: list):
|
||||
@@ -313,12 +357,12 @@ class Profile(object):
|
||||
)
|
||||
)
|
||||
)
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
@timer
|
||||
def reverse(self):
|
||||
self._points.reverse()
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
# Sediment Layers
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
)
|
||||
self._points.append(pt)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def get_point_i(self, index: int) -> PointXYZ:
|
||||
"""Get point at index.
|
||||
@@ -624,7 +624,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
)
|
||||
self.points.append(point_xyz)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
def insert(self, index: int):
|
||||
"""Insert a new point at index.
|
||||
@@ -643,7 +643,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
point = PointXYZ(x=x, y=y, z=z, profile=self, status=self._status)
|
||||
self._points.insert(index, point)
|
||||
|
||||
self.modified()
|
||||
self.content_modified()
|
||||
|
||||
return point
|
||||
|
||||
@@ -1172,8 +1172,9 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
interpolated=self.interpolated)
|
||||
|
||||
for i, k in enumerate(self.points):
|
||||
p.insert_point(i, k.copy())
|
||||
p.insert_point(i, k.cloned_for(p))
|
||||
|
||||
p._interpolated = self.interpolated
|
||||
return p
|
||||
|
||||
def purge_aligned_points(self):
|
||||
|
||||
+28
-3
@@ -21,7 +21,7 @@ import shutil
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from tools import timer, timestamp
|
||||
from tools import timer, timestamp, parse_datetime
|
||||
from functools import reduce
|
||||
|
||||
from Model.Tools.PamhyrListExt import PamhyrModelList
|
||||
@@ -32,6 +32,7 @@ from Model.Scenario import Scenario
|
||||
from Model.Status import StudyStatus
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
from Model.River import River
|
||||
from Model.TimeShift import shift_river_times, shift_database_times
|
||||
from Model.Geometry.Reach import Reach
|
||||
from Model.HydraulicStructures.HydraulicStructures import (
|
||||
HydraulicStructure
|
||||
@@ -72,6 +73,7 @@ class Study(SQLModel):
|
||||
self.description = ""
|
||||
# Time system
|
||||
self._time_system = "time"
|
||||
self._pending_time_offset = 0.0
|
||||
self._date = datetime.fromtimestamp(0)
|
||||
|
||||
if init_new:
|
||||
@@ -198,6 +200,16 @@ class Study(SQLModel):
|
||||
self._date = date
|
||||
self.status.modified()
|
||||
|
||||
def change_start_date(self, date, preserve_dates=False):
|
||||
"""Change the origin, optionally preserving series calendar dates."""
|
||||
new_date = parse_datetime(date)
|
||||
offset = (parse_datetime(self.date) - new_date).total_seconds()
|
||||
if preserve_dates and offset:
|
||||
shift_river_times(self.river, offset)
|
||||
self._pending_time_offset += offset
|
||||
self._river_scenario_cache.clear()
|
||||
self.use_date(new_date)
|
||||
|
||||
@property
|
||||
def date(self):
|
||||
return self._date
|
||||
@@ -217,8 +229,7 @@ class Study(SQLModel):
|
||||
me.name = name
|
||||
me.description = description
|
||||
if date is not None:
|
||||
me.use_date()
|
||||
me.date = date
|
||||
me.use_date(date)
|
||||
return me
|
||||
|
||||
@classmethod
|
||||
@@ -461,6 +472,17 @@ class Study(SQLModel):
|
||||
)
|
||||
progress()
|
||||
|
||||
if self._pending_time_offset:
|
||||
self._db.execute('SAVEPOINT shift_time_origin')
|
||||
try:
|
||||
shift_database_times(self._db, self._pending_time_offset)
|
||||
self._db.execute('RELEASE SAVEPOINT shift_time_origin')
|
||||
except Exception:
|
||||
self._db.execute('ROLLBACK TO SAVEPOINT shift_time_origin')
|
||||
self._db.execute('RELEASE SAVEPOINT shift_time_origin')
|
||||
raise
|
||||
self._pending_time_offset = 0.0
|
||||
|
||||
self._save_submodel(
|
||||
[self.scenarios, self._river],
|
||||
data=progress
|
||||
@@ -595,6 +617,9 @@ class Study(SQLModel):
|
||||
self.status.stop_loading()
|
||||
self.status.scenario = old_scenario
|
||||
|
||||
if self._pending_time_offset:
|
||||
shift_river_times(river, self._pending_time_offset)
|
||||
|
||||
# FIXME: Disable scenario cache to save memory usage
|
||||
# self._river_scenario_cache[scenario] = river
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
"""Shift temporal series when preserving calendar dates across a new origin."""
|
||||
from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||
from Model.LateralContribution.LateralContribution import LateralContribution
|
||||
from Model.WeatherParameters.WeatherParameters import WeatherParameters
|
||||
from Model.BoundaryConditionsAdisTS.BoundaryConditionAdisTS import (
|
||||
BoundaryConditionAdisTS
|
||||
)
|
||||
from Model.LateralContributionsAdisTS.LateralContributionAdisTS import (
|
||||
LateralContributionAdisTS
|
||||
)
|
||||
from Model.BoundaryConditionsTemperature.BoundaryConditionTemperature import (
|
||||
BoundaryConditionTemperature
|
||||
)
|
||||
|
||||
|
||||
def shift_river_times(river, offset):
|
||||
changes = []
|
||||
seen = set()
|
||||
|
||||
def collect(obj, data):
|
||||
temporal = isinstance(obj, (
|
||||
BoundaryConditionAdisTS,
|
||||
LateralContributionAdisTS,
|
||||
BoundaryConditionTemperature
|
||||
))
|
||||
if isinstance(obj, (
|
||||
BoundaryCondition, LateralContribution, WeatherParameters
|
||||
)):
|
||||
temporal = bool(obj.header) and obj.header[0] == 'time'
|
||||
if temporal:
|
||||
for point in obj._data:
|
||||
if id(point) not in seen:
|
||||
changes.append((point, float(point[0]) + offset))
|
||||
seen.add(id(point))
|
||||
|
||||
river._data_traversal(modifier=collect)
|
||||
for point, value in changes:
|
||||
# This is a global change of origin, not a scenario-specific edit.
|
||||
point[0] = value
|
||||
|
||||
|
||||
def shift_database_times(connection, offset):
|
||||
tables = [
|
||||
(
|
||||
'boundary_condition_data', 'boundary_condition',
|
||||
'bc', BoundaryCondition
|
||||
),
|
||||
(
|
||||
'lateral_contribution_data', 'lateral_contribution',
|
||||
'lc', LateralContribution
|
||||
),
|
||||
(
|
||||
'weather_parameters_data', 'weather_parameters',
|
||||
'wp', WeatherParameters
|
||||
),
|
||||
('boundary_condition_data_adists', None, None, None),
|
||||
('lateral_contribution_data_adists', None, None, None),
|
||||
('boundary_condition_data_temperature', None, None, None),
|
||||
]
|
||||
for table, parent, fk, model in tables:
|
||||
if model is None:
|
||||
rows = connection.execute(
|
||||
f'SELECT rowid, data0 FROM {table}'
|
||||
).fetchall()
|
||||
else:
|
||||
rows = []
|
||||
for kind, in connection.execute(
|
||||
f'SELECT DISTINCT type FROM {parent}'
|
||||
):
|
||||
headers = model._get_ctor_from_type(kind)().header
|
||||
if not headers or headers[0] != 'time':
|
||||
continue
|
||||
rows.extend(connection.execute(
|
||||
f'SELECT d.rowid, d.data0 FROM {table} d JOIN {parent} p '
|
||||
f'ON p.pamhyr_id=d.{fk} AND p.scenario=d.scenario '
|
||||
f'WHERE p.type=?',
|
||||
(kind,)
|
||||
).fetchall())
|
||||
connection.executemany(
|
||||
f'UPDATE {table} SET data0=? WHERE rowid=?',
|
||||
[(float(value) + offset, rowid) for rowid, value in rows]
|
||||
)
|
||||
@@ -19,8 +19,9 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from tools import timer, parse_command_line, get_version, logger_exception
|
||||
from tools import parse_datetime
|
||||
|
||||
try:
|
||||
# Installation allow Unix-like signal
|
||||
@@ -158,11 +159,15 @@ class CommandLineSolver(AbstractSolver):
|
||||
txt = add_file.text
|
||||
txt = txt.replace("@version", get_version())
|
||||
txt = txt.replace("@date", datetime.now().isoformat(sep=" "))
|
||||
txt = self._prepare_additional_file_text(add_file.path, txt)
|
||||
|
||||
f.write(txt)
|
||||
|
||||
return files
|
||||
|
||||
def _prepare_additional_file_text(self, path, text):
|
||||
return text
|
||||
|
||||
def export_study_description(self, study, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
|
||||
+39
-11
@@ -303,7 +303,7 @@ class Mage(CommandLineSolver):
|
||||
# Point line
|
||||
wfile.write(f"{x} {y} {z} {n} {sediment}\n")
|
||||
|
||||
def _export_BC(self, t, bounds, repertory, qlog, name="0"):
|
||||
def _export_BC(self, study, t, bounds, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
if len(bounds) == 0:
|
||||
@@ -333,7 +333,7 @@ class Mage(CommandLineSolver):
|
||||
v1 = d[1]
|
||||
|
||||
if t in ["HYD", "LIM"]:
|
||||
v0 /= 60 # Convert first column to minute
|
||||
v0 /= 60 # Convert first column to minutes
|
||||
|
||||
f.write(f"{v0:9} {v1:9} \n")
|
||||
|
||||
@@ -365,10 +365,17 @@ class Mage(CommandLineSolver):
|
||||
elif bound.bctype == "SL":
|
||||
QSO.append(bound)
|
||||
|
||||
files = files + self._export_BC("AVA", AVA, repertory, qlog, name=name)
|
||||
files = files + self._export_BC("HYD", HYD, repertory, qlog, name=name)
|
||||
files = files + self._export_BC("LIM", LIM, repertory, qlog, name=name)
|
||||
files = files + self._export_QSO(QSO, repertory, qlog, name=name)
|
||||
files = files + self._export_BC(
|
||||
study, "AVA", AVA, repertory, qlog, name=name
|
||||
)
|
||||
files = files + self._export_BC(
|
||||
study, "HYD", HYD, repertory, qlog, name=name
|
||||
)
|
||||
files = files + self._export_BC(
|
||||
study, "LIM", LIM, repertory, qlog, name=name
|
||||
)
|
||||
files = files + self._export_QSO(study, QSO, repertory,
|
||||
qlog, name=name)
|
||||
|
||||
return files
|
||||
|
||||
@@ -422,10 +429,11 @@ class Mage(CommandLineSolver):
|
||||
if d.is_deleted():
|
||||
continue
|
||||
|
||||
time = d[0]
|
||||
if lateral.lctype in ["EV"]:
|
||||
f.write(f"{d[0]:10.3f}{-d[1]:10.3f}\n")
|
||||
f.write(f"{time:10.3f}{-d[1]:10.3f}\n")
|
||||
else:
|
||||
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||
f.write(f"{time:10.3f}{d[1]:10.3f}\n")
|
||||
|
||||
def _export_RUG(self, study, repertory, qlog, name="0"):
|
||||
files = []
|
||||
@@ -686,6 +694,23 @@ class Mage(CommandLineSolver):
|
||||
|
||||
return res
|
||||
|
||||
def _prepare_additional_file_text(self, path, text):
|
||||
if os.path.splitext(path)[1].lower() != ".var":
|
||||
return text
|
||||
|
||||
lines = []
|
||||
for line in text.splitlines(keepends=True):
|
||||
stripped = line.lstrip()
|
||||
fields = stripped.split()
|
||||
if stripped.startswith("$"):
|
||||
# MAGE only recognizes rule markers in the first column.
|
||||
line = stripped
|
||||
elif (not stripped.startswith("*") and len(fields) >= 2
|
||||
and fields[1] == "W2Z"):
|
||||
line = "$ " + stripped
|
||||
lines.append(line)
|
||||
return "".join(lines)
|
||||
|
||||
def _export_VAR(self, study, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
@@ -736,9 +761,11 @@ class Mage(CommandLineSolver):
|
||||
name = bhs.name
|
||||
if name == "":
|
||||
name = f"HS_{bhs.id:>3}".replace(" ", "0")
|
||||
else:
|
||||
name = name.replace(" ", "_")
|
||||
|
||||
f.write(
|
||||
f"${name} clapet"
|
||||
f"${name} clapet\n"
|
||||
)
|
||||
return files
|
||||
|
||||
@@ -964,7 +991,7 @@ class Mage8(Mage):
|
||||
|
||||
return files
|
||||
|
||||
def _export_QSO(self, bounds, repertory, qlog, name="0"):
|
||||
def _export_QSO(self, study, bounds, repertory, qlog, name="0"):
|
||||
files = []
|
||||
|
||||
if len(bounds) == 0:
|
||||
@@ -994,7 +1021,8 @@ class Mage8(Mage):
|
||||
|
||||
# Data
|
||||
for d in bound.data:
|
||||
f.write(f"{d[0]/60:10.3f}{d[1]:10.3f}\n")
|
||||
time = d[0] / 60
|
||||
f.write(f"{time:10.3f}{d[1]:10.3f}\n")
|
||||
|
||||
return files
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ from datetime import date, time, datetime, timedelta
|
||||
from tools import (
|
||||
trace, timer,
|
||||
timestamp_to_old_pamhyr_date,
|
||||
old_pamhyr_date_to_timestamp, format_datetime
|
||||
old_pamhyr_date_to_timestamp, format_datetime, parse_datetime
|
||||
)
|
||||
|
||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||
@@ -94,11 +94,12 @@ class TableModel(PamhyrTableModel):
|
||||
v = v.replace(',', '.')
|
||||
value = f"{float(v):.4f}"
|
||||
elif self._data.header[column] == "time":
|
||||
if self._opt_data == "time":
|
||||
if self.time_system == "time":
|
||||
value = timestamp_to_old_pamhyr_date(int(v))
|
||||
else:
|
||||
value = format_datetime(
|
||||
self._start_date + timedelta(seconds=float(v))
|
||||
parse_datetime(self.start_date)
|
||||
+ timedelta(seconds=float(v))
|
||||
)
|
||||
else:
|
||||
value = f"{v}"
|
||||
@@ -117,7 +118,7 @@ class TableModel(PamhyrTableModel):
|
||||
|
||||
try:
|
||||
if (self._data.header[column] == "time"
|
||||
and self._opt_data == "date"):
|
||||
and self.time_system == "date"):
|
||||
value = self.date_to_elapsed_seconds(value)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
@@ -238,17 +239,18 @@ class TableModel(PamhyrTableModel):
|
||||
if len(data) == 0:
|
||||
return
|
||||
|
||||
try:
|
||||
rows = [self._data.new_from_data(header, d) for d in data]
|
||||
except (ValueError, TypeError, IndexError) as error:
|
||||
logger.warning(error)
|
||||
return False
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.new_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
rows
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from Modules import Modules
|
||||
|
||||
from tools import timer, trace
|
||||
|
||||
from numpy import sqrt
|
||||
@@ -174,7 +176,7 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
data=self._data,
|
||||
undo=self._undo_stack,
|
||||
opt_data=self._study.time_system,
|
||||
start_date=self._study.date
|
||||
study=self._study
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -262,6 +264,11 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
self._d50sigma.set_d50(self._data.d50)
|
||||
self._d50sigma.set_sigma(self._data.sigma)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.STUDY in key:
|
||||
self._table.layoutChanged.emit()
|
||||
self.plot.update()
|
||||
|
||||
def update(self):
|
||||
self.plot.update()
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ class DelCommand(QUndoCommand):
|
||||
self._bcs.insert(self._tab, row, el)
|
||||
|
||||
def redo(self):
|
||||
self._bcs.delete_i(self._tab, self._rows)
|
||||
self._bcs.delete(self._tab, [el for _, el in self._bc])
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
|
||||
@@ -21,6 +21,7 @@ import traceback
|
||||
|
||||
from datetime import date, time, datetime, timedelta
|
||||
|
||||
from tools import parse_datetime
|
||||
from tools import (
|
||||
trace, timer,
|
||||
timestamp_to_old_pamhyr_date,
|
||||
@@ -84,11 +85,12 @@ class TableModel(PamhyrTableModel):
|
||||
if self._data._types[column] == float:
|
||||
value = f"{v:.4f}"
|
||||
elif self._data.header[column] == "time":
|
||||
if self._opt_data == "time":
|
||||
if self.time_system == "time":
|
||||
value = timestamp_to_old_pamhyr_date(int(v))
|
||||
else:
|
||||
value = format_datetime(
|
||||
self._start_date + timedelta(seconds=float(v))
|
||||
parse_datetime(self.start_date)
|
||||
+ timedelta(seconds=float(v))
|
||||
)
|
||||
else:
|
||||
value = f"{v}"
|
||||
@@ -107,7 +109,7 @@ class TableModel(PamhyrTableModel):
|
||||
|
||||
try:
|
||||
if (self._data.header[column] == "time"
|
||||
and self._opt_data == "date"):
|
||||
and self.time_system == "date"):
|
||||
value = self.date_to_elapsed_seconds(value)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
@@ -169,17 +171,18 @@ class TableModel(PamhyrTableModel):
|
||||
if len(data) == 0:
|
||||
return
|
||||
|
||||
try:
|
||||
rows = [self._data.new_from_data(header, d) for d in data]
|
||||
except (ValueError, TypeError, IndexError) as error:
|
||||
logger.warning(error)
|
||||
return False
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.new_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
rows
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from Modules import Modules
|
||||
|
||||
from tools import timer, trace
|
||||
|
||||
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||
@@ -129,7 +131,7 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
data=self._data,
|
||||
undo=self._undo_stack,
|
||||
opt_data=self._study.time_system,
|
||||
start_date=self._study.date
|
||||
study=self._study
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -162,6 +164,11 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||
self._table.dataChanged.connect(self.update)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.STUDY in key:
|
||||
self._table.layoutChanged.emit()
|
||||
self.plot.update()
|
||||
|
||||
def update(self):
|
||||
self.plot.update()
|
||||
self.plot.fit_to_data()
|
||||
|
||||
@@ -21,6 +21,7 @@ import traceback
|
||||
|
||||
from datetime import date, time, datetime, timedelta
|
||||
|
||||
from tools import parse_datetime
|
||||
from tools import (
|
||||
trace, timer,
|
||||
timestamp_to_old_pamhyr_date,
|
||||
@@ -84,11 +85,12 @@ class TableModel(PamhyrTableModel):
|
||||
if self._data._types[column] == float:
|
||||
value = f"{v:.2f}"
|
||||
elif self._data.header[column] == "time":
|
||||
if self._opt_data == "time":
|
||||
if self.time_system == "time":
|
||||
value = timestamp_to_old_pamhyr_date(int(v))
|
||||
else:
|
||||
value = format_datetime(
|
||||
self._start_date + timedelta(seconds=float(v))
|
||||
parse_datetime(self.start_date)
|
||||
+ timedelta(seconds=float(v))
|
||||
)
|
||||
else:
|
||||
value = f"{v}"
|
||||
@@ -107,7 +109,7 @@ class TableModel(PamhyrTableModel):
|
||||
|
||||
try:
|
||||
if (self._data.header[column] == "time"
|
||||
and self._opt_data == "date"):
|
||||
and self.time_system == "date"):
|
||||
value = self.date_to_elapsed_seconds(value)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
@@ -169,17 +171,18 @@ class TableModel(PamhyrTableModel):
|
||||
if len(data) == 0:
|
||||
return
|
||||
|
||||
try:
|
||||
rows = [self._data.new_from_data(header, d) for d in data]
|
||||
except (ValueError, TypeError, IndexError) as error:
|
||||
logger.warning(error)
|
||||
return False
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.new_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
rows
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from Modules import Modules
|
||||
|
||||
from tools import timer, trace
|
||||
|
||||
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||
@@ -118,7 +120,7 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
data=self._data,
|
||||
undo=self._undo_stack,
|
||||
opt_data=self._study.time_system,
|
||||
start_date=self._study.date
|
||||
study=self._study
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -151,6 +153,11 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||
self._table.dataChanged.connect(self.update)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.STUDY in key:
|
||||
self._table.layoutChanged.emit()
|
||||
self.plot.update()
|
||||
|
||||
def update(self):
|
||||
self.plot.update()
|
||||
self.plot.fit_to_data()
|
||||
|
||||
@@ -112,7 +112,7 @@ class PlotAC(PamhyrPlot):
|
||||
profile_id = 0
|
||||
|
||||
profile = self.data.profile(profile_id)
|
||||
if profile is None:
|
||||
if profile is None or self._parent.tableView.isRowHidden(profile_id):
|
||||
return
|
||||
|
||||
station = profile.get_station()
|
||||
@@ -192,21 +192,24 @@ class PlotAC(PamhyrPlot):
|
||||
self.plot_selected.set_data([], [])
|
||||
self.next_plot_selected.set_data([], [])
|
||||
|
||||
if 0 <= previous_id < self.data.number_profiles:
|
||||
if (0 <= previous_id < self.data.number_profiles
|
||||
and not self._parent.tableView.isRowHidden(previous_id)):
|
||||
self.previous_plot_selected.set_data(
|
||||
self.data.profile(previous_id).get_station(),
|
||||
self.data.profile(previous_id).z()
|
||||
)
|
||||
self.previous_plot_selected.set_visible(True)
|
||||
|
||||
if 0 <= profile_id < self.data.number_profiles:
|
||||
if (0 <= profile_id < self.data.number_profiles
|
||||
and not self._parent.tableView.isRowHidden(profile_id)):
|
||||
self.plot_selected.set_data(
|
||||
self.data.profile(profile_id).get_station(),
|
||||
self.data.profile(profile_id).z()
|
||||
)
|
||||
self.plot_selected.set_visible(True)
|
||||
|
||||
if 0 <= next_id < self.data.number_profiles:
|
||||
if (0 <= next_id < self.data.number_profiles
|
||||
and not self._parent.tableView.isRowHidden(next_id)):
|
||||
self.next_plot_selected.set_data(
|
||||
self.data.profile(next_id).get_station(),
|
||||
self.data.profile(next_id).z()
|
||||
|
||||
@@ -20,6 +20,7 @@ import logging
|
||||
|
||||
from tools import timer
|
||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||
from matplotlib.backend_bases import MouseButton
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QItemSelectionModel,
|
||||
@@ -64,7 +65,7 @@ class PlotRKZ(PamhyrPlot):
|
||||
def onpick(self, event):
|
||||
if event.mouseevent.inaxes != self.canvas.axes:
|
||||
return
|
||||
if event.mouseevent.button.value != 1:
|
||||
if event.mouseevent.button != MouseButton.LEFT:
|
||||
return
|
||||
|
||||
modifiers = QApplication.keyboardModifiers()
|
||||
@@ -110,9 +111,9 @@ class PlotRKZ(PamhyrPlot):
|
||||
def _closest_rk(self, event):
|
||||
|
||||
s = event.artist.get_segments()
|
||||
x = [i[0, 0] for i in s]
|
||||
mx = event.mouseevent.xdata
|
||||
points = enumerate(x)
|
||||
points = [(i, segment[0, 0]) for i, segment in enumerate(s)
|
||||
if len(segment)]
|
||||
|
||||
def dist_mouse(point):
|
||||
x = point[1]
|
||||
@@ -136,6 +137,7 @@ class PlotRKZ(PamhyrPlot):
|
||||
if len(ind) == 0:
|
||||
return
|
||||
|
||||
ind = [i for i in ind if not self._table.isRowHidden(i)]
|
||||
for i in ind:
|
||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
||||
|
||||
@@ -150,18 +152,7 @@ class PlotRKZ(PamhyrPlot):
|
||||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
||||
|
||||
def _select_range_in_table(self, ind1, ind2):
|
||||
if self._table is not None:
|
||||
self._table.setFocus()
|
||||
selection = self._table.selectionModel()
|
||||
index = QItemSelection(self._table.model().index(ind1, 0),
|
||||
self._table.model().index(ind2, 0))
|
||||
selection.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
self._table.scrollTo(self._table.model().index(ind2, 0))
|
||||
self._select_in_table(list(range(ind1, ind2 + 1)))
|
||||
|
||||
@timer
|
||||
def redraw(self, data):
|
||||
@@ -213,13 +204,23 @@ class PlotRKZ(PamhyrPlot):
|
||||
picker=10,
|
||||
)
|
||||
|
||||
if self._table is not None:
|
||||
segments = self.line_rk_zmin_zmax.get_segments()
|
||||
self.line_rk_zmin_zmax.set_segments([
|
||||
segment[:0] if self._table.isRowHidden(row) else segment
|
||||
for row, segment in enumerate(segments)
|
||||
])
|
||||
|
||||
def color_highlight(self):
|
||||
rows = sorted(list(
|
||||
set(
|
||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
||||
)
|
||||
))
|
||||
colors = [self.color_plot for row in range(len(self._data))]
|
||||
colors = [
|
||||
"darkorange" if profile.interpolated else self.color_plot
|
||||
for profile in self._data.profiles
|
||||
]
|
||||
style = ["-" for row in range(len(self._data))]
|
||||
if len(rows) > 0:
|
||||
for row in rows:
|
||||
|
||||
+17
-19
@@ -18,6 +18,7 @@
|
||||
|
||||
from tools import timer, trace
|
||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||
from matplotlib.backend_bases import MouseButton
|
||||
from matplotlib import collections
|
||||
import numpy as np
|
||||
|
||||
@@ -60,7 +61,7 @@ class PlotXY(PamhyrPlot):
|
||||
def onpick(self, event):
|
||||
if event.mouseevent.inaxes != self.canvas.axes:
|
||||
return
|
||||
if event.mouseevent.button.value != 1:
|
||||
if event.mouseevent.button != MouseButton.LEFT:
|
||||
return
|
||||
|
||||
modifiers = QApplication.keyboardModifiers()
|
||||
@@ -136,6 +137,7 @@ class PlotXY(PamhyrPlot):
|
||||
index = QItemSelection()
|
||||
if len(ind) == 0:
|
||||
return
|
||||
ind = [i for i in ind if not self._table.isRowHidden(i)]
|
||||
for i in ind:
|
||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
||||
selection.select(
|
||||
@@ -149,18 +151,7 @@ class PlotXY(PamhyrPlot):
|
||||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
||||
|
||||
def _select_range_in_table(self, ind1, ind2):
|
||||
if self._table is not None:
|
||||
self._table.setFocus()
|
||||
selection = self._table.selectionModel()
|
||||
index = QItemSelection(self._table.model().index(ind1, 0),
|
||||
self._table.model().index(ind2, 0))
|
||||
selection.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
self._table.scrollTo(self._table.model().index(ind2, 0))
|
||||
self._select_in_table(list(range(ind1, ind2 + 1)))
|
||||
|
||||
@timer
|
||||
def redraw(self, data):
|
||||
@@ -189,10 +180,14 @@ class PlotXY(PamhyrPlot):
|
||||
|
||||
def draw_xy(self):
|
||||
self.line_xy = []
|
||||
for xy in zip(self.data.get_x(), self.data.get_y()):
|
||||
self.line_xy.append(np.column_stack(xy))
|
||||
for row, profile in enumerate(self.data.profiles):
|
||||
hidden = self._table is not None and self._table.isRowHidden(row)
|
||||
self.line_xy.append(
|
||||
np.empty((0, 2)) if hidden or len(profile) == 0
|
||||
else np.column_stack((profile.x(), profile.y()))
|
||||
)
|
||||
|
||||
self._colors, self._style = self.color_hightlight()
|
||||
self._colors, self._style = self.color_highlight()
|
||||
self.line_xy_collection = collections.LineCollection(
|
||||
self.line_xy,
|
||||
colors=self._colors,
|
||||
@@ -201,13 +196,16 @@ class PlotXY(PamhyrPlot):
|
||||
)
|
||||
self.canvas.axes.add_collection(self.line_xy_collection)
|
||||
|
||||
def color_hightlight(self):
|
||||
def color_highlight(self):
|
||||
rows = sorted(list(
|
||||
set(
|
||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
||||
)
|
||||
))
|
||||
colors = [self.color_plot for row in range(len(self._data))]
|
||||
colors = [
|
||||
"darkorange" if profile.interpolated else self.color_plot
|
||||
for profile in self._data.profiles
|
||||
]
|
||||
style = ["-" for row in range(len(self._data))]
|
||||
if len(rows) > 0:
|
||||
for row in rows:
|
||||
@@ -320,7 +318,7 @@ class PlotXY(PamhyrPlot):
|
||||
|
||||
def update_current(self):
|
||||
if self._current_data_update:
|
||||
self._colors, self._style = self.color_hightlight()
|
||||
self._colors, self._style = self.color_highlight()
|
||||
self.line_xy_collection.set_colors(self._colors)
|
||||
self.line_xy_collection.set_linestyle(self._style)
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ from math import dist, sqrt
|
||||
|
||||
from tools import timer, trace
|
||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||
from matplotlib.backend_bases import MouseButton
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QCoreApplication, QItemSelectionModel,
|
||||
@@ -111,7 +112,7 @@ class Plot(PamhyrPlot):
|
||||
def onpick(self, event):
|
||||
if event.mouseevent.inaxes != self.canvas.axes:
|
||||
return
|
||||
if event.mouseevent.button.value != 1:
|
||||
if event.mouseevent.button != MouseButton.LEFT:
|
||||
return
|
||||
|
||||
modifiers = QApplication.keyboardModifiers()
|
||||
@@ -126,11 +127,11 @@ class Plot(PamhyrPlot):
|
||||
def onclick(self, event):
|
||||
if event.inaxes != self.canvas.axes:
|
||||
return
|
||||
if event.button.value == 1:
|
||||
if event.button not in (MouseButton.MIDDLE, MouseButton.RIGHT):
|
||||
return
|
||||
|
||||
z = self._get_z_from_click(event)
|
||||
if z < self.data.z_min() or event.button.value == 2:
|
||||
if z < self.data.z_min() or event.button == MouseButton.MIDDLE:
|
||||
self.highlight = None
|
||||
self.draw_highligth()
|
||||
self.update_idle()
|
||||
|
||||
@@ -37,6 +37,11 @@ class SetDataCommand(QUndoCommand):
|
||||
self._index = index
|
||||
self._old = old_value
|
||||
self._new = self.type(new_value)
|
||||
if self._profile.old_interpolated == "":
|
||||
if self._profile.interpolated:
|
||||
self._profile.old_interpolated = "interpolated"
|
||||
else:
|
||||
self._profile.old_interpolated = "not_interpolated"
|
||||
|
||||
|
||||
class SetXCommand(SetDataCommand):
|
||||
@@ -46,10 +51,19 @@ class SetXCommand(SetDataCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).x = self._old
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.point(self._index).x = self._new
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -60,10 +74,19 @@ class SetYCommand(SetDataCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).y = self._old
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.point(self._index).y = self._new
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -74,10 +97,19 @@ class SetZCommand(SetDataCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).z = self._old
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.point(self._index).z = self._new
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -89,9 +121,20 @@ class SetNameCommand(SetDataCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).name = self._old
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.point(self._index).name = self._new
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
@@ -104,6 +147,13 @@ class AddCommand(QUndoCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.delete_i([self._index])
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
@@ -111,7 +161,8 @@ class AddCommand(QUndoCommand):
|
||||
self._point = self._profile.insert(self._index)
|
||||
else:
|
||||
self._profile.insert_point(self._index, self._point)
|
||||
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -125,10 +176,19 @@ class DelCommand(QUndoCommand):
|
||||
def undo(self):
|
||||
for point in self._points:
|
||||
point.set_as_not_deleted()
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.delete_points(self._points)
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -153,10 +213,19 @@ class SortCommand(QUndoCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.sort_with_indexes(self._indexes)
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.sort(self._column, self._reverse)
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -173,6 +242,13 @@ class MoveCommand(QUndoCommand):
|
||||
self._profile.move_up_point(self._i)
|
||||
else:
|
||||
self._profile.move_down_point(self._i)
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
@@ -180,6 +256,8 @@ class MoveCommand(QUndoCommand):
|
||||
self._profile.move_up_point(self._i)
|
||||
else:
|
||||
self._profile.move_down_point(self._i)
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.interpolated = False
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -191,10 +269,19 @@ class ReverseCommand(QUndoCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.reverse()
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._profile.reverse()
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -209,10 +296,19 @@ class PurgeCommand(QUndoCommand):
|
||||
def undo(self):
|
||||
for point in self._deleted:
|
||||
point.set_as_not_deleted()
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
self._deleted = self._profile.purge(self._np_purge)
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
|
||||
|
||||
@@ -228,9 +324,18 @@ class PasteCommand(QUndoCommand):
|
||||
|
||||
def undo(self):
|
||||
self._profile.delete_points(self._points)
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
self._profile.modified()
|
||||
|
||||
def redo(self):
|
||||
for point in self._points:
|
||||
self._profile.insert_point(self._row, point)
|
||||
self._profile.interpolated = False
|
||||
self._profile.increase_modification_count()
|
||||
self._profile.modified()
|
||||
@@ -45,6 +45,9 @@ class GeometryTranslate(MainTranslate):
|
||||
self._dict["cross_sections"] = _translate("Geometry", "cross-sections")
|
||||
self._dict["profile"] = _translate("Geometry", "cross-section")
|
||||
self._dict["profiles"] = _translate("Geometry", "cross-sections")
|
||||
self._dict["show_interpolated_profiles"] = _translate(
|
||||
"Geometry", "Show interpolated profiles"
|
||||
)
|
||||
self._dict["cross_section_enabled_count"] = _translate(
|
||||
"Geometry", "Cross-section enabled ({count} disabled)"
|
||||
)
|
||||
|
||||
@@ -41,6 +41,7 @@ class SetDataCommand(QUndoCommand):
|
||||
self._index = index
|
||||
self._old = old_value
|
||||
self._new = self.type(new_value)
|
||||
self._profile = self._reach.profile(self._index)
|
||||
|
||||
|
||||
class SetNameCommand(SetDataCommand):
|
||||
@@ -48,24 +49,52 @@ class SetNameCommand(SetDataCommand):
|
||||
self.type = str
|
||||
super(SetNameCommand, self).__init__(
|
||||
reach, index, old_value, new_value)
|
||||
if self._profile.old_interpolated == "":
|
||||
if self._profile.interpolated:
|
||||
self._profile.old_interpolated = "interpolated"
|
||||
else:
|
||||
self._profile.old_interpolated = "not_interpolated"
|
||||
|
||||
def undo(self):
|
||||
self._reach.profile(self._index).name = self._old
|
||||
self._profile.name = self._old
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
|
||||
def redo(self):
|
||||
self._reach.profile(self._index).name = self._new
|
||||
# Name setter will automatically update the interpolated attribute
|
||||
self._profile.name = self._new
|
||||
self._profile.increase_modification_count()
|
||||
|
||||
|
||||
class SetRKCommand(SetDataCommand):
|
||||
def __init__(self, reach, index, old_value, new_value):
|
||||
self.type = float
|
||||
super(SetRKCommand, self).__init__(reach, index, old_value, new_value)
|
||||
if self._profile.old_interpolated == "":
|
||||
if self._profile.interpolated:
|
||||
self._profile.old_interpolated = "interpolated"
|
||||
else:
|
||||
self._profile.old_interpolated = "not_interpolated"
|
||||
|
||||
def undo(self):
|
||||
self._reach.profile(self._index).rk = self._old
|
||||
self._profile.rk = self._old
|
||||
self._profile.decrease_modification_count()
|
||||
if self._profile.modification_count == 0:
|
||||
if self._profile.old_interpolated == "interpolated":
|
||||
self._profile.interpolated = True
|
||||
else:
|
||||
self._profile.interpolated = False
|
||||
self._profile.old_interpolated = ""
|
||||
|
||||
def redo(self):
|
||||
self._reach.profile(self._index).rk = self._new
|
||||
# RK setter will automatically update the interpolated attribute
|
||||
self._profile.rk = self._new
|
||||
self._profile.increase_modification_count()
|
||||
|
||||
|
||||
class SetEnabledCommand(QUndoCommand):
|
||||
|
||||
@@ -127,6 +127,9 @@ class GeometryWindow(PamhyrWindow):
|
||||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_checkbox(self):
|
||||
self.find(QCheckBox, "checkBox_show_interpolated").setText(
|
||||
self._trad["show_interpolated_profiles"]
|
||||
)
|
||||
self._checkbox = self.find(QCheckBox, "checkBox_enabled")
|
||||
self._set_checkbox_state()
|
||||
|
||||
@@ -197,6 +200,18 @@ class GeometryWindow(PamhyrWindow):
|
||||
self._status_label.setText(txt)
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QCheckBox, "checkBox_show_interpolated").toggled.connect(
|
||||
self.update_interpolated_profiles_visibility
|
||||
)
|
||||
self.find(QCheckBox, "checkBox_show_interpolated").toggled.connect(
|
||||
self.update_redraw
|
||||
)
|
||||
self._table.modelReset.connect(
|
||||
self.update_interpolated_profiles_visibility)
|
||||
self._table.rowsInserted.connect(
|
||||
self.update_interpolated_profiles_visibility)
|
||||
self._table.rowsRemoved.connect(
|
||||
self.update_interpolated_profiles_visibility)
|
||||
if self._study.is_read_only():
|
||||
actions = {
|
||||
"action_export": self.export_to_file,
|
||||
@@ -237,6 +252,24 @@ class GeometryWindow(PamhyrWindow):
|
||||
def update(self):
|
||||
self._update()
|
||||
|
||||
def update_interpolated_profiles_visibility(self):
|
||||
show_interpolated = self.find(
|
||||
QCheckBox, "checkBox_show_interpolated"
|
||||
).isChecked()
|
||||
selection = self.tableView.selectionModel()
|
||||
for row in range(self._table.rowCount()):
|
||||
hidden = not show_interpolated \
|
||||
and self._reach.profile(row).interpolated
|
||||
self.tableView.setRowHidden(row, hidden)
|
||||
if hidden:
|
||||
selection.select(
|
||||
self._table.index(row, 0),
|
||||
QItemSelectionModel.Deselect | QItemSelectionModel.Rows
|
||||
)
|
||||
if selection.currentIndex().row() == row:
|
||||
selection.setCurrentIndex(QModelIndex(),
|
||||
QItemSelectionModel.NoUpdate)
|
||||
|
||||
def update_redraw(self):
|
||||
self._update(redraw=True)
|
||||
|
||||
@@ -248,6 +281,7 @@ class GeometryWindow(PamhyrWindow):
|
||||
self.find(QAction, "action_meshing").setEnabled(enabled)
|
||||
|
||||
def _update(self, redraw=False, propagate=True):
|
||||
self.update_interpolated_profiles_visibility()
|
||||
self.update_meshing_action()
|
||||
|
||||
if redraw:
|
||||
@@ -498,6 +532,7 @@ class GeometryWindow(PamhyrWindow):
|
||||
data=self._reach,
|
||||
trad=self._trad,
|
||||
toolbar=self._toolbar_ac,
|
||||
parent=self,
|
||||
)
|
||||
self._plot_ac.draw()
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
from tools import timer
|
||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||
from matplotlib.backend_bases import MouseButton
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
QCoreApplication, Qt,
|
||||
@@ -243,7 +244,7 @@ class PlotRKC(PamhyrPlot):
|
||||
def onpick(self, event):
|
||||
if event.mouseevent.inaxes != self.canvas.axes:
|
||||
return
|
||||
if event.mouseevent.button.value != 1:
|
||||
if event.mouseevent.button != MouseButton.LEFT:
|
||||
return
|
||||
|
||||
modifiers = QApplication.keyboardModifiers()
|
||||
|
||||
@@ -20,6 +20,7 @@ import logging
|
||||
import traceback
|
||||
from datetime import date, time, datetime, timedelta
|
||||
|
||||
from tools import parse_datetime
|
||||
from tools import (
|
||||
trace, timer,
|
||||
timestamp_to_old_pamhyr_date,
|
||||
@@ -73,11 +74,12 @@ class TableModel(PamhyrTableModel):
|
||||
if self._data.get_type_column(column) == float:
|
||||
value = f"{v:.4f}"
|
||||
elif self._data.header[column] == "time":
|
||||
if self._opt_data == "time":
|
||||
if self.time_system == "time":
|
||||
value = timestamp_to_old_pamhyr_date(int(v))
|
||||
else:
|
||||
value = format_datetime(
|
||||
self._start_date + timedelta(seconds=float(v))
|
||||
parse_datetime(self.start_date)
|
||||
+ timedelta(seconds=float(v))
|
||||
)
|
||||
else:
|
||||
value = f"{v}"
|
||||
@@ -96,7 +98,7 @@ class TableModel(PamhyrTableModel):
|
||||
|
||||
try:
|
||||
if (self._data.header[column] == "time"
|
||||
and self._opt_data == "date"):
|
||||
and self.time_system == "date"):
|
||||
value = self.date_to_elapsed_seconds(value)
|
||||
|
||||
self._undo.push(
|
||||
@@ -184,17 +186,18 @@ class TableModel(PamhyrTableModel):
|
||||
if len(data) == 0:
|
||||
return
|
||||
|
||||
try:
|
||||
rows = [self._data.new_from_data(header, d) for d in data]
|
||||
except (ValueError, TypeError, IndexError) as error:
|
||||
logger.warning(error)
|
||||
return False
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.new_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
rows
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from Modules import Modules
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel, QCoreApplication,
|
||||
)
|
||||
@@ -110,7 +112,7 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
undo=self._undo_stack,
|
||||
trad=self._trad,
|
||||
opt_data=self._study.time_system,
|
||||
start_date=self._study.date
|
||||
study=self._study
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -146,6 +148,11 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
self._table.dataChanged.connect(self.update)
|
||||
self._table.layoutChanged.connect(self.update)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.STUDY in key:
|
||||
self._table.layoutChanged.emit()
|
||||
self.plot.update()
|
||||
|
||||
def update(self):
|
||||
self.plot.update()
|
||||
self.plot.fit_to_data()
|
||||
|
||||
@@ -127,7 +127,7 @@ class PlotXY(PamhyrPlot):
|
||||
for xy in zip(self.data.get_x(), self.data.get_y()):
|
||||
self.line_xy.append(np.column_stack(xy))
|
||||
|
||||
self._colors, self._style = self.color_hightlight()
|
||||
self._colors, self._style = self.color_highlight()
|
||||
self.line_xy_collection = collections.LineCollection(
|
||||
self.line_xy,
|
||||
colors=self._colors,
|
||||
@@ -136,7 +136,7 @@ class PlotXY(PamhyrPlot):
|
||||
)
|
||||
self.canvas.axes.add_collection(self.line_xy_collection)
|
||||
|
||||
def color_hightlight(self):
|
||||
def color_highlight(self):
|
||||
rk_min, rk_max = (-1, -1)
|
||||
if self._highlight_data is not None:
|
||||
rk_min, rk_max = self._highlight_data
|
||||
@@ -250,7 +250,7 @@ class PlotXY(PamhyrPlot):
|
||||
|
||||
def update_current(self):
|
||||
if self._current_data_update:
|
||||
self._colors, self._style = self.color_hightlight()
|
||||
self._colors, self._style = self.color_highlight()
|
||||
self.line_xy_collection.set_colors(self._colors)
|
||||
self.line_xy_collection.set_linestyle(self._style)
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import logging
|
||||
import traceback
|
||||
from datetime import date, time, datetime, timedelta
|
||||
|
||||
from tools import parse_datetime
|
||||
from tools import (
|
||||
trace, timer,
|
||||
timestamp_to_old_pamhyr_date,
|
||||
@@ -87,11 +88,12 @@ class TableModel(PamhyrTableModel):
|
||||
if self._data._types[column] == float:
|
||||
value = f"{v:.4f}"
|
||||
elif self._data.header[column] == "time":
|
||||
if self._opt_data == "time":
|
||||
if self.time_system == "time":
|
||||
value = timestamp_to_old_pamhyr_date_adists(int(v))
|
||||
else:
|
||||
value = format_datetime(
|
||||
self._start_date + timedelta(seconds=float(v))
|
||||
parse_datetime(self.start_date)
|
||||
+ timedelta(seconds=float(v))
|
||||
)
|
||||
else:
|
||||
value = f"{v}"
|
||||
@@ -110,7 +112,7 @@ class TableModel(PamhyrTableModel):
|
||||
|
||||
try:
|
||||
if (self._data.header[column] == "time"
|
||||
and self._opt_data == "date"):
|
||||
and self.time_system == "date"):
|
||||
value = self.date_to_elapsed_seconds(value)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
|
||||
@@ -29,6 +29,8 @@ from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel, QCoreApplication,
|
||||
)
|
||||
|
||||
from Modules import Modules
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
@@ -57,6 +59,15 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||
name = trad[self._pamhyr_name]
|
||||
|
||||
if self._data is not None:
|
||||
pollutant_name = next(
|
||||
(
|
||||
pollutant.name
|
||||
for pollutant in study.river.Pollutants.Pollutants_List
|
||||
if pollutant.id == self._data.pollutant
|
||||
),
|
||||
None
|
||||
)
|
||||
|
||||
if self._data.reach is not None:
|
||||
reach_name = next(filter(
|
||||
lambda reach: reach.id == self._data.reach,
|
||||
@@ -75,12 +86,10 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||
else:
|
||||
end_rk = trad['not_associated']
|
||||
|
||||
name += (
|
||||
f" - {study.name} - " +
|
||||
f"{reach_name} - " +
|
||||
f"({begin_rk} - " +
|
||||
f"{end_rk})"
|
||||
)
|
||||
name += f" - {study.name}"
|
||||
if pollutant_name is not None:
|
||||
name += f" - {pollutant_name}"
|
||||
name += f" - {reach_name} - ({begin_rk} - {end_rk})"
|
||||
|
||||
super(EditLateralContributionAdisTSWindow, self).__init__(
|
||||
title=name,
|
||||
@@ -125,7 +134,7 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||
undo=self._undo_stack,
|
||||
trad=self._trad,
|
||||
opt_data=self._study.time_system,
|
||||
start_date=self._study.date
|
||||
study=self._study
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -159,6 +168,11 @@ class EditLateralContributionAdisTSWindow(PamhyrWindow):
|
||||
|
||||
self._table.dataChanged.connect(self.update)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.STUDY in key:
|
||||
self._table.layoutChanged.emit()
|
||||
self.plot.update()
|
||||
|
||||
def update(self):
|
||||
self.plot.update()
|
||||
self.plot.fit_to_data()
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# PlotXY.py -- Pamhyr
|
||||
# Copyright (C) 2023-2026 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from View.Geometry.PlotXY import PlotXY as GeometryPlotXY
|
||||
|
||||
|
||||
class PlotXY(GeometryPlotXY):
|
||||
"""Geometry plot highlighting the lateral-contribution extent."""
|
||||
|
||||
def color_highlight(self):
|
||||
rk_min, rk_max = (-1, -1)
|
||||
if self.highlight is not None:
|
||||
rk_min, rk_max = self.highlight
|
||||
|
||||
colors = [
|
||||
self.color_plot_river_bottom for _ in range(len(self.data))
|
||||
]
|
||||
for index, rk in enumerate(self.data.get_rk_complete_profiles()):
|
||||
if rk_min <= rk <= rk_max:
|
||||
colors[index] = self.color_plot_current
|
||||
|
||||
styles = ["-" for _ in range(len(self.data))]
|
||||
return colors, styles
|
||||
@@ -45,7 +45,7 @@ from View.LateralContributionsAdisTS.Table import (
|
||||
)
|
||||
|
||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||
from View.Geometry.PlotXY import PlotXY
|
||||
from View.LateralContributionsAdisTS.PlotXY import PlotXY
|
||||
from View.LateralContributionsAdisTS.translate \
|
||||
import LCTranslate
|
||||
from View.LateralContributionsAdisTS.Edit.Window \
|
||||
|
||||
+65
-31
@@ -61,6 +61,7 @@ from View.WaitingDialog import WaitingDialog
|
||||
|
||||
from View.MainWindowTabInfo import WidgetInfo
|
||||
from View.MainWindowTabChecker import WidgetChecker
|
||||
from View.MainWindowTabGraph import WidgetGraph
|
||||
|
||||
from View.Configure.Window import ConfigureWindow
|
||||
from View.Study.Window import NewStudyWindow
|
||||
@@ -235,6 +236,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
|
||||
def setup_tab(self):
|
||||
self.setup_tab_info()
|
||||
self.setup_tab_graph()
|
||||
self.setup_tab_checker()
|
||||
|
||||
def setup_tab_info(self):
|
||||
@@ -261,6 +263,19 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
self._trad["tab_checker_name"]
|
||||
)
|
||||
|
||||
def setup_tab_graph(self):
|
||||
tab_widget = self.findChild(QTabWidget, "tabWidget")
|
||||
|
||||
self._tab_widget_graph = WidgetGraph(
|
||||
study=self._study, trad=self._trad, parent=self
|
||||
)
|
||||
|
||||
tab_widget.insertTab(
|
||||
0, self._tab_widget_graph,
|
||||
self._trad["tab_graph_name"]
|
||||
)
|
||||
tab_widget.setCurrentWidget(self._tab_widget_graph)
|
||||
|
||||
def enable_actions(self, action: str, enable: bool):
|
||||
"""Enable of disable an action componant
|
||||
|
||||
@@ -545,6 +560,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
self._do_propagate_update_rec(window, keys)
|
||||
|
||||
self._tab_widget_checker.update(modules=keys)
|
||||
self._tab_widget_graph.update()
|
||||
|
||||
def _do_propagate_update_info_tab(self, keys):
|
||||
modules = Modules.modelling_list()
|
||||
@@ -570,6 +586,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
self._tab_widget_info.study = self._study
|
||||
self._tab_widget_info.update()
|
||||
|
||||
if self._tab_widget_graph.study != self._study:
|
||||
self._tab_widget_graph.study = self._study
|
||||
self._tab_widget_graph.update()
|
||||
|
||||
if self._tab_widget_checker.study != self._study:
|
||||
self._tab_widget_checker.study = self._study
|
||||
self._tab_widget_checker.update(modules=Modules.STUDY)
|
||||
@@ -898,13 +918,32 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
# MSG AND DIALOG #
|
||||
##################
|
||||
|
||||
def msg_select_reach(self):
|
||||
self.message_box(
|
||||
window_title=self._trad["Warning"],
|
||||
text=self._trad["mb_select_reach_title"],
|
||||
informative_text=self._trad["mb_select_reach_msg"]
|
||||
def ensure_current_reach(self):
|
||||
"""Offer a reach selection when needed;
|
||||
return False on cancellation."""
|
||||
if self._study is None:
|
||||
return False
|
||||
river = self._study.river
|
||||
if river.has_current_reach():
|
||||
return True
|
||||
edges = list(river.edges())
|
||||
if not edges:
|
||||
QMessageBox.information(
|
||||
self, self._trad["Select reach"], self._trad["no_reach"]
|
||||
)
|
||||
return False
|
||||
labels = [f"{edge.name or self._trad['reach']} (#{edge.id})"
|
||||
for edge in edges]
|
||||
selected, accepted = QInputDialog.getItem(
|
||||
self, self._trad["Select reach"],
|
||||
self._trad["reach"] + ":", labels, 0, False
|
||||
)
|
||||
self.open_network()
|
||||
if not accepted:
|
||||
return False
|
||||
river.set_current_reach(edges[labels.index(selected)])
|
||||
self._tab_widget_graph.update()
|
||||
self._propagate_update(key=Modules.NETWORK)
|
||||
return True
|
||||
|
||||
def dialog_reopen_study(self):
|
||||
dlg = QMessageBox(self)
|
||||
@@ -1287,6 +1326,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
return
|
||||
|
||||
self.network = NetworkWindow(study=self._study, parent=self)
|
||||
self.network.networkChanged.connect(
|
||||
self._tab_widget_graph.update, Qt.QueuedConnection
|
||||
)
|
||||
self.network.show()
|
||||
|
||||
def open_scenarios(self):
|
||||
@@ -1336,7 +1378,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
if (self._study is not None and self._study.river.has_current_reach()):
|
||||
if self.ensure_current_reach():
|
||||
reach = self._study.river.current_reach().reach
|
||||
|
||||
if self.sub_window_exists(
|
||||
@@ -1356,9 +1398,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
)
|
||||
geometry.show()
|
||||
return geometry
|
||||
else:
|
||||
self.msg_select_reach()
|
||||
return None
|
||||
return None
|
||||
|
||||
def open_meshing(self):
|
||||
"""Open the current reach geometry and its meshing dialog."""
|
||||
@@ -1441,27 +1481,24 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
strick.show()
|
||||
|
||||
def open_frictions(self):
|
||||
if self._study is not None:
|
||||
if self._study.river.has_current_reach():
|
||||
reach = self._study.river.current_reach()
|
||||
if self.ensure_current_reach():
|
||||
reach = self._study.river.current_reach()
|
||||
|
||||
if self.sub_window_exists(
|
||||
FrictionsWindow,
|
||||
data=[self._study, self.conf, reach]
|
||||
):
|
||||
return
|
||||
if self.sub_window_exists(
|
||||
FrictionsWindow,
|
||||
data=[self._study, self.conf, reach]
|
||||
):
|
||||
return
|
||||
|
||||
frictions = FrictionsWindow(
|
||||
study=self._study,
|
||||
config=self.conf,
|
||||
parent=self
|
||||
)
|
||||
frictions.show()
|
||||
else:
|
||||
self.msg_select_reach()
|
||||
frictions = FrictionsWindow(
|
||||
study=self._study,
|
||||
config=self.conf,
|
||||
parent=self
|
||||
)
|
||||
frictions.show()
|
||||
|
||||
def open_initial_conditions(self):
|
||||
if self._study.river.has_current_reach():
|
||||
if self.ensure_current_reach():
|
||||
reach = self._study.river.current_reach()
|
||||
|
||||
if self.sub_window_exists(
|
||||
@@ -1477,8 +1514,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
parent=self
|
||||
)
|
||||
initial.show()
|
||||
else:
|
||||
self.msg_select_reach()
|
||||
|
||||
def open_additional_files(self):
|
||||
if self._study is not None:
|
||||
@@ -1552,8 +1587,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
)
|
||||
return
|
||||
|
||||
if not self._study.river.has_current_reach():
|
||||
self.msg_select_reach()
|
||||
if not self.ensure_current_reach():
|
||||
return
|
||||
|
||||
reach = self._study.river.current_reach().reach
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
# MainWindowTabGraph.py -- Pamhyr
|
||||
# Copyright (C) 2026 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||
from View.PlotXY import PlotXY
|
||||
from View.Network.GraphWidget import GraphWidget
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import (
|
||||
QWidget, QGroupBox, QLabel, QHBoxLayout, QVBoxLayout, QSplitter,
|
||||
)
|
||||
|
||||
|
||||
class WidgetGraph(QWidget):
|
||||
"""Read-only network graph displayed in the main window."""
|
||||
|
||||
def __init__(self, study=None, trad=None, parent=None):
|
||||
super(WidgetGraph, self).__init__(parent)
|
||||
|
||||
self._study = study
|
||||
self._trad = trad
|
||||
self._plot_river = None
|
||||
|
||||
layout = QHBoxLayout(self)
|
||||
self._splitter = QSplitter(Qt.Horizontal, self)
|
||||
self._splitter.setChildrenCollapsible(False)
|
||||
layout.addWidget(self._splitter)
|
||||
self._graph_widget = None
|
||||
|
||||
self._graph_group = QGroupBox(
|
||||
self._trad["graph_network_title"], self
|
||||
)
|
||||
self._graph_layout = QVBoxLayout(self._graph_group)
|
||||
|
||||
self._graph_title = QLabel(self._graph_group)
|
||||
self._graph_title.setTextFormat(Qt.PlainText)
|
||||
self._graph_title.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
|
||||
self._graph_title.setWordWrap(True)
|
||||
self._graph_layout.addWidget(self._graph_title)
|
||||
self._update_graph_title()
|
||||
self._splitter.addWidget(self._graph_group)
|
||||
|
||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
||||
self.canvas.setObjectName("canvas_graph")
|
||||
self.toolbar = PamhyrPlotToolbar(
|
||||
self.canvas, self,
|
||||
items=["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
)
|
||||
self._plot_group = QGroupBox(
|
||||
self._trad["graph_geographic_title"], self
|
||||
)
|
||||
self._plot_layout = QVBoxLayout(self._plot_group)
|
||||
self._plot_layout.addWidget(self.toolbar)
|
||||
self._plot_layout.addWidget(self.canvas, 1)
|
||||
self._splitter.addWidget(self._plot_group)
|
||||
self._splitter.setStretchFactor(0, 1)
|
||||
self._splitter.setStretchFactor(1, 1)
|
||||
self._splitter.setSizes([1000, 1000])
|
||||
|
||||
self.plot = PlotXY(
|
||||
canvas=self.canvas,
|
||||
data=None,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar,
|
||||
parent=self
|
||||
)
|
||||
|
||||
@property
|
||||
def study(self):
|
||||
return self._study
|
||||
|
||||
@study.setter
|
||||
def study(self, study):
|
||||
self._study = study
|
||||
self._update_graph_title()
|
||||
|
||||
def _update_graph_title(self):
|
||||
self._graph_title.setText(
|
||||
self._study.name if self._study is not None else ""
|
||||
)
|
||||
|
||||
def update(self):
|
||||
river = self._study.river if self._study is not None else None
|
||||
view = None
|
||||
if river is not None and river is self._plot_river:
|
||||
axes = self.canvas.axes
|
||||
if axes.has_data():
|
||||
view = (axes.get_xlim(), axes.get_ylim(),
|
||||
axes.get_aspect(), axes.get_adjustable())
|
||||
|
||||
self._update_graph_title()
|
||||
if (self._graph_widget is not None
|
||||
and (self._study is None
|
||||
or self._graph_widget.graph is not self._study.river)):
|
||||
self._graph_layout.removeWidget(self._graph_widget)
|
||||
self._graph_widget.deleteLater()
|
||||
self._graph_widget = None
|
||||
|
||||
if self._study is not None and self._graph_widget is None:
|
||||
self._graph_widget = GraphWidget(
|
||||
self._study.river,
|
||||
parent=self,
|
||||
only_display=True,
|
||||
trad=self._trad,
|
||||
)
|
||||
self._graph_layout.addWidget(self._graph_widget, 1)
|
||||
elif self._graph_widget is not None:
|
||||
self._graph_widget.display_update()
|
||||
|
||||
data = None
|
||||
geotiff = None
|
||||
if self._study is not None:
|
||||
data = self._study.river.enable_edges()
|
||||
geotiff = self._study.river.geotiff
|
||||
|
||||
self.plot = PlotXY(
|
||||
canvas=self.canvas,
|
||||
data=data,
|
||||
geotiff=geotiff,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar,
|
||||
parent=self
|
||||
)
|
||||
self.plot.update()
|
||||
self._plot_river = river
|
||||
if view is not None:
|
||||
x_limits, y_limits, aspect, adjustable = view
|
||||
self.canvas.axes.set_aspect(aspect, adjustable=adjustable)
|
||||
self.canvas.axes.set_xlim(x_limits)
|
||||
self.canvas.axes.set_ylim(y_limits)
|
||||
self.canvas.draw_idle()
|
||||
@@ -448,6 +448,7 @@ class NewEdgeLine(QGraphicsItem):
|
||||
class GraphWidget(QGraphicsView):
|
||||
changeEdge = pyqtSignal(object)
|
||||
changeNode = pyqtSignal(object)
|
||||
currentEdgeChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, graph, parent=None,
|
||||
min_size=(400, 400), max_size=None,
|
||||
@@ -476,6 +477,7 @@ class GraphWidget(QGraphicsView):
|
||||
self.m_origin_x = 0.0
|
||||
self.m_origin_y = 0.0
|
||||
self.clicked = False
|
||||
self._panning = False
|
||||
|
||||
self.setup_scene(min_size, max_size, size)
|
||||
|
||||
@@ -491,8 +493,8 @@ class GraphWidget(QGraphicsView):
|
||||
self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
|
||||
self.setResizeAnchor(QGraphicsView.AnchorViewCenter)
|
||||
|
||||
self.scale(1, 1)
|
||||
self.previousScale = 1
|
||||
self.scale(0.7, 0.7)
|
||||
self.previousScale = 0.7
|
||||
self.centerOn(1000.0, 1000.0)
|
||||
|
||||
if min_size:
|
||||
@@ -667,6 +669,13 @@ class GraphWidget(QGraphicsView):
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
# Scene items are destroyed by clear(); do not retain hover/selection
|
||||
# references to them when refreshing another view of the same graph.
|
||||
self._selected_item = None
|
||||
self._selected_new_edge_src_node = None
|
||||
self._current_edge = None
|
||||
self._current_moved_node = None
|
||||
self.tmp_line = None
|
||||
self.scene().clear()
|
||||
self.create_items()
|
||||
|
||||
@@ -875,6 +884,9 @@ class GraphWidget(QGraphicsView):
|
||||
|
||||
if previous_edge:
|
||||
previous_edge.update()
|
||||
edge.update()
|
||||
if previous_edge is not edge:
|
||||
self.currentEdgeChanged.emit()
|
||||
except Exception as e:
|
||||
logger.warning(str(e))
|
||||
|
||||
@@ -937,6 +949,8 @@ class GraphWidget(QGraphicsView):
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
if self._only_display:
|
||||
if event.button() == Qt.LeftButton:
|
||||
self._start_pan(event)
|
||||
return
|
||||
|
||||
if event.button() == Qt.RightButton \
|
||||
@@ -959,6 +973,12 @@ class GraphWidget(QGraphicsView):
|
||||
self._selected_new_edge_src_node = None
|
||||
|
||||
items = self.items(event.pos())
|
||||
if event.button() == Qt.LeftButton and not any(
|
||||
isinstance(item, (NodeItem, EdgeItem, NodeText))
|
||||
for item in items
|
||||
):
|
||||
self._start_pan(event)
|
||||
return
|
||||
if items and type(items[0]) is EdgeItem:
|
||||
edge = items[0]
|
||||
if edge:
|
||||
@@ -1007,7 +1027,10 @@ class GraphWidget(QGraphicsView):
|
||||
def mouseReleaseEvent(self, event):
|
||||
self.clicked = False
|
||||
|
||||
if self._only_display:
|
||||
if self._panning or self._only_display:
|
||||
self._panning = False
|
||||
self.viewport().unsetCursor()
|
||||
event.accept()
|
||||
return
|
||||
|
||||
locked = self.graph._status.is_read_only()
|
||||
@@ -1029,7 +1052,28 @@ class GraphWidget(QGraphicsView):
|
||||
self.update()
|
||||
super(GraphWidget, self).mouseReleaseEvent(event)
|
||||
|
||||
def _start_pan(self, event):
|
||||
self.clicked = True
|
||||
self._panning = True
|
||||
self.m_origin_x = event.x()
|
||||
self.m_origin_y = event.y()
|
||||
self.viewport().setCursor(Qt.ClosedHandCursor)
|
||||
event.accept()
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
if self._panning or self._only_display:
|
||||
if self._panning and event.buttons() & Qt.LeftButton:
|
||||
dx = event.x() - self.m_origin_x
|
||||
dy = event.y() - self.m_origin_y
|
||||
horizontal = self.horizontalScrollBar()
|
||||
vertical = self.verticalScrollBar()
|
||||
horizontal.setValue(horizontal.value() - dx)
|
||||
vertical.setValue(vertical.value() - dy)
|
||||
self.m_origin_x = event.x()
|
||||
self.m_origin_y = event.y()
|
||||
event.accept()
|
||||
return
|
||||
|
||||
pos = self.mapToScene(event.pos())
|
||||
locked = self.graph._status.is_read_only()
|
||||
|
||||
@@ -1061,20 +1105,6 @@ class GraphWidget(QGraphicsView):
|
||||
|
||||
# If state is "move"
|
||||
if self._state == "move":
|
||||
# Move on scene
|
||||
if not self.selected_item():
|
||||
if event.buttons() & Qt.LeftButton:
|
||||
old_p = self.mapToScene(
|
||||
int(self.m_origin_x), int(self.m_origin_y)
|
||||
)
|
||||
new_p = self.mapToScene(event.pos())
|
||||
translation = new_p - old_p
|
||||
|
||||
self.translate(translation.x(), translation.y())
|
||||
|
||||
self.m_origin_x = event.x()
|
||||
self.m_origin_y = event.y()
|
||||
|
||||
# Propagate event
|
||||
self.update()
|
||||
super(GraphWidget, self).mouseMoveEvent(event)
|
||||
|
||||
@@ -64,7 +64,17 @@ class SelectProfileDialog(PamhyrDialog):
|
||||
|
||||
self._reach = reach
|
||||
self._profile = None
|
||||
self._profiles = self._reach.reach.enabled_profiles
|
||||
self._profiles = list(self._reach.reach.profiles)
|
||||
structure_profiles = [
|
||||
structure.input_section
|
||||
for structure in study.river.hydraulic_structures.lst
|
||||
if structure.input_reach is reach and not structure.is_deleted()
|
||||
]
|
||||
self._selectable_indices = [
|
||||
index for index, profile in enumerate(self._profiles)
|
||||
if 0 < index < len(self._profiles) - 1
|
||||
and profile not in structure_profiles
|
||||
]
|
||||
|
||||
self.setup_combobox()
|
||||
|
||||
@@ -74,19 +84,28 @@ class SelectProfileDialog(PamhyrDialog):
|
||||
list(
|
||||
map(
|
||||
lambda p: p.display_name(),
|
||||
self._reach.reach.profiles[1:-1]
|
||||
self._profiles
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if len(self._profiles) == 0:
|
||||
self.find(QDialogButtonBox, "buttonBox")\
|
||||
.button(QDialogButtonBox.Ok)\
|
||||
.setEnabled(False)
|
||||
combobox = self.find(QComboBox, "comboBox")
|
||||
for index in range(len(self._profiles)):
|
||||
if index not in self._selectable_indices:
|
||||
item = combobox.model().item(index)
|
||||
item.setFlags(item.flags() &
|
||||
~(Qt.ItemIsEnabled | Qt.ItemIsSelectable))
|
||||
|
||||
combobox.setCurrentIndex(
|
||||
self._selectable_indices[0] if self._selectable_indices else -1
|
||||
)
|
||||
self.find(QDialogButtonBox, "buttonBox")\
|
||||
.button(QDialogButtonBox.Ok)\
|
||||
.setEnabled(bool(self._selectable_indices))
|
||||
|
||||
def accept(self):
|
||||
index = self.find(QComboBox, "comboBox").currentIndex()
|
||||
if not 0 <= index < len(self._profiles):
|
||||
if index not in self._selectable_indices:
|
||||
return
|
||||
|
||||
self._profile = self._profiles[index]
|
||||
|
||||
@@ -58,6 +58,8 @@ _translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class NetworkWindow(PamhyrWindow):
|
||||
networkChanged = pyqtSignal()
|
||||
|
||||
_pamhyr_ui = "Network"
|
||||
_pamhyr_name = "River network"
|
||||
|
||||
@@ -140,6 +142,8 @@ class NetworkWindow(PamhyrWindow):
|
||||
self._graph_layout.addWidget(self._graph_widget)
|
||||
|
||||
def setup_connections(self):
|
||||
self._undo_stack.indexChanged.connect(self.networkChanged)
|
||||
self._graph_widget.currentEdgeChanged.connect(self.networkChanged)
|
||||
self._nodes_model.dataChanged.connect(self.update)
|
||||
self._reachs_model.dataChanged.connect(
|
||||
self._graph_widget.display_update)
|
||||
|
||||
@@ -76,11 +76,14 @@ class PlotRKC(PamhyrPlot):
|
||||
@staticmethod
|
||||
def reach_geometry(reach):
|
||||
"""Return geometry values for profiles present in the results."""
|
||||
# The study's enabled profiles can change after a calculation. Keep
|
||||
# coordinates in the same order as the result profiles and columns.
|
||||
profiles = reach.profiles
|
||||
return (
|
||||
reach.geometry.get_rk_enabled_profiles(),
|
||||
reach.geometry.get_z_min_enabled_profiles(),
|
||||
reach.geometry.get_z_max_enabled_profiles()
|
||||
)
|
||||
[profile.rk for profile in profiles],
|
||||
[profile.geometry.z_min() for profile in profiles],
|
||||
[profile.geometry.z_max() for profile in profiles],
|
||||
)
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
|
||||
@@ -24,6 +24,7 @@ import numpy as np
|
||||
|
||||
from tools import timer, trace, logger_exception
|
||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||
from matplotlib.backend_bases import MouseButton
|
||||
from matplotlib import collections
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
@@ -89,7 +90,7 @@ class PlotXY(PamhyrPlot):
|
||||
def onpick(self, event):
|
||||
if event.mouseevent.inaxes != self.canvas.axes:
|
||||
return
|
||||
if event.mouseevent.button.value != 1:
|
||||
if event.mouseevent.button != MouseButton.LEFT:
|
||||
return
|
||||
|
||||
modifiers = QApplication.keyboardModifiers()
|
||||
|
||||
@@ -45,6 +45,36 @@ logger = logging.getLogger()
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ValueDelegate(QItemDelegate):
|
||||
"""Use a combo box for solver parameters backed by an index."""
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
choices = index.model().value_choices(index)
|
||||
if choices is None:
|
||||
return QLineEdit(parent)
|
||||
|
||||
editor = QComboBox(parent)
|
||||
for value, label in choices.items():
|
||||
editor.addItem(label, value)
|
||||
return editor
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
if isinstance(editor, QComboBox):
|
||||
current = index.model().raw_value(index)
|
||||
editor.setCurrentIndex(editor.findData(current))
|
||||
else:
|
||||
editor.setText(str(index.model().raw_value(index)))
|
||||
|
||||
def setModelData(self, editor, model, index):
|
||||
if isinstance(editor, QComboBox):
|
||||
model.setData(index, editor.currentData())
|
||||
else:
|
||||
model.setData(index, editor.text())
|
||||
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
editor.setGeometry(option.rect)
|
||||
|
||||
|
||||
class TableModel(PamhyrTableModel):
|
||||
def _setup_lst(self):
|
||||
self._tab = self._opt_data
|
||||
@@ -68,6 +98,10 @@ class TableModel(PamhyrTableModel):
|
||||
elif cname == "value":
|
||||
value = self._lst.get(row)[cname]
|
||||
|
||||
choices = self.value_choices(index)
|
||||
if choices is not None:
|
||||
return choices.get(value, value)
|
||||
|
||||
if value in self._trad.get_dict("yes_no"):
|
||||
value = self._trad.get_dict("yes_no")[value]
|
||||
|
||||
@@ -79,7 +113,14 @@ class TableModel(PamhyrTableModel):
|
||||
if not index.isValid() or role != Qt.EditRole:
|
||||
return False
|
||||
|
||||
if self.is_same_data(index, value):
|
||||
choices = self.value_choices(index)
|
||||
if choices is not None:
|
||||
reverse_choices = {label: key for key, label in choices.items()}
|
||||
value = reverse_choices.get(value, value)
|
||||
if str(self.raw_value(index)) == str(value):
|
||||
return False
|
||||
|
||||
elif self.is_same_data(index, value):
|
||||
return False
|
||||
|
||||
row = index.row()
|
||||
@@ -103,6 +144,15 @@ class TableModel(PamhyrTableModel):
|
||||
self.dataChanged.emit(index, index)
|
||||
return True
|
||||
|
||||
def value_choices(self, index):
|
||||
if not index.isValid():
|
||||
return None
|
||||
name = self._lst.get(index.row())["name"]
|
||||
return self._trad.get_dict("indexed_values").get(name)
|
||||
|
||||
def raw_value(self, index):
|
||||
return self._lst.get(index.row())["value"]
|
||||
|
||||
def undo(self):
|
||||
self._undo.undo()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
@@ -41,7 +41,7 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from View.SolverParameters.UndoCommand import *
|
||||
from View.SolverParameters.Table import TableModel
|
||||
from View.SolverParameters.Table import TableModel, ValueDelegate
|
||||
from View.SolverParameters.translate import ParamTranslate
|
||||
|
||||
from Solver.Solvers import solver_long_name, solver_type_list
|
||||
@@ -103,6 +103,7 @@ class SolverParametersWindow(PamhyrWindow):
|
||||
opt_data=st,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
editable_headers=editable_headers,
|
||||
delegates={"value": ValueDelegate(table)},
|
||||
trad=self._trad,
|
||||
undo=self._undo_stack[st],
|
||||
)
|
||||
|
||||
@@ -50,6 +50,30 @@ class ParamTranslate(MainTranslate):
|
||||
_translate("SolverParameters", "N"): "n",
|
||||
}
|
||||
|
||||
self._sub_dict["indexed_values"] = {
|
||||
"mage_shields_critique": {
|
||||
"1": _translate("SolverParameters", "Constant (0.047)"),
|
||||
"2": _translate("SolverParameters", "Soulsby (1997)"),
|
||||
"3": _translate("SolverParameters", "Camenen (2012)"),
|
||||
},
|
||||
"mage_shields_correction": {
|
||||
"0": _translate("SolverParameters", "No correction"),
|
||||
"1": _translate("SolverParameters", "Effective Shields"),
|
||||
},
|
||||
"mage_capacite_solide": {
|
||||
"1": _translate(
|
||||
"SolverParameters", "Meyer-Peter & Muller (1948)"
|
||||
),
|
||||
"2": _translate(
|
||||
"SolverParameters", "Camenen & Larson (2005)"
|
||||
),
|
||||
"3": _translate(
|
||||
"SolverParameters", "Engelund & Hansen (1967)"
|
||||
),
|
||||
"4": _translate("SolverParameters", "Recking (2013)"),
|
||||
},
|
||||
}
|
||||
|
||||
self._sub_dict["names"] = {
|
||||
"all_init_time":
|
||||
_translate("SolverParameters",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import logging
|
||||
|
||||
from datetime import datetime
|
||||
from tools import get_user_name
|
||||
from tools import get_user_name, parse_datetime, format_datetime
|
||||
|
||||
from Modules import Modules
|
||||
from Model.Study import Study
|
||||
@@ -34,7 +34,7 @@ from PyQt5.QtGui import (
|
||||
from PyQt5.QtWidgets import (
|
||||
QRadioButton, QLabel, QDateTimeEdit,
|
||||
QTextEdit, QPlainTextEdit, QTextBrowser,
|
||||
QPushButton,
|
||||
QPushButton, QMessageBox,
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
@@ -155,7 +155,80 @@ All right reserved.
|
||||
self.find(QLabel, "label_date").setEnabled(True)
|
||||
self.find(QDateTimeEdit, "dateTimeEdit_date").setEnabled(True)
|
||||
|
||||
def _close_study_editors(self):
|
||||
def close_children(parent):
|
||||
for _, window in list(parent.sub_win_list):
|
||||
if window is self:
|
||||
continue
|
||||
if not close_children(window):
|
||||
return False
|
||||
if not window.close():
|
||||
return False
|
||||
undo = getattr(window, "_undo_stack", None)
|
||||
if undo is not None:
|
||||
undo.clear()
|
||||
window.deleteLater()
|
||||
return True
|
||||
|
||||
return close_children(self.parent)
|
||||
|
||||
def accept(self):
|
||||
preserve_dates = False
|
||||
if (
|
||||
self._study is not None
|
||||
and self._study.time_system == "date"
|
||||
and self.get_radio_button("radioButton_date")
|
||||
):
|
||||
old_date = parse_datetime(self._study.date)
|
||||
new_date = parse_datetime(
|
||||
self.get_datetime_edit("dateTimeEdit_date")
|
||||
)
|
||||
if new_date != old_date:
|
||||
dialog = QMessageBox(self)
|
||||
dialog.setWindowTitle(_translate(
|
||||
"Study", "Change simulation start date?"
|
||||
))
|
||||
dialog.setText(_translate(
|
||||
"Study", "How should the data dates change?"
|
||||
))
|
||||
dialog.setInformativeText(_translate(
|
||||
"Study",
|
||||
"Previous start: {old}\nNew start: {new}\n\n"
|
||||
"Shift dates: keep elapsed simulation times unchanged.\n"
|
||||
"Keep dates: adjust elapsed times so calendar dates "
|
||||
"stay unchanged."
|
||||
).format(
|
||||
old=format_datetime(old_date),
|
||||
new=format_datetime(new_date)
|
||||
))
|
||||
shift = dialog.addButton(
|
||||
_translate("Study", "Shift dates"),
|
||||
QMessageBox.AcceptRole
|
||||
)
|
||||
keep = dialog.addButton(
|
||||
_translate("Study", "Keep dates"),
|
||||
QMessageBox.ActionRole
|
||||
)
|
||||
cancel = dialog.addButton(QMessageBox.Cancel)
|
||||
dialog.setDefaultButton(cancel)
|
||||
dialog.exec()
|
||||
if dialog.clickedButton() not in (shift, keep):
|
||||
return
|
||||
preserve_dates = dialog.clickedButton() is keep
|
||||
|
||||
if self._study is not None:
|
||||
date_mode = self.get_radio_button("radioButton_date")
|
||||
mode_changed = date_mode != (self._study.time_system == "date")
|
||||
date_changed = date_mode and (
|
||||
parse_datetime(self.get_datetime_edit("dateTimeEdit_date"))
|
||||
!= parse_datetime(self._study.date)
|
||||
)
|
||||
if (
|
||||
(mode_changed or date_changed)
|
||||
and not self._close_study_editors()
|
||||
):
|
||||
return
|
||||
|
||||
name = self.get_line_edit_text("lineEdit_name")
|
||||
description = self.get_plaintext_edit_text("plainTextEdit_description")
|
||||
|
||||
@@ -172,7 +245,9 @@ All right reserved.
|
||||
self._study.description = description
|
||||
if self.get_radio_button("radioButton_date"):
|
||||
date = self.get_datetime_edit("dateTimeEdit_date")
|
||||
self._study.use_date(date)
|
||||
self._study.change_start_date(
|
||||
date, preserve_dates=preserve_dates
|
||||
)
|
||||
else:
|
||||
self._study.use_time()
|
||||
|
||||
|
||||
@@ -62,8 +62,22 @@ class PamhyrTextDelegate(QStyledItemDelegate):
|
||||
|
||||
|
||||
class PamhyrTableModel(QAbstractTableModel):
|
||||
@property
|
||||
def time_system(self):
|
||||
return (
|
||||
self._study.time_system
|
||||
if self._study is not None else self._opt_data
|
||||
)
|
||||
|
||||
@property
|
||||
def start_date(self):
|
||||
return (
|
||||
self._study.date
|
||||
if self._study is not None else self._start_date
|
||||
)
|
||||
|
||||
def date_to_elapsed_seconds(self, value):
|
||||
"""Convert an entered date to seconds since the study start date."""
|
||||
"""Convert an accepted calendar date to elapsed simulation seconds."""
|
||||
try:
|
||||
entered_date = parse_datetime(value)
|
||||
except ValueError as error:
|
||||
@@ -81,7 +95,7 @@ class PamhyrTableModel(QAbstractTableModel):
|
||||
)
|
||||
raise error
|
||||
|
||||
return (entered_date - self._start_date).total_seconds()
|
||||
return (entered_date - parse_datetime(self.start_date)).total_seconds()
|
||||
|
||||
def _setup_delegates(self):
|
||||
if self._table_view is None:
|
||||
@@ -110,7 +124,7 @@ class PamhyrTableModel(QAbstractTableModel):
|
||||
opt_data=None,
|
||||
options=["rows_selection"],
|
||||
parent=None,
|
||||
start_date=None):
|
||||
start_date=None, study=None):
|
||||
super(PamhyrTableModel, self).__init__()
|
||||
|
||||
self._table_view = table_view
|
||||
@@ -128,6 +142,7 @@ class PamhyrTableModel(QAbstractTableModel):
|
||||
self._undo = undo
|
||||
self._lst = []
|
||||
self._start_date = start_date
|
||||
self._study = study
|
||||
|
||||
self._setup_delegates()
|
||||
self._setup_lst()
|
||||
|
||||
+11
-6
@@ -175,6 +175,15 @@ class MainTranslate(UnitTranslate):
|
||||
self._dict["tab_checker_name"] = _translate(
|
||||
"MainWindow", "Checks"
|
||||
)
|
||||
self._dict["tab_graph_name"] = _translate(
|
||||
"MainWindow", "Graph"
|
||||
)
|
||||
self._dict["graph_network_title"] = _translate(
|
||||
"MainWindow", "Hydrographic network"
|
||||
)
|
||||
self._dict["graph_geographic_title"] = _translate(
|
||||
"MainWindow", "Geographic view"
|
||||
)
|
||||
|
||||
self._dict["open_debug"] = _translate(
|
||||
"MainWindow", "Open debug window"
|
||||
@@ -200,13 +209,9 @@ class MainTranslate(UnitTranslate):
|
||||
self._dict["Warning"] = _translate(
|
||||
"MainWindow", "Warning"
|
||||
)
|
||||
self._dict["mb_select_reach_title"] = _translate(
|
||||
"MainWindow", "Please select a reach"
|
||||
)
|
||||
self._dict["mb_select_reach_msg"] = _translate(
|
||||
self._dict["no_reach"] = _translate(
|
||||
"MainWindow",
|
||||
"This edition window need a reach selected "
|
||||
"into the river network to work on it"
|
||||
"Create a reach in the network before opening this window."
|
||||
)
|
||||
|
||||
self._dict["mb_last_open_title"] = _translate(
|
||||
|
||||
@@ -20,6 +20,7 @@ import logging
|
||||
import traceback
|
||||
from datetime import date, time, datetime, timedelta
|
||||
|
||||
from tools import parse_datetime
|
||||
from tools import (
|
||||
trace, timer,
|
||||
timestamp_to_old_pamhyr_date,
|
||||
@@ -74,11 +75,12 @@ class TableModel(PamhyrTableModel):
|
||||
if self._data.get_type_column(column) == float:
|
||||
value = f"{v:.4f}"
|
||||
elif self._data.header[column] == "time":
|
||||
if self._opt_data == "time":
|
||||
if self.time_system == "time":
|
||||
value = timestamp_to_old_pamhyr_date(int(v))
|
||||
else:
|
||||
value = format_datetime(
|
||||
self._start_date + timedelta(seconds=float(v))
|
||||
parse_datetime(self.start_date)
|
||||
+ timedelta(seconds=float(v))
|
||||
)
|
||||
else:
|
||||
value = f"{v}"
|
||||
@@ -97,7 +99,7 @@ class TableModel(PamhyrTableModel):
|
||||
|
||||
try:
|
||||
if (self._data.header[column] == "time"
|
||||
and self._opt_data == "date"):
|
||||
and self.time_system == "date"):
|
||||
value = self.date_to_elapsed_seconds(value)
|
||||
|
||||
self._undo.push(
|
||||
@@ -175,17 +177,18 @@ class TableModel(PamhyrTableModel):
|
||||
if len(data) == 0:
|
||||
return
|
||||
|
||||
try:
|
||||
rows = [self._data.new_from_data(header, d) for d in data]
|
||||
except (ValueError, TypeError, IndexError) as error:
|
||||
logger.warning(error)
|
||||
return False
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row,
|
||||
list(
|
||||
map(
|
||||
lambda d: self._data.new_from_data(header, d),
|
||||
data
|
||||
)
|
||||
)
|
||||
rows
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from Modules import Modules
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel, QCoreApplication,
|
||||
)
|
||||
@@ -122,7 +124,7 @@ class EditWeatherParametersWindow(PamhyrWindow):
|
||||
undo=self._undo_stack,
|
||||
trad=self._trad,
|
||||
opt_data=self._study.time_system,
|
||||
start_date=self._study.date
|
||||
study=self._study
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -158,6 +160,11 @@ class EditWeatherParametersWindow(PamhyrWindow):
|
||||
self._table.dataChanged.connect(self.update)
|
||||
self._table.layoutChanged.connect(self.update)
|
||||
|
||||
def _propagated_update(self, key=Modules(0)):
|
||||
if Modules.STUDY in key:
|
||||
self._table.layoutChanged.emit()
|
||||
self.plot.update()
|
||||
|
||||
def update(self):
|
||||
self.plot.update()
|
||||
self.plot.fit_to_data()
|
||||
|
||||
@@ -40,7 +40,7 @@ class WPETranslate(WeatherParametersTranslate):
|
||||
"Humidity"),
|
||||
"radiation": _translate("WeatherParameters", "Radiation (W/m²)"),
|
||||
"wind speed": _translate("WeatherParameters", "Wind Speed (m/s)"),
|
||||
"albedo": _translate("WeatherParameters", "Albedo"),
|
||||
"albedo": _translate("WeatherParameters", "Water albedo"),
|
||||
"shading coefficient": _translate("WeatherParameters",
|
||||
"Shading Coefficient"),
|
||||
"cloud cover fraction": _translate("WeatherParameters",
|
||||
|
||||
@@ -76,7 +76,7 @@ class WeatherParametersTranslate(MainTranslate):
|
||||
"Groundwater Temperature (°C)"),
|
||||
"surface_flow_rate": _translate("WeatherParameters",
|
||||
"Groundwater Flow Rate (m³/s)"),
|
||||
"albedo": _translate("WeatherParameters", "Albedo"),
|
||||
"albedo": _translate("WeatherParameters", "Water albedo"),
|
||||
"shading_coefficient": _translate("WeatherParameters",
|
||||
"Shading Coefficient"),
|
||||
"cloud_cover_fraction": _translate("WeatherParameters",
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -25,6 +25,16 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_show_interpolated">
|
||||
<property name="text">
|
||||
<string notr="true">Show interpolated profiles</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
|
||||
+227
-147
File diff suppressed because it is too large.
Load diff
@@ -240,6 +240,8 @@ def timestamp(dt: datetime):
|
||||
|
||||
|
||||
SUPPORTED_DATETIME_FORMATS = (
|
||||
"%d:%m:%Y, %H:%M:%S",
|
||||
"%d:%m:%Y",
|
||||
"%d-%m-%Y %H:%M:%S.%f",
|
||||
"%d-%m-%Y %H:%M:%S",
|
||||
"%d-%m-%Y %H:%M",
|
||||
|
||||
Reference in new issue
Block a user