diff --git a/src/Meshing/Mage.py b/src/Meshing/Mage.py index 1e8f4c2d32f8d6f7a014d484219041881a93b1ea..4dc75a1dc65ce4e2b9fe12f8e4b4ab52907ca855 100644 --- a/src/Meshing/Mage.py +++ b/src/Meshing/Mage.py @@ -371,7 +371,8 @@ class MeshingWithMageMailleurTT(AMeshingTool): lplan: bool = False, lm: int = 3, linear: bool = False, - origin_value=0.0): + origin_value = 0.0, + orientation = 0): if reach is None or len(reach.profiles) == 0: return reach @@ -400,7 +401,7 @@ class MeshingWithMageMailleurTT(AMeshingTool): f"{str(step)} " + f"{limites[0]} {limites[1]} " + f"{directrices[0]} {directrices[1]} " + - f"{lplan} {lm} {linear} " + + f"{orientation} {lm} {linear} " + f"{origin} " ) proc.start( @@ -413,7 +414,7 @@ class MeshingWithMageMailleurTT(AMeshingTool): "update_kp", step, limites[0], limites[1], directrices[0], directrices[1], - lplan, lm, linear, origin, origin_value + orientation, lm, linear, origin, origin_value ] ) ) diff --git a/src/View/Geometry/UpdateKPDialog.py b/src/View/Geometry/UpdateKPDialog.py index b1b0b307876ea0c5514b9c2a29b582b416d9973b..548a87c1db654994ff2ee5fc27a619b902dfa2c9 100644 --- a/src/View/Geometry/UpdateKPDialog.py +++ b/src/View/Geometry/UpdateKPDialog.py @@ -28,7 +28,7 @@ from PyQt5.QtCore import ( from PyQt5.QtWidgets import ( QDialogButtonBox, QComboBox, QUndoStack, QShortcut, - QDoubleSpinBox, + QDoubleSpinBox, QButtonGroup, ) @@ -50,12 +50,7 @@ class UpdateKPDialog(PamhyrDialog): 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._orientation = 0 self._begin_dir = "un" self._end_dir = "np" self._origin = self._reach.profile(0) @@ -72,6 +67,15 @@ class UpdateKPDialog(PamhyrDialog): self.find(QComboBox, "comboBox_origin").currentIndexChanged.connect( self.changed_profile) + buttonbox = self.find(QButtonGroup, "buttonGroup_orientation") + + i = 0 + for button in buttonbox.buttons(): + if button.objectName() == "radioButton_0": i = 0 + if button.objectName() == "radioButton_1": i = 1 + if button.objectName() == "radioButton_2": i = 2 + buttonbox.setId(button, i) + def changed_profile(self): origin = self.get_combobox_text("comboBox_origin") self.set_double_spin_box( @@ -114,6 +118,10 @@ class UpdateKPDialog(PamhyrDialog): self.set_combobox_text("comboBox_begin_gl", self._begin_dir) self.set_combobox_text("comboBox_end_gl", self._end_dir) + @property + def orientation(self): + return self._orientation + @property def origin(self): return self._origin @@ -133,11 +141,10 @@ class UpdateKPDialog(PamhyrDialog): 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") + self._orientation = self.get_checked_id_button_group("buttonGroup_orientation") super().accept() diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 055ea8c31ae5050505d29776181cf8449068f3c1..ad5b0a23bbfdac4096812b9e0fd8aa387d3f7d1d 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -336,6 +336,7 @@ class GeometryWindow(PamhyrWindow): "origin": dlg.origin, "directrices": [dlg.begin_dir, dlg.end_dir], "origin_value": dlg.origin_value, + "orientation": dlg.orientation, } self._update_kp(data) except Exception as e: diff --git a/src/View/Tools/ASubWindow.py b/src/View/Tools/ASubWindow.py index 786553589d2a1f8a05369e51972975e8d79a6db4..2bbeca94b3fafa4af1f0cc582b69a3baec0f2b1b 100644 --- a/src/View/Tools/ASubWindow.py +++ b/src/View/Tools/ASubWindow.py @@ -35,7 +35,7 @@ from PyQt5.QtWidgets import ( QRadioButton, QComboBox, QFileDialog, QMessageBox, QTableView, QAction, QDateTimeEdit, QWidget, QPlainTextEdit, - QLabel, QDoubleSpinBox, + QLabel, QDoubleSpinBox, QButtonGroup, ) from PyQt5.QtCore import ( QTime, QDateTime, @@ -498,6 +498,17 @@ class ASubWindowFeatures(object): qdate = QDateTime.fromString(date.isoformat(), "yyyy-MM-ddThh:mm:ss") 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 diff --git a/src/View/ui/UpdateKPOptions.ui b/src/View/ui/UpdateKPOptions.ui index 881491bad9fac97dbf4c6a70017cf771630df7d1..0f5f1b88a5e90a09b3cd46079115d1851c6d4230 100644 --- a/src/View/ui/UpdateKPOptions.ui +++ b/src/View/ui/UpdateKPOptions.ui @@ -6,37 +6,23 @@ <rect> <x>0</x> <y>0</y> - <width>340</width> - <height>204</height> + <width>381</width> + <height>302</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </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"> @@ -47,11 +33,17 @@ </property> </widget> </item> - <item row="2" column="1"> - <widget class="QComboBox" name="comboBox_begin_gl"> - <property name="enabled"> - <bool>true</bool> + <item row="5" column="1"> + <widget class="QRadioButton" name="radioButton_1"> + <property name="text"> + <string>Upstream to downstream</string> </property> + <property name="checked"> + <bool>false</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup_orientation</string> + </attribute> </widget> </item> <item row="2" column="0"> @@ -67,6 +59,19 @@ <item row="0" column="1"> <widget class="QComboBox" name="comboBox_origin"/> </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> <item row="0" column="0"> <widget class="QLabel" name="label_3"> <property name="text"> @@ -74,6 +79,13 @@ </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="1" column="0"> <widget class="QLabel" name="label_4"> <property name="text"> @@ -81,22 +93,59 @@ </property> </widget> </item> - <item row="1" column="1"> - <widget class="QDoubleSpinBox" name="doubleSpinBox_origin"> - <property name="decimals"> - <number>4</number> + <item row="9" column="1"> + <widget class="QRadioButton" name="radioButton_2"> + <property name="text"> + <string>Downstream to upstream</string> </property> - <property name="minimum"> - <double>-99999999.000000000000000</double> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup_orientation</string> + </attribute> + </widget> + </item> + <item row="3" column="1"> + <widget class="QComboBox" name="comboBox_end_gl"> + <property name="enabled"> + <bool>true</bool> </property> - <property name="maximum"> - <double>99999999.000000000000000</double> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Orientation</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QRadioButton" name="radioButton_0"> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> </property> + <property name="text"> + <string>Keep current</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">buttonGroup_orientation</string> + </attribute> </widget> </item> </layout> </widget> </item> + <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> </layout> </widget> <resources/> @@ -134,4 +183,7 @@ </hints> </connection> </connections> + <buttongroups> + <buttongroup name="buttonGroup_orientation"/> + </buttongroups> </ui>