From 87e8e17e917c4c1c4965dd775b21647a31c6411d Mon Sep 17 00:00:00 2001 From: Theophile Terraz Date: Tue, 14 May 2024 14:13:46 +0200 Subject: [PATCH] forgotten files --- src/View/Geometry/UpdateKPDialog.py | 143 ++++++++++++++++++++++++++++ src/View/ui/UpdateKPOptions.ui | 137 ++++++++++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 src/View/Geometry/UpdateKPDialog.py create mode 100644 src/View/ui/UpdateKPOptions.ui diff --git a/src/View/Geometry/UpdateKPDialog.py b/src/View/Geometry/UpdateKPDialog.py new file mode 100644 index 00000000..08abf1f4 --- /dev/null +++ b/src/View/Geometry/UpdateKPDialog.py @@ -0,0 +1,143 @@ +# MeshingDialog.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.QtGui import ( + QKeySequence, +) + +from PyQt5.QtCore import ( + Qt, QVariant, QAbstractTableModel, +) + +from PyQt5.QtWidgets import ( + QDialogButtonBox, QComboBox, QUndoStack, QShortcut, + QDoubleSpinBox, +) + + +class UpdateKPDialog(PamhyrDialog): + _pamhyr_ui = "UpdateKPOptions" + _pamhyr_name = "UpdateKP" + + def __init__(self, reach, trad=None, parent=None): + super(UpdateKPDialog, self).__init__( + title=trad[self._pamhyr_name], + trad=trad, + options=[], + parent=parent + ) + + self._reach = reach + self._profiles = None + + self._init_default_values() + + def _init_default_values(self): + self._space_step = 50.0 + self._lplan = False + self._lm = "3" + self._linear = False + self._begin_cs = -1 + self._end_cs = -1 + self._begin_dir = "un" + self._end_dir = "np" + self._origin = self._reach.profile(0) + self._origin_value = self._reach.profile(0).kp + + self._init_default_values_profiles() + self._init_default_values_guidelines() + + def _init_default_values_profiles(self): + profiles = self.profiles + + self.combobox_add_items("comboBox_origin", profiles) + + self.find(QComboBox, "comboBox_origin").currentIndexChanged.connect( + self.changed_profile) + + def changed_profile(self): + origin = self.get_combobox_text("comboBox_origin") + self.set_double_spin_box("doubleSpinBox_origin", + self._reach.profile(self.profiles.index(origin)).kp) + + @property + def profiles(self): + if self._profiles is None: + self._profiles = list( + map( + lambda p: self._profile_name(p), + self._reach.profiles + ) + ) + + return self._profiles + + def _profile_name(self, profile): + name = profile.name + + if name == "": + name = f"{profile.kp}" + else: + name += f" ({profile.kp})" + + return name + + def _init_default_values_guidelines(self): + gl, _ = self._reach.compute_guidelines() + gl = list(gl) + + bgl = ['un'] + gl + ['np'] + egl = ['un'] + gl + ['np'] + + self.combobox_add_items("comboBox_begin_gl", bgl) + self.combobox_add_items("comboBox_end_gl", egl) + + self.set_combobox_text("comboBox_begin_gl", self._begin_dir) + self.set_combobox_text("comboBox_end_gl", self._end_dir) + + @property + def origin(self): + return self._origin + + @property + def origin_value(self): + return self._origin_value + + @property + def begin_dir(self): + return self._begin_dir + + @property + def end_dir(self): + return self._end_dir + + def accept(self): + origin = self.get_combobox_text("comboBox_origin") + self._origin = self.profiles.index(origin) + + self._origin_value = self.get_double_spin_box("doubleSpinBox_origin") + + self._begin_dir = self.get_combobox_text("comboBox_begin_gl") + self._end_dir = self.get_combobox_text("comboBox_end_gl") + + super().accept() + + def reject(self): + self.close() diff --git a/src/View/ui/UpdateKPOptions.ui b/src/View/ui/UpdateKPOptions.ui new file mode 100644 index 00000000..881491ba --- /dev/null +++ b/src/View/ui/UpdateKPOptions.ui @@ -0,0 +1,137 @@ + + + Dialog + + + + 0 + 0 + 340 + 204 + + + + Dialog + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Distance computation + + + + + + true + + + + + + + true + + + Second guide-line + + + + + + + true + + + + + + + true + + + First guide-line + + + + + + + + + + Origin + + + + + + + Origin value + + + + + + + 4 + + + -99999999.000000000000000 + + + 99999999.000000000000000 + + + + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +