From 5fc69510602b42c4a640589e8cbd85ea8742f975 Mon Sep 17 00:00:00 2001 From: Theophile Terraz Date: Fri, 6 Jun 2025 17:32:02 +0200 Subject: [PATCH] more work on import geo image --- src/View/Results/CoordinatesDialog.py | 77 +++++++++++ src/View/Results/Window.py | 15 +- src/View/Results/translate.py | 7 +- src/View/ui/GeotiffCoordinates.ui | 188 +++++++++++++++++++++++++ src/lang/fr.ts | 192 +++++++++++++++++--------- 5 files changed, 408 insertions(+), 71 deletions(-) create mode 100644 src/View/Results/CoordinatesDialog.py create mode 100644 src/View/ui/GeotiffCoordinates.ui diff --git a/src/View/Results/CoordinatesDialog.py b/src/View/Results/CoordinatesDialog.py new file mode 100644 index 00000000..d6c8c191 --- /dev/null +++ b/src/View/Results/CoordinatesDialog.py @@ -0,0 +1,77 @@ +# ShiftDialog.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 . + +# -*- coding: utf-8 -*- + +from View.Tools.PamhyrWindow import PamhyrDialog +from PyQt5.QtWidgets import QDoubleSpinBox, QPushButton + + +class CoordinatesDialog(PamhyrDialog): + _pamhyr_ui = "GeotiffCoordinates" + _pamhyr_name = "ImageCoordinates" + + def __init__(self, x, y, trad=None, parent=None): + super(CoordinatesDialog, self).__init__( + title=trad[self._pamhyr_name], + trad=trad, + options=[], + parent=parent + ) + + self.spinbox = {} + self._init_default_values(x, y) + self.setup_connections() + + def _init_default_values(self, x, y): + self._x = x + self._y = y + self._values = {"bottom": x[0], + "top": x[1], + "left": y[0], + "right": y[1]} + self.spinbox = {} + for t in self._values: + self.spinbox[t] = self.find(QDoubleSpinBox, f"doubleSpinBox_{t}") + self.reset(t) + + def setup_connections(self): + for t in self._values: + self.find(QPushButton, + f"pushButton_{t}").clicked.connect(lambda state, x=t: self.reset(x)) + + def reset(self, t): + self.spinbox[t].setValue(self._values[t]) + + @property + def x(self): + return [self._values["bottom"], self._values["top"]] + + @property + def y(self): + return [self._values["left"], self._values["right"]] + + @property + def values(self): + return [self._values[t] for t in self._values] + + def accept(self): + for t in self._values: + self._values[t] = self.get_double_spin_box(f"doubleSpinBox_{t}") + super().accept() + + def reject(self): + self.close() diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index e2d389b7..a6d3a71b 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -68,7 +68,7 @@ from View.Results.translate import ( ResultsTranslate, CompareResultsTranslate ) -from View.Stricklers.Window import StricklersWindow +from View.Results.CoordinatesDialog import CoordinatesDialog _translate = QCoreApplication.translate @@ -1192,12 +1192,17 @@ class ResultsWindow(PamhyrWindow): # b[1] bottom # b[2] right # b[3] top - if b[2] < b[0] and b[1] < b[3]: + if b[2] > b[0] and b[1] < b[3]: self.canvas.axes.imshow(img.transpose((1, 2, 0)), extent=[b[0], b[2], b[1], b[3]]) else: - x = self.canvas.axes.get_xlim() - y = self.canvas.axes.get_ylim() - self.canvas.axes.imshow(img.transpose((1, 2, 0)), extent=[x[0], x[1], y[0], y[1]]) + dlg = CoordinatesDialog( + self.canvas.axes.get_xlim(), + self.canvas.axes.get_ylim(), + trad=self._trad, + parent=self + ) + if dlg.exec(): + self.canvas.axes.imshow(img.transpose((1, 2, 0)), extent=dlg.values) self.plot_xy.idle() diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index e7fe830d..343ddef4 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -53,9 +53,12 @@ class ResultsTranslate(MainTranslate): "Results", "Max water elevation" ) - self._dict["file_all"] = _translate("GeoTIFF", "All files (*)") + self._dict["file_all"] = _translate("Results", "All files (*)") self._dict["file_geotiff"] = _translate( - "GeoTIFF", "GeoTIFF file (*.tiff *.tif)") + "Results", "GeoTIFF file (*.tiff *.tif)") + self._dict["ImageCoordinates"] = _translate( + "Results", "Image coordinates" + ) self._sub_dict["table_headers_reach"] = { "name": _translate("Results", "Reach name"), diff --git a/src/View/ui/GeotiffCoordinates.ui b/src/View/ui/GeotiffCoordinates.ui new file mode 100644 index 00000000..3f69a53d --- /dev/null +++ b/src/View/ui/GeotiffCoordinates.ui @@ -0,0 +1,188 @@ + + + Dialog + + + + 0 + 0 + 451 + 206 + + + + Dialog + + + Qt::LeftToRight + + + + + + + + 4 + + + -99999999.000000000000000 + + + 99999999.000000000000000 + + + + + + + 4 + + + -99999999.000000000000000 + + + 99999999.000000000000000 + + + 1.000000000000000 + + + + + + + Bottom coordinate + + + + + + + Left coordinate + + + + + + + 4 + + + -99999999.000000000000000 + + + 99999999.000000000000000 + + + + + + + 4 + + + -99999999.000000000000000 + + + 99999999.000000000000000 + + + 1.000000000000000 + + + + + + + Top coordinate + + + + + + + true + + + Right coordinate + + + + + + + Reset + + + + + + + Reset + + + + + + + Reset + + + + + + + Reset + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/lang/fr.ts b/src/lang/fr.ts index 3c36b6cf..572186d2 100644 --- a/src/lang/fr.ts +++ b/src/lang/fr.ts @@ -1,5 +1,6 @@ - + + About @@ -944,6 +945,36 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.OK Ok + + + Bottom coordinate + Coordonnée bas + + + + Left coordinate + Coordonnée gauche + + + + Top coordinate + Coordonnée haut + + + + Right coordinate + Coordonnée droite + + + + Reset + Rétablir + + + + Image coordinates + Coordonnées de l'image + Documentation @@ -1235,14 +1266,9 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Version : @version @codename - - Copyright © 2022-2025 INRAE - Copyright © 2022-2025 INRAE - - Copyright © 2022-2025 INRAE - + Copyright © 2022-2025 INRAE @@ -1278,6 +1304,14 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Coefficient + + GeoTIFF + + + All files (*) + Tous les fichiers (*) + + Geometry @@ -1539,17 +1573,17 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie. MainWindow - + Open debug window Ouvrir la fenêtre de débogage - + Open SQLite debuging tool ('sqlitebrowser') Ouvrir l'outil de débogage SQLite ('sqlitebrowser') - + Enable this window Activer cette fenêtre @@ -1614,7 +1648,7 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Éditer la couche sédimentaire - + Ctrl+E Ctrl+E @@ -2104,17 +2138,17 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Hydrogramme - + Add customized visualization Ajouter une visualisation personnalisée - + Reload Recharger - + Export Exporter @@ -2394,12 +2428,12 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Maillage - + Summary Résumé - + Checks Vérifications @@ -2549,12 +2583,12 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Purger les profiles pour garder un nombre fixer de points - + Sort points Trier les points - + Export data as CSV Exporter les données au format CSV @@ -2619,47 +2653,47 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Données - + Please select a reach Veuillez sélectionner un bief - + Last open study Dernière étude ouverte - + Do you want to open again the last open study? Voulez-vous rouvrir la dernière étude ? - + This edition window need a reach selected into the river network to work on it Cette fenêtre d'édition a besoin d'un bief sélectionné dans le réseau pour travailler dessus - + Close without saving study Fermer sans sauvegarder l'étude - + Do you want to save current study before closing it? Souhaitez-vous sauvegarder l'étude en cours avant de la fermer ? - + Warning Avertissement - + X (m) X (m) - + Y (m) Y (m) @@ -2729,7 +2763,7 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Activer / Désactiver la sortie AdisTS - + Add a new point in boundary condition or punctual contribution Ajouter un nouveau point dans la condition limite @@ -2834,12 +2868,12 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Export données brutes - + Yes Oui - + No Non @@ -2848,6 +2882,16 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Compare results Comparaison de résultats + + + Geo tiff + Geo tiff + + + + <html><head/><body><p>Import Geo tiff image</p></body></html> + + MainWindow_reach @@ -3033,7 +3077,7 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.jour - + X (m) X (m) @@ -3068,27 +3112,27 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Lecture des résultats - + Water elevation Cote de l'eau - + Max water elevation Cote maximum de l'eau - + Reach name Nom du bief - + Profile Profil - + Bottom Fond @@ -3138,30 +3182,50 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Masse min - + Variables names Noms des variables - + Pollutant name Nom des polluants envelop - enveloppe + enveloppe - + Profile name Nom du profil - + Solver Solveur + + + Envelop + Enveloppe + + + + GeoTIFF file (*.tiff *.tif) + Fichiers GeoTIFF (*.tiff *.tif) + + + + Image coordinates + Coordonnées de l'image + + + + All files (*) + Tous les fichiers (*) + SedimentLayers @@ -3579,27 +3643,27 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Cote (m) - + Area (hectare) Aire (hectare) - + Time (sec) Temps (s) - + Time (JJJ:HH:MM:SS) Temps (JJJ:HH:MM:SS) - + Date (sec) Date (s) - + Date (ISO format) Date (format ISO) @@ -3624,17 +3688,17 @@ Cette fonctionnalité nécessite un bief muni d'une géométrie.Vitesse (m/s) - + Wet Perimeter (m) Périmètre mouillé (m) - + Hydraulic Radius (m) Rayon hydraulique (m) - + Froude number Nombre de Froude @@ -3757,52 +3821,52 @@ moyen droit (m) Vitesse min (m/s) - + Area Aire - + Rho Rho - + Porosity Porosité - + CDC_RIV CDC_RIV - + CDC_CAS CDC_CAS - + APD APD - + AC AC - + BC BC - + Concentration (g/l) Concentration (g/l) - + Mass (kg) Masse @@ -3827,27 +3891,27 @@ moyen droit (m) Débit - + Discharge Envelop Enveloppe du débit - + Max Discharge Débit max - + Min Discharge Débit min - + Concentration Concentration - + Wet Area Aire mouillée