mirror of https://gitlab.com/pamhyr/pamhyr2
forgotten files
parent
9e79178d0f
commit
87e8e17e91
|
|
@ -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 <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 (
|
||||||
|
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()
|
||||||
|
|
@ -0,0 +1,137 @@
|
||||||
|
<?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>340</width>
|
||||||
|
<height>204</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>Distance computation</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBox_end_gl">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Second guide-line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBox_begin_gl">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>First guide-line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBox_origin"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Origin</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Origin value</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBox_origin">
|
||||||
|
<property name="decimals">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<double>-99999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>99999999.000000000000000</double>
|
||||||
|
</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>
|
||||||
Loading…
Reference in New Issue