mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ae16ca6ec | ||
|
|
c7406d3bce | ||
|
|
cb8ecc752b | ||
|
|
4c522ae050 | ||
|
|
689d5a7592 | ||
|
|
c118d4fae8 | ||
|
|
1baf2e8dd5 | ||
|
|
1fcdaa8b81 | ||
|
|
71729578dd | ||
|
|
abe7bf969a | ||
|
|
673ae3908c | ||
|
|
1a31c9122e | ||
|
|
c53d7d9c25 | ||
|
|
02f14ffdf1 | ||
|
|
84fd841f86 | ||
|
|
629b856788 | ||
|
|
f3007e2fe2 | ||
|
|
a7a1a4ddd1 | ||
|
|
0719db17ed | ||
|
|
018192714c | ||
|
|
501000fa6b | ||
|
|
75149000db | ||
|
|
3c82148f44 | ||
|
|
7f2ff9d341 | ||
|
|
57be80bcd4 |
No files matched your search
+2
-7
@@ -29,7 +29,7 @@ stages:
|
|||||||
#############
|
#############
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
MAGE_8_VERSION: "v8.3.6"
|
MAGE_8_VERSION: "v8.3.5"
|
||||||
|
|
||||||
dl-mage8-doc:
|
dl-mage8-doc:
|
||||||
stage: downloads
|
stage: downloads
|
||||||
@@ -262,11 +262,6 @@ build-linux:
|
|||||||
- cp -v ../mage8-linux/* pamhyr/mage8/
|
- cp -v ../mage8-linux/* pamhyr/mage8/
|
||||||
# Copy Pamhyr
|
# Copy Pamhyr
|
||||||
- cp -r dist/pamhyr/* pamhyr/
|
- cp -r dist/pamhyr/* pamhyr/
|
||||||
# Pamhyr script to force x11
|
|
||||||
- echo '#!/usr/bin/env bash' > pamhyr/pamhyr-x11
|
|
||||||
- echo "" >> pamhyr/pamhyr-x11
|
|
||||||
- echo "GDK_BACKEND=x11 ./pamhyr $@" >> pamhyr/pamhyr-x11
|
|
||||||
- chmod +x pamhyr/pamhyr-x11
|
|
||||||
# Copy Pamhyr resources
|
# Copy Pamhyr resources
|
||||||
- mkdir -p pamhyr/_internal/View
|
- mkdir -p pamhyr/_internal/View
|
||||||
- mkdir -p pamhyr/_internal/View/ui
|
- mkdir -p pamhyr/_internal/View/ui
|
||||||
@@ -338,7 +333,7 @@ build-windows:
|
|||||||
- python -m pip install -U -r ..\requirements.txt
|
- python -m pip install -U -r ..\requirements.txt
|
||||||
# Run Pyinstaller
|
# Run Pyinstaller
|
||||||
# - pyinstaller --noconsole -y ..\src\pamhyr.py
|
# - pyinstaller --noconsole -y ..\src\pamhyr.py
|
||||||
- pyinstaller -i ../src/View/ui/ressources/icon.ico --hide-console hide-early -y ..\src\pamhyr.py
|
- pyinstaller --hide-console hide-early -y ..\src\pamhyr.py
|
||||||
# Create directory
|
# Create directory
|
||||||
- mkdir pamhyr
|
- mkdir pamhyr
|
||||||
- dir
|
- dir
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -3,7 +3,6 @@
|
|||||||
!define LIC_NAME "LICENSE"
|
!define LIC_NAME "LICENSE"
|
||||||
!define APP_NAME "PAMHYR"
|
!define APP_NAME "PAMHYR"
|
||||||
|
|
||||||
Icon "pamhyr\_internal\View\ui\ressources\icon.ico"
|
|
||||||
Name "Pamhyr2"
|
Name "Pamhyr2"
|
||||||
OutFile "pamhyr-windows.exe"
|
OutFile "pamhyr-windows.exe"
|
||||||
LicenseData "pamhyr\_internal\LICENSE"
|
LicenseData "pamhyr\_internal\LICENSE"
|
||||||
|
|||||||
+4
-4
@@ -206,11 +206,11 @@ class MageGeometryGuideLineChecker(StudyGeometryChecker):
|
|||||||
def __init__(self, version="mage8"):
|
def __init__(self, version="mage8"):
|
||||||
super(MageGeometryGuideLineChecker, self).__init__()
|
super(MageGeometryGuideLineChecker, self).__init__()
|
||||||
|
|
||||||
self._name = _translate("Checker", "Mage geometry guideline checker")
|
self._name = _translate("Checker", "Mage geometry guide line checker")
|
||||||
self._description = _translate(
|
self._description = _translate(
|
||||||
"Checker",
|
"Checker",
|
||||||
"Check if exists geometry guidelines are correctly defined \
|
"Check if exists geometry guide line is correctly defined \
|
||||||
for each reach"
|
for each reaches of the study"
|
||||||
)
|
)
|
||||||
self._solver = version
|
self._solver = version
|
||||||
self._modules = Modules.GEOMETRY
|
self._modules = Modules.GEOMETRY
|
||||||
@@ -241,7 +241,7 @@ for each reach"
|
|||||||
for profile in profiles:
|
for profile in profiles:
|
||||||
if not profile.has_standard_named_points():
|
if not profile.has_standard_named_points():
|
||||||
self._status = STATUS.WARNING
|
self._status = STATUS.WARNING
|
||||||
self._summary = "no_standard_guideline_defined"
|
self._summary = "no_standard_guileline_defined"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for gl in gls[1:]:
|
for gl in gls[1:]:
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ class StudyNetworkReachChecker(AbstractModelChecker):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(StudyNetworkReachChecker, self).__init__()
|
super(StudyNetworkReachChecker, self).__init__()
|
||||||
|
|
||||||
self._name = _translate("Checker", "Study reach network checker")
|
self._name = _translate("Checker", "Study network reach checker")
|
||||||
self._description = _translate(
|
self._description = _translate(
|
||||||
"Checker", "Check if exists at least one reach exists"
|
"Checker", "Check if exists at least one reach for study"
|
||||||
)
|
)
|
||||||
self._modules = Modules.NETWORK
|
self._modules = Modules.NETWORK
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ class StudyGeometryChecker(AbstractModelChecker):
|
|||||||
|
|
||||||
self._name = _translate("Checker", "Study geometry checker")
|
self._name = _translate("Checker", "Study geometry checker")
|
||||||
self._description = _translate(
|
self._description = _translate(
|
||||||
"Checker", "Check if the geometry of each reach exists"
|
"Checker", "Check if exists geometry for each reach of study"
|
||||||
)
|
)
|
||||||
self._modules = Modules.GEOMETRY
|
self._modules = Modules.GEOMETRY
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -371,8 +371,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
|
|||||||
lplan: bool = False,
|
lplan: bool = False,
|
||||||
lm: int = 3,
|
lm: int = 3,
|
||||||
linear: bool = False,
|
linear: bool = False,
|
||||||
origin_value=0.0,
|
origin_value=0.0):
|
||||||
orientation=0):
|
|
||||||
if reach is None or len(reach.profiles) == 0:
|
if reach is None or len(reach.profiles) == 0:
|
||||||
return reach
|
return reach
|
||||||
|
|
||||||
@@ -401,7 +400,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
|
|||||||
f"{str(step)} " +
|
f"{str(step)} " +
|
||||||
f"{limites[0]} {limites[1]} " +
|
f"{limites[0]} {limites[1]} " +
|
||||||
f"{directrices[0]} {directrices[1]} " +
|
f"{directrices[0]} {directrices[1]} " +
|
||||||
f"{orientation} {lm} {linear} " +
|
f"{lplan} {lm} {linear} " +
|
||||||
f"{origin} "
|
f"{origin} "
|
||||||
)
|
)
|
||||||
proc.start(
|
proc.start(
|
||||||
@@ -414,7 +413,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
|
|||||||
"update_kp", step,
|
"update_kp", step,
|
||||||
limites[0], limites[1],
|
limites[0], limites[1],
|
||||||
directrices[0], directrices[1],
|
directrices[0], directrices[1],
|
||||||
orientation, lm, linear, origin, origin_value
|
lplan, lm, linear, origin, origin_value
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -315,9 +315,6 @@ class BoundaryCondition(SQLSubModel):
|
|||||||
self._data.sort(reverse=_reverse, key=key)
|
self._data.sort(reverse=_reverse, key=key)
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
|
|
||||||
def index(self, bc):
|
|
||||||
self._data.index(bc)
|
|
||||||
|
|
||||||
def get_i(self, index):
|
def get_i(self, index):
|
||||||
return self.data[index]
|
return self.data[index]
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
|||||||
self._end_kp = 0.0
|
self._end_kp = 0.0
|
||||||
self._data = []
|
self._data = []
|
||||||
self._header = ["time", "rate"]
|
self._header = ["time", "rate"]
|
||||||
self._types = [float, float]
|
self._types = [self.time_convert, float]
|
||||||
|
|
||||||
LateralContributionAdisTS._id_cnt = max(
|
LateralContributionAdisTS._id_cnt = max(
|
||||||
LateralContributionAdisTS._id_cnt + 1, self.id)
|
LateralContributionAdisTS._id_cnt + 1, self.id)
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
# Results.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import numpy as np
|
||||||
|
import os, glob
|
||||||
|
|
||||||
|
from copy import deepcopy
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from Model.Results.River.RiverAdisTS import River
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class Results(object):
|
||||||
|
def __init__(self, study=None, solver=None,
|
||||||
|
repertory="", name="0"):
|
||||||
|
self._study = study
|
||||||
|
self._solver = solver
|
||||||
|
self._repertory = repertory
|
||||||
|
self._name = name
|
||||||
|
|
||||||
|
self._river = River(self._study)
|
||||||
|
|
||||||
|
self._meta_data = {
|
||||||
|
# Keep results creation date
|
||||||
|
"creation_date": datetime.now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
repertory_results = os.path.join(repertory, "resultats")
|
||||||
|
self._pollutants_list = [el.split("/")[-1][0:-4] for el in glob.glob(repertory_results + "/*.bin")]
|
||||||
|
|
||||||
|
self._phys_var_list = ["C", "G", "M", "D", "L", "N", "R"]
|
||||||
|
|
||||||
|
print("*********files names resultats from Results Object: ", self._pollutants_list)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def date(self):
|
||||||
|
date = self._meta_data["creation_date"]
|
||||||
|
return f"{date.isoformat(sep=' ')}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def river(self):
|
||||||
|
return self._river
|
||||||
|
|
||||||
|
@property
|
||||||
|
def study(self):
|
||||||
|
return self._study
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pollutants_list(self):
|
||||||
|
return self._pollutants_list
|
||||||
|
|
||||||
|
@property
|
||||||
|
def phys_var_list(self):
|
||||||
|
return self._phys_var_list
|
||||||
|
|
||||||
|
def set(self, key, value):
|
||||||
|
self._meta_data[key] = value
|
||||||
|
|
||||||
|
def get(self, key):
|
||||||
|
return self._meta_data[key]
|
||||||
|
|
||||||
|
def reload(self):
|
||||||
|
return self._solver.results(
|
||||||
|
self._study,
|
||||||
|
self._repertory,
|
||||||
|
qlog=None,
|
||||||
|
)
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
# River.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class Profile(object):
|
||||||
|
def __init__(self, profile, study):
|
||||||
|
self._study = study
|
||||||
|
self._profile = profile # Source profile in the study
|
||||||
|
self._data = {} # Dict of dict {<ts>: {<key>: <value>, ...}, ...}
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self._data)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._profile.name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def kp(self):
|
||||||
|
return self._profile.kp
|
||||||
|
|
||||||
|
@property
|
||||||
|
def geometry(self):
|
||||||
|
return self._profile
|
||||||
|
|
||||||
|
def set(self, timestamp, key, data):
|
||||||
|
if timestamp not in self._data:
|
||||||
|
self._data[timestamp] = {}
|
||||||
|
|
||||||
|
self._data[timestamp][key] = data
|
||||||
|
|
||||||
|
def get_ts(self, timestamp):
|
||||||
|
return self._data[timestamp]
|
||||||
|
|
||||||
|
def get_key(self, key):
|
||||||
|
return list(
|
||||||
|
map(lambda ts: self._data[ts][key], self._data)
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_ts_key(self, timestamp, key):
|
||||||
|
return self._data[timestamp][key]
|
||||||
|
|
||||||
|
def has_sediment(self):
|
||||||
|
return any(map(lambda ts: "sl" in self._data[ts], self._data))
|
||||||
|
|
||||||
|
|
||||||
|
class Reach(object):
|
||||||
|
def __init__(self, reach, study):
|
||||||
|
self._study = study
|
||||||
|
self._reach = reach # Source reach in the study
|
||||||
|
self._profiles = list(
|
||||||
|
map(
|
||||||
|
lambda p: Profile(p, self._study),
|
||||||
|
reach.profiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self._profiles)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._reach.name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def geometry(self):
|
||||||
|
return self._reach
|
||||||
|
|
||||||
|
@property
|
||||||
|
def profiles(self):
|
||||||
|
return self._profiles.copy()
|
||||||
|
|
||||||
|
def profile(self, id):
|
||||||
|
return self._profiles[id]
|
||||||
|
|
||||||
|
def set(self, profile_id, timestamp, key, data):
|
||||||
|
self._profiles[profile_id].set(timestamp, key, data)
|
||||||
|
|
||||||
|
def has_sediment(self):
|
||||||
|
return any(map(lambda profile: profile.has_sediment(), self._profiles))
|
||||||
|
|
||||||
|
|
||||||
|
class River(object):
|
||||||
|
def __init__(self, study):
|
||||||
|
self._study = study
|
||||||
|
|
||||||
|
# Dict with timestamps as key
|
||||||
|
self._reachs = []
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self._reachs)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def reachs(self):
|
||||||
|
return self._reachs.copy()
|
||||||
|
|
||||||
|
def reach(self, id):
|
||||||
|
return self._reachs[id]
|
||||||
|
|
||||||
|
def has_reach(self, id):
|
||||||
|
return 0 <= id < len(self._reachs)
|
||||||
|
|
||||||
|
def add(self, reach_id):
|
||||||
|
reachs = self._study.river.enable_edges()
|
||||||
|
|
||||||
|
new = Reach(reachs[reach_id].reach, self._study)
|
||||||
|
|
||||||
|
self._reachs.append(new)
|
||||||
|
return new
|
||||||
|
|
||||||
|
def get_reach_by_geometry(self, geometry_reach):
|
||||||
|
return next(
|
||||||
|
filter(
|
||||||
|
lambda r: r.geometry is geometry_reach,
|
||||||
|
self._reachs
|
||||||
|
)
|
||||||
|
)
|
||||||
+2
-17
@@ -22,19 +22,10 @@ logger = logging.getLogger()
|
|||||||
|
|
||||||
|
|
||||||
class SavedStatus(object):
|
class SavedStatus(object):
|
||||||
def __init__(self, version=0):
|
def __init__(self):
|
||||||
super(SavedStatus, self).__init__()
|
super(SavedStatus, self).__init__()
|
||||||
self._version = version
|
|
||||||
self._saved = True
|
self._saved = True
|
||||||
|
|
||||||
@property
|
|
||||||
def version(self):
|
|
||||||
return self._version
|
|
||||||
|
|
||||||
@version.setter
|
|
||||||
def version(self, version):
|
|
||||||
self._version = version
|
|
||||||
|
|
||||||
def is_saved(self):
|
def is_saved(self):
|
||||||
return self._saved
|
return self._saved
|
||||||
|
|
||||||
@@ -43,11 +34,5 @@ class SavedStatus(object):
|
|||||||
self._saved = True
|
self._saved = True
|
||||||
|
|
||||||
def modified(self):
|
def modified(self):
|
||||||
if self._saved:
|
# logger.debug("model status set as modified")
|
||||||
self._version += 1
|
|
||||||
|
|
||||||
logger.debug(
|
|
||||||
"STATUS: Model status set as modified " +
|
|
||||||
f"at version {self._version}"
|
|
||||||
)
|
|
||||||
self._saved = False
|
self._saved = False
|
||||||
+9
-34
@@ -41,7 +41,7 @@ class Study(SQLModel):
|
|||||||
|
|
||||||
def __init__(self, filename=None, init_new=True):
|
def __init__(self, filename=None, init_new=True):
|
||||||
# Metadata
|
# Metadata
|
||||||
self._version = "0.0.10"
|
self._version = "0.0.9"
|
||||||
self.creation_date = datetime.now()
|
self.creation_date = datetime.now()
|
||||||
self.last_modification_date = datetime.now()
|
self.last_modification_date = datetime.now()
|
||||||
self.last_save_date = datetime.now()
|
self.last_save_date = datetime.now()
|
||||||
@@ -117,9 +117,6 @@ class Study(SQLModel):
|
|||||||
if ".backup" in self.filename:
|
if ".backup" in self.filename:
|
||||||
is_new = True
|
is_new = True
|
||||||
|
|
||||||
if not os.path.exists(self.filename):
|
|
||||||
is_new = True
|
|
||||||
|
|
||||||
self._init_db_file(self.filename, is_new=is_new)
|
self._init_db_file(self.filename, is_new=is_new)
|
||||||
self.commit()
|
self.commit()
|
||||||
|
|
||||||
@@ -212,12 +209,7 @@ class Study(SQLModel):
|
|||||||
def _create(self):
|
def _create(self):
|
||||||
# Info (metadata)
|
# Info (metadata)
|
||||||
self.execute(
|
self.execute(
|
||||||
"INSERT INTO info VALUES ('study_release', '0')"
|
"CREATE TABLE info(key TEXT NOT NULL UNIQUE, value TEXT NOT NULL)")
|
||||||
)
|
|
||||||
|
|
||||||
self.execute(
|
|
||||||
"CREATE TABLE info(key TEXT NOT NULL UNIQUE, value TEXT NOT NULL)"
|
|
||||||
)
|
|
||||||
self.execute(
|
self.execute(
|
||||||
"INSERT INTO info VALUES ('version', " +
|
"INSERT INTO info VALUES ('version', " +
|
||||||
f"'{self._db_format(self._version)}')",
|
f"'{self._db_format(self._version)}')",
|
||||||
@@ -226,20 +218,19 @@ class Study(SQLModel):
|
|||||||
self.execute("INSERT INTO info VALUES ('name', '')")
|
self.execute("INSERT INTO info VALUES ('name', '')")
|
||||||
self.execute("INSERT INTO info VALUES ('description', '')")
|
self.execute("INSERT INTO info VALUES ('description', '')")
|
||||||
self.execute(
|
self.execute(
|
||||||
f"INSERT INTO info VALUES ('time_system', '{self._time_system}')"
|
f"INSERT INTO info VALUES ('time_system', '{self._time_system}')")
|
||||||
)
|
|
||||||
self.execute(
|
self.execute(
|
||||||
"INSERT INTO info VALUES ('date', " +
|
f"INSERT INTO info VALUES ('date', " +
|
||||||
f"'{self._date.timestamp()}')"
|
"'{self._date.timestamp()}')"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.execute(
|
self.execute(
|
||||||
"INSERT INTO info VALUES ('creation_date', " +
|
f"INSERT INTO info VALUES ('creation_date', " +
|
||||||
f"'{self.creation_date.timestamp()}')"
|
"'{self.creation_time.timestamp()}')"
|
||||||
)
|
)
|
||||||
self.execute(
|
self.execute(
|
||||||
"INSERT INTO info VALUES ('last_save_date', " +
|
f"INSERT INTO info VALUES ('last_save_date', " +
|
||||||
f"'{self.last_save_date.timestamp()}')"
|
"'{self.last_save_time.timestamp()}')"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._create_submodel()
|
self._create_submodel()
|
||||||
@@ -254,12 +245,6 @@ class Study(SQLModel):
|
|||||||
|
|
||||||
logger.debug("Update database")
|
logger.debug("Update database")
|
||||||
|
|
||||||
major, minor, release = version[0].split('.')
|
|
||||||
if major == "0" and minor == "0" and int(release) < 10:
|
|
||||||
self.execute(
|
|
||||||
"INSERT INTO info VALUES ('study_release', '0')"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self._update_submodel(version[0]):
|
if self._update_submodel(version[0]):
|
||||||
self.execute(
|
self.execute(
|
||||||
f"UPDATE info SET value='{self._version}' WHERE key='version'"
|
f"UPDATE info SET value='{self._version}' WHERE key='version'"
|
||||||
@@ -273,11 +258,6 @@ class Study(SQLModel):
|
|||||||
def _load(cls, filename):
|
def _load(cls, filename):
|
||||||
new = cls(init_new=False, filename=filename)
|
new = cls(init_new=False, filename=filename)
|
||||||
|
|
||||||
version = new.execute(
|
|
||||||
"SELECT value FROM info WHERE key='study_release'"
|
|
||||||
)
|
|
||||||
new.status.version = int(version[0])
|
|
||||||
|
|
||||||
# TODO: Load metadata
|
# TODO: Load metadata
|
||||||
new.name = new.execute("SELECT value FROM info WHERE key='name'")[0]
|
new.name = new.execute("SELECT value FROM info WHERE key='name'")[0]
|
||||||
new.description = new.execute(
|
new.description = new.execute(
|
||||||
@@ -312,11 +292,6 @@ class Study(SQLModel):
|
|||||||
def _save(self, progress=None):
|
def _save(self, progress=None):
|
||||||
progress = progress if progress is not None else lambda: None
|
progress = progress if progress is not None else lambda: None
|
||||||
|
|
||||||
self.execute(
|
|
||||||
"INSERT INTO info VALUES ('study_release', " +
|
|
||||||
f"'{self.status.version}')"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.execute(
|
self.execute(
|
||||||
f"UPDATE info SET " +
|
f"UPDATE info SET " +
|
||||||
f"value='{self._db_format(self.name)}' WHERE key='name'"
|
f"value='{self._db_format(self.name)}' WHERE key='name'"
|
||||||
|
|||||||
+245
-8
@@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os, glob
|
||||||
import logging
|
import logging
|
||||||
|
from http.cookiejar import reach
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
@@ -31,7 +33,7 @@ from tools import (
|
|||||||
|
|
||||||
from Solver.CommandLine import CommandLineSolver
|
from Solver.CommandLine import CommandLineSolver
|
||||||
|
|
||||||
from Model.Results.Results import Results
|
from Model.Results.ResultsAdisTS import Results
|
||||||
from Model.Results.River.River import River, Reach, Profile
|
from Model.Results.River.River import River, Reach, Profile
|
||||||
|
|
||||||
from Checker.Adists import (
|
from Checker.Adists import (
|
||||||
@@ -112,7 +114,7 @@ class AdisTS(CommandLineSolver):
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
rep_file.write(line.line)
|
rep_file.write(line.line)
|
||||||
|
|
||||||
def _export_REP(self, study, repertory, files, qlog, name="0"):
|
def _export_REP(self, study, repertory, mage_rep, files, qlog, name="0"):
|
||||||
|
|
||||||
if qlog is not None:
|
if qlog is not None:
|
||||||
qlog.put("Export REP file")
|
qlog.put("Export REP file")
|
||||||
@@ -124,8 +126,8 @@ class AdisTS(CommandLineSolver):
|
|||||||
), "w+"
|
), "w+"
|
||||||
) as f:
|
) as f:
|
||||||
|
|
||||||
f.write(f"NET ../default-mage/{name}.NET\n")
|
f.write(f"NET ../{mage_rep}/{name}.NET\n")
|
||||||
f.write(f"REP ../default-mage/{name}.REP\n")
|
f.write(f"REP ../{mage_rep}/{name}.REP\n")
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
EXT = file.split('.')[1]
|
EXT = file.split('.')[1]
|
||||||
@@ -133,7 +135,7 @@ class AdisTS(CommandLineSolver):
|
|||||||
|
|
||||||
self._export_REP_additional_lines(study, f)
|
self._export_REP_additional_lines(study, f)
|
||||||
|
|
||||||
path_mage_net = os.path.join(os.path.abspath(os.path.join(repertory, os.pardir)), f"default-mage/net")
|
path_mage_net = os.path.join(os.path.abspath(os.path.join(repertory, os.pardir)), f"{mage_rep}/net")
|
||||||
path_adists_net = os.path.join(repertory, "net")
|
path_adists_net = os.path.join(repertory, "net")
|
||||||
|
|
||||||
if os.path.exists(path_mage_net):
|
if os.path.exists(path_mage_net):
|
||||||
@@ -457,6 +459,241 @@ class AdisTSlc(AdisTS):
|
|||||||
|
|
||||||
f.write(f"output = {id_reach} {kp} {title}\n")
|
f.write(f"output = {id_reach} {kp} {title}\n")
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def read_bin(self, study, repertory, results, qlog=None, name="0"):
|
||||||
|
repertory_results = os.path.join(repertory, "resultats")
|
||||||
|
|
||||||
|
files_bin_names = [el.split("/")[-1] for el in glob.glob(repertory_results+"/*.bin")]
|
||||||
|
print("files names resultats: ", files_bin_names)
|
||||||
|
|
||||||
|
ifilename = os.path.join(repertory_results, files_bin_names[0])
|
||||||
|
|
||||||
|
logger.info(f"read_bin: Start reading '{ifilename}' ...")
|
||||||
|
|
||||||
|
print("reading ", ifilename)
|
||||||
|
with open(ifilename, 'rb') as f:
|
||||||
|
# header
|
||||||
|
# first line
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=3)
|
||||||
|
ibmax = data[0] # number of reaches
|
||||||
|
ismax = data[1] # total number of cross sections
|
||||||
|
kbl = data[2] * -1 # block size for .BIN header
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# second line
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
ibu = np.fromfile(f, dtype=np.int32, count=ibmax)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# third line
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=2 * ibmax)
|
||||||
|
is1 = np.zeros(ibmax, dtype=np.int32)
|
||||||
|
is2 = np.zeros(ibmax, dtype=np.int32)
|
||||||
|
print("nombre de biefs : ", ibmax)
|
||||||
|
|
||||||
|
logger.debug(f"read_bin: nb_reach = {ibmax}")
|
||||||
|
logger.debug(f"read_bin: nb_profile = {ismax}")
|
||||||
|
|
||||||
|
results.set("nb_reach", f"{ibmax}")
|
||||||
|
results.set("nb_profile", f"{ismax}")
|
||||||
|
|
||||||
|
reachs = []
|
||||||
|
iprofiles = {}
|
||||||
|
reach_offset = {}
|
||||||
|
|
||||||
|
for i in range(ibmax):
|
||||||
|
# Add results reach to reach list
|
||||||
|
r = results.river.add(i)
|
||||||
|
reachs.append(r)
|
||||||
|
|
||||||
|
is1[i] = data[2 * i] - 1 # first section of reach i (FORTRAN numbering)
|
||||||
|
is2[i] = data[2 * i + 1] - 1 # last section of reach i (FORTRAN numbering)
|
||||||
|
|
||||||
|
key = (is1[i], is2[i])
|
||||||
|
iprofiles[key] = r
|
||||||
|
|
||||||
|
reach_offset[r] = is1[i]
|
||||||
|
|
||||||
|
logger.debug(f"read_bin: iprofiles = {iprofiles}")
|
||||||
|
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# fourth line
|
||||||
|
pk = np.zeros(ismax, dtype=np.float32)
|
||||||
|
for k in range(0, ismax, kbl):
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
pk[k:min(k + kbl, ismax)] = np.fromfile(f, dtype=np.float32, count=min(k + kbl, ismax) - k)
|
||||||
|
print("pk : ", pk)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
|
||||||
|
# fifth line (useless)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
zmin_OLD = np.fromfile(f, dtype=np.float32, count=1)[0]
|
||||||
|
print("zmin_OLD : ", zmin_OLD)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# sixth line
|
||||||
|
zf = np.zeros(ismax, dtype=np.float32)
|
||||||
|
z = np.zeros(ismax * 3, dtype=np.float32)
|
||||||
|
for k in range(0, ismax, kbl):
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
z[3 * k:3 * min(k + kbl, ismax)] = np.fromfile(f, dtype=np.float32,
|
||||||
|
count=3 * (min(k + kbl, ismax) - k))
|
||||||
|
# z[i*3+1] and z[i*3+2] are useless
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
zf = [z[i * 3] for i in range(ismax)]
|
||||||
|
print("zf : ", zf)
|
||||||
|
# seventh line (useless)
|
||||||
|
for k in range(0, ismax, kbl):
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
zero = np.fromfile(f, dtype=np.int32, count=ismax)
|
||||||
|
print("zero : ", zero)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# end header
|
||||||
|
|
||||||
|
def ip_to_r(i): return iprofiles[
|
||||||
|
next(
|
||||||
|
filter(
|
||||||
|
lambda k: k[0] <= i <= k[1],
|
||||||
|
iprofiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
def ip_to_ri(r, i): return i - reach_offset[r]
|
||||||
|
|
||||||
|
path_files = map(lambda file: os.path.join(repertory_results, file), files_bin_names)
|
||||||
|
|
||||||
|
data_tmp = {}
|
||||||
|
|
||||||
|
for file_bin in path_files:
|
||||||
|
key_pol = file_bin.split("/")[-1][0:-4]
|
||||||
|
data_tmp[key_pol] = {}
|
||||||
|
with open(file_bin, 'rb') as f:
|
||||||
|
# header
|
||||||
|
# first line
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=3)
|
||||||
|
ibmax = data[0] # number of reaches
|
||||||
|
ismax = data[1] # total number of cross sections
|
||||||
|
kbl = data[2] * -1 # block size for .BIN header
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# second line
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
ibu = np.fromfile(f, dtype=np.int32, count=ibmax)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# third line
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=2 * ibmax)
|
||||||
|
is1 = np.zeros(ibmax, dtype=np.int32)
|
||||||
|
is2 = np.zeros(ibmax, dtype=np.int32)
|
||||||
|
for i in range(ibmax):
|
||||||
|
is1[i] = data[2 * i] # first section of reach i (FORTRAN numbering)
|
||||||
|
is2[i] = data[2 * i + 1] # last section of reach i (FORTRAN numbering)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# fourth line
|
||||||
|
pk = np.zeros(ismax, dtype=np.float32)
|
||||||
|
for k in range(0, ismax, kbl):
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
pk[k:min(k + kbl, ismax)] = np.fromfile(f, dtype=np.float32, count=min(k + kbl, ismax) - k)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# fifth line (useless)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
zmin_OLD = np.fromfile(f, dtype=np.float32, count=1)[0]
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# sixth line
|
||||||
|
zf = np.zeros(ismax, dtype=np.float32)
|
||||||
|
z = np.zeros(ismax * 3, dtype=np.float32)
|
||||||
|
for k in range(0, ismax, kbl):
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
z[3 * k:3 * min(k + kbl, ismax)] = np.fromfile(f, dtype=np.float32,
|
||||||
|
count=3 * (min(k + kbl, ismax) - k))
|
||||||
|
# z[i*3+1] and z[i*3+2] are useless
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
zf = [z[i * 3] for i in range(ismax)]
|
||||||
|
# seventh line (useless)
|
||||||
|
for k in range(0, ismax, kbl):
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
zero = np.fromfile(f, dtype=np.int32, count=ismax)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
# end header
|
||||||
|
# data
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
while data.size > 0:
|
||||||
|
ismax = np.fromfile(f, dtype=np.int32, count=1)[0]
|
||||||
|
t = np.fromfile(f, dtype=np.float64, count=1)[0]
|
||||||
|
if not t in data_tmp[key_pol]:
|
||||||
|
data_tmp[key_pol][t] = {}
|
||||||
|
c = np.fromfile(f, dtype=np.byte, count=1)
|
||||||
|
# possible values :
|
||||||
|
# sediment : C, G, M, D, L, N, R
|
||||||
|
# polutant : C, G, M, D
|
||||||
|
phys_var = bytearray(c).decode()
|
||||||
|
data_tmp[key_pol][t][phys_var] = {}
|
||||||
|
real_data = np.fromfile(f, dtype=np.float32, count=ismax)
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (end)
|
||||||
|
data_tmp[key_pol][t][phys_var] = real_data
|
||||||
|
data = np.fromfile(f, dtype=np.int32, count=1) # line length (bytes) (start)
|
||||||
|
# end data
|
||||||
|
|
||||||
|
###print("dta tmp AAA")
|
||||||
|
###print("-----------")
|
||||||
|
###print(data_tmp["AAA-silt"])
|
||||||
|
|
||||||
|
pollutants_keys = list(data_tmp.keys())
|
||||||
|
timestamps_keys = list(data_tmp[pollutants_keys[0]].keys())
|
||||||
|
phys_data_names = list(data_tmp[pollutants_keys[0]][timestamps_keys[0]].keys())
|
||||||
|
|
||||||
|
###print("pol keys: ", pollutants_keys)
|
||||||
|
###print("t keys: ", timestamps_keys)
|
||||||
|
###print("phys var: ", phys_data_names)
|
||||||
|
#print("set timestamps keys: ", set(timestamps_keys))
|
||||||
|
#print("isma")
|
||||||
|
###print("iprofiles: ", iprofiles)
|
||||||
|
|
||||||
|
pi_tmp = []
|
||||||
|
reach_tmp = []
|
||||||
|
|
||||||
|
for i in range(ismax-1):
|
||||||
|
#print("first i: ", i)
|
||||||
|
reach = ip_to_r(i)
|
||||||
|
reach_tmp.append(reach)
|
||||||
|
#print("reach i:", reach)
|
||||||
|
#print("second i: ", i)
|
||||||
|
p_i = ip_to_ri(reach, i)
|
||||||
|
pi_tmp.append(p_i)
|
||||||
|
|
||||||
|
for t_data in timestamps_keys:
|
||||||
|
pol_view = []
|
||||||
|
for pol in pollutants_keys:
|
||||||
|
#print("pol results: ", type(list(data_tmp[pol][t_data].values())))
|
||||||
|
pol_view.append(tuple( list(map(lambda data_el: data_el[p_i], list(data_tmp[pol][t_data].values()))) ))
|
||||||
|
|
||||||
|
reach.set(p_i, t_data, "pols", pol_view)
|
||||||
|
|
||||||
|
###print("pi_tmp: ", pi_tmp)
|
||||||
|
###print("pol view: ", pol_view)
|
||||||
|
###print("reach from i: ", reach_tmp)
|
||||||
|
#print("pol view: ", pol_view)
|
||||||
|
#print("results: ", results)
|
||||||
|
results.set("timestamps", set(timestamps_keys))
|
||||||
|
#print("------------------------set timestamps results meta data: ", set(timestamps_keys))
|
||||||
|
|
||||||
|
###print("debug profiles for draw:")
|
||||||
|
###print("------------------------")
|
||||||
|
###print(data_tmp["AAA-silt"][0.0]["C"][0])
|
||||||
|
###print(data_tmp["AAA-silt"][600.0]["C"][0])
|
||||||
|
###print(data_tmp["AAA-silt"][1205.7208829578194]["C"][0])
|
||||||
|
###print("========================")
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def results(self, study, repertory, qlog=None, name=None):
|
||||||
|
self._study = study
|
||||||
|
if name is None:
|
||||||
|
name = study.name.replace(" ", "_")
|
||||||
|
|
||||||
|
results = super(AdisTSlc, self).results(study, repertory, qlog, name=name)
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
def export_func_dict(self):
|
def export_func_dict(self):
|
||||||
return [
|
return [
|
||||||
self._export_NUM,
|
self._export_NUM,
|
||||||
@@ -466,7 +703,7 @@ class AdisTSlc(AdisTS):
|
|||||||
]
|
]
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def export(self, study, repertory, qlog=None, name="0"):
|
def export(self, study, repertory, mage_rep, qlog=None, name="0"):
|
||||||
print("cmd solver adistslc : ", self._cmd_solver)
|
print("cmd solver adistslc : ", self._cmd_solver)
|
||||||
self._study = study
|
self._study = study
|
||||||
name = study.name.replace(" ", "_")
|
name = study.name.replace(" ", "_")
|
||||||
@@ -479,7 +716,7 @@ class AdisTSlc(AdisTS):
|
|||||||
files = files + func(study, repertory, qlog, name=name)
|
files = files + func(study, repertory, qlog, name=name)
|
||||||
|
|
||||||
self.export_additional_files(study, repertory, qlog, name=name)
|
self.export_additional_files(study, repertory, qlog, name=name)
|
||||||
self._export_REP(study, repertory, files, qlog, name=name)
|
self._export_REP(study, repertory, mage_rep, files, qlog, name=name)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -196,17 +196,11 @@ class CommandLineSolver(AbstractSolver):
|
|||||||
The executable and list of arguments
|
The executable and list of arguments
|
||||||
"""
|
"""
|
||||||
cmd = cmd.replace("@install_dir", self._install_dir())
|
cmd = cmd.replace("@install_dir", self._install_dir())
|
||||||
print("format command installDir :", self._install_dir())
|
|
||||||
cmd = cmd.replace("@path", "\"" + path + "\"")
|
cmd = cmd.replace("@path", "\"" + path + "\"")
|
||||||
print("format command path :", path)
|
|
||||||
cmd = cmd.replace("@input", self.input_param().replace(" ", "_"))
|
cmd = cmd.replace("@input", self.input_param().replace(" ", "_"))
|
||||||
print("format command input :", self.input_param().replace(" ", "_"))
|
|
||||||
cmd = cmd.replace("@output", self.output_param())
|
cmd = cmd.replace("@output", self.output_param())
|
||||||
print("format command output :", self.output_param())
|
|
||||||
cmd = cmd.replace("@dir", self._process.workingDirectory())
|
cmd = cmd.replace("@dir", self._process.workingDirectory())
|
||||||
print("format command dir :", self._process.workingDirectory())
|
|
||||||
cmd = cmd.replace("@args", " ".join(self.cmd_args(study)))
|
cmd = cmd.replace("@args", " ".join(self.cmd_args(study)))
|
||||||
print("format command args :", " ".join(self.cmd_args(study)))
|
|
||||||
|
|
||||||
logger.debug(f"! {cmd}")
|
logger.debug(f"! {cmd}")
|
||||||
|
|
||||||
@@ -243,11 +237,7 @@ class CommandLineSolver(AbstractSolver):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
cmd = self._cmd_solver
|
cmd = self._cmd_solver
|
||||||
print("run solver commandline cmd : ", cmd)
|
|
||||||
print("path solver : ", self._path_solver)
|
|
||||||
exe, args = self._format_command(study, cmd, self._path_solver)
|
exe, args = self._format_command(study, cmd, self._path_solver)
|
||||||
print("parsed cmd solver exe : ", exe)
|
|
||||||
print("parsed cmd solver args : ", args)
|
|
||||||
|
|
||||||
if not os.path.exists(exe):
|
if not os.path.exists(exe):
|
||||||
error = f"[ERROR] Path {exe} do not exists"
|
error = f"[ERROR] Path {exe} do not exists"
|
||||||
@@ -318,11 +308,6 @@ class CommandLineSolver(AbstractSolver):
|
|||||||
self._output.put(res)
|
self._output.put(res)
|
||||||
|
|
||||||
def run(self, study, process=None, output_queue=None):
|
def run(self, study, process=None, output_queue=None):
|
||||||
print("Run debug")
|
|
||||||
print("---------")
|
|
||||||
print("cmd input : ", self._cmd_input)
|
|
||||||
print("cmd solver : ", self._cmd_solver)
|
|
||||||
print("cmd output : ", self._cmd_output)
|
|
||||||
self._study = study
|
self._study = study
|
||||||
|
|
||||||
# Replace old values if needed
|
# Replace old values if needed
|
||||||
|
|||||||
@@ -980,6 +980,7 @@ class Mage8(Mage):
|
|||||||
|
|
||||||
# Add profile id correspondance to reach
|
# Add profile id correspondance to reach
|
||||||
key = (i1, i2)
|
key = (i1, i2)
|
||||||
|
print("mage keys reachs: ", key)
|
||||||
iprofiles[key] = r
|
iprofiles[key] = r
|
||||||
|
|
||||||
# Profile ID offset
|
# Profile ID offset
|
||||||
@@ -1012,6 +1013,8 @@ class Mage8(Mage):
|
|||||||
]
|
]
|
||||||
def ip_to_ri(r, i): return i - reach_offset[r]
|
def ip_to_ri(r, i): return i - reach_offset[r]
|
||||||
|
|
||||||
|
print("mage iprofiles: ", iprofiles)
|
||||||
|
|
||||||
ts = set()
|
ts = set()
|
||||||
end = False
|
end = False
|
||||||
while not end:
|
while not end:
|
||||||
@@ -1047,6 +1050,7 @@ class Mage8(Mage):
|
|||||||
|
|
||||||
logger.debug(reachs[0].profiles[0]._data)
|
logger.debug(reachs[0].profiles[0]._data)
|
||||||
results.set("timestamps", ts)
|
results.set("timestamps", ts)
|
||||||
|
print("set timestamps mage: ", ts)
|
||||||
logger.info(f"read_bin: ... end with {len(ts)} timestamp read")
|
logger.info(f"read_bin: ... end with {len(ts)} timestamp read")
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ solver_long_name = {
|
|||||||
# "mage7": "Mage v7",
|
# "mage7": "Mage v7",
|
||||||
"mage8": "Mage v8",
|
"mage8": "Mage v8",
|
||||||
# "mage_fake7": "Mage fake v7",
|
# "mage_fake7": "Mage fake v7",
|
||||||
|
"rubarbe": "RubarBE",
|
||||||
"adistslc": "Adis-TS_LC",
|
"adistslc": "Adis-TS_LC",
|
||||||
# "rubarbe": "RubarBE",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
solver_type_list = {
|
solver_type_list = {
|
||||||
@@ -41,6 +41,6 @@ solver_type_list = {
|
|||||||
# "mage7": Mage7,
|
# "mage7": Mage7,
|
||||||
"mage8": Mage8,
|
"mage8": Mage8,
|
||||||
# "mage_fake7": MageFake7,
|
# "mage_fake7": MageFake7,
|
||||||
|
"rubarbe": RubarBE,
|
||||||
"adistslc": AdisTSlc,
|
"adistslc": AdisTSlc,
|
||||||
# "rubarbe": RubarBE,
|
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
logger.info(e)
|
logger.info(e)
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.update()
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add(self, row, parent=QModelIndex()):
|
def add(self, row, parent=QModelIndex()):
|
||||||
@@ -112,7 +112,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
self.update()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def delete(self, rows, parent=QModelIndex()):
|
def delete(self, rows, parent=QModelIndex()):
|
||||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||||
@@ -135,7 +135,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
self.update()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def move_up(self, row, parent=QModelIndex()):
|
def move_up(self, row, parent=QModelIndex()):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
@@ -152,7 +152,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.endMoveRows()
|
self.endMoveRows()
|
||||||
self.update()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def move_down(self, index, parent=QModelIndex()):
|
def move_down(self, index, parent=QModelIndex()):
|
||||||
if row > len(self._data):
|
if row > len(self._data):
|
||||||
@@ -169,7 +169,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.endMoveRows()
|
self.endMoveRows()
|
||||||
self.update()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def paste(self, row, header, data):
|
def paste(self, row, header, data):
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
@@ -190,13 +190,4 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
self.update()
|
|
||||||
|
|
||||||
def auto_sort(self):
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
|
||||||
self._data.sort(key=lambda x: x[0])
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
# self.auto_sort()
|
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
@@ -195,7 +195,6 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
|||||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||||
|
|
||||||
self._table.dataChanged.connect(self.update)
|
self._table.dataChanged.connect(self.update)
|
||||||
self._table.layoutChanged.connect(self.update)
|
|
||||||
|
|
||||||
if self._is_solid:
|
if self._is_solid:
|
||||||
self._d50sigma.d50Changed.connect(self.d50_changed)
|
self._d50sigma.d50Changed.connect(self.d50_changed)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class BCTranslate(MainTranslate):
|
|||||||
|
|
||||||
self._sub_dict["long_types"] = {
|
self._sub_dict["long_types"] = {
|
||||||
"ND": self._dict["not_defined"],
|
"ND": self._dict["not_defined"],
|
||||||
"PC": _translate("BoundaryCondition", "Point sources"),
|
"PC": _translate("BoundaryCondition", "Ponctual contribution"),
|
||||||
"TZ": _translate("BoundaryCondition", "Z(t)"),
|
"TZ": _translate("BoundaryCondition", "Z(t)"),
|
||||||
"TD": _translate("BoundaryCondition", "Q(t)"),
|
"TD": _translate("BoundaryCondition", "Q(t)"),
|
||||||
"ZD": _translate("BoundaryCondition", "Q(Z)"),
|
"ZD": _translate("BoundaryCondition", "Q(Z)"),
|
||||||
|
|||||||
@@ -0,0 +1,200 @@
|
|||||||
|
# WindowAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from tools import trace, timer
|
||||||
|
|
||||||
|
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||||
|
|
||||||
|
from PyQt5.QtGui import (
|
||||||
|
QKeySequence,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
Qt, QVariant, QAbstractTableModel,
|
||||||
|
QCoreApplication, QModelIndex, QRect, QThread,
|
||||||
|
pyqtSlot, pyqtSignal,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import (
|
||||||
|
QDialogButtonBox, QPushButton, QLineEdit,
|
||||||
|
QFileDialog, QTableView, QAbstractItemView,
|
||||||
|
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||||
|
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||||
|
QProgressBar, QLabel,
|
||||||
|
)
|
||||||
|
|
||||||
|
from View.CheckList.Table import TableModel
|
||||||
|
from View.CheckList.Worker import Worker
|
||||||
|
from View.CheckList.Translate import CheckListTranslate
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
|
class CheckListWindowAdisTS(PamhyrWindow):
|
||||||
|
_pamhyr_ui = "CheckList"
|
||||||
|
_pamhyr_name = "Check list"
|
||||||
|
|
||||||
|
signalStatus = pyqtSignal(str)
|
||||||
|
|
||||||
|
def __init__(self, autorun: bool = True,
|
||||||
|
study=None, config=None,
|
||||||
|
solver=None, parent=None, mage_rep=None):
|
||||||
|
trad = CheckListTranslate()
|
||||||
|
|
||||||
|
self._autorun = autorun
|
||||||
|
self._solver = solver
|
||||||
|
self._mage_rep = mage_rep
|
||||||
|
|
||||||
|
name = trad[self._pamhyr_name] + " - " + study.name
|
||||||
|
|
||||||
|
super(CheckListWindowAdisTS, self).__init__(
|
||||||
|
title=name,
|
||||||
|
study=study,
|
||||||
|
config=config,
|
||||||
|
trad=trad,
|
||||||
|
options=[],
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add solver to hash computation data
|
||||||
|
self._hash_data.append(self._solver)
|
||||||
|
|
||||||
|
self._checker_list = (
|
||||||
|
self._study.checkers() +
|
||||||
|
self._solver.checkers()
|
||||||
|
)
|
||||||
|
|
||||||
|
self.setup_table()
|
||||||
|
self.setup_progress_bar()
|
||||||
|
self.setup_connections()
|
||||||
|
self.setup_thread()
|
||||||
|
self.setup_statusbar()
|
||||||
|
|
||||||
|
def setup_table(self):
|
||||||
|
table = self.find(QTableView, f"tableView")
|
||||||
|
self._table = TableModel(
|
||||||
|
table_view=table,
|
||||||
|
table_headers=self._trad.get_dict("table_headers"),
|
||||||
|
data=self._checker_list,
|
||||||
|
)
|
||||||
|
|
||||||
|
def setup_progress_bar(self):
|
||||||
|
self._progress = self.find(QProgressBar, f"progressBar")
|
||||||
|
self._p = 0 # Progress current step
|
||||||
|
|
||||||
|
self._progress.setRange(0, len(self._checker_list))
|
||||||
|
self._progress.setValue(self._p)
|
||||||
|
|
||||||
|
def setup_connections(self):
|
||||||
|
self.find(QPushButton, "pushButton_ok").clicked.connect(self.accept)
|
||||||
|
self.find(QPushButton, "pushButton_retry").clicked.connect(self.retry)
|
||||||
|
self.find(QPushButton, "pushButton_cancel")\
|
||||||
|
.clicked.connect(self.reject)
|
||||||
|
|
||||||
|
def setup_thread(self):
|
||||||
|
self._worker = Worker(self._study, self._checker_list)
|
||||||
|
self._worker_thread = QThread()
|
||||||
|
self._worker.moveToThread(self._worker_thread)
|
||||||
|
|
||||||
|
# Connect any worker signals
|
||||||
|
self._worker.signalStatus.connect(self.update)
|
||||||
|
self._worker_thread.started.connect(self._worker.process)
|
||||||
|
|
||||||
|
self._worker_thread.start()
|
||||||
|
|
||||||
|
def retry(self):
|
||||||
|
self._worker_thread.terminate()
|
||||||
|
self._worker_thread.wait()
|
||||||
|
|
||||||
|
self.find(QPushButton, "pushButton_retry").setEnabled(False)
|
||||||
|
self.find(QPushButton, "pushButton_ok").setEnabled(False)
|
||||||
|
|
||||||
|
self.setup_thread()
|
||||||
|
|
||||||
|
def _compute_status(self):
|
||||||
|
ok = len(list(filter(lambda c: c.is_ok(), self._checker_list)))
|
||||||
|
warning = len(
|
||||||
|
list(filter(lambda c: c.is_warning(), self._checker_list)))
|
||||||
|
error = len(list(filter(lambda c: c.is_error(), self._checker_list)))
|
||||||
|
|
||||||
|
return ok, warning, error
|
||||||
|
|
||||||
|
def _compute_status_label(self):
|
||||||
|
ok, warning, error = self._compute_status()
|
||||||
|
return (f"<font color=\"Green\">Ok: {ok} </font> |" +
|
||||||
|
f"<font color=\"Orange\">Warning: {warning} </font> |" +
|
||||||
|
f"<font color=\"Red\">Error: {error}</font>")
|
||||||
|
|
||||||
|
def setup_statusbar(self):
|
||||||
|
txt = self._compute_status_label()
|
||||||
|
self._status_label = QLabel(txt)
|
||||||
|
self.statusbar.addPermanentWidget(self._status_label)
|
||||||
|
|
||||||
|
def update_statusbar(self):
|
||||||
|
txt = self._compute_status_label()
|
||||||
|
self._status_label.setText(txt)
|
||||||
|
|
||||||
|
def progress(self):
|
||||||
|
self._p += 1
|
||||||
|
self._progress.setValue(self._p)
|
||||||
|
self._table.update()
|
||||||
|
|
||||||
|
def start_compute(self):
|
||||||
|
self._p = 0
|
||||||
|
self._progress.setValue(self._p)
|
||||||
|
|
||||||
|
def info_compute(self, str):
|
||||||
|
self.statusbar.showMessage(str, 3000)
|
||||||
|
|
||||||
|
def end_compute(self):
|
||||||
|
self._table.layoutChanged.emit()
|
||||||
|
self.find(QPushButton, "pushButton_retry").setEnabled(True)
|
||||||
|
|
||||||
|
errors = any(filter(lambda c: c.is_error(), self._checker_list))
|
||||||
|
if not errors:
|
||||||
|
self.find(QPushButton, "pushButton_ok").setEnabled(True)
|
||||||
|
if self._autorun:
|
||||||
|
self._parent.solver_log_adists(self._solver, self._mage_rep)
|
||||||
|
self.end()
|
||||||
|
|
||||||
|
self.update_statusbar()
|
||||||
|
|
||||||
|
def update(self, key: str):
|
||||||
|
if key == "start":
|
||||||
|
self.start_compute()
|
||||||
|
self.info_compute("Starting ...")
|
||||||
|
elif key == "end":
|
||||||
|
self.info_compute("Finish")
|
||||||
|
self.end_compute()
|
||||||
|
elif key == "progress":
|
||||||
|
self.progress()
|
||||||
|
else:
|
||||||
|
self.info_compute(key)
|
||||||
|
|
||||||
|
self.update_statusbar()
|
||||||
|
|
||||||
|
def end(self):
|
||||||
|
# self._worker.join()b
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def reject(self):
|
||||||
|
self.end()
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
self._parent.solver_log_adists(self._solver, self._mage_rep)
|
||||||
|
# self.end()
|
||||||
@@ -46,7 +46,7 @@ class Worker(QObject):
|
|||||||
self.signalStatus.emit(checker.name)
|
self.signalStatus.emit(checker.name)
|
||||||
|
|
||||||
# Run checker
|
# Run checker
|
||||||
checker.run(self._study)
|
checker._run(self._study)
|
||||||
|
|
||||||
self.signalStatus.emit("progress")
|
self.signalStatus.emit("progress")
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
# PlotKPC.py -- Pamhyr
|
|
||||||
# Copyright (C) 2023-2024 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/>.
|
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from PyQt5.QtCore import QCoreApplication
|
|
||||||
from View.HydraulicStructures.PlotKPC import PlotKPC
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
|
||||||
|
|
||||||
|
|
||||||
class PlotKPZ(PlotKPC):
|
|
||||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
|
||||||
river=None, reach=None, profile=None,
|
|
||||||
parent=None):
|
|
||||||
super(PlotKPC, self).__init__(
|
|
||||||
canvas=canvas,
|
|
||||||
trad=trad,
|
|
||||||
data=river,
|
|
||||||
toolbar=toolbar,
|
|
||||||
parent=parent
|
|
||||||
)
|
|
||||||
|
|
||||||
self._current_reach = reach
|
|
||||||
self._current_profile = profile
|
|
||||||
|
|
||||||
self.label_x = self._trad["unit_kp"]
|
|
||||||
self.label_y = self._trad["unit_elevation"]
|
|
||||||
|
|
||||||
self._isometric_axis = False
|
|
||||||
|
|
||||||
self._auto_relim_update = True
|
|
||||||
self._autoscale_update = True
|
|
||||||
self.parent = parent
|
|
||||||
|
|
||||||
def onpick(self, event):
|
|
||||||
return
|
|
||||||
@@ -42,7 +42,7 @@ class PlotStricklers(PamhyrPlot):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.label_x = self._trad["kp"]
|
self.label_x = self._trad["kp"]
|
||||||
self.label_y = self._trad["strickler_plot"]
|
self.label_y = self._trad["stricklers"]
|
||||||
|
|
||||||
self.line_kp_elevation = [None, None]
|
self.line_kp_elevation = [None, None]
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ from View.Frictions.Table import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.Frictions.PlotKPZ import PlotKPZ
|
from View.Geometry.PlotKPZ import PlotKPZ
|
||||||
from View.Frictions.PlotStricklers import PlotStricklers
|
from View.Frictions.PlotStricklers import PlotStricklers
|
||||||
from View.Frictions.translate import FrictionsTranslate
|
from View.Frictions.translate import FrictionsTranslate
|
||||||
|
|
||||||
@@ -135,11 +135,9 @@ class FrictionsWindow(PamhyrWindow):
|
|||||||
|
|
||||||
self.plot = PlotKPZ(
|
self.plot = PlotKPZ(
|
||||||
canvas=self.canvas,
|
canvas=self.canvas,
|
||||||
reach=self._reach,
|
data=self._reach.reach,
|
||||||
river=self._study.river,
|
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
toolbar=None,
|
toolbar=None,
|
||||||
parent=self
|
|
||||||
)
|
)
|
||||||
self.plot.draw()
|
self.plot.draw()
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ class FrictionsTranslate(MainTranslate):
|
|||||||
super(FrictionsTranslate, self).__init__()
|
super(FrictionsTranslate, self).__init__()
|
||||||
|
|
||||||
self._dict["kp"] = self._dict["unit_kp"]
|
self._dict["kp"] = self._dict["unit_kp"]
|
||||||
self._dict["strickler_plot"] = _translate(
|
|
||||||
"Frictions", "Strickler ($m^{1/3}/s$)"
|
|
||||||
)
|
|
||||||
self._dict["stricklers"] = _translate(
|
self._dict["stricklers"] = _translate(
|
||||||
"Frictions", "Stricklers"
|
"Frictions", "Stricklers"
|
||||||
)
|
)
|
||||||
@@ -42,8 +39,8 @@ class FrictionsTranslate(MainTranslate):
|
|||||||
self._sub_dict["table_headers"] = {
|
self._sub_dict["table_headers"] = {
|
||||||
# "name": self._dict["name"],
|
# "name": self._dict["name"],
|
||||||
# "edge": self._dict["reach"],
|
# "edge": self._dict["reach"],
|
||||||
"begin_kp": _translate("Frictions", "Start (m)"),
|
"begin_kp": _translate("Frictions", "Begin kp (m)"),
|
||||||
"end_kp": _translate("Frictions", "End (m)"),
|
"end_kp": _translate("Frictions", "End kp (m)"),
|
||||||
"begin_strickler": _translate("Frictions", "Start coefficient"),
|
"begin_strickler": _translate("Frictions", "Begin strickler"),
|
||||||
"end_strickler": _translate("Frictions", "End coefficient"),
|
"end_strickler": _translate("Frictions", "End strickler"),
|
||||||
}
|
}
|
||||||
@@ -125,6 +125,14 @@ class MeshingDialog(PamhyrDialog):
|
|||||||
def lplan(self):
|
def lplan(self):
|
||||||
return self._lplan
|
return self._lplan
|
||||||
|
|
||||||
|
@property
|
||||||
|
def origin(self):
|
||||||
|
return self._origin
|
||||||
|
|
||||||
|
@property
|
||||||
|
def lm(self):
|
||||||
|
return int(self._lm)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def linear(self):
|
def linear(self):
|
||||||
return self._linear
|
return self._linear
|
||||||
@@ -157,9 +165,15 @@ class MeshingDialog(PamhyrDialog):
|
|||||||
self._begin_cs = self.profiles.index(p1)
|
self._begin_cs = self.profiles.index(p1)
|
||||||
self._end_cs = self.profiles.index(p2)
|
self._end_cs = self.profiles.index(p2)
|
||||||
|
|
||||||
|
origin = self.get_combobox_text("comboBox_origin")
|
||||||
|
self._origin = self.profiles.index(origin)
|
||||||
|
|
||||||
self._begin_dir = self.get_combobox_text("comboBox_begin_gl")
|
self._begin_dir = self.get_combobox_text("comboBox_begin_gl")
|
||||||
self._end_dir = self.get_combobox_text("comboBox_end_gl")
|
self._end_dir = self.get_combobox_text("comboBox_end_gl")
|
||||||
|
|
||||||
|
r_lm_dict = self._trad.get_dict("r_lm_dict")
|
||||||
|
self._lm = r_lm_dict[self.get_combobox_text("comboBox_lm")]
|
||||||
|
|
||||||
super().accept()
|
super().accept()
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ class PlotAC(PamhyrPlot):
|
|||||||
label=self.label_next_plot_selected,
|
label=self.label_next_plot_selected,
|
||||||
color=self.color_plot_next, lw=1.6, linestyle='--'
|
color=self.color_plot_next, lw=1.6, linestyle='--'
|
||||||
)
|
)
|
||||||
self.canvas.axes.set_visible(False)
|
|
||||||
|
|
||||||
def draw_gl(self):
|
def draw_gl(self):
|
||||||
if self._current_data_update:
|
if self._current_data_update:
|
||||||
@@ -107,16 +106,12 @@ class PlotAC(PamhyrPlot):
|
|||||||
profile_id = 0
|
profile_id = 0
|
||||||
|
|
||||||
profile = self.data.profile(profile_id)
|
profile = self.data.profile(profile_id)
|
||||||
if profile is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
station = profile.get_station()
|
station = profile.get_station()
|
||||||
elevation = profile.z()
|
elevation = profile.z()
|
||||||
gl = profile.names()
|
gl = profile.names()
|
||||||
|
|
||||||
self.annotation = []
|
self.annotation = []
|
||||||
self.complete_gl, self.incomplete_gl = self.data.compute_guidelines()
|
self.complete_gl, self.incomplete_gl = self.data.compute_guidelines()
|
||||||
|
|
||||||
lcomplete = list(self.complete_gl)
|
lcomplete = list(self.complete_gl)
|
||||||
lincomplete = list(self.incomplete_gl)
|
lincomplete = list(self.incomplete_gl)
|
||||||
|
|
||||||
@@ -165,9 +160,6 @@ class PlotAC(PamhyrPlot):
|
|||||||
self.draw()
|
self.draw()
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.data is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.update_current()
|
self.update_current()
|
||||||
self.update_gl()
|
self.update_gl()
|
||||||
|
|
||||||
@@ -179,10 +171,6 @@ class PlotAC(PamhyrPlot):
|
|||||||
previous_id = profile_id - 1
|
previous_id = profile_id - 1
|
||||||
next_id = profile_id + 1
|
next_id = profile_id + 1
|
||||||
|
|
||||||
self.previous_plot_selected.set_visible(False)
|
|
||||||
self.plot_selected.set_visible(False)
|
|
||||||
self.next_plot_selected.set_visible(False)
|
|
||||||
|
|
||||||
self.previous_plot_selected.set_data([], [])
|
self.previous_plot_selected.set_data([], [])
|
||||||
self.plot_selected.set_data([], [])
|
self.plot_selected.set_data([], [])
|
||||||
self.next_plot_selected.set_data([], [])
|
self.next_plot_selected.set_data([], [])
|
||||||
@@ -192,23 +180,18 @@ class PlotAC(PamhyrPlot):
|
|||||||
self.data.profile(previous_id).get_station(),
|
self.data.profile(previous_id).get_station(),
|
||||||
self.data.profile(previous_id).z()
|
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:
|
||||||
self.plot_selected.set_data(
|
self.plot_selected.set_data(
|
||||||
self.data.profile(profile_id).get_station(),
|
self.data.profile(profile_id).get_station(),
|
||||||
self.data.profile(profile_id).z()
|
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:
|
||||||
self.next_plot_selected.set_data(
|
self.next_plot_selected.set_data(
|
||||||
self.data.profile(next_id).get_station(),
|
self.data.profile(next_id).get_station(),
|
||||||
self.data.profile(next_id).z()
|
self.data.profile(next_id).z()
|
||||||
)
|
)
|
||||||
self.next_plot_selected.set_visible(True)
|
|
||||||
|
|
||||||
self.canvas.axes.set_visible(True)
|
|
||||||
|
|
||||||
def update_full(self):
|
def update_full(self):
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|||||||
+132
-201
@@ -20,11 +20,6 @@ import logging
|
|||||||
|
|
||||||
from tools import timer
|
from tools import timer
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
from PyQt5.QtWidgets import QApplication
|
|
||||||
from PyQt5.QtCore import (
|
|
||||||
Qt, QItemSelectionModel,
|
|
||||||
QItemSelection, QItemSelectionRange,
|
|
||||||
)
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
@@ -32,7 +27,7 @@ logger = logging.getLogger()
|
|||||||
class PlotKPZ(PamhyrPlot):
|
class PlotKPZ(PamhyrPlot):
|
||||||
def __init__(self, canvas=None, trad=None,
|
def __init__(self, canvas=None, trad=None,
|
||||||
study=None, data=None, toolbar=None,
|
study=None, data=None, toolbar=None,
|
||||||
table=None, parent=None):
|
parent=None):
|
||||||
self._study = study
|
self._study = study
|
||||||
|
|
||||||
super(PlotKPZ, self).__init__(
|
super(PlotKPZ, self).__init__(
|
||||||
@@ -40,7 +35,6 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
trad=trad,
|
trad=trad,
|
||||||
data=data,
|
data=data,
|
||||||
toolbar=toolbar,
|
toolbar=toolbar,
|
||||||
table=table,
|
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -57,111 +51,6 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
self.before_plot_selected = None
|
self.before_plot_selected = None
|
||||||
self.plot_selected = None
|
self.plot_selected = None
|
||||||
self.after_plot_selected = None
|
self.after_plot_selected = None
|
||||||
self.parent = parent
|
|
||||||
self._table = table
|
|
||||||
self._colors = []
|
|
||||||
|
|
||||||
def onpick(self, event):
|
|
||||||
if event.mouseevent.inaxes != self.canvas.axes:
|
|
||||||
return
|
|
||||||
if event.mouseevent.button.value != 1:
|
|
||||||
return
|
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
|
||||||
if modifiers not in [Qt.ControlModifier,
|
|
||||||
Qt.NoModifier,
|
|
||||||
Qt.ShiftModifier]:
|
|
||||||
return
|
|
||||||
|
|
||||||
ind, point = self._closest_kp(event)
|
|
||||||
if self.parent._table is None:
|
|
||||||
return
|
|
||||||
self.parent._table.blockSignals(True)
|
|
||||||
if modifiers == Qt.ControlModifier:
|
|
||||||
rows = list(
|
|
||||||
set(
|
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if ind in rows:
|
|
||||||
rows.remove(ind)
|
|
||||||
else:
|
|
||||||
rows.append(ind)
|
|
||||||
self._select_in_table(rows)
|
|
||||||
elif modifiers == Qt.ShiftModifier:
|
|
||||||
rows = sorted(list(
|
|
||||||
set(
|
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
|
||||||
)
|
|
||||||
))
|
|
||||||
if len(rows) > 0:
|
|
||||||
i1 = min(rows[0], rows[-1], ind)
|
|
||||||
i2 = max(rows[0], rows[-1], ind)
|
|
||||||
else:
|
|
||||||
i1 = ind
|
|
||||||
i2 = ind
|
|
||||||
self._select_range_in_table(i1, i2)
|
|
||||||
else:
|
|
||||||
self._select_in_table([ind])
|
|
||||||
self.parent._table.blockSignals(False)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def _closest_kp(self, event):
|
|
||||||
|
|
||||||
s = event.artist.get_segments()
|
|
||||||
x = [i[0, 0] for i in s]
|
|
||||||
mx = event.mouseevent.xdata
|
|
||||||
points = enumerate(x)
|
|
||||||
|
|
||||||
def dist_mouse(point):
|
|
||||||
x = point[1]
|
|
||||||
d = abs(mx - x)
|
|
||||||
return d
|
|
||||||
|
|
||||||
closest = min(
|
|
||||||
points, key=dist_mouse
|
|
||||||
)
|
|
||||||
|
|
||||||
return closest
|
|
||||||
|
|
||||||
def _select_in_table(self, ind):
|
|
||||||
if self._table is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
self._table.setFocus()
|
|
||||||
selection = self._table.selectionModel()
|
|
||||||
index = QItemSelection()
|
|
||||||
|
|
||||||
if len(ind) == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
for i in ind:
|
|
||||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
|
||||||
|
|
||||||
selection.select(
|
|
||||||
index,
|
|
||||||
QItemSelectionModel.Rows |
|
|
||||||
QItemSelectionModel.ClearAndSelect |
|
|
||||||
QItemSelectionModel.Select
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(ind) > 0:
|
|
||||||
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))
|
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
@@ -185,7 +74,8 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.draw_z_line()
|
self.draw_z_line()
|
||||||
self.draw_lr()
|
self.draw_z_line_highlight()
|
||||||
|
self.draw_current()
|
||||||
self.draw_gl()
|
self.draw_gl()
|
||||||
self.draw_bottom()
|
self.draw_bottom()
|
||||||
self.draw_profiles_hs(self._data)
|
self.draw_profiles_hs(self._data)
|
||||||
@@ -198,60 +88,76 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
z_min = self.data.get_z_min()
|
z_min = self.data.get_z_min()
|
||||||
z_max = self.data.get_z_max()
|
z_max = self.data.get_z_max()
|
||||||
|
|
||||||
self._colors, self._style = self.color_hightlight()
|
|
||||||
|
|
||||||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||||
x=kp, ymin=z_min, ymax=z_max,
|
x=kp, ymin=z_min, ymax=z_max,
|
||||||
color=self._colors,
|
color=self.color_plot,
|
||||||
linestyle=self._style,
|
lw=1.
|
||||||
lw=1.,
|
|
||||||
picker=10,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def color_hightlight(self):
|
def draw_z_line_highlight(self):
|
||||||
rows = sorted(list(
|
if self._highlight_data is not None:
|
||||||
set(
|
kp = self.data.get_kp_complete_profiles()
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
z_min = self.data.get_z_min()
|
||||||
|
z_max = self.data.get_z_max()
|
||||||
|
|
||||||
|
kp_min, kp_max = self._highlight_data
|
||||||
|
|
||||||
|
indexes = list(
|
||||||
|
map(
|
||||||
|
lambda x: x[0],
|
||||||
|
filter(
|
||||||
|
lambda x: kp_min <= x[1] <= kp_max,
|
||||||
|
enumerate(kp)
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
))
|
|
||||||
colors = [self.color_plot for row in range(len(self._data))]
|
|
||||||
style = ["-" for row in range(len(self._data))]
|
|
||||||
if len(rows) > 0:
|
|
||||||
for row in rows:
|
|
||||||
colors[row] = self.color_plot_current
|
|
||||||
if rows[0] > 0:
|
|
||||||
colors[rows[0]-1] = self.color_plot_previous
|
|
||||||
style[rows[0]-1] = "--"
|
|
||||||
if rows[-1] < len(self._data)-1:
|
|
||||||
colors[rows[-1]+1] = self.color_plot_next
|
|
||||||
style[rows[-1]+1] = "--"
|
|
||||||
return colors, style
|
|
||||||
|
|
||||||
def draw_lr(self):
|
def indexes_filter(data): return list(
|
||||||
|
map(
|
||||||
|
lambda x: x[1],
|
||||||
|
filter(
|
||||||
|
lambda x: x[0] in indexes,
|
||||||
|
enumerate(data)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
ikp = indexes_filter(kp)
|
||||||
|
imin = indexes_filter(z_min)
|
||||||
|
imax = indexes_filter(z_max)
|
||||||
|
|
||||||
|
self.line_kp_zmin_zmax_highlight = self.canvas.axes.vlines(
|
||||||
|
x=ikp,
|
||||||
|
ymin=imin, ymax=imax,
|
||||||
|
color=self.color_plot_highlight,
|
||||||
|
lw=1.
|
||||||
|
)
|
||||||
|
|
||||||
|
def draw_current(self):
|
||||||
kp = self.data.get_kp_complete_profiles()
|
kp = self.data.get_kp_complete_profiles()
|
||||||
lz = []
|
z_min = self.data.get_z_min()
|
||||||
rz = []
|
z_max = self.data.get_z_max()
|
||||||
|
|
||||||
self.line_lr = []
|
self.plot_selected, = self.canvas.axes.plot(
|
||||||
for z in self.data.get_z():
|
(kp[0], kp[0]),
|
||||||
lz.append(z[0])
|
(z_min[0], z_max[0]),
|
||||||
rz.append(z[-1])
|
color=self.color_plot_current, lw=1.5
|
||||||
|
|
||||||
line = self.canvas.axes.plot(
|
|
||||||
kp, lz,
|
|
||||||
color=self.color_plot_river_bottom,
|
|
||||||
linestyle="dotted",
|
|
||||||
lw=1.,
|
|
||||||
)
|
)
|
||||||
self.line_lr.append(line)
|
self.plot_selected.set_visible(False)
|
||||||
|
|
||||||
line = self.canvas.axes.plot(
|
self.before_plot_selected, = self.canvas.axes.plot(
|
||||||
kp, rz,
|
(kp[0], kp[0]),
|
||||||
color=self.color_plot_river_bottom,
|
(z_min[0], z_max[0]),
|
||||||
linestyle="dotted",
|
color=self.color_plot_previous, lw=1.5, linestyle='--'
|
||||||
lw=1.,
|
|
||||||
)
|
)
|
||||||
self.line_lr.append(line)
|
self.before_plot_selected.set_visible(False)
|
||||||
|
|
||||||
|
self.after_plot_selected, = self.canvas.axes.plot(
|
||||||
|
(kp[0], kp[0]),
|
||||||
|
(z_min[0], z_max[0]),
|
||||||
|
color=self.color_plot_next, lw=1.5, linestyle='--'
|
||||||
|
)
|
||||||
|
self.after_plot_selected.set_visible(False)
|
||||||
|
|
||||||
def draw_gl(self):
|
def draw_gl(self):
|
||||||
kp = self.data.get_kp_complete_profiles()
|
kp = self.data.get_kp_complete_profiles()
|
||||||
@@ -285,34 +191,30 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
def draw_profiles_hs(self, reach):
|
def draw_profiles_hs(self, reach):
|
||||||
lhs = filter(
|
lhs = filter(
|
||||||
lambda hs: hs._input_reach.reach is reach,
|
lambda hs: hs._input_reach.reach is reach,
|
||||||
filter(
|
self._study.river.hydraulic_structures.lst
|
||||||
lambda hs: hs._input_reach is not None,
|
|
||||||
self._study.river.hydraulic_structures.lst
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for hs in lhs:
|
for hs in lhs:
|
||||||
x = hs.input_kp
|
x = hs.input_kp
|
||||||
if x is not None:
|
z_min = reach.get_z_min()
|
||||||
z_min = reach.get_z_min()
|
z_max = reach.get_z_max()
|
||||||
z_max = reach.get_z_max()
|
|
||||||
|
|
||||||
self.canvas.axes.plot(
|
self.canvas.axes.plot(
|
||||||
[x, x],
|
[x, x],
|
||||||
[min(z_min), max(z_max)],
|
[min(z_min), max(z_max)],
|
||||||
linestyle="--",
|
linestyle="--",
|
||||||
lw=1.,
|
lw=1.,
|
||||||
color=self.color_plot_previous,
|
color=self.color_plot_previous,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.canvas.axes.annotate(
|
self.canvas.axes.annotate(
|
||||||
" > " + hs.name,
|
" > " + hs.name,
|
||||||
(x, max(z_max)),
|
(x, max(z_max)),
|
||||||
horizontalalignment='left',
|
horizontalalignment='left',
|
||||||
verticalalignment='top',
|
verticalalignment='top',
|
||||||
annotation_clip=True,
|
annotation_clip=True,
|
||||||
fontsize=9, color=self.color_plot_previous,
|
fontsize=9, color=self.color_plot_previous,
|
||||||
)
|
)
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def update(self):
|
def update(self):
|
||||||
@@ -320,7 +222,6 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
self.draw()
|
self.draw()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.update_lr()
|
|
||||||
self.update_gl()
|
self.update_gl()
|
||||||
self.update_current()
|
self.update_current()
|
||||||
|
|
||||||
@@ -328,9 +229,52 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
|
|
||||||
def update_current(self):
|
def update_current(self):
|
||||||
if self._current_data_update:
|
if self._current_data_update:
|
||||||
self._colors, self._style = self.color_hightlight()
|
ind = self._current_data
|
||||||
self.line_kp_zmin_zmax.set_colors(self._colors)
|
before = ind - 1
|
||||||
self.line_kp_zmin_zmax.set_linestyle(self._style)
|
after = ind + 1
|
||||||
|
|
||||||
|
self.before_plot_selected.set_visible(False)
|
||||||
|
self.plot_selected.set_visible(False)
|
||||||
|
self.after_plot_selected.set_visible(False)
|
||||||
|
|
||||||
|
if 0 <= before < self.data.number_profiles:
|
||||||
|
profile = self.data.profile(before)
|
||||||
|
if len(profile) > 0:
|
||||||
|
kp_i = profile.kp
|
||||||
|
z_min_i = profile.z_min()
|
||||||
|
z_max_i = profile.z_max()
|
||||||
|
|
||||||
|
self.before_plot_selected.set_data(
|
||||||
|
(kp_i, kp_i),
|
||||||
|
(z_min_i, z_max_i)
|
||||||
|
)
|
||||||
|
self.before_plot_selected.set_visible(True)
|
||||||
|
|
||||||
|
if 0 <= ind < self.data.number_profiles:
|
||||||
|
profile = self.data.profile(ind)
|
||||||
|
if len(profile) > 0:
|
||||||
|
kp_i = profile.kp
|
||||||
|
z_min_i = profile.z_min()
|
||||||
|
z_max_i = profile.z_max()
|
||||||
|
|
||||||
|
self.plot_selected.set_data(
|
||||||
|
(kp_i, kp_i),
|
||||||
|
(z_min_i, z_max_i)
|
||||||
|
)
|
||||||
|
self.plot_selected.set_visible(True)
|
||||||
|
|
||||||
|
if 0 <= after < self.data.number_profiles:
|
||||||
|
profile = self.data.profile(after)
|
||||||
|
if len(profile) > 0:
|
||||||
|
kp_i = profile.kp
|
||||||
|
z_min_i = profile.z_min()
|
||||||
|
z_max_i = profile.z_max()
|
||||||
|
|
||||||
|
self.after_plot_selected.set_data(
|
||||||
|
(kp_i, kp_i),
|
||||||
|
(z_min_i, z_max_i)
|
||||||
|
)
|
||||||
|
self.after_plot_selected.set_visible(True)
|
||||||
|
|
||||||
def update_gl(self):
|
def update_gl(self):
|
||||||
if self._current_data_update:
|
if self._current_data_update:
|
||||||
@@ -342,19 +286,12 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
|
|
||||||
self.line_kp_zmin.set_data(kp, z_min)
|
self.line_kp_zmin.set_data(kp, z_min)
|
||||||
|
|
||||||
# TODO comprendre à quoi sert ce bout de code
|
self.line_kp_zmin_zmax.remove()
|
||||||
# ========>
|
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||||
# self.line_kp_zmin_zmax.remove()
|
x=kp,
|
||||||
# self._colors, self._style = self.color_hightlight()
|
ymin=z_min, ymax=z_max,
|
||||||
# self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
color='r', lw=1.
|
||||||
# x=kp,
|
)
|
||||||
# ymin=z_min,
|
|
||||||
# ymax=z_max,
|
|
||||||
# color=self._colors,
|
|
||||||
# linestyle = self._style,
|
|
||||||
# lw=1.
|
|
||||||
# )
|
|
||||||
# <========
|
|
||||||
|
|
||||||
z_complete = self.data.get_guidelines_z()
|
z_complete = self.data.get_guidelines_z()
|
||||||
try:
|
try:
|
||||||
@@ -364,9 +301,3 @@ class PlotKPZ(PamhyrPlot):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to update graphic KPZ: {e}")
|
logger.warning(f"Failed to update graphic KPZ: {e}")
|
||||||
|
|
||||||
def update_lr(self):
|
|
||||||
for line in self.line_lr:
|
|
||||||
line[0].remove()
|
|
||||||
|
|
||||||
self.draw_lr()
|
|
||||||
+90
-167
@@ -18,27 +18,22 @@
|
|||||||
|
|
||||||
from tools import timer, trace
|
from tools import timer, trace
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
from matplotlib import collections
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
QCoreApplication, Qt, QItemSelectionModel,
|
QCoreApplication
|
||||||
QItemSelection, QItemSelectionRange,
|
|
||||||
)
|
)
|
||||||
from PyQt5.QtWidgets import QApplication
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
class PlotXY(PamhyrPlot):
|
class PlotXY(PamhyrPlot):
|
||||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||||
table=None, parent=None):
|
parent=None):
|
||||||
super(PlotXY, self).__init__(
|
super(PlotXY, self).__init__(
|
||||||
canvas=canvas,
|
canvas=canvas,
|
||||||
trad=trad,
|
trad=trad,
|
||||||
data=data,
|
data=data,
|
||||||
toolbar=toolbar,
|
toolbar=toolbar,
|
||||||
table=table,
|
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -51,116 +46,6 @@ class PlotXY(PamhyrPlot):
|
|||||||
self.before_plot_selected = None
|
self.before_plot_selected = None
|
||||||
self.plot_selected = None
|
self.plot_selected = None
|
||||||
self.after_plot_selected = None
|
self.after_plot_selected = None
|
||||||
self.parent = parent
|
|
||||||
self.line_xy_collection = None
|
|
||||||
self._table = table
|
|
||||||
self._colors = []
|
|
||||||
self._style = []
|
|
||||||
|
|
||||||
def onpick(self, event):
|
|
||||||
if event.mouseevent.inaxes != self.canvas.axes:
|
|
||||||
return
|
|
||||||
if event.mouseevent.button.value != 1:
|
|
||||||
return
|
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
|
||||||
if modifiers not in [Qt.ControlModifier,
|
|
||||||
Qt.NoModifier,
|
|
||||||
Qt.ShiftModifier]:
|
|
||||||
return
|
|
||||||
|
|
||||||
ind, point = self._closest_section(event)
|
|
||||||
if self._table is None:
|
|
||||||
return
|
|
||||||
self._table.blockSignals(True)
|
|
||||||
if modifiers == Qt.ControlModifier:
|
|
||||||
rows = list(
|
|
||||||
set(
|
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if ind in rows:
|
|
||||||
rows.remove(ind)
|
|
||||||
self._select_in_table(rows)
|
|
||||||
else:
|
|
||||||
self._select_in_table(rows + [ind])
|
|
||||||
elif modifiers == Qt.ShiftModifier:
|
|
||||||
rows = list(
|
|
||||||
set(
|
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if len(rows) > 0:
|
|
||||||
i1 = min(rows[0], rows[-1], ind)
|
|
||||||
i2 = max(rows[0], rows[-1], ind)
|
|
||||||
else:
|
|
||||||
i1 = ind
|
|
||||||
i2 = ind
|
|
||||||
self._select_range_in_table(i1, i2)
|
|
||||||
else:
|
|
||||||
self._select_in_table([ind])
|
|
||||||
self._table.blockSignals(False)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def _closest_section(self, event):
|
|
||||||
axes = self.canvas.axes
|
|
||||||
mx = event.mouseevent.xdata
|
|
||||||
my = event.mouseevent.ydata
|
|
||||||
bx, by = axes.get_xlim(), axes.get_ylim()
|
|
||||||
ratio = (bx[0] - bx[1]) / (by[0] - by[1])
|
|
||||||
|
|
||||||
segments = event.artist.get_segments()
|
|
||||||
ind = event.ind
|
|
||||||
|
|
||||||
points = []
|
|
||||||
for i in ind:
|
|
||||||
points = points + [[i, j] for j in segments[i]]
|
|
||||||
|
|
||||||
def dist_mouse(point):
|
|
||||||
x, y = point[1]
|
|
||||||
d2 = (((mx - x) / ratio) ** 2) + ((my - y) ** 2)
|
|
||||||
return d2
|
|
||||||
|
|
||||||
closest = min(
|
|
||||||
points, key=dist_mouse
|
|
||||||
)
|
|
||||||
|
|
||||||
return closest
|
|
||||||
|
|
||||||
def _select_in_table(self, ind):
|
|
||||||
if self._table is None:
|
|
||||||
return
|
|
||||||
self._table.setFocus()
|
|
||||||
selection = self._table.selectionModel()
|
|
||||||
index = QItemSelection()
|
|
||||||
if len(ind) == 0:
|
|
||||||
return
|
|
||||||
for i in ind:
|
|
||||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
|
||||||
selection.select(
|
|
||||||
index,
|
|
||||||
QItemSelectionModel.Rows |
|
|
||||||
QItemSelectionModel.ClearAndSelect |
|
|
||||||
QItemSelectionModel.Select
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(ind) > 0:
|
|
||||||
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))
|
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def draw(self):
|
def draw(self):
|
||||||
@@ -178,42 +63,33 @@ class PlotXY(PamhyrPlot):
|
|||||||
self.draw_xy()
|
self.draw_xy()
|
||||||
self.draw_lr()
|
self.draw_lr()
|
||||||
self.draw_gl()
|
self.draw_gl()
|
||||||
|
self.draw_current()
|
||||||
|
|
||||||
self.idle()
|
self.idle()
|
||||||
self._init = True
|
self._init = True
|
||||||
|
|
||||||
def draw_xy(self):
|
def draw_xy(self):
|
||||||
|
kp = self.data.get_kp_complete_profiles()
|
||||||
|
|
||||||
|
kp_min, kp_max = (-1, -1)
|
||||||
|
if self._highlight_data is not None:
|
||||||
|
kp_min, kp_max = self._highlight_data
|
||||||
|
|
||||||
|
def color_hightlight(kp):
|
||||||
|
if kp_min <= kp <= kp_max:
|
||||||
|
return self.color_plot_highlight
|
||||||
|
return self.color_plot
|
||||||
|
|
||||||
self.line_xy = []
|
self.line_xy = []
|
||||||
for xy in zip(self.data.get_x(), self.data.get_y()):
|
for x, y, kp in zip(self.data.get_x(),
|
||||||
self.line_xy.append(np.column_stack(xy))
|
self.data.get_y(),
|
||||||
|
kp):
|
||||||
self._colors, self._style = self.color_hightlight()
|
line = self.canvas.axes.plot(
|
||||||
self.line_xy_collection = collections.LineCollection(
|
x, y,
|
||||||
self.line_xy,
|
color=color_hightlight(kp),
|
||||||
colors=self._colors,
|
**self.plot_default_kargs
|
||||||
linestyle=self._style,
|
|
||||||
picker=10
|
|
||||||
)
|
|
||||||
self.canvas.axes.add_collection(self.line_xy_collection)
|
|
||||||
|
|
||||||
def color_hightlight(self):
|
|
||||||
rows = sorted(list(
|
|
||||||
set(
|
|
||||||
(i.row() for i in self.parent.tableView.selectedIndexes())
|
|
||||||
)
|
)
|
||||||
))
|
self.line_xy.append(line)
|
||||||
colors = [self.color_plot for row in range(len(self._data))]
|
|
||||||
style = ["-" for row in range(len(self._data))]
|
|
||||||
if len(rows) > 0:
|
|
||||||
for row in rows:
|
|
||||||
colors[row] = self.color_plot_current
|
|
||||||
if rows[0] > 0:
|
|
||||||
colors[rows[0]-1] = self.color_plot_previous
|
|
||||||
style[rows[0]-1] = "--"
|
|
||||||
if rows[-1] < len(self._data)-1:
|
|
||||||
colors[rows[-1]+1] = self.color_plot_next
|
|
||||||
style[rows[-1]+1] = "--"
|
|
||||||
return colors, style
|
|
||||||
|
|
||||||
def draw_lr(self):
|
def draw_lr(self):
|
||||||
lx = []
|
lx = []
|
||||||
@@ -260,6 +136,33 @@ class PlotXY(PamhyrPlot):
|
|||||||
self.line_gl.append(line)
|
self.line_gl.append(line)
|
||||||
ind += 1
|
ind += 1
|
||||||
|
|
||||||
|
def draw_current(self):
|
||||||
|
# Previous profile
|
||||||
|
self.before_plot_selected, = self.canvas.axes.plot(
|
||||||
|
self.data.profile(0).x(),
|
||||||
|
self.data.profile(0).y(),
|
||||||
|
color=self.color_plot_previous, linestyle="--",
|
||||||
|
**self.plot_default_kargs
|
||||||
|
)
|
||||||
|
self.before_plot_selected.set_visible(False)
|
||||||
|
|
||||||
|
# Current profile
|
||||||
|
self.plot_selected, = self.canvas.axes.plot(
|
||||||
|
self.data.profile(0).x(),
|
||||||
|
self.data.profile(0).y(),
|
||||||
|
color=self.color_plot_current, **self.plot_default_kargs
|
||||||
|
)
|
||||||
|
self.plot_selected.set_visible(False)
|
||||||
|
|
||||||
|
# Next profile
|
||||||
|
self.after_plot_selected, = self.canvas.axes.plot(
|
||||||
|
self.data.profile(0).x(),
|
||||||
|
self.data.profile(0).y(),
|
||||||
|
color=self.color_plot_next, linestyle='--',
|
||||||
|
**self.plot_default_kargs
|
||||||
|
)
|
||||||
|
self.after_plot_selected.set_visible(False)
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def update(self):
|
def update(self):
|
||||||
if not self._init:
|
if not self._init:
|
||||||
@@ -280,24 +183,21 @@ class PlotXY(PamhyrPlot):
|
|||||||
x_complete = list(self.data.get_guidelines_x())
|
x_complete = list(self.data.get_guidelines_x())
|
||||||
y_complete = list(self.data.get_guidelines_y())
|
y_complete = list(self.data.get_guidelines_y())
|
||||||
|
|
||||||
# TODO comprendre à quoi sert ce bout de code
|
for i in range(self.data.number_profiles):
|
||||||
# ========>
|
if i < len(self.line_xy):
|
||||||
# for i in range(self.data.number_profiles):
|
self.line_xy[i][0].set_data(
|
||||||
# if i < len(self.line_xy):
|
self.data.profile(i).x(),
|
||||||
# self.line_xy[i][0].set_data(
|
self.data.profile(i).y()
|
||||||
# self.data.profile(i).x(),
|
)
|
||||||
# self.data.profile(i).y()
|
else:
|
||||||
# )
|
self.line_xy.append(
|
||||||
# else:
|
self.canvas.axes.plot(
|
||||||
# self.line_xy.append(
|
self.data.profile(i).x(),
|
||||||
# self.canvas.axes.plot(
|
self.data.profile(i).y(),
|
||||||
# self.data.profile(i).x(),
|
color='r',
|
||||||
# self.data.profile(i).y(),
|
**self.plot_default_kargs
|
||||||
# color='r',
|
)
|
||||||
# **self.plot_default_kargs
|
)
|
||||||
# )
|
|
||||||
# )
|
|
||||||
# <========
|
|
||||||
|
|
||||||
for i in range(len(x_complete)):
|
for i in range(len(x_complete)):
|
||||||
if i < len(self.line_gl):
|
if i < len(self.line_gl):
|
||||||
@@ -315,9 +215,32 @@ class PlotXY(PamhyrPlot):
|
|||||||
|
|
||||||
def update_current(self):
|
def update_current(self):
|
||||||
if self._current_data_update:
|
if self._current_data_update:
|
||||||
self._colors, self._style = self.color_hightlight()
|
ind = self._current_data
|
||||||
self.line_xy_collection.set_colors(self._colors)
|
before = ind - 1
|
||||||
self.line_xy_collection.set_linestyle(self._style)
|
after = ind + 1
|
||||||
|
|
||||||
|
self.before_plot_selected.set_visible(False)
|
||||||
|
self.plot_selected.set_visible(False)
|
||||||
|
self.after_plot_selected.set_visible(False)
|
||||||
|
|
||||||
|
if 0 <= before < self.data.number_profiles:
|
||||||
|
self.before_plot_selected.set_data(
|
||||||
|
self.data.profile(before).x(),
|
||||||
|
self.data.profile(before).y()
|
||||||
|
)
|
||||||
|
self.before_plot_selected.set_visible(True)
|
||||||
|
|
||||||
|
if 0 <= ind < self.data.number_profiles:
|
||||||
|
self.plot_selected.set_data(self.data.profile(ind).x(),
|
||||||
|
self.data.profile(ind).y())
|
||||||
|
self.plot_selected.set_visible(True)
|
||||||
|
|
||||||
|
if 0 <= after < self.data.number_profiles:
|
||||||
|
self.after_plot_selected.set_data(
|
||||||
|
self.data.profile(after).x(),
|
||||||
|
self.data.profile(after).y()
|
||||||
|
)
|
||||||
|
self.after_plot_selected.set_visible(True)
|
||||||
|
|
||||||
def update_lr(self):
|
def update_lr(self):
|
||||||
for line in self.line_lr:
|
for line in self.line_lr:
|
||||||
|
|||||||
@@ -24,12 +24,10 @@ from tools import timer, trace
|
|||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
Qt, QCoreApplication, QItemSelectionModel,
|
Qt, QCoreApplication, QItemSelectionModel
|
||||||
QItemSelection, QItemSelectionRange,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from matplotlib.widgets import RectangleSelector
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
@@ -48,7 +46,6 @@ class Plot(PamhyrPlot):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._table = table
|
self._table = table
|
||||||
self._parent = parent
|
|
||||||
self._z_note = None
|
self._z_note = None
|
||||||
self._z_line = None
|
self._z_line = None
|
||||||
self._z_fill_between = None
|
self._z_fill_between = None
|
||||||
@@ -71,86 +68,40 @@ class Plot(PamhyrPlot):
|
|||||||
None # Hydrolic values (z, wet_area,
|
None # Hydrolic values (z, wet_area,
|
||||||
# wet_preimeter, water_width)
|
# wet_preimeter, water_width)
|
||||||
)
|
)
|
||||||
self._onpickevent = None
|
|
||||||
self._rect_select = RectangleSelector(
|
|
||||||
ax=self.canvas.axes,
|
|
||||||
onselect=self.rect_select_callback,
|
|
||||||
useblit=True,
|
|
||||||
button=[1], # don't use middle nor right button
|
|
||||||
minspanx=2.0,
|
|
||||||
minspany=2.0,
|
|
||||||
spancoords='pixels',
|
|
||||||
interactive=False
|
|
||||||
)
|
|
||||||
|
|
||||||
def onrelease(self, event):
|
|
||||||
# we need to do that to prevent conflicst
|
|
||||||
# between onpick and rect_select_callback
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
|
||||||
points, hyd = self.highlight
|
|
||||||
if self._onpickevent is not None:
|
|
||||||
ind, point = self._closest_point(self._onpickevent)
|
|
||||||
if modifiers == Qt.ControlModifier:
|
|
||||||
rows = self._parent.index_selected_rows()
|
|
||||||
if ind in rows:
|
|
||||||
rows.remove(ind)
|
|
||||||
del (points[ind])
|
|
||||||
self.highlight = (points, hyd)
|
|
||||||
self._select_in_table(rows)
|
|
||||||
else:
|
|
||||||
self.highlight = (points+[point], hyd)
|
|
||||||
self._select_in_table(rows+[ind])
|
|
||||||
elif modifiers == Qt.ShiftModifier:
|
|
||||||
rows = self._parent.index_selected_rows()
|
|
||||||
if len(rows) > 0:
|
|
||||||
i1 = min(rows[0], rows[-1], ind)
|
|
||||||
i2 = max(rows[0], rows[-1], ind)
|
|
||||||
p = [
|
|
||||||
[self.data.points[i].x, self.data.points[i].y]
|
|
||||||
for i in range(i1, i2)
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
i1 = ind
|
|
||||||
i2 = ind
|
|
||||||
p = [point]
|
|
||||||
self.highlight = (p, hyd)
|
|
||||||
self._select_range_in_table(i1, i2)
|
|
||||||
else:
|
|
||||||
self.highlight = ([point], hyd)
|
|
||||||
self._select_in_table([ind])
|
|
||||||
|
|
||||||
self._onpickevent = None
|
|
||||||
|
|
||||||
def onpick(self, event):
|
def onpick(self, event):
|
||||||
if event.mouseevent.inaxes != self.canvas.axes:
|
if event.mouseevent.inaxes != self.canvas.axes:
|
||||||
return
|
return
|
||||||
if event.mouseevent.button.value != 1:
|
|
||||||
return
|
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
modifiers = QApplication.keyboardModifiers()
|
||||||
if modifiers not in [Qt.ControlModifier,
|
if modifiers != Qt.ControlModifier:
|
||||||
Qt.NoModifier,
|
|
||||||
Qt.ShiftModifier]:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self._onpickevent = event
|
_, hyd = self.highlight
|
||||||
|
|
||||||
|
ind, point = self._closer_point(event)
|
||||||
|
|
||||||
|
self.highlight = ([point], hyd)
|
||||||
|
self._select_in_table(ind)
|
||||||
|
|
||||||
|
self.update()
|
||||||
return
|
return
|
||||||
|
|
||||||
def onclick(self, event):
|
def onclick(self, event):
|
||||||
if event.inaxes != self.canvas.axes:
|
if event.inaxes != self.canvas.axes:
|
||||||
return
|
return
|
||||||
if event.button.value == 1:
|
|
||||||
|
modifiers = QApplication.keyboardModifiers()
|
||||||
|
if modifiers != Qt.ShiftModifier:
|
||||||
return
|
return
|
||||||
|
|
||||||
points, _ = self.highlight
|
points, _ = self.highlight
|
||||||
|
|
||||||
z = self._get_z_from_click(event)
|
z = self._get_z_from_click(event)
|
||||||
if z < self.data.z_min() or event.button.value == 2:
|
if z < self.data.z_min():
|
||||||
self.highlight = (points, None)
|
|
||||||
self.update()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
a, p, w = self._compute_hydraulics(z)
|
a, p, w = self._compute_hydrolics(z)
|
||||||
|
|
||||||
logger.debug(f"{z, a, p, w}")
|
logger.debug(f"{z, a, p, w}")
|
||||||
|
|
||||||
@@ -159,7 +110,7 @@ class Plot(PamhyrPlot):
|
|||||||
self.update()
|
self.update()
|
||||||
return
|
return
|
||||||
|
|
||||||
def select_points_from_indices(self, indices):
|
def select_points_from_indexes(self, indexes):
|
||||||
data = self.data
|
data = self.data
|
||||||
_, hyd = self.highlight
|
_, hyd = self.highlight
|
||||||
|
|
||||||
@@ -167,7 +118,7 @@ class Plot(PamhyrPlot):
|
|||||||
map(
|
map(
|
||||||
lambda e: e[1],
|
lambda e: e[1],
|
||||||
filter(
|
filter(
|
||||||
lambda e: e[0] in indices,
|
lambda e: e[0] in indexes,
|
||||||
enumerate(
|
enumerate(
|
||||||
zip(data.get_station(), data.z())
|
zip(data.get_station(), data.z())
|
||||||
)
|
)
|
||||||
@@ -182,13 +133,9 @@ class Plot(PamhyrPlot):
|
|||||||
if self._table is not None:
|
if self._table is not None:
|
||||||
self._table.blockSignals(True)
|
self._table.blockSignals(True)
|
||||||
self._table.setFocus()
|
self._table.setFocus()
|
||||||
|
|
||||||
selection = self._table.selectionModel()
|
selection = self._table.selectionModel()
|
||||||
index = QItemSelection()
|
index = self._table.model().index(ind, 0)
|
||||||
if len(ind) > 0:
|
|
||||||
for i in ind:
|
|
||||||
index.append(QItemSelectionRange(
|
|
||||||
self._table.model().index(i, 0))
|
|
||||||
)
|
|
||||||
selection.select(
|
selection.select(
|
||||||
index,
|
index,
|
||||||
QItemSelectionModel.Rows |
|
QItemSelectionModel.Rows |
|
||||||
@@ -196,27 +143,10 @@ class Plot(PamhyrPlot):
|
|||||||
QItemSelectionModel.Select
|
QItemSelectionModel.Select
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(ind) > 0:
|
self._table.scrollTo(index)
|
||||||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
|
||||||
self._table.blockSignals(False)
|
self._table.blockSignals(False)
|
||||||
|
|
||||||
def _select_range_in_table(self, ind1, ind2):
|
def _closer_point(self, event):
|
||||||
if self._table is not None:
|
|
||||||
self._table.blockSignals(True)
|
|
||||||
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._table.blockSignals(False)
|
|
||||||
|
|
||||||
def _closest_point(self, event):
|
|
||||||
points_ind = event.ind
|
points_ind = event.ind
|
||||||
axes = self.canvas.axes
|
axes = self.canvas.axes
|
||||||
bx, by = axes.get_xlim(), axes.get_ylim()
|
bx, by = axes.get_xlim(), axes.get_ylim()
|
||||||
@@ -236,62 +166,22 @@ class Plot(PamhyrPlot):
|
|||||||
|
|
||||||
def dist_mouse(point):
|
def dist_mouse(point):
|
||||||
x, y = point[1]
|
x, y = point[1]
|
||||||
d2 = ((mx - x) / ratio) ** 2 + ((my - y) ** 2)
|
d = sqrt(
|
||||||
return d2
|
(((mx - x) / ratio) ** 2) +
|
||||||
|
((my - y) ** 2)
|
||||||
|
)
|
||||||
|
return d
|
||||||
|
|
||||||
closest = min(
|
closer = min(
|
||||||
points, key=dist_mouse
|
points, key=dist_mouse
|
||||||
)
|
)
|
||||||
|
|
||||||
return closest
|
return closer
|
||||||
|
|
||||||
def _get_z_from_click(self, event):
|
def _get_z_from_click(self, event):
|
||||||
return event.ydata
|
return event.ydata
|
||||||
|
|
||||||
def rect_select_callback(self, eclick, erelease):
|
def _compute_hydrolics(self, z):
|
||||||
|
|
||||||
points, hyd = self.highlight
|
|
||||||
x1, y1 = eclick.xdata, eclick.ydata
|
|
||||||
x2, y2 = erelease.xdata, erelease.ydata
|
|
||||||
|
|
||||||
if (max(abs(x1-x2), abs(y1-y2)) < 0.001):
|
|
||||||
return
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
|
||||||
|
|
||||||
x1, y1 = eclick.xdata, eclick.ydata
|
|
||||||
x2, y2 = erelease.xdata, erelease.ydata
|
|
||||||
|
|
||||||
inds, points2 = self._points_in_rectangle(x1, y1, x2, y2)
|
|
||||||
self._onclickevent = None
|
|
||||||
if modifiers == Qt.ControlModifier:
|
|
||||||
rows = self._parent.index_selected_rows()
|
|
||||||
if all(i in rows for i in inds):
|
|
||||||
for ind in sorted(inds, reverse=True):
|
|
||||||
rows.remove(ind)
|
|
||||||
del (points[ind])
|
|
||||||
self.highlight = (points, hyd)
|
|
||||||
self._select_in_table(rows)
|
|
||||||
else:
|
|
||||||
self.highlight = (points+points2, hyd)
|
|
||||||
self._select_in_table(rows+inds)
|
|
||||||
else:
|
|
||||||
self.highlight = (points2, hyd)
|
|
||||||
self._select_in_table(inds)
|
|
||||||
return
|
|
||||||
|
|
||||||
def _points_in_rectangle(self, x1, y1, x2, y2):
|
|
||||||
# TODO: use lambdas
|
|
||||||
listi = []
|
|
||||||
listp = []
|
|
||||||
station = self.data._get_station(self.data.points)
|
|
||||||
for i, p in enumerate(self.data.points):
|
|
||||||
if (min(x1, x2) < station[i] < max(x1, x2)
|
|
||||||
and min(y1, y2) < p.z < max(y1, y2)):
|
|
||||||
listi.append(i)
|
|
||||||
listp.append((station[i], p.z))
|
|
||||||
return listi, listp
|
|
||||||
|
|
||||||
def _compute_hydraulics(self, z):
|
|
||||||
profile = self.data
|
profile = self.data
|
||||||
|
|
||||||
points = profile.wet_points(z)
|
points = profile.wet_points(z)
|
||||||
@@ -320,7 +210,7 @@ class Plot(PamhyrPlot):
|
|||||||
self.profile_line2D, = self.canvas.axes.plot(
|
self.profile_line2D, = self.canvas.axes.plot(
|
||||||
x, y, color=self.color_plot,
|
x, y, color=self.color_plot,
|
||||||
lw=1.5, markersize=7, marker='+',
|
lw=1.5, markersize=7, marker='+',
|
||||||
picker=10
|
picker=30
|
||||||
)
|
)
|
||||||
|
|
||||||
self.draw_annotation(x, y)
|
self.draw_annotation(x, y)
|
||||||
@@ -379,16 +269,12 @@ class Plot(PamhyrPlot):
|
|||||||
x, y,
|
x, y,
|
||||||
color=self.color_plot_highlight,
|
color=self.color_plot_highlight,
|
||||||
lw=1.5, markersize=7, marker='+',
|
lw=1.5, markersize=7, marker='+',
|
||||||
|
picker=30
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if hyd is not None:
|
if hyd is not None:
|
||||||
self.draw_highligth_z_line(*hyd)
|
self.draw_highligth_z_line(*hyd)
|
||||||
else:
|
|
||||||
if self._z_note is not None:
|
|
||||||
self._z_note.set_visible(False)
|
|
||||||
self._z_line[0].set_visible(False)
|
|
||||||
self._z_fill_between.set_visible(False)
|
|
||||||
|
|
||||||
def draw_highligth_z_line(self, z, a, p, w):
|
def draw_highligth_z_line(self, z, a, p, w):
|
||||||
text = (
|
text = (
|
||||||
@@ -413,7 +299,6 @@ class Plot(PamhyrPlot):
|
|||||||
xlim, [z, z],
|
xlim, [z, z],
|
||||||
color=self.color_plot_river_water
|
color=self.color_plot_river_water
|
||||||
)
|
)
|
||||||
self._z_line[0].set_visible(True)
|
|
||||||
|
|
||||||
self._z_note = self.canvas.axes.annotate(
|
self._z_note = self.canvas.axes.annotate(
|
||||||
text, pos,
|
text, pos,
|
||||||
@@ -425,15 +310,12 @@ class Plot(PamhyrPlot):
|
|||||||
fontweight='bold',
|
fontweight='bold',
|
||||||
alpha=0.7
|
alpha=0.7
|
||||||
)
|
)
|
||||||
self._z_note.set_visible(True)
|
|
||||||
else:
|
else:
|
||||||
self.draw_highligth_z_line_fill(x, y, z)
|
self.draw_highligth_z_line_fill(x, y, z)
|
||||||
|
|
||||||
self._z_line[0].set_data(xlim, [z, z])
|
self._z_line[0].set_data(xlim, [z, z])
|
||||||
self._z_note.set_position(pos)
|
self._z_note.set_position(pos)
|
||||||
self._z_note.set_text(text)
|
self._z_note.set_text(text)
|
||||||
self._z_line[0].set_visible(True)
|
|
||||||
self._z_note.set_visible(True)
|
|
||||||
|
|
||||||
def draw_highligth_z_line_fill(self, x, y, z):
|
def draw_highligth_z_line_fill(self, x, y, z):
|
||||||
if self._z_fill_between is not None:
|
if self._z_fill_between is not None:
|
||||||
|
|||||||
@@ -82,6 +82,16 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||||||
elif value == self._data.z_max():
|
elif value == self._data.z_max():
|
||||||
return QColor("blue")
|
return QColor("blue")
|
||||||
|
|
||||||
|
if role == Qt.ToolTipRole:
|
||||||
|
if value == self._data.z_min():
|
||||||
|
return _translate("MainWindowProfile",
|
||||||
|
"La cote du fond",
|
||||||
|
"Z minimale")
|
||||||
|
elif value == self._data.z_max():
|
||||||
|
return _translate("MainWindowProfile",
|
||||||
|
"La cote maximale",
|
||||||
|
"Z maximale")
|
||||||
|
|
||||||
if index.column() == 3:
|
if index.column() == 3:
|
||||||
value = self._data.point(index.row()).name
|
value = self._data.point(index.row()).name
|
||||||
|
|
||||||
@@ -94,6 +104,16 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||||||
if role == Qt.ForegroundRole:
|
if role == Qt.ForegroundRole:
|
||||||
return QColor("darkRed")
|
return QColor("darkRed")
|
||||||
|
|
||||||
|
if role == Qt.ToolTipRole:
|
||||||
|
if value.strip().upper() == "RG":
|
||||||
|
return _translate(
|
||||||
|
"MainWindowProfile", "Rive gauche"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return _translate(
|
||||||
|
"MainWindowProfile", "Rive droite"
|
||||||
|
)
|
||||||
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
def setData(self, index, value, role=Qt.EditRole):
|
def setData(self, index, value, role=Qt.EditRole):
|
||||||
@@ -230,11 +250,11 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||||||
self.endMoveRows()
|
self.endMoveRows()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def purge(self, np_purge):
|
def purge(self):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
PurgeCommand(
|
PurgeCommand(
|
||||||
self._data, np_purge
|
self._data, 24
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,8 @@ import copy
|
|||||||
import sys
|
import sys
|
||||||
import csv
|
import csv
|
||||||
from time import time
|
from time import time
|
||||||
import logging
|
|
||||||
|
|
||||||
from tools import trace, timer, logger_exception
|
from tools import trace, timer
|
||||||
from Modules import Modules
|
from Modules import Modules
|
||||||
|
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
@@ -47,12 +46,9 @@ from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
|||||||
from View.Geometry.Profile.Plot import Plot
|
from View.Geometry.Profile.Plot import Plot
|
||||||
from View.Geometry.Profile.Table import GeometryProfileTableModel
|
from View.Geometry.Profile.Table import GeometryProfileTableModel
|
||||||
from View.Geometry.Profile.Translate import GeometryProfileTranslate
|
from View.Geometry.Profile.Translate import GeometryProfileTranslate
|
||||||
from View.Geometry.PurgeDialog import PurgeDialog
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
logger = logging.getLogger()
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileWindow(PamhyrWindow):
|
class ProfileWindow(PamhyrWindow):
|
||||||
_pamhyr_ui = "GeometryCrossSection"
|
_pamhyr_ui = "GeometryCrossSection"
|
||||||
@@ -115,8 +111,7 @@ class ProfileWindow(PamhyrWindow):
|
|||||||
data=self._profile,
|
data=self._profile,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
toolbar=self._toolbar,
|
toolbar=self._toolbar,
|
||||||
table=self.find(QTableView, "tableView"),
|
table=self.find(QTableView, "tableView")
|
||||||
parent=self
|
|
||||||
)
|
)
|
||||||
self._plot.draw()
|
self._plot.draw()
|
||||||
|
|
||||||
@@ -147,7 +142,7 @@ class ProfileWindow(PamhyrWindow):
|
|||||||
|
|
||||||
def update_points_selection(self):
|
def update_points_selection(self):
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
self._plot.select_points_from_indices(rows)
|
self._plot.select_points_from_indexes(rows)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.update_plot()
|
self.update_plot()
|
||||||
@@ -170,6 +165,7 @@ class ProfileWindow(PamhyrWindow):
|
|||||||
if Modules.GEOMETRY not in key:
|
if Modules.GEOMETRY not in key:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
logger.debug("TOTO")
|
||||||
self._tablemodel.layoutChanged.emit()
|
self._tablemodel.layoutChanged.emit()
|
||||||
self._update(redraw=True, propagate=False)
|
self._update(redraw=True, propagate=False)
|
||||||
|
|
||||||
@@ -262,19 +258,6 @@ class ProfileWindow(PamhyrWindow):
|
|||||||
self._tablemodel.purge()
|
self._tablemodel.purge()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def purge(self):
|
|
||||||
try:
|
|
||||||
dlg = PurgeDialog(
|
|
||||||
trad=self._trad,
|
|
||||||
parent=self
|
|
||||||
)
|
|
||||||
if dlg.exec():
|
|
||||||
self._tablemodel.purge(dlg.np_purge)
|
|
||||||
self._plot.draw()
|
|
||||||
except Exception as e:
|
|
||||||
logger_exception(e)
|
|
||||||
return
|
|
||||||
|
|
||||||
def reverse(self):
|
def reverse(self):
|
||||||
self._tablemodel.reverse()
|
self._tablemodel.reverse()
|
||||||
self.update()
|
self.update()
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
# PurgeDialog.py -- Pamhyr
|
|
||||||
# Copyright (C) 2023-2024 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/>.
|
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
|
||||||
|
|
||||||
from PyQt5.QtGui import (
|
|
||||||
QKeySequence,
|
|
||||||
)
|
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
|
||||||
Qt, QVariant, QAbstractTableModel,
|
|
||||||
)
|
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QUndoStack, QShortcut, QSpinBox,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class PurgeDialog(PamhyrDialog):
|
|
||||||
_pamhyr_ui = "PurgeOptions"
|
|
||||||
_pamhyr_name = "Purge"
|
|
||||||
|
|
||||||
def __init__(self, trad=None, parent=None):
|
|
||||||
super(PurgeDialog, self).__init__(
|
|
||||||
title=trad[self._pamhyr_name],
|
|
||||||
trad=trad,
|
|
||||||
options=[],
|
|
||||||
parent=parent
|
|
||||||
)
|
|
||||||
|
|
||||||
self._init_default_values()
|
|
||||||
|
|
||||||
def _init_default_values(self):
|
|
||||||
self._np_purge = 24
|
|
||||||
|
|
||||||
@property
|
|
||||||
def np_purge(self):
|
|
||||||
return self._np_purge
|
|
||||||
|
|
||||||
def accept(self):
|
|
||||||
self._np_purge = self.get_spin_box("spinBox_np_purge")
|
|
||||||
super().accept()
|
|
||||||
|
|
||||||
def reject(self):
|
|
||||||
self.close()
|
|
||||||
@@ -259,11 +259,11 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def purge(self, np_purge):
|
def purge(self):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
PurgeCommand(
|
PurgeCommand(
|
||||||
self._data, np_purge
|
self._data, 24
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
@@ -33,12 +33,12 @@ class GeometryTranslate(MainTranslate):
|
|||||||
|
|
||||||
self._dict["open_file"] = _translate("Geometry", "Open a file")
|
self._dict["open_file"] = _translate("Geometry", "Open a file")
|
||||||
self._dict["file_st"] = _translate(
|
self._dict["file_st"] = _translate(
|
||||||
"Geometry", "Mage geometry file (*.ST *.st)")
|
"Geometry", "File mage geometry (*.ST *.st)")
|
||||||
self._dict["file_m"] = _translate(
|
self._dict["file_m"] = _translate(
|
||||||
"Geometry", "Mage meshed geometry file (*.M *.m)")
|
"Geometry", "File mage meshed geometry (*.M *.m)")
|
||||||
self._dict["file_shp"] = _translate(
|
self._dict["file_shp"] = _translate(
|
||||||
"Geometry", "Shapefile (*.SHP *.shp)")
|
"Geometry", "Shapefile (*.SHP *.shp)")
|
||||||
self._dict["file_all"] = _translate("Geometry", "All files (*)")
|
self._dict["file_all"] = _translate("Geometry", "All file (*)")
|
||||||
|
|
||||||
self._dict["cross_section"] = _translate("Geometry", "cross-section")
|
self._dict["cross_section"] = _translate("Geometry", "cross-section")
|
||||||
self._dict["cross_sections"] = _translate("Geometry", "cross-sections")
|
self._dict["cross_sections"] = _translate("Geometry", "cross-sections")
|
||||||
@@ -70,7 +70,7 @@ class GeometryTranslate(MainTranslate):
|
|||||||
"2": _translate("Geometry", "the second guide-line"),
|
"2": _translate("Geometry", "the second guide-line"),
|
||||||
"3": _translate(
|
"3": _translate(
|
||||||
"Geometry",
|
"Geometry",
|
||||||
"the mean over the two guide-lines"
|
"the means between the two guide-lines"
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# UpdateKPDialog.py -- Pamhyr
|
# MeshingDialog.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2024 INRAE
|
# Copyright (C) 2023-2024 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
@@ -28,7 +28,7 @@ from PyQt5.QtCore import (
|
|||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
||||||
QDoubleSpinBox, QButtonGroup,
|
QDoubleSpinBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -50,20 +50,14 @@ class UpdateKPDialog(PamhyrDialog):
|
|||||||
self._init_default_values()
|
self._init_default_values()
|
||||||
|
|
||||||
def _init_default_values(self):
|
def _init_default_values(self):
|
||||||
gl, _ = self._reach.compute_guidelines()
|
self._space_step = 50.0
|
||||||
self._gl = list(gl)
|
self._lplan = False
|
||||||
|
self._lm = "3"
|
||||||
|
self._linear = False
|
||||||
|
self._begin_cs = -1
|
||||||
|
self._end_cs = -1
|
||||||
self._begin_dir = "un"
|
self._begin_dir = "un"
|
||||||
self._end_dir = "np"
|
self._end_dir = "np"
|
||||||
|
|
||||||
lower_gl = list(map(str.lower, self._gl))
|
|
||||||
for i, gl in enumerate(lower_gl):
|
|
||||||
if gl == "rd":
|
|
||||||
self._begin_dir = self._gl[i]
|
|
||||||
elif gl == "rg":
|
|
||||||
self._end_dir = self._gl[i]
|
|
||||||
|
|
||||||
self._orientation = 0
|
|
||||||
self._origin = self._reach.profile(0)
|
self._origin = self._reach.profile(0)
|
||||||
self._origin_value = self._reach.profile(0).kp
|
self._origin_value = self._reach.profile(0).kp
|
||||||
|
|
||||||
@@ -75,19 +69,8 @@ class UpdateKPDialog(PamhyrDialog):
|
|||||||
|
|
||||||
self.combobox_add_items("comboBox_origin", profiles)
|
self.combobox_add_items("comboBox_origin", profiles)
|
||||||
|
|
||||||
self.find(QComboBox, "comboBox_origin")\
|
self.find(QComboBox, "comboBox_origin").currentIndexChanged.connect(
|
||||||
.currentIndexChanged\
|
self.changed_profile)
|
||||||
.connect(
|
|
||||||
self.changed_profile
|
|
||||||
)
|
|
||||||
|
|
||||||
buttonbox = self.find(QButtonGroup, "buttonGroup_orientation")
|
|
||||||
|
|
||||||
for button in buttonbox.buttons():
|
|
||||||
name = button.objectName()
|
|
||||||
i = int(name.split('_')[-1])
|
|
||||||
|
|
||||||
buttonbox.setId(button, i)
|
|
||||||
|
|
||||||
def changed_profile(self):
|
def changed_profile(self):
|
||||||
origin = self.get_combobox_text("comboBox_origin")
|
origin = self.get_combobox_text("comboBox_origin")
|
||||||
@@ -119,8 +102,11 @@ class UpdateKPDialog(PamhyrDialog):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
def _init_default_values_guidelines(self):
|
def _init_default_values_guidelines(self):
|
||||||
bgl = ['un'] + self._gl + ['np']
|
gl, _ = self._reach.compute_guidelines()
|
||||||
egl = ['un'] + self._gl + ['np']
|
gl = list(gl)
|
||||||
|
|
||||||
|
bgl = ['un'] + gl + ['np']
|
||||||
|
egl = ['un'] + gl + ['np']
|
||||||
|
|
||||||
self.combobox_add_items("comboBox_begin_gl", bgl)
|
self.combobox_add_items("comboBox_begin_gl", bgl)
|
||||||
self.combobox_add_items("comboBox_end_gl", egl)
|
self.combobox_add_items("comboBox_end_gl", egl)
|
||||||
@@ -128,10 +114,6 @@ class UpdateKPDialog(PamhyrDialog):
|
|||||||
self.set_combobox_text("comboBox_begin_gl", self._begin_dir)
|
self.set_combobox_text("comboBox_begin_gl", self._begin_dir)
|
||||||
self.set_combobox_text("comboBox_end_gl", self._end_dir)
|
self.set_combobox_text("comboBox_end_gl", self._end_dir)
|
||||||
|
|
||||||
@property
|
|
||||||
def orientation(self):
|
|
||||||
return self._orientation
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def origin(self):
|
def origin(self):
|
||||||
return self._origin
|
return self._origin
|
||||||
@@ -151,12 +133,11 @@ class UpdateKPDialog(PamhyrDialog):
|
|||||||
def accept(self):
|
def accept(self):
|
||||||
origin = self.get_combobox_text("comboBox_origin")
|
origin = self.get_combobox_text("comboBox_origin")
|
||||||
self._origin = self.profiles.index(origin)
|
self._origin = self.profiles.index(origin)
|
||||||
|
|
||||||
self._origin_value = self.get_double_spin_box("doubleSpinBox_origin")
|
self._origin_value = self.get_double_spin_box("doubleSpinBox_origin")
|
||||||
|
|
||||||
self._begin_dir = self.get_combobox_text("comboBox_begin_gl")
|
self._begin_dir = self.get_combobox_text("comboBox_begin_gl")
|
||||||
self._end_dir = self.get_combobox_text("comboBox_end_gl")
|
self._end_dir = self.get_combobox_text("comboBox_end_gl")
|
||||||
self._orientation = self.get_checked_id_button_group(
|
|
||||||
"buttonGroup_orientation"
|
|
||||||
)
|
|
||||||
|
|
||||||
super().accept()
|
super().accept()
|
||||||
|
|
||||||
|
|||||||
+66
-40
@@ -36,7 +36,7 @@ from PyQt5.QtCore import (
|
|||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QApplication, QMainWindow, QFileDialog, QCheckBox,
|
QApplication, QMainWindow, QFileDialog, QCheckBox,
|
||||||
QUndoStack, QShortcut, QTableView, QHeaderView,
|
QUndoStack, QShortcut, QTableView, QHeaderView,
|
||||||
QAction, QPushButton, QVBoxLayout,
|
QAction, QSlider, QPushButton, QVBoxLayout,
|
||||||
QLabel, QAbstractItemView,
|
QLabel, QAbstractItemView,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -57,7 +57,6 @@ from View.Geometry.PlotAC import PlotAC
|
|||||||
from View.Geometry.PlotKPZ import PlotKPZ
|
from View.Geometry.PlotKPZ import PlotKPZ
|
||||||
from View.Geometry.MeshingDialog import MeshingDialog
|
from View.Geometry.MeshingDialog import MeshingDialog
|
||||||
from View.Geometry.UpdateKPDialog import UpdateKPDialog
|
from View.Geometry.UpdateKPDialog import UpdateKPDialog
|
||||||
from View.Geometry.PurgeDialog import PurgeDialog
|
|
||||||
from View.Geometry.Translate import GeometryTranslate
|
from View.Geometry.Translate import GeometryTranslate
|
||||||
from View.Geometry.Profile.Window import ProfileWindow
|
from View.Geometry.Profile.Window import ProfileWindow
|
||||||
|
|
||||||
@@ -97,6 +96,7 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
self.setup_plots()
|
self.setup_plots()
|
||||||
self.setup_statusbar()
|
self.setup_statusbar()
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
self.changed_slider_value()
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
table_headers = self._trad.get_dict("table_headers")
|
table_headers = self._trad.get_dict("table_headers")
|
||||||
@@ -157,9 +157,6 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
|
|
||||||
def _compute_status_label(self):
|
def _compute_status_label(self):
|
||||||
row = self.index_selected_row()
|
row = self.index_selected_row()
|
||||||
if row is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
profile = self._reach.profile(row)
|
profile = self._reach.profile(row)
|
||||||
|
|
||||||
name = profile.name + " " + str(profile.kp)
|
name = profile.name + " " + str(profile.kp)
|
||||||
@@ -200,6 +197,13 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
self.find(QAction, action)\
|
self.find(QAction, action)\
|
||||||
.triggered.connect(actions[action])
|
.triggered.connect(actions[action])
|
||||||
|
|
||||||
|
self.find(QSlider, "verticalSlider").valueChanged.connect(
|
||||||
|
self.changed_slider_value)
|
||||||
|
self.find(QPushButton, "pushButton_up").clicked.connect(
|
||||||
|
self.decrement_value_slider)
|
||||||
|
self.find(QPushButton, "pushButton_down").clicked.connect(
|
||||||
|
self.increment_value_slider)
|
||||||
|
|
||||||
# Profile selection when line change in table
|
# Profile selection when line change in table
|
||||||
self.find(QTableView, "tableView").selectionModel()\
|
self.find(QTableView, "tableView").selectionModel()\
|
||||||
.selectionChanged\
|
.selectionChanged\
|
||||||
@@ -220,6 +224,7 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
self._plot_ac.draw()
|
self._plot_ac.draw()
|
||||||
|
|
||||||
self.select_current_profile()
|
self.select_current_profile()
|
||||||
|
self.changed_slider_value()
|
||||||
|
|
||||||
if propagate:
|
if propagate:
|
||||||
self._propagate_update(key=Modules.GEOMETRY)
|
self._propagate_update(key=Modules.GEOMETRY)
|
||||||
@@ -293,8 +298,10 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
data = {
|
data = {
|
||||||
"step": dlg.space_step,
|
"step": dlg.space_step,
|
||||||
"limites": [dlg.begin_cs, dlg.end_cs],
|
"limites": [dlg.begin_cs, dlg.end_cs],
|
||||||
|
"origin": dlg.origin,
|
||||||
"directrices": [dlg.begin_dir, dlg.end_dir],
|
"directrices": [dlg.begin_dir, dlg.end_dir],
|
||||||
"lplan": dlg.lplan,
|
"lplan": dlg.lplan,
|
||||||
|
"lm": dlg.lm,
|
||||||
"linear": dlg.linear,
|
"linear": dlg.linear,
|
||||||
}
|
}
|
||||||
self._edit_meshing(data)
|
self._edit_meshing(data)
|
||||||
@@ -327,7 +334,6 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
"origin": dlg.origin,
|
"origin": dlg.origin,
|
||||||
"directrices": [dlg.begin_dir, dlg.end_dir],
|
"directrices": [dlg.begin_dir, dlg.end_dir],
|
||||||
"origin_value": dlg.origin_value,
|
"origin_value": dlg.origin_value,
|
||||||
"orientation": dlg.orientation,
|
|
||||||
}
|
}
|
||||||
self._update_kp(data)
|
self._update_kp(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -354,9 +360,7 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
canvas=self._canvas_xy,
|
canvas=self._canvas_xy,
|
||||||
data=self._reach,
|
data=self._reach,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
toolbar=self._toolbar_xy,
|
toolbar=self._toolbar_xy
|
||||||
table=self.find(QTableView, "tableView"),
|
|
||||||
parent=self
|
|
||||||
)
|
)
|
||||||
self._plot_xy.draw()
|
self._plot_xy.draw()
|
||||||
|
|
||||||
@@ -375,9 +379,7 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
study=self._study,
|
study=self._study,
|
||||||
data=self._reach,
|
data=self._reach,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
toolbar=self._toolbar_kpc,
|
toolbar=self._toolbar_kpc
|
||||||
table=self.find(QTableView, "tableView"),
|
|
||||||
parent=self
|
|
||||||
)
|
)
|
||||||
self._plot_kpc.draw()
|
self._plot_kpc.draw()
|
||||||
|
|
||||||
@@ -403,6 +405,7 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
|
|
||||||
def update_plot_ac(self, ind: int):
|
def update_plot_ac(self, ind: int):
|
||||||
self.tableView.model().blockSignals(True)
|
self.tableView.model().blockSignals(True)
|
||||||
|
self._plot_ac.current = ind
|
||||||
self._plot_ac.update()
|
self._plot_ac.update()
|
||||||
self.tableView.model().blockSignals(False)
|
self.tableView.model().blockSignals(False)
|
||||||
|
|
||||||
@@ -430,11 +433,27 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
self._plot_ac.update()
|
self._plot_ac.update()
|
||||||
self.tableView.model().blockSignals(False)
|
self.tableView.model().blockSignals(False)
|
||||||
|
|
||||||
|
def select_row_profile_slider(self, ind: int = 0):
|
||||||
|
if self.tableView is not None:
|
||||||
|
selectionModel = self.tableView.selectionModel()
|
||||||
|
index = self.tableView.model().index(ind, 0)
|
||||||
|
|
||||||
|
selectionModel.select(
|
||||||
|
index,
|
||||||
|
QItemSelectionModel.Rows |
|
||||||
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
|
||||||
|
self.tableView.scrollTo(index)
|
||||||
|
|
||||||
def select_current_profile(self):
|
def select_current_profile(self):
|
||||||
self.tableView.model().blockSignals(True)
|
self.tableView.model().blockSignals(True)
|
||||||
row = self.index_selected_row()
|
|
||||||
|
|
||||||
if row is not None:
|
if len(self.tableView.selectedIndexes()) > 0:
|
||||||
|
row = self.index_selected_row()
|
||||||
|
|
||||||
|
self.find(QSlider, "verticalSlider").setValue(row)
|
||||||
self.select_plot_xy(row)
|
self.select_plot_xy(row)
|
||||||
self.select_plot_kpc(row)
|
self.select_plot_kpc(row)
|
||||||
self.select_plot_ac(row)
|
self.select_plot_ac(row)
|
||||||
@@ -445,6 +464,33 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
|
|
||||||
self.tableView.model().blockSignals(False)
|
self.tableView.model().blockSignals(False)
|
||||||
|
|
||||||
|
def changed_slider_value(self):
|
||||||
|
self.tableView.model().blockSignals(True)
|
||||||
|
|
||||||
|
if self._table.rowCount() != 0:
|
||||||
|
slider = self.find(QSlider, "verticalSlider")
|
||||||
|
slider.setMaximum(self._table.rowCount() - 1)
|
||||||
|
|
||||||
|
slider_value = slider.value()
|
||||||
|
kp = self._reach.profile(slider_value).kp
|
||||||
|
|
||||||
|
self.select_plot_xy(slider_value)
|
||||||
|
self.select_plot_kpc(slider_value)
|
||||||
|
self.select_row_profile_slider(slider_value)
|
||||||
|
self.update_statusbar()
|
||||||
|
|
||||||
|
self.tableView.model().blockSignals(False)
|
||||||
|
|
||||||
|
def increment_value_slider(self):
|
||||||
|
slider = self.find(QSlider, "verticalSlider")
|
||||||
|
if 0 <= slider.value() < self._table.rowCount() - 1:
|
||||||
|
slider.setValue(slider.value() + 1)
|
||||||
|
|
||||||
|
def decrement_value_slider(self):
|
||||||
|
slider = self.find(QSlider, "verticalSlider")
|
||||||
|
if 0 < slider.value() < self._table.rowCount():
|
||||||
|
slider.setValue(slider.value() - 1)
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
if len(self.tableView.selectedIndexes()) == 0:
|
if len(self.tableView.selectedIndexes()) == 0:
|
||||||
self._table.add(self._table.rowCount())
|
self._table.add(self._table.rowCount())
|
||||||
@@ -465,37 +511,29 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
self._table.delete(rows)
|
self._table.delete(rows)
|
||||||
|
|
||||||
def index_selected_row(self):
|
def index_selected_row(self):
|
||||||
r = self.tableView\
|
return self.tableView\
|
||||||
.selectionModel()\
|
.selectionModel()\
|
||||||
.selectedRows()
|
.selectedRows()[0]\
|
||||||
|
.row()
|
||||||
if len(r) == 1:
|
|
||||||
return r[0].row()
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def sort_ascending(self):
|
def sort_ascending(self):
|
||||||
self._table.sort_profiles(False)
|
self._table.sort_profiles(False)
|
||||||
self.select_current_profile()
|
self.select_current_profile()
|
||||||
|
self.changed_slider_value()
|
||||||
|
|
||||||
def sort_descending(self):
|
def sort_descending(self):
|
||||||
self._table.sort_profiles(True)
|
self._table.sort_profiles(True)
|
||||||
|
|
||||||
self.select_current_profile()
|
self.select_current_profile()
|
||||||
|
self.changed_slider_value()
|
||||||
|
|
||||||
def move_up(self):
|
def move_up(self):
|
||||||
row = self.index_selected_row()
|
row = self.index_selected_row()
|
||||||
if row is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
self._table.move_up(row)
|
self._table.move_up(row)
|
||||||
self.select_current_profile()
|
self.select_current_profile()
|
||||||
|
|
||||||
def move_down(self):
|
def move_down(self):
|
||||||
row = self.index_selected_row()
|
row = self.index_selected_row()
|
||||||
if row is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
self._table.move_down(row)
|
self._table.move_down(row)
|
||||||
self.select_current_profile()
|
self.select_current_profile()
|
||||||
|
|
||||||
@@ -503,18 +541,6 @@ class GeometryWindow(PamhyrWindow):
|
|||||||
self._table.purge()
|
self._table.purge()
|
||||||
self.update_redraw()
|
self.update_redraw()
|
||||||
|
|
||||||
def purge(self):
|
|
||||||
try:
|
|
||||||
dlg = PurgeDialog(
|
|
||||||
trad=self._trad,
|
|
||||||
parent=self
|
|
||||||
)
|
|
||||||
if dlg.exec():
|
|
||||||
self._table.purge(dlg.np_purge)
|
|
||||||
except Exception as e:
|
|
||||||
logger_exception(e)
|
|
||||||
return
|
|
||||||
|
|
||||||
def duplicate(self):
|
def duplicate(self):
|
||||||
rows = [
|
rows = [
|
||||||
row.row() for row in
|
row.row() for row in
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class BasicHydraulicStructuresTranslate(MainTranslate):
|
|||||||
super(BasicHydraulicStructuresTranslate, self).__init__()
|
super(BasicHydraulicStructuresTranslate, self).__init__()
|
||||||
|
|
||||||
self._dict["Basic Hydraulic Structures"] = _translate(
|
self._dict["Basic Hydraulic Structures"] = _translate(
|
||||||
"BasicHydraulicStructures", "Basic Hydraulic Structure"
|
"BasicHydraulicStructures", "Basic Hydraulic Structures"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._dict['msg_type_change_title'] = _translate(
|
self._dict['msg_type_change_title'] = _translate(
|
||||||
@@ -138,7 +138,7 @@ hydraulic structure values?"
|
|||||||
"BasicHydraulicStructures", "Check valve"
|
"BasicHydraulicStructures", "Check valve"
|
||||||
),
|
),
|
||||||
"UD": _translate(
|
"UD": _translate(
|
||||||
"BasicHydraulicStructures", "User-defined"
|
"BasicHydraulicStructures", "User defined"
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,8 @@ from tools import timer
|
|||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
QCoreApplication, Qt,
|
QCoreApplication
|
||||||
)
|
)
|
||||||
from PyQt5.QtWidgets import QApplication
|
|
||||||
|
|
||||||
from matplotlib.collections import LineCollection
|
from matplotlib.collections import LineCollection
|
||||||
|
|
||||||
@@ -51,7 +50,6 @@ class PlotKPC(PamhyrPlot):
|
|||||||
|
|
||||||
self._auto_relim_update = True
|
self._auto_relim_update = True
|
||||||
self._autoscale_update = True
|
self._autoscale_update = True
|
||||||
self.parent = parent
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def river(self):
|
def river(self):
|
||||||
@@ -93,14 +91,7 @@ class PlotKPC(PamhyrPlot):
|
|||||||
self.line_kp_zmin, = self.canvas.axes.plot(
|
self.line_kp_zmin, = self.canvas.axes.plot(
|
||||||
kp, z_min,
|
kp, z_min,
|
||||||
color=self.color_plot_river_bottom,
|
color=self.color_plot_river_bottom,
|
||||||
lw=1.,
|
lw=1.
|
||||||
)
|
|
||||||
|
|
||||||
self.line_kp_zmax, = self.canvas.axes.plot(
|
|
||||||
kp, z_max,
|
|
||||||
color=self.color_plot_river_bottom,
|
|
||||||
lw=1.,
|
|
||||||
alpha=0.0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(kp) != 0:
|
if len(kp) != 0:
|
||||||
@@ -108,8 +99,7 @@ class PlotKPC(PamhyrPlot):
|
|||||||
x=kp,
|
x=kp,
|
||||||
ymin=z_min, ymax=z_max,
|
ymin=z_min, ymax=z_max,
|
||||||
color=self.color_plot,
|
color=self.color_plot,
|
||||||
lw=1.,
|
lw=1.
|
||||||
picker=10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_current(self):
|
def draw_current(self):
|
||||||
@@ -173,40 +163,3 @@ class PlotKPC(PamhyrPlot):
|
|||||||
self.profile.set_data([], [])
|
self.profile.set_data([], [])
|
||||||
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
||||||
def onpick(self, event):
|
|
||||||
if event.mouseevent.inaxes != self.canvas.axes:
|
|
||||||
return
|
|
||||||
if event.mouseevent.button.value != 1:
|
|
||||||
return
|
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
|
||||||
if modifiers not in [Qt.ControlModifier,
|
|
||||||
Qt.NoModifier,
|
|
||||||
Qt.ShiftModifier]:
|
|
||||||
return
|
|
||||||
|
|
||||||
closest = self._closest_profile(event)
|
|
||||||
index = self.parent.tableView.selectedIndexes()
|
|
||||||
if self.parent._table is not None:
|
|
||||||
self.parent._table.setData(index[2], closest)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def _closest_profile(self, event):
|
|
||||||
|
|
||||||
s = event.artist.get_segments()
|
|
||||||
x = [i[0, 0] for i in s]
|
|
||||||
mx = event.mouseevent.xdata
|
|
||||||
points = enumerate(x)
|
|
||||||
|
|
||||||
def dist_mouse(point):
|
|
||||||
x = point[1]
|
|
||||||
d = abs(mx - x)
|
|
||||||
return d
|
|
||||||
|
|
||||||
closest = min(
|
|
||||||
points, key=dist_mouse
|
|
||||||
)
|
|
||||||
|
|
||||||
return closest[1]
|
|
||||||
@@ -141,8 +141,7 @@ class HydraulicStructuresWindow(PamhyrWindow):
|
|||||||
reach=None,
|
reach=None,
|
||||||
profile=None,
|
profile=None,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
toolbar=self.toolbar,
|
toolbar=self.toolbar
|
||||||
parent=self
|
|
||||||
)
|
)
|
||||||
self.plot_kpc.draw()
|
self.plot_kpc.draw()
|
||||||
|
|
||||||
|
|||||||
@@ -52,41 +52,18 @@ class PlotDischarge(PamhyrPlot):
|
|||||||
self._init = True
|
self._init = True
|
||||||
|
|
||||||
def draw_data(self):
|
def draw_data(self):
|
||||||
self.line_discharge = []
|
kp = self.data.reach.reach.get_kp()
|
||||||
|
|
||||||
if len(self.data) != 0:
|
if len(self.data) != 0:
|
||||||
kp = self.data.get_kp()
|
kp = self.data.get_kp()
|
||||||
discharge = self.data.get_discharge()
|
discharge = self.data.get_discharge()
|
||||||
|
|
||||||
line, = self.canvas.axes.plot(
|
self.line_kp_zmin = self.canvas.axes.plot(
|
||||||
kp, discharge,
|
kp, discharge,
|
||||||
color=self.color_plot,
|
color=self.color_plot,
|
||||||
**self.plot_default_kargs
|
**self.plot_default_kargs
|
||||||
)
|
)
|
||||||
self.line_discharge.append(line)
|
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def update(self, ind=None):
|
def update(self, ind=None):
|
||||||
if not self._init:
|
self.draw()
|
||||||
self.draw()
|
|
||||||
|
|
||||||
self.update_data()
|
|
||||||
|
|
||||||
self.update_idle()
|
|
||||||
|
|
||||||
def update_data(self):
|
|
||||||
if len(self.data) == len(self.line_discharge):
|
|
||||||
kp = self.data.get_kp()
|
|
||||||
discharge = self.data.get_discharge()
|
|
||||||
|
|
||||||
line, = self.canvas.axes.plot(
|
|
||||||
kp, discharge,
|
|
||||||
color=self.color_plot,
|
|
||||||
**self.plot_default_kargs
|
|
||||||
)
|
|
||||||
self.line_discharge.append(line)
|
|
||||||
else:
|
|
||||||
for line in self.line_discharge:
|
|
||||||
line.remove()
|
|
||||||
|
|
||||||
self._draw_data()
|
|
||||||
@@ -194,13 +194,8 @@ class InitialConditionsWindow(PamhyrWindow):
|
|||||||
return rows[0].row()
|
return rows[0].row()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.update(propagate=False)
|
|
||||||
|
|
||||||
def _update(self, propagate=True):
|
|
||||||
self._update_plot()
|
self._update_plot()
|
||||||
|
self._propagate_update(key=Modules.INITIAL_CONDITION)
|
||||||
if propagate:
|
|
||||||
self._propagate_update(key=Modules.INITIAL_CONDITION)
|
|
||||||
|
|
||||||
def _update_plot(self):
|
def _update_plot(self):
|
||||||
self.plot_1.draw()
|
self.plot_1.draw()
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
logger.info(e)
|
logger.info(e)
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.update()
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add(self, row, parent=QModelIndex()):
|
def add(self, row, parent=QModelIndex()):
|
||||||
@@ -112,7 +112,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
self.update()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def delete(self, rows, parent=QModelIndex()):
|
def delete(self, rows, parent=QModelIndex()):
|
||||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||||
@@ -135,7 +135,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
self.update()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def move_up(self, row, parent=QModelIndex()):
|
def move_up(self, row, parent=QModelIndex()):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
@@ -152,7 +152,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.endMoveRows()
|
self.endMoveRows()
|
||||||
self.update()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def move_down(self, index, parent=QModelIndex()):
|
def move_down(self, index, parent=QModelIndex()):
|
||||||
if row > len(self._data):
|
if row > len(self._data):
|
||||||
@@ -169,7 +169,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.endMoveRows()
|
self.endMoveRows()
|
||||||
self.update()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def paste(self, row, header, data):
|
def paste(self, row, header, data):
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
@@ -190,13 +190,4 @@ class TableModel(PamhyrTableModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
self.layoutAboutToBeChanged.emit()
|
||||||
self.update()
|
|
||||||
|
|
||||||
def auto_sort(self):
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
|
||||||
self._data.sort(key=lambda x: x[0])
|
|
||||||
self.layoutAboutToBeChanged.emit()
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
# self.auto_sort()
|
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
@@ -137,7 +137,6 @@ class EditLateralContributionWindow(PamhyrWindow):
|
|||||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||||
|
|
||||||
self._table.dataChanged.connect(self.update)
|
self._table.dataChanged.connect(self.update)
|
||||||
self._table.layoutChanged.connect(self.update)
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.plot.update()
|
self.plot.update()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class LCETranslate(LCTranslate):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(LCETranslate, self).__init__()
|
super(LCETranslate, self).__init__()
|
||||||
self._dict["Edit lateral contribution"] = _translate(
|
self._dict["Edit lateral contribution"] = _translate(
|
||||||
"LateralContribution", "Edit lateral sources"
|
"LateralContribution", "Edit lateral contribution"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._sub_dict["table_headers"] = {
|
self._sub_dict["table_headers"] = {
|
||||||
|
|||||||
@@ -1,260 +0,0 @@
|
|||||||
# PlotXY.py -- Pamhyr
|
|
||||||
# Copyright (C) 2023-2024 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/>.
|
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from tools import timer, trace
|
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
|
||||||
from matplotlib import collections
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
|
||||||
QCoreApplication, Qt, QItemSelectionModel,
|
|
||||||
QItemSelection, QItemSelectionRange,
|
|
||||||
)
|
|
||||||
from PyQt5.QtWidgets import QApplication, QTableView
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
|
||||||
|
|
||||||
|
|
||||||
class PlotXY(PamhyrPlot):
|
|
||||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
|
||||||
table=None, parent=None):
|
|
||||||
super(PlotXY, self).__init__(
|
|
||||||
canvas=canvas,
|
|
||||||
trad=trad,
|
|
||||||
data=data,
|
|
||||||
toolbar=toolbar,
|
|
||||||
table=table,
|
|
||||||
parent=parent
|
|
||||||
)
|
|
||||||
|
|
||||||
self.line_xy = []
|
|
||||||
self.line_gl = []
|
|
||||||
|
|
||||||
self.label_x = self._trad["x"]
|
|
||||||
self.label_y = self._trad["y"]
|
|
||||||
|
|
||||||
self.before_plot_selected = None
|
|
||||||
self.plot_selected = None
|
|
||||||
self.after_plot_selected = None
|
|
||||||
self.parent = parent
|
|
||||||
self.line_xy_collection = None
|
|
||||||
self._table = table
|
|
||||||
self._colors = []
|
|
||||||
self._style = []
|
|
||||||
|
|
||||||
def onpick(self, event):
|
|
||||||
if event.mouseevent.inaxes != self.canvas.axes:
|
|
||||||
return
|
|
||||||
if event.mouseevent.button.value not in [1, 3]:
|
|
||||||
return
|
|
||||||
|
|
||||||
closest = self._closest_section(event)
|
|
||||||
t = self.parent.current_tab()
|
|
||||||
tableView = self.parent.find(QTableView, f"tableView_{t}")
|
|
||||||
table = self.parent._table[t]
|
|
||||||
index = tableView.selectedIndexes()
|
|
||||||
kp = self.data.get_kp()
|
|
||||||
if self.parent._table is not None:
|
|
||||||
if event.mouseevent.button.value == 1:
|
|
||||||
table.setData(index[3], kp[closest[0]])
|
|
||||||
if event.mouseevent.button.value == 3:
|
|
||||||
table.setData(index[4], kp[closest[0]])
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def _closest_section(self, event):
|
|
||||||
axes = self.canvas.axes
|
|
||||||
mx = event.mouseevent.xdata
|
|
||||||
my = event.mouseevent.ydata
|
|
||||||
bx, by = axes.get_xlim(), axes.get_ylim()
|
|
||||||
ratio = (bx[0] - bx[1]) / (by[0] - by[1])
|
|
||||||
|
|
||||||
segments = event.artist.get_segments()
|
|
||||||
ind = event.ind
|
|
||||||
|
|
||||||
points = []
|
|
||||||
for i in ind:
|
|
||||||
points = points + [[i, j] for j in segments[i]]
|
|
||||||
|
|
||||||
def dist_mouse(point):
|
|
||||||
x, y = point[1]
|
|
||||||
d2 = (((mx - x) / ratio) ** 2) + ((my - y) ** 2)
|
|
||||||
return d2
|
|
||||||
|
|
||||||
closest = min(
|
|
||||||
points, key=dist_mouse
|
|
||||||
)
|
|
||||||
|
|
||||||
return closest
|
|
||||||
|
|
||||||
@timer
|
|
||||||
def draw(self):
|
|
||||||
self.init_axes()
|
|
||||||
|
|
||||||
if self.data is None:
|
|
||||||
self.idle()
|
|
||||||
return
|
|
||||||
|
|
||||||
if self.data.number_profiles == 0:
|
|
||||||
self._init = False
|
|
||||||
self.idle()
|
|
||||||
return
|
|
||||||
|
|
||||||
self.draw_xy()
|
|
||||||
self.draw_lr()
|
|
||||||
self.draw_gl()
|
|
||||||
|
|
||||||
self.idle()
|
|
||||||
self._init = True
|
|
||||||
|
|
||||||
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))
|
|
||||||
|
|
||||||
self._colors, self._style = self.color_hightlight()
|
|
||||||
self.line_xy_collection = collections.LineCollection(
|
|
||||||
self.line_xy,
|
|
||||||
colors=self._colors,
|
|
||||||
linestyle=self._style,
|
|
||||||
picker=10
|
|
||||||
)
|
|
||||||
self.canvas.axes.add_collection(self.line_xy_collection)
|
|
||||||
|
|
||||||
def color_hightlight(self):
|
|
||||||
kp_min, kp_max = (-1, -1)
|
|
||||||
if self._highlight_data is not None:
|
|
||||||
kp_min, kp_max = self._highlight_data
|
|
||||||
|
|
||||||
colors = [self.color_plot for row in range(len(self._data))]
|
|
||||||
for i, kp in enumerate(self.data.get_kp_complete_profiles()):
|
|
||||||
if kp_min <= kp <= kp_max:
|
|
||||||
colors[i] = self.color_plot_current
|
|
||||||
style = ["-" for row in range(len(self._data))]
|
|
||||||
|
|
||||||
return colors, style
|
|
||||||
|
|
||||||
def draw_lr(self):
|
|
||||||
lx = []
|
|
||||||
ly = []
|
|
||||||
rx = []
|
|
||||||
ry = []
|
|
||||||
|
|
||||||
self.line_lr = []
|
|
||||||
for x, y in zip(self.data.get_x(),
|
|
||||||
self.data.get_y()):
|
|
||||||
lx.append(x[0])
|
|
||||||
ly.append(y[0])
|
|
||||||
|
|
||||||
rx.append(x[-1])
|
|
||||||
ry.append(y[-1])
|
|
||||||
|
|
||||||
line = self.canvas.axes.plot(
|
|
||||||
lx, ly,
|
|
||||||
color=self.color_plot_river_bottom,
|
|
||||||
linestyle="dotted",
|
|
||||||
lw=1.,
|
|
||||||
)
|
|
||||||
self.line_lr.append(line)
|
|
||||||
|
|
||||||
line = self.canvas.axes.plot(
|
|
||||||
rx, ry,
|
|
||||||
color=self.color_plot_river_bottom,
|
|
||||||
linestyle="dotted",
|
|
||||||
lw=1.,
|
|
||||||
)
|
|
||||||
self.line_lr.append(line)
|
|
||||||
|
|
||||||
def draw_gl(self):
|
|
||||||
x_complete = self.data.get_guidelines_x()
|
|
||||||
y_complete = self.data.get_guidelines_y()
|
|
||||||
|
|
||||||
ind = 0
|
|
||||||
self.line_gl = []
|
|
||||||
for x, y in zip(x_complete, y_complete):
|
|
||||||
line = self.canvas.axes.plot(
|
|
||||||
x, y, color=self.colors[ind % len(self.colors)],
|
|
||||||
linestyle=self.linestyle[ind // len(self.colors)]
|
|
||||||
)
|
|
||||||
self.line_gl.append(line)
|
|
||||||
ind += 1
|
|
||||||
|
|
||||||
@timer
|
|
||||||
def update(self):
|
|
||||||
if not self._init:
|
|
||||||
self.draw()
|
|
||||||
return
|
|
||||||
|
|
||||||
if self.data is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.update_lr()
|
|
||||||
self.update_gl()
|
|
||||||
self.update_current()
|
|
||||||
|
|
||||||
self.update_idle()
|
|
||||||
|
|
||||||
def update_gl(self):
|
|
||||||
self.data.compute_guidelines()
|
|
||||||
x_complete = list(self.data.get_guidelines_x())
|
|
||||||
y_complete = list(self.data.get_guidelines_y())
|
|
||||||
|
|
||||||
# TODO comprendre à quoi sert ce bout de code
|
|
||||||
# ========>
|
|
||||||
# for i in range(self.data.number_profiles):
|
|
||||||
# if i < len(self.line_xy):
|
|
||||||
# self.line_xy[i][0].set_data(
|
|
||||||
# self.data.profile(i).x(),
|
|
||||||
# self.data.profile(i).y()
|
|
||||||
# )
|
|
||||||
# else:
|
|
||||||
# self.line_xy.append(
|
|
||||||
# self.canvas.axes.plot(
|
|
||||||
# self.data.profile(i).x(),
|
|
||||||
# self.data.profile(i).y(),
|
|
||||||
# color='r',
|
|
||||||
# **self.plot_default_kargs
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
# <========
|
|
||||||
|
|
||||||
for i in range(len(x_complete)):
|
|
||||||
if i < len(self.line_gl):
|
|
||||||
self.line_gl[i][0].set_data(
|
|
||||||
x_complete[i],
|
|
||||||
y_complete[i]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.line_gl.append(
|
|
||||||
self.canvas.axes.plot(
|
|
||||||
x_complete[i],
|
|
||||||
y_complete[i]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def update_current(self):
|
|
||||||
if self._current_data_update:
|
|
||||||
self._colors, self._style = self.color_hightlight()
|
|
||||||
self.line_xy_collection.set_colors(self._colors)
|
|
||||||
self.line_xy_collection.set_linestyle(self._style)
|
|
||||||
|
|
||||||
def update_lr(self):
|
|
||||||
for line in self.line_lr:
|
|
||||||
line[0].remove()
|
|
||||||
|
|
||||||
self.draw_lr()
|
|
||||||
@@ -54,7 +54,7 @@ from View.LateralContribution.Table import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.LateralContribution.PlotXY import PlotXY
|
from View.Geometry.PlotXY import PlotXY
|
||||||
from View.LateralContribution.translate import (
|
from View.LateralContribution.translate import (
|
||||||
LC_types, LCTranslate,
|
LC_types, LCTranslate,
|
||||||
)
|
)
|
||||||
@@ -83,7 +83,6 @@ class LateralContributionWindow(PamhyrWindow):
|
|||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
self.setup_graph()
|
self.setup_graph()
|
||||||
self.tabs = self.find(QTabWidget, "tabWidget")
|
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
@@ -149,7 +148,6 @@ class LateralContributionWindow(PamhyrWindow):
|
|||||||
data=None,
|
data=None,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
toolbar=None,
|
toolbar=None,
|
||||||
parent=self
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def setup_connections(self):
|
def setup_connections(self):
|
||||||
@@ -158,8 +156,6 @@ class LateralContributionWindow(PamhyrWindow):
|
|||||||
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
||||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||||
|
|
||||||
self.tabs.currentChanged.connect(self._set_current_reach)
|
|
||||||
|
|
||||||
for t in ["liquid", "solid", "suspenssion"]:
|
for t in ["liquid", "solid", "suspenssion"]:
|
||||||
table = self.find(QTableView, f"tableView_{t}")
|
table = self.find(QTableView, f"tableView_{t}")
|
||||||
table.selectionModel()\
|
table.selectionModel()\
|
||||||
@@ -220,7 +216,6 @@ class LateralContributionWindow(PamhyrWindow):
|
|||||||
data=data,
|
data=data,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
toolbar=None,
|
toolbar=None,
|
||||||
parent=self
|
|
||||||
)
|
)
|
||||||
self.plot.highlight = highlight
|
self.plot.highlight = highlight
|
||||||
self.plot.update()
|
self.plot.update()
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ class LCTranslate(MainTranslate):
|
|||||||
super(LCTranslate, self).__init__()
|
super(LCTranslate, self).__init__()
|
||||||
|
|
||||||
self._dict["Lateral contribution"] = _translate(
|
self._dict["Lateral contribution"] = _translate(
|
||||||
"LateralContribution", "Lateral sources"
|
"LateralContribution", "Lateral contribution"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._sub_dict["long_types"] = {
|
self._sub_dict["long_types"] = {
|
||||||
"ND": self._dict["not_defined"],
|
"ND": self._dict["not_defined"],
|
||||||
"LC": _translate("LateralContribution", "Lateral sources"),
|
"LC": _translate("LateralContribution", "Lateral contribution"),
|
||||||
"RA": _translate("LateralContribution", "Rain"),
|
"RA": _translate("LateralContribution", "Rain"),
|
||||||
"EV": _translate("LateralContribution", "Evaporation"),
|
"EV": _translate("LateralContribution", "Evaporation"),
|
||||||
}
|
}
|
||||||
@@ -57,6 +57,6 @@ class LCTranslate(MainTranslate):
|
|||||||
"name": self._dict["name"],
|
"name": self._dict["name"],
|
||||||
"type": self._dict["type"],
|
"type": self._dict["type"],
|
||||||
"edge": self._dict["reach"],
|
"edge": self._dict["reach"],
|
||||||
"begin_kp": _translate("LateralContribution", "Start (m)"),
|
"begin_kp": _translate("LateralContribution", "Begin kp (m)"),
|
||||||
"end_kp": _translate("LateralContribution", "End (m)")
|
"end_kp": _translate("LateralContribution", "End kp (m)")
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,8 @@ from datetime import date, time, datetime, timedelta
|
|||||||
from tools import (
|
from tools import (
|
||||||
trace, timer,
|
trace, timer,
|
||||||
timestamp_to_old_pamhyr_date,
|
timestamp_to_old_pamhyr_date,
|
||||||
old_pamhyr_date_to_timestamp
|
old_pamhyr_date_to_timestamp,
|
||||||
|
timestamp_to_old_pamhyr_date_adists
|
||||||
)
|
)
|
||||||
|
|
||||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||||
@@ -69,7 +70,7 @@ class TableModel(PamhyrTableModel):
|
|||||||
value = f"{v:.4f}"
|
value = f"{v:.4f}"
|
||||||
elif self._data.header[column] == "time":
|
elif self._data.header[column] == "time":
|
||||||
if self._opt_data == "time":
|
if self._opt_data == "time":
|
||||||
value = timestamp_to_old_pamhyr_date(int(v))
|
value = timestamp_to_old_pamhyr_date_adists(int(v))
|
||||||
else:
|
else:
|
||||||
value = str(datetime.fromtimestamp(v))
|
value = str(datetime.fromtimestamp(v))
|
||||||
else:
|
else:
|
||||||
|
|||||||
+115
-36
@@ -24,6 +24,8 @@ import subprocess
|
|||||||
from queue import Queue
|
from queue import Queue
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from platformdirs import user_cache_dir
|
from platformdirs import user_cache_dir
|
||||||
|
|
||||||
|
from Solver.AdisTS import AdisTS
|
||||||
from tools import logger_exception
|
from tools import logger_exception
|
||||||
|
|
||||||
from PyQt5 import QtGui
|
from PyQt5 import QtGui
|
||||||
@@ -71,8 +73,11 @@ from View.AdditionalFiles.Window import AddFileListWindow
|
|||||||
from View.REPLines.Window import REPLineListWindow
|
from View.REPLines.Window import REPLineListWindow
|
||||||
from View.SolverParameters.Window import SolverParametersWindow
|
from View.SolverParameters.Window import SolverParametersWindow
|
||||||
from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
||||||
|
from View.RunSolver.WindowAdisTS import SelectSolverWindowAdisTS, SolverLogWindowAdisTS
|
||||||
from View.CheckList.Window import CheckListWindow
|
from View.CheckList.Window import CheckListWindow
|
||||||
|
from View.CheckList.WindowAdisTS import CheckListWindowAdisTS
|
||||||
from View.Results.Window import ResultsWindow
|
from View.Results.Window import ResultsWindow
|
||||||
|
from View.Results.WindowAdisTS import ResultsWindowAdisTS
|
||||||
from View.Results.ReadingResultsDialog import ReadingResultsDialog
|
from View.Results.ReadingResultsDialog import ReadingResultsDialog
|
||||||
from View.Debug.Window import ReplWindow
|
from View.Debug.Window import ReplWindow
|
||||||
from View.OutputKpAdisTS.Window import OutputKpAdisTSWindow
|
from View.OutputKpAdisTS.Window import OutputKpAdisTSWindow
|
||||||
@@ -241,7 +246,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
"action_menu_dif": self.open_dif,
|
"action_menu_dif": self.open_dif,
|
||||||
"action_menu_d90": self.open_d90,
|
"action_menu_d90": self.open_d90,
|
||||||
"action_menu_pollutants": self.open_pollutants,
|
"action_menu_pollutants": self.open_pollutants,
|
||||||
"action_menu_run_adists":self.run_solver_adists,
|
"action_menu_run_adists":self.select_run_solver_adists,
|
||||||
"action_menu_output_kp": self.open_output_kp_adists,
|
"action_menu_output_kp": self.open_output_kp_adists,
|
||||||
"action_menu_config": self.open_configure,
|
"action_menu_config": self.open_configure,
|
||||||
"action_menu_new": self.open_new_study,
|
"action_menu_new": self.open_new_study,
|
||||||
@@ -459,7 +464,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
if Modules.CONFIG in keys:
|
if Modules.CONFIG in keys:
|
||||||
self._do_update_config()
|
self._do_update_config()
|
||||||
|
|
||||||
self._do_propagate_update_info_tab(keys)
|
if Modules.STUDY in keys:
|
||||||
|
self._tab_widget_info.update()
|
||||||
|
|
||||||
logger.debug(f"Propagation of {keys}")
|
logger.debug(f"Propagation of {keys}")
|
||||||
for _, window in self.sub_win_list:
|
for _, window in self.sub_win_list:
|
||||||
@@ -468,18 +474,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
|
|
||||||
self._tab_widget_checker.update(modules=keys)
|
self._tab_widget_checker.update(modules=keys)
|
||||||
|
|
||||||
def _do_propagate_update_info_tab(self, keys):
|
|
||||||
modules = Modules.modelling_list()
|
|
||||||
modules.append(Modules.STUDY)
|
|
||||||
|
|
||||||
has_info_mod = reduce(
|
|
||||||
lambda acc, m: acc or (m in keys),
|
|
||||||
modules, False
|
|
||||||
)
|
|
||||||
|
|
||||||
if has_info_mod:
|
|
||||||
self._tab_widget_info.update()
|
|
||||||
|
|
||||||
def _do_propagate_update_rec(self, window, keys):
|
def _do_propagate_update_rec(self, window, keys):
|
||||||
for _, win in window.sub_win_list:
|
for _, win in window.sub_win_list:
|
||||||
win._propagated_update(key=keys)
|
win._propagated_update(key=keys)
|
||||||
@@ -590,13 +584,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
if self._study.filename is None or self._study.filename == "":
|
if self._study.filename is None or self._study.filename == "":
|
||||||
options = QFileDialog.Options()
|
|
||||||
options |= QFileDialog.DontUseNativeDialog
|
|
||||||
|
|
||||||
file_name, _ = QFileDialog.getSaveFileName(
|
file_name, _ = QFileDialog.getSaveFileName(
|
||||||
self, "Save File",
|
self, "Save File",
|
||||||
"", "Pamhyr(*.pamhyr)",
|
"", "Pamhyr(*.pamhyr)"
|
||||||
options=options,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if file_name.rsplit(".", 1)[-1] == "pamhyr":
|
if file_name.rsplit(".", 1)[-1] == "pamhyr":
|
||||||
@@ -645,13 +635,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
Returns:
|
Returns:
|
||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
options = QFileDialog.Options()
|
|
||||||
options |= QFileDialog.DontUseNativeDialog
|
|
||||||
|
|
||||||
file_name, _ = QFileDialog.getSaveFileName(
|
file_name, _ = QFileDialog.getSaveFileName(
|
||||||
self, "Save File",
|
self, "Save File",
|
||||||
"", "Pamhyr(*.pamhyr)",
|
"", "Pamhyr(*.pamhyr)"
|
||||||
options=options,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.debug(f"Save study as : {repr(file_name)}")
|
logger.debug(f"Save study as : {repr(file_name)}")
|
||||||
@@ -995,10 +981,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
if self._study is None:
|
if self._study is None:
|
||||||
options = QFileDialog.Options()
|
dialog = QFileDialog(self)
|
||||||
options |= QFileDialog.DontUseNativeDialog
|
|
||||||
|
|
||||||
dialog = QFileDialog(self, options=options)
|
|
||||||
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
|
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||||
dialog.setDefaultSuffix(".pamhyr")
|
dialog.setDefaultSuffix(".pamhyr")
|
||||||
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
||||||
@@ -1279,13 +1262,46 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
if run.exec():
|
if run.exec():
|
||||||
self.run_solver(run.solver)
|
self.run_solver(run.solver)
|
||||||
|
|
||||||
def run_solver_adists(self):
|
def select_run_solver_adists(self):
|
||||||
if self._study is None:
|
if self._study is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
#solver = next(filter(lambda x: x._type == "adistslc", self.conf.solvers))
|
#solver = next(filter(lambda x: x._type == "adistslc", self.conf.solvers))
|
||||||
solver = next(filter(lambda x: x.name == "AdisTS-LC", self.conf.solvers))
|
#solver = next(filter(lambda x: x.name == "AdisTS-LC", self.conf.solvers))
|
||||||
self.run_solver(solver)
|
#print(solver._type)
|
||||||
|
#self.run_solver(solver)
|
||||||
|
|
||||||
|
run = SelectSolverWindowAdisTS(
|
||||||
|
study=self._study,
|
||||||
|
config=self.conf,
|
||||||
|
parent=self
|
||||||
|
)
|
||||||
|
if run.exec():
|
||||||
|
self.run_solver_adists(run.solver, run.mage_rep)
|
||||||
|
|
||||||
|
def run_solver_adists(self, solver, mage_rep):
|
||||||
|
if self._study is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.sub_window_exists(
|
||||||
|
CheckListWindowAdisTS,
|
||||||
|
data=[
|
||||||
|
self._study,
|
||||||
|
self.conf,
|
||||||
|
solver,
|
||||||
|
mage_rep
|
||||||
|
]
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
check = CheckListWindowAdisTS(
|
||||||
|
study=self._study,
|
||||||
|
config=self.conf,
|
||||||
|
solver=solver,
|
||||||
|
parent=self,
|
||||||
|
mage_rep=mage_rep,
|
||||||
|
)
|
||||||
|
check.show()
|
||||||
|
|
||||||
def run_solver(self, solver):
|
def run_solver(self, solver):
|
||||||
if self._study is None:
|
if self._study is None:
|
||||||
@@ -1309,6 +1325,16 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
)
|
)
|
||||||
check.show()
|
check.show()
|
||||||
|
|
||||||
|
def solver_log_adists(self, solver, mage_rep):
|
||||||
|
sol = SolverLogWindowAdisTS(
|
||||||
|
study=self._study,
|
||||||
|
config=self.conf,
|
||||||
|
solver=solver,
|
||||||
|
parent=self,
|
||||||
|
mage_rep=mage_rep,
|
||||||
|
)
|
||||||
|
sol.show()
|
||||||
|
|
||||||
def solver_log(self, solver):
|
def solver_log(self, solver):
|
||||||
sol = SolverLogWindow(
|
sol = SolverLogWindow(
|
||||||
study=self._study,
|
study=self._study,
|
||||||
@@ -1375,6 +1401,63 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
)
|
)
|
||||||
res.show()
|
res.show()
|
||||||
|
|
||||||
|
def open_solver_results_adists(self, solver, results=None):
|
||||||
|
def reading_fn():
|
||||||
|
self._tmp_results = results
|
||||||
|
|
||||||
|
# If no specific results, get last results
|
||||||
|
if results is None:
|
||||||
|
def reading_fn():
|
||||||
|
self._tmp_results = self._last_results
|
||||||
|
|
||||||
|
if self._last_results is None:
|
||||||
|
def reading_fn():
|
||||||
|
self._tmp_results = solver.results(
|
||||||
|
self._study,
|
||||||
|
self._solver_workdir(solver),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Open from file
|
||||||
|
if type(results) is str:
|
||||||
|
logger.info(f"Open results from {os.path.dirname(results)}")
|
||||||
|
|
||||||
|
name = os.path.basename(results).replace(".BIN", "")
|
||||||
|
|
||||||
|
def reading_fn():
|
||||||
|
self._tmp_results = solver.results(
|
||||||
|
self._study,
|
||||||
|
os.path.dirname(results),
|
||||||
|
name=name
|
||||||
|
)
|
||||||
|
|
||||||
|
dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
|
||||||
|
dlg.exec_()
|
||||||
|
results = self._tmp_results
|
||||||
|
|
||||||
|
# No results available
|
||||||
|
if results is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Windows already opened
|
||||||
|
if self.sub_window_exists(
|
||||||
|
ResultsWindowAdisTS,
|
||||||
|
data=[
|
||||||
|
self._study,
|
||||||
|
None, # No config
|
||||||
|
solver,
|
||||||
|
results
|
||||||
|
]
|
||||||
|
):
|
||||||
|
return
|
||||||
|
|
||||||
|
res = ResultsWindowAdisTS(
|
||||||
|
study=self._study,
|
||||||
|
solver=solver,
|
||||||
|
results=results,
|
||||||
|
parent=self
|
||||||
|
)
|
||||||
|
res.show()
|
||||||
|
|
||||||
def _solver_workdir(self, solver):
|
def _solver_workdir(self, solver):
|
||||||
workdir = os.path.join(
|
workdir = os.path.join(
|
||||||
os.path.dirname(self._study.filename),
|
os.path.dirname(self._study.filename),
|
||||||
@@ -1398,11 +1481,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||||||
if self._study.filename == "":
|
if self._study.filename == "":
|
||||||
return
|
return
|
||||||
|
|
||||||
options = QFileDialog.Options()
|
dialog = QFileDialog(self)
|
||||||
options |= QFileDialog.DontUseNativeDialog
|
|
||||||
|
|
||||||
dialog = QFileDialog(self, options=options)
|
|
||||||
|
|
||||||
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
|
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||||
dialog.setDefaultSuffix(".BIN")
|
dialog.setDefaultSuffix(".BIN")
|
||||||
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
||||||
|
|||||||
@@ -54,12 +54,10 @@ class NetworkTranslate(MainTranslate):
|
|||||||
self._sub_dict["table_headers_node"] = {
|
self._sub_dict["table_headers_node"] = {
|
||||||
"name": self._dict['name'],
|
"name": self._dict['name'],
|
||||||
"type": self._dict['type'],
|
"type": self._dict['type'],
|
||||||
# "id": _translate("Network", "Index"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self._sub_dict["table_headers_edge"] = {
|
self._sub_dict["table_headers_edge"] = {
|
||||||
"name": self._dict['name'],
|
"name": self._dict['name'],
|
||||||
"node1": _translate("Network", "Source node"),
|
"node1": _translate("Network", "Source node"),
|
||||||
"node2": _translate("Network", "Destination node"),
|
"node2": _translate("Network", "Destination node"),
|
||||||
# "id": _translate("Network", "Index"),
|
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ class CustomPlotTranslate(ResultsTranslate):
|
|||||||
super(CustomPlotTranslate, self).__init__()
|
super(CustomPlotTranslate, self).__init__()
|
||||||
|
|
||||||
self._dict["Custom Plot Selection"] = _translate(
|
self._dict["Custom Plot Selection"] = _translate(
|
||||||
"CustomPlot", "Custom plot selection"
|
"CustomPlot", "Custom Plot Selection"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Value type
|
# Value type
|
||||||
@@ -38,13 +38,13 @@ class CustomPlotTranslate(ResultsTranslate):
|
|||||||
self._dict['water_elevation'] = self._dict["unit_water_elevation"]
|
self._dict['water_elevation'] = self._dict["unit_water_elevation"]
|
||||||
self._dict['discharge'] = self._dict["unit_discharge"]
|
self._dict['discharge'] = self._dict["unit_discharge"]
|
||||||
self._dict['elevation'] = _translate(
|
self._dict['elevation'] = _translate(
|
||||||
"CustomPlot", "Bed elevation (m)"
|
"CustomPlot", "Bed load elevation (m)"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Unit corresponding long name (plot axes display)
|
# Unit corresponding long name (plot axes display)
|
||||||
|
|
||||||
self._dict['0-meter'] = _translate(
|
self._dict['0-meter'] = _translate(
|
||||||
"CustomPlot", "Bed elevation (m)"
|
"CustomPlot", "Bed load elevation (m)"
|
||||||
)
|
)
|
||||||
self._dict['1-m3s'] = self._dict["unit_discharge"]
|
self._dict['1-m3s'] = self._dict["unit_discharge"]
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
# PlotCAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from functools import reduce
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
QCoreApplication
|
||||||
|
)
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class PlotC(PamhyrPlot):
|
||||||
|
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||||
|
results=None, reach_id=0, profile_id=0, pol_id=0,
|
||||||
|
parent=None):
|
||||||
|
super(PlotC, self).__init__(
|
||||||
|
canvas=canvas,
|
||||||
|
trad=trad,
|
||||||
|
data=results,
|
||||||
|
toolbar=toolbar,
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self._mode = "time"
|
||||||
|
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self._current_pol_id = pol_id
|
||||||
|
|
||||||
|
self.label_x = _translate("Results", "Time (s)")
|
||||||
|
self.label_y = _translate("Results", "Discharge (m³/s)")
|
||||||
|
|
||||||
|
self.label_discharge = _translate("Results", "Cross-section discharge")
|
||||||
|
self.label_discharge_max = _translate("Results", "Max discharge")
|
||||||
|
self.label_timestamp = _translate("Results", "Current timestamp")
|
||||||
|
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = False
|
||||||
|
self._autoscale_update = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def results(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@results.setter
|
||||||
|
def results(self, results):
|
||||||
|
self.data = results
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def draw(self, highlight=None):
|
||||||
|
self.init_axes()
|
||||||
|
|
||||||
|
if self.results is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
if reach.geometry.number_profiles == 0:
|
||||||
|
self._init = False
|
||||||
|
return
|
||||||
|
|
||||||
|
self.draw_data(reach, profile, pollutant)
|
||||||
|
|
||||||
|
self.set_ticks_time_formater()
|
||||||
|
|
||||||
|
self.enable_legend()
|
||||||
|
|
||||||
|
self.idle()
|
||||||
|
self._init = True
|
||||||
|
|
||||||
|
def draw_data(self, reach, profile, pollutant):
|
||||||
|
self.ts = list(self.results.get("timestamps"))
|
||||||
|
self.ts.sort()
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
#First 0 for pol and second 0 for phys var
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
|
||||||
|
|
||||||
|
###print("************//////////////////")
|
||||||
|
###print("profile: ", self._current_profile_id)
|
||||||
|
###print("reach: ", self._current_reach_id)
|
||||||
|
###print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
###print("*****************draw data: ", len(x),len(y))
|
||||||
|
###print("x: ", x)
|
||||||
|
###print("y: ", y)
|
||||||
|
###print("reach: ", reach)
|
||||||
|
###print("profile: ", profile)
|
||||||
|
###print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
self._line, = self.canvas.axes.plot(
|
||||||
|
x, y,
|
||||||
|
label=self.label_discharge,
|
||||||
|
color=self.color_plot,
|
||||||
|
**self.plot_default_kargs
|
||||||
|
)
|
||||||
|
|
||||||
|
def set_reach(self, reach_id):
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = 0
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
def set_profile(self, profile_id):
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def set_pollutant(self, pol_id):
|
||||||
|
self._current_pol_id = pol_id
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def set_timestamp(self, timestamp):
|
||||||
|
self._current_timestamp = timestamp
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if not self._init:
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
self.update_data()
|
||||||
|
|
||||||
|
self.update_idle()
|
||||||
|
|
||||||
|
def update_data(self):
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
|
||||||
|
|
||||||
|
self._line.set_data(x, y)
|
||||||
@@ -109,10 +109,7 @@ class PlotKPC(PamhyrPlot):
|
|||||||
def draw_profiles_hs(self, reach):
|
def draw_profiles_hs(self, reach):
|
||||||
lhs = filter(
|
lhs = filter(
|
||||||
lambda hs: hs._input_reach.reach is reach.geometry,
|
lambda hs: hs._input_reach.reach is reach.geometry,
|
||||||
filter(
|
self.results.study.river.hydraulic_structures.lst
|
||||||
lambda hs: hs._input_reach is not None,
|
|
||||||
self.results.study.river.hydraulic_structures.lst
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for hs in lhs:
|
for hs in lhs:
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
# PlotMAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from functools import reduce
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
QCoreApplication
|
||||||
|
)
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class PlotM(PamhyrPlot):
|
||||||
|
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||||
|
results=None, reach_id=0, profile_id=0, pol_id=0,
|
||||||
|
parent=None):
|
||||||
|
super(PlotM, self).__init__(
|
||||||
|
canvas=canvas,
|
||||||
|
trad=trad,
|
||||||
|
data=results,
|
||||||
|
toolbar=toolbar,
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self._mode = "time"
|
||||||
|
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self._current_pol_id = pol_id
|
||||||
|
|
||||||
|
self.label_x = _translate("Results", "Time (s)")
|
||||||
|
self.label_y = _translate("Results", "Discharge (m³/s)")
|
||||||
|
|
||||||
|
self.label_discharge = _translate("Results", "Cross-section discharge")
|
||||||
|
self.label_discharge_max = _translate("Results", "Max discharge")
|
||||||
|
self.label_timestamp = _translate("Results", "Current timestamp")
|
||||||
|
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = False
|
||||||
|
self._autoscale_update = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def results(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@results.setter
|
||||||
|
def results(self, results):
|
||||||
|
self.data = results
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def draw(self, highlight=None):
|
||||||
|
self.init_axes()
|
||||||
|
|
||||||
|
if self.results is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
if reach.geometry.number_profiles == 0:
|
||||||
|
self._init = False
|
||||||
|
return
|
||||||
|
|
||||||
|
self.draw_data(reach, profile, pollutant)
|
||||||
|
|
||||||
|
self.set_ticks_time_formater()
|
||||||
|
|
||||||
|
self.enable_legend()
|
||||||
|
|
||||||
|
self.idle()
|
||||||
|
self._init = True
|
||||||
|
|
||||||
|
def draw_data(self, reach, profile, pollutant):
|
||||||
|
self.ts = list(self.results.get("timestamps"))
|
||||||
|
self.ts.sort()
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
#First 0 for pol and second 0 for phys var
|
||||||
|
y1 = list(map(lambda data_el: data_el[pollutant][1], profile.get_key("pols")))
|
||||||
|
y2 = list(map(lambda data_el: data_el[pollutant][2], profile.get_key("pols")))
|
||||||
|
y3 = list(map(lambda data_el: data_el[pollutant][3], profile.get_key("pols")))
|
||||||
|
|
||||||
|
y = (np.array(y1) + np.array(y2) + np.array(y3)).tolist()
|
||||||
|
|
||||||
|
###print("************//////////////////")
|
||||||
|
###print("profile: ", self._current_profile_id)
|
||||||
|
###print("reach: ", self._current_reach_id)
|
||||||
|
###print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
###print("*****************draw data: ", len(x),len(y))
|
||||||
|
###print("x: ", x)
|
||||||
|
###print("y: ", y)
|
||||||
|
###print("reach: ", reach)
|
||||||
|
###print("profile: ", profile)
|
||||||
|
###print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
self._line, = self.canvas.axes.plot(
|
||||||
|
x, y,
|
||||||
|
label=self.label_discharge,
|
||||||
|
color=self.color_plot,
|
||||||
|
**self.plot_default_kargs
|
||||||
|
)
|
||||||
|
|
||||||
|
def set_reach(self, reach_id):
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = 0
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
def set_profile(self, profile_id):
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def set_pollutant(self, pol_id):
|
||||||
|
self._current_pol_id = pol_id
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def set_timestamp(self, timestamp):
|
||||||
|
self._current_timestamp = timestamp
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if not self._init:
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
self.update_data()
|
||||||
|
|
||||||
|
self.update_idle()
|
||||||
|
|
||||||
|
def update_data(self):
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
|
||||||
|
y1 = list(map(lambda data_el: data_el[pollutant][1], profile.get_key("pols")))
|
||||||
|
y2 = list(map(lambda data_el: data_el[pollutant][2], profile.get_key("pols")))
|
||||||
|
y3 = list(map(lambda data_el: data_el[pollutant][3], profile.get_key("pols")))
|
||||||
|
|
||||||
|
y = (np.array(y1) + np.array(y2) + np.array(y3)).tolist()
|
||||||
|
|
||||||
|
self._line.set_data(x, y)
|
||||||
@@ -231,7 +231,7 @@ class PlotSedReach(PamhyrPlot):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.canvas.axes.set_xlabel(
|
self.canvas.axes.set_xlabel(
|
||||||
_translate("MainWindow_reach", "Position (m)"),
|
_translate("MainWindow_reach", "Kp (m)"),
|
||||||
color='black', fontsize=10
|
color='black', fontsize=10
|
||||||
)
|
)
|
||||||
self.canvas.axes.set_ylabel(
|
self.canvas.axes.set_ylabel(
|
||||||
|
|||||||
@@ -0,0 +1,160 @@
|
|||||||
|
# PlotTotSedCAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from functools import reduce
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
QCoreApplication
|
||||||
|
)
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class PlotTotSedC(PamhyrPlot):
|
||||||
|
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||||
|
results=None, reach_id=0, profile_id=0, pol_id=0,
|
||||||
|
parent=None):
|
||||||
|
super(PlotTotSedC, self).__init__(
|
||||||
|
canvas=canvas,
|
||||||
|
trad=trad,
|
||||||
|
data=results,
|
||||||
|
toolbar=toolbar,
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self._mode = "time"
|
||||||
|
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self._current_pol_id = pol_id
|
||||||
|
|
||||||
|
self.label_x = _translate("Results", "Time (s)")
|
||||||
|
self.label_y = _translate("Results", "Discharge (m³/s)")
|
||||||
|
|
||||||
|
self.label_discharge = _translate("Results", "Cross-section discharge")
|
||||||
|
self.label_discharge_max = _translate("Results", "Max discharge")
|
||||||
|
self.label_timestamp = _translate("Results", "Current timestamp")
|
||||||
|
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = False
|
||||||
|
self._autoscale_update = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def results(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@results.setter
|
||||||
|
def results(self, results):
|
||||||
|
self.data = results
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def draw(self, highlight=None):
|
||||||
|
self.init_axes()
|
||||||
|
|
||||||
|
if self.results is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
if reach.geometry.number_profiles == 0:
|
||||||
|
self._init = False
|
||||||
|
return
|
||||||
|
|
||||||
|
self.draw_data(reach, profile, pollutant)
|
||||||
|
|
||||||
|
self.set_ticks_time_formater()
|
||||||
|
|
||||||
|
self.enable_legend()
|
||||||
|
|
||||||
|
self.idle()
|
||||||
|
self._init = True
|
||||||
|
|
||||||
|
def draw_data(self, reach, profile, pollutant):
|
||||||
|
self.ts = list(self.results.get("timestamps"))
|
||||||
|
self.ts.sort()
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
#First 0 for pol and second 0 for phys var
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
|
||||||
|
|
||||||
|
print("Total Sed C************//////////////////")
|
||||||
|
print("profile: ", self._current_profile_id)
|
||||||
|
print("reach: ", self._current_reach_id)
|
||||||
|
print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
###print("*****************draw data: ", len(x),len(y))
|
||||||
|
###print("x: ", x)
|
||||||
|
###print("y: ", y)
|
||||||
|
###print("reach: ", reach)
|
||||||
|
###print("profile: ", profile)
|
||||||
|
###print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
self._line, = self.canvas.axes.plot(
|
||||||
|
x, y,
|
||||||
|
label=self.label_discharge,
|
||||||
|
color=self.color_plot,
|
||||||
|
**self.plot_default_kargs
|
||||||
|
)
|
||||||
|
|
||||||
|
def set_reach(self, reach_id):
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = 0
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
def set_profile(self, profile_id):
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def set_timestamp(self, timestamp):
|
||||||
|
self._current_timestamp = timestamp
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if not self._init:
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
self.update_data()
|
||||||
|
|
||||||
|
self.update_idle()
|
||||||
|
|
||||||
|
def update_data(self):
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][0], profile.get_key("pols")))
|
||||||
|
|
||||||
|
self._line.set_data(x, y)
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
# PlotTotSedEDAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from functools import reduce
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
QCoreApplication
|
||||||
|
)
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class PlotTotSedED(PamhyrPlot):
|
||||||
|
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||||
|
results=None, reach_id=0, profile_id=0, pol_id=0,
|
||||||
|
parent=None):
|
||||||
|
super(PlotTotSedED, self).__init__(
|
||||||
|
canvas=canvas,
|
||||||
|
trad=trad,
|
||||||
|
data=results,
|
||||||
|
toolbar=toolbar,
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self._mode = "time"
|
||||||
|
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self._current_pol_id = pol_id
|
||||||
|
|
||||||
|
self.label_x = _translate("Results", "Time (s)")
|
||||||
|
self.label_y = _translate("Results", "Discharge (m³/s)")
|
||||||
|
|
||||||
|
self.label_discharge = _translate("Results", "Cross-section discharge")
|
||||||
|
self.label_discharge_max = _translate("Results", "Max discharge")
|
||||||
|
self.label_timestamp = _translate("Results", "Current timestamp")
|
||||||
|
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = False
|
||||||
|
self._autoscale_update = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def results(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@results.setter
|
||||||
|
def results(self, results):
|
||||||
|
self.data = results
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def draw(self, highlight=None):
|
||||||
|
self.init_axes()
|
||||||
|
|
||||||
|
if self.results is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
if reach.geometry.number_profiles == 0:
|
||||||
|
self._init = False
|
||||||
|
return
|
||||||
|
|
||||||
|
self.draw_data(reach, profile, pollutant)
|
||||||
|
|
||||||
|
self.set_ticks_time_formater()
|
||||||
|
|
||||||
|
self.enable_legend()
|
||||||
|
|
||||||
|
self.idle()
|
||||||
|
self._init = True
|
||||||
|
|
||||||
|
def draw_data(self, reach, profile, pollutant):
|
||||||
|
self.ts = list(self.results.get("timestamps"))
|
||||||
|
self.ts.sort()
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
#First 0 for pol and second 0 for phys var
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][3], profile.get_key("pols")))
|
||||||
|
|
||||||
|
print("Total Sed ED ************//////////////////")
|
||||||
|
print("profile: ", self._current_profile_id)
|
||||||
|
print("reach: ", self._current_reach_id)
|
||||||
|
print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
###print("*****************draw data: ", len(x),len(y))
|
||||||
|
###print("x: ", x)
|
||||||
|
###print("y: ", y)
|
||||||
|
###print("reach: ", reach)
|
||||||
|
###print("profile: ", profile)
|
||||||
|
###print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
self._line, = self.canvas.axes.plot(
|
||||||
|
x, y,
|
||||||
|
label=self.label_discharge,
|
||||||
|
color=self.color_plot,
|
||||||
|
**self.plot_default_kargs
|
||||||
|
)
|
||||||
|
|
||||||
|
def set_reach(self, reach_id):
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = 0
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
def set_profile(self, profile_id):
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def set_timestamp(self, timestamp):
|
||||||
|
self._current_timestamp = timestamp
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if not self._init:
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
self.update_data()
|
||||||
|
|
||||||
|
self.update_idle()
|
||||||
|
|
||||||
|
def update_data(self):
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][3], profile.get_key("pols")))
|
||||||
|
|
||||||
|
self._line.set_data(x, y)
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
# PlotTotSedEGAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from functools import reduce
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
QCoreApplication
|
||||||
|
)
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class PlotTotSedEG(PamhyrPlot):
|
||||||
|
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||||
|
results=None, reach_id=0, profile_id=0, pol_id=0,
|
||||||
|
parent=None):
|
||||||
|
super(PlotTotSedEG, self).__init__(
|
||||||
|
canvas=canvas,
|
||||||
|
trad=trad,
|
||||||
|
data=results,
|
||||||
|
toolbar=toolbar,
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self._mode = "time"
|
||||||
|
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self._current_pol_id = pol_id
|
||||||
|
|
||||||
|
self.label_x = _translate("Results", "Time (s)")
|
||||||
|
self.label_y = _translate("Results", "Discharge (m³/s)")
|
||||||
|
|
||||||
|
self.label_discharge = _translate("Results", "Cross-section discharge")
|
||||||
|
self.label_discharge_max = _translate("Results", "Max discharge")
|
||||||
|
self.label_timestamp = _translate("Results", "Current timestamp")
|
||||||
|
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = False
|
||||||
|
self._autoscale_update = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def results(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@results.setter
|
||||||
|
def results(self, results):
|
||||||
|
self.data = results
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def draw(self, highlight=None):
|
||||||
|
self.init_axes()
|
||||||
|
|
||||||
|
if self.results is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
if reach.geometry.number_profiles == 0:
|
||||||
|
self._init = False
|
||||||
|
return
|
||||||
|
|
||||||
|
self.draw_data(reach, profile, pollutant)
|
||||||
|
|
||||||
|
self.set_ticks_time_formater()
|
||||||
|
|
||||||
|
self.enable_legend()
|
||||||
|
|
||||||
|
self.idle()
|
||||||
|
self._init = True
|
||||||
|
|
||||||
|
def draw_data(self, reach, profile, pollutant):
|
||||||
|
self.ts = list(self.results.get("timestamps"))
|
||||||
|
self.ts.sort()
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
#First 0 for pol and second 0 for phys var
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][1], profile.get_key("pols")))
|
||||||
|
|
||||||
|
print("Total Sed EG ************//////////////////")
|
||||||
|
print("profile: ", self._current_profile_id)
|
||||||
|
print("reach: ", self._current_reach_id)
|
||||||
|
print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
###print("*****************draw data: ", len(x),len(y))
|
||||||
|
###print("x: ", x)
|
||||||
|
###print("y: ", y)
|
||||||
|
###print("reach: ", reach)
|
||||||
|
###print("profile: ", profile)
|
||||||
|
###print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
self._line, = self.canvas.axes.plot(
|
||||||
|
x, y,
|
||||||
|
label=self.label_discharge,
|
||||||
|
color=self.color_plot,
|
||||||
|
**self.plot_default_kargs
|
||||||
|
)
|
||||||
|
|
||||||
|
def set_reach(self, reach_id):
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = 0
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
def set_profile(self, profile_id):
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def set_timestamp(self, timestamp):
|
||||||
|
self._current_timestamp = timestamp
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if not self._init:
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
self.update_data()
|
||||||
|
|
||||||
|
self.update_idle()
|
||||||
|
|
||||||
|
def update_data(self):
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][1], profile.get_key("pols")))
|
||||||
|
|
||||||
|
self._line.set_data(x, y)
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
# PlotTotSedEMAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from functools import reduce
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
QCoreApplication
|
||||||
|
)
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class PlotTotSedEM(PamhyrPlot):
|
||||||
|
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||||
|
results=None, reach_id=0, profile_id=0, pol_id=0,
|
||||||
|
parent=None):
|
||||||
|
super(PlotTotSedEM, self).__init__(
|
||||||
|
canvas=canvas,
|
||||||
|
trad=trad,
|
||||||
|
data=results,
|
||||||
|
toolbar=toolbar,
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self._mode = "time"
|
||||||
|
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self._current_pol_id = pol_id
|
||||||
|
|
||||||
|
self.label_x = _translate("Results", "Time (s)")
|
||||||
|
self.label_y = _translate("Results", "Discharge (m³/s)")
|
||||||
|
|
||||||
|
self.label_discharge = _translate("Results", "Cross-section discharge")
|
||||||
|
self.label_discharge_max = _translate("Results", "Max discharge")
|
||||||
|
self.label_timestamp = _translate("Results", "Current timestamp")
|
||||||
|
|
||||||
|
self._isometric_axis = False
|
||||||
|
|
||||||
|
self._auto_relim_update = False
|
||||||
|
self._autoscale_update = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def results(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@results.setter
|
||||||
|
def results(self, results):
|
||||||
|
self.data = results
|
||||||
|
self._current_timestamp = max(results.get("timestamps"))
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def draw(self, highlight=None):
|
||||||
|
self.init_axes()
|
||||||
|
|
||||||
|
if self.results is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
if reach.geometry.number_profiles == 0:
|
||||||
|
self._init = False
|
||||||
|
return
|
||||||
|
|
||||||
|
self.draw_data(reach, profile, pollutant)
|
||||||
|
|
||||||
|
self.set_ticks_time_formater()
|
||||||
|
|
||||||
|
self.enable_legend()
|
||||||
|
|
||||||
|
self.idle()
|
||||||
|
self._init = True
|
||||||
|
|
||||||
|
def draw_data(self, reach, profile, pollutant):
|
||||||
|
self.ts = list(self.results.get("timestamps"))
|
||||||
|
self.ts.sort()
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
#First 0 for pol and second 0 for phys var
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][2], profile.get_key("pols")))
|
||||||
|
|
||||||
|
print("Total Sed EM ************//////////////////")
|
||||||
|
print("profile: ", self._current_profile_id)
|
||||||
|
print("reach: ", self._current_reach_id)
|
||||||
|
print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
###print("*****************draw data: ", len(x),len(y))
|
||||||
|
###print("x: ", x)
|
||||||
|
###print("y: ", y)
|
||||||
|
###print("reach: ", reach)
|
||||||
|
###print("profile: ", profile)
|
||||||
|
###print("pollutant: ", pollutant)
|
||||||
|
|
||||||
|
self._line, = self.canvas.axes.plot(
|
||||||
|
x, y,
|
||||||
|
label=self.label_discharge,
|
||||||
|
color=self.color_plot,
|
||||||
|
**self.plot_default_kargs
|
||||||
|
)
|
||||||
|
|
||||||
|
def set_reach(self, reach_id):
|
||||||
|
self._current_reach_id = reach_id
|
||||||
|
self._current_profile_id = 0
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
def set_profile(self, profile_id):
|
||||||
|
self._current_profile_id = profile_id
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def set_timestamp(self, timestamp):
|
||||||
|
self._current_timestamp = timestamp
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if not self._init:
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
self.update_data()
|
||||||
|
|
||||||
|
self.update_idle()
|
||||||
|
|
||||||
|
def update_data(self):
|
||||||
|
reach = self.results.river.reach(self._current_reach_id)
|
||||||
|
profile = reach.profile(self._current_profile_id)
|
||||||
|
pollutant = self._current_pol_id
|
||||||
|
|
||||||
|
x = self.ts
|
||||||
|
#y = profile.get_key("Q")
|
||||||
|
y = list(map(lambda data_el: data_el[pollutant][2], profile.get_key("pols")))
|
||||||
|
|
||||||
|
self._line.set_data(x, y)
|
||||||
+13
-102
@@ -22,14 +22,10 @@ from functools import reduce
|
|||||||
|
|
||||||
from tools import timer, trace
|
from tools import timer, trace
|
||||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
import numpy as np
|
|
||||||
from matplotlib import collections
|
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
QCoreApplication, Qt, QItemSelectionModel,
|
QCoreApplication
|
||||||
QItemSelection, QItemSelectionRange
|
|
||||||
)
|
)
|
||||||
from PyQt5.QtWidgets import QApplication, QTableView
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
@@ -61,73 +57,6 @@ class PlotXY(PamhyrPlot):
|
|||||||
self.label_y = _translate("Results", "Y (m)")
|
self.label_y = _translate("Results", "Y (m)")
|
||||||
|
|
||||||
self._isometric_axis = True
|
self._isometric_axis = True
|
||||||
self._tablemodel = parent._table["profile"]
|
|
||||||
self._table = parent.find(QTableView, f"tableView_profile")
|
|
||||||
|
|
||||||
def onpick(self, event):
|
|
||||||
if event.mouseevent.inaxes != self.canvas.axes:
|
|
||||||
return
|
|
||||||
if event.mouseevent.button.value != 1:
|
|
||||||
return
|
|
||||||
|
|
||||||
modifiers = QApplication.keyboardModifiers()
|
|
||||||
if modifiers not in [Qt.ControlModifier,
|
|
||||||
Qt.NoModifier,
|
|
||||||
Qt.ShiftModifier]:
|
|
||||||
return
|
|
||||||
|
|
||||||
ind, point = self._closest_section(event)
|
|
||||||
if self._table is None:
|
|
||||||
return
|
|
||||||
self._select_in_table([ind])
|
|
||||||
self._table.blockSignals(False)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def _closest_section(self, event):
|
|
||||||
axes = self.canvas.axes
|
|
||||||
mx = event.mouseevent.xdata
|
|
||||||
my = event.mouseevent.ydata
|
|
||||||
bx, by = axes.get_xlim(), axes.get_ylim()
|
|
||||||
ratio = (bx[0] - bx[1]) / (by[0] - by[1])
|
|
||||||
|
|
||||||
segments = event.artist.get_segments()
|
|
||||||
ind = event.ind
|
|
||||||
|
|
||||||
points = []
|
|
||||||
for i in ind:
|
|
||||||
points = points + [[i, j] for j in segments[i]]
|
|
||||||
|
|
||||||
def dist_mouse(point):
|
|
||||||
x, y = point[1]
|
|
||||||
d2 = (((mx - x) / ratio) ** 2) + ((my - y) ** 2)
|
|
||||||
return d2
|
|
||||||
|
|
||||||
closest = min(
|
|
||||||
points, key=dist_mouse
|
|
||||||
)
|
|
||||||
|
|
||||||
return closest
|
|
||||||
|
|
||||||
def _select_in_table(self, ind):
|
|
||||||
if self._table is None:
|
|
||||||
return
|
|
||||||
self._table.setFocus()
|
|
||||||
selection = self._table.selectionModel()
|
|
||||||
index = QItemSelection()
|
|
||||||
if len(ind) == 0:
|
|
||||||
return
|
|
||||||
for i in ind:
|
|
||||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
|
||||||
selection.select(
|
|
||||||
index,
|
|
||||||
QItemSelectionModel.Rows |
|
|
||||||
QItemSelectionModel.ClearAndSelect |
|
|
||||||
QItemSelectionModel.Select
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(ind) > 0:
|
|
||||||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def results(self):
|
def results(self):
|
||||||
@@ -161,36 +90,18 @@ class PlotXY(PamhyrPlot):
|
|||||||
self._init = False
|
self._init = False
|
||||||
return
|
return
|
||||||
|
|
||||||
self.line_xy = []
|
self.line_xy = [
|
||||||
for xy in zip(reach.geometry.get_x(),
|
self.canvas.axes.plot(
|
||||||
reach.geometry.get_y()):
|
x, y,
|
||||||
self.line_xy.append(np.column_stack(xy))
|
color=self.color_plot_river_bottom,
|
||||||
|
**self.plot_default_kargs
|
||||||
self._colors, self._style = self.color_hightlight()
|
)
|
||||||
self.line_xy_collection = collections.LineCollection(
|
for x, y, kp in zip(
|
||||||
self.line_xy,
|
reach.geometry.get_x(),
|
||||||
colors=self._colors,
|
reach.geometry.get_y(),
|
||||||
linestyle=self._style,
|
reach.geometry.get_kp()
|
||||||
picker=10
|
)
|
||||||
)
|
]
|
||||||
self.canvas.axes.add_collection(self.line_xy_collection)
|
|
||||||
|
|
||||||
def color_hightlight(self):
|
|
||||||
reach = self.results.river.reach(self._current_reach_id)
|
|
||||||
rows = [self._current_profile_id]
|
|
||||||
colors = [self.color_plot
|
|
||||||
for row in range(reach.geometry.number_profiles)]
|
|
||||||
style = ["-" for row in range(reach.geometry.number_profiles)]
|
|
||||||
if len(rows) > 0:
|
|
||||||
for row in rows:
|
|
||||||
colors[row] = self.color_plot_current
|
|
||||||
if rows[0] > 0:
|
|
||||||
colors[rows[0]-1] = self.color_plot_previous
|
|
||||||
style[rows[0]-1] = "--"
|
|
||||||
if rows[-1] < reach.geometry.number_profiles-1:
|
|
||||||
colors[rows[-1]+1] = self.color_plot_next
|
|
||||||
style[rows[-1]+1] = "--"
|
|
||||||
return colors, style
|
|
||||||
|
|
||||||
def draw_guide_lines(self, reach):
|
def draw_guide_lines(self, reach):
|
||||||
x_complete = reach.geometry.get_guidelines_x()
|
x_complete = reach.geometry.get_guidelines_x()
|
||||||
|
|||||||
@@ -45,8 +45,12 @@ _translate = QCoreApplication.translate
|
|||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def _setup_lst(self):
|
def _setup_lst(self):
|
||||||
_river = self._data.river
|
_river = self._data.river
|
||||||
|
print("data: ", self._data)
|
||||||
|
print("river: ", _river)
|
||||||
|
print("reaches: ", _river.reachs)
|
||||||
if self._opt_data == "reach":
|
if self._opt_data == "reach":
|
||||||
self._lst = _river.reachs
|
self._lst = _river.reachs
|
||||||
|
print("optreach: ", self._lst)
|
||||||
elif self._opt_data == "profile":
|
elif self._opt_data == "profile":
|
||||||
self._lst = _river.reach(0).profiles
|
self._lst = _river.reach(0).profiles
|
||||||
elif self._opt_data == "raw_data":
|
elif self._opt_data == "raw_data":
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
# TableAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
from tools import timer, trace
|
||||||
|
|
||||||
|
from PyQt5.QtGui import (
|
||||||
|
QKeySequence, QColor
|
||||||
|
)
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
Qt, QAbstractTableModel, QModelIndex,
|
||||||
|
QVariant, pyqtSlot, QCoreApplication,
|
||||||
|
)
|
||||||
|
from PyQt5.QtWidgets import (
|
||||||
|
QMessageBox, QUndoCommand, QUndoStack,
|
||||||
|
QStyledItemDelegate, QLineEdit, QAbstractItemView,
|
||||||
|
QComboBox,
|
||||||
|
)
|
||||||
|
|
||||||
|
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||||
|
from View.Results.translate import *
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
|
class TableModel(PamhyrTableModel):
|
||||||
|
def _setup_lst(self):
|
||||||
|
_river = self._data.river
|
||||||
|
###print("//////////////////opt_data: ", self._opt_data)
|
||||||
|
###print("data: ", self._data)
|
||||||
|
###print("river: ", _river)
|
||||||
|
###print("reaches: ", _river.reachs)
|
||||||
|
if self._opt_data == "reach":
|
||||||
|
self._lst = _river.reachs
|
||||||
|
###print("optreach: ", self._lst)
|
||||||
|
elif self._opt_data == "profile":
|
||||||
|
self._lst = _river.reach(0).profiles
|
||||||
|
elif self._opt_data == "raw_data":
|
||||||
|
self._lst = _river.reach(0).profiles
|
||||||
|
elif self._opt_data == "pollutants":
|
||||||
|
tmp_list = self._data.pollutants_list.copy()
|
||||||
|
tmp_list.remove("total_sediment")
|
||||||
|
###print(type(tmp_list))
|
||||||
|
#tmp_list.insert(len(tmp_list), "total_sediment")
|
||||||
|
self._lst = tmp_list
|
||||||
|
###print("=====table pollutants: ", self._lst)
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
self._timestamp = 0.0
|
||||||
|
super(TableModel, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
def data(self, index, role=Qt.DisplayRole):
|
||||||
|
if role != Qt.ItemDataRole.DisplayRole:
|
||||||
|
return QVariant()
|
||||||
|
|
||||||
|
row = index.row()
|
||||||
|
column = index.column()
|
||||||
|
|
||||||
|
if self._opt_data == "reach":
|
||||||
|
if self._headers[column] == "name":
|
||||||
|
v = self._lst[row].name
|
||||||
|
return str(v)
|
||||||
|
elif self._opt_data == "pollutants":
|
||||||
|
if self._headers[column] == "name":
|
||||||
|
v = self._lst[row]
|
||||||
|
return str(v)
|
||||||
|
elif self._opt_data == "profile":
|
||||||
|
if self._headers[column] == "name":
|
||||||
|
v = self._lst[row].name
|
||||||
|
return str(v)
|
||||||
|
elif self._headers[column] == "kp":
|
||||||
|
v = self._lst[row].kp
|
||||||
|
return f"{v:.4f}"
|
||||||
|
elif self._opt_data == "raw_data":
|
||||||
|
p = self._lst[row]
|
||||||
|
if self._headers[column] == "name":
|
||||||
|
if p.name == "":
|
||||||
|
return f"{p.kp:.4f}"
|
||||||
|
return f"{p.name}"
|
||||||
|
tmp_list = self._data.pollutants_list.copy()
|
||||||
|
tmp_list.remove("total_sediment")
|
||||||
|
tmp_list2 = self._data.pollutants_list.copy()
|
||||||
|
print("=============================list polutants table raw: ", tmp_list)
|
||||||
|
print("=============================list polutants table raw: ", tmp_list2)
|
||||||
|
for pol in tmp_list:
|
||||||
|
pol_index = tmp_list2.index(pol)
|
||||||
|
print("=============================pol index: ", pol_index)
|
||||||
|
header_name = pol + " Concentration"
|
||||||
|
print("=============================Headers: ", self._headers[column])
|
||||||
|
print("=============================Headers: ", header_name)
|
||||||
|
if self._headers[column] == header_name:
|
||||||
|
print("=============================Headers: ", self._headers[column])
|
||||||
|
print("=============================Headers: ", header_name)
|
||||||
|
v = self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index][0]
|
||||||
|
return f"{v:.4f}"
|
||||||
|
elif self._headers[column] == pol + " Mass":
|
||||||
|
m1 = self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index][1]
|
||||||
|
m2 = self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index][2]
|
||||||
|
m3 = self._lst[row].get_ts_key(self._timestamp, "pols")[pol_index][3]
|
||||||
|
v = m1 + m2 + m3
|
||||||
|
return f"{v:.4f}"
|
||||||
|
|
||||||
|
return QVariant()
|
||||||
|
|
||||||
|
def update(self, reach):
|
||||||
|
_river = self._data.river
|
||||||
|
|
||||||
|
if self._opt_data == "reach":
|
||||||
|
self._lst = _river.reachs
|
||||||
|
elif self._opt_data == "profile" or self._opt_data == "raw_data":
|
||||||
|
self._lst = _river.reach(reach).profiles
|
||||||
|
|
||||||
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def timestamp(self):
|
||||||
|
return self._timestamp
|
||||||
|
|
||||||
|
@timestamp.setter
|
||||||
|
def timestamp(self, timestamp):
|
||||||
|
self._timestamp = timestamp
|
||||||
|
self.layoutChanged.emit()
|
||||||
@@ -176,8 +176,7 @@ class ResultsWindow(PamhyrWindow):
|
|||||||
profile_id=0,
|
profile_id=0,
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
toolbar=self.toolbar,
|
toolbar=self.toolbar,
|
||||||
display_current=True,
|
display_current=True
|
||||||
parent=self
|
|
||||||
)
|
)
|
||||||
self.plot_xy.draw()
|
self.plot_xy.draw()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,643 @@
|
|||||||
|
# WindowAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import csv
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from tools import trace, timer, logger_exception
|
||||||
|
|
||||||
|
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||||
|
|
||||||
|
from PyQt5.QtGui import (
|
||||||
|
QKeySequence, QIcon, QPixmap,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
Qt, QVariant, QAbstractTableModel,
|
||||||
|
QCoreApplication, QModelIndex, pyqtSlot,
|
||||||
|
QItemSelectionModel, QTimer,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import (
|
||||||
|
QDialogButtonBox, QPushButton, QLineEdit,
|
||||||
|
QFileDialog, QTableView, QAbstractItemView,
|
||||||
|
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||||
|
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||||
|
QSlider, QLabel, QWidget, QGridLayout,
|
||||||
|
)
|
||||||
|
|
||||||
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
|
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||||
|
|
||||||
|
from View.Results.PlotCAdisTS import PlotC
|
||||||
|
from View.Results.PlotMAdisTS import PlotM
|
||||||
|
from View.Results.PlotTotSedCAdisTS import PlotTotSedC
|
||||||
|
from View.Results.PlotTotSedEGAdisTS import PlotTotSedEG
|
||||||
|
from View.Results.PlotTotSedEMAdisTS import PlotTotSedEM
|
||||||
|
from View.Results.PlotTotSedEDAdisTS import PlotTotSedED
|
||||||
|
|
||||||
|
from View.Results.CustomPlot.Plot import CustomPlot
|
||||||
|
from View.Results.CustomPlot.CustomPlotValuesSelectionDialog import (
|
||||||
|
CustomPlotValuesSelectionDialog,
|
||||||
|
)
|
||||||
|
|
||||||
|
from View.Results.TableAdisTS import TableModel
|
||||||
|
from View.Results.translate import ResultsTranslate
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class ResultsWindowAdisTS(PamhyrWindow):
|
||||||
|
_pamhyr_ui = "ResultsAdisTS"
|
||||||
|
_pamhyr_name = "Results"
|
||||||
|
|
||||||
|
def _path_file(self, filename):
|
||||||
|
return os.path.abspath(
|
||||||
|
os.path.join(
|
||||||
|
os.path.dirname(__file__),
|
||||||
|
"..", "ui", "ressources", filename
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, study=None, config=None,
|
||||||
|
solver=None, results=None,
|
||||||
|
parent=None):
|
||||||
|
self._solver = solver
|
||||||
|
self._results = results
|
||||||
|
|
||||||
|
pollutants_headers = self._results.pollutants_list.copy()
|
||||||
|
print("***///---+++///***---+++pollutants translate: ", pollutants_headers)
|
||||||
|
|
||||||
|
trad = ResultsTranslate(pollutants_headers)
|
||||||
|
name = (
|
||||||
|
trad[self._pamhyr_name] + " - "
|
||||||
|
+ study.name + " - "
|
||||||
|
+ self._solver.name
|
||||||
|
)
|
||||||
|
|
||||||
|
super(ResultsWindowAdisTS, self).__init__(
|
||||||
|
title=name,
|
||||||
|
study=study,
|
||||||
|
config=config,
|
||||||
|
trad=trad,
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self._hash_data.append(self._solver)
|
||||||
|
self._hash_data.append(self._results)
|
||||||
|
|
||||||
|
self._additional_plot = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
#print("timestamps results: ", self._results)
|
||||||
|
self._timestamps = sorted(list(self._results.get("timestamps")))
|
||||||
|
|
||||||
|
print("setup table adists results")
|
||||||
|
|
||||||
|
self.setup_table()
|
||||||
|
self.setup_plots()
|
||||||
|
self.setup_slider()
|
||||||
|
print("///setup slider correct")
|
||||||
|
self.setup_statusbar()
|
||||||
|
print("///setup status bar correct")
|
||||||
|
self.setup_connections()
|
||||||
|
print("///setup connections correct")
|
||||||
|
except Exception as e:
|
||||||
|
logger_exception(e)
|
||||||
|
return
|
||||||
|
|
||||||
|
def setup_table(self):
|
||||||
|
print("setup table adists results")
|
||||||
|
print("results study name: ", self._results.study.name)
|
||||||
|
print("results study river: ", self._results.study.river)
|
||||||
|
print("*********files names resultats from Results Window: ", self._results.pollutants_list)
|
||||||
|
self._table = {}
|
||||||
|
for t in ["reach", "profile", "pollutants", "raw_data"]:
|
||||||
|
print("t: ", t)
|
||||||
|
table = self.find(QTableView, f"tableView_{t}")
|
||||||
|
self._table[t] = TableModel(
|
||||||
|
table_view=table,
|
||||||
|
table_headers=self._trad.get_dict(f"table_headers_{t}"),
|
||||||
|
data=self._results,
|
||||||
|
undo=self._undo_stack,
|
||||||
|
opt_data=t
|
||||||
|
)
|
||||||
|
|
||||||
|
def setup_slider(self):
|
||||||
|
self._timer = QTimer(self)
|
||||||
|
|
||||||
|
def setup_plots(self):
|
||||||
|
self.canvas_4 = MplCanvas(width=5, height=4, dpi=100)
|
||||||
|
self.canvas_4.setObjectName("canvas_4")
|
||||||
|
self.toolbar_4 = PamhyrPlotToolbar(
|
||||||
|
self.canvas_4, self, items=[
|
||||||
|
"home", "move", "zoom", "save",
|
||||||
|
"iso", "back/forward"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
self.plot_layout_4 = self.find(
|
||||||
|
QVBoxLayout, "verticalLayout_concentration")
|
||||||
|
self.plot_layout_4.addWidget(self.toolbar_4)
|
||||||
|
self.plot_layout_4.addWidget(self.canvas_4)
|
||||||
|
|
||||||
|
self.plot_c = PlotC(
|
||||||
|
canvas=self.canvas_4,
|
||||||
|
results=self._results,
|
||||||
|
reach_id=0,
|
||||||
|
profile_id=0,
|
||||||
|
pol_id=0,
|
||||||
|
trad=self._trad,
|
||||||
|
toolbar=self.toolbar_4
|
||||||
|
)
|
||||||
|
self.plot_c.draw()
|
||||||
|
|
||||||
|
print("///plot c adists correct")
|
||||||
|
|
||||||
|
self.canvas_3 = MplCanvas(width=5, height=4, dpi=100)
|
||||||
|
self.canvas_3.setObjectName("canvas_3")
|
||||||
|
self.toolbar_3 = PamhyrPlotToolbar(
|
||||||
|
self.canvas_3, self, items=[
|
||||||
|
"home", "move", "zoom", "save",
|
||||||
|
"iso", "back/forward"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
self.plot_layout_3 = self.find(
|
||||||
|
QVBoxLayout, "verticalLayout_mass")
|
||||||
|
self.plot_layout_3.addWidget(self.toolbar_3)
|
||||||
|
self.plot_layout_3.addWidget(self.canvas_3)
|
||||||
|
|
||||||
|
self.plot_m = PlotM(
|
||||||
|
canvas=self.canvas_3,
|
||||||
|
results=self._results,
|
||||||
|
reach_id=0,
|
||||||
|
profile_id=0,
|
||||||
|
pol_id=0,
|
||||||
|
trad=self._trad,
|
||||||
|
toolbar=self.toolbar_3
|
||||||
|
)
|
||||||
|
self.plot_m.draw()
|
||||||
|
|
||||||
|
print("///plot m adists correct")
|
||||||
|
|
||||||
|
self.canvas_2 = MplCanvas(width=5, height=4, dpi=100)
|
||||||
|
self.canvas_2.setObjectName("canvas_2")
|
||||||
|
self.toolbar_2 = PamhyrPlotToolbar(
|
||||||
|
self.canvas_2, self, items=[
|
||||||
|
"home", "move", "zoom", "save",
|
||||||
|
"iso", "back/forward"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
self.plot_layout_2 = self.find(
|
||||||
|
QVBoxLayout, "verticalLayout_tot_c")
|
||||||
|
self.plot_layout_2.addWidget(self.toolbar_2)
|
||||||
|
self.plot_layout_2.addWidget(self.canvas_2)
|
||||||
|
|
||||||
|
self.plot_tot_c = PlotTotSedC(
|
||||||
|
canvas=self.canvas_2,
|
||||||
|
results=self._results,
|
||||||
|
reach_id=0,
|
||||||
|
profile_id=0,
|
||||||
|
pol_id=self._results.pollutants_list.index("total_sediment"),
|
||||||
|
trad=self._trad,
|
||||||
|
toolbar=self.toolbar_2
|
||||||
|
)
|
||||||
|
|
||||||
|
self.plot_tot_c.draw()
|
||||||
|
|
||||||
|
self.canvas_1 = MplCanvas(width=5, height=4, dpi=100)
|
||||||
|
self.canvas_1.setObjectName("canvas_1")
|
||||||
|
self.toolbar_1 = PamhyrPlotToolbar(
|
||||||
|
self.canvas_1, self, items=[
|
||||||
|
"home", "move", "zoom", "save",
|
||||||
|
"iso", "back/forward"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
self.plot_layout_1 = self.find(
|
||||||
|
QVBoxLayout, "verticalLayout_tot_left_2")
|
||||||
|
self.plot_layout_1.addWidget(self.toolbar_1)
|
||||||
|
self.plot_layout_1.addWidget(self.canvas_1)
|
||||||
|
|
||||||
|
self.plot_tot_eg = PlotTotSedEG(
|
||||||
|
canvas=self.canvas_1,
|
||||||
|
results=self._results,
|
||||||
|
reach_id=0,
|
||||||
|
profile_id=0,
|
||||||
|
pol_id=self._results.pollutants_list.index("total_sediment"),
|
||||||
|
trad=self._trad,
|
||||||
|
toolbar=self.toolbar_1
|
||||||
|
)
|
||||||
|
|
||||||
|
self.plot_tot_eg.draw()
|
||||||
|
|
||||||
|
self.canvas_0 = MplCanvas(width=5, height=4, dpi=100)
|
||||||
|
self.canvas_0.setObjectName("canvas_0")
|
||||||
|
self.toolbar_0 = PamhyrPlotToolbar(
|
||||||
|
self.canvas_0, self, items=[
|
||||||
|
"home", "move", "zoom", "save",
|
||||||
|
"iso", "back/forward"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
self.plot_layout_0 = self.find(
|
||||||
|
QVBoxLayout, "verticalLayout_tot_minor")
|
||||||
|
self.plot_layout_0.addWidget(self.toolbar_0)
|
||||||
|
self.plot_layout_0.addWidget(self.canvas_0)
|
||||||
|
|
||||||
|
self.plot_tot_em = PlotTotSedEM(
|
||||||
|
canvas=self.canvas_0,
|
||||||
|
results=self._results,
|
||||||
|
reach_id=0,
|
||||||
|
profile_id=0,
|
||||||
|
pol_id=self._results.pollutants_list.index("total_sediment"),
|
||||||
|
trad=self._trad,
|
||||||
|
toolbar=self.toolbar_0
|
||||||
|
)
|
||||||
|
|
||||||
|
self.plot_tot_em.draw()
|
||||||
|
|
||||||
|
self.canvas_5 = MplCanvas(width=5, height=4, dpi=100)
|
||||||
|
self.canvas_5.setObjectName("canvas_5")
|
||||||
|
self.toolbar_5 = PamhyrPlotToolbar(
|
||||||
|
self.canvas_5, self, items=[
|
||||||
|
"home", "move", "zoom", "save",
|
||||||
|
"iso", "back/forward"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
self.plot_layout_5 = self.find(
|
||||||
|
QVBoxLayout, "verticalLayout_tot_right")
|
||||||
|
self.plot_layout_5.addWidget(self.toolbar_5)
|
||||||
|
print("///***---+++///+++add toolbar correct")
|
||||||
|
self.plot_layout_5.addWidget(self.canvas_5)
|
||||||
|
print("///***---+++///+++add canvas correct")
|
||||||
|
|
||||||
|
self.plot_tot_ed = PlotTotSedED(
|
||||||
|
canvas=self.canvas_5,
|
||||||
|
results=self._results,
|
||||||
|
reach_id=0,
|
||||||
|
profile_id=0,
|
||||||
|
pol_id=self._results.pollutants_list.index("total_sediment"),
|
||||||
|
trad=self._trad,
|
||||||
|
toolbar=self.toolbar_5
|
||||||
|
)
|
||||||
|
|
||||||
|
self.plot_tot_ed.draw()
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
try:
|
||||||
|
self._timer.stop()
|
||||||
|
except Exception as e:
|
||||||
|
logger_exception(e)
|
||||||
|
|
||||||
|
super(ResultsWindowAdisTS, self).closeEvent(event)
|
||||||
|
|
||||||
|
def _compute_status_label(self):
|
||||||
|
# Reach
|
||||||
|
table = self.find(QTableView, f"tableView_reach")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
reach = self._study.river.edges()[0]
|
||||||
|
else:
|
||||||
|
reach = self._study.river.edges()[indexes[0].row()]
|
||||||
|
|
||||||
|
# Profile
|
||||||
|
table = self.find(QTableView, f"tableView_profile")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
profile = reach.reach.profile(0)
|
||||||
|
else:
|
||||||
|
profile = reach.reach.profile(indexes[0].row())
|
||||||
|
|
||||||
|
pname = profile.name if profile.name != "" else profile.kp
|
||||||
|
|
||||||
|
# Pollutant
|
||||||
|
table = self.find(QTableView, f"tableView_pollutants")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
pollutant = self._results.pollutants_list[0]
|
||||||
|
else:
|
||||||
|
pollutant = self._results.pollutants_list[indexes[0].row()]
|
||||||
|
|
||||||
|
return (f"Reach: {reach.name} | " +
|
||||||
|
f"Profile: {pname} | " +
|
||||||
|
f"Pollutant: {pollutant}")
|
||||||
|
|
||||||
|
def setup_statusbar(self):
|
||||||
|
txt = self._compute_status_label()
|
||||||
|
self._status_label = QLabel(txt)
|
||||||
|
self.statusbar.addPermanentWidget(self._status_label)
|
||||||
|
|
||||||
|
def update_statusbar(self):
|
||||||
|
txt = self._compute_status_label()
|
||||||
|
self._status_label.setText(txt)
|
||||||
|
|
||||||
|
def setup_connections(self):
|
||||||
|
# Action
|
||||||
|
actions = {
|
||||||
|
"action_reload": self._reload,
|
||||||
|
###"action_add": self._add_custom_plot,
|
||||||
|
"action_export": self.export,
|
||||||
|
}
|
||||||
|
|
||||||
|
for action in actions:
|
||||||
|
self.find(QAction, action).triggered.connect(
|
||||||
|
actions[action]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Table and Plot
|
||||||
|
fun = {
|
||||||
|
"reach": self._set_current_reach,
|
||||||
|
"profile": self._set_current_profile,
|
||||||
|
"pollutants": self._set_current_pol,
|
||||||
|
"raw_data": self._set_current_profile_raw_data,
|
||||||
|
}
|
||||||
|
|
||||||
|
for t in ["reach", "profile", "pollutants"]:###, "raw_data"]:
|
||||||
|
table = self.find(QTableView, f"tableView_{t}")
|
||||||
|
|
||||||
|
table.selectionModel()\
|
||||||
|
.selectionChanged\
|
||||||
|
.connect(fun[t])
|
||||||
|
|
||||||
|
self._table[t].dataChanged.connect(fun[t])
|
||||||
|
|
||||||
|
self._timer.timeout.connect(self._update_slider)
|
||||||
|
|
||||||
|
def update_table_selection_reach(self, ind):
|
||||||
|
table = self.find(QTableView, f"tableView_reach")
|
||||||
|
selectionModel = table.selectionModel()
|
||||||
|
index = table.model().index(ind, 0)
|
||||||
|
|
||||||
|
selectionModel.select(
|
||||||
|
index,
|
||||||
|
QItemSelectionModel.Rows |
|
||||||
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
table.scrollTo(index)
|
||||||
|
|
||||||
|
self._table["profile"].update(ind)
|
||||||
|
###self._table["raw_data"].update(ind)
|
||||||
|
|
||||||
|
def update_table_selection_profile(self, ind):
|
||||||
|
for t in ["profile"]:###, "raw_data"]:
|
||||||
|
table = self.find(QTableView, f"tableView_{t}")
|
||||||
|
selectionModel = table.selectionModel()
|
||||||
|
index = table.model().index(ind, 0)
|
||||||
|
|
||||||
|
selectionModel.select(
|
||||||
|
index,
|
||||||
|
QItemSelectionModel.Rows |
|
||||||
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
table.scrollTo(index)
|
||||||
|
|
||||||
|
def update_table_selection_pol(self, ind):
|
||||||
|
for t in ["pollutants"]:###, "raw_data"]:
|
||||||
|
table = self.find(QTableView, f"tableView_{t}")
|
||||||
|
selectionModel = table.selectionModel()
|
||||||
|
index = table.model().index(ind, 0)
|
||||||
|
|
||||||
|
selectionModel.select(
|
||||||
|
index,
|
||||||
|
QItemSelectionModel.Rows |
|
||||||
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
table.scrollTo(index)
|
||||||
|
|
||||||
|
def update(self, reach_id=None, profile_id=None, pol_id=None, timestamp=None):
|
||||||
|
if reach_id is not None:
|
||||||
|
self.plot_c.set_reach(reach_id)
|
||||||
|
self.plot_m.set_reach(reach_id)
|
||||||
|
self.plot_tot_c.set_reach(reach_id)
|
||||||
|
self.plot_tot_eg.set_reach(reach_id)
|
||||||
|
self.plot_tot_em.set_reach(reach_id)
|
||||||
|
self.plot_tot_ed.set_reach(reach_id)
|
||||||
|
|
||||||
|
self.update_table_selection_reach(reach_id)
|
||||||
|
self.update_table_selection_profile(0)
|
||||||
|
self.update_table_selection_pol(0)
|
||||||
|
|
||||||
|
if profile_id is not None:
|
||||||
|
self.plot_c.set_profile(profile_id)
|
||||||
|
self.plot_m.set_profile(profile_id)
|
||||||
|
self.plot_tot_c.set_profile(profile_id)
|
||||||
|
self.plot_tot_eg.set_profile(profile_id)
|
||||||
|
self.plot_tot_em.set_profile(profile_id)
|
||||||
|
self.plot_tot_ed.set_profile(profile_id)
|
||||||
|
|
||||||
|
self.update_table_selection_profile(profile_id)
|
||||||
|
|
||||||
|
print("--**//++update pol_id before None: ", pol_id)
|
||||||
|
|
||||||
|
if pol_id is not None:
|
||||||
|
print("--**//++//**//** update pol_id: ", pol_id)
|
||||||
|
self.plot_c.set_pollutant(pol_id)
|
||||||
|
self.plot_m.set_pollutant(pol_id)
|
||||||
|
|
||||||
|
self.update_table_selection_pol(pol_id)
|
||||||
|
|
||||||
|
if timestamp is not None:
|
||||||
|
self.plot_c.set_timestamp(timestamp)
|
||||||
|
self.plot_m.set_timestamp(timestamp)
|
||||||
|
self.plot_tot_c.set_timestamp(timestamp)
|
||||||
|
self.plot_tot_eg.set_timestamp(timestamp)
|
||||||
|
self.plot_tot_em.set_timestamp(timestamp)
|
||||||
|
self.plot_tot_ed.set_timestamp(timestamp)
|
||||||
|
|
||||||
|
self._table["raw_data"].timestamp = timestamp
|
||||||
|
|
||||||
|
self.update_statusbar()
|
||||||
|
|
||||||
|
def _set_current_reach(self):
|
||||||
|
table = self.find(QTableView, f"tableView_reach")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.update(reach_id=indexes[0].row())
|
||||||
|
|
||||||
|
def _set_current_profile(self):
|
||||||
|
table = self.find(QTableView, f"tableView_profile")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
ind = indexes[0].row()
|
||||||
|
self.update(profile_id=ind)
|
||||||
|
###self._slider_profile.setValue(ind)
|
||||||
|
|
||||||
|
def _set_current_pol(self):
|
||||||
|
table = self.find(QTableView, f"tableView_pollutants")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
ind = indexes[0].row()
|
||||||
|
print("set pol id: ", ind)
|
||||||
|
self.update(pol_id=ind)
|
||||||
|
|
||||||
|
def _set_current_profile_raw_data(self):
|
||||||
|
table = self.find(QTableView, f"tableView_raw_data")
|
||||||
|
indexes = table.selectedIndexes()
|
||||||
|
if len(indexes) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
ind = indexes[0].row()
|
||||||
|
self.update(profile_id=ind)
|
||||||
|
self._slider_profile.setValue(ind)
|
||||||
|
|
||||||
|
def _set_current_profile_slider(self):
|
||||||
|
pid = self._slider_profile.value()
|
||||||
|
self.update(profile_id=pid)
|
||||||
|
|
||||||
|
def _set_current_timestamp(self):
|
||||||
|
timestamp = self._timestamps[self._slider_time.value()]
|
||||||
|
self.update(timestamp=timestamp)
|
||||||
|
|
||||||
|
def _reload_plots(self):
|
||||||
|
self.plot_c.results = self._results
|
||||||
|
self.plot_m.results = self._results
|
||||||
|
self.plot_tot_c.results = self._results
|
||||||
|
self.plot_tot_eg.results = self._results
|
||||||
|
self.plot_tot_em.results = self._results
|
||||||
|
self.plot_tot_ed.results = self._results
|
||||||
|
|
||||||
|
self.plot_c.draw()
|
||||||
|
self.plot_m.draw()
|
||||||
|
self.plot_tot_c.draw()
|
||||||
|
self.plot_tot_eg.draw()
|
||||||
|
self.plot_tot_em.draw()
|
||||||
|
self.plot_tot_ed.draw()
|
||||||
|
|
||||||
|
def _reload_slider(self):
|
||||||
|
self._slider_time = self.find(QSlider, f"horizontalSlider_time")
|
||||||
|
self._slider_time.setMaximum(len(self._timestamps) - 1)
|
||||||
|
self._slider_time.setValue(len(self._timestamps) - 1)
|
||||||
|
|
||||||
|
def _reload(self):
|
||||||
|
logger.debug("Reload results...")
|
||||||
|
self._results = self._results.reload()
|
||||||
|
|
||||||
|
self._timestamps = sorted(list(self._results.get("timestamps")))
|
||||||
|
|
||||||
|
self._reload_plots()
|
||||||
|
###self._reload_slider()
|
||||||
|
|
||||||
|
def _copy(self):
|
||||||
|
logger.info("TODO: copy")
|
||||||
|
|
||||||
|
def _paste(self):
|
||||||
|
logger.info("TODO: paste")
|
||||||
|
|
||||||
|
def _undo(self):
|
||||||
|
self._table.undo()
|
||||||
|
|
||||||
|
def _redo(self):
|
||||||
|
self._table.redo()
|
||||||
|
|
||||||
|
# play / pause buttons
|
||||||
|
def _update_slider(self):
|
||||||
|
if self._slider_time.value() == self._slider_time.maximum():
|
||||||
|
self._slider_time.setValue(self._slider_time.minimum())
|
||||||
|
else:
|
||||||
|
self._slider_time.setValue(self._slider_time.value()+1)
|
||||||
|
|
||||||
|
def _next(self):
|
||||||
|
self._slider_time.setValue(self._slider_time.value()+1)
|
||||||
|
|
||||||
|
def _back(self):
|
||||||
|
self._slider_time.setValue(self._slider_time.value()-1)
|
||||||
|
|
||||||
|
def _first(self):
|
||||||
|
self._slider_time.setValue(self._slider_time.minimum())
|
||||||
|
|
||||||
|
def _last(self):
|
||||||
|
self._slider_time.setValue(self._slider_time.maximum())
|
||||||
|
|
||||||
|
def _pause(self):
|
||||||
|
if self._button_play.isChecked():
|
||||||
|
self._button_next.setEnabled(False)
|
||||||
|
self._button_back.setEnabled(False)
|
||||||
|
self._button_first.setEnabled(False)
|
||||||
|
self._button_last.setEnabled(False)
|
||||||
|
self._timer.start(100)
|
||||||
|
self._button_play.setIcon(self._icon_pause)
|
||||||
|
else:
|
||||||
|
self._timer.stop()
|
||||||
|
self._button_next.setEnabled(True)
|
||||||
|
self._button_back.setEnabled(True)
|
||||||
|
self._button_first.setEnabled(True)
|
||||||
|
self._button_last.setEnabled(True)
|
||||||
|
self._button_play.setIcon(self._icon_start)
|
||||||
|
|
||||||
|
def export(self):
|
||||||
|
self.file_dialog(
|
||||||
|
select_file=False,
|
||||||
|
callback=lambda d: self.export_to(d[0])
|
||||||
|
)
|
||||||
|
|
||||||
|
def export_to(self, directory):
|
||||||
|
for reach in self._results.river.reachs:
|
||||||
|
self.export_reach(reach, directory)
|
||||||
|
|
||||||
|
def export_reach(self, reach, directory):
|
||||||
|
name = reach.name
|
||||||
|
name = name.replace(" ", "-")
|
||||||
|
|
||||||
|
file_name = os.path.join(
|
||||||
|
directory,
|
||||||
|
f"reach_{name}.csv"
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(file_name, 'w', newline='') as csvfile:
|
||||||
|
writer = csv.writer(csvfile, delimiter=',',
|
||||||
|
quotechar='|', quoting=csv.QUOTE_MINIMAL)
|
||||||
|
writer.writerow(["name", "kp", "data-file"])
|
||||||
|
for profile in reach.profiles:
|
||||||
|
p_file_name = os.path.join(
|
||||||
|
directory,
|
||||||
|
f"cs_{profile.geometry.id}.csv"
|
||||||
|
)
|
||||||
|
|
||||||
|
writer.writerow([
|
||||||
|
profile.name,
|
||||||
|
profile.kp,
|
||||||
|
p_file_name
|
||||||
|
])
|
||||||
|
|
||||||
|
self.export_profile(reach, profile, p_file_name)
|
||||||
|
|
||||||
|
def export_profile(self, reach, profile, file_name):
|
||||||
|
with open(file_name, 'w', newline='') as csvfile:
|
||||||
|
writer = csv.writer(csvfile, delimiter=',',
|
||||||
|
quotechar='|', quoting=csv.QUOTE_MINIMAL)
|
||||||
|
|
||||||
|
writer.writerow(["timestamp", "z", "q"])
|
||||||
|
timestamps = sorted(self._results.get("timestamps"))
|
||||||
|
|
||||||
|
for ts in timestamps:
|
||||||
|
writer.writerow([
|
||||||
|
ts,
|
||||||
|
profile.get_ts_key(ts, "Z"),
|
||||||
|
profile.get_ts_key(ts, "Q"),
|
||||||
|
])
|
||||||
@@ -24,7 +24,13 @@ _translate = QCoreApplication.translate
|
|||||||
|
|
||||||
|
|
||||||
class ResultsTranslate(MainTranslate):
|
class ResultsTranslate(MainTranslate):
|
||||||
def __init__(self):
|
def __init__(self, pollutants=None):
|
||||||
|
if pollutants is not None:
|
||||||
|
self.pollutants = pollutants
|
||||||
|
self.pollutants.remove("total_sediment")
|
||||||
|
else:
|
||||||
|
self.pollutants = pollutants
|
||||||
|
|
||||||
super(ResultsTranslate, self).__init__()
|
super(ResultsTranslate, self).__init__()
|
||||||
|
|
||||||
self._dict["Results"] = _translate("Results", "Results")
|
self._dict["Results"] = _translate("Results", "Results")
|
||||||
@@ -48,14 +54,31 @@ class ResultsTranslate(MainTranslate):
|
|||||||
"name": _translate("Results", "Reach name"),
|
"name": _translate("Results", "Reach name"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self._sub_dict["table_headers_phys_var"] = {
|
||||||
|
"name": _translate("Results", "Variables names"),
|
||||||
|
}
|
||||||
|
|
||||||
self._sub_dict["table_headers_profile"] = {
|
self._sub_dict["table_headers_profile"] = {
|
||||||
"name": self._dict["name"],
|
"name": self._dict["name"],
|
||||||
"kp": self._dict["unit_kp"],
|
"kp": self._dict["unit_kp"],
|
||||||
}
|
}
|
||||||
|
|
||||||
self._sub_dict["table_headers_raw_data"] = {
|
self._sub_dict["table_headers_pollutants"] = {
|
||||||
"name": _translate("Results", "Profile"),
|
"name": _translate("Results", "Pollutant name"),
|
||||||
"water_elevation": self._dict["unit_water_elevation"],
|
|
||||||
"discharge": self._dict["unit_discharge"],
|
|
||||||
"speed": self._dict["unit_speed"],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.pollutants is not None:
|
||||||
|
self._sub_dict["table_headers_raw_data"] = {
|
||||||
|
"name": _translate("Results", "Profile"),
|
||||||
|
}
|
||||||
|
for pol in self.pollutants:
|
||||||
|
self._sub_dict["table_headers_raw_data"][pol + " Concentration"] = pol + "\n Concentration"
|
||||||
|
self._sub_dict["table_headers_raw_data"][pol + " Mass"] = pol + "\n Mass"
|
||||||
|
else:
|
||||||
|
self._sub_dict["table_headers_raw_data"] = {
|
||||||
|
"name": _translate("Results", "Profile"),
|
||||||
|
"water_elevation": self._dict["unit_water_elevation"],
|
||||||
|
"discharge": self._dict["unit_discharge"],
|
||||||
|
"speed": self._dict["unit_speed"],
|
||||||
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,9 @@ class SelectSolverWindow(PamhyrDialog):
|
|||||||
self.select_last_solver()
|
self.select_last_solver()
|
||||||
|
|
||||||
def setup_combobox(self):
|
def setup_combobox(self):
|
||||||
solvers = self._config.solvers
|
#solvers = self._config.solvers
|
||||||
|
#solvers mage
|
||||||
|
solvers = list(filter(lambda x: "adists" not in x._type, self._config.solvers))
|
||||||
solvers_name = list(
|
solvers_name = list(
|
||||||
map(
|
map(
|
||||||
self._format_solver_name,
|
self._format_solver_name,
|
||||||
|
|||||||
@@ -0,0 +1,451 @@
|
|||||||
|
# WindowAdisTS.py -- Pamhyr
|
||||||
|
# Copyright (C) 2023-2024 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/>.
|
||||||
|
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import logging
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
from queue import Queue
|
||||||
|
from tools import trace, timer, logger_exception
|
||||||
|
|
||||||
|
from View.Tools.PamhyrWindow import PamhyrDialog, PamhyrWindow
|
||||||
|
|
||||||
|
from PyQt5.QtGui import (
|
||||||
|
QKeySequence,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (
|
||||||
|
Qt, QVariant, QAbstractTableModel,
|
||||||
|
QCoreApplication, QModelIndex, pyqtSlot,
|
||||||
|
QRect, QTimer, QProcess,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import (
|
||||||
|
QDialogButtonBox, QPushButton, QLineEdit,
|
||||||
|
QFileDialog, QTableView, QAbstractItemView,
|
||||||
|
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||||
|
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||||
|
QTextEdit,
|
||||||
|
)
|
||||||
|
|
||||||
|
from View.RunSolver.Log.Window import SolverLogFileWindow
|
||||||
|
from View.Results.ReadingResultsDialog import ReadingResultsDialog
|
||||||
|
|
||||||
|
try:
|
||||||
|
from signal import SIGTERM, SIGSTOP, SIGCONT
|
||||||
|
_signal = True
|
||||||
|
except Exception:
|
||||||
|
_signal = False
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class SelectSolverWindowAdisTS(PamhyrDialog):
|
||||||
|
_pamhyr_ui = "SelectSolverAdisTS"
|
||||||
|
_pamhyr_name = "Select solver"
|
||||||
|
|
||||||
|
def __init__(self, study=None, config=None,
|
||||||
|
parent=None):
|
||||||
|
self._solver = None
|
||||||
|
|
||||||
|
name = _translate("Solver", "Select solver")
|
||||||
|
super(SelectSolverWindowAdisTS, self).__init__(
|
||||||
|
title=name,
|
||||||
|
study=study,
|
||||||
|
config=config,
|
||||||
|
options=[],
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self.setup_combobox()
|
||||||
|
self.setup_connections()
|
||||||
|
self.select_last_solver()
|
||||||
|
|
||||||
|
def setup_combobox(self):
|
||||||
|
#solvers = self._config.solvers
|
||||||
|
#solvers mage
|
||||||
|
solvers = list(filter(lambda x: "mage" not in x._type, self._config.solvers))
|
||||||
|
solvers_name = list(
|
||||||
|
map(
|
||||||
|
self._format_solver_name,
|
||||||
|
solvers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
solvers_mage = list(filter(lambda x: "mage" in x._type.lower(), self._config.solvers))
|
||||||
|
solvers_mage_names = list(map(lambda x: x._name, solvers_mage))
|
||||||
|
|
||||||
|
solvers_dir = os.path.join(
|
||||||
|
os.path.dirname(self._study.filename),
|
||||||
|
"_PAMHYR_",
|
||||||
|
self._study.name.replace(" ", "_"),
|
||||||
|
)
|
||||||
|
|
||||||
|
dir_solvers_List = os.listdir(solvers_dir)
|
||||||
|
|
||||||
|
display_mage_names = list(filter(lambda x: x in solvers_mage_names, dir_solvers_List))
|
||||||
|
|
||||||
|
self.combobox_add_items("comboBox", solvers_name)
|
||||||
|
self.combobox_add_items("comboBoxRepMage", display_mage_names)
|
||||||
|
|
||||||
|
def setup_connections(self):
|
||||||
|
self.find(QPushButton, "pushButton_run").clicked.connect(self.accept)
|
||||||
|
self.find(QPushButton, "pushButton_cancel")\
|
||||||
|
.clicked.connect(self.reject)
|
||||||
|
|
||||||
|
def select_last_solver(self):
|
||||||
|
solvers = self._config.solvers
|
||||||
|
last = self._config.last_solver_name
|
||||||
|
|
||||||
|
solver = list(
|
||||||
|
filter(
|
||||||
|
lambda s: s.name == last,
|
||||||
|
solvers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(solver) != 0:
|
||||||
|
self.set_combobox_text(
|
||||||
|
"comboBox",
|
||||||
|
self._format_solver_name(solver[0])
|
||||||
|
)
|
||||||
|
|
||||||
|
def _format_solver_name(self, solver):
|
||||||
|
return f"{solver.name} - ({solver._type})"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def solver(self):
|
||||||
|
return self._solver
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mage_rep(self):
|
||||||
|
return self._mage_result_rep
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
solver_name = self.get_combobox_text("comboBox")
|
||||||
|
solver_name = solver_name.rsplit(" - ", 1)[0]
|
||||||
|
|
||||||
|
self._mage_result_rep = self.get_combobox_text("comboBoxRepMage")
|
||||||
|
|
||||||
|
self._config.update_last_solver_used(solver_name)
|
||||||
|
|
||||||
|
self._solver = next(
|
||||||
|
filter(
|
||||||
|
lambda s: s.name == solver_name,
|
||||||
|
self._config.solvers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
super(SelectSolverWindowAdisTS, self).accept()
|
||||||
|
|
||||||
|
class SolverLogWindowAdisTS(PamhyrWindow):
|
||||||
|
_pamhyr_ui = "SolverLogAdisTS"
|
||||||
|
_pamhyr_name = "Solver Log"
|
||||||
|
|
||||||
|
def __init__(self, study=None, config=None,
|
||||||
|
solver=None, parent=None, mage_rep=None):
|
||||||
|
self._solver = solver
|
||||||
|
self._results = None
|
||||||
|
self._results_mage = None
|
||||||
|
self._mage_rep = mage_rep
|
||||||
|
|
||||||
|
name = _translate("Solver", "Select log")
|
||||||
|
super(SolverLogWindowAdisTS, self).__init__(
|
||||||
|
title=name,
|
||||||
|
study=study,
|
||||||
|
config=config,
|
||||||
|
options=[],
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
|
self.setup_action()
|
||||||
|
self.setup_alarm()
|
||||||
|
self.setup_connections()
|
||||||
|
self.setup_workdir()
|
||||||
|
self.setup_process()
|
||||||
|
|
||||||
|
ok = self.export()
|
||||||
|
if ok:
|
||||||
|
self.run()
|
||||||
|
else:
|
||||||
|
self._log(
|
||||||
|
f" *** Failed to export study to {self._solver._type}",
|
||||||
|
color="red"
|
||||||
|
)
|
||||||
|
|
||||||
|
def setup_action(self):
|
||||||
|
self.find(QAction, "action_start").setEnabled(False)
|
||||||
|
if _signal:
|
||||||
|
self.find(QAction, "action_pause").setEnabled(True)
|
||||||
|
else:
|
||||||
|
self.find(QAction, "action_pause").setEnabled(False)
|
||||||
|
|
||||||
|
self.find(QAction, "action_stop").setEnabled(True)
|
||||||
|
self.find(QAction, "action_log_file").setEnabled(False)
|
||||||
|
self.find(QAction, "action_results").setEnabled(False)
|
||||||
|
|
||||||
|
def setup_alarm(self):
|
||||||
|
self._alarm = QTimer()
|
||||||
|
|
||||||
|
def setup_connections(self):
|
||||||
|
self.find(QAction, "action_start").triggered.connect(self.start)
|
||||||
|
self.find(QAction, "action_pause").triggered.connect(self.pause)
|
||||||
|
self.find(QAction, "action_stop").triggered.connect(self.stop)
|
||||||
|
self.find(QAction, "action_log_file").triggered.connect(self.log_file)
|
||||||
|
self.find(QAction, "action_results").triggered.connect(self.results)
|
||||||
|
self.find(QAction, "action_results_Mage").triggered.connect(self.resultsMage)
|
||||||
|
|
||||||
|
self._alarm.timeout.connect(self.update)
|
||||||
|
|
||||||
|
def setup_workdir(self):
|
||||||
|
self._workdir = ""
|
||||||
|
if self._study.filename == "":
|
||||||
|
self._workdir = tempfile.TemporaryDirectory()
|
||||||
|
else:
|
||||||
|
self._workdir = os.path.join(
|
||||||
|
os.path.dirname(self._study.filename),
|
||||||
|
"_PAMHYR_",
|
||||||
|
self._study.name.replace(" ", "_"),
|
||||||
|
self._solver.name.replace(" ", "_"),
|
||||||
|
)
|
||||||
|
os.makedirs(self._workdir, exist_ok=True)
|
||||||
|
|
||||||
|
def setup_process(self):
|
||||||
|
self._alarm.start(100)
|
||||||
|
self._output = Queue()
|
||||||
|
self._process = self.new_process(self._parent)
|
||||||
|
|
||||||
|
def new_process(self, parent):
|
||||||
|
new = QProcess(parent)
|
||||||
|
new.setWorkingDirectory(self._workdir)
|
||||||
|
new.setProcessChannelMode(QProcess.MergedChannels)
|
||||||
|
return new
|
||||||
|
|
||||||
|
def export(self):
|
||||||
|
self._log(f" *** Export study {self._solver.name}", color="blue")
|
||||||
|
ok = self._solver.export(self._study, self._workdir, self._mage_rep, qlog=self._output)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
return ok
|
||||||
|
|
||||||
|
def closeEvent(self, event):
|
||||||
|
self._alarm.stop()
|
||||||
|
super(SolverLogWindowAdisTS, self).closeEvent(event)
|
||||||
|
|
||||||
|
def _copy(self):
|
||||||
|
self.find(QTextEdit, "textEdit").copy()
|
||||||
|
|
||||||
|
#######
|
||||||
|
# LOG #
|
||||||
|
#######
|
||||||
|
|
||||||
|
def _log(self, msg, color=None):
|
||||||
|
if type(msg) is str:
|
||||||
|
self._log_str(msg, color)
|
||||||
|
elif type(msg) is int:
|
||||||
|
self._log_int(msg, color)
|
||||||
|
|
||||||
|
def _log_str(self, msg, color=None):
|
||||||
|
if msg == "":
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.info(f"solver: {msg}")
|
||||||
|
msg = msg.rsplit('\n', 1)[0]
|
||||||
|
|
||||||
|
if color is not None:
|
||||||
|
msg = f"<font color=\"{color}\">" + msg + "</font>"
|
||||||
|
|
||||||
|
self.find(QTextEdit, "textEdit").append(msg)
|
||||||
|
|
||||||
|
def _log_int(self, int_code, color=None):
|
||||||
|
logger.info(f"solver: Returns {int_code}")
|
||||||
|
color = "blue" if int_code == 0 else "red"
|
||||||
|
|
||||||
|
self.find(QTextEdit, "textEdit")\
|
||||||
|
.append(
|
||||||
|
f"<font color=\"{color}\">" +
|
||||||
|
f" *** Finished with code {int_code}" +
|
||||||
|
"</font>"
|
||||||
|
)
|
||||||
|
|
||||||
|
self.statusbar.showMessage(
|
||||||
|
"Done" if int_code == 0 else "Failed",
|
||||||
|
3000
|
||||||
|
)
|
||||||
|
|
||||||
|
##########
|
||||||
|
# UPDATE #
|
||||||
|
##########
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if self._solver.is_stoped():
|
||||||
|
self.find(QAction, "action_start").setEnabled(True)
|
||||||
|
self.find(QAction, "action_pause").setEnabled(False)
|
||||||
|
self.find(QAction, "action_stop").setEnabled(False)
|
||||||
|
self.find(QAction, "action_results").setEnabled(True)
|
||||||
|
|
||||||
|
if self._solver.log_file() != "":
|
||||||
|
self.find(QAction, "action_log_file").setEnabled(True)
|
||||||
|
|
||||||
|
self._update_logs_all()
|
||||||
|
# self._update_get_results()
|
||||||
|
|
||||||
|
self._update_logs_all()
|
||||||
|
|
||||||
|
def _update_get_results(self):
|
||||||
|
if self._results is None:
|
||||||
|
def reading_fn():
|
||||||
|
try:
|
||||||
|
self._results = self._solver.results(
|
||||||
|
self._study, self._workdir, qlog=self._output
|
||||||
|
)
|
||||||
|
self._parent.set_results(self._solver, self._results)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to open results")
|
||||||
|
logger_exception(e)
|
||||||
|
|
||||||
|
dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
|
||||||
|
dlg.exec_()
|
||||||
|
|
||||||
|
def _update_logs_all(self):
|
||||||
|
while self._output.qsize() != 0:
|
||||||
|
s = self._output.get()
|
||||||
|
|
||||||
|
try:
|
||||||
|
if type(s) is str and "[ERROR]" in s:
|
||||||
|
self._log(s.encode("utf-8"), color="red")
|
||||||
|
else:
|
||||||
|
self._log(s)
|
||||||
|
except Exception as e:
|
||||||
|
logger_exception(e)
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Process controle #
|
||||||
|
####################
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self._log(f" *** Run solver {self._solver.name}", color="blue")
|
||||||
|
self._solver.run(
|
||||||
|
self._study,
|
||||||
|
process=self._process,
|
||||||
|
output_queue=self._output
|
||||||
|
)
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
if self._solver.is_stoped():
|
||||||
|
self._log(f" *** Export study {self._solver.name}", color="blue")
|
||||||
|
|
||||||
|
ok = self._solver.export(
|
||||||
|
self._study, self._workdir, self._mage_rep, qlog=self._output
|
||||||
|
)
|
||||||
|
|
||||||
|
if not ok:
|
||||||
|
self._log(f" *** Failed to export", color="red")
|
||||||
|
self.update()
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self.update()
|
||||||
|
self._process = self.new_process(self._parent)
|
||||||
|
|
||||||
|
self._log(" *** Start", color="blue")
|
||||||
|
self._results = None
|
||||||
|
self._solver.start(self._study, process=self._process)
|
||||||
|
|
||||||
|
self.find(QAction, "action_start").setEnabled(False)
|
||||||
|
if _signal:
|
||||||
|
self.find(QAction, "action_pause").setEnabled(True)
|
||||||
|
else:
|
||||||
|
self.find(QAction, "action_pause").setEnabled(False)
|
||||||
|
self.find(QAction, "action_stop").setEnabled(True)
|
||||||
|
self.find(QAction, "action_log_file").setEnabled(False)
|
||||||
|
self.find(QAction, "action_results").setEnabled(False)
|
||||||
|
|
||||||
|
def pause(self):
|
||||||
|
self._log(" *** Pause", color="blue")
|
||||||
|
self._solver.pause()
|
||||||
|
|
||||||
|
self.find(QAction, "action_start").setEnabled(True)
|
||||||
|
self.find(QAction, "action_pause").setEnabled(False)
|
||||||
|
self.find(QAction, "action_stop").setEnabled(True)
|
||||||
|
self.find(QAction, "action_results").setEnabled(False)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self._log(" *** Stop", color="blue")
|
||||||
|
self._solver.kill()
|
||||||
|
|
||||||
|
self.find(QAction, "action_start").setEnabled(True)
|
||||||
|
self.find(QAction, "action_pause").setEnabled(False)
|
||||||
|
self.find(QAction, "action_stop").setEnabled(False)
|
||||||
|
self.find(QAction, "action_results").setEnabled(True)
|
||||||
|
if self._solver.log_file() != "":
|
||||||
|
self.find(QAction, "action_log_file").setEnabled(True)
|
||||||
|
|
||||||
|
###########
|
||||||
|
# Results #
|
||||||
|
###########
|
||||||
|
|
||||||
|
def results(self):
|
||||||
|
if self._results is None:
|
||||||
|
def reading_fn():
|
||||||
|
self._results = self._solver.results(
|
||||||
|
self._study, self._workdir, qlog=self._output
|
||||||
|
)
|
||||||
|
|
||||||
|
dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
|
||||||
|
dlg.exec_()
|
||||||
|
|
||||||
|
self._parent.set_results(self._solver, self._results)
|
||||||
|
self._parent.open_solver_results_adists(self._solver, self._results)
|
||||||
|
|
||||||
|
self._solver.has_results_loaded()
|
||||||
|
|
||||||
|
def resultsMage(self):
|
||||||
|
if self._results_mage is None:
|
||||||
|
mage_solver = next(filter(lambda x: x._name == self._mage_rep, self._config.solvers))
|
||||||
|
workdir_mage = os.path.join(
|
||||||
|
os.path.dirname(self._study.filename),
|
||||||
|
"_PAMHYR_",
|
||||||
|
self._study.name.replace(" ", "_"),
|
||||||
|
mage_solver.name.replace(" ", "_"),
|
||||||
|
)
|
||||||
|
def reading_fn():
|
||||||
|
self._results_mage = mage_solver.results(
|
||||||
|
self._study, workdir_mage, qlog=self._output
|
||||||
|
)
|
||||||
|
|
||||||
|
dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
|
||||||
|
dlg.exec_()
|
||||||
|
|
||||||
|
self._parent.set_results(mage_solver, self._results_mage)
|
||||||
|
self._parent.open_solver_results(mage_solver, self._results_mage)
|
||||||
|
|
||||||
|
mage_solver.has_results_loaded()
|
||||||
|
|
||||||
|
def log_file(self):
|
||||||
|
file_name = os.path.join(self._workdir, self._solver.log_file())
|
||||||
|
log = SolverLogFileWindow(
|
||||||
|
file_name=file_name,
|
||||||
|
study=self._study,
|
||||||
|
config=self._config,
|
||||||
|
solver=self._solver,
|
||||||
|
parent=self,
|
||||||
|
)
|
||||||
|
log.show()
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ class ParamTranslate(MainTranslate):
|
|||||||
"Minimum water height (meter)"),
|
"Minimum water height (meter)"),
|
||||||
"mage_max_niter":
|
"mage_max_niter":
|
||||||
_translate("SolverParameters",
|
_translate("SolverParameters",
|
||||||
"Maximum number of iterations (< 100)"),
|
"Maximun number of iterations (< 100)"),
|
||||||
"mage_timestep_reduction_factor":
|
"mage_timestep_reduction_factor":
|
||||||
_translate("SolverParameters",
|
_translate("SolverParameters",
|
||||||
"Timestep reduction factor"),
|
"Timestep reduction factor"),
|
||||||
@@ -114,10 +114,10 @@ class ParamTranslate(MainTranslate):
|
|||||||
"Reduction precision factor of residue"),
|
"Reduction precision factor of residue"),
|
||||||
"mage_niter_max_precision":
|
"mage_niter_max_precision":
|
||||||
_translate("SolverParameters",
|
_translate("SolverParameters",
|
||||||
"Number of iterations at maximum precision"),
|
"Number of iteration at maximum precision"),
|
||||||
"mage_niter_before_switch":
|
"mage_niter_before_switch":
|
||||||
_translate("SolverParameters",
|
_translate("SolverParameters",
|
||||||
"Number of iterations before switch"),
|
"Number of iteration before switch"),
|
||||||
"mage_max_froude":
|
"mage_max_froude":
|
||||||
_translate("SolverParameters",
|
_translate("SolverParameters",
|
||||||
"Maximum accepted Froude number"),
|
"Maximum accepted Froude number"),
|
||||||
@@ -152,7 +152,7 @@ class ParamTranslate(MainTranslate):
|
|||||||
"mage_methode_modification_geometrie":
|
"mage_methode_modification_geometrie":
|
||||||
_translate("SolverParameters", "Geometry modification method"),
|
_translate("SolverParameters", "Geometry modification method"),
|
||||||
"mage_shields_critique":
|
"mage_shields_critique":
|
||||||
_translate("SolverParameters", "Critical Shields number"),
|
_translate("SolverParameters", "Critic shields"),
|
||||||
"mage_shields_correction":
|
"mage_shields_correction":
|
||||||
_translate("SolverParameters", "Shields correction"),
|
_translate("SolverParameters", "Shields correction"),
|
||||||
"mage_capacite_solide":
|
"mage_capacite_solide":
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class StricklersTranslate(MainTranslate):
|
|||||||
super(StricklersTranslate, self).__init__()
|
super(StricklersTranslate, self).__init__()
|
||||||
|
|
||||||
self._dict["Stricklers"] = _translate(
|
self._dict["Stricklers"] = _translate(
|
||||||
"Stricklers", "Strickler coefficients"
|
"Stricklers", "Stricklers"
|
||||||
)
|
)
|
||||||
|
|
||||||
self._sub_dict["table_headers"] = {
|
self._sub_dict["table_headers"] = {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QRadioButton, QComboBox, QFileDialog,
|
QRadioButton, QComboBox, QFileDialog,
|
||||||
QMessageBox, QTableView, QAction,
|
QMessageBox, QTableView, QAction,
|
||||||
QDateTimeEdit, QWidget, QPlainTextEdit,
|
QDateTimeEdit, QWidget, QPlainTextEdit,
|
||||||
QLabel, QDoubleSpinBox, QButtonGroup,
|
QLabel, QDoubleSpinBox,
|
||||||
)
|
)
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
QTime, QDateTime,
|
QTime, QDateTime,
|
||||||
@@ -102,10 +102,7 @@ class WindowToolKit(object):
|
|||||||
Returns:
|
Returns:
|
||||||
The returns of callback
|
The returns of callback
|
||||||
"""
|
"""
|
||||||
options = QFileDialog.Options()
|
dialog = QFileDialog(self)
|
||||||
options |= QFileDialog.DontUseNativeDialog
|
|
||||||
|
|
||||||
dialog = QFileDialog(self, options=options)
|
|
||||||
|
|
||||||
if select_file:
|
if select_file:
|
||||||
mode = QFileDialog.FileMode.ExistingFile
|
mode = QFileDialog.FileMode.ExistingFile
|
||||||
@@ -501,17 +498,6 @@ class ASubWindowFeatures(object):
|
|||||||
qdate = QDateTime.fromString(date.isoformat(), "yyyy-MM-ddThh:mm:ss")
|
qdate = QDateTime.fromString(date.isoformat(), "yyyy-MM-ddThh:mm:ss")
|
||||||
self.find(QDateTimeEdit, name).setDateTime(qdate)
|
self.find(QDateTimeEdit, name).setDateTime(qdate)
|
||||||
|
|
||||||
def get_checked_id_button_group(self, name: str):
|
|
||||||
"""Get current checked button id in a buttonGroup
|
|
||||||
|
|
||||||
Args:
|
|
||||||
name: The buttonGroup component name
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Current checked id
|
|
||||||
"""
|
|
||||||
return self.find(QButtonGroup, name).checkedId()
|
|
||||||
|
|
||||||
|
|
||||||
# Top level interface
|
# Top level interface
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
import matplotlib.colors as mplcolors
|
import matplotlib.colors as mplcolors
|
||||||
from matplotlib import ticker
|
from matplotlib import ticker
|
||||||
|
|
||||||
@@ -27,8 +25,6 @@ from View.Tools.Plot.APlot import APlot
|
|||||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||||
|
|
||||||
logger = logging.getLogger()
|
|
||||||
|
|
||||||
|
|
||||||
class PamhyrPlot(APlot):
|
class PamhyrPlot(APlot):
|
||||||
color_axes = "black"
|
color_axes = "black"
|
||||||
@@ -42,6 +38,7 @@ class PamhyrPlot(APlot):
|
|||||||
color_plot_river_bottom = "grey"
|
color_plot_river_bottom = "grey"
|
||||||
color_plot_river_water = "blue"
|
color_plot_river_water = "blue"
|
||||||
color_plot_river_water_zone = "skyblue"
|
color_plot_river_water_zone = "skyblue"
|
||||||
|
|
||||||
colors = list(mplcolors.TABLEAU_COLORS)
|
colors = list(mplcolors.TABLEAU_COLORS)
|
||||||
linestyle = ['solid', 'dashed', 'dashdot', 'dotted']
|
linestyle = ['solid', 'dashed', 'dashdot', 'dotted']
|
||||||
|
|
||||||
@@ -80,7 +77,6 @@ class PamhyrPlot(APlot):
|
|||||||
connector = {
|
connector = {
|
||||||
'pick_event': self.onpick,
|
'pick_event': self.onpick,
|
||||||
'button_press_event': self.onclick,
|
'button_press_event': self.onclick,
|
||||||
'button_release_event': self.onrelease,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for event in connector:
|
for event in connector:
|
||||||
@@ -104,7 +100,6 @@ class PamhyrPlot(APlot):
|
|||||||
self._highlight_data_update = False
|
self._highlight_data_update = False
|
||||||
self._current_data = None #: Current data identifier
|
self._current_data = None #: Current data identifier
|
||||||
self._current_data_update = False
|
self._current_data_update = False
|
||||||
self._rect_select = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def canvas(self):
|
def canvas(self):
|
||||||
@@ -236,13 +231,3 @@ class PamhyrPlot(APlot):
|
|||||||
|
|
||||||
def onclick(self, event):
|
def onclick(self, event):
|
||||||
return
|
return
|
||||||
|
|
||||||
def onrelease(self, event):
|
|
||||||
return
|
|
||||||
|
|
||||||
def rect_select_callback(self, eclick, erelease):
|
|
||||||
'eclick and erelease are the press and release events'
|
|
||||||
x1, y1 = eclick.xdata, eclick.ydata
|
|
||||||
x2, y2 = erelease.xdata, erelease.ydata
|
|
||||||
logging.debug("(%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2))
|
|
||||||
return
|
|
||||||
@@ -112,7 +112,7 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||||||
self.toolitems.append(
|
self.toolitems.append(
|
||||||
(
|
(
|
||||||
'Forward',
|
'Forward',
|
||||||
_translate("Toolbar", 'Back to next view'),
|
_translate("Toolbar", 'Return to next view'),
|
||||||
'forward', 'forward'
|
'forward', 'forward'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -121,7 +121,7 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||||||
self.toolitems.append(
|
self.toolitems.append(
|
||||||
(
|
(
|
||||||
'Pan',
|
'Pan',
|
||||||
_translate("Toolbar", 'Panoramic axes'),
|
_translate("Toolbar", 'Axes panoramic'),
|
||||||
'move', 'pan'
|
'move', 'pan'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -184,7 +184,7 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||||||
self.toolitems.append(
|
self.toolitems.append(
|
||||||
(
|
(
|
||||||
'Save',
|
'Save',
|
||||||
_translate("Toolbar", 'Save figure'),
|
_translate("Toolbar", 'Save the figure'),
|
||||||
'filesave', 'save_figure'
|
'filesave', 'save_figure'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -253,12 +253,12 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||||||
self._actions['back'].setToolTip(
|
self._actions['back'].setToolTip(
|
||||||
_translate("Toolbar", "Back to previous view"))
|
_translate("Toolbar", "Back to previous view"))
|
||||||
self._actions['forward'].setToolTip(
|
self._actions['forward'].setToolTip(
|
||||||
_translate("Toolbar", "Back to next view"))
|
_translate("Toolbar", "Return to next view"))
|
||||||
self._actions['pan'].setToolTip(
|
self._actions['pan'].setToolTip(
|
||||||
_translate("Toolbar", "Panoramic axes"))
|
_translate("Toolbar", "Axes panoramic"))
|
||||||
self._actions['zoom'].setToolTip(_translate("Toolbar", "Zoom"))
|
self._actions['zoom'].setToolTip(_translate("Toolbar", "Zoom"))
|
||||||
self._actions['save_figure'].setToolTip(
|
self._actions['save_figure'].setToolTip(
|
||||||
_translate("Toolbar", "Save figure"))
|
_translate("Toolbar", "Save the figure"))
|
||||||
self.action_isometric_view.setToolTip(
|
self.action_isometric_view.setToolTip(
|
||||||
_translate("Toolbar", "Isometric view (Shift+W)"))
|
_translate("Toolbar", "Isometric view (Shift+W)"))
|
||||||
self.action_auto_global_view.setToolTip(
|
self.action_auto_global_view.setToolTip(
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class UnitTranslate(CommonWordTranslate):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(UnitTranslate, self).__init__()
|
super(UnitTranslate, self).__init__()
|
||||||
|
|
||||||
self._dict["unit_kp"] = _translate("Unit", "Position (m)")
|
self._dict["unit_kp"] = _translate("Unit", "KP (m)")
|
||||||
self._dict["unit_width"] = _translate("Unit", "Width (m)")
|
self._dict["unit_width"] = _translate("Unit", "Width (m)")
|
||||||
self._dict["unit_height"] = _translate("Unit", "Height (m)")
|
self._dict["unit_height"] = _translate("Unit", "Height (m)")
|
||||||
self._dict["unit_diameter"] = _translate("Unit", "Diameter (m)")
|
self._dict["unit_diameter"] = _translate("Unit", "Diameter (m)")
|
||||||
@@ -103,5 +103,5 @@ class MainTranslate(UnitTranslate):
|
|||||||
"MainWindow", "Open SQLite debuging tool ('sqlitebrowser')"
|
"MainWindow", "Open SQLite debuging tool ('sqlitebrowser')"
|
||||||
)
|
)
|
||||||
self._dict["active_window"] = _translate(
|
self._dict["active_window"] = _translate(
|
||||||
"MainWindow", "Enable this window"
|
"MainWindow", "Activate this window"
|
||||||
)
|
)
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_liquid">
|
<widget class="QWidget" name="tab_liquid">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_suspenssion">
|
<widget class="QWidget" name="tab_suspenssion">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Suspension</string>
|
<string>Suspenssion</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Add a new boundary condition or point source</string>
|
<string>Add a new boundary condition or punctual contribution</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+N</string>
|
<string>Ctrl+N</string>
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
<string>Edit</string>
|
<string>Edit</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit boundary condition or point source</string>
|
<string>Edit boundary condition or punctual contribution</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+E</string>
|
<string>Ctrl+E</string>
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
<string>Sort</string>
|
<string>Sort</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Sort by names</string>
|
<string>Sort boundary condition by name</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_9">
|
<widget class="QLabel" name="label_9">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Frequency</string>
|
<string>Frequence</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -349,7 +349,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>This value must be used for reading or editing files in speficic cases.</string>
|
<string>This value must be used for reading or editing files in speficic case.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -374,7 +374,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_12">
|
<widget class="QLabel" name="label_12">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string> - The "@file" keyword is replaced by the path of file to open.</string>
|
<string> - The "@file" keyworkd is replace by the path of file to open.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -382,7 +382,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_language">
|
<widget class="QWidget" name="tab_language">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Langue</string>
|
<string>Language</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_6">
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="pushButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Evaluate</string>
|
<string>Eval</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Add a new point</string>
|
<string>Add a new point in boundary condition or punctual contribution</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+N</string>
|
<string>Ctrl+N</string>
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
<string>Sort</string>
|
<string>Sort</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Sort points</string>
|
<string>Sort boundary condition points</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Add a new point in boundary condition or lateral source</string>
|
<string>Add a new point in boundary condition or lateral contribution</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+N</string>
|
<string>Ctrl+N</string>
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
<string>Sort</string>
|
<string>Sort</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Sort points</string>
|
<string>Sort boundary condition point</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -98,10 +98,7 @@
|
|||||||
<normaloff>ressources/edit.png</normaloff>ressources/edit.png</iconset>
|
<normaloff>ressources/edit.png</normaloff>ressources/edit.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Edit Strickler coefficients</string>
|
<string>Edit stricklers</string>
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Edit Strickler coefficients</string>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+E</string>
|
<string>Ctrl+E</string>
|
||||||
|
|||||||
@@ -67,10 +67,10 @@
|
|||||||
<normaloff>ressources/add.png</normaloff>ressources/add.png</iconset>
|
<normaloff>ressources/add.png</normaloff>ressources/add.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>add</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Add a point to cross-section</string>
|
<string>Add a point on cross-section</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_delete">
|
<action name="action_delete">
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
<normaloff>ressources/up.png</normaloff>ressources/up.png</iconset>
|
<normaloff>ressources/up.png</normaloff>ressources/up.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Up</string>
|
<string>up</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Move up selected point(s)</string>
|
<string>Move up selected point(s)</string>
|
||||||
@@ -103,10 +103,10 @@
|
|||||||
<normaloff>ressources/down.png</normaloff>ressources/down.png</iconset>
|
<normaloff>ressources/down.png</normaloff>ressources/down.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Down</string>
|
<string>down</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Move down selected point(s)</string>
|
<string>Mode down selected point(s)</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_sort_asc">
|
<action name="action_sort_asc">
|
||||||
|
|||||||
@@ -28,6 +28,49 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="tableView"/>
|
<widget class="QTableView" name="tableView"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_up">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/go-up2.png</normaloff>ressources/go-up2.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="verticalSlider">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="invertedAppearance">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="invertedControls">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_down">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/go-down1.png</normaloff>ressources/go-down1.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QSplitter" name="splitter_2">
|
<widget class="QSplitter" name="splitter_2">
|
||||||
@@ -123,7 +166,7 @@
|
|||||||
<normaloff>ressources/add.png</normaloff>ressources/add.png</iconset>
|
<normaloff>ressources/add.png</normaloff>ressources/add.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>add</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Add a cross-section</string>
|
<string>Add a cross-section</string>
|
||||||
@@ -147,7 +190,7 @@
|
|||||||
<normaloff>ressources/edit.png</normaloff>ressources/edit.png</iconset>
|
<normaloff>ressources/edit.png</normaloff>ressources/edit.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Edit</string>
|
<string>edit</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit selected cross section(s)</string>
|
<string>Edit selected cross section(s)</string>
|
||||||
@@ -162,7 +205,7 @@
|
|||||||
<string>sort_asc</string>
|
<string>sort_asc</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Sort cross-sections by ascending position</string>
|
<string>Sort cross-sections by ascending KP</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_sort_des">
|
<action name="action_sort_des">
|
||||||
@@ -174,7 +217,7 @@
|
|||||||
<string>sort_des</string>
|
<string>sort_des</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Sort cross-sections by descending position</string>
|
<string>Sort cross-sections by descending KP</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_up">
|
<action name="action_up">
|
||||||
@@ -183,7 +226,7 @@
|
|||||||
<normaloff>ressources/up.png</normaloff>ressources/up.png</iconset>
|
<normaloff>ressources/up.png</normaloff>ressources/up.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Up</string>
|
<string>up</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Move up selected cross-section(s)</string>
|
<string>Move up selected cross-section(s)</string>
|
||||||
@@ -195,7 +238,7 @@
|
|||||||
<normaloff>ressources/down.png</normaloff>ressources/down.png</iconset>
|
<normaloff>ressources/down.png</normaloff>ressources/down.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Down</string>
|
<string>down</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Move down selected cross-section(s)</string>
|
<string>Move down selected cross-section(s)</string>
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
<string>sort</string>
|
<string>sort</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Sort inital conditions</string>
|
<string>Sort inital condition</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_import">
|
<action name="action_import">
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_liquid">
|
<widget class="QWidget" name="tab_liquid">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_suspenssion">
|
<widget class="QWidget" name="tab_suspenssion">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Suspension</string>
|
<string>Suspenssion</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Add a new boundary condition or lateral source</string>
|
<string>Add a new boundary condition or lateral contribution</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+N</string>
|
<string>Ctrl+N</string>
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
<string>Edit</string>
|
<string>Edit</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit boundary condition or lateral source</string>
|
<string>Edit boundary condition or lateral contribution</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+E</string>
|
<string>Ctrl+E</string>
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
<string>Sort</string>
|
<string>Sort</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Sort by names</string>
|
<string>Sort boundary condition by name</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
+14
-14
@@ -117,7 +117,7 @@
|
|||||||
<locale language="English" country="Europe"/>
|
<locale language="English" country="Europe"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&River network</string>
|
<string>&River Network</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="action_menu_edit_network"/>
|
<addaction name="action_menu_edit_network"/>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -422,7 +422,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="action_menu_config">
|
<action name="action_menu_config">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Pamhyr2 configuration</string>
|
<string>Pamhyr configuration</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_menu_quit">
|
<action name="action_menu_quit">
|
||||||
@@ -460,10 +460,10 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="action_menu_numerical_parameter">
|
<action name="action_menu_numerical_parameter">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Numerical parameters of solvers</string>
|
<string>Numerical parameter for solvers</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Numerical parameters of solvers</string>
|
<string>Numerical parameter for solvers</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_menu_boundary_conditions">
|
<action name="action_menu_boundary_conditions">
|
||||||
@@ -472,7 +472,7 @@
|
|||||||
<normaloff>ressources/boundary_condition.png</normaloff>ressources/boundary_condition.png</iconset>
|
<normaloff>ressources/boundary_condition.png</normaloff>ressources/boundary_condition.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Boundary conditions and point sources</string>
|
<string>Boundary conditions and punctual contributions</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font/>
|
<font/>
|
||||||
@@ -493,7 +493,7 @@
|
|||||||
<normaloff>ressources/friction.png</normaloff>ressources/friction.png</iconset>
|
<normaloff>ressources/friction.png</normaloff>ressources/friction.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Edit frictions</string>
|
<string>Edit friction</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_menu_edit_lateral_contribution">
|
<action name="action_menu_edit_lateral_contribution">
|
||||||
@@ -502,7 +502,7 @@
|
|||||||
<normaloff>ressources/lateral_contribution.png</normaloff>ressources/lateral_contribution.png</iconset>
|
<normaloff>ressources/lateral_contribution.png</normaloff>ressources/lateral_contribution.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Edit lateral sources</string>
|
<string>Edit lateral contributions</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_menu_run_solver">
|
<action name="action_menu_run_solver">
|
||||||
@@ -611,7 +611,7 @@
|
|||||||
<string>Boundary conditions</string>
|
<string>Boundary conditions</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit boundary conditions and point sources</string>
|
<string>Edit boundary conditions and punctual contributions</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font/>
|
<font/>
|
||||||
@@ -623,10 +623,10 @@
|
|||||||
<normaloff>ressources/lateral_contribution.png</normaloff>ressources/lateral_contribution.png</iconset>
|
<normaloff>ressources/lateral_contribution.png</normaloff>ressources/lateral_contribution.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Lateral sources</string>
|
<string>Lateral contribution</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit lateral sources</string>
|
<string>Edit lateral contribution</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_toolBar_frictions">
|
<action name="action_toolBar_frictions">
|
||||||
@@ -638,7 +638,7 @@
|
|||||||
<string>Friction</string>
|
<string>Friction</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit friction</string>
|
<string>Edit frictions</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_menu_edit">
|
<action name="action_menu_edit">
|
||||||
@@ -683,7 +683,7 @@
|
|||||||
<string>Mage</string>
|
<string>Mage</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Open Mage documentation</string>
|
<string>Open mage documentation</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_menu_pamhyr_users_wiki">
|
<action name="action_menu_pamhyr_users_wiki">
|
||||||
@@ -731,12 +731,12 @@
|
|||||||
<normaloff>ressources/boundary_condition.png</normaloff>ressources/boundary_condition.png</iconset>
|
<normaloff>ressources/boundary_condition.png</normaloff>ressources/boundary_condition.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Boundary conditions and point sources</string>
|
<string>Boundary conditions and punctual contributions</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_menu_additional_file">
|
<action name="action_menu_additional_file">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Additional files</string>
|
<string>&Additional file</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_menu_rep_additional_lines">
|
<action name="action_menu_rep_additional_lines">
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Space step (m)</string>
|
<string>Section space step (m)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Guideline used for distance computation</string>
|
<string>Distance computation</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Second guideline</string>
|
<string>Second guide-line</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>First guideline</string>
|
<string>First guide-line</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>First cross-section</string>
|
<string>First cross section</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -186,7 +186,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Last cross-section</string>
|
<string>Last cross section</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -127,7 +127,7 @@
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Starting date</string>
|
<string>Staring date</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog</class>
|
|
||||||
<widget class="QDialog" name="Dialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>194</width>
|
|
||||||
<height>114</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
|
||||||
<property name="title">
|
|
||||||
<string>Number of points to keep</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QSpinBox" name="spinBox_np_purge">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>3</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>999999999</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>24</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="lineEdit_line">
|
<widget class="QLineEdit" name="lineEdit_line">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p>Comment lines start with '*' char (let see Mage documentation for more details)</p></body></html></string>
|
<string>Comment lines start with '*' char (let see the mage documentation for more details)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -37,13 +37,13 @@
|
|||||||
<action name="action_add">
|
<action name="action_add">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
<normaloff>ressources/add.png</normaloff>ressources/add.png</iconset>
|
<normaloff>ressources/add.png</normaloff>ressources/gtk-add.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Add new line</string>
|
<string>Add new additional line</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+N</string>
|
<string>Ctrl+N</string>
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
<action name="action_delete">
|
<action name="action_delete">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
<normaloff>ressources/del.png</normaloff>ressources/del.png</iconset>
|
<normaloff>ressources/del.png</normaloff>ressources/gtk-remove.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Delete</string>
|
<string>Delete</string>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_apply">
|
<widget class="QPushButton" name="pushButton_apply">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Apply sediment layers to all reaches</string>
|
<string>Apply sediment layers on all reach</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
<string>Edit profile</string>
|
<string>Edit profile</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit sediment layers of the profile</string>
|
<string>Edit profile sediment layer</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
<string>Edit</string>
|
<string>Edit</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit stage-area relation</string>
|
<string>Edit elevation/surface law</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_sort">
|
<action name="action_sort">
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
<string>Sort</string>
|
<string>Sort</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Sort points by elevations</string>
|
<string>Sort points by elevation</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
<action name="action_add">
|
<action name="action_add">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
<normaloff>ressources/add.png</normaloff>ressources/add.png</iconset>
|
<normaloff>ressources/add.png</normaloff>ressources/gtk-add.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
<action name="action_delete">
|
<action name="action_delete">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
<normaloff>ressources/del.png</normaloff>ressources/del.png</iconset>
|
<normaloff>ressources/del.png</normaloff>ressources/gtk-remove.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Delete</string>
|
<string>Delete</string>
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
<string>Edit</string>
|
<string>Edit</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Edit reservoir equations</string>
|
<string>Edit reservoir law</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -145,7 +145,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_4">
|
<widget class="QWidget" name="tab_4">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -198,7 +198,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Discharge time series</string>
|
<string>Hydrograph</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
@@ -251,7 +251,7 @@
|
|||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Add customized visualization</string>
|
<string>Add custom visualization</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_reload">
|
<action name="action_reload">
|
||||||
|
|||||||
@@ -0,0 +1,235 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1280</width>
|
||||||
|
<height>720</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="English" country="Europe"/>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>874</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QSplitter" name="splitter_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QSplitter" name="splitter_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QTableView" name="tableView_reach"/>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="tableView_profile"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="tableView_pollutants"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_tot_left"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab_4">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Raw data</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="tableView_raw_data"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Concentration</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_concentration"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_3">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Mass</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_mass"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_5">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Total Sediments</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_tot">
|
||||||
|
<item>
|
||||||
|
<widget class="QTabWidget" name="tabWidget_2">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Concentration</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_7">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_tot_c"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_6">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Left thickness</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_8">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_tot_left_2"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_7">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Minor thickness</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_9">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_tot_minor"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_8">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Right thickness</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_10">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_tot_right"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1280</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="action_add"/>
|
||||||
|
<addaction name="action_export"/>
|
||||||
|
<addaction name="action_reload"/>
|
||||||
|
</widget>
|
||||||
|
<action name="action_add">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/add.png</normaloff>ressources/add.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Add</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add custom visualization</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_reload">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/reload.png</normaloff>ressources/reload.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Reload</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_export">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/export.png</normaloff>ressources/export.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Export</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Export raw data</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+E</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Loaded 100 of 109 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user