From 8ef86c61852197eb3a3ebd617c7e82188707329a Mon Sep 17 00:00:00 2001 From: Konstantin Leontev Date: Mon, 25 Mar 2024 19:11:15 +0000 Subject: [PATCH] [bos #38044][EDF] (2023-T3) Support for automatic reparation. Added sub-shapes line edit to a base dialog. --- src/RepairGUIAdv/basedlg.py | 45 ++++++++++++++++++- src/RepairGUIAdv/locate_subshapes.py | 63 ++------------------------- src/RepairGUIAdv/subshapes_basedlg.py | 2 + 3 files changed, 49 insertions(+), 61 deletions(-) diff --git a/src/RepairGUIAdv/basedlg.py b/src/RepairGUIAdv/basedlg.py index 1f92af5ed..484401886 100644 --- a/src/RepairGUIAdv/basedlg.py +++ b/src/RepairGUIAdv/basedlg.py @@ -35,7 +35,7 @@ from .basedlg_ui import Ui_BaseDlg from .geomrepairadv_execute import execute from .geomrepairadv_logger import logger from .geomrepairadv_common import DlgRef_1Sel_QTD, \ - GEOM_RESULT_NAME_GRP, NAME_LBL, GEOM_SELECTED_LBL, GEOM_SELECTED_SHAPE + GEOM_RESULT_NAME_GRP, NAME_LBL, GEOM_SELECTED_LBL, GEOM_SELECTED_SHAPE, GEOM_SELECTED_SUBSHAPE import GEOM class BaseDlg(Ui_BaseDlg, QWidget): @@ -94,6 +94,9 @@ class BaseDlg(Ui_BaseDlg, QWidget): self._selected_widget.TextLabel1.setText(GEOM_SELECTED_SHAPE) self._selected_widget.PushButton1.clicked.connect(self.on_select_object) + # A widget to show selected sub-shapes + self._sel_subshape_widget = self.create_sel_subshape_widget() + # Keep references to selected object and its temporary copy # that we need to pass for execution instead of original one. # TODO: decide if we really need to pass a copy. @@ -105,8 +108,9 @@ class BaseDlg(Ui_BaseDlg, QWidget): self.child_layout.setContentsMargins(0, 0, 0, 0) self.child_layout.addWidget(self._result_widget, 0, 0) self.child_layout.addWidget(self._selected_widget, 1, 0) + self.child_layout.addWidget(self._sel_subshape_widget, 2, 0) if child_widget: - self.child_layout.addWidget(child_widget, 2, 0) + self.child_layout.addWidget(child_widget, 3, 0) # Set basic button's actions self.buttonOk.clicked.connect(self.on_apply_close) @@ -133,6 +137,8 @@ class BaseDlg(Ui_BaseDlg, QWidget): self._sel_manager = salome_pyqt.getSelection() self._sel_connection = \ self._sel_manager.currentSelectionChanged.connect(self.on_select_object) + self._sel_subshape_connection = \ + self._sel_manager.currentSelectionChanged.connect(self.on_select_subshape) # Check if we already have selected object self.on_select_object() @@ -386,6 +392,40 @@ class BaseDlg(Ui_BaseDlg, QWidget): return True + def create_sel_subshape_widget(self): + """ + Returns a widget that lists preliminarily selected for processing sub_shapes. + + Args: + None. + + Returns: + A new widget. + """ + + sel_subshape_widget = DlgRef_1Sel_QTD() + sel_subshape_widget.TextLabel1.setText(GEOM_SELECTED_SUBSHAPE) + sel_subshape_widget.PushButton1.clicked.connect(self.on_select_subshape) + + return sel_subshape_widget + + + def on_select_subshape(self): + """ + Updates pre selected widget. + + Args: + None. + + Returns: + None. + """ + + selected_ids = self.get_local_selection() + selected_ids_str = ', '.join(str(id) for id in selected_ids) + self._sel_subshape_widget.LineEdit1.setText(selected_ids_str) + + def closeEvent(self, event): """ Overrides default close envent to reset selection level. @@ -395,6 +435,7 @@ class BaseDlg(Ui_BaseDlg, QWidget): # Clean up all selection changes self._sel_manager.currentSelectionChanged.disconnect(self._sel_connection) + self._sel_manager.currentSelectionChanged.disconnect(self._sel_subshape_connection) self.set_selection(None) diff --git a/src/RepairGUIAdv/locate_subshapes.py b/src/RepairGUIAdv/locate_subshapes.py index 2388cfdb8..21cc090a5 100644 --- a/src/RepairGUIAdv/locate_subshapes.py +++ b/src/RepairGUIAdv/locate_subshapes.py @@ -26,8 +26,7 @@ from qtsalome import QGridLayout, QFrame, QApplication, \ from salome.geom.geomrepairadv.basedlg import BaseDlg -from .geomrepairadv_common import DlgRef_1Spin_QTD, DlgRef_1Sel_QTD, \ - GEOM_SELECTED_SUBSHAPE +from .geomrepairadv_common import DlgRef_1Spin_QTD import GEOM class LocateSubShapesDlg(BaseDlg): @@ -49,9 +48,6 @@ class LocateSubShapesDlg(BaseDlg): self._type_widget.setToolTip('Select a type of shape measurement') self._type_widget.currentIndexChanged.connect(self.on_measurment_type_changed) - # A widget to show preliminarily selected sub-shapes - self._pre_selected_widget = self.create_pre_selected_widget() - # Min/max values widgets decimals = 2 max_value = sys.float_info.max @@ -65,10 +61,9 @@ class LocateSubShapesDlg(BaseDlg): # Add the widgets to layout layout.addWidget(type_label, 0, 0) layout.addWidget(self._type_widget, 1, 0) - layout.addWidget(self._pre_selected_widget, 2, 0) - layout.addWidget(self._min_widget, 3, 0) - layout.addWidget(self._max_widget, 4, 0) - layout.addWidget(self._select_button, 5, 0) + layout.addWidget(self._min_widget, 2, 0) + layout.addWidget(self._max_widget, 3, 0) + layout.addWidget(self._select_button, 4, 0) # Init base dialog BaseDlg.__init__( @@ -80,45 +75,6 @@ class LocateSubShapesDlg(BaseDlg): selection_level ) - # Connect selection manager from a base class - self._sel_subshape_connection = \ - self._sel_manager.currentSelectionChanged.connect(self.on_select_subshape) - - - def create_pre_selected_widget(self): - """ - Returns a widget that lists preliminarily selected for processing sub_shapes. - - Args: - None. - - Returns: - A new widget. - """ - - pre_sel_widget = DlgRef_1Sel_QTD() - pre_sel_widget.TextLabel1.setText(GEOM_SELECTED_SUBSHAPE) - pre_sel_widget.PushButton1.clicked.connect(self.on_select_subshape) - - return pre_sel_widget - - - def on_select_subshape(self): - """ - Updates pre selected widget. - - Args: - None. - - Returns: - None. - """ - - selected_ids = self.get_local_selection() - selected_ids_str = ', '.join(str(id) for id in selected_ids) - self._pre_selected_widget.LineEdit1.setText(selected_ids_str) - - def get_limits(self): """ @@ -218,17 +174,6 @@ class LocateSubShapesDlg(BaseDlg): return None - def closeEvent(self, event): - """ - Overrides default close envent to reset selection level. - """ - - super().closeEvent(event) - - # Clean up all selection changes - self._sel_manager.currentSelectionChanged.disconnect(self._sel_subshape_connection) - - # For testing run as a module from geomrepairadv parent directory in # Salome INSTALL, because the dialog needs a generated Ui_BaseDlg class # that we don't have in the SOURCE. diff --git a/src/RepairGUIAdv/subshapes_basedlg.py b/src/RepairGUIAdv/subshapes_basedlg.py index 7608a9cc9..e309fb909 100644 --- a/src/RepairGUIAdv/subshapes_basedlg.py +++ b/src/RepairGUIAdv/subshapes_basedlg.py @@ -43,6 +43,8 @@ class SubShapesBaseDlg(BaseDlg): # Precision widget self._precision_widget = DlgRef_1Spin_QTD('Precision', 0, 2, 100) + + # Add the widgets to layout layout.addWidget(self._precision_widget, 0, 0) BaseDlg.__init__( -- 2.39.2